iPXE
Data Structures | Defines | Functions
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...

Defines

#define INIT_FNS   __table ( struct init_fn, "init_fns" )
 Initialisation function table.
#define __init_fn(init_order)   __table_entry ( INIT_FNS, 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)   __table_entry ( STARTUP_FNS, 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)
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.

Define Documentation

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

Initialisation function table.

Definition at line 19 of file init.h.

Referenced by initialise().

#define __init_fn (   init_order)    __table_entry ( INIT_FNS, init_order )

Declare an initialisation functon.

Definition at line 22 of file init.h.

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

Startup/shutdown function table.

Definition at line 47 of file init.h.

Referenced by shutdown(), and startup().

#define __startup_fn (   startup_order)    __table_entry ( STARTUP_FNS, startup_order )

Declare a startup/shutdown function.

Definition at line 50 of file init.h.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
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 49 of file init.c.

References for_each_table_entry, INIT_FNS, and init_fn::initialise.

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

                         {
        struct init_fn *init_fn;

        /* Call registered initialisation functions */
        for_each_table_entry ( init_fn, INIT_FNS )
                init_fn->initialise ();
}
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 64 of file init.c.

References for_each_table_entry, started, startup_fn::startup, and STARTUP_FNS.

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

                      {
        struct startup_fn *startup_fn;

        if ( started )
                return;

        /* Call registered startup functions */
        for_each_table_entry ( startup_fn, STARTUP_FNS ) {
                if ( startup_fn->startup )
                        startup_fn->startup();
        }

        started = 1;
}
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 91 of file init.c.

References console_reset(), for_each_table_entry_reverse, startup_fn::shutdown, started, and STARTUP_FNS.

                            {
        struct startup_fn *startup_fn;

        if ( ! started )
                return;

        /* Call registered shutdown functions (in reverse order) */
        for_each_table_entry_reverse ( startup_fn, STARTUP_FNS ) {
                if ( startup_fn->shutdown )
                        startup_fn->shutdown ( flags );
        }

        /* Reset console */
        console_reset();

        started = 0;
}
static void shutdown_boot ( void  ) [inline, static]

Shut down system for OS boot.

Definition at line 75 of file init.h.

References shutdown.

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

                                          {
        shutdown ( 1 );
}
static void shutdown_exit ( void  ) [inline, static]

Shut down system for exit back to firmware.

Definition at line 83 of file init.h.

References shutdown.

Referenced by efi_unload(), and main().

                                          {
        shutdown ( 0 );
}