6#include "dawn/dawn.hxx"
8#ifdef CONFIG_DAWN_DESC_SWITCH
9# include "dawn/dev/descriptor.hxx"
10# include "dawn/dev/descswitch.hxx"
12#ifdef CONFIG_DAWN_LIFECYCLE_TEARDOWN
13# include "dawn/dev/shutdown.hxx"
19 : userIOFactory(iofactory)
20 , userProgFactory(progfactory)
21 , userProtoFactory(protofactory)
29 DAWNASSERT(bin !=
nullptr && len > 0,
"invalid input");
33 ret = desc.
loadBin(bin, len,
false);
36 DAWNERR(
"ERROR: _desc.loadBin failed %d\n", ret);
42 ret = io.
init(desc, userIOFactory);
45 DAWNERR(
"failed to initialize IO handler\n");
54 DAWNERR(
"failed to initialize IOs\n");
60 ret = prog.
init(desc, &io, userProgFactory);
63 DAWNERR(
"failed to initialize PROG handler\n");
72 DAWNERR(
"failed to initialize PROGs\n");
78 ret = proto.
init(desc, &io, userProtoFactory);
81 DAWNERR(
"failed to initialize PROTO handler\n");
90 DAWNERR(
"failed to initialize PROTOs\n");
99 DAWNERR(
"failed to bind special IO objects\n");
106#ifdef CONFIG_DAWN_DESC_SWITCH
107int CDawn::load_descriptor_from_slot(uint8_t slot)
118 if (reg.
ptr ==
nullptr || reg.
len == 0)
130#ifdef CONFIG_DAWN_LIFECYCLE_TEARDOWN
133#ifdef CONFIG_DAWN_DESC_SWITCH
142#ifdef CONFIG_DAWN_LIFECYCLE_TEARDOWN
150#ifdef CONFIG_DAWN_LIFECYCLE_TEARDOWN
162#ifdef CONFIG_DAWN_LIFECYCLE_TEARDOWN
174#ifdef CONFIG_DAWN_LIFECYCLE_TEARDOWN
181 DAWNINFO(
"DAWN: START SUCCESS!\n");
185#ifdef CONFIG_DAWN_LIFECYCLE_TEARDOWN
188 DAWNINFO(
"shutdown requested - quit\n");
193#ifdef CONFIG_DAWN_DESC_SWITCH
196 DAWNINFO(
"descriptor switch requested\n");
203 DAWNINFO(
"no active protocols - quit\n");
213 dawn::oot::user_on_idle(
this);
216#ifdef CONFIG_DAWN_LIFECYCLE_TEARDOWN
220 tmp = dawn::oot::user_pre_shutdown(
this);
223 DAWNWARN(
"user_pre_shutdown returned %d\n", tmp);
229 DAWNERR(
"failed to stop protos %d\n", tmp);
240 DAWNERR(
"failed to stop programs %d\n", tmp);
251 DAWNERR(
"failed to stop IO %d\n", tmp);
262 DAWNERR(
"failed to deinit protos %d\n", tmp);
272 DAWNERR(
"failed to deinit programs %d\n", tmp);
282 DAWNERR(
"failed to deinit IO %d\n", tmp);
292#ifdef CONFIG_DAWN_DESC_SWITCH
299 ret = load_descriptor_from_slot(newSlot);
302 DAWNERR(
"descriptor switch failed for slot %d\n", newSlot);
int load_descriptor(uint32_t *bin, size_t len)
Load and initialize descriptor.
int start(bool no_loop=false)
Start Dawn framework.
CDawn(IIOFactory *iofactory=nullptr, IProgFactory *progfactory=nullptr, IProtoFactory *protofactory=nullptr)
Construct CDawn framework.
static void setActiveSlot(uint8_t slot)
Set currently active descriptor slot.
static void clear()
Clear pending switch request.
static uint8_t getSwitchSlot()
Get pending switch target slot.
static bool isSwitchRequested()
Check if descriptor switch is pending.
bool getNoIdleQuit() const
Return true if the descriptor requests no idle quit.
int loadBin(uint32_t *bin, size_t len, bool force_valid=false, bool dump=false)
Load binary descriptor from memory.
int getDescriptor(int inst, SDescriptorReg ®)
Get registered descriptor data for an instance.
static CDevDescriptor * getInst()
Get singleton instance.
int deinitAll()
De-initialize all I/O objects.
int startAll()
Start all I/O objects.
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.
int bindObjects(IHandler &io, IHandler &prog, IHandler &prot)
Bind special I/O objects (Config, Control, Trigger) to targets.
int stopAll()
Stop all Programs objects.
int startAll()
Start all Programs objects.
int initAll()
Configure, bind, and initialize all Program objects.
bool hasThread() const
Check if any Programs are running.
int init(CDescriptor &desc, CIOHandler *io, IProgFactory *f)
Initialize the Programs handler.
int deinitAll()
Deinitialize all Programs objects.
int startAll()
Start all protocol objects.
int init(CDescriptor &desc, CIOHandler *io, IProtoFactory *f)
Initialize protocol handler and instances.
int initAll()
Configure, bind, and initialize all protocol objects.
bool hasThread() const
Check if any protocol is running.
int stopAll()
Stop all protocol objects.
int deinitAll()
Deinitialize all protocol objects.
static void clear()
Clear pending shutdown request.
static bool isRequested()
Check if shutdown has been requested.
Abstract factory interface for extensible I/O object creation.
Abstract factory interface for PROG object creation.
Abstract factory interface for protocol creation.
Out-of-tree user-extension hooks for Dawn.
Registered descriptor information.
size_t len
Descriptor length in bytes.
void * ptr
Pointer to descriptor data.