iPXE
init.h File Reference
#include <ipxe/tables.h>

Go to the source code of this file.

Data Structures

struct  init_fn
 An initialisation function. More...
struct  startup_fn
 A startup/shutdown function. More...

Macros

#define INIT_FNS   __table ( struct init_fn, "init_fns" )
 Initialisation function table.
#define __init_fn(init_order)
 Declare an initialisation functon.
#define INIT_EARLY   01
 Early initialisation.
#define INIT_CONSOLE   02
 Console initialisation.
#define INIT_NORMAL   03
 Normal initialisation.
#define INIT_LATE   04
 Late initialisation.
#define STARTUP_FNS   __table ( struct startup_fn, "startup_fns" )
 Startup/shutdown function table.
#define __startup_fn(startup_order)
 Declare a startup/shutdown function.
#define STARTUP_EARLY   01
 Early startup.
#define STARTUP_NORMAL   02
 Normal startup.
#define STARTUP_LATE   03
 Late startup.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)
void initialise (void)
 Initialise iPXE.
void startup (void)
 Start up iPXE.
void shutdown (int booting)
 Shut down iPXE.
static void shutdown_boot (void)
 Shut down system for OS boot.
static void shutdown_exit (void)
 Shut down system for exit back to firmware.

Macro Definition Documentation

◆ INIT_FNS

#define INIT_FNS   __table ( struct init_fn, "init_fns" )

Initialisation function table.

Definition at line 21 of file init.h.

Referenced by initialise().

◆ __init_fn

#define __init_fn ( init_order)
Value:
__table_entry ( INIT_FNS, init_order )
#define INIT_FNS
Initialisation function table.
Definition init.h:21
#define __table_entry(table, idx)
Declare a linker table entry.
Definition tables.h:239

Declare an initialisation functon.

Definition at line 24 of file init.h.

Referenced by __init_fn(), __init_fn(), __init_fn(), and __init_fn().

◆ STARTUP_FNS

#define STARTUP_FNS   __table ( struct startup_fn, "startup_fns" )

Startup/shutdown function table.

Definition at line 50 of file init.h.

Referenced by shutdown(), and startup().

◆ __startup_fn

#define __startup_fn ( startup_order)
Value:
__table_entry ( STARTUP_FNS, startup_order )
#define STARTUP_FNS
Startup/shutdown function table.
Definition init.h:50

Declare a startup/shutdown function.

Definition at line 53 of file init.h.

53#define __startup_fn( startup_order ) \
54 __table_entry ( STARTUP_FNS, startup_order )

Referenced by __startup_fn(), __startup_fn(), and __startup_fn().

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ initialise()

void initialise ( void )
extern

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 53 of file init.c.

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

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 )
extern

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 70 of file init.c.

70 {
71 struct startup_fn *startup_fn;
72
73 if ( started )
74 return;
75
76 /* Call registered startup functions */
78 if ( startup_fn->startup ) {
79 DBGC ( colour, "INIT startup %s...\n",
82 }
83 }
84
85 started = 1;
86 DBGC ( colour, "INIT startup complete\n" );
87}
static int started
"startup() has been called" flag
Definition init.c:38
A startup/shutdown function.
Definition init.h:43
void(* startup)(void)
Definition init.h:45
const char * name
Definition init.h:44

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

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

◆ shutdown()

void shutdown ( int flags)
extern

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 101 of file init.c.

101 {
102 struct startup_fn *startup_fn;
103
104 if ( ! started )
105 return;
106
107 /* Call registered shutdown functions (in reverse order) */
109 if ( startup_fn->shutdown ) {
110 DBGC ( colour, "INIT shutdown %s...\n",
111 startup_fn->name );
113 }
114 }
115
116 /* Reset console */
118
119 started = 0;
120 DBGC ( colour, "INIT shutdown complete\n" );
121}
uint8_t flags
Flags.
Definition ena.h:7
static void console_reset(void)
Reset console.
Definition console.h:215
void(* shutdown)(int booting)
Definition init.h:46
#define for_each_table_entry_reverse(pointer, table)
Iterate through all entries within a linker table in reverse order.
Definition tables.h:441

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().

◆ shutdown_boot()

void shutdown_boot ( void )
inlinestatic

Shut down system for OS boot.

Definition at line 78 of file init.h.

78 {
79 shutdown ( 1 );
80}
void shutdown(int booting)
Shut down iPXE.
Definition init.c:101

References shutdown().

Referenced by bzimage_exec(), efi_shutdown_hook(), elfboot_exec(), int22(), lkrn_exec(), multiboot_exec(), nbi_exec(), and pxenv_stop_undi().

◆ shutdown_exit()

void shutdown_exit ( void )
inlinestatic

Shut down system for exit back to firmware.

Definition at line 86 of file init.h.

86 {
87 shutdown ( 0 );
88}

References shutdown().

Referenced by efi_unload(), and main().