iPXE
Defines | Functions | Variables
embedded.c File Reference

Embedded image support. More...

#include <string.h>
#include <ipxe/image.h>
#include <ipxe/uaccess.h>
#include <ipxe/init.h>

Go to the source code of this file.

Defines

#define EMBED(_index, _path, _name)
#define EMBED(_index, _path, _name)

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
static void embedded_init (void)
 Register all embedded images.
struct init_fn embedded_init_fn __init_fn (INIT_LATE)
 Embedded image initialisation function.

Variables

static struct image embedded_images []

Detailed Description

Embedded image support.

Embedded images are images built into the iPXE binary and do not require fetching over the network.

Definition in file embedded.c.


Define Documentation

#define EMBED (   _index,
  _path,
  _name 
)
Value:
extern char embedded_image_ ## _index ## _data[];               \
        extern char embedded_image_ ## _index ## _len[];                \
        __asm__ ( ".section \".rodata\", \"a\", " PROGBITS "\n\t"       \
                  "\nembedded_image_" #_index "_data:\n\t"              \
                  ".incbin \"" _path "\"\n\t"                           \
                  "\nembedded_image_" #_index "_end:\n\t"               \
                  ".equ embedded_image_" #_index "_len, "               \
                        "( embedded_image_" #_index "_end - "           \
                        "  embedded_image_" #_index "_data )\n\t"       \
                  ".previous\n\t" );

Definition at line 33 of file embedded.c.

#define EMBED (   _index,
  _path,
  _name 
)
Value:
{                                       \
        .refcnt = REF_INIT ( ref_no_free ),                             \
        .name = _name,                                                  \
        .data = ( userptr_t ) ( embedded_image_ ## _index ## _data ),   \
        .len = ( size_t ) embedded_image_ ## _index ## _len,            \
},

Definition at line 33 of file embedded.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
static void embedded_init ( void  ) [static]

Register all embedded images.

Definition at line 46 of file embedded.c.

References image::data, data, DBG, image_select(), image::len, image::name, rc, register_image(), strerror(), and virt_to_user().

                                   {
        int i;
        struct image *image;
        void *data;
        int rc;

        /* Skip if we have no embedded images */
        if ( ! sizeof ( embedded_images ) )
                return;

        /* Fix up data pointers and register images */
        for ( i = 0 ; i < ( int ) ( sizeof ( embedded_images ) /
                                    sizeof ( embedded_images[0] ) ) ; i++ ) {
                image = &embedded_images[i];

                /* virt_to_user() cannot be used in a static
                 * initialiser, so we cast the pointer to a userptr_t
                 * in the initialiser and fix it up here.  (This will
                 * actually be a no-op on most platforms.)
                 */
                data = ( ( void * ) image->data );
                image->data = virt_to_user ( data );

                DBG ( "Embedded image \"%s\": %zd bytes at %p\n",
                      image->name, image->len, data );

                if ( ( rc = register_image ( image ) ) != 0 ) {
                        DBG ( "Could not register embedded image \"%s\": "
                              "%s\n", image->name, strerror ( rc ) );
                        return;
                }
        }

        /* Select the first image */
        image = &embedded_images[0];
        if ( ( rc = image_select ( image ) ) != 0 ) {
                DBG ( "Could not select embedded image \"%s\": %s\n",
                      image->name, strerror ( rc ) );
                return;
        }
}
struct init_fn embedded_init_fn __init_fn ( INIT_LATE  ) [read]

Embedded image initialisation function.


Variable Documentation

struct image embedded_images[] [static]
Initial value:
 {
        EMBED_ALL
}

Definition at line 39 of file embedded.c.