|
ginnOS
The reference: libc, the libraries and the kernel
|
optional per-device operations. More...
#include </home/runner/work/ginnOS-docs/ginnOS-docs/ginnOS/src/kernel/device/device.h>
Data Fields | |
| void(*) | shutdown (device_t *dev) |
| int32_t(*) | ioctl (device_t *dev, uint32_t request, void *arg) |
| device-specific control operation, the transport for ioctl(2)-style requests (e.g. | |
| int32_t(*) | mmap (device_t *dev, addr_space_t as, uintptr_t virt, size_t length, int prot, uint64_t offset) |
| map the device's memory into a process address space (optional; NULL means the device is not mappable, i.e. | |
| uint32_t(*) | read (device_t *dev, uint64_t offset, void *buf, uint32_t len) |
| byte-oriented read at an explicit offset (optional; NULL means the device is not readable). | |
| uint32_t(*) | write (device_t *dev, uint64_t offset, const void *buf, uint32_t len) |
| byte-oriented write at an explicit offset (optional; NULL means the device is not writable). | |
| uint64_t(*) | size (device_t *dev) |
| total byte size of the device's addressable memory (optional; NULL means unknown/zero). | |
| kerr_t(*) | open (device_t *dev, uint32_t flags, struct file **out) |
| open the device as a stream of its own (optional). | |
optional per-device operations.
all fields may be NULL; the model does not require any of them. concrete device families extend behaviour through their own interfaces (block_device_t, tty_t, ...) and use this only for lifecycle.
| void(*) device_ops_t::shutdown(device_t *dev) |
device-specific control operation, the transport for ioctl(2)-style requests (e.g.
the framebuffer's FBIOGET_VSCREENINFO). optional: a NULL hook means the device supports no ioctls.
| dev | the device. |
| request | driver-defined request code. |
| arg | request-specific argument (often a user pointer, already bounds-checked by the syscall layer before it reaches here). |
| int32_t(*) device_ops_t::mmap(device_t *dev, addr_space_t as, uintptr_t virt, size_t length, int prot, uint64_t offset) |
map the device's memory into a process address space (optional; NULL means the device is not mappable, i.e.
-ENODEV). the device maps its own frames at virt in as; the caller (SYS_mmap) has already reserved the virtual range and validated it. eager mapping, no demand paging. the frames are device memory (outside PMM), so process teardown leaves them alone.
| dev | the device. |
| as | the target process's address space. |
| virt | page-aligned destination virtual address. |
| length | number of bytes to map (page-multiple). |
| prot | PROT_* protection bits. |
| offset | byte offset into the device memory (page-aligned). |
byte-oriented read at an explicit offset (optional; NULL means the device is not readable).
the caller (devfs) owns the cursor and passes it in.
byte-oriented write at an explicit offset (optional; NULL means the device is not writable).
total byte size of the device's addressable memory (optional; NULL means unknown/zero).
used for read clamping and lseek(SEEK_END).
open the device as a stream of its own (optional).
when set, open(2) of the /dev node gives the file this hook makes, with the device's own file operations (blocking, O_NONBLOCK, poll, a release when the last descriptor closes), and read, write and ioctl above are not used for it.
| dev | the device. |
| flags | the O_ access mode and status flags of the open. |
| out | receives the new open-file description. |