The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
device.c File Reference

flat device registry. More...

#include "device.h"
#include "common/string.h"
#include "kernel/sync/spinlock.h"

Macros

#define DEVICE_MAX   32

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.

Detailed Description

flat device registry.

a fixed array of device pointers, enough for the handful of devices ginnOS has today. drivers keep their own device_t storage; the registry only holds references so it can enumerate and look them up by name.

Macro Definition Documentation

◆ DEVICE_MAX

#define DEVICE_MAX   32

Function Documentation

◆ device_registry_init()

void device_registry_init ( void )

reset the device registry.

call once during early boot.

◆ device_register()

bool device_register ( device_t * dev)

register a device.

the device_t is owned by the caller and must outlive its registration (drivers use static or long-lived storage).

Parameters
devthe device to add.
Returns
true on success, false if the registry is full or dev is invalid.

◆ device_count()

uint32_t device_count ( void )

number of currently registered devices.

◆ device_get()

device_t * device_get ( uint32_t index)

get a registered device by index (0 .

. device_count()-1).

Returns
the device, or NULL if the index is out of range.

◆ device_find()

device_t * device_find ( const char * name)

find a registered device by name.

Returns
the device, or NULL if no device has that name.