Browse Source

Separated out initialisation functions from startup/shutdown functions.

tags/v0.9.3
Michael Brown 17 years ago
parent
commit
89349d7fad

+ 0
- 2
src/arch/i386/core/cpu.c View File

85
 	identify_cpu(&cpu_info);
85
 	identify_cpu(&cpu_info);
86
 }
86
 }
87
 
87
 
88
-INIT_FN ( INIT_CPU, cpu_setup, NULL );
89
-
90
 #endif /* CONFIG_X86_64 */
88
 #endif /* CONFIG_X86_64 */

+ 3
- 1
src/arch/i386/core/gdbsym.c View File

28
 	getkey();
28
 	getkey();
29
 }
29
 }
30
 
30
 
31
-INIT_FN ( INIT_GDBSYM, gdb_symbol_line, NULL );
31
+struct startup_fn gdb_startup_fn __startup_fn ( STARTUP_NORMAL ) = {
32
+	.startup = gdb_symbol_line,
33
+};

+ 3
- 1
src/arch/i386/core/i386_timer.c View File

191
 
191
 
192
 #endif /* RTC_CURRTICKS */
192
 #endif /* RTC_CURRTICKS */
193
 
193
 
194
-INIT_FN ( INIT_TIMERS, setup_timers, NULL );
194
+struct init_fn timer_init_fn __init_fn ( INIT_NORMAL ) = {
195
+	.initialise = setup_timers,
196
+};

+ 3
- 1
src/arch/i386/core/video_subr.c View File

99
 	.disabled = 1,
99
 	.disabled = 1,
100
 };
100
 };
101
 
101
 
102
-INIT_FN ( INIT_CONSOLE, video_init, NULL );
102
+struct init_fn video_init_fn __init_fn ( INIT_EARLY ) = {
103
+	.initialise = video_init,
104
+};

+ 9
- 2
src/arch/i386/firmware/pcbios/hidemem.c View File

18
 #include <realmode.h>
18
 #include <realmode.h>
19
 #include <biosint.h>
19
 #include <biosint.h>
20
 #include <basemem.h>
20
 #include <basemem.h>
21
+#include <gpxe/init.h>
21
 #include <gpxe/hidemem.h>
22
 #include <gpxe/hidemem.h>
22
 
23
 
23
 /** Alignment for hidden memory regions */
24
 /** Alignment for hidden memory regions */
110
  * Installs an INT 15 handler to edit Etherboot out of the memory map
111
  * Installs an INT 15 handler to edit Etherboot out of the memory map
111
  * returned by the BIOS.
112
  * returned by the BIOS.
112
  */
113
  */
