1 #ifndef _GPXE_PROCESS_H
2 #define _GPXE_PROCESS_H
10 #include <gpxe/list.h>
11 #include <gpxe/refcnt.h>
12 #include <gpxe/tables.h>
16 /** List of processes */
17 struct list_head list;
19 * Single-step the process
21 * This method should execute a single step of the process.
22 * Returning from this method is isomorphic to yielding the
23 * CPU to another process.
25 void ( * step ) ( struct process *process );
28 * If this interface is not part of a reference-counted
29 * object, this field may be NULL.
31 struct refcnt *refcnt;
34 extern void process_add ( struct process *process );
35 extern void process_del ( struct process *process );
36 extern void step ( void );
39 * Initialise process without adding to process list
42 * @v step Process' step() method
44 static inline __attribute__ (( always_inline )) void
45 process_init_stopped ( struct process *process,
46 void ( * step ) ( struct process *process ),
47 struct refcnt *refcnt ) {
49 process->refcnt = refcnt;
53 * Initialise process and add to process list
56 * @v step Process' step() method
58 static inline __attribute__ (( always_inline )) void
59 process_init ( struct process *process,
60 void ( * step ) ( struct process *process ),
61 struct refcnt *refcnt ) {
62 process_init_stopped ( process, step, refcnt );
63 process_add ( process );
66 /** Permanent process table */
67 #define PERMANENT_PROCESSES "processes"
70 * Declare a permanent process
72 * Permanent processes will be automatically added to the process list
73 * at initialisation time.
75 #define __permanent_process \
76 __table ( struct process, PERMANENT_PROCESSES, 01 )
78 #endif /* _GPXE_PROCESS_H */