From f11900a9c6c85b6167a3ad6c6a3efc6c9b8e1686 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sat, 13 Jan 2007 17:28:51 +0000 Subject: I prefer IMAGE_XXX to XXX_IMAGE. Add IMAGE_PXE to use the new image format framework. "kernel pxelinux.0" now works. --- src/arch/i386/image/pxe_image.c | 83 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 src/arch/i386/image/pxe_image.c (limited to 'src/arch') diff --git a/src/arch/i386/image/pxe_image.c b/src/arch/i386/image/pxe_image.c new file mode 100644 index 000000000..f88c45970 --- /dev/null +++ b/src/arch/i386/image/pxe_image.c @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2007 Michael Brown . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/** + * @file + * + * PXE image format + * + */ + +#include +#include +#include +#include + +/** PXE load address segment */ +#define PXE_LOAD_SEGMENT 0 + +/** PXE load address offset */ +#define PXE_LOAD_OFFSET 0x7c00 + +struct image_type pxe_image_type __image_type ( PROBE_PXE ); + +/** + * Execute PXE image + * + * @v image PXE image + * @ret rc Return status code + */ +static int pxe_exec ( struct image *image __unused ) { + return pxe_boot(); +} + +/** + * Load PXE image into memory + * + * @v image PXE file + * @ret rc Return status code + */ +int pxe_load ( struct image *image ) { + userptr_t buffer = real_to_user ( 0, 0x7c00 ); + size_t filesz = image->len; + size_t memsz = image->len; + int rc; + + /* There are no signature checks for PXE; we will accept anything */ + if ( ! image->type ) + image->type = &pxe_image_type; + + /* Verify and prepare segment */ + if ( ( rc = prep_segment ( buffer, filesz, memsz ) != 0 ) ) { + DBG ( "PXE image could not prepare segment: %s\n", + strerror ( rc ) ); + return rc; + } + + /* Copy image to segment */ + memcpy_user ( buffer, 0, image->data, 0, filesz ); + + return 0; +} + +/** PXE image type */ +struct image_type pxe_image_type __image_type ( PROBE_PXE ) = { + .name = "PXE", + .load = pxe_load, + .exec = pxe_exec, +}; -- cgit v1.2.3-55-g7522