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");
96 ret = system.init(desc,
nullptr);
99 DAWNERR(
"failed to initialize SYSTEM handler\n");
108 DAWNERR(
"failed to initialize SYSTEM objects\n");
117 DAWNERR(
"failed to bind special IO objects\n");
124#ifdef CONFIG_DAWN_DESC_SWITCH
125int CDawn::load_descriptor_from_slot(uint8_t slot)
136 if (reg.
ptr ==
nullptr || reg.
len == 0)
148#ifdef CONFIG_DAWN_LIFECYCLE_TEARDOWN
151#ifdef CONFIG_DAWN_DESC_SWITCH
160#ifdef CONFIG_DAWN_LIFECYCLE_TEARDOWN
168#ifdef CONFIG_DAWN_LIFECYCLE_TEARDOWN
180#ifdef CONFIG_DAWN_LIFECYCLE_TEARDOWN
192#ifdef CONFIG_DAWN_LIFECYCLE_TEARDOWN
204#ifdef CONFIG_DAWN_LIFECYCLE_TEARDOWN
211 DAWNINFO(
"DAWN: START SUCCESS!\n");
215#ifdef CONFIG_DAWN_LIFECYCLE_TEARDOWN
218 DAWNINFO(
"shutdown requested - quit\n");
223#ifdef CONFIG_DAWN_DESC_SWITCH
226 DAWNINFO(
"descriptor switch requested\n");
233 DAWNINFO(
"no active protocols - quit\n");
243 dawn::oot::user_on_idle(
this);
246#ifdef CONFIG_DAWN_LIFECYCLE_TEARDOWN
250 tmp = dawn::oot::user_pre_shutdown(
this);
253 DAWNWARN(
"user_pre_shutdown returned %d\n", tmp);
259 DAWNERR(
"failed to stop protos %d\n", tmp);
270 DAWNERR(
"failed to stop programs %d\n", tmp);
281 DAWNERR(
"failed to stop SYSTEM objects %d\n", tmp);
292 DAWNERR(
"failed to stop IO %d\n", tmp);
303 DAWNERR(
"failed to deinit protos %d\n", tmp);
313 DAWNERR(
"failed to deinit programs %d\n", tmp);
323 DAWNERR(
"failed to deinit SYSTEM objects %d\n", tmp);
333 DAWNERR(
"failed to deinit IO %d\n", tmp);
343#ifdef CONFIG_DAWN_DESC_SWITCH
350 ret = load_descriptor_from_slot(newSlot);
353 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, IHandler &dev)
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.
int startAll()
Start all objects managed by this handler.
int deinitAll()
De-initialize all objects managed by this handler.
int stopAll()
Stop all objects managed by this handler.
int initAll()
Run one-time init() for all configured objects.
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.