[En-Nut-Discussion] Nut/OS Initialization

Nathan Moore nategoose at gmail.com
Wed Sep 17 05:48:10 CEST 2008


I suspect that the case of automatically hooking in the call back functions
if they are implemented is done by way of having alternate implementations
of those functions in libraries with the like order (or priority) arranged
so that
if you didn't write your own the default is pulled from the library, and the
default doesn't actually do anything.

With the structures that are defined to reference start up functions -- I
suspect
this works by having all such structures linked in in one contiguous area
with
linker labels at the beginning and end and code somewhere that loops over
this
array of start-up structures, since it knows the beginning and end of the
list
because the linker filled in those values.  Something like:
extern char _init_struct_begin[], _init_struct_end[]; // anything with the
right names whose address can be taken
struct init_struct * p;
void * end;
for (p = _init_struct_begin, end = _init_struct_end; p<e; p++) {
   do_init(p);
}
If the list was empty it would never execute do_init.

Nathan



More information about the En-Nut-Discussion mailing list