2
0
mirror of https://github.com/xcat2/xNBA.git synced 2024-12-17 00:31:32 +00:00
xNBA/src/core/init.c
Michael Brown dad5274522 Add "name" field to struct device to allow human-readable hardware device
names.

Add "dev" pointer in struct net_device to tie network interfaces back to a
hardware device.

Force natural alignment of data types in __table() macros.  This seems to
prevent gcc from taking the unilateral decision to occasionally increase
their alignment (which screws up the table packing).
2007-01-10 04:22:09 +00:00

47 lines
1.1 KiB
C

/**************************************************************************
* call_{init,reset,exit}_fns ()
*
* Call the various initialisation and exit functions. We use a
* function table so that we don't end up dragging in an object just
* because we call its initialisation function.
**************************************************************************
*/
#include <gpxe/init.h>
static struct init_fn init_fns[0]
__table_start ( struct init_fn, init_fn );
static struct init_fn init_fns_end[0]
__table_end ( struct init_fn, init_fn );
void call_init_fns ( void ) {
struct init_fn *init_fn;
for ( init_fn = init_fns; init_fn < init_fns_end ; init_fn++ ) {
if ( init_fn->init )
init_fn->init ();
}
}
void call_reset_fns ( void ) {
struct init_fn *init_fn;
for ( init_fn = init_fns; init_fn < init_fns_end ; init_fn++ ) {
if ( init_fn->reset )
init_fn->reset ();
}
}
void call_exit_fns ( void ) {
struct init_fn *init_fn;
/*
* Exit functions are called in reverse order to
* initialisation functions.
*/
for ( init_fn = init_fns_end - 1; init_fn >= init_fns ; init_fn-- ) {
if ( init_fn->exit )
init_fn->exit ();
}
}