|
My Kernel v0.1.0
|
Driver API. More...

Data Structures | |
| struct | device_driver |
| The basic device driver structure. More... | |
Macros | |
| #define | DECLARE_DRIVER(_name, _driver, _driver_register) |
| Declare a new driver. More... | |
Functions | |
| void | driver_register (driver_t *driver) |
| Register a new driver. More... | |
| void | driver_load_drivers (void) |
| Load all builtin drivers. More... | |
| driver_t * | driver_find_match (device_t *) |
| Retreive the driver that matches the given arguments. More... | |
This file describes the driver part of the Device/Driver API.
When creating a new driver, you MUST declare it using DECLARE_DRIVER. All drivers declared using this macro are automatically loaded when starting up the kernel.
The kernel automatically detects and keeps track of all the connected hardware devices. When a new device is detected, its corresponding driver is looked for inside this list of loaded drivers. If a match is found, the matching driver's probe function is called to create the correct type of device, and register it.
Drivers for devices on a same bus generally share some similarities, at least in the way the are interacted with. The driver struct should be embedded inside a more specific 'per-bus' struct and interacted with through the bus's API.
| #define DECLARE_DRIVER | ( | _name, | |
| _driver, | |||
| _driver_register | |||
| ) |
Drivers declared using this macro are automatically loaded at startup, and are automatically associated with their corresponding devices.
| _name | The name of the driver |
| _driver | The driver's definition (device_driver) |
| _driver_register | The per-bus API register function |
| void driver_load_drivers | ( | void | ) |
Builtin drivers are ones declared using DECLARE_DRIVER
| void driver_register | ( | driver_t * | driver | ) |
This function adds the driver to the list of enumeratable drivers. It should always be called inside a per-bus API's register function as this step is bus-independent (and required).
After a driver has been registerd, any newly detected device that it matches will automatically be bound to it using the probe function.
@info This function is generally called automatically during startup on the declared drivers, and should not need to be called manually elsewhere.