소스 검색

I prefer IMAGE_XXX to XXX_IMAGE.

Add IMAGE_PXE to use the new image format framework.  "kernel pxelinux.0"
now works.
tags/v0.9.3
Michael Brown 18 년 전
부모
커밋
f11900a9c6
3개의 변경된 파일105개의 추가작업 그리고 21개의 파일을 삭제
  1. 83
    0
      src/arch/i386/image/pxe_image.c
  2. 11
    10
      src/config.h
  3. 11
    11
      src/core/config.c

+ 83
- 0
src/arch/i386/image/pxe_image.c 파일 보기

@@ -0,0 +1,83 @@
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
+ * PXE image format
23
+ *
24
+ */
25
+
26
+#include <gpxe/uaccess.h>
27
+#include <gpxe/image.h>
28
+#include <gpxe/segment.h>
29
+#include <pxe_call.h>
30
+
31
+/** PXE load address segment */
32
+#define PXE_LOAD_SEGMENT 0
33
+
34
+/** PXE load address offset */
35
+#define PXE_LOAD_OFFSET 0x7c00
36
+
37
+struct image_type pxe_image_type __image_type ( PROBE_PXE );
38
+
39
+/**
40
+ * Execute PXE image
41
+ *
42
+ * @v image		PXE image
43
+ * @ret rc		Return status code
44
+ */
45
+static int pxe_exec ( struct image *image __unused ) {
46
+	return pxe_boot();
47
+}
48
+
49
+/**
50
+ * Load PXE image into memory
51
+ *
52
+ * @v image		PXE file
53
+ * @ret rc		Return status code
54
+ */
55
+int pxe_load ( struct image *image ) {
56
+	userptr_t buffer = real_to_user ( 0, 0x7c00 );
57
+	size_t filesz = image->len;
58
+	size_t memsz = image->len;
59
+	int rc;
60
+
61
+	/* There are no signature checks for PXE; we will accept anything */
62
+	if ( ! image->type )
63
+		image->type = &pxe_image_type;
64
+
65
+	/* Verify and prepare segment */
66
+	if ( ( rc = prep_segment ( buffer, filesz, memsz ) != 0 ) ) {
67
+		DBG ( "PXE image could not prepare segment: %s\n",
68
+		      strerror ( rc ) );
69
+		return rc;
70
+	}
71
+
72
+	/* Copy image to segment */
73
+	memcpy_user ( buffer, 0, image->data, 0, filesz );
74
+
75
+	return 0;
76
+}
77
+
78
+/** PXE image type */
79
+struct image_type pxe_image_type __image_type ( PROBE_PXE ) = {
80
+	.name = "PXE",
81
+	.load = pxe_load,
82
+	.exec = pxe_exec,
83
+};

+ 11
- 10
src/config.h 파일 보기

@@ -98,16 +98,16 @@
98 98
  * you want to use.
99 99
  *
100 100
  */
101
-#undef	TAGGED_IMAGE		/* NBI image support */
102
-#undef	ELF64_IMAGE		/* ELF64 image support */
103
-#undef	ELF_IMAGE		/* ELF image support */
104
-#undef	COFF_IMAGE		/* COFF image support */
105
-#undef	FREEBSD_IMAGE		/* FreeBSD kernel image support */
106
-#define	MULTIBOOT_IMAGE		/* MultiBoot image support */
107
-#undef	AOUT_IMAGE		/* a.out image support */
108
-#undef	WINCE_IMAGE		/* WinCE image support */
109
-#undef	PXE_IMAGE		/* PXE image support */
110
-#define SCRIPT_IMAGE		/* gPXE script image support */
101
+#undef	IMAGE_NBI		/* NBI image support */
102
+#undef	IMAGE_ELF64		/* ELF64 image support */
103
+#undef	IMAGE_ELF		/* ELF image support */
104
+#undef	IMAGE_COFF		/* COFF image support */
105
+#undef	IMAGE_FREEBSD		/* FreeBSD kernel image support */
106
+#define	IMAGE_MULTIBOOT		/* MultiBoot image support */
107
+#undef	IMAGE_AOUT		/* a.out image support */
108
+#undef	IMAGE_WINCE		/* WinCE image support */
109
+#define	IMAGE_PXE		/* PXE image support */
110
+#define IMAGE_SCRIPT		/* gPXE script image support */
111 111
 
112 112
 /* @END general.h */ 
113 113
 
@@ -122,6 +122,7 @@
122 122
 #define	IFMGMT_CMD		/* Interface management commands */
123 123
 #define	ROUTE_CMD		/* Routing table management commands */
124 124
 #define IMAGE_CMD		/* Image management commands */
125
+#define DHCP_CMD		/* DHCP management commands */
125 126
 
126 127
 /* @END general.h */ 
127 128
 

+ 11
- 11
src/core/config.c 파일 보기

@@ -110,34 +110,34 @@ REQUIRE_OBJECT ( nmb );
110 110
  * Drag in all requested image formats
111 111
  *
112 112
  */
113
-#ifdef TAGGED_IMAGE
113
+#ifdef IMAGE_NBI
114 114
 REQUIRE_OBJECT ( nbi );
115 115
 #endif
116
-#ifdef ELF64_IMAGE
116
+#ifdef IMAGE_ELF64
117 117
 REQUIRE_OBJECT ( elf64 );
118 118
 #endif
119
-#ifdef ELF_IMAGE
119
+#ifdef IMAGE_ELF
120 120
 REQUIRE_OBJECT ( elf );
121 121
 #endif
122
-#ifdef COFF_IMAGE
122
+#ifdef IMAGE_ELF
123 123
 REQUIRE_OBJECT ( coff );
124 124
 #endif
125
-#ifdef FREEBSD_IMAGE
125
+#ifdef IMAGE_FREEBSD
126 126
 REQUIRE_OBJECT ( freebsd );
127 127
 #endif
128
-#ifdef MULTIBOOT_IMAGE
128
+#ifdef IMAGE_MULTIBOOT
129 129
 REQUIRE_OBJECT ( multiboot );
130 130
 #endif
131
-#ifdef AOUT_IMAGE
131
+#ifdef IMAGE_AOUT
132 132
 REQUIRE_OBJECT ( aout );
133 133
 #endif
134
-#ifdef WINCE_IMAGE
134
+#ifdef IMAGE_WINCE
135 135
 REQUIRE_OBJECT ( wince );
136 136
 #endif
137
-#ifdef PXE_IMAGE
138
-REQUIRE_OBJECT ( pxe );
137
+#ifdef IMAGE_PXE
138
+REQUIRE_OBJECT ( pxe_image );
139 139
 #endif
140
-#ifdef SCRIPT_IMAGE
140
+#ifdef IMAGE_SCRIPT
141 141
 REQUIRE_OBJECT ( script );
142 142
 #endif
143 143
 

Loading…
취소
저장