6#include "dawn/io/handler.hxx"
17#include "dawn/debug.hxx"
18#include "dawn/io/common.hxx"
20#ifdef CONFIG_DAWN_IO_CONFIG
21# include "dawn/io/config.hxx"
24#ifdef CONFIG_DAWN_IO_CONTROL
25# include "dawn/io/control.hxx"
28#ifdef CONFIG_DAWN_IO_TRIGGER
29# include "dawn/io/trigger.hxx"
32#ifdef CONFIG_DAWN_IO_DESCRIPTOR
33# include "dawn/io/descriptor.hxx"
36#ifdef CONFIG_DAWN_INSPECT
37# include "dawn/dev/inspector.hxx"
54 DAWNERR(
"Failed to create IO object 0x%" PRIx32
"\n", desc.
getObjectIdV());
55 t.allocError = -ENOMEM;
59 DAWNINFO(
"created IO: 0x%" PRIx32
" %p\n", desc.
getObjectIdV(), tmp);
74 if (userFactory !=
nullptr)
76 ret = userFactory->
create(desc);
83 return factory.
create(desc);
101 ret = objalloc(desc);
107#ifdef CONFIG_DAWN_INSPECT
119#ifdef CONFIG_DAWN_IO_NOTIFY
126#ifdef CONFIG_DAWN_IO_NOTIFY
161#ifdef CONFIG_DAWN_IO_NOTIFY
186#if defined(CONFIG_DAWN_IO_CONFIG) || defined(CONFIG_DAWN_IO_CONTROL) || \
187 defined(CONFIG_DAWN_IO_TRIGGER)
218 DAWNERR(
"invalid object type for ID 0x%" PRIx32
"\n",
id);
225 DAWNERR(
"object not found for ID 0x%" PRIx32
"\n",
id);
234#if defined(CONFIG_DAWN_IO_CONFIG) || defined(CONFIG_DAWN_IO_CONTROL) || \
235 defined(CONFIG_DAWN_IO_TRIGGER)
239 const std::vector<SObjectId::ObjectId> &ids,
242 for (
auto const &
id : ids)
247 ret = resolveObjectById(
id, io, prog, prot, &obj);
256 DAWNERR(
"bind failed for ID 0x%" PRIx32
" (error %d)\n",
id, ret);
271#if defined(CONFIG_DAWN_IO_CONFIG) || defined(CONFIG_DAWN_IO_CONTROL) || \
272 defined(CONFIG_DAWN_IO_TRIGGER)
275# ifdef CONFIG_DAWN_IO_CONFIG
279 std::vector<SObjectId::ObjectId> ids;
281 ids.reserve(cfg->
map.size());
282 for (
auto const &[
id, _] : cfg->
map)
300# ifdef CONFIG_DAWN_IO_CONTROL
305 int ret = bindGeneric(io,
317# ifdef CONFIG_DAWN_IO_TRIGGER
322 int ret = bindGeneric(io,
Descriptor wrapper for individual object configuration.
SObjectId::ObjectId getObjectIdV() const
Get object identifier as raw 32-bit value.
SObjectId::UObjectId & getObjectId() const
Get object identifier as union structure.
Binary device descriptor manager.
Global registry for object inspection.
static CDevInspector * getInst()
Get singleton instance.
void registerIOHandler(const CIOHandler *handler)
Register IO handler.
int initAll()
Run one-time init() for all configured objects.
int registerObject(T *obj)
Register object.
int stopAll()
Stop all objects managed by this handler.
T * getObjectById(const SObjectId::UObjectId &id) const
Get object by ObjectID.
int configureAll()
Configure all objects managed by this handler.
std::vector< CIOCommon * > objects
Vector of registered objects.
int objalloc(CDescriptor &desc, CDescriptor::allocobj_func_t func)
Allocate objects from descriptor.
int startAll()
Start all objects managed by this handler.
Base implementation of IHandler interface.
Base class for all I/O objects.
@ IO_CLASS_TRIGGER
Trigger I/O.
@ IO_CLASS_CONTROL
Control I/O.
@ IO_CLASS_CONFIG
Configuration I/O.
Configuration I/O for runtime object management.
std::map< uint32_t, CObject * > map
Map of object ID to bound CObject pointers.
Control I/O for lifecycle management of bound objects.
std::vector< SObjectId::ObjectId > ids
Object IDs to resolve; populated during configure().
CIOCommon * create(CDescObject &desc)
Create I/O object from descriptor.
Manages I/O object lifecycle and dispatch.
void onInitObject(CIOCommon *io)
Hook called for each I/O object during initAll().
int startAll()
Start all I/O objects.
CObject * getObject(const SObjectId::ObjectId id)
Get object by ObjectID as CObject*.
int stopAll()
Stop all I/O objects.
int initAll()
Configure and initialize all I/O objects.
int init(CDescriptor &desc, IIOFactory *f)
Initialize virtual I/O.
CIOCommon * getIO(SObjectId::UObjectId &id) const
Get I/O object by ObjectID as CIOCommon*.
bool isObjectValid(SObjectId::UObjectId &obj) const
Validate object ID.
int bindObjects(IHandler &io, IHandler &prog, IHandler &prot)
Bind special I/O objects (Config, Control, Trigger) to targets.
Trigger I/O for dispatching commands to bound objects.
std::vector< SObjectId::ObjectId > ids
Object IDs to resolve; populated during configure().
Base class for all Dawn objects (IOs, Programs, Protocols).
uint16_t getCls() const
Get object class field.
Common interface for all handler implementations.
virtual CObject * getObject(const SObjectId::ObjectId id)=0
Get object from this handler by ID.
Abstract factory interface for extensible I/O object creation.
virtual CIOCommon * create(CDescObject &desc)=0
Create I/O object from descriptor.
Out-of-tree user-extension hooks for Dawn.
@ OBJTYPE_PROTO
Protocol object type.
@ OBJTYPE_IO
Input/Output object type.
@ OBJTYPE_PROG
Program/algorithm object type.
static bool objectIsIO(const UObjectId &objid)
Check if object is I/O type (union structure version).
static uint8_t objectIdGetType(const ObjectId objid)
Extract object type from ObjectID.
uint32_t ObjectId
ObjectID type - single 32-bit value.
32-bit encoded object identifier (union with bit field).
ObjectId v
Raw 32-bit ObjectID value (for comparison, hashing, storage).