driver.mgr¶
Driver registration and device management for the Asuro driver framework.
Overview¶
This unit implements the central driver manager. It maintains a list of registered drivers and a list of discovered devices. When a device is registered, the manager scans all registered drivers for an identifier match and invokes the matched driver's load callback. Terminal commands are provided to inspect registered drivers and devices at runtime.
Dependencies¶
driver.typesterminalsyslog
Constants¶
idANY¶
Value: $FFFFFFFF. Wildcard value for any field of a TDeviceIdentifier. A driver using idANY in a given identifier field will match any device value in that field.
Types¶
TBusIdentifier¶
Enumeration of supported bus types used to classify devices during registration.
| Value | Description |
|---|---|
biUnknown |
Unknown or unclassified bus |
biPCI |
PCI bus |
biUSB |
USB bus |
bii2c |
I2C bus |
biPCIe |
PCI Express bus |
biANY |
Matches any bus type |
TDevEx¶
A linked-list node for extended device identifiers. Allows drivers to specify additional identifier fields beyond the base four.
| Field | Type | Description |
|---|---|---|
id |
uint32 |
Extended identifier value |
Next |
^TDevEx |
Pointer to next node, or nil |
TDeviceIdentifier¶
Uniquely identifies a class of device. Used by both driver registration (what devices the driver handles) and device registration (what device was discovered).
| Field | Type | Description |
|---|---|---|
bus |
TBusIdentifier |
Bus type |
id0..id3 |
uint32 |
Primary identifier fields |
Extended |
^TDevEx |
Optional linked list of additional identifiers |
TDriverRegistration¶
Represents a registered driver entry.
| Field | Type | Description |
|---|---|---|
Identifier |
TDeviceIdentifier |
The device pattern this driver handles |
Driver_Load |
procedure(ptr: pointer) |
Callback invoked when a matching device is found |
Name |
string |
Human-readable driver name |
TDeviceRegistration¶
Represents a registered device entry.
| Field | Type | Description |
|---|---|---|
Identifier |
TDeviceIdentifier |
The identifier of the discovered device |
Ptr |
pointer |
Opaque pointer to device-specific data passed to the driver load callback |
Functions and Procedures¶
init¶
Initialises the driver manager. Must be called before any registration functions.register_driver¶
procedure register_driver(Identifier: TDeviceIdentifier; Driver_Load: TDriverLoadProc; Name: string);
Driver_Load is called with the device pointer.
register_driver_ex¶
procedure register_driver_ex(Identifier: TDeviceIdentifier; Driver_Load: TDriverLoadProc; Name: string; force_load: boolean);
force_load is true, Driver_Load is called immediately regardless of whether a matching device is present. Used by drivers that self-initialise without waiting for device discovery (e.g. bus scanners, PS/2 controllers).
register_device¶
Registers a discovered device. Iterates all registered drivers, callsidentifiers_match for each, and invokes the first matching driver's Driver_Load with Ptr.
terminal_command_dev¶
Terminal command handler for thedev command. Subcommands:
- dev drivers — lists all registered drivers with their identifier fields
- dev devices — lists all registered devices
- dev driverex — lists drivers with extended identifier chains
Notes¶
- Identifier matching treats
idANY($FFFFFFFF) in a driver's field as a wildcard that matches any value in the corresponding device field. - The bus field is compared directly;
biANYin the driver identifier matches any bus type. - Extended identifiers in
TDevExchains are matched in order; the chain length must be equal between driver and device identifiers for a full match. - Only the first matching driver is invoked per
register_devicecall.