2 * Copyright (C) 2001-2003 Hewlett-Packard Co.
3 * Contributed by Stephane Eranian <eranian@hpl.hp.com>
4 * Contributed by Fenghua Yu <fenghua.yu@intel.com>
5 * Contributed by Bibo Mao <bibo.mao@intel.com>
6 * Contributed by Chandramouli Narayanan <mouli@linux.intel.com>
8 * This file is part of the ELILO, the EFI Linux boot loader.
10 * ELILO is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2, or (at your option)
15 * ELILO is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with ELILO; see the file COPYING. If not, write to the Free
22 * Software Foundation, 59 Temple Place - Suite 330, Boston, MA
25 * Please check out the elilo.txt for complete documentation on how
26 * to use this program.
28 * Portions of this file are derived from the LILO/x86
29 * Copyright 1992-1997 Werner Almesberger.
34 #include <efistdarg.h>
40 * The first default config file is architecture dependent. This is useful
41 * in case of network booting where the server is used for both types of
44 #if defined(CONFIG_ia64)
45 #define ELILO_ARCH_DEFAULT_CONFIG L"elilo-ia64.conf"
46 #elif defined (CONFIG_ia32)
47 #define ELILO_ARCH_DEFAULT_CONFIG L"elilo-ia32.conf"
48 #elif defined (CONFIG_x86_64)
49 #define ELILO_ARCH_DEFAULT_CONFIG L"elilo-x86_64.conf"
51 #error "You need to specfy your default arch config file"
55 * last resort config file. Common to all architectures
57 #define ELILO_DEFAULT_CONFIG L"elilo.conf"
59 #define MAX_STRING CMDLINE_MAXLEN
60 #define CONFIG_BUFSIZE 512 /* input buffer size */
63 * maximum number of message files.
65 * main message= goes at entry 0, entries [1-12] are used for function keys
68 #define MAX_MESSAGES 13
70 typedef struct boot_image {
71 struct boot_image *next;
72 CHAR16 label[MAX_STRING];
73 CHAR16 kname[FILENAME_MAXLEN];
74 CHAR16 options[MAX_STRING];
75 CHAR16 initrd[FILENAME_MAXLEN];
76 CHAR16 vmcode[FILENAME_MAXLEN];
77 CHAR16 root[FILENAME_MAXLEN];
78 CHAR16 fallback[MAX_STRING];
79 CHAR16 description[MAX_STRING];
85 sys_img_options_t sys_img_opts; /* architecture specific image options */
96 * global shared options
97 * architecture specific global options are private to each architecture
100 CHAR16 root[FILENAME_MAXLEN]; /* globally defined root fs */
101 CHAR16 initrd[FILENAME_MAXLEN];/* globally defined initrd */
102 CHAR16 vmcode[FILENAME_MAXLEN];/* globally defined boot-time module */
103 CHAR16 options[MAX_STRING];
104 CHAR16 default_image_name[MAX_STRING];
105 CHAR16 message_file[MAX_MESSAGES][FILENAME_MAXLEN];
106 CHAR16 chooser[FILENAME_MAXLEN];/* which image chooser to use */
107 CHAR16 config_file[FILENAME_MAXLEN];
108 boot_image_t *default_image;
113 * options that may affect global elilo options
121 UINTN edd30_no_force; /* don't force EDD30 if not set */
125 * structure used to point to a group of options.
126 * Several group for the same category are supported via a linked list.
128 typedef struct _config_option_group {
129 struct _config_option_group *next; /* pointer to next group */
130 config_option_t *options; /* the table of options for this group */
131 UINTN nentries; /* number of entries for this group */
132 } config_option_group_t;
134 static option_action_t do_image, do_literal, do_options;
135 static INTN check_verbosity(VOID *), check_chooser(VOID *);
137 static global_config_t global_config; /* options shared by all images */
140 * Core global options: shared by all architectures, all modules
142 static config_option_t global_common_options[]={
143 {OPT_STR, OPT_GLOBAL, L"default", NULL, NULL, global_config.default_image_name},
144 {OPT_NUM, OPT_GLOBAL, L"timeout", NULL, NULL, &global_config.timeout},
145 {OPT_NUM, OPT_GLOBAL, L"delay", NULL, NULL, &global_config.delay},
146 {OPT_BOOL, OPT_GLOBAL, L"debug", NULL, NULL, &global_config.debug},
147 {OPT_BOOL, OPT_GLOBAL, L"prompt", NULL, NULL, &global_config.prompt},
148 {OPT_NUM, OPT_GLOBAL, L"verbose", NULL, check_verbosity, &global_config.verbose},
149 {OPT_FILE, OPT_GLOBAL, L"root", NULL, NULL, global_config.root},
150 {OPT_BOOL, OPT_GLOBAL, L"read-only", NULL, NULL, &global_config.readonly},
151 {OPT_BOOL, OPT_GLOBAL, L"noedd30", NULL, NULL, &global_config.edd30_no_force},
152 {OPT_CMD, OPT_GLOBAL, L"append", NULL, NULL, global_config.options},
153 {OPT_FILE, OPT_GLOBAL, L"initrd", NULL, NULL, global_config.initrd},
154 {OPT_FILE, OPT_GLOBAL, L"vmm", NULL, NULL, global_config.vmcode},
155 {OPT_FILE, OPT_GLOBAL, L"image", do_image, NULL, opt_offsetof(kname)},
156 {OPT_BOOL, OPT_GLOBAL, L"checkalt", NULL, NULL, &global_config.alt_check},
157 {OPT_STR, OPT_GLOBAL, L"chooser", NULL, check_chooser, global_config.chooser},
158 {OPT_FILE, OPT_GLOBAL, L"message", NULL, NULL, global_config.message_file[0]},
159 {OPT_FILE, OPT_GLOBAL, L"f1", NULL, NULL, global_config.message_file[1]},
160 {OPT_FILE, OPT_GLOBAL, L"f2", NULL, NULL, global_config.message_file[2]},
161 {OPT_FILE, OPT_GLOBAL, L"f3", NULL, NULL, global_config.message_file[3]},
162 {OPT_FILE, OPT_GLOBAL, L"f4", NULL, NULL, global_config.message_file[4]},
163 {OPT_FILE, OPT_GLOBAL, L"f5", NULL, NULL, global_config.message_file[5]},
164 {OPT_FILE, OPT_GLOBAL, L"f6", NULL, NULL, global_config.message_file[6]},
165 {OPT_FILE, OPT_GLOBAL, L"f7", NULL, NULL, global_config.message_file[7]},
166 {OPT_FILE, OPT_GLOBAL, L"f8", NULL, NULL, global_config.message_file[8]},
167 {OPT_FILE, OPT_GLOBAL, L"f9", NULL, NULL, global_config.message_file[9]},
168 {OPT_FILE, OPT_GLOBAL, L"f10", NULL, NULL, global_config.message_file[10]},
169 {OPT_FILE, OPT_GLOBAL, L"f11", NULL, NULL, global_config.message_file[11]},
170 {OPT_FILE, OPT_GLOBAL, L"f12", NULL, NULL, global_config.message_file[12]}
173 static config_option_t image_common_options[]={
174 {OPT_FILE, OPT_IMAGE, L"root", NULL, NULL, opt_offsetof(root)},
175 {OPT_BOOL, OPT_IMAGE, L"read-only", NULL, NULL, opt_offsetof(readonly)},
176 {OPT_CMD, OPT_IMAGE, L"append", do_options, NULL, opt_offsetof(options)},
177 {OPT_CMD, OPT_IMAGE, L"literal", do_literal, NULL, NULL},
178 {OPT_FILE, OPT_IMAGE, L"initrd", NULL, NULL, opt_offsetof(initrd)},
179 {OPT_FILE, OPT_IMAGE, L"vmm", NULL, NULL, opt_offsetof(vmcode)},
180 {OPT_STR, OPT_IMAGE, L"label", NULL, NULL, opt_offsetof(label)},
181 {OPT_FILE, OPT_IMAGE, L"image", do_image, NULL, opt_offsetof(kname)},
182 {OPT_STR, OPT_IMAGE, L"description", NULL, NULL, opt_offsetof(description)},
185 #define OPTION_IS_GLOBAL(p) ((p)->scope == OPT_GLOBAL)
186 #define OPTION_IS_IMG_SYS(p) ((p)->scope == OPT_IMAGE_SYS)
188 #define CHAR_EOF (CHAR16)-1 /* Unicode version of EOF */
189 #define CHAR_NUM0 L'0'
190 #define CHAR_NUM9 L'9'
192 static UINTN line_num;
193 static INTN back; /* can go back by one char */
195 static config_option_group_t *global_option_list;
196 static config_option_group_t *image_option_list;
199 static config_option_group_t *current_options;
201 static boot_image_t *image_list, *first_image;
202 static boot_image_t *current_img;
204 static INT8 config_buf[CONFIG_BUFSIZE]; /* input buffer: file must be in ASCII! */
205 static UINTN buf_max, buf_pos;
207 static fops_fd_t config_fd;
210 config_error(CHAR16 *msg,...)
212 Print(L"near line %d: ",line_num);
213 IPrint(systab->ConOut, msg);
218 * low level read routine
222 * - the next available unicode character
224 * - CHAR_EOF : indicating error or EOF
226 * XXX: we suppose that the file is in ASCII format!
233 if (buf_pos == 0 || buf_pos == buf_max) {
234 buf_max = CONFIG_BUFSIZE;
235 status = fops_read(config_fd, config_buf, &buf_max);
236 if (EFI_ERROR(status) || buf_max == 0) return CHAR_EOF;
240 return (CHAR16)config_buf[buf_pos++];
245 * get the next unicode character with a one character
262 * rewind by one character
267 if (back) { config_error(L"config: again invoked twice"); }
272 * Look for matching option in the current group
275 * - pointer to option if found
276 * - NULL if not found
278 static config_option_t *
279 find_option(config_option_group_t *grp, CHAR16 *str)
281 config_option_t *p = NULL;
282 config_option_t *end;
286 end = grp->options+grp->nentries;
289 if (!StrCmp(str, p->name)) return p;
298 * main parser function
300 * - a token code representing the kind of element found
301 * - TOK_EOF: end-of-file (or error) detected
302 * - TOK_STR: if string is found
303 * - TOK_EQUAL: for the '=' sign
304 * - TOK_ERR: in case of (parsing) error
307 get_token(CHAR16 *str, UINTN maxlen)
313 while ((ch = next()), ch == ' ' || ch == '\t' || ch == '\n') if (ch == '\n') line_num++;
315 if (ch == CHAR_EOF) return TOK_EOF;
317 if (ch != '#') break;
319 /* skip comment line */
320 while ((ch = next()), ch != '\n') if (ch == CHAR_EOF) return TOK_EOF;
323 if (ch == '=') return TOK_EQUAL;
327 while (here-str < maxlen) {
328 if ((ch = next()) == CHAR_EOF) {
329 config_error(L"EOF in quoted string");
338 if (ch != '"' && ch != '\\' && ch != '\n') {
339 config_error(L"Bad use of \\ in quoted string");
342 if (ch == '\n') continue;
344 while ((ch = next()), ch == ' ' || ch == '\t');
351 if (ch == '\n' || ch == '\t') {
352 config_error(L"\\n and \\t are not allowed in quoted strings");
357 config_error(L"Quoted string is too long");
364 while (here-str < maxlen) {
366 if (ch == CHAR_EOF) {
367 config_error(L"\\ precedes EOF");
370 if (ch == '\n') line_num++;
371 else *here++ = ch == '\t' ? ' ' : ch;
375 if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '#' ||
376 ch == '=' || ch == CHAR_EOF) {
381 if (!(escaped = (ch == '\\'))) *here++ = ch;
385 config_error(L"Token is too long");
390 image_check(boot_image_t *img)
394 if (img == NULL) return -1;
396 /* do the obvious first */
397 if (img->label[0] == '\0') {
398 config_error(L"image has no label");
402 /* image_list points to the */
403 for(b=image_list; b; b = b->next) {
404 if (img == b) continue;
405 if (!StrCmp(img->label, b->label)) {
406 config_error(L"image with label %s already defined", img->label);
424 if (global_config.default_image_name[0]) {
425 for(b=image_list; b; b = b->next) {
426 if (!StrCmp(b->label, global_config.default_image_name)) goto found;
428 config_error(L"default image '%s' not defined ", global_config.default_image_name);
431 global_config.default_image = first_image;
434 global_config.default_image = b;
439 * depending on the active set of options
440 * adjust the option data pointer to:
441 * if global option set:
442 * - just the straight value from p->data
443 * if image option set:
444 * - adjust as offset to image
446 * - the adjusted pointer
449 adjust_pointer(config_option_t *p)
454 if (OPTION_IS_GLOBAL(p)) return p->data;
456 if (OPTION_IS_IMG_SYS(p)) return (VOID *)((UINTN)¤t_img->sys_img_opts + p->data);
458 return (VOID *)((UINTN)current_img + p->data);
462 * create a new image entry
465 do_image(config_option_t *p, VOID *str)
470 * if we move to a new image from the current one
471 * then we need to check for validity of current.
473 * if this is the first image, then check the global
477 if (image_check(current_img) == -1) return -1;
478 } else if (global_check() == -1) return -1;
480 img = (boot_image_t *)alloc(sizeof(boot_image_t), EfiLoaderData);
481 if (img == NULL) return -1;
483 Memset(img, 0, sizeof(boot_image_t));
485 DBG_PRT((L"must do image on %s", (CHAR16 *)str));
487 /* copy kernel file name */
488 StrCpy(img->kname, str);
490 /* switch to image mode */
491 current_options = image_option_list;
493 /* keep track of first image in case no default is defined */
494 if (image_list == NULL) first_image = img;
496 /* append to end of image list, so when a chooser asks for the list
497 * it gets them in the order they were in in the config file
499 if (image_list == NULL)
502 boot_image_t * p = image_list;
509 /* update current image */
516 * by default all boolean options are defined
517 * as false. This function sets the boolean
521 do_boolean(config_option_t *p)
525 buf = adjust_pointer(p);
527 if (p->action) return p->action(p, NULL);
529 /* set the field to true, overwrite if already defined */
536 * the image option 'literal' requires special handling
537 * because it overrides any defined option be it global or
538 * local. so we use the option field and record the fact that
539 * it should be interpreted as literal
542 do_literal(config_option_t *p, VOID *str)
545 * we know we have a valid current image at this point
547 StrCpy(current_img->options, str);
549 current_img->literal = 1;
555 do_options(config_option_t *p, VOID *str)
557 /* we ignore append if literal is already defined */
558 if (current_img->literal) return 0;
561 * we know we have a valid current image at this point
563 StrCpy(current_img->options, str);
569 do_numeric(config_option_t *p)
571 CHAR16 numstr[MAX_STRING];
580 tok = get_token(numstr, MAX_STRING);
581 if (tok != TOK_EQUAL) {
582 config_error(L"Option %s expects an equal signal + value", p->name);
588 * XXX: = lexer should return TOK_NUM (and we'd be done)
590 tok = get_token(numstr, MAX_STRING);
591 if (tok != TOK_STR) {
592 config_error(L"Option %s expects a value", p->name);
597 * if there is a customized way of doing the operation
598 * do it and bypass generic
600 if (p->action) return p->action(p, str);
605 if (p->data == NULL) return 0;
607 buf = (UINTN *)adjust_pointer(p);
609 while (*str && *str >= CHAR_NUM0 && *str <= CHAR_NUM9) str++;
611 config_error(L"%s is expecting a numeric decimal value", p->name);
617 if (p->check && p->check(&tmp) == -1) return -1;
620 * check for multiple definitions in the same context
621 * XXX: zero must not be a valid number !
624 config_error(L"option %s is already defined in this context", p->name);
634 check_verbosity(VOID *data)
636 UINTN *val = (UINTN *)data;
639 config_error(L"Verbosity level must be in [0-5] and not %d", *val);
647 * here we simply check if chooser is compiled in. At this point, the chooser
648 * initialization is not done, so we don't know if that chooser will even be
652 check_chooser(VOID *data)
654 CHAR16 *chooser = (CHAR16 *)data;
656 if (exist_chooser(chooser) == -1) {
657 config_error(L"chooser %s is unknown\n", chooser);
665 do_string_core(config_option_t *p, CHAR16 *str, UINTN maxlen, CHAR16 *msg)
673 tok = get_token(str, maxlen);
674 if (tok != TOK_EQUAL) {
675 config_error(L"Option %s expects an equal signal + %s", p->name, msg);
682 tok = get_token(str, maxlen);
683 if (tok != TOK_STR) {
684 config_error(L"Option %s expects %s", p->name, msg);
689 * if there is a customized way of doing the operation
690 * do it and bypass generic
692 if (p->action) return p->action(p, str);
697 if (p->data == NULL) return 0;
699 buf = adjust_pointer(p);
701 if (*buf != CHAR_NULL) {
702 config_error(L"'%s' already defined", p->name);
705 if (p->check && p->check(str) == -1) return -1;
716 do_string(config_option_t *p)
718 CHAR16 str[MAX_STRING];
720 return do_string_core(p, str, MAX_STRING, L"string");
724 do_file(config_option_t *p)
726 CHAR16 str[FILENAME_MAXLEN];
728 return do_string_core(p, str, FILENAME_MAXLEN, L"filename");
733 do_cmd(config_option_t *p)
735 CHAR16 str[CMDLINE_MAXLEN];
736 return do_string_core(p, str, CMDLINE_MAXLEN, L"kernel options");
743 CHAR16 str[MAX_STRING];
749 tok = get_token(str, MAX_STRING);
751 if (tok == TOK_EOF) break;
753 if (tok == TOK_ERR) return -1;
755 if ( (p = find_option(current_options, str)) == NULL) {
756 config_error(L"Unkown option %s", str);
760 /* make sure we trap in case of error */
780 config_error(L"Unkown option type %d", p->type);
782 if (ret == -1) goto error;
785 ret = image_check(current_img);
787 config_error(L"No image defined !");
789 if (ret == 0) ret = final_check();
795 update_elilo_opt(VOID)
798 * update boolean options first
799 * Rule: by default not set unless explcitely requested on command line
800 * therefore we can just update from global_config is set there.
802 if (global_config.alt_check) elilo_opt.alt_check = 1;
804 if (global_config.debug) elilo_opt.debug = 1;
805 if (global_config.prompt) elilo_opt.prompt = 1;
808 * update only if not set on command line
809 * XXX: rely on the existence of a non-valid value as a marker than
810 * the option was not specified on the command line
812 if (global_config.verbose && elilo_opt.verbose == 0)
813 elilo_opt.verbose = global_config.verbose;
815 if (global_config.chooser[0] && elilo_opt.chooser[0] == 0)
816 StrCpy(elilo_opt.chooser, global_config.chooser);
819 * if edd30_no_force not set by command line option but via config
820 * file, then propagate
822 if (global_config.edd30_no_force && elilo_opt.edd30_no_force == 0)
823 elilo_opt.edd30_no_force = 1;
826 * Difficult case of numeric where 0 can be a valid value
827 * XXX: find a better way of handling these options!
829 if (global_config.delay && elilo_opt.delay_set == 0)
830 elilo_opt.delay = global_config.delay;
832 /* readjusted by caller if necessary. 0 not a valid value here */
833 elilo_opt.timeout = global_config.timeout;
835 /* initrd is updated later when we have an image match */
839 * When called after read_config(), this function returns the config file
840 * used by the loader, or NULL if no file was found.
843 get_config_file(VOID)
845 return global_config.config_file[0] ? global_config.config_file : NULL;
849 read_config(CHAR16 *filename)
854 if (filename == NULL) return EFI_INVALID_PARAMETER;
856 VERB_PRT(3, Print(L"trying config file %s\n", filename));
858 StrCpy(global_config.config_file, filename);
860 status = fops_open(filename, &config_fd);
861 if (EFI_ERROR(status)) {
862 VERB_PRT(3, Print(L"cannot open config file %s\n", filename));
866 * start numbering at line 1
870 ret = config_parse();
872 fops_close(config_fd);
874 DBG_PRT((L"done parsing config file\n"));
876 if (ret != 0) return EFI_INVALID_PARAMETER;
884 print_label_list(VOID)
886 boot_image_t *img, *dfl = global_config.default_image;
888 if (dfl) Print(L"\t%s\n", dfl->label);
890 for (img = image_list; img; img = img->next) {
891 if (img != dfl) Print(L"\t%s\n", img->label);
895 /* Make labels and corresponding descriptions available to choosers. The
896 * idea is that the caller passes NULL for 'prev'; the first time, and
897 * passes the previously returned value on subsequent calls. The caller
898 * repeats until this fn returns NULL.
902 get_next_description(VOID *prev, CHAR16 **label, CHAR16 **description)
904 boot_image_t *img = (boot_image_t *)prev;
913 *description = img->description;
921 * find a description using the label name
922 * return NULL if label not found or no description defined
925 find_description(CHAR16 *label)
929 /* Attempt to find the image name now */
930 for (img = image_list; img; img = img->next) {
931 if (StriCmp(img->label, label) == 0) {
932 return img->description;
939 find_label(CHAR16 *label, CHAR16 *kname, CHAR16 *options, CHAR16 *initrd, CHAR16 *vmcode)
944 if (global_config.default_image == NULL) return -1;
945 img = global_config.default_image;
951 /* Attempt to find the image name now */
952 for (img = image_list; img; img = img->next) {
953 if (StriCmp(img->label, label) == 0) {
958 * when the label does not exist, we still propagate the global options
960 if (global_config.root[0]) {
961 StrCpy(options, L" root=");
962 StrCat(options, global_config.root);
965 if (global_config.options[0]) {
966 StrCat(options, L" ");
967 StrCat(options, global_config.options);
969 if (global_config.readonly) StrCat(options, L" ro");
971 if (global_config.initrd[0]) StrCpy(initrd, global_config.initrd);
972 if (global_config.vmcode[0]) StrCpy(vmcode, global_config.vmcode);
974 /* make sure we don't get garbage here */
975 elilo_opt.sys_img_opts = NULL;
979 StrCpy(kname, img->kname);
982 * literal option overrides any other image-based or global option
984 * In any case, the image option has priority over the global option
986 if (img->literal == 0) {
987 if (img->root[0] || global_config.root[0]) {
988 StrCat(options, L"root=");
989 StrCat(options, img->root[0] ? img->root : global_config.root);
991 /* XXX: check max length */
992 if (img->options[0] || global_config.options[0]) {
993 StrCat(options, L" ");
994 StrCat(options, img->options[0] ? img->options: global_config.options);
996 if (img->readonly || global_config.readonly) {
997 StrCat(options, L" ro");
1000 /* literal options replace everything */
1001 StrCpy(options, img->options);
1004 /* per image initrd has precedence over global initrd */
1006 StrCpy(initrd, img->initrd);
1007 else if (global_config.initrd[0])
1008 StrCpy(initrd, global_config.initrd);
1011 StrCpy(vmcode, img->vmcode);
1012 else if (global_config.vmcode[0])
1013 StrCpy(vmcode, global_config.vmcode);
1016 * point to architecture dependent options for this image
1018 elilo_opt.sys_img_opts = &img->sys_img_opts;
1020 DBG_PRT((L"label %s: kname=%s options=%s initrd=%s vmcode=%s", img->label, kname, options, initrd, vmcode));
1026 print_options(config_option_group_t *grp, BOOLEAN first)
1028 config_option_t *end, *p;
1033 end = grp->options+grp->nentries;
1044 str = L"%s=filename";
1047 str = L"%s=kernel_options";
1055 if (str && first == FALSE) Print(L", ");
1056 if (str) Print(str, p->name);
1066 print_config_options(VOID)
1068 Print(L"Global options supported:\n");
1070 print_options(global_option_list, TRUE);
1073 Print(L"Image options supported:\n");
1074 print_options(image_option_list, TRUE);
1080 * returns a pointer to filename used for message N (which). NULL if it does
1084 get_message_filename(INTN which)
1086 if (which < 0 || which >= MAX_MESSAGES) return NULL;
1087 return global_config.message_file[which];
1091 register_config_options(config_option_t *opt, UINTN n, config_option_group_scope_t group)
1093 config_option_group_t *newgrp, **grp;
1095 if (opt == NULL || n == 0 || (group != OPTIONS_GROUP_GLOBAL && group != OPTIONS_GROUP_IMAGE)) return -1;
1097 VERB_PRT(3, Print(L"registering %d options for group %s\n", n, group == OPTIONS_GROUP_GLOBAL ? L"global" : L"image"));
1099 newgrp = alloc(sizeof(config_option_group_t), EfiLoaderData);
1100 if (newgrp == NULL) return -1;
1102 grp = group == OPTIONS_GROUP_GLOBAL ? &global_option_list : &image_option_list;
1104 if (*grp) while ((*grp)->next) grp = &(*grp)->next;
1106 newgrp->options = opt;
1107 newgrp->next = NULL;
1108 newgrp->nentries = n;
1111 (*grp)->next = newgrp;
1119 * initialize config options: register global and per image options
1126 ret = register_config_options(global_common_options,
1127 sizeof(global_common_options)/sizeof(config_option_t),
1128 OPTIONS_GROUP_GLOBAL);
1129 if (ret == -1) return -1;
1131 ret = register_config_options(image_common_options,
1132 sizeof(image_common_options)/sizeof(config_option_t),
1133 OPTIONS_GROUP_IMAGE);
1135 current_options = global_option_list;