[
https://issues.apache.org/jira/browse/MYNEWT-512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15762409#comment-15762409
]
ASF subversion and git services commented on MYNEWT-512:
--------------------------------------------------------
Commit 43a5ef8860cbf4bc5bf43fde8a29fe74361536fa in incubator-mynewt-core's
branch refs/heads/develop from [~ccollins476]
[ https://git-wip-us.apache.org/repos/asf?p=incubator-mynewt-core.git;h=43a5ef8
]
MYNEWT-512 Replace gen. sysinit with linker sect
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:
/* Package initialization function. */
typedef void sysinit_init_fn(struct sysinit_init_ctxt *ctxt);
struct sysinit_entry {
/* Initializes a package. */
sysinit_init_fn *init_fn;
/* Specifies when the init function gets called. 0=first, 1=next, etc.
*/
uint8_t stage;
};
struct sysinit_init_ctxt {
/* Corresponds to the init function currently executing. */
const struct sysinit_entry *entry;
/* The stage that sysinit is currently processing. */
uint8_t cur_stage;
};
/**
* Registers a package initialization function
*
* @param init_cb Pointer to the init function to register.
* @param init_stage Indicates when this init function gets
called,
* relative to other init functions.
0=first,
* 1=next, etc.
*/
#define SYSINIT_REGISTER_INIT(init_cb, init_stage) /* ... */
EXAMPLE:
static void
my_pkg_init(struct sysinit_init_ctxt *ctxt)
{
/* ... */
}
SYSINIT_REGISTER(my_pkg_init, 2);
> 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)