113
-void hide_etherboot ( void ) {
114
+static void hide_etherboot ( void ) {
114
 
115
 
115
 	/* Initialise the hidden regions */
116
 	/* Initialise the hidden regions */
116
 	hide_text();
117
 	hide_text();
127
  * Uninstalls the INT 15 handler installed by hide_etherboot(), if
128
  * Uninstalls the INT 15 handler installed by hide_etherboot(), if
128
  * possible.
129
  * possible.
129
  */
130
  */
130
-void unhide_etherboot ( void ) {
131
+static void unhide_etherboot ( void ) {
131
 
132
 
132
 	/* If we have more than one hooked interrupt at this point, it
133
 	/* If we have more than one hooked interrupt at this point, it
133
 	 * means that some other vector is still hooked, in which case
134
 	 * means that some other vector is still hooked, in which case
147
 	unhook_bios_interrupt ( 0x15, ( unsigned int ) int15,
148
 	unhook_bios_interrupt ( 0x15, ( unsigned int ) int15,
148
 				&int15_vector );
149
 				&int15_vector );
149
 }
150
 }
151
+
152
+/** Hide Etherboot startup function */
153
+struct startup_fn hide_etherboot_startup_fn __startup_fn ( EARLY_STARTUP ) = {
154
+	.startup = hide_etherboot,
155
+	.shutdown = unhide_etherboot,
156
+};

+ 1
- 1
src/arch/i386/image/bzimage.c View File

34
 #include <gpxe/image.h>
34
 #include <gpxe/image.h>
35
 #include <gpxe/segment.h>
35
 #include <gpxe/segment.h>
36
 #include <gpxe/memmap.h>
36
 #include <gpxe/memmap.h>
37
-#include <gpxe/shutdown.h>
37
+#include <gpxe/init.h>
38
 #include <gpxe/initrd.h>
38
 #include <gpxe/initrd.h>
39
 
39
 
40
 struct image_type bzimage_image_type __image_type ( PROBE_NORMAL );
40
 struct image_type bzimage_image_type __image_type ( PROBE_NORMAL );

+ 1
- 1
src/arch/i386/image/eltorito.c View File

33
 #include <gpxe/image.h>
33
 #include <gpxe/image.h>
34
 #include <gpxe/segment.h>
34
 #include <gpxe/segment.h>
35
 #include <gpxe/ramdisk.h>
35
 #include <gpxe/ramdisk.h>
36
-#include <gpxe/shutdown.h>
36
+#include <gpxe/init.h>
37
 
37
 
38
 #define ISO9660_BLKSIZE 2048
38
 #define ISO9660_BLKSIZE 2048
39
 #define ELTORITO_VOL_DESC_OFFSET ( 17 * ISO9660_BLKSIZE )
39
 #define ELTORITO_VOL_DESC_OFFSET ( 17 * ISO9660_BLKSIZE )

+ 1
- 1
src/arch/i386/image/multiboot.c View File

32
 #include <gpxe/segment.h>
32
 #include <gpxe/segment.h>
33
 #include <gpxe/memmap.h>
33
 #include <gpxe/memmap.h>
34
 #include <gpxe/elf.h>
34
 #include <gpxe/elf.h>
35
-#include <gpxe/shutdown.h>
35
+#include <gpxe/init.h>
36
 
36
 
37
 struct image_type multiboot_image_type __image_type ( PROBE_MULTIBOOT );
37
 struct image_type multiboot_image_type __image_type ( PROBE_MULTIBOOT );
38
 
38
 

+ 1
- 1
src/arch/i386/image/nbi.c View File

6
 #include <basemem_packet.h>
6
 #include <basemem_packet.h>
7
 #include <gpxe/uaccess.h>
7
 #include <gpxe/uaccess.h>
8
 #include <gpxe/segment.h>
8
 #include <gpxe/segment.h>
9
-#include <gpxe/shutdown.h>
9
+#include <gpxe/init.h>
10
 #include <gpxe/netdevice.h>
10
 #include <gpxe/netdevice.h>
11
 #include <gpxe/dhcp.h>
11
 #include <gpxe/dhcp.h>
12
 #include <gpxe/image.h>
12
 #include <gpxe/image.h>

+ 0
- 27
src/core/heap.c View File

1
-#include <gpxe/malloc.h>
2
-#include <gpxe/heap.h>
3
-
4
-/**
5
- * @file
6
- *
7
- * Heap
8
- *
9
- */
10
-
11
-/**
12
- * Heap size
13
- *
14
- * Currently fixed at 128kB.
15
- */
16
-#define HEAP_SIZE ( 128 * 1024 )
17
-
18
-/** The heap itself */
19
-char heap[HEAP_SIZE] __attribute__ (( aligned ( __alignof__(void *) )));
20
-
21
-/**
22
- * Initialise the heap
23
- *
24
- */
25
-void init_heap ( void ) {
26
-	mpopulate ( heap, sizeof ( heap ) );
27
-}

+ 101
- 21
src/core/init.c View File

1
-/**************************************************************************
2
- * call_{init,reset,exit}_fns ()
3
- * 
4
- * Call the various initialisation and exit functions.  We use a
5
- * function table so that we don't end up dragging in an object just
6
- * because we call its initialisation function.
7
- **************************************************************************
1
+/*
2
+ * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
3
+ *
4
+ * This program is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU General Public License as
6
+ * published by the Free Software Foundation; either version 2 of the
7
+ * License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful, but
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
+ * General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with this program; if not, write to the Free Software
16
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
8
  */
17
  */
9
 
18
 
19
+#include <gpxe/device.h>
10
 #include <gpxe/init.h>
20
 #include <gpxe/init.h>
11
 
21
 
22
+/** @file
23
+ *
24
+ * Initialisation, startup and shutdown routines
25
+ *
26
+ */
27
+
28
+/** Registered initialisation functions */
12
 static struct init_fn init_fns[0]
29
 static struct init_fn init_fns[0]
13
-	__table_start ( struct init_fn, init_fn );
30
+	__table_start ( struct init_fn, init_fns );
14
 static struct init_fn init_fns_end[0]
31
 static struct init_fn init_fns_end[0]
15
-	__table_end ( struct init_fn, init_fn );
32
+	__table_end ( struct init_fn, init_fns );
33
+
34
+/** Registered startup/shutdown functions */
35
+static struct startup_fn startup_fns[0]
36
+	__table_start ( struct startup_fn, startup_fns );
37
+static struct startup_fn startup_fns_end[0]
38
+	__table_end ( struct startup_fn, startup_fns );
16
 
39
 
17
-void call_init_fns ( void ) {
40
+/** "startup() has been called" flag */
41
+static int started = 0;
42
+
43
+/**
44
+ * Initialise gPXE
45
+ *
46
+ * This function performs the one-time-only and irreversible
47
+ * initialisation steps, such as initialising the heap.  It must be
48
+ * called before (almost) any other function.
49
+ *
50
+ * There is, by definition, no counterpart to this function on the
51
+ * shutdown path.
52
+ */
53
+void initialise ( void ) {
18
 	struct init_fn *init_fn;
54
 	struct init_fn *init_fn;
19
 
55
 
20
-	for ( init_fn = init_fns; init_fn < init_fns_end ; init_fn++ ) {
21
-		if ( init_fn->init )
22
-			init_fn->init ();
56
+	/* Call registered initialisation functions */
57
+	for ( init_fn = init_fns ; init_fn < init_fns_end ; init_fn++ ) {
58
+		init_fn->initialise ();
23
 	}
59
 	}
24
 }
60
 }
25
 
61
 
26
-void call_exit_fns ( void ) {
27
-	struct init_fn *init_fn;
62
+/**
63
+ * Start up gPXE
64
+ *
65
+ * This function performs the repeatable initialisation steps, such as
66
+ * probing devices.  You may call startup() and shutdown() multiple
67
+ * times (as is done via the PXE API when PXENV_START_UNDI is used).
68
+ */
69
+void startup ( void ) {
70
+	struct startup_fn *startup_fn;
71
+
72
+	if ( started )
73
+		return;
74
+
75
+	/* Call registered startup functions */
76
+	for ( startup_fn = startup_fns ; startup_fn < startup_fns_end ;
77
+	      startup_fn++ ) {
78
+		if ( startup_fn->startup )
79
+			startup_fn->startup();
80
+	}
28
 
81
 
29
-	/* 
30
-	 * Exit functions are called in reverse order to
31
-	 * initialisation functions.
82
+	/* Probe for all devices.  Treated separately because nothing
83
+	 * else will drag in device.o
32
 	 */
84
 	 */
33
-	for ( init_fn = init_fns_end - 1; init_fn >= init_fns ; init_fn-- ) {
34
-		if ( init_fn->exit )
35
-			init_fn->exit ();
85
+	probe_devices();
86
+
87
+	started = 1;
88
+}
89
+
90
+/**
91
+ * Shut down gPXE
92
+ *
93
+ * This function reverses the actions of startup(), and leaves gPXE in
94
+ * a state ready to be removed from memory.  You may call startup()
95
+ * again after calling shutdown().
96
+
97
+ * Call this function only once, before either exiting main() or
98
+ * starting up a non-returnable image.
99
+ */
100
+void shutdown ( void ) {
101
+	struct startup_fn *startup_fn;
102
+
103
+	if ( ! started )
104
+		return;
105
+
106
+	/* Remove all devices */
107
+	remove_devices();
108
+
109
+	/* Call registered shutdown functions (in reverse order) */
110
+	for ( startup_fn = startup_fns_end - 1 ; startup_fn >= startup_fns ;
111
+	      startup_fn-- ) {
112
+		if ( startup_fn->shutdown )
113
+			startup_fn->shutdown();
36
 	}
114
 	}
115
+
116
+	started = 0;
37
 }
117
 }

+ 2
- 32
src/core/main.c View File

1
 /**************************************************************************
1
 /**************************************************************************
2
-Etherboot -  Network Bootstrap Program
2
+gPXE -  Network Bootstrap Program
3
 
3
 
4
 Literature dealing with the network protocols:
4
 Literature dealing with the network protocols:
5
 	ARP - RFC826
5
 	ARP - RFC826
14
 
14
 
15
 **************************************************************************/
15
 **************************************************************************/
16
 
16
 
17
-#include <gpxe/heap.h>
18
 #include <gpxe/init.h>
17
 #include <gpxe/init.h>
19
-#include <gpxe/process.h>
20
-#include <gpxe/device.h>
21
 #include <gpxe/shell.h>
18
 #include <gpxe/shell.h>
22
 #include <gpxe/shell_banner.h>
19
 #include <gpxe/shell_banner.h>
23
-#include <gpxe/shutdown.h>
24
-#include <gpxe/hidemem.h>
25
 #include <usr/autoboot.h>
20
 #include <usr/autoboot.h>
26
 
21
 
27
-/**
28
- * Start up Etherboot
29
- *
30
- * Call this function only once, before doing (almost) anything else.
31
- */
32
-static void startup ( void ) {
33
-	init_heap();
34
-	init_processes();
35
-
36
-	hide_etherboot();
37
-	call_init_fns();
38
-	probe_devices();
39
-}
40
-
41
-/**
42
- * Shut down Etherboot
43
- *
44
- * Call this function only once, before either exiting main() or
45
- * starting up a non-returnable image.
46
- */
47
-void shutdown ( void ) {
48
-	remove_devices();
49
-	call_exit_fns();
50
-	unhide_etherboot();
51
-}
52
-
53
 /**
22
 /**
54
  * Main entry point
23
  * Main entry point
55
  *
24
  *
57
  */
26
  */
58
 int main ( void ) {
27
 int main ( void ) {
59
 
28
 
29
+	initialise();
60
 	startup();
30
 	startup();
61
 
31
 
62
 	/* Try autobooting if we're not going straight to the shell */
32
 	/* Try autobooting if we're not going straight to the shell */

+ 24
- 0
src/core/malloc.c View File

22
 #include <strings.h>
22
 #include <strings.h>
23
 #include <io.h>
23
 #include <io.h>
24
 #include <gpxe/list.h>
24
 #include <gpxe/list.h>
25
+#include <gpxe/init.h>
25
 #include <gpxe/malloc.h>
26
 #include <gpxe/malloc.h>
26
 
27
 
27
 /** @file
28
 /** @file
72
 /** Total amount of free memory */
73
 /** Total amount of free memory */
73
 size_t freemem;
74
 size_t freemem;
74
 
75
 
76
+/**
77
+ * Heap size
78
+ *
79
+ * Currently fixed at 128kB.
80
+ */
81
+#define HEAP_SIZE ( 128 * 1024 )
82
+
83
+/** The heap itself */
84
+static char heap[HEAP_SIZE] __attribute__ (( aligned ( __alignof__(void *) )));
85
+
75
 /**
86
 /**
76
  * Allocate a memory block
87
  * Allocate a memory block
77
  *
88
  *
342
 	free_memblock ( start, ( len & ~( MIN_MEMBLOCK_SIZE - 1 ) ) );
353
 	free_memblock ( start, ( len & ~( MIN_MEMBLOCK_SIZE - 1 ) ) );
343
 }
354
 }
344
 
355
 
356
+/**
357
+ * Initialise the heap
358
+ *
359
+ */
360
+static void init_heap ( void ) {
361
+	mpopulate ( heap, sizeof ( heap ) );
362
+}
363
+
364
+/** Memory allocator initialisation function */
365
+struct init_fn heap_init_fn __init_fn ( INIT_EARLY ) = {
366
+	.initialise = init_heap,
367
+};
368
+
345
 #if 0
369
 #if 0
346
 #include <stdio.h>
370
 #include <stdio.h>
347
 /**
371
 /**

+ 7
- 1
src/core/process.c View File

17
  */
17
  */
18
 
18
 
19
 #include <gpxe/list.h>
19
 #include <gpxe/list.h>
20
+#include <gpxe/init.h>
20
 #include <gpxe/process.h>
21
 #include <gpxe/process.h>
21
 
22
 
22
 /** @file
23
 /** @file
83
  * Initialise processes
84
  * Initialise processes
84
  *
85
  *
85
  */
86
  */
86
-void init_processes ( void ) {
87
+static void init_processes ( void ) {
87
 	struct process *process;
88
 	struct process *process;
88
 
89
 
89
 	for ( process = processes ; process < processes_end ; process++ ) {
90
 	for ( process = processes ; process < processes_end ; process++ ) {
90
 		process_add ( process );
91
 		process_add ( process );
91
 	}
92
 	}
92
 }
93
 }
94
+
95
+/** Process initialiser */
96
+struct init_fn process_init_fn __init_fn ( INIT_NORMAL ) = {
97
+	.initialise = init_processes,
98
+};

+ 16
- 2
src/core/serial.c View File

225
 /*
225
 /*
226
  * void serial_fini(void);
226
  * void serial_fini(void);
227
  *	Cleanup our use of the serial port, in particular flush the
227
  *	Cleanup our use of the serial port, in particular flush the
228
- *	output buffer so we don't accidentially loose characters.
228
+ *	output buffer so we don't accidentially lose characters.
229
  */
229
  */
230
 static void serial_fini ( void ) {
230
 static void serial_fini ( void ) {
231
 	int i, status;
231
 	int i, status;
250
 	.disabled = 1,
250
 	.disabled = 1,
251
 };
251
 };
252
 
252
 
253
-INIT_FN ( INIT_CONSOLE, serial_init, serial_fini );
253
+/** Serial console startup function */
254
+struct startup_fn serial_startup_fn __startup_fn ( STARTUP_NORMAL ) = {
255
+	.startup = serial_init,
256
+	.shutdown = serial_fini,
257
+};
254
 
258
 
259
+/**
260
+ * Serial console initialisation function
261
+ *
262
+ * Initialise console early on so that it is available to capture
263
+ * early debug messages.  It is safe to call serial_init() multiple
264
+ * times.
265
+ */
266
+struct init_fn serial_init_fn __init_fn ( INIT_EARLY ) = {
267
+	.initialise = serial_init,
268
+};

+ 7
- 7
src/include/console.h View File

21
  * Must be made part of the console drivers table by using
21
  * Must be made part of the console drivers table by using
22
  * #__console_driver.
22
  * #__console_driver.
23
  *
23
  *
24
- * @note Consoles that cannot be used before their INIT_FN() has
25
- * completed should set #disabled=1 initially.  This allows other
26
- * console devices to still be used to print out early debugging
27
- * messages.
24
+ * @note Consoles that cannot be used before their initialisation
25
+ * function has completed should set #disabled=1 initially.  This
26
+ * allows other console devices to still be used to print out early
27
+ * debugging messages.
28
  *
28
  *
29
  */
29
  */
30
 struct console_driver {
30
 struct console_driver {
31
 	/** Console is disabled.
31
 	/** Console is disabled.
32
 	 *
32
 	 *
33
 	 * The console's putchar(), putline(), getchar() and iskey()
33
 	 * The console's putchar(), putline(), getchar() and iskey()
34
-	 * methods will not be called while #disabled==1. Typically the
35
-	 * console's initialisation functions (called via INIT_FN())
36
-	 * will set #disabled=0 upon completion.
34
+	 * methods will not be called while #disabled==1. Typically
35
+	 * the console's initialisation functions will set #disabled=0
36
+	 * upon completion.
37
 	 *
37
 	 *
38
 	 */
38
 	 */
39
 	int disabled;
39
 	int disabled;

+ 0
- 15
src/include/gpxe/heap.h View File

1
-#ifndef _GPXE_HEAP_H
2
-#define _GPXE_HEAP_H
3
-
4
-/**
5
- * @file
6
- *
7
- * Heap
8
- *
9
- */
10
-
11
-extern char heap[];
12
-
13
-extern void init_heap ( void );
14
-
15
-#endif /* _GPXE_HEAP_H */

+ 0
- 2
src/include/gpxe/hidemem.h View File

17
 	EXTMEM,
17
 	EXTMEM,
18
 };
18
 };
19
 
19
 
20
-extern void hide_etherboot();
21
-extern void unhide_etherboot();
22
 extern void hide_region ( unsigned int region_id, physaddr_t start,
20
 extern void hide_region ( unsigned int region_id, physaddr_t start,
23
 			  physaddr_t end );
21
 			  physaddr_t end );
24
 
22
 

+ 47
- 36
src/include/gpxe/init.h View File

3
 
3
 
4
 #include <gpxe/tables.h>
4
 #include <gpxe/tables.h>
5
 
5
 
6
-/*
7
- * In order to avoid having objects dragged in just because main()
8
- * calls their initialisation function, we allow each object to
9
- * specify that it has a function that must be called to initialise
10
- * that object.  The function call_init_fns() will call all the
11
- * included objects' initialisation functions.
6
+/**
7
+ * An initialisation function
12
  *
8
  *
13
- * Objects that require initialisation should include init.h and
14
- * register the initialisation function using INIT_FN().
9
+ * Initialisation functions are called exactly once, as part of the
10
+ * call to initialise().
11
+ */
12
+struct init_fn {
13
+	void ( * initialise ) ( void );
14
+};
15
+
16
+/** Declare an initialisation functon */
17
+#define __init_fn( init_order ) \
18
+	__table ( struct init_fn, init_fns, init_order )
19
+
20
+/** @defgroup initfn_order Initialisation function ordering
21
+ * @{
22
+ */
23
+
24
+#define INIT_EARLY	01	/**< Early initialisation */
25
+#define INIT_NORMAL	02	/**< Normal initialisation */
26
+
27
+/** @} */
28
+
29
+/**
30
+ * A startup/shutdown function
15
  *
31
  *
16
- * Objects may register up to three functions: init, reset and exit.
17
- * init gets called only once, at the point that Etherboot is
18
- * initialised (before the call to main()).  reset gets called between
19
- * each boot attempt.  exit gets called only once, just before the
20
- * loaded OS starts up (or just before Etherboot exits, if it exits,
21
- * or when the PXE NBP calls UNDI_SHUTDOWN, if it's a PXE NBP).
32
+ * Startup and shutdown functions may be called multiple times, as
33
+ * part of the calls to startup() and shutdown().
34
+ */
35
+struct startup_fn {
36
+	void ( * startup ) ( void );
37
+	void ( * shutdown ) ( void );
38
+};
39
+
40
+/** Declare a startup/shutdown function */
41
+#define __startup_fn( startup_order ) \
42
+	__table ( struct startup_fn, startup_fns, startup_order )
43
+
44
+/** @defgroup startfn_order Startup/shutdown function ordering
45
+ *
46
+ * Shutdown functions are called in the reverse order to startup
47
+ * functions.
22
  *
48
  *
23
- * The syntax is:
24
- *   INIT_FN ( init_order, init_function, reset_function, exit_function );
25
- * where init_order is an ordering taken from the list below.  Any
26
- * function may be left as NULL.
49
+ * @{
27
  */
50
  */
28
 
51
 
29
-/* An entry in the initialisation function table */
52
+#define STARTUP_EARLY	01	/**< Early startup */
53
+#define STARTUP_NORMAL	02	/**< Normal startup */
30
 
54
 
31
-struct init_fn {
32
-	void ( *init ) ( void );
33
-	void ( *exit ) ( void );
34
-};
55
+/** @} */
35
 
56
 
36
 /* Use double digits to avoid problems with "10" < "9" on alphabetic sort */
57
 /* Use double digits to avoid problems with "10" < "9" on alphabetic sort */
37
 #define	INIT_CONSOLE	02
58
 #define	INIT_CONSOLE	02
40
 #define	INIT_TIMERS	05
61
 #define	INIT_TIMERS	05
41
 #define	INIT_LOADBUF	08
62
 #define	INIT_LOADBUF	08
42
 #define	INIT_PCMCIA	09
63
 #define	INIT_PCMCIA	09
43
-#define	INIT_RPC	11
44
-
45
-/* Macro for creating an initialisation function table entry */
46
-#define INIT_FN( init_order, init_func, exit_func )	\
47
-	struct init_fn PREFIX_OBJECT(init_fn__)			\
48
-	    __table ( struct init_fn, init_fn, init_order ) = {	\
49
-		.init = init_func,				\
50
-		.exit = exit_func,				\
51
-	};
52
-
53
-/* Function prototypes */
54
 
64
 
55
-void call_init_fns ( void );
56
-void call_exit_fns ( void );
65
+extern void initialise ( void );
66
+extern void startup ( void );
67
+extern void shutdown ( void );
57
 
68
 
58
 #endif /* _GPXE_INIT_H */
69
 #endif /* _GPXE_INIT_H */

+ 0
- 1
src/include/gpxe/process.h View File

34
 extern void process_add ( struct process *process );
34
 extern void process_add ( struct process *process );
35
 extern void process_del ( struct process *process );
35
 extern void process_del ( struct process *process );
36
 extern void step ( void );
36
 extern void step ( void );
37
-extern void init_processes ( void );
38
 
37
 
39
 /**
38
 /**
40
  * Initialise process without adding to process list
39
  * Initialise process without adding to process list

+ 0
- 10
src/include/gpxe/shutdown.h View File

1
-#ifndef _GPXE_SHUTDOWN_H
2
-#define _GPXE_SHUTDOWN_H
3
-
4
-/**
5
- * Shut down before exit
6
- */
7
-
8
-extern void shutdown ( void );
9
-
10
-#endif /* _GPXE_SHUTDOWN_H */

+ 12
- 26
src/interface/pxe/pxe_preboot.c View File

31
 #include <gpxe/device.h>
31
 #include <gpxe/device.h>
32
 #include <gpxe/netdevice.h>
32
 #include <gpxe/netdevice.h>
33
 #include <gpxe/isapnp.h>
33
 #include <gpxe/isapnp.h>
34
+#include <gpxe/init.h>
34
 #include <basemem_packet.h>
35
 #include <basemem_packet.h>
35
 #include "pxe.h"
36
 #include "pxe.h"
36
 #include "pxe_call.h"
37
 #include "pxe_call.h"
54
 PXENV_EXIT_t pxenv_unload_stack ( struct s_PXENV_UNLOAD_STACK *unload_stack ) {
55
 PXENV_EXIT_t pxenv_unload_stack ( struct s_PXENV_UNLOAD_STACK *unload_stack ) {
55
 	DBG ( "PXENV_UNLOAD_STACK" );
56
 	DBG ( "PXENV_UNLOAD_STACK" );
56
 
57
 
57
-#if 0
58
-	/* We need to call cleanup() at some point.  The network card
59
-	 * has already been disabled by ENSURE_CAN_UNLOAD(), but for
60
-	 * the sake of completeness we should call the console_fini()
61
-	 * etc. that are part of cleanup().
62
-	 *
63
-	 * There seems to be a lack of consensus on which is the final
64
-	 * PXE API call to make, but it's a fairly safe bet that all
65
-	 * the potential shutdown sequences will include a call to
66
-	 * PXENV_UNLOAD_STACK at some point, so we may as well do it
67
-	 * here.
68
-	 */
69
-	cleanup();
70
-
71
-	if ( ! success ) {
72
-		unload_stack->Status = PXENV_STATUS_KEEP_ALL;
73
-		return PXENV_EXIT_FAILURE;
74
-	}
75
-#endif
76
-
77
 	unload_stack->Status = PXENV_STATUS_SUCCESS;
58
 	unload_stack->Status = PXENV_STATUS_SUCCESS;
78
 	return PXENV_EXIT_SUCCESS;
59
 	return PXENV_EXIT_SUCCESS;
79
 }
60
 }
209
 	DBG ( "PXENV_START_UNDI %04x:%04x:%04x",
190
 	DBG ( "PXENV_START_UNDI %04x:%04x:%04x",
210
 	      start_undi->AX, start_undi->BX, start_undi->DX );
191
 	      start_undi->AX, start_undi->BX, start_undi->DX );
211
 
192
 
193
+	/* Probe for devices, etc. */
194
+	startup();
195
+
212
 	/* Determine bus type and location */
196
 	/* Determine bus type and location */
213
 	isapnp_read_port = start_undi->DX;
197
 	isapnp_read_port = start_undi->DX;
214
 	isapnp_csn = start_undi->BX;
198
 	isapnp_csn = start_undi->BX;
252
 PXENV_EXIT_t pxenv_stop_undi ( struct s_PXENV_STOP_UNDI *stop_undi ) {
236
 PXENV_EXIT_t pxenv_stop_undi ( struct s_PXENV_STOP_UNDI *stop_undi ) {
253
 	DBG ( "PXENV_STOP_UNDI" );
237
 	DBG ( "PXENV_STOP_UNDI" );
254
 
238
 
255
-#if 0
256
-	if ( ! ensure_pxe_state(CAN_UNLOAD) ) {
257
-		stop_undi->Status = PXENV_STATUS_KEEP_UNDI;
258
-		return PXENV_EXIT_FAILURE;
259
-	}
260
-#endif
239
+	/* Unhook INT 1A */
240
+	pxe_unhook_int1a();
241
+
242
+	/* Clear PXE net device */
243
+	pxe_set_netdev ( NULL );
244
+
245
+	/* Prepare for unload */
246
+	shutdown();
261
 
247
 
262
 	stop_undi->Status = PXENV_STATUS_SUCCESS;
248
 	stop_undi->Status = PXENV_STATUS_SUCCESS;
263
 	return PXENV_EXIT_SUCCESS;
249
 	return PXENV_EXIT_SUCCESS;

+ 1
- 3
src/proto/nfs.c View File

32
 /**************************************************************************
32
 /**************************************************************************
33
 RPC_INIT - set up the ID counter to something fairly random
33
 RPC_INIT - set up the ID counter to something fairly random
34
 **************************************************************************/
34
 **************************************************************************/
35
-static void rpc_init(void)
35
+void rpc_init(void)
36
 {
36
 {
37
 	unsigned long t;
37
 	unsigned long t;
38
 
38
 
608
 	return 1;
608
 	return 1;
609
 }
609
 }
610
 
610
 
611
-INIT_FN ( INIT_RPC, rpc_init, nfs_reset );
612
-
613
 struct protocol nfs_protocol __protocol = {
611
 struct protocol nfs_protocol __protocol = {
614
 	.name = "nfs",
612
 	.name = "nfs",
615
 	.default_port = SUNRPC_PORT,
613
 	.default_port = SUNRPC_PORT,

Loading…
Cancel
Save