iPXE
Functions
process.c File Reference

Processes. More...

#include <ipxe/list.h>
#include <ipxe/init.h>
#include <ipxe/process.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static LIST_HEAD (run_queue)
 Process run queue. More...
 
void * process_object (struct process *process)
 Get pointer to object containing process. More...
 
void process_add (struct process *process)
 Add process to process list. More...
 
void process_del (struct process *process)
 Remove process from process list. More...
 
void step (void)
 Single-step a single process. More...
 
static void init_processes (void)
 Initialise processes. More...
 
struct init_fn process_init_fn __init_fn (INIT_NORMAL)
 Process initialiser. More...
 

Detailed Description

Processes.

We implement a trivial form of cooperative multitasking, in which all processes share a single stack and address space.

Definition in file process.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ LIST_HEAD()

static LIST_HEAD ( run_queue  )
static

Process run queue.

◆ process_object()

void* process_object ( struct process process)

Get pointer to object containing process.

Parameters
processProcess
Return values
objectContaining object

Definition at line 47 of file process.c.

47  {
48  return ( ( ( void * ) process ) - process->desc->offset );
49 }
A process.
Definition: process.h:17
size_t offset
Offset of process within containing object.
Definition: process.h:35
struct process_descriptor * desc
Process descriptor.
Definition: process.h:21

References process::desc, and process_descriptor::offset.

Referenced by step().

◆ process_add()

void process_add ( struct process process)

Add process to process list.

Parameters
processProcess

It is safe to call process_add() multiple times; further calls will have no effect.

Definition at line 59 of file process.c.

59  {
60  if ( ! process_running ( process ) ) {
61  DBGC ( PROC_COL ( process ), "PROCESS " PROC_FMT
62  " starting\n", PROC_DBG ( process ) );
63  ref_get ( process->refcnt );
64  list_add_tail ( &process->list, &run_queue );
65  } else {
66  DBGC ( PROC_COL ( process ), "PROCESS " PROC_FMT
67  " already started\n", PROC_DBG ( process ) );
68  }
69 }
A process.
Definition: process.h:17
#define DBGC(...)
Definition: compiler.h:505
struct list_head list
List of processes.
Definition: process.h:19
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition: list.h:93
#define ref_get(refcnt)
Get additional reference to object.
Definition: refcnt.h:92
static int process_running(struct process *process)
Check if process is running.
Definition: process.h:175
#define PROC_DBG(process)
printf() arguments for representing a process
Definition: process.h:216
#define PROC_COL(process)
Find debugging colourisation for a process.
Definition: process.h:205
#define PROC_FMT
printf() format string for PROC_DBG()
Definition: process.h:208
struct refcnt * refcnt
Reference counter.
Definition: process.h:27

References DBGC, process::list, list_add_tail, PROC_COL, PROC_DBG, PROC_FMT, process_running(), ref_get, and process::refcnt.

Referenced by efi_local_open(), efi_pxe_udp_schedule_close(), fc_els_request(), fcpcmd_start_send(), gve_restart(), gve_startup(), http_reopen(), hub_complete(), hub_open(), ib_cmrc_close(), imux_probe(), init_processes(), iscsi_tx_resume(), net80211_autoassociate(), peerblk_dequeue(), peerblk_enqueue(), peerblk_retrieval_close(), peerblk_step(), peermux_block_close(), peermux_info_close(), process_init(), sanpath_open(), scsidev_ready(), tcp_close(), tcp_rx(), tls_tx_resume(), usbblk_in_complete(), usbblk_out_complete(), usbblk_start(), validator_xfer_close(), and xcm_reopen().

◆ process_del()

void process_del ( struct process process)

Remove process from process list.

Parameters
processProcess

It is safe to call process_del() multiple times; further calls will have no effect.

Definition at line 79 of file process.c.

79  {
80  if ( process_running ( process ) ) {
81  DBGC ( PROC_COL ( process ), "PROCESS " PROC_FMT
82  " stopping\n", PROC_DBG ( process ) );
83  list_del ( &process->list );
85  ref_put ( process->refcnt );
86  } else {
87  DBGC ( PROC_COL ( process ), "PROCESS " PROC_FMT
88  " already stopped\n", PROC_DBG ( process ) );
89  }
90 }
A process.
Definition: process.h:17
#define DBGC(...)
Definition: compiler.h:505
struct list_head list
List of processes.
Definition: process.h:19
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
static int process_running(struct process *process)
Check if process is running.
Definition: process.h:175
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45
#define PROC_DBG(process)
printf() arguments for representing a process
Definition: process.h:216
#define PROC_COL(process)
Find debugging colourisation for a process.
Definition: process.h:205
#define PROC_FMT
printf() format string for PROC_DBG()
Definition: process.h:208
struct refcnt * refcnt
Reference counter.
Definition: process.h:27
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106

