76#define DEV(major, minor) ((dev_t)(((major) & 0xFF) << 8) | ((minor) & 0xFF))
77#define DEV_MAJOR(dev) ((devid_t)(((dev) >> 8) & 0xFF))
78#define DEV_MINOR(dev) ((devid_t)(((dev) >> 0) & 0xFF))
79#define VNODE_DEV(vnode) ((struct devid){.type = (vnode)->mode & S_IFMT, .major = DEV_MAJOR((vnode)->rdev), .minor = DEV_MINOR((vnode)->rdev)})
int kdev_map(struct devid *dd, struct vm_space *vm_space, struct vm_entry *vm_entry)
Maps a device into an address space (mmap() of a framebuffer).
ssize_t kdev_file_close(struct devid *dd, struct file *file)
Closes an open device file, through its driver's file operations.
off_t kdev_file_lseek(struct devid *dd, struct file *file, off_t offset, int whence)
Moves an open device file's offset, through its driver's file operations.
void kdev_blkdev_register(devid_t major, struct dev *dev)
Registers a driver as the block device of a major number.
struct fops * kdev_fops(struct devid *dd)
Returns the file operations of a device.
int kdev_file_can_write(struct devid *dd, struct file *file, size_t size)
Asks a device's driver whether a write wouldn't have to wait.
int kdev_file_eof(struct devid *dd, struct file *file)
Asks a device's driver whether a read that found no data is at the end of the file.
ssize_t kdev_file_write(struct devid *dd, struct file *file, struct iobuf *io)
Writes to an open device file, through its driver's file operations.
ssize_t kdev_file_read(struct devid *dd, struct file *file, struct iobuf *io)
Reads an open device file, through its driver's file operations.
int kdev_file_ioctl(struct devid *dd, struct file *file, int request, void *argp)
Passes an ioctl() on an open device file to its driver's file operations.
ssize_t kdev_read(struct devid *dd, off_t offset, struct iobuf *io)
Reads from a device: a character device through its driver, a block device in blocks.
void kdev_chrdev_register(devid_t major, struct dev *dev)
Registers a driver as the character device of a major number.
int kdev_file_open(struct devid *dd, struct file *file)
Opens a device, through its driver's file operations.
int kdev_sync(void)
Writes what the block cache holds that was written, and what the block devices hold in their write ca...
int kdev_ioctl(struct devid *dd, int request, void *argp)
Passes an ioctl() to a device's driver.
int kdev_file_can_read(struct devid *dd, struct file *file, size_t size)
Asks a device's driver whether a read wouldn't have to wait.
ssize_t kdev_write(struct devid *dd, off_t offset, struct iobuf *io)
Writes to a device: a character device through its driver, a block device in blocks.
void kdev_init()
Starts the device layer, at boot.
A device driver: its operations, any of which may be NULL.
ssize_t(*) read(struct devid *dev, off_t offset, struct iobuf *io)
int(*) map(struct devid *dev, struct vm_space *vm_space, struct vm_entry *vm_entry)
ssize_t(*) write(struct devid *dev, off_t offset, struct iobuf *io)
size_t(*) getbs(struct devid *dev)
int(*) ioctl(struct devid *dev, int request, void *argp)
ssize_t(*) bread(struct devid *dev, off_t lba, size_t count, void *buf)
ssize_t(*) bwrite(struct devid *dev, off_t lba, size_t count, void *buf)
Which device: its kind (S_IFCHR or S_IFBLK) and numbers.
A framebuffer: its driver, its screen's information, its operations.
An open file (POSIX's "open file description", fs/file.c).
An open file's operations.
A mapping (map entry): a range of an address space, its permissions, and where its pages come from.
An address space: its mappings, and its page tables.