In main.c, it calls initialize() and startup(). Inside each of these functions in init.c, it loops through a table that contains the registered functions and calls them:
void startup ( void ) {
struct startup_fn *startup_fn;
if ( started )
return;
/* Call registered startup functions */
for_each_table_entry ( startup_fn, STARTUP_FNS ) {
if ( startup_fn->startup )
startup_fn->startup();
}
started = 1;
}
I don't know where the registered functions are, according to the comment.
#define STARTUP_FNS __table ( struct startup_fn, "startup_fns" )
#define __table( type, name ) ( type, name )
__table is the end of what I can look into. The comment says that it "Declare a linker table". But how can it get the functions?
There are more in table.h, such as __table_entry, table_start... where does this table come from? Where are its entries? what does it mean by:
#define table_start( table ) __table_entries ( table, 00 )
What does 00
mean here?
Please help. I really want to understand. Thanks.