ia64/xen-unstable

view xen/arch/ia64/tools/xelilo/elilo-3.4.11.xen.patch @ 6879:97dbd9524a7e

Patches and recipe to build an elilo.efi that will boot domain0 with initrd
and pre-built "xlilo.efi". Courtesy of Anthony Xu and Fred Yang.
author djm@kirby.fc.hp.com
date Thu Sep 22 11:34:14 2005 -0600 (2005-09-22)
parents
children
line source
1 <Sign-off: fred.yang@intel.com>
2 diff -Naur base/bootparams.c elilo/bootparams.c
3 --- base/bootparams.c 2005-09-20 19:51:07.000000000 -0700
4 +++ elilo/bootparams.c 2005-09-20 19:33:00.000000000 -0700
5 @@ -38,7 +38,7 @@
6 * bp : the address of the bootparams otherwise (opaque type)
7 */
8 VOID *
9 -create_boot_params(CHAR16 *args, memdesc_t *initrd, UINTN *cookie)
10 +create_boot_params(CHAR16 *args, memdesc_t *initrd, memdesc_t *vmcode, UINTN *cookie)
11 {
12 /*
13 * XXX: need cleanup
14 @@ -95,7 +95,7 @@
15 */
16 Memset(bp, 0, BOOT_PARAM_MEMSIZE);
18 - if (sysdeps_create_boot_params(bp, cp, initrd, cookie) == -1) return 0;
19 + if (sysdeps_create_boot_params(bp, cp, initrd, vmcode, cookie) == -1) return 0;
21 /*
22 * Convert kernel command line args from UNICODE to ASCII and put them where
23 diff -Naur base/choosers/simple.c elilo/choosers/simple.c
24 --- base/choosers/simple.c 2005-09-20 19:51:07.000000000 -0700
25 +++ elilo/choosers/simple.c 2005-09-20 19:28:15.000000000 -0700
26 @@ -37,6 +37,7 @@
27 {
28 CHAR16 *desc;
29 CHAR16 initrd_name[CMDLINE_MAXLEN];
30 + CHAR16 vmcode_name[CMDLINE_MAXLEN];
31 CHAR16 options_tmp[CMDLINE_MAXLEN];
32 CHAR16 options[CMDLINE_MAXLEN];
33 CHAR16 kname[FILENAME_MAXLEN];
34 @@ -46,9 +47,9 @@
35 Print(L"desc : %s\n", desc);
36 }
38 - initrd_name[0] = options_tmp[0] = kname[0] = CHAR_NULL;
39 + initrd_name[0] = vmcode_name[0] = options_tmp[0] = kname[0] = CHAR_NULL;
41 - if (find_label(name, kname, options_tmp, initrd_name) == -1) {
42 + if (find_label(name, kname, options_tmp, initrd_name, vmcode_name) == -1) {
43 StrCpy(kname, name);
44 Print(L"\n");
45 }
46 @@ -56,6 +57,7 @@
48 Print(L"cmdline: %s %s\n", kname, options);
49 if (initrd_name[0]) Print(L"initrd : %s\n", initrd_name);
50 + if (vmcode_name[0]) Print(L"vmcode : %s\n", vmcode_name);
51 }
53 static VOID
54 @@ -247,6 +249,7 @@
55 CHAR16 buffer[CMDLINE_MAXLEN];
56 CHAR16 alt_buffer[CMDLINE_MAXLEN];
57 CHAR16 initrd_name[CMDLINE_MAXLEN];
58 + CHAR16 vmcode_name[CMDLINE_MAXLEN];
59 CHAR16 args[CMDLINE_MAXLEN];
60 CHAR16 devname[CMDLINE_MAXLEN];
61 CHAR16 dpath[FILENAME_MAXLEN];
62 @@ -259,7 +262,7 @@
63 display_message();
65 restart:
66 - initrd_name[0] = kname[0] = cmdline[0] = args[0] = CHAR_NULL;
67 + initrd_name[0] = vmcode_name[0] = kname[0] = cmdline[0] = args[0] = CHAR_NULL;
69 /* reset per image loader options */
70 Memset(&elilo_opt.img_opt, 0, sizeof(elilo_opt.img_opt));
71 @@ -303,7 +306,7 @@
72 * if no match is found, the args and initrd arguments may
73 * still be modified by global options in the config file.
74 */
75 - ret = find_label((index < argc) ? argv[index] : NULL, kname, args, initrd_name);
76 + ret = find_label((index < argc) ? argv[index] : NULL, kname, args, initrd_name, vmcode_name);
78 /*
79 * not found, so assume first argument is kernel name and
80 @@ -335,6 +338,10 @@
81 StrCpy(elilo_opt.initrd, initrd_name);
82 }
84 + if (elilo_opt.vmcode[0] == CHAR_NULL && vmcode_name[0] != CHAR_NULL) {
85 + StrCpy(elilo_opt.vmcode, vmcode_name);
86 + }
87 +
88 VERB_PRT(1, { Print(L"kernel is '%s'\n", kname);
89 Print(L"arguments are '%s'\n", args);
90 if (elilo_opt.initrd[0]) Print(L"initrd is '%s'\n", elilo_opt.initrd);
91 diff -Naur base/choosers/textmenu.c elilo/choosers/textmenu.c
92 --- base/choosers/textmenu.c 2005-09-20 19:51:07.000000000 -0700
93 +++ elilo/choosers/textmenu.c 2005-09-20 19:28:29.000000000 -0700
94 @@ -358,6 +358,7 @@
95 # define BOOT_IMG_STR L"BOOT_IMAGE="
96 CHAR16 label[CMDLINE_MAXLEN];
97 CHAR16 initrd_name[CMDLINE_MAXLEN];
98 + CHAR16 vmcode_name[CMDLINE_MAXLEN];
99 CHAR16 args[CMDLINE_MAXLEN];
100 CHAR16 devname[CMDLINE_MAXLEN];
101 CHAR16 dpath[FILENAME_MAXLEN];
102 @@ -412,9 +413,9 @@
103 * still be modified by global options in the config file.
104 */
105 if (label[0])
106 - ret = find_label(label, kname, args, initrd_name);
107 + ret = find_label(label, kname, args, initrd_name, vmcode_name);
108 else
109 - ret = find_label(argv[index], kname, args, initrd_name);
110 + ret = find_label(argv[index], kname, args, initrd_name, vmcode_name);
112 /*
113 * not found, so assume first argument is kernel name and
114 @@ -448,6 +449,10 @@
115 StrCpy(elilo_opt.initrd, initrd_name);
116 }
118 + if (elilo_opt.vmcode[0] == CHAR_NULL && vmcode_name[0] != CHAR_NULL) {
119 + StrCpy(elilo_opt.vmcode, vmcode_name);
120 + }
121 +
122 VERB_PRT(1, { Print(L"kernel is '%s'\n", kname);
123 Print(L"arguments are '%s'\n", args);
124 if (elilo_opt.initrd[0]) Print(L"initrd is '%s'\n", elilo_opt.initrd);
125 diff -Naur base/config.c elilo/config.c
126 --- base/config.c 2005-09-20 19:51:07.000000000 -0700
127 +++ elilo/config.c 2005-09-20 19:33:26.000000000 -0700
128 @@ -68,6 +68,7 @@
129 CHAR16 kname[FILENAME_MAXLEN];
130 CHAR16 options[MAX_STRING];
131 CHAR16 initrd[FILENAME_MAXLEN];
132 + CHAR16 vmcode[FILENAME_MAXLEN];
133 CHAR16 root[FILENAME_MAXLEN];
134 CHAR16 fallback[MAX_STRING];
135 CHAR16 description[MAX_STRING];
136 @@ -93,6 +94,7 @@
137 typedef struct {
138 CHAR16 root[FILENAME_MAXLEN]; /* globally defined root fs */
139 CHAR16 initrd[FILENAME_MAXLEN];/* globally defined initrd */
140 + CHAR16 vmcode[FILENAME_MAXLEN];/* globally defined boot-time module */
141 CHAR16 options[MAX_STRING];
142 CHAR16 default_image_name[MAX_STRING];
143 CHAR16 message_file[MAX_MESSAGES][FILENAME_MAXLEN];
144 @@ -144,6 +146,7 @@
145 {OPT_BOOL, OPT_GLOBAL, L"noedd30", NULL, NULL, &global_config.edd30_no_force},
146 {OPT_CMD, OPT_GLOBAL, L"append", NULL, NULL, global_config.options},
147 {OPT_FILE, OPT_GLOBAL, L"initrd", NULL, NULL, global_config.initrd},
148 +{OPT_FILE, OPT_GLOBAL, L"vmm", NULL, NULL, global_config.vmcode},
149 {OPT_FILE, OPT_GLOBAL, L"image", do_image, NULL, opt_offsetof(kname)},
150 {OPT_BOOL, OPT_GLOBAL, L"checkalt", NULL, NULL, &global_config.alt_check},
151 {OPT_STR, OPT_GLOBAL, L"chooser", NULL, check_chooser, global_config.chooser},
152 @@ -168,6 +171,7 @@
153 {OPT_CMD, OPT_IMAGE, L"append", do_options, NULL, opt_offsetof(options)},
154 {OPT_CMD, OPT_IMAGE, L"literal", do_literal, NULL, NULL},
155 {OPT_FILE, OPT_IMAGE, L"initrd", NULL, NULL, opt_offsetof(initrd)},
156 + {OPT_FILE, OPT_IMAGE, L"vmm", NULL, NULL, opt_offsetof(vmcode)},
157 {OPT_STR, OPT_IMAGE, L"label", NULL, NULL, opt_offsetof(label)},
158 {OPT_FILE, OPT_IMAGE, L"image", do_image, NULL, opt_offsetof(kname)},
159 {OPT_STR, OPT_IMAGE, L"description", NULL, NULL, opt_offsetof(description)},
160 @@ -974,7 +978,7 @@
161 }
163 INTN
164 -find_label(CHAR16 *label, CHAR16 *kname, CHAR16 *options, CHAR16 *initrd)
165 +find_label(CHAR16 *label, CHAR16 *kname, CHAR16 *options, CHAR16 *initrd, CHAR16 *vmcode)
166 {
167 boot_image_t *img;
169 @@ -1007,6 +1011,7 @@
170 if (global_config.readonly) StrCat(options, L" ro");
172 if (global_config.initrd[0]) StrCpy(initrd, global_config.initrd);
173 + if (global_config.vmcode[0]) StrCpy(vmcode, global_config.vmcode);
175 /* make sure we don't get garbage here */
176 elilo_opt.sys_img_opts = NULL;
177 @@ -1044,12 +1049,17 @@
178 else if (global_config.initrd[0])
179 StrCpy(initrd, global_config.initrd);
181 + if (img->vmcode[0])
182 + StrCpy(vmcode, img->vmcode);
183 + else if (global_config.vmcode[0])
184 + StrCpy(vmcode, global_config.vmcode);
185 +
186 /*
187 * point to architecture dependent options for this image
188 */
189 elilo_opt.sys_img_opts = &img->sys_img_opts;
191 - DBG_PRT((L"label %s: kname=%s options=%s initrd=%s", img->label, kname, options, initrd));
192 + DBG_PRT((L"label %s: kname=%s options=%s initrd=%s vmcode=%s", img->label, kname, options, initrd, vmcode));
194 return 0;
195 }
196 diff -Naur base/elilo.c elilo/elilo.c
197 --- base/elilo.c 2005-09-20 19:51:07.000000000 -0700
198 +++ elilo/elilo.c 2005-09-20 19:33:41.000000000 -0700
199 @@ -84,10 +84,23 @@
200 }
202 INTN
203 -kernel_load(EFI_HANDLE image, CHAR16 *kname, kdesc_t *kd, memdesc_t *imem)
204 +kernel_load(EFI_HANDLE image, CHAR16 *kname, kdesc_t *kd, memdesc_t *imem, memdesc_t *mmem)
205 {
207 /*
208 + * Do the vm image switch here
209 + * if there is "vmm=" then elilo should load image specified
210 + * in "vmm=" and then give the "image" to vmm as target kernel image
211 + */
212 + if (elilo_opt.vmcode[0]) {
213 + CHAR16 buffer[CMDLINE_MAXLEN];
214 + VERB_PRT(1,Print(L"swapping vmm=%s with image=%s\n", elilo_opt.vmcode,
215 + kname));
216 + StrCpy(buffer, kname);
217 + StrCpy(kname, elilo_opt.vmcode);
218 + StrCpy(elilo_opt.vmcode, buffer);
219 + }
220 + /*
221 * Now let's try to load the kernel !
222 */
223 switch(do_kernel_load(kname, kd)) {
224 @@ -134,10 +147,32 @@
225 return ELILO_LOAD_RETRY;
226 }
227 }
228 +
229 + if (elilo_opt.vmcode[0]) {
230 +
231 + mmem->start_addr = 0; /* let the allocator decide */
232 +
233 + switch(load_initrd(elilo_opt.vmcode, mmem)) {
234 + case ELILO_LOAD_SUCCESS:
235 + break;
236 + case ELILO_LOAD_ERROR:
237 + goto exit_error;
238 + case ELILO_LOAD_ABORTED:
239 + free_kmem();
240 + /* we drop initrd in case we aborted the load */
241 + elilo_opt.vmcode[0] = CHAR_NULL;
242 + elilo_opt.prompt = 1;
243 + elilo_opt.timeout = ELILO_DEFAULT_TIMEOUT;
244 + elilo_opt.delay = 0;
245 +
246 + return ELILO_LOAD_RETRY;
247 + }
248 + }
249 return ELILO_LOAD_SUCCESS;
250 exit_error:
251 free_kmem();
252 if (imem->start_addr) free(imem->start_addr);
253 + if (mmem->start_addr) free(mmem->start_addr);
255 return ELILO_LOAD_ERROR;
256 }
257 @@ -152,7 +187,7 @@
258 UINTN cookie;
259 EFI_STATUS status = EFI_SUCCESS;
260 kdesc_t kd;
261 - memdesc_t imem;
262 + memdesc_t imem, mmem;
263 INTN r;
265 /*
266 @@ -169,7 +204,7 @@
268 if (kernel_chooser(argv, argc, index, kname, cmdline_tmp) == -1) goto exit_error;
270 - switch (kernel_load(image, kname, &kd, &imem)) {
271 + switch (kernel_load(image, kname, &kd, &imem, &mmem)) {
272 case ELILO_LOAD_SUCCESS:
273 goto do_launch;
274 case ELILO_LOAD_ERROR:
275 @@ -187,7 +222,7 @@
276 close_devices();
278 /* No console output permitted after create_boot_params()! */
279 - if ((bp=create_boot_params(cmdline, &imem, &cookie)) == 0) goto error;
280 + if ((bp=create_boot_params(cmdline, &imem, &mmem, &cookie)) == 0) goto error;
282 /* terminate bootservices */
283 status = BS->ExitBootServices(image, cookie);
284 @@ -221,6 +256,7 @@
285 Print(L"-v verbose level(can appear multiple times)\n");
286 Print(L"-a always check for alternate kernel image\n");
287 Print(L"-i file load file as the initial ramdisk\n");
288 + Print(L"-m file load file as additional boot time vmm module\n");
289 Print(L"-C file indicate the config file to use\n");
290 Print(L"-P parse config file only (verify syntax)\n");
291 Print(L"-D enable debug prints\n");
292 @@ -491,6 +527,13 @@
293 }
294 StrCpy(elilo_opt.initrd, Optarg);
295 break;
296 + case 'm':
297 + if (StrLen(Optarg) >= FILENAME_MAXLEN-1) {
298 + Print(L"vmm module filename is limited to %d characters\n", FILENAME_MAXLEN);
299 + goto do_exit;
300 + }
301 + StrCpy(elilo_opt.vmcode, Optarg);
302 + break;
303 case 'C':
304 if (StrLen(Optarg) >= FILENAME_MAXLEN-1) {
305 Print(L"config filename is limited to %d characters\n", FILENAME_MAXLEN);
306 diff -Naur base/elilo.h elilo/elilo.h
307 --- base/elilo.h 2005-09-20 19:51:07.000000000 -0700
308 +++ elilo/elilo.h 2005-09-20 19:32:19.000000000 -0700
309 @@ -75,6 +75,7 @@
310 UINTN delay; /* delay before booting the image */
311 UINTN verbose; /* verbosity level [1-5] */
312 CHAR16 initrd[FILENAME_MAXLEN]; /* name of file for initial ramdisk */
313 + CHAR16 vmcode[FILENAME_MAXLEN]; /* name of file for boot time module*/
314 UINT8 delay_set; /* mark whether or not delay was specified on cmdline */
315 UINT8 edd30_on; /* true is EDD30 variable is TRUE */
316 UINT8 edd30_no_force; /* don't force EDD30 variable to true */
317 @@ -131,7 +132,7 @@
318 #endif
320 #define VERB_PRT(n,cmd) \
321 - { if (elilo_opt.verbose >= (n)) { cmd; } }
322 + { if (elilo_opt.verbose >= (n)) { cmd; } }
325 /* from alloc.c */
326 @@ -163,7 +164,7 @@
327 /* from config.c (more in config.h) */
328 extern EFI_STATUS read_config(CHAR16 *, INTN retry);
329 extern VOID print_config_options(VOID);
330 -extern INTN find_label(CHAR16 *, CHAR16 *, CHAR16 *, CHAR16 *);
331 +extern INTN find_label(CHAR16 *, CHAR16 *, CHAR16 *, CHAR16 *, CHAR16 *);
332 extern VOID print_label_list(VOID);
333 extern INTN config_init(VOID);
334 extern CHAR16 *get_message_filename(INTN which);
335 @@ -178,7 +179,7 @@
336 extern INTN alternate_kernel(CHAR16 *, INTN);
338 /* from bootparams.c */
339 -extern VOID *create_boot_params (CHAR16 *, memdesc_t *, UINTN *);
340 +extern VOID *create_boot_params (CHAR16 *, memdesc_t *, memdesc_t *, UINTN *);
341 extern VOID free_boot_params(VOID *bp);
343 /*
344 @@ -186,7 +187,7 @@
345 */
348 -extern INTN sysdeps_create_boot_params(boot_params_t *, CHAR8 *, memdesc_t *, UINTN *);
349 +extern INTN sysdeps_create_boot_params(boot_params_t *, CHAR8 *, memdesc_t *, memdesc_t *, UINTN *);
350 extern VOID sysdeps_free_boot_params(boot_params_t *);
351 extern INTN sysdeps_init(EFI_HANDLE dev);
352 extern INTN sysdeps_initrd_get_addr(kdesc_t *, memdesc_t *);
353 diff -Naur base/ia32/system.c elilo/ia32/system.c
354 --- base/ia32/system.c 2005-09-20 19:51:07.000000000 -0700
355 +++ elilo/ia32/system.c 2005-09-20 19:30:10.000000000 -0700
356 @@ -408,6 +408,7 @@
357 boot_params_t *bp,
358 CHAR8 *cmdline,
359 memdesc_t *initrd,
360 + memdesc_t *vmcode, /* no use for ia32 now*/
361 UINTN *cookie)
362 {
363 mmap_desc_t mdesc;
364 diff -Naur base/ia64/sysdeps.h elilo/ia64/sysdeps.h
365 --- base/ia64/sysdeps.h 2005-09-20 19:51:07.000000000 -0700
366 +++ elilo/ia64/sysdeps.h 2005-09-20 19:29:07.000000000 -0700
367 @@ -65,8 +65,11 @@
368 UINTN initrd_start; /* virtual address where the initial ramdisk begins */
369 UINTN initrd_size; /* how big is the initial ramdisk */
371 + UINTN vmcode_start; /* virtual address where the boot time vmcode begins */
372 + UINTN vmcode_size; /* how big is the boot module */
373 UINTN loader_addr; /* start address of boot loader */
374 UINTN loader_size; /* size of loader code & data */
375 +
376 } boot_params_t;
378 typedef struct sys_img_options {
379 diff -Naur base/ia64/system.c elilo/ia64/system.c
380 --- base/ia64/system.c 2005-09-20 19:51:07.000000000 -0700
381 +++ elilo/ia64/system.c 2005-09-20 19:29:28.000000000 -0700
382 @@ -39,7 +39,7 @@
383 * IA-64 specific boot paramters initialization routine
384 */
385 INTN
386 -sysdeps_create_boot_params(boot_params_t *bp, CHAR8 *cmdline, memdesc_t *initrd, UINTN *cookie)
387 +sysdeps_create_boot_params(boot_params_t *bp, CHAR8 *cmdline, memdesc_t *initrd, memdesc_t *vmcode, UINTN *cookie)
388 {
389 UINTN cols, rows;
390 SIMPLE_TEXT_OUTPUT_INTERFACE *conout;
391 @@ -65,6 +65,11 @@
392 bp->command_line = (UINTN)cmdline;
393 bp->initrd_start = (UINTN) initrd->start_addr;
394 bp->initrd_size = initrd->size;
395 + DBG_PRT((L"Got initrd @ 0x%lx (%d bytes)", initrd->start_addr, initrd->size));
396 +
397 + bp->vmcode_start = (UINTN) vmcode->start_addr;
398 + bp->vmcode_size = vmcode->size;
399 + DBG_PRT((L"Got vmcode @ 0x%lx (%d bytes)", vmcode->start_addr, vmcode->size));
401 /* fetch console parameters: */
402 conout = systab->ConOut;