Dawn Framework 1.0
Universal data acquisition framework for embedded systems
config.hxx
1// dawn/include/dawn/io/config.hxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#pragma once
7
8#include <map>
9#include <mutex>
10
11#include "dawn/io/common.hxx"
12#include "dawn/porting/config.hxx"
13
14namespace dawn
15{
23class CIOConfig : public CIOCommon
24{
25public:
26 enum
27 {
28 IO_CONFIG_CFG_FIRST = 0,
29 IO_CONFIG_CFG_ALLOC = 1,
30 IO_CONFIG_CFG_OBJCFG = 2,
31 IO_CONFIG_CFG_OFFSET = 3,
32 IO_CONFIG_CFG_SIZE = 4,
33 IO_CONFIG_CFG_LAST = 31
34 };
35
36 explicit CIOConfig(CDescObject &desc)
37 : CIOCommon(desc)
38 , objcfg(0)
39 , cfg_offset(0)
40 , cfg_size(0)
41 {
42 }
43
44 ~CIOConfig() override;
45
46#ifdef CONFIG_DAWN_OBJECT_HAS_NAME
47 const char *getClassNameStr() const override
48 {
49 return "config";
50 }
51#endif
52
53 int configure() override;
54 int deinit() override;
55 int getDataImpl(IODataCmn &data, size_t len) override;
56 int setDataImpl(IODataCmn &data) override;
57 size_t getDataSize() const override;
58 size_t getDataDim() const override;
59
60 bool isRead() const override
61 {
62 return true;
63 };
64
65 bool isWrite() const override
66 {
67 return true;
68 };
69
70 bool isNotify() const override
71 {
72 return false;
73 };
74
75 bool isBatch() const override
76 {
77 return false;
78 };
79
80 int bind(CObject *obj, uint32_t id);
81
83
84 constexpr static SObjectId::ObjectId objectId(SObjectId::EObjectDataType dtype, uint16_t inst)
85 {
86 return ObjectIdHelper::create(dtype, inst);
87 }
88
89 constexpr static SObjectCfg::ObjectCfgId cfgIdCfg()
90 {
94 false,
95 1,
96 IO_CONFIG_CFG_OBJCFG);
97 }
98
99 constexpr static SObjectCfg::ObjectCfgId cfgIdAlloc(uint8_t dtype, bool rw, uint8_t len)
100 {
102 SObjectId::OBJTYPE_IO, (CIOCommon::IO_CLASS_CONFIG), dtype, rw, len, IO_CONFIG_CFG_ALLOC);
103 }
104
105 constexpr static SObjectCfg::ObjectCfgId cfgIdOffset()
106 {
110 false,
111 1,
112 IO_CONFIG_CFG_OFFSET);
113 }
114
115 constexpr static SObjectCfg::ObjectCfgId cfgIdSize()
116 {
120 false,
121 1,
122 IO_CONFIG_CFG_SIZE);
123 }
124
125 std::map<uint32_t, CObject *> map;
126
127private:
128 uint32_t objcfg;
129 uint32_t cfg_offset;
130 uint32_t cfg_size;
131
132 void configureDesc(const CDescObject &desc);
133};
134} // Namespace dawn
Descriptor wrapper for individual object configuration.
Template helper for creating ObjectIDs for I/O types without timestamp support.
Definition common.hxx:303
static SObjectId::ObjectId create(uint16_t inst)
Create ObjectID with fixed data type and no timestamp.
Definition common.hxx:312
Base class for all I/O objects.
Definition common.hxx:27
@ IO_CLASS_CONFIG
Configuration I/O.
Definition common.hxx:90
Configuration I/O for runtime object management.
Definition config.hxx:24
int getDataImpl(IODataCmn &data, size_t len)
Get data implementation (override in derived classes).
Definition config.cxx:449
int deinit()
De-initialize object.
Definition config.cxx:444
std::map< uint32_t, CObject * > map
Map of object ID to bound CObject pointers.
Definition config.hxx:125
int setDataImpl(IODataCmn &data)
Set data implementation (override in derived classes).
Definition config.cxx:508
int configure()
Configure object from descriptor data.
Definition config.cxx:385
bool isNotify() const
Check if IO supports notifications.
Definition config.hxx:70
size_t getDataSize() const
Get data size in bytes.
Definition config.cxx:651
size_t getDataDim() const
Get data vector dimension.
Definition config.cxx:673
bool isRead() const
Check if IO supports read operations.
Definition config.hxx:60
bool isWrite() const
Check if IO supports write operations.
Definition config.hxx:65
bool isBatch() const
Check if IO supports batch operations.
Definition config.hxx:75
Base class for all Dawn objects (IOs, Programs, Protocols).
Definition object.hxx:28
static ObjectCfgId objectCfg(uint8_t type, uint16_t cls, uint8_t dtype, bool rw, uint16_t size, uint8_t id)
Construct 32-bit ConfigID from component fields.
uint32_t ObjectCfgId
ConfigID type - single 32-bit value.
Definition objectcfg.hxx:60
Out-of-tree user-extension hooks for Dawn.
Definition bindable.hxx:13
Base interface for I/O data buffers (static and dynamic).
Definition idata.hxx:21
@ OBJTYPE_IO
Input/Output object type.
Definition objectid.hxx:184
EObjectDataType
Data types supported by Dawn framework.
Definition objectid.hxx:61
@ DTYPE_UINT32
Unsigned 32-bit integer (0 to 4294967295).
Definition objectid.hxx:96
uint32_t ObjectId
ObjectID type - single 32-bit value.
Definition objectid.hxx:44