|
AquilaOS documentation
How it works, and its code
|
#include <core/system.h>#include <mm/vm.h>#include <fs/vfs.h>#include <sys/proc.h>#include <fs/iobuf.h>Go to the source code of this file.
Data Structures | |
| struct | devid |
| Which device: its kind (S_IFCHR or S_IFBLK) and numbers. More... | |
| struct | dev |
| A device driver: its operations, any of which may be NULL. More... | |
Macros | |
| #define | DEV(major, minor) |
| #define | DEV_MAJOR(dev) |
| #define | DEV_MINOR(dev) |
| #define | VNODE_DEV(vnode) |
Functions | |
| void | kdev_init (void) |
| Starts the device layer, at boot. | |
| void | kdev_chrdev_register (devid_t major, struct dev *dev) |
| Registers a driver as the character device of a major number. | |
| void | kdev_blkdev_register (devid_t major, struct dev *dev) |
| Registers a driver as the block device of a major number. | |
| int | kdev_sync (void) |
| Writes what the block cache holds that was written, and what the block devices hold in their write caches, to the media. | |
| 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. | |
| 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. | |
| int | kdev_ioctl (struct devid *dd, int request, void *argp) |
| Passes an ioctl() to a device's driver. | |
| 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). | |
| struct fops * | kdev_fops (struct devid *dd) |
| Returns the file operations of a device. | |
| int | kdev_file_open (struct devid *dd, struct file *file) |
| Opens a device, 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. | |
| 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. | |
| 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. | |
| ssize_t | kdev_file_close (struct devid *dd, struct file *file) |
| Closes 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. | |
| 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. | |
| 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. | |
Variables | |
| struct dev | ttydev |
| struct dev | pcidev |
| struct dev | atadev |
| struct dev | fbdev |
| struct dev | rddev |
| #define DEV | ( | major, | |
| minor ) |
Definition at line 76 of file dev.h.
Referenced by ext2_inode_build(), ext2_vmknod(), kmain(), load_ramdisk(), minix_vmknod(), ptm_new(), pts_new(), root_dev(), and tty_open().
| #define DEV_MAJOR | ( | dev | ) |
Definition at line 77 of file dev.h.
Referenced by ext2_vmknod(), minix_vmknod(), vt_file_close(), and vt_file_open().
| #define DEV_MINOR | ( | dev | ) |
Definition at line 78 of file dev.h.
Referenced by ext2_vmknod(), minix_vmknod(), uart_can_read(), uart_file_eof(), uart_file_open(), uart_read_timeout(), vt_file_close(), and vt_file_open().
| #define VNODE_DEV | ( | vnode | ) |
Definition at line 79 of file dev.h.
Referenced by ctty_open(), posix_file_read(), ptm_can_read(), pts_can_read(), pts_eof(), pts_open(), pts_read_timeout(), vfs_file_can_read(), vfs_file_can_write(), vfs_file_close(), vfs_file_eof(), vfs_file_ioctl(), vfs_file_lseek(), vfs_file_open(), vfs_file_read(), vfs_file_write(), vfs_ioctl(), vfs_map(), vfs_read_io(), vfs_write_io(), and vt_file().
Registers a driver as the block device of a major number.
A driver registered before for that major is replaced.
| major | the major number |
| dev | the driver |
Definition at line 605 of file kdev.c.
References blkdev, kdev_blkdev_register(), dev::name, and printk().
Referenced by ata_probe(), kdev_blkdev_register(), and rd_probe().
Registers a driver as the character device of a major number.
A driver registered before for that major is replaced.
| major | the major number |
| dev | the driver |
Definition at line 575 of file kdev.c.
References chrdev, kdev_chrdev_register(), dev::name, and printk().
Referenced by fbdev_probe(), kdev_chrdev_register(), memdev_probe(), ps2mouse_probe(), pty_init(), ttydev_probe(), and vt_probe().
Asks a device's driver whether a read wouldn't have to wait.
| dd | the device's number |
| file | the open file |
| size | how much would be read |
Definition at line 513 of file kdev.c.
References fops::can_read, dev::fops, kdev_file_can_read(), kdev_get(), and NULL.
Referenced by kdev_file_can_read(), and vfs_file_can_read().
Asks a device's driver whether a write wouldn't have to wait.
| dd | the device's number |
| file | the open file |
| size | how much would be written |
Definition at line 534 of file kdev.c.
References fops::can_write, dev::fops, kdev_file_can_write(), kdev_get(), and NULL.
Referenced by kdev_file_can_write(), and vfs_file_can_write().
Closes an open device file, through its driver's file operations.
| dd | the device's number |
| file | the open file |
Definition at line 468 of file kdev.c.
References fops::close, dev::fops, kdev_file_close(), kdev_get(), NULL, and posix_file_close().
Referenced by kdev_file_close(), and vfs_file_close().
Asks a device's driver whether a read that found no data is at the end of the file.
| dd | the device's number |
| file | the open file |
Definition at line 555 of file kdev.c.
References fops::eof, dev::fops, kdev_file_eof(), kdev_get(), and NULL.
Referenced by kdev_file_eof(), and vfs_file_eof().
Passes an ioctl() on an open device file to its driver's file operations.
| dd | the device's number |
| file | the open file |
| request | the request |
| argp | its argument |
Definition at line 492 of file kdev.c.
References dev::fops, fops::ioctl, kdev_file_ioctl(), kdev_get(), and NULL.
Referenced by kdev_file_ioctl(), and vfs_file_ioctl().
Moves an open device file's offset, through its driver's file operations.
| dd | the device's number |
| file | the open file |
| offset | the offset |
| whence | what it is from (SEEK_SET, SEEK_CUR, SEEK_END) |
Definition at line 447 of file kdev.c.
References dev::fops, kdev_file_lseek(), kdev_get(), fops::lseek, and NULL.
Referenced by kdev_file_lseek(), and vfs_file_lseek().
Opens a device, through its driver's file operations.
| dd | the device's number |
| file | the open file |
Definition at line 381 of file kdev.c.
References dev::fops, kdev_file_open(), kdev_get(), NULL, and fops::open.
Referenced by ctty_open(), kdev_file_open(), and vfs_file_open().
Reads an open device file, through its driver's file operations.
| dd | the device's number |
| file | the open file |
| io | where to put what is read |
Definition at line 402 of file kdev.c.
References dev::fops, kdev_file_read(), kdev_get(), NULL, and fops::read.
Referenced by kdev_file_read(), and vfs_file_read().
Writes to an open device file, through its driver's file operations.
| dd | the device's number |
| file | the open file |
| io | what to write |
Definition at line 423 of file kdev.c.
References dev::fops, kdev_file_write(), kdev_get(), NULL, and fops::write.
Referenced by kdev_file_write(), and vfs_file_write().
Returns the file operations of a device.
| dd | the device's number |
Definition at line 52 of file kdev.c.
References dev::fops, kdev_fops(), kdev_get(), and NULL.
Referenced by kdev_fops(), and posix_file_read().
| void kdev_init | ( | void | ) |
Starts the device layer, at boot.
It has nothing to set up: the drivers register themselves.
Definition at line 615 of file kdev.c.
References kdev_init(), and printk().
Referenced by kdev_init(), and kmain().
| int kdev_ioctl | ( | struct devid * | dd, |
| int | request, | ||
| void * | argp ) |
Passes an ioctl() to a device's driver.
| dd | the device's number |
| request | the request |
| argp | its argument |
Definition at line 340 of file kdev.c.
References dev::ioctl, kdev_get(), kdev_ioctl(), and NULL.
Referenced by kdev_ioctl(), and vfs_ioctl().
Maps a device into an address space (mmap() of a framebuffer).
| dd | the device's number |
| vm_space | the address space |
| vm_entry | the mapping |
Definition at line 361 of file kdev.c.
References kdev_get(), kdev_map(), dev::map, and NULL.
Referenced by kdev_map(), and vfs_map().
Reads from a device: a character device through its driver, a block device in blocks.
| dd | the device's number |
| offset | where to read from, in bytes |
| io | where to put what is read |
Definition at line 297 of file kdev.c.
References dev::bread, kdev_blk_io(), kdev_get(), kdev_read(), NULL, dev::read, and devid::type.
Referenced by kdev_read(), and vfs_read_io().
| int kdev_sync | ( | void | ) |
Writes what the block cache holds that was written, and what the block devices hold in their write caches, to the media.
Definition at line 587 of file kdev.c.
References blkcache_flush(), blkdev, kdev_sync(), and dev::sync.
Referenced by kdev_sync(), kernel_reboot(), and sys_sync().
Writes to a device: a character device through its driver, a block device in blocks.
| dd | the device's number |
| offset | where to write, in bytes |
| io | what to write |
Definition at line 319 of file kdev.c.
References dev::bwrite, kdev_blk_io(), kdev_get(), kdev_write(), NULL, devid::type, and dev::write.
Referenced by kdev_write(), and vfs_write_io().
|
extern |
Definition at line 592 of file ata.c.
Referenced by ata_probe().