PebbleOS v4.47.0-1075-g013613c8a
Loading...
Searching...
No Matches
device.h File Reference
#include <stddef.h>
#include <stdint.h>
#include <pbl/kernel/compiler.h>
#include <pbl/kernel/section.h>

Data Structures

struct  pbl_device_state
 Runtime state of a device. More...
 
struct  pbl_device_class
 A device class. More...
 
struct  pbl_device
 A hardware device. More...
 
struct  pbl_mem_region
 Memory region reserved for a device, what a devicetree memory-region entry points to (a reserved-memory node). More...
 
struct  pbl_device_depends
 Devices that device dev needs, on top of its parent. More...
 

Macros

#define PBL_DEVICE_CLASS_DEFINE(sym, _name)   const struct pbl_device_class sym = {.name = (_name)}
 Define a device class.
 
#define PBL_MEM_REGION(_base, _size)   {.base = (_base), .size = (_size)}
 Initializer of a struct pbl_mem_region.
 
#define PBL_DEVICE_DEPS(...)   ((const struct pbl_device *const[]){__VA_ARGS__, nullptr})
 Static NULL-terminated list of devices.
 
#define PBL_DEVICE_STATE_DEFINE(sym)   static struct pbl_device_state sym##_device_state
 Define the runtime state of device instance sym.
 
#define PBL_DEVICE_INIT_CLASS(sym, _name, _init, _parent, _cls)
 Initializer for the struct pbl_device of device instance sym, in class _cls.
 
#define PBL_DEVICE_INIT(sym, _name, _init, _parent)    PBL_DEVICE_INIT_CLASS(sym, _name, _init, _parent, nullptr)
 Initializer for the struct pbl_device of device instance sym.
 
#define PBL_DEVICE_REGISTER(sym, dev)
 Add a device to the table pbl_device_init_all() walks.
 
#define PBL_DEVICE_DEPENDS(sym, _dev, ...)
 List devices a device needs, without touching its definition.
 
#define PBL_DEVICE_ALIAS(sym, inst, type, class_type, member)
 Give an instance a second name with the type of its class, for code that does not know the driver.
 
#define PBL_DEVICE_INSTANCE(sym, type, class_type, member)
 Start the definition of a registered instance, followed by its initializer.
 
#define PBL_DEVICE_INSTANCE_DEV(sym, type)
 Start the definition of a registered instance of a device in no class, followed by its initializer.
 
#define PBL_DEVICE_CLASS_FOREACH(_cls, _dev)
 Iterate over the registered devices of a class.
 

Enumerations

enum  pbl_device_status { PBL_DEVICE_UNINIT , PBL_DEVICE_INITIALIZING , PBL_DEVICE_READY , PBL_DEVICE_FAILED }
 Device status. More...
 

Functions

int pbl_device_init (const struct pbl_device *dev)
 Initialize a device, its parent and the devices of its PBL_DEVICE_DEPENDS() first.
 
bool pbl_device_is_ready (const struct pbl_device *dev)
 Check whether a device is initialized.
 
int pbl_device_init_all (void)
 Initialize every registered device.
 
int pbl_device_init_children (const struct pbl_device *parent)
 Initialize every registered device whose parent is parent.
 
static const char * pbl_device_name (const struct pbl_device *dev)
 Get the name of a device.