iPXE
Functions
sdi.c File Reference

System Deployment Image (SDI) More...

#include <stdint.h>
#include <string.h>
#include <errno.h>
#include <realmode.h>
#include <sdi.h>
#include <ipxe/image.h>
#include <ipxe/features.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FEATURE (FEATURE_IMAGE,"SDI", DHCP_EB_FEATURE_SDI, 1)
static int sdi_parse_header (struct image *image, struct sdi_header *sdi)
 Parse SDI image header.
static int sdi_exec (struct image *image)
 Execute SDI image.
static int sdi_probe (struct image *image)
 Probe SDI image.
struct image_type sdi_image_type __image_type (PROBE_NORMAL)
 SDI image type.

Detailed Description

System Deployment Image (SDI)

Based on the MSDN article "RAM boot using SDI in Windows XP Embedded with Service Pack 1", available at the time of writing from:

http://msdn.microsoft.com/en-us/library/ms838543.aspx

Definition in file sdi.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
FEATURE ( FEATURE_IMAGE  ,
"SDI"  ,
DHCP_EB_FEATURE_SDI  ,
 
)
static int sdi_parse_header ( struct image image,
struct sdi_header sdi 
) [static]

Parse SDI image header.

Parameters:
imageSDI file
sdiSDI header to fill in
Return values:
rcReturn status code

Definition at line 54 of file sdi.c.

References copy_from_user(), image::data, DBGC, ENOEXEC, image::len, sdi_header::magic, and SDI_MAGIC.

Referenced by sdi_exec(), and sdi_probe().

                                                                            {

        /* Sanity check */
        if ( image->len < sizeof ( *sdi ) ) {
                DBGC ( image, "SDI %p too short for SDI header\n", image );
                return -ENOEXEC;
        }

        /* Read in header */
        copy_from_user ( sdi, image->data, 0, sizeof ( *sdi ) );

        /* Check signature */
        if ( sdi->magic != SDI_MAGIC ) {
                DBGC ( image, "SDI %p is not an SDI image\n", image );
                return -ENOEXEC;
        }

        return 0;
}
static int sdi_exec ( struct image image) [static]

Execute SDI image.

Parameters:
imageSDI file
Return values:
rcReturn status code

Definition at line 80 of file sdi.c.

References __asm__(), assert, sdi_header::boot_offset, sdi_header::boot_size, image::data, DBGC, ECANCELED, ENOTTY, image::len, memcpy_user(), rc, REAL_CODE, real_to_user(), SDI_BOOT_OFF, SDI_BOOT_SEG, sdi_parse_header(), SDI_WTF, and user_to_phys().

                                            {
        struct sdi_header sdi;
        uint32_t sdiptr;
        int rc;

        /* Parse image header */
        if ( ( rc = sdi_parse_header ( image, &sdi ) ) != 0 )
                return rc;

        /* Check that image is bootable */
        if ( sdi.boot_size == 0 ) {
                DBGC ( image, "SDI %p is not bootable\n", image );
                return -ENOTTY;
        }
        DBGC ( image, "SDI %p image at %08lx+%08zx\n",
               image, user_to_phys ( image->data, 0 ), image->len );
        DBGC ( image, "SDI %p boot code at %08lx+%llx\n", image,
               user_to_phys ( image->data, sdi.boot_offset ), sdi.boot_size );

        /* Copy boot code */
        memcpy_user ( real_to_user ( SDI_BOOT_SEG, SDI_BOOT_OFF ), 0,
                      image->data, sdi.boot_offset, sdi.boot_size );

        /* Jump to boot code */
        sdiptr = ( user_to_phys ( image->data, 0 ) | SDI_WTF );
        __asm__ __volatile__ ( REAL_CODE ( "ljmp %0, %1\n\t" )
                               : : "i" ( SDI_BOOT_SEG ),
                                   "i" ( SDI_BOOT_OFF ),
                                   "d" ( sdiptr ) );

        /* There is no way for the image to return, since we provide
         * no return address.
         */
        assert ( 0 );

        return -ECANCELED; /* -EIMPOSSIBLE */
}
static int sdi_probe ( struct image image) [static]

Probe SDI image.

Parameters:
imageSDI file
Return values:
rcReturn status code

Definition at line 124 of file sdi.c.

References rc, and sdi_parse_header().

                                             {
        struct sdi_header sdi;
        int rc;

        /* Parse image */
        if ( ( rc = sdi_parse_header ( image, &sdi ) ) != 0 )
                return rc;

        return 0;
}
struct image_type sdi_image_type __image_type ( PROBE_NORMAL  ) [read]

SDI image type.