Dawn Framework 1.0
Universal data acquisition framework for embedded systems
dummy.cxx
1// dawn/src/proto/nxscope/dummy.cxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#include "dawn/proto/nxscope/dummy.hxx"
7
8#include "dawn/io/common.hxx"
9#include "dawn/io/sdata.hxx"
10
11using namespace dawn;
12
13int CProtoNxscopeDummy::configureDesc(const CDescObject &desc)
14{
16 size_t offset = 0;
17
18 for (size_t i = 0; i < desc.getSize(); i++)
19 {
20 item = desc.objectCfgItemNext(offset);
21
23 {
24 DAWNERR("unsupported nxscope cfg 0x08%" PRIx32 "\n", item->cfgid.v);
25 return -EINVAL;
26 }
27
28 switch (item->cfgid.s.id)
29 {
31 {
32 const size_t wpe = sizeof(SProtoNxscopeIOBind) / 4;
33 size_t j;
34
35 for (j = 0; j < item->cfgid.s.size; j++)
36 {
37 SProtoNxscopeIOBind *tmp =
38 reinterpret_cast<SProtoNxscopeIOBind *>(item->data + j * wpe);
39
40 allocObject(tmp);
41 }
42
43 break;
44 }
45
47 {
48 const size_t wpe = sizeof(SProtoNxscopeIOBind2) / 4;
49 const size_t entry_count = item->cfgid.s.size / wpe;
50 size_t j;
51
52 if (item->cfgid.s.size % wpe != 0)
53 {
54 DAWNERR("unsupported nxscope cfg 0x08%" PRIx32 "\n", item->cfgid.v);
55 return -EINVAL;
56 }
57
58 for (j = 0; j < entry_count; j++)
59 {
60 SProtoNxscopeIOBind2 *tmp =
61 reinterpret_cast<SProtoNxscopeIOBind2 *>(item->data + j * wpe);
62
63 allocObject(&tmp->bind);
64 allocNames(j, &tmp->name);
65 }
66
67 break;
68 }
69
70 default:
71 {
72 DAWNERR("unsupported nxscope cfg 0x08%" PRIx32 "\n", item->cfgid.v);
73 return -EINVAL;
74 }
75 }
76 }
77
78 return OK;
79}
80
81int CProtoNxscopeDummy::confgureNxscopePriv()
82{
83 int ret;
84
85 nxsDummyCfg.res = 0;
86
87 DAWNINFO("nxscope dummy\n");
88
89 ret = nxscope_dummy_init(&nxsIntf, &nxsDummyCfg);
90 if (ret != OK)
91 {
92 DAWNERR("nxscope_dummy_init failed: %d\n", ret);
93 return ret;
94 }
95
96 return ret;
97}
98
99CProtoNxscopeDummy::~CProtoNxscopeDummy()
100{
101}
102
103int CProtoNxscopeDummy::initPriv()
104{
105 int ret;
106
107 // Configure object
108
109 ret = configureDesc(getDesc());
110 if (ret != OK)
111 {
112 return ret;
113 }
114
115 ret = confgureNxscopePriv();
116 if (ret != OK)
117 {
118 return ret;
119 }
120
121 ret = configureNxscope();
122 if (ret != OK)
123 {
124 return ret;
125 }
126
127 return OK;
128}
129
130int CProtoNxscopeDummy::deinitPriv()
131{
132 nxscope_dummy_deinit(&nxsIntf);
133 return OK;
134}
135
136int CProtoNxscopeDummy::startPriv()
137{
138 return OK;
139}
140
141int CProtoNxscopeDummy::stopPriv()
142{
143 return OK;
144}
Descriptor wrapper for individual object configuration.
size_t getSize() const
Get number of configuration items for this object.
SObjectCfg::SObjectCfgItem * objectCfgItemNext(size_t &offset) const
Get config item at current offset and advance past it.
CDescObject & getDesc()
Get descriptor object for this object.
Definition object.cxx:190
@ PROTO_CLASS_NXSCOPE_DUMMY
NxScope real-time visualization (dummy interface).
Definition common.hxx:39
@ PROTO_NXSCOPE_DUMMY_CFG_IOBIND2
I/O bindings with names.
Definition dummy.hxx:26
@ PROTO_NXSCOPE_DUMMY_CFG_IOBIND
I/O bindings.
Definition dummy.hxx:25
struct nxscope_intf_s nxsIntf
NXScope interface structure (from logging library).
Definition nxscope.hxx:79
Out-of-tree user-extension hooks for Dawn.
Definition bindable.hxx:13
Single configuration item within object.
ObjectCfgData_t data[]
Configuration data array (flexible, size from cfgid.s.size).
UObjectCfgId cfgid
Configuration ID header (type, class, id, size, rw, dtype).
ObjectCfgId v
Raw 32-bit ConfigID value (for storage, comparison).
Definition objectcfg.hxx:82
uint32_t cls
Object class (bits 21-29, max 511).
uint32_t id
Configuration identifier (bits 0-4, max 31).
Definition objectcfg.hxx:94
uint32_t size
Configuration data size in 32-bit words (bits 5-14, max 1023).
struct dawn::SObjectCfg::UObjectCfgId::@10 s
Bit-field structure for named member access.