Christopher Collins created MYNEWT-512:
------------------------------------------
Summary: Replace generated sysinit code with linker section
Key: MYNEWT-512
URL: https://issues.apache.org/jira/browse/MYNEWT-512
Project: Mynewt
Issue Type: Improvement
Reporter: Christopher Collins
Assignee: Christopher Collins
Fix For: v1_0_0_rel
*Old mechanism:*
* pkg.yml file specifies "init_function" and "init_stage"
* newt generates sysinit C files which call the packages' init functions in the
specified order.
*New mechanism:*
* Each package defines an "init entry" struct containing:
** pointer to init function
** uint8_t stage
* Init entry structs are placed in a special section.
* At startup, the sysinit() function walks the list of entries in the special
section and calls their corresponding init functions in the correct order.
*Interface*
{code}
typedef void sysinit_init_fn(struct sysinit_init_ctxt *ctxt);
struct sysinit_entry {
sysinit_init_fn *init_fn;
uint8_t stage;
};
struct sysinit_init_ctxt {
const struct sysinit_entry *entry;
uint8_t cur_stage;
};
#define SYSINIT_REGISTER_INIT(init_cb, init_stage) // ...
{code}
User defines a package initialization function and registers it. Registration
creates a {{struct sysinit_entry}} instance in the special "sysinit" section.
*Example:*
{code}
static void
my_pkg_init(void)
{
/* ... */
}
SYSINIT_REGISTER(my_pkg_init, 2);
{code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)