iPXE
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.

Functions

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

Variables

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

Detailed Description

Initialisation, startup and shutdown routines.

Definition in file init.c.


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;
}

Variable Documentation

int started = 0 [static]

"startup() has been called" flag

Definition at line 37 of file init.c.

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