|
ginnOS
The reference: libc, the libraries and the kernel
|
generic device model: a named/typed handle plus a registry. More...
Go to the source code of this file.
Data Structures | |
| struct | device_ops_t |
| optional per-device operations. More... | |
| struct | device |
| a registered device. More... | |
Macros | |
| #define | DEVICE_NAME_MAX 16 |
| #define | DEVICE_NUMBER(major, minor) |
| a device number from its major and minor numbers, packed as Linux and the libc's makedev (sys/sysmacros.h) pack them. | |
Typedefs | |
| typedef struct device | device_t |
Enumerations | |
| enum | device_type_t { DEVICE_TYPE_UNKNOWN = 0 , DEVICE_TYPE_BLOCK , DEVICE_TYPE_CHAR , DEVICE_TYPE_INPUT , DEVICE_TYPE_TIMER } |
Functions | |
| void | device_registry_init (void) |
| reset the device registry. | |
| bool | device_register (device_t *dev) |
| register a device. | |
| uint32_t | device_count (void) |
| number of currently registered devices. | |
| device_t * | device_get (uint32_t index) |
| get a registered device by index (0 . | |
| device_t * | device_find (const char *name) |
| find a registered device by name. | |
generic device model: a named/typed handle plus a registry.
drivers wrap their concrete device in a device_t and register it here during init, so the rest of the kernel has one place to enumerate what hardware is present. this is the groundwork for a future devfs that surfaces registered devices as /dev/hda, /dev/tty0, and so on.
the model intentionally stays thin: it does not replace the driver-specific init flow (which has its own ordering), it just records the result.
| #define DEVICE_NAME_MAX 16 |
a device number from its major and minor numbers, packed as Linux and the libc's makedev (sys/sysmacros.h) pack them.
ginnOS uses Linux's numbers for the terminals: tty0 4:0, ptmx 5:2, pts/N 136:N.
| enum device_type_t |
| void device_registry_init | ( | void | ) |
reset the device registry.
call once during early boot.
register a device.
the device_t is owned by the caller and must outlive its registration (drivers use static or long-lived storage).
| dev | the device to add. |
| uint32_t device_count | ( | void | ) |
number of currently registered devices.
get a registered device by index (0 .
. device_count()-1).
| device_t * device_find | ( | const char * | name | ) |
find a registered device by name.