[sundance] Add reset completion check
[gpxe.git] / src / include / gpxe / process.h
blob8d9b109a5f6ef23e6514147ba047c871a277efb0
1 #ifndef _GPXE_PROCESS_H
2 #define _GPXE_PROCESS_H
4 /** @file
6 * Processes
8 */
10 #include <gpxe/list.h>
11 #include <gpxe/refcnt.h>
12 #include <gpxe/tables.h>
14 /** A process */
15 struct process {
16 /** List of processes */
17 struct list_head list;
18 /**
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 );
26 /** Reference counter
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 );
38 /**
39 * Initialise process without adding to process list
41 * @v process Process
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 ) {
48 process->step = step;
49 process->refcnt = refcnt;
52 /**
53 * Initialise process and add to process list
55 * @v process Process
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 /**
67 * Declare a permanent process
69 * Permanent processes will be automatically added to the process list
70 * at initialisation time.
72 #define __permanent_process \
73 __table ( struct process, processes, 01 )
75 #endif /* _GPXE_PROCESS_H */