Browse Source

Use a linker-table based system to automatically mark and start up

permanent processes, rather than requiring each one to have its own
initialisation function.
tags/v0.9.3
Michael Brown 17 years ago
parent
commit
fd86c819ba
6 changed files with 35 additions and 18 deletions
  1. 4
    1
      src/core/main.c
  2. 18
    0
      src/core/process.c
  3. 0
    1
      src/include/gpxe/init.h
  4. 11
    0
      src/include/gpxe/process.h
  5. 1
    8
      src/net/netdevice.c
  6. 1
    8
      src/net/retry.c

+ 4
- 1
src/core/main.c View File

16
 
16
 
17
 #include <gpxe/heap.h>
17
 #include <gpxe/heap.h>
18
 #include <gpxe/init.h>
18
 #include <gpxe/init.h>
19
+#include <gpxe/process.h>
19
 #include <gpxe/device.h>
20
 #include <gpxe/device.h>
20
 #include <gpxe/shell.h>
21
 #include <gpxe/shell.h>
21
 #include <gpxe/shell_banner.h>
22
 #include <gpxe/shell_banner.h>
29
  * Call this function only once, before doing (almost) anything else.
30
  * Call this function only once, before doing (almost) anything else.
30
  */
31
  */
31
 static void startup ( void ) {
32
 static void startup ( void ) {
32
-	hide_etherboot();
33
 	init_heap();
33
 	init_heap();
34
+	init_processes();
35
+
36
+	hide_etherboot();
34
 	call_init_fns();
37
 	call_init_fns();
35
 	probe_devices();
38
 	probe_devices();
36
 }
39
 }

+ 18
- 0
src/core/process.c View File

30
 /** Process run queue */
30
 /** Process run queue */
31
 static LIST_HEAD ( run_queue );
31
 static LIST_HEAD ( run_queue );
32
 
32
 
33
+/** Registered permanent processes */
34
+static struct process processes[0]
35
+	__table_start ( struct process, processes );
36
+static struct process processes_end[0]
37
+	__table_end ( struct process, processes );
38
+
33
 /**
39
 /**
34
  * Add process to process list
40
  * Add process to process list
35
  *
41
  *
72
 		break;
78
 		break;
73
 	}
79
 	}
74
 }
80
 }
81
+
82
+/**
83
+ * Initialise processes
84
+ *
85
+ */
86
+void init_processes ( void ) {
87
+	struct process *process;
88
+
89
+	for ( process = processes ; process < processes_end ; process++ ) {
90
+		process_add ( process );
91
+	}
92
+}

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

42
 #define	INIT_LOADBUF	08
42
 #define	INIT_LOADBUF	08
43
 #define	INIT_PCMCIA	09
43
 #define	INIT_PCMCIA	09
44
 #define	INIT_RPC	11
44
 #define	INIT_RPC	11
45
-#define INIT_PROCESS	12
46
 
45
 
47
 /* Macro for creating an initialisation function table entry */
46
 /* Macro for creating an initialisation function table entry */
48
 #define INIT_FN( init_order, init_func, reset_func, exit_func )	\
47
 #define INIT_FN( init_order, init_func, reset_func, exit_func )	\

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

9
 
9
 
10
 #include <gpxe/list.h>
10
 #include <gpxe/list.h>
11
 #include <gpxe/refcnt.h>
11
 #include <gpxe/refcnt.h>
12
+#include <gpxe/tables.h>
12
 
13
 
13
 /** A process */
14
 /** A process */
14
 struct process {
15
 struct process {
33
 extern void process_add ( struct process *process );
34
 extern void process_add ( struct process *process );
34
 extern void process_del ( struct process *process );
35
 extern void process_del ( struct process *process );
35
 extern void step ( void );
36
 extern void step ( void );
37
+extern void init_processes ( void );
36
 
38
 
37
 /**
39
 /**
38
  * Initialise process without adding to process list
40
  * Initialise process without adding to process list
62
 	process_add ( process );
64
 	process_add ( process );
63
 }
65
 }
64
 
66
 
67
+/**
68
+ * Declare a permanent process
69
+ *
70
+ * Permanent processes will be automatically added to the process list
71
+ * at initialisation time.
72
+ */
73
+#define __permanent_process \
74
+	__table ( struct process, processes, 01 )
75
+
65
 #endif /* _GPXE_PROCESS_H */
76
 #endif /* _GPXE_PROCESS_H */

+ 1
- 8
src/net/netdevice.c View File

448
 }
448
 }
449
 
449
 
450
 /** Networking stack process */
450
 /** Networking stack process */
451
-static struct process net_process = {
451
+struct process net_process __permanent_process = {
452
 	.step = net_step,
452
 	.step = net_step,
453
 };
453
 };
454
-
455
-/** Initialise the networking stack process */
456
-static void init_net ( void ) {
457
-	process_add ( &net_process );
458
-}
459
-
460
-INIT_FN ( INIT_PROCESS, init_net, NULL, NULL );

+ 1
- 8
src/net/retry.c View File

167
 }
167
 }
168
 
168
 
169
 /** Retry timer process */
169
 /** Retry timer process */
170
-static struct process retry_process = {
170
+struct process retry_process __permanent_process = {
171
 	.step = retry_step,
171
 	.step = retry_step,
172
 };
172
 };
173
-
174
-/** Initialise the retry timer module */
175
-static void init_retry ( void ) {
176
-	process_add ( &retry_process );
177
-}
178
-
179
-INIT_FN ( INIT_PROCESS, init_retry, NULL, NULL );

Loading…
Cancel
Save