mirror of https://github.com/ipxe/ipxe.git
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.pull/1/head
parent
4bcfe7507b
commit
fd86c819ba
|
@ -16,6 +16,7 @@ Literature dealing with the network protocols:
|
||||||
|
|
||||||
#include <gpxe/heap.h>
|
#include <gpxe/heap.h>
|
||||||
#include <gpxe/init.h>
|
#include <gpxe/init.h>
|
||||||
|
#include <gpxe/process.h>
|
||||||
#include <gpxe/device.h>
|
#include <gpxe/device.h>
|
||||||
#include <gpxe/shell.h>
|
#include <gpxe/shell.h>
|
||||||
#include <gpxe/shell_banner.h>
|
#include <gpxe/shell_banner.h>
|
||||||
|
@ -29,8 +30,10 @@ Literature dealing with the network protocols:
|
||||||
* Call this function only once, before doing (almost) anything else.
|
* Call this function only once, before doing (almost) anything else.
|
||||||
*/
|
*/
|
||||||
static void startup ( void ) {
|
static void startup ( void ) {
|
||||||
hide_etherboot();
|
|
||||||
init_heap();
|
init_heap();
|
||||||
|
init_processes();
|
||||||
|
|
||||||
|
hide_etherboot();
|
||||||
call_init_fns();
|
call_init_fns();
|
||||||
probe_devices();
|
probe_devices();
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,12 @@
|
||||||
/** Process run queue */
|
/** Process run queue */
|
||||||
static LIST_HEAD ( run_queue );
|
static LIST_HEAD ( run_queue );
|
||||||
|
|
||||||
|
/** Registered permanent processes */
|
||||||
|
static struct process processes[0]
|
||||||
|
__table_start ( struct process, processes );
|
||||||
|
static struct process processes_end[0]
|
||||||
|
__table_end ( struct process, processes );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add process to process list
|
* Add process to process list
|
||||||
*
|
*
|
||||||
|
@ -72,3 +78,15 @@ void step ( void ) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialise processes
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void init_processes ( void ) {
|
||||||
|
struct process *process;
|
||||||
|
|
||||||
|
for ( process = processes ; process < processes_end ; process++ ) {
|
||||||
|
process_add ( process );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -42,7 +42,6 @@ struct init_fn {
|
||||||
#define INIT_LOADBUF 08
|
#define INIT_LOADBUF 08
|
||||||
#define INIT_PCMCIA 09
|
#define INIT_PCMCIA 09
|
||||||
#define INIT_RPC 11
|
#define INIT_RPC 11
|
||||||
#define INIT_PROCESS 12
|
|
||||||
|
|
||||||
/* Macro for creating an initialisation function table entry */
|
/* Macro for creating an initialisation function table entry */
|
||||||
#define INIT_FN( init_order, init_func, reset_func, exit_func ) \
|
#define INIT_FN( init_order, init_func, reset_func, exit_func ) \
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <gpxe/list.h>
|
#include <gpxe/list.h>
|
||||||
#include <gpxe/refcnt.h>
|
#include <gpxe/refcnt.h>
|
||||||
|
#include <gpxe/tables.h>
|
||||||
|
|
||||||
/** A process */
|
/** A process */
|
||||||
struct process {
|
struct process {
|
||||||
|
@ -33,6 +34,7 @@ struct process {
|
||||||
extern void process_add ( struct process *process );
|
extern void process_add ( struct process *process );
|
||||||
extern void process_del ( struct process *process );
|
extern void process_del ( struct process *process );
|
||||||
extern void step ( void );
|
extern void step ( void );
|
||||||
|
extern void init_processes ( void );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialise process without adding to process list
|
* Initialise process without adding to process list
|
||||||
|
@ -62,4 +64,13 @@ process_init ( struct process *process,
|
||||||
process_add ( process );
|
process_add ( process );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Declare a permanent process
|
||||||
|
*
|
||||||
|
* Permanent processes will be automatically added to the process list
|
||||||
|
* at initialisation time.
|
||||||
|
*/
|
||||||
|
#define __permanent_process \
|
||||||
|
__table ( struct process, processes, 01 )
|
||||||
|
|
||||||
#endif /* _GPXE_PROCESS_H */
|
#endif /* _GPXE_PROCESS_H */
|
||||||
|
|
|
@ -448,13 +448,6 @@ static void net_step ( struct process *process __unused ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Networking stack process */
|
/** Networking stack process */
|
||||||
static struct process net_process = {
|
struct process net_process __permanent_process = {
|
||||||
.step = net_step,
|
.step = net_step,
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Initialise the networking stack process */
|
|
||||||
static void init_net ( void ) {
|
|
||||||
process_add ( &net_process );
|
|
||||||
}
|
|
||||||
|
|
||||||
INIT_FN ( INIT_PROCESS, init_net, NULL, NULL );
|
|
||||||
|
|
|
@ -167,13 +167,6 @@ static void retry_step ( struct process *process __unused ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Retry timer process */
|
/** Retry timer process */
|
||||||
static struct process retry_process = {
|
struct process retry_process __permanent_process = {
|
||||||
.step = retry_step,
|
.step = retry_step,
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Initialise the retry timer module */
|
|
||||||
static void init_retry ( void ) {
|
|
||||||
process_add ( &retry_process );
|
|
||||||
}
|
|
||||||
|
|
||||||
INIT_FN ( INIT_PROCESS, init_retry, NULL, NULL );
|
|
||||||
|
|
Loading…
Reference in New Issue