wok view gpxe/stuff/default_boot.u @ rev 1002

gpxe: fix floppy bot
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Jul 06 18:15:46 2008 +0000 (2008-07-06)
parents da7eea2e2d10
children e591dc06c14f
line source
1 --- gpxe-0.9.3/src/arch/i386/interface/pxe/pxe_call.c
2 +++ gpxe-0.9.3/src/arch/i386/interface/pxe/pxe_call.c
3 @@ -96,6 +96,8 @@
4 PXENV_EXIT_t ( * file_select ) ( struct s_PXENV_FILE_SELECT * );
5 PXENV_EXIT_t ( * file_read ) ( struct s_PXENV_FILE_READ * );
6 PXENV_EXIT_t ( * get_file_size ) ( struct s_PXENV_GET_FILE_SIZE * );
7 + PXENV_EXIT_t ( * file_exec ) ( struct s_PXENV_FILE_EXEC * );
8 + PXENV_EXIT_t ( * file_api_check ) ( struct s_PXENV_FILE_API_CHECK * );
9 };
11 /**
12 @@ -294,6 +296,14 @@
13 pxenv_call.get_file_size = pxenv_get_file_size;
14 param_len = sizeof ( pxenv_any.get_file_size );
15 break;
16 + case PXENV_FILE_EXEC:
17 + pxenv_call.file_exec = pxenv_file_exec;
18 + param_len = sizeof ( pxenv_any.file_exec );
19 + break;
20 + case PXENV_FILE_API_CHECK:
21 + pxenv_call.file_api_check = pxenv_file_api_check;
22 + param_len = sizeof ( pxenv_any.file_api_check );
23 + break;
24 default:
25 DBG ( "PXENV_UNKNOWN_%hx", opcode );
26 pxenv_call.unknown = pxenv_unknown;
28 --- gpxe-0.9.3/src/arch/i386/prefix/lkrnprefix.S
29 +++ gpxe-0.9.3/src/arch/i386/prefix/lkrnprefix.S
30 @@ -441,6 +441,8 @@
31 /* Calculated lcall to _start with %cs:0000 = image start */
32 lret
34 +boot_url:
35 + .space 256, 0
37 .org PREFIXSIZE
38 /*
39 @@ -453,6 +457,13 @@
40 movw %bx, %ss
41 movw $_estack16, %sp
43 + /* Copy our boot_url structure to the forced_url variable */
44 + push %cs
45 + pop %ds
46 + movw %bx, %es
47 + movw $forced_url, %di
48 + movw $boot_url, %si
49 + movw $256, %cx
50 + rep movsb
51 +
52 /* Jump to .text16 segment */
53 pushw %ax
54 pushw $1f
56 --- gpxe-0.9.3/src/arch/i386/prefix/pxeprefix.S
57 +++ gpxe-0.9.3/src/arch/i386/prefix/pxeprefix.S
58 @@ -19,6 +19,9 @@
59 .section ".prefix"
60 /* Set up our non-stack segment registers */
61 jmp $0x7c0, $1f
62 +#define PXELOADER_KEEP_UNDI
63 +boot_url:
64 + .space 256, 0
65 1: movw %cs, %ax
66 movw %ax, %ds
67 movw $0x40, %ax /* BIOS data segment access */
68 @@ -703,16 +706,22 @@
69 /* Set up real-mode stack */
70 movw %bx, %ss
71 movw $_estack16, %sp
72 -
73 + movw %bx, %es
74 +
75 #ifdef PXELOADER_KEEP_UNDI
76 /* Copy our undi_device structure to the preloaded_undi variable */
77 - movw %bx, %es
78 movw $preloaded_undi, %di
79 movw $undi_device, %si
80 movw $undi_device_size, %cx
81 rep movsb
82 #endif
84 + /* Copy our boot_url structure to the forced_url variable */
85 + movw $forced_url, %di
86 + movw $boot_url, %si
87 + movw $256, %cx
88 + rep movsb
89 +
90 /* Jump to .text16 segment with %ds pointing to .data16 */
91 movw %bx, %ds
92 pushw %ax
94 --- gpxe-0.9.3/src/include/pxe_api.h
95 +++ gpxe-0.9.3/src/include/pxe_api.h
96 @@ -1684,6 +1684,54 @@
98 /** @} */ /* pxenv_get_file_size */
100 +/** @defgroup pxenv_file_exec PXENV_FILE_EXEC
101 + *
102 + * FILE EXEC
103 + *
104 + * @{
105 + */
106 +
107 +/** PXE API function code for pxenv_file_exec() */
108 +#define PXENV_FILE_EXEC 0x00e5
109 +
110 +/** Parameter block for pxenv_file_exec() */
111 +struct s_PXENV_FILE_EXEC {
112 + PXENV_STATUS_t Status; /**< PXE status code */
113 + SEGOFF16_t Command; /**< Command to execute */
114 +} PACKED;
115 +
116 +typedef struct s_PXENV_FILE_EXEC PXENV_FILE_EXEC_t;
117 +
118 +extern PXENV_EXIT_t pxenv_file_exec ( struct s_PXENV_FILE_EXEC *file_exec );
119 +
120 +/** @} */ /* pxenv_file_exec */
121 +
122 +/** @defgroup pxenv_file_api_check PXENV_FILE_API_CHECK
123 + *
124 + * FILE API CHECK
125 + *
126 + * @{
127 + */
128 +
129 +/** PXE API function code for pxenv_file_api_check() */
130 +#define PXENV_FILE_API_CHECK 0x00e6
131 +
132 +/** Parameter block for pxenv_file_api_check() */
133 +struct s_PXENV_FILE_API_CHECK {
134 + PXENV_STATUS_t Status; /**< PXE status code */
135 + UINT16_t Size; /**< Size of structure */
136 + UINT32_t Magic; /**< Magic number */
137 + UINT32_t Provider; /**< Implementation identifier */
138 + UINT32_t APIMask; /**< Supported API functions */
139 + UINT32_t Flags; /**< Reserved for the future */
140 +} PACKED;
141 +
142 +typedef struct s_PXENV_FILE_API_CHECK PXENV_FILE_API_CHECK_t;
143 +
144 +extern PXENV_EXIT_t pxenv_file_api_check ( struct s_PXENV_FILE_API_CHECK *file_api_check );
145 +
146 +/** @} */ /* pxenv_file_api_check */
147 +
148 /** @} */ /* pxe_file_api */
150 /** @defgroup pxe_loader_api PXE Loader API
152 --- gpxe-0.9.3/src/include/pxe.h
153 +++ gpxe-0.9.3/src/include/pxe.h
154 @@ -63,6 +63,8 @@
155 struct s_PXENV_FILE_SELECT file_select;
156 struct s_PXENV_FILE_READ file_read;
157 struct s_PXENV_GET_FILE_SIZE get_file_size;
158 + struct s_PXENV_FILE_EXEC file_exec;
159 + struct s_PXENV_FILE_API_CHECK file_api_check;
160 };
162 typedef union u_PXENV_ANY PXENV_ANY_t;
164 --- gpxe-0.9.3/src/interface/pxe/pxe_file.c
165 +++ gpxe-0.9.3/src/interface/pxe/pxe_file.c
166 @@ -31,7 +31,7 @@
167 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
168 */
170 -FEATURE ( FEATURE_MISC, "PXEXT", DHCP_EB_FEATURE_PXE_EXT, 1 );
171 +FEATURE ( FEATURE_MISC, "PXEXT", DHCP_EB_FEATURE_PXE_EXT, 2 );
173 /**
174 * FILE OPEN
175 @@ -189,3 +189,76 @@
176 get_file_size->Status = PXENV_STATUS_SUCCESS;
177 return PXENV_EXIT_SUCCESS;
178 }
179 +
180 +/**
181 + * FILE EXEC
182 + *
183 + * @v file_exec Pointer to a struct s_PXENV_FILE_EXEC
184 + * @v s_PXENV_FILE_EXEC::Command Command to execute
185 + * @ret #PXENV_EXIT_SUCCESS Command was executed successfully
186 + * @ret #PXENV_EXIT_FAILURE Command was not executed successfully
187 + * @ret s_PXENV_FILE_EXEC::Status PXE status code
188 + *
189 + */
190 +PXENV_EXIT_t pxenv_file_exec ( struct s_PXENV_FILE_EXEC *file_exec ) {
191 + userptr_t command;
192 + size_t command_len;
193 + int rc;
194 +
195 + DBG ( "PXENV_FILE_EXEC" );
196 +
197 + /* Copy name from external program, and exec it */
198 + command = real_to_user ( file_exec->Command.segment,
199 + file_exec->Command.offset );
200 + command_len = strlen_user ( command, 0 );
201 + {
202 + char command_string[ command_len + 1 ];
203 +
204 + copy_from_user ( command_string, command, 0,
205 + sizeof ( command_string ) );
206 + DBG ( " %s", command_string );
207 +
208 + if ( ( rc = system ( command_string ) ) != 0 ) {
209 + file_exec->Status = PXENV_STATUS ( rc );
210 + return PXENV_EXIT_FAILURE;
211 + }
212 + }
213 +
214 + file_exec->Status = PXENV_STATUS_SUCCESS;
215 + return PXENV_EXIT_SUCCESS;
216 +}
217 +
218 +/**
219 + * FILE API CHECK
220 + *
221 + * @v file_exec Pointer to a struct s_PXENV_FILE_API_CHECK
222 + * @v s_PXENV_FILE_API_CHECK::Magic Inbound magic number (0x91d447b2)
223 + * @ret #PXENV_EXIT_SUCCESS Command was executed successfully
224 + * @ret #PXENV_EXIT_FAILURE Command was not executed successfully
225 + * @ret s_PXENV_FILE_API_CHECK::Status PXE status code
226 + * @ret s_PXENV_FILE_API_CHECK::Magic Outbound magic number (0xe9c17b20)
227 + * @ret s_PXENV_FILE_API_CHECK::Provider "gPXE" (0x45585067)
228 + * @ret s_PXENV_FILE_API_CHECK::APIMask API function bitmask
229 + * @ret s_PXENV_FILE_API_CHECK::Flags Reserved
230 + *
231 + */
232 +PXENV_EXIT_t pxenv_file_api_check ( struct s_PXENV_FILE_API_CHECK *file_api_check ) {
233 + DBG ( "PXENV_FILE_API_CHECK" );
234 +
235 + if ( file_api_check->Magic != 0x91d447b2 ) {
236 + file_api_check->Status = PXENV_STATUS_BAD_FUNC;
237 + return PXENV_EXIT_FAILURE;
238 + } else if ( file_api_check->Size <
239 + sizeof(struct s_PXENV_FILE_API_CHECK) ) {
240 + file_api_check->Status = PXENV_STATUS_OUT_OF_RESOURCES;
241 + return PXENV_EXIT_FAILURE;
242 + } else {
243 + file_api_check->Status = PXENV_STATUS_SUCCESS;
244 + file_api_check->Size = sizeof(struct s_PXENV_FILE_API_CHECK);
245 + file_api_check->Magic = 0xe9c17b20;
246 + file_api_check->Provider = 0x45585067; /* "gPXE" */
247 + file_api_check->APIMask = 0x0000007f; /* Functions e0-e6 */
248 + file_api_check->Flags = 0; /* None defined */
249 + return PXENV_EXIT_SUCCESS;
250 + }
251 +}
253 --- gpxe-0.9.3/src/usr/autoboot.c
254 +++ gpxe-0.9.3/src/usr/autoboot.c
255 @@ -120,6 +120,28 @@
256 return -ENOTSUP;
257 }
259 +static void set_url ( char buf[], const char url[] ) {
260 + int i, d = 0;
261 +
262 + for (i = 0; url[i] >= ' '; i++) {
263 + if (url[i] == '/') d = i;
264 + buf[i] = url[i];
265 + }
266 + buf[i] = 0;
267 + if (strstr(buf,"pxelinux")) {
268 + struct dhcp_option_block *options = list_entry (
269 + dhcp_option_blocks.next, typeof ( *options ), list );
270 +
271 + set_dhcp_option( options, 208, "\xF1\x00\x74\x7E", 4 );
272 + set_dhcp_option( options, 210, buf, d+1 );
273 + }
274 +}
275 +
276 +struct _forced_url {
277 + char url[256];
278 +};
279 +struct _forced_url __data16 ( forced_url );
280 +#define forced_url __use_data16 ( forced_url )
281 /**
282 * Boot from a network device
283 *
284 @@ -148,6 +170,12 @@
285 /* Try to download and boot whatever we are given as a filename */
286 dhcp_snprintf ( buf, sizeof ( buf ),
287 find_global_dhcp_option ( DHCP_BOOTFILE_NAME ) );
288 +
289 + if ( forced_url.url[0] != 0 ) {
290 + /* Try to boot a forced url if we have one */
291 + set_url ( buf, forced_url.url );
292 + }
293 + while (1) {
294 if ( buf[0] ) {
295 printf ( "Booting from filename \"%s\"\n", buf );
296 return boot_filename ( buf );
297 @@ -162,7 +190,8 @@
298 }
300 printf ( "No filename or root path specified\n" );
301 - return -ENOENT;
302 + set_url ( buf, "http://boot.slitaz.org/gpxe" );
303 + }
304 }
306 /**