Dawn Framework 1.0
Universal data acquisition framework for embedded systems
descriptor.hxx
1// dawn/include/dawn/dev/descriptor.hxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#pragma once
7
8#include <array>
9#include <cstddef>
10#include <cstdint>
11
12#include "dawn/porting/config.hxx"
13
14namespace dawn
15{
17
19{
20public:
22
23 constexpr static int MAX_DESCRIPTORS = CONFIG_DAWN_DESC_SLOTS;
24#if CONFIG_DAWN_DESC_SLOTS > 1
25 constexpr static size_t SLOT_SIZE = CONFIG_DAWN_DESC_SLOT_SIZE;
26#else
27 constexpr static size_t SLOT_SIZE = 0;
28#endif
29
31
32 struct descriptor_reg_s
33 {
34 void *ptr;
35 size_t len;
36 } typedef SDescriptorReg;
37
45
46 int regDescriptor(int inst, const SDescriptorReg &reg);
47
55
56 int getDescriptor(int inst, SDescriptorReg &reg);
57
67
68 int writeSlotData(int inst, const void *data, size_t offset, size_t len);
69
76
77 size_t getSlotWritten(int inst) const;
78
87
88 int resetSlot(int inst);
89
90private:
92
93 SDescriptorReg regDesc[MAX_DESCRIPTORS] = {};
94
95#if CONFIG_DAWN_DESC_SLOTS > 1
97
98 std::array<std::array<uint8_t, SLOT_SIZE>, CONFIG_DAWN_DESC_SLOTS - 1> slotBuf = {};
99
101
102 std::array<size_t, CONFIG_DAWN_DESC_SLOTS - 1> slotWritten = {};
103#endif
104};
105
106} // Namespace dawn
Descriptor interface available for IO.
int resetSlot(int inst)
Reset a RAM slot.
int getDescriptor(int inst, SDescriptorReg &reg)
Get registered descriptor data for an instance.
int regDescriptor(int inst, const SDescriptorReg &reg)
Register descriptor data for an instance.
int writeSlotData(int inst, const void *data, size_t offset, size_t len)
Write descriptor bytes into a RAM slot.
static int MAX_DESCRIPTORS
Maximum number of descriptors that can be registered.
size_t getSlotWritten(int inst) const
Get valid byte count currently stored in a RAM slot.
Out-of-tree user-extension hooks for Dawn.
Definition bindable.hxx:13
Registered descriptor information.
size_t len
Descriptor length in bytes.
void * ptr
Pointer to descriptor data.