Added the embedded pxelinux payload patch from hpa.

This commit is contained in:
Michael Brown
2008-01-08 15:51:36 +00:00
parent 3311169707
commit 74fd544101
6 changed files with 107 additions and 0 deletions

7
src/image/embed.S Normal file
View File

@@ -0,0 +1,7 @@
.section ".data", "aw"
.balign 4
.globl _embedded_image_start
_embedded_image_start:
.incbin EMBEDIMG
.globl _embedded_image_end
_embedded_image_end:

49
src/image/embedded.c Normal file
View File

@@ -0,0 +1,49 @@
/** @file
*
* Take a possible embedded image and put it in a struct image
* data structure.
*/
#include <stdio.h>
#include <gpxe/image.h>
#include <gpxe/malloc.h>
#include <gpxe/uaccess.h>
#include <gpxe/umalloc.h>
#include <gpxe/embedded.h>
extern char _embedded_image_start[], _embedded_image_end[];
struct image *embedded_image(void)
{
static int reclaimed = 0;
struct image *image;
size_t eisize = _embedded_image_end - _embedded_image_start;
if ( !eisize )
return NULL; /* No embedded image */
if ( reclaimed )
return NULL; /* Already reclaimed */
printf("Embedded image: %d bytes at %p\n",
eisize, _embedded_image_start);
image = alloc_image();
if (!image)
return NULL;
image->len = eisize;
image->data = umalloc(eisize);
if (image->data == UNULL) {
image_put(image);
return image = NULL;
}
copy_to_user(image->data, 0, _embedded_image_start, eisize);
/* Reclaim embedded image memory */
reclaimed = 1;
mpopulate(_embedded_image_start, eisize);
return image;
}