Sfoglia il codice sorgente

Placeholder bzImage support

tags/v0.9.3
Michael Brown 17 anni fa
parent
commit
b07161f397
4 ha cambiato i file con 158 aggiunte e 0 eliminazioni
  1. 81
    0
      src/arch/i386/image/bzimage.c
  2. 73
    0
      src/arch/i386/include/bzimage.h
  3. 1
    0
      src/config.h
  4. 3
    0
      src/core/config.c

+ 81
- 0
src/arch/i386/image/bzimage.c Vedi File

@@ -0,0 +1,81 @@
1
+/*
2
+ * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
3
+ *
4
+ * This program is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU General Public License as
6
+ * published by the Free Software Foundation; either version 2 of the
7
+ * License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful, but
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
+ * General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with this program; if not, write to the Free Software
16
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
+ */
18
+
19
+/**
20
+ * @file
21
+ *
22
+ * Linux bzImage image format
23
+ *
24
+ */
25
+
26
+#include <errno.h>
27
+#include <assert.h>
28
+#include <realmode.h>
29
+#include <bzimage.h>
30
+#include <gpxe/uaccess.h>
31
+#include <gpxe/image.h>
32
+#include <gpxe/segment.h>
33
+#include <gpxe/memmap.h>
34
+#include <gpxe/shutdown.h>
35
+
36
+struct image_type bzimage_image_type __image_type ( PROBE_NORMAL );
37
+
38
+/**
39
+ * Execute bzImage image
40
+ *
41
+ * @v image		bzImage image
42
+ * @ret rc		Return status code
43
+ */
44
+static int bzimage_exec ( struct image *image ) {
45
+}
46
+
47
+/**
48
+ * Load bzImage image into memory
49
+ *
50
+ * @v image		bzImage file
51
+ * @ret rc		Return status code
52
+ */
53
+int bzimage_load ( struct image *image ) {
54
+	struct bzimage_header bzhdr;
55
+
56
+	/* Sanity check */
57
+	if ( image->len < ( BZHDR_OFFSET + sizeof ( bzhdr ) ) ) {
58
+		DBGC ( image, "BZIMAGE %p too short\n", image );
59
+		return -ENOEXEC;
60
+	}
61
+
62
+	/* Read and verify header */
63
+	copy_from_user ( &bzhdr, image->data, BZHDR_OFFSET, sizeof ( bzhdr ) );
64
+	if ( bzhdr.header != BZIMAGE_SIGNATURE ) {
65
+		DBGC ( image, "BZIMAGE %p not a bzImage\n", image );
66
+		return -ENOEXEC;
67
+	}
68
+
69
+	/* This is a bzImage image, valid or otherwise */
70
+	if ( ! image->type )
71
+		image->type = &bzimage_image_type;
72
+
73
+	return 0;
74
+}
75
+
76
+/** Linux bzImage image type */
77
+struct image_type bzimage_image_type __image_type ( PROBE_NORMAL ) = {
78
+	.name = "bzImage",
79
+	.load = bzimage_load,
80
+	.exec = bzimage_exec,
81
+};

+ 73
- 0
src/arch/i386/include/bzimage.h Vedi File

@@ -0,0 +1,73 @@
1
+#ifndef _BZIMAGE_H
2
+#define _BZIMAGE_H
3
+
4
+#include <stdint.h>
5
+
6
+/**
7
+ * A bzImage header
8
+ *
9
+ * As documented in Documentation/i386/boot.txt
10
+ */
11
+struct bzimage_header {
12
+	/** The size of the setup in sectors
13
+	 *
14
+	 * If this field contains 0, assume it contains 4.
15
+	 */
16
+	uint8_t setup_sects;
17
+	/** If set, the root is mounted readonly */
18
+	uint16_t root_flags;
19
+	/** DO NOT USE - for bootsect.S use only */
20
+	uint16_t syssize;
21
+	/** DO NOT USE - obsolete */
22
+	uint16_t swap_dev;
23
+	/** DO NOT USE - for bootsect.S use only */
24
+	uint16_t ram_size;
25
+	/** Video mode control */
26
+	uint16_t vid_mode;
27
+	/** Default root device number */
28
+	uint16_t root_dev;
29
+	/** 0xAA55 magic number */
30
+	uint16_t boot_flag;
31
+	/** Jump instruction */
32
+	uint16_t jump;
33
+	/** Magic signature "HdrS" */
34
+	uint32_t header;
35
+	/** Boot protocol version supported */
36
+	uint16_t version;
37
+	/** Boot loader hook (see below) */
38
+	uint32_t realmode_swtch;
39
+	/** The load-low segment (0x1000) (obsolete) */
40
+	uint16_t start_sys;
41
+	/** Pointer to kernel version string */
42
+	uint16_t kernel_version;
43
+	/** Boot loader identifier */
44
+	uint8_t type_of_loader;
45
+	/** Boot protocol option flags */
46
+	uint8_t loadflags;
47
+	/** Move to high memory size (used with hooks) */
48
+	uint16_t setup_move_size;
49
+	/** Boot loader hook (see below) */
50
+	uint32_t code32_start;
51
+	/** initrd load address (set by boot loader) */
52
+	uint32_t ramdisk_image;
53
+	/** initrd size (set by boot loader) */
54
+	uint32_t ramdisk_size;
55
+	/** DO NOT USE - for bootsect.S use only */
56
+	uint32_t bootsect_kludge;
57
+	/** Free memory after setup end */
58
+	uint16_t heap_end_ptr;
59
+	/** Unused */
60
+	uint16_t pad1;
61
+	/** 32-bit pointer to the kernel command line */
62
+	uint32_t cmd_line_ptr;
63
+	/** Highest legal initrd address */
64
+	uint32_t initrd_addr_max;
65
+} __attribute__ (( packed ));
66
+
67
+/** Offset of bzImage header within kernel image */
68
+#define BZHDR_OFFSET 0x1f1
69
+
70
+/** bzImage magic signature value */
71
+#define BZIMAGE_SIGNATURE 0x53726448
72
+
73
+#endif /* _BZIMAGE_H */

+ 1
- 0
src/config.h Vedi File

@@ -108,6 +108,7 @@
108 108
 #undef	IMAGE_WINCE		/* WinCE image support */
109 109
 #define	IMAGE_PXE		/* PXE image support */
110 110
 #define IMAGE_SCRIPT		/* gPXE script image support */
111
+#define IMAGE_BZIMAGE		/* Linux bzImage image support */
111 112
 
112 113
 /* @END general.h */ 
113 114
 

+ 3
- 0
src/core/config.c Vedi File

@@ -140,6 +140,9 @@ REQUIRE_OBJECT ( pxe_image );
140 140
 #ifdef IMAGE_SCRIPT
141 141
 REQUIRE_OBJECT ( script );
142 142
 #endif
143
+#ifdef IMAGE_BZIMAGE
144
+REQUIRE_OBJECT ( bzimage );
145
+#endif
143 146
 
144 147
 /*
145 148
  * Drag in all requested commands

Loading…
Annulla
Salva