docs (drivers): documented driver structure and API
This commit is contained in:
parent
3b7eeb6460
commit
b455532316
|
@ -0,0 +1,72 @@
|
|||
# NOXOS Drivers API
|
||||
|
||||
The API is directly baked into the kernel.
|
||||
The [libnxdrv](https://git.nerdcult.net/noxos/libraries/src/branch/master/libnxdrv) library provides dummies which can be (dynamically) linked into the driver.
|
||||
|
||||
All API calls are prefixed with `nx_drv_`.
|
||||
|
||||
# API
|
||||
## Config
|
||||
|
||||
### struct `nx_drv_device_id_T`
|
||||
This struct is used to identify PCI and USB devices.
|
||||
|
||||
| Name | Type | Description |
|
||||
|-----------|----------|-------------------------|
|
||||
| vendor_id | uint16_t | The devices vendors' ID |
|
||||
| device_id | uint16_t | The devices' ID |
|
||||
|
||||
|
||||
### struct `nx_drv_config_pci_T`
|
||||
|
||||
| Name | Type | Description |
|
||||
|----------------|---------------------------------------|------------------------------------------------------|
|
||||
| enable_progif | bool | If set to false, the `progif` field will be ignored. |
|
||||
| class | uint8_t | The PCI main class of the supported devices. |
|
||||
| subclass | uint8_t | The PCI subclass of the supported devices. |
|
||||
| progif | uint8_t | The PCI progif of the supported devices. |
|
||||
| num_device_ids | uint16_t | The size of the `device_ids` field. |
|
||||
| device_ids | nx_drv_device_id_T [`num_device_ids`] | An array of device ids that the driver supports. |
|
||||
|
||||
|
||||
### struct `nx_drv_config_usb_T`
|
||||
|
||||
| Name | Type | Description |
|
||||
|----------------|---------------------------------------|---------------------------------------------------|
|
||||
| min_version | uint8_t | The minimum required version of the USB standard. |
|
||||
| num_device_ids | uint16_t | The size of the `device_ids` field. |
|
||||
| device_ids | nx_drv_device_id_T [`num_device_ids`] | An array of device ids that the driver supports. |
|
||||
|
||||
|
||||
### struct `nx_drv_config_fs_T`
|
||||
|
||||
| Name | Type | Description |
|
||||
|----------|--------------|---------------------------------------------------------------|
|
||||
| gpt_guid | uint8_t [16] | The GPT type GUID of the filesystem that the driver supports. |
|
||||
| mbr_type | uint8_t | The MBR type of the filesystem that the driver supports. |
|
||||
|
||||
|
||||
### func - void `nx_drv_pci_config(nx_drv_config_pci_T* config)`
|
||||
Applies the pci configuration `config`.
|
||||
|
||||
This function should be called in the init function, when the driver handles PCI devices.
|
||||
|
||||
|
||||
### func - void `nx_drv_usb_config(nx_drv_config_usb_T* config)`
|
||||
Applies the usb configuration `config`.
|
||||
|
||||
This function should be called in the init function, when the driver handles USB devices.
|
||||
|
||||
|
||||
### func - void `nx_drv_fs_config(nx_drv_config_fs_T* config)`
|
||||
Applies the fs configuration `config`.
|
||||
|
||||
This function should be called in the init function, when the driver handles a filesystem.
|
||||
|
||||
---
|
||||
|
||||
## Miscellaneous
|
||||
|
||||
### func - void `nx_drv_log(const char* string)`
|
||||
Logs `string`.
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
# Drivers
|
||||
This is the documentation for the driver interface, not for the 'drivers' repo.
|
||||
|
||||
Drivers are ELF executables which are dynamically linked into the kernel at runtime.
|
||||
A Driver can assign itself to PCI and USB devices or a Filesystem.
|
||||
PCI and USB device bindings are identified by their vendor and device ID.
|
||||
A Filesystem binding is identified by its MBR type and GPT type GUID.
|
||||
|
||||
# Driver structure
|
||||
## Initialization
|
||||
A driver needs to have a function `void _init()` that will be called by the kernel when loading the driver.
|
||||
This function should handle the following things:
|
||||
- Load one or more __*configurations*__ (see API docs for more details)
|
||||
- Register __*handlers*__ (see API docs for more details)
|
||||
- Everything else the driver needs to initialize to be fully ready to be used (devices, etc.)
|
||||
|
||||
## API
|
||||
Drivers communicate with the kernel using a runtime API.
|
||||
The documentation can be found [here](https://git.nerdcult.net/noxos/documentation/src/branch/master/drivers/API.md).
|
||||
|
||||
## Handlers
|
||||
Drivers can register handler functions,
|
||||
that are called by the kernel when handling an action for an assigned device or filesystem.
|
||||
The documentation can be found [here](https://git.nerdcult.net/noxos/documentation/src/branch/master/drivers/handlers.md).
|
|
@ -0,0 +1,3 @@
|
|||
# Handlers
|
||||
|
||||
TODO: plan handlers
|
Loading…
Reference in New Issue