summaryrefslogtreecommitdiffstats
path: root/src/core/init.c
blob: 61570fd171c6910ed1184b35c833718ed6adf8e8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**************************************************************************
 * 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_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 ();
	}
}