iPXE
Macros | Functions | Variables
init.c File Reference

Initialisation, startup and shutdown routines. More...

#include <ipxe/device.h>
#include <ipxe/console.h>
#include <ipxe/init.h>

Go to the source code of this file.

Macros

#define colour   table_start ( INIT_FNS )
 Colour for debug messages. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
void initialise (void)
 Initialise iPXE. More...
 
void startup (void)
 Start up iPXE. More...
 
void shutdown (int flags)
 Shut down iPXE. More...
 

Variables

static int started = 0
 "startup() has been called" flag More...
 

Detailed Description

Initialisation, startup and shutdown routines.

Definition in file init.c.

Macro Definition Documentation

◆ colour

#define colour   table_start ( INIT_FNS )

Colour for debug messages.

Definition at line 40 of file init.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ initialise()

void initialise ( void  )

Initialise iPXE.

This function performs the one-time-only and irreversible initialisation steps, such as initialising the heap. It must be called before (almost) any other function.

There is, by definition, no counterpart to this function on the shutdown path.

Definition at line 52 of file init.c.

52  {
53  struct init_fn *init_fn;
54 
55  /* Call registered initialisation functions */
57  DBGC ( colour, "INIT initialising %s...\n", init_fn->name );
58  init_fn->initialise ();
59  }
60 }
#define INIT_FNS
Initialisation function table.
Definition: init.h:20
void(* initialise)(void)
Definition: init.h:16
#define DBGC(...)
Definition: compiler.h:505
#define colour
Colour for debug messages.
Definition: init.c:40
An initialisation function.
Definition: init.h:14
const char * name
Definition: init.h:15
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition: tables.h:385

References colour, DBGC, for_each_table_entry, INIT_FNS, init_fn::initialise, and init_fn::name.

Referenced by _efidrv_start(), main(), and undi_loader().

◆ startup()

void startup ( void  )

Start up iPXE.

This function performs the repeatable initialisation steps, such as probing devices. You may call startup() and shutdown() multiple times (as is done via the PXE API when PXENV_START_UNDI is used).

Definition at line 69 of file init.c.

69  {
70  struct startup_fn *startup_fn;
71 
72  if ( started )
73  return;
74 
75  /* Call registered startup functions */
77  if ( startup_fn->startup ) {
78  DBGC ( colour, "INIT startup %s...\n",
79  startup_fn->name );
81  }
82  }
83 
84  started = 1;
85  DBGC ( colour, "INIT startup complete\n" );
86 }
#define DBGC(...)
Definition: compiler.h:505
const char * name
Definition: init.h:43
A startup/shutdown function.
Definition: init.h:42
#define colour
Colour for debug messages.
Definition: init.c:40
static int started
"startup() has been called" flag
Definition: init.c:37
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition: tables.h:385
void(* startup)(void)
Definition: init.h:44
#define STARTUP_FNS
Startup/shutdown function table.
Definition: init.h:49

References colour, DBGC, for_each_table_entry, startup_fn::name, started, startup_fn::startup, and STARTUP_FNS.

Referenced by _efidrv_start(), main(), pxenv_start_undi(), and select_media().

◆ shutdown()

void shutdown ( int  flags)

Shut down iPXE.

Parameters
flagsShutdown behaviour flags

This function reverses the actions of startup(), and leaves iPXE in a state ready to be removed from memory. You may call startup() again after calling shutdown().

Call this function only once, before either exiting main() or starting up a non-returnable image.

Definition at line 100 of file init.c.

100  {
101  struct startup_fn *startup_fn;
102 
103  if ( ! started )
104  return;
105 
106  /* Call registered shutdown functions (in reverse order) */
108  if ( startup_fn->shutdown ) {
109  DBGC ( colour, "INIT shutdown %s...\n",
110  startup_fn->name );
112  }
113  }
114 
115  /* Reset console */
116  console_reset();
117 
118  started = 0;
119  DBGC ( colour, "INIT shutdown complete\n" );
120 }
#define DBGC(...)
Definition: compiler.h:505
#define for_each_table_entry_reverse(pointer, table)
Iterate through all entries within a linker table in reverse order.
Definition: tables.h:440
const char * name
Definition: init.h:43
A startup/shutdown function.
Definition: init.h:42
#define colour
Colour for debug messages.
Definition: init.c:40
static int started
"startup() has been called" flag
Definition: init.c:37
uint8_t flags
Flags.
Definition: ena.h:18
static void console_reset(void)
Reset console.
Definition: console.h:214
void(* shutdown)(int booting)
Definition: init.h:45
#define STARTUP_FNS
Startup/shutdown function table.
Definition: init.h:49

References colour, console_reset(), DBGC, flags, for_each_table_entry_reverse, startup_fn::name, startup_fn::shutdown, started, and STARTUP_FNS.

Referenced by intelxl_admin_shutdown(), shutdown_boot(), and shutdown_exit().

Variable Documentation

◆ started

int started = 0
static

"startup() has been called" flag

Definition at line 37 of file init.c.

Referenced by librm_test_exec(), profile_start_at(), shutdown(), startup(), undinet_call(), and xenbus_backend_wait().