References DBGC, INIT_LIST_HEAD, process::list, list_del, PROC_COL, PROC_DBG, PROC_FMT, process_running(), ref_put, and process::refcnt.

Referenced by efi_local_close(), efi_pxe_udp_close(), efi_pxe_udp_open(), fc_els_close(), fc_ns_query_close(), fcpcmd_stop_send(), gve_close(), http_close(), hub_close(), hub_refill(), hw_finished(), ib_cmrc_shutdown(), imux_shutdown(), iscsi_close(), iscsi_tx_pause(), net80211_netdev_close(), net80211_step_associate(), peerblk_reset(), peermux_close(), peermux_step(), sanpath_close(), scsidev_close(), step(), tcp_close(), tls_close(), usbblk_stop(), validator_finished(), xcm_close(), xcm_destroy(), and xcm_reopen().

◆ step()

void step ( void  )

Single-step a single process.

This executes a single step of the first process in the run queue, and moves the process to the end of the run queue.

Definition at line 98 of file process.c.

98  {
99  struct process *process;
100  struct process_descriptor *desc;
101  void *object;
102 
103  if ( ( process = list_first_entry ( &run_queue, struct process,
104  list ) ) ) {
105  ref_get ( process->refcnt ); /* Inhibit destruction mid-step */
106  desc = process->desc;
107  object = process_object ( process );
108  if ( desc->reschedule ) {
109  list_del ( &process->list );
110  list_add_tail ( &process->list, &run_queue );
111  } else {
112  process_del ( process );
113  }
114  DBGC2 ( PROC_COL ( process ), "PROCESS " PROC_FMT
115  " executing\n", PROC_DBG ( process ) );
116  desc->step ( object );
117  DBGC2 ( PROC_COL ( process ), "PROCESS " PROC_FMT
118  " finished executing\n", PROC_DBG ( process ) );
119  ref_put ( process->refcnt ); /* Allow destruction */
120  }
121 }
A process.
Definition: process.h:17
uint64_t desc
Microcode descriptor list physical address.
Definition: ucode.h:12
A process descriptor.
Definition: process.h:31
struct list_head list
List of processes.
Definition: process.h:19
void process_del(struct process *process)
Remove process from process list.
Definition: process.c:79
#define list_first_entry(list, type, member)
Get the container of the first entry in a list.
Definition: list.h:333
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
void * process_object(struct process *process)
Get pointer to object containing process.
Definition: process.c:47
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition: list.h:93
#define ref_get(refcnt)
Get additional reference to object.
Definition: refcnt.h:92
#define PROC_DBG(process)
printf() arguments for representing a process
Definition: process.h:216
#define DBGC2(...)
Definition: compiler.h:522
struct process_descriptor * desc
Process descriptor.
Definition: process.h:21
#define PROC_COL(process)
Find debugging colourisation for a process.
Definition: process.h:205
#define PROC_FMT
printf() format string for PROC_DBG()
Definition: process.h:208
struct refcnt * refcnt
Reference counter.
Definition: process.h:27
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106

References DBGC2, desc, process::desc, process::list, list_add_tail, list_del, list_first_entry, PROC_COL, PROC_DBG, PROC_FMT, process_del(), process_object(), ref_get, ref_put, and process::refcnt.

Referenced by ath5k_hw_rf_check_gainf_readback(), ath5k_hw_rf_gainf_corr(), comboot_resolv(), efi_download_poll(), efi_ifr_numeric_op(), efi_pxe_dhcp(), efi_pxe_mtftp(), efi_pxe_udp_read(), gdbmach_set_single_step(), getchar(), getchar_timeout(), int22(), iwlist(), md4_digest(), md5_digest(), monojob_wait(), open(), pxenv_tftp_get_fsize(), pxenv_tftp_open(), pxenv_tftp_read(), pxenv_tftp_read_file(), pxenv_udp_read(), read_user(), sandev_command(), sandev_describe(), sandev_reopen(), select(), sha1_digest(), sleep_interruptible(), spi_bit_transfer(), tcp_shutdown(), x25519_ladder(), and x25519_step().

◆ init_processes()

static void init_processes ( void  )
static

Initialise processes.

Definition at line 127 of file process.c.

127  {
128  struct process *process;
129 
131  process_add ( process );
132 }
A process.
Definition: process.h:17
#define PERMANENT_PROCESSES
Permanent process table.
Definition: process.h:180
void process_add(struct process *process)
Add process to process list.
Definition: process.c:59
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition: tables.h:385

References for_each_table_entry, PERMANENT_PROCESSES, and process_add().

◆ __init_fn()

struct init_fn process_init_fn __init_fn ( INIT_NORMAL  )

Process initialiser.