Dawn Framework 1.0
Universal data acquisition framework for embedded systems
gateway.hxx
1// dawn/include/dawn/prog/gateway.hxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#pragma once
7
8#include <vector>
9
10#include "dawn/io/virt.hxx"
11#include "dawn/porting/config.hxx"
12#include "dawn/prog/common.hxx"
13
14namespace dawn
15{
16// Forward declaration
17
18class CIOVirt;
19class io_ddata_t;
20
30{
31public:
32 enum
33 {
34 PROG_GATEWAY_CFG_FIRST = 0,
35 PROG_GATEWAY_CFG_IOBIND = 1,
36 PROG_GATEWAY_CFG_LAST = 31
37 };
38
39 enum
40 {
41 FLAG_IO1_READ = (1 << 0),
42 FLAG_IO1_WRITE = (1 << 1),
43 FLAG_IO2_READ = (1 << 2),
44 FLAG_IO2_WRITE = (1 << 3),
45 } typedef EProgGatewayFlags;
46
60
61 explicit CProgGateway(CDescObject &desc)
62 : CProgCommon(desc)
63 {
64 }
65
66 ~CProgGateway() override;
67
68#ifdef CONFIG_DAWN_OBJECT_HAS_NAME
69 const char *getClassNameStr() const override
70 {
71 return "gateway";
72 }
73#endif
74
75 int configure() override;
76 int init() override;
77 int deinit() override;
78 int doStart() override;
79 int doStop() override;
80
81 constexpr static SObjectId::ObjectId objectId(uint16_t inst)
82 {
85 }
86
87 constexpr static SObjectCfg::ObjectCfgId cfgId(bool rw, uint8_t size, uint8_t id)
88 {
91 }
92
93 constexpr static SObjectCfg::ObjectCfgId cfgIdIOBind(uint16_t size)
94 {
95 return CProgGateway::cfgId(false, size, PROG_GATEWAY_CFG_IOBIND);
96 }
97
98private:
99 struct SGatewayBind
100 {
101 SProgGatewayIOBind cfg;
102 CIOVirt *vio1;
103 CIOVirt *vio2;
104 io_ddata_t *iodata;
105 };
106
107 std::vector<SGatewayBind *> binds;
108
109 int configureDesc(const CDescObject &desc);
110 int allocObject(const SProgGatewayIOBind *cfg);
111
112 static void io1SetCb(CIOVirt *io, void *priv);
113 static void io2SetCb(CIOVirt *io, void *priv);
114 static void io1GetCb(CIOVirt *io, void *priv);
115 static void io2GetCb(CIOVirt *io, void *priv);
116};
117} // Namespace dawn
Descriptor wrapper for individual object configuration.
Base class for all PROG (processing) objects.
Definition common.hxx:27
@ PROG_CLASS_GATEWAY
Protocol-to-protocol IO gateway.
Definition common.hxx:75
Protocol-to-protocol IO gateway Program.
Definition gateway.hxx:30
int init()
One-time initialize object after bindings are resolved.
Definition gateway.cxx:209
int configure()
Configure object from descriptor data.
Definition gateway.cxx:174
int deinit()
De-initialize object.
Definition gateway.cxx:194
@ FLAG_IO1_WRITE
io1 set callback: propagates to io2.
Definition gateway.hxx:42
@ FLAG_IO2_WRITE
io2 set callback: propagates to io1.
Definition gateway.hxx:44
@ FLAG_IO2_READ
io2 get callback: fetches from io1.
Definition gateway.hxx:43
@ FLAG_IO1_READ
io1 get callback: fetches from io2.
Definition gateway.hxx:41
int doStart()
Start implementation hook.
Definition gateway.cxx:257
int doStop()
Stop implementation hook.
Definition gateway.cxx:311
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
Descriptor payload for one binding (4 uint32_t words).
Definition gateway.hxx:54
SObjectId::UObjectId io1
First Virtual IO object ID.
Definition gateway.hxx:55
SObjectId::UObjectId io2
Second Virtual IO object ID.
Definition gateway.hxx:56
uint32_t flags
EProgGatewayFlags bitmask.
Definition gateway.hxx:57
uint32_t dim
VirtIO data dimension (number of elements).
Definition gateway.hxx:58
@ OBJTYPE_PROG
Program/algorithm object type.
Definition objectid.hxx:202
@ DTYPE_ANY
Wildcard data type (matches any actual type).
Definition objectid.hxx:68
uint32_t ObjectId
ObjectID type - single 32-bit value.
Definition objectid.hxx:44
static ObjectId objectId(uint8_t type, uint16_t cls, uint8_t dtype, uint8_t flags, uint16_t priv)
Construct 32-bit ObjectID from component fields.
Definition objectid.hxx:290
32-bit encoded object identifier (union with bit field).
Definition objectid.hxx:218