《操作系统》的实验代码。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
925 B

12 years ago
  1. #ifndef __KERN_FS_DEVS_DEV_H__
  2. #define __KERN_FS_DEVS_DEV_H__
  3. #include <defs.h>
  4. struct inode;
  5. struct iobuf;
  6. /*
  7. * Filesystem-namespace-accessible device.
  8. * d_io is for both reads and writes; the iobuf will indicates the direction.
  9. */
  10. struct device {
  11. size_t d_blocks;
  12. size_t d_blocksize;
  13. int (*d_open)(struct device *dev, uint32_t open_flags);
  14. int (*d_close)(struct device *dev);
  15. int (*d_io)(struct device *dev, struct iobuf *iob, bool write);
  16. int (*d_ioctl)(struct device *dev, int op, void *data);
  17. };
  18. #define dop_open(dev, open_flags) ((dev)->d_open(dev, open_flags))
  19. #define dop_close(dev) ((dev)->d_close(dev))
  20. #define dop_io(dev, iob, write) ((dev)->d_io(dev, iob, write))
  21. #define dop_ioctl(dev, op, data) ((dev)->d_ioctl(dev, op, data))
  22. void dev_init(void);
  23. struct inode *dev_create_inode(void);
  24. #endif /* !__KERN_FS_DEVS_DEV_H__ */