embedded.c File Reference

Embedded image support. More...

#include <string.h>
#include <gpxe/image.h>
#include <gpxe/uaccess.h>
#include <gpxe/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)
static void embedded_image_free (struct refcnt *refcnt __unused)
 Free embedded image.
static void embedded_init (void)
 Register all embedded images.
struct init_fn embedded_init_fn __init_fn (INIT_NORMAL)
 Embedded image initialisation function.

Variables

static struct image embedded_images []


Detailed Description

Embedded image support.

Embedded images are images built into the gPXE 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 43 of file embedded.c.

#define EMBED ( _index,
_path,
_name   ) 

Value:

{                                       \
        .refcnt = { .free = embedded_image_free, },                     \
        .name = _name,                                                  \
        .data = ( userptr_t ) ( embedded_image_ ## _index ## _data ),   \
        .len = ( size_t ) embedded_image_ ## _index ## _len,            \
},

Definition at line 43 of file embedded.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

static void embedded_image_free ( struct refcnt *refcnt  __unused  )  [static]

Free embedded image.

Parameters:
refcnt Reference counter

Definition at line 22 of file embedded.c.

00022                                                        {
00023         /* Do nothing */
00024 }

static void embedded_init ( void   )  [static]

Register all embedded images.

Definition at line 56 of file embedded.c.

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

00056                                    {
00057         int i;
00058         struct image *image;
00059         void *data;
00060         int rc;
00061 
00062         /* Skip if we have no embedded images */
00063         if ( ! sizeof ( embedded_images ) )
00064                 return;
00065 
00066         /* Fix up data pointers and register images */
00067         for ( i = 0 ; i < ( int ) ( sizeof ( embedded_images ) /
00068                                     sizeof ( embedded_images[0] ) ) ; i++ ) {
00069                 image = &embedded_images[i];
00070 
00071                 /* virt_to_user() cannot be used in a static
00072                  * initialiser, so we cast the pointer to a userptr_t
00073                  * in the initialiser and fix it up here.  (This will
00074                  * actually be a no-op on most platforms.)
00075                  */
00076                 data = ( ( void * ) image->data );
00077                 image->data = virt_to_user ( data );
00078 
00079                 DBG ( "Embedded image \"%s\": %zd bytes at %p\n",
00080                       image->name, image->len, data );
00081 
00082                 if ( ( rc = register_image ( image ) ) != 0 ) {
00083                         DBG ( "Could not register embedded image \"%s\": "
00084                               "%s\n", image->name, strerror ( rc ) );
00085                         return;
00086                 }
00087         }
00088 
00089         /* Load the first image */
00090         image = &embedded_images[0];
00091         if ( ( rc = image_autoload ( image ) ) != 0 ) {
00092                 DBG ( "Could not load embedded image \"%s\": %s\n",
00093                       image->name, strerror ( rc ) );
00094                 return;
00095         }
00096 }

struct init_fn embedded_init_fn __init_fn ( INIT_NORMAL   )  [read]

Embedded image initialisation function.


Variable Documentation

struct image embedded_images[] [static]

Initial value:

 {
        EMBED_ALL
}

Definition at line 49 of file embedded.c.


Generated on Tue Apr 6 20:01:47 2010 for gPXE by  doxygen 1.5.7.1