2 * Copyright (C) 2001-2003 Hewlett-Packard Co.
3 * Contributed by Stephane Eranian <eranian@hpl.hp.com>
5 * This file is part of the ELILO, the EFI Linux boot loader.
7 * ELILO is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * ELILO is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with ELILO; see the file COPYING. If not, write to the Free
19 * Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 * Please check out the elilo.txt for complete documentation on how
23 * to use this program.
25 * Portions of this file are derived from the LILO/x86
26 * Copyright 1992-1997 Werner Almesberger.
31 #include <efistdarg.h>
37 * The first default config file is architecture dependent. This is useful
38 * in case of network booting where the server is used for both types of
41 #if defined(CONFIG_ia64)
42 #define ELILO_ARCH_DEFAULT_CONFIG L"elilo-ia64.conf"
43 #elif defined (CONFIG_ia32)
44 #define ELILO_ARCH_DEFAULT_CONFIG L"elilo-ia32.conf"
46 #error "You need to specfy your default arch config file"
50 * last resort config file. Common to all architectures
52 #define ELILO_DEFAULT_CONFIG L"elilo.conf"
54 #define MAX_STRING CMDLINE_MAXLEN
55 #define CONFIG_BUFSIZE 512 /* input buffer size */
58 * maximum number of message files.
60 * main message= goes at entry 0, entries [1-12] are used for function keys
63 #define MAX_MESSAGES 13
65 typedef struct boot_image {
66 struct boot_image *next;
67 CHAR16 label[MAX_STRING];
68 CHAR16 kname[FILENAME_MAXLEN];
69 CHAR16 options[MAX_STRING];
70 CHAR16 initrd[FILENAME_MAXLEN];
71 CHAR16 root[FILENAME_MAXLEN];
72 CHAR16 fallback[MAX_STRING];
73 CHAR16 description[MAX_STRING];
79 sys_img_options_t sys_img_opts; /* architecture specific image options */
90 * global shared options
91 * architecture specific global options are private to each architecture
94 CHAR16 root[FILENAME_MAXLEN]; /* globally defined root fs */
95 CHAR16 initrd[FILENAME_MAXLEN];/* globally defined initrd */
96 CHAR16 options[MAX_STRING];
97 CHAR16 default_image_name[MAX_STRING];
98 CHAR16 message_file[MAX_MESSAGES][FILENAME_MAXLEN];
99 CHAR16 chooser[FILENAME_MAXLEN];/* which image chooser to use */
100 CHAR16 config_file[FILENAME_MAXLEN];
101 boot_image_t *default_image;
106 * options that may affect global elilo options
114 UINTN edd30_no_force; /* don't force EDD30 if not set */
118 * structure used to point to a group of options.
119 * Several group for the same category are supported via a linked list.
121 typedef struct _config_option_group {
122 struct _config_option_group *next; /* pointer to next group */
123 config_option_t *options; /* the table of options for this group */
124 UINTN nentries; /* number of entries for this group */
125 } config_option_group_t;
127 static option_action_t do_image, do_literal, do_options;
128 static INTN check_verbosity(VOID *), check_chooser(VOID *);
130 static global_config_t global_config; /* options shared by all images */
133 * Core global options: shared by all architectures, all modules
135 static config_option_t global_common_options[]={
136 {OPT_STR, OPT_GLOBAL, L"default", NULL, NULL, global_config.default_image_name},
137 {OPT_NUM, OPT_GLOBAL, L"timeout", NULL, NULL, &global_config.timeout},
138 {OPT_NUM, OPT_GLOBAL, L"delay", NULL, NULL, &global_config.delay},
139 {OPT_BOOL, OPT_GLOBAL, L"debug", NULL, NULL, &global_config.debug},
140 {OPT_BOOL, OPT_GLOBAL, L"prompt", NULL, NULL, &global_config.prompt},
141 {OPT_NUM, OPT_GLOBAL, L"verbose", NULL, check_verbosity, &global_config.verbose},
142 {OPT_FILE, OPT_GLOBAL, L"root", NULL, NULL, global_config.root},
143 {OPT_BOOL, OPT_GLOBAL, L"read-only", NULL, NULL, &global_config.readonly},
144 {OPT_BOOL, OPT_GLOBAL, L"noedd30", NULL, NULL, &global_config.edd30_no_force},
145 {OPT_CMD, OPT_GLOBAL, L"append", NULL, NULL, global_config.options},
146 {OPT_FILE, OPT_GLOBAL, L"initrd", NULL, NULL, global_config.initrd},
147 {OPT_FILE, OPT_GLOBAL, L"image", do_image, NULL, opt_offsetof(kname)},
148 {OPT_BOOL, OPT_GLOBAL, L"checkalt", NULL, NULL, &global_config.alt_check},
149 {OPT_STR, OPT_GLOBAL, L"chooser", NULL, check_chooser, global_config.chooser},
150 {OPT_FILE, OPT_GLOBAL, L"message", NULL, NULL, global_config.message_file[0]},
151 {OPT_FILE, OPT_GLOBAL, L"f1", NULL, NULL, global_config.message_file[1]},
152 {OPT_FILE, OPT_GLOBAL, L"f2", NULL, NULL, global_config.message_file[2]},
153 {OPT_FILE, OPT_GLOBAL, L"f3", NULL, NULL, global_config.message_file[3]},
154 {OPT_FILE, OPT_GLOBAL, L"f4", NULL, NULL, global_config.message_file[4]},
155 {OPT_FILE, OPT_GLOBAL, L"f5", NULL, NULL, global_config.message_file[5]},
156 {OPT_FILE, OPT_GLOBAL, L"f6", NULL, NULL, global_config.message_file[6]},
157 {OPT_FILE, OPT_GLOBAL, L"f7", NULL, NULL, global_config.message_file[7]},
158 {OPT_FILE, OPT_GLOBAL, L"f8", NULL, NULL, global_config.message_file[8]},
159 {OPT_FILE, OPT_GLOBAL, L"f9", NULL, NULL, global_config.message_file[9]},
160 {OPT_FILE, OPT_GLOBAL, L"f10", NULL, NULL, global_config.message_file[10]},
161 {OPT_FILE, OPT_GLOBAL, L"f11", NULL, NULL, global_config.message_file[11]},
162 {OPT_FILE, OPT_GLOBAL, L"f12", NULL, NULL, global_config.message_file[12]}
165 static config_option_t image_common_options[]={
166 {OPT_FILE, OPT_IMAGE, L"root", NULL, NULL, opt_offsetof(root)},
167 {OPT_BOOL, OPT_IMAGE, L"read-only", NULL, NULL, opt_offsetof(readonly)},
168 {OPT_CMD, OPT_IMAGE, L"append", do_options, NULL, opt_offsetof(options)},
169 {OPT_CMD, OPT_IMAGE, L"literal", do_literal, NULL, NULL},
170 {OPT_FILE, OPT_IMAGE, L"initrd", NULL, NULL, opt_offsetof(initrd)},
171 {OPT_STR, OPT_IMAGE, L"label", NULL, NULL, opt_offsetof(label)},
172 {OPT_FILE, OPT_IMAGE, L"image", do_image, NULL, opt_offsetof(kname)},
173 {OPT_STR, OPT_IMAGE, L"description", NULL, NULL, opt_offsetof(description)},
176 #define OPTION_IS_GLOBAL(p) ((p)->scope == OPT_GLOBAL)
177 #define OPTION_IS_IMG_SYS(p) ((p)->scope == OPT_IMAGE_SYS)
179 #define CHAR_EOF (CHAR16)-1 /* Unicode version of EOF */
180 #define CHAR_NUM0 L'0'
181 #define CHAR_NUM9 L'9'
183 static UINTN line_num;
184 static INTN back; /* can go back by one char */
186 static config_option_group_t *global_option_list;
187 static config_option_group_t *image_option_list;
190 static config_option_group_t *current_options;
192 static boot_image_t *image_list, *first_image;
193 static boot_image_t *current_img;
195 static INT8 config_buf[CONFIG_BUFSIZE]; /* input buffer: file must be in ASCII! */
196 static UINTN buf_max, buf_pos;
198 static fops_fd_t config_fd;
201 config_error(CHAR16 *msg,...)
204 extern UINTN _IPrint (UINTN, UINTN, SIMPLE_TEXT_OUTPUT_INTERFACE *, CHAR16 *, CHAR8 *, va_list);
206 Print(L"near line %d: ",line_num);
209 _IPrint((UINTN)-1, (UINTN)-1, systab->ConOut, msg, NULL, ap);
215 * low level read routine
219 * - the next available unicode character
221 * - CHAR_EOF : indicating error or EOF
223 * XXX: we suppose that the file is in ASCII format!
230 if (buf_pos == 0 || buf_pos == buf_max) {
231 buf_max = CONFIG_BUFSIZE;
232 status = fops_read(config_fd, config_buf, &buf_max);
233 if (EFI_ERROR(status) || buf_max == 0) return CHAR_EOF;
237 return (CHAR16)config_buf[buf_pos++];
242 * get the next unicode character with a one character
259 * rewind by one character
264 if (back) { config_error(L"config: again invoked twice"); }
269 * Look for matching option in the current group
272 * - pointer to option if found
273 * - NULL if not found
275 static config_option_t *
276 find_option(config_option_group_t *grp, CHAR16 *str)
278 config_option_t *p = NULL;
279 config_option_t *end;
283 end = grp->options+grp->nentries;
286 if (!StrCmp(str, p->name)) return p;
295 * main parser function
297 * - a token code representing the kind of element found
298 * - TOK_EOF: end-of-file (or error) detected
299 * - TOK_STR: if string is found
300 * - TOK_EQUAL: for the '=' sign
301 * - TOK_ERR: in case of (parsing) error
304 get_token(CHAR16 *str, UINTN maxlen)
310 while ((ch = next()), ch == ' ' || ch == '\t' || ch == '\n') if (ch == '\n') line_num++;
312 if (ch == CHAR_EOF) return TOK_EOF;
314 if (ch != '#') break;
316 /* skip comment line */
317 while ((ch = next()), ch != '\n') if (ch == CHAR_EOF) return TOK_EOF;
320 if (ch == '=') return TOK_EQUAL;
324 while (here-str < maxlen) {
325 if ((ch = next()) == CHAR_EOF) {
326 config_error(L"EOF in quoted string");
335 if (ch != '"' && ch != '\\' && ch != '\n') {
336 config_error(L"Bad use of \\ in quoted string");
339 if (ch == '\n') continue;
341 while ((ch = next()), ch == ' ' || ch == '\t');
348 if (ch == '\n' || ch == '\t') {
349 config_error(L"\\n and \\t are not allowed in quoted strings");
354 config_error(L"Quoted string is too long");
361 while (here-str < maxlen) {
363 if (ch == CHAR_EOF) {
364 config_error(L"\\ precedes EOF");
367 if (ch == '\n') line_num++;
368 else *here++ = ch == '\t' ? ' ' : ch;
372 if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '#' ||
373 ch == '=' || ch == CHAR_EOF) {
378 if (!(escaped = (ch == '\\'))) *here++ = ch;
382 config_error(L"Token is too long");
387 image_check(boot_image_t *img)
391 if (img == NULL) return -1;
393 /* do the obvious first */
394 if (img->label[0] == '\0') {
395 config_error(L"image has no label");
399 /* image_list points to the */
400 for(b=image_list; b; b = b->next) {
401 if (img == b) continue;
402 if (!StrCmp(img->label, b->label)) {
403 config_error(L"image with label %s already defined", img->label);
421 if (global_config.default_image_name[0]) {
422 for(b=image_list; b; b = b->next) {
423 if (!StrCmp(b->label, global_config.default_image_name)) goto found;
425 config_error(L"default image '%s' not defined ", global_config.default_image_name);
428 global_config.default_image = first_image;
431 global_config.default_image = b;
436 * depending on the active set of options
437 * adjust the option data pointer to:
438 * if global option set:
439 * - just the straight value from p->data
440 * if image option set:
441 * - adjust as offset to image
443 * - the adjusted pointer
446 adjust_pointer(config_option_t *p)
451 if (OPTION_IS_GLOBAL(p)) return p->data;
453 if (OPTION_IS_IMG_SYS(p)) return (VOID *)((UINTN)¤t_img->sys_img_opts + p->data);
455 return (VOID *)((UINTN)current_img + p->data);
459 * create a new image entry
462 do_image(config_option_t *p, VOID *str)
467 * if we move to a new image from the current one
468 * then we need to check for validity of current.
470 * if this is the first image, then check the global
474 if (image_check(current_img) == -1) return -1;
475 } else if (global_check() == -1) return -1;
477 img = (boot_image_t *)alloc(sizeof(boot_image_t), EfiLoaderData);
478 if (img == NULL) return -1;
480 Memset(img, 0, sizeof(boot_image_t));
482 DBG_PRT((L"must do image on %s", (CHAR16 *)str));
484 /* copy kernel file name */
485 StrCpy(img->kname, str);
487 /* switch to image mode */
488 current_options = image_option_list;
490 /* keep track of first image in case no default is defined */
491 if (image_list == NULL) first_image = img;
493 /* append to end of image list, so when a chooser asks for the list
494 * it gets them in the order they were in in the config file
496 if (image_list == NULL)
499 boot_image_t * p = image_list;
506 /* update current image */
513 * by default all boolean options are defined
514 * as false. This function sets the boolean
518 do_boolean(config_option_t *p)
522 buf = adjust_pointer(p);
524 if (p->action) return p->action(p, NULL);
526 /* set the field to true, overwrite if already defined */
533 * the image option 'literal' requires special handling
534 * because it overrides any defined option be it global or
535 * local. so we use the option field and record the fact that
536 * it should be interpreted as literal
539 do_literal(config_option_t *p, VOID *str)
542 * we know we have a valid current image at this point
544 StrCpy(current_img->options, str);
546 current_img->literal = 1;
552 do_options(config_option_t *p, VOID *str)
554 /* we ignore append if literal is already defined */
555 if (current_img->literal) return 0;
558 * we know we have a valid current image at this point
560 StrCpy(current_img->options, str);
566 do_numeric(config_option_t *p)
568 CHAR16 numstr[MAX_STRING];
577 tok = get_token(numstr, MAX_STRING);
578 if (tok != TOK_EQUAL) {
579 config_error(L"Option %s expects an equal signal + value", p->name);
585 * XXX: = lexer should return TOK_NUM (and we'd be done)
587 tok = get_token(numstr, MAX_STRING);
588 if (tok != TOK_STR) {
589 config_error(L"Option %s expects a value", p->name);
594 * if there is a customized way of doing the operation
595 * do it and bypass generic
597 if (p->action) return p->action(p, str);
602 if (p->data == NULL) return 0;
604 buf = (UINTN *)adjust_pointer(p);
606 while (*str && *str >= CHAR_NUM0 && *str <= CHAR_NUM9) str++;
608 config_error(L"%s is expecting a numeric decimal value", p->name);
614 if (p->check && p->check(&tmp) == -1) return -1;
617 * check for multiple definitions in the same context
618 * XXX: zero must not be a valid number !
621 config_error(L"option %s is already defined in this context", p->name);
631 check_verbosity(VOID *data)
633 UINTN *val = (UINTN *)data;
636 config_error(L"Verbosity level must be in [0-5] and not %d", *val);
644 * here we simply check if chooser is compiled in. At this point, the chooser
645 * initialization is not done, so we don't know if that chooser will even be
649 check_chooser(VOID *data)
651 CHAR16 *chooser = (CHAR16 *)data;
653 if (exist_chooser(chooser) == -1) {
654 config_error(L"chooser %s is unknown\n", chooser);
662 do_string_core(config_option_t *p, CHAR16 *str, UINTN maxlen, CHAR16 *msg)
670 tok = get_token(str, maxlen);
671 if (tok != TOK_EQUAL) {
672 config_error(L"Option %s expects an equal signal + %s", p->name, msg);
679 tok = get_token(str, maxlen);
680 if (tok != TOK_STR) {
681 config_error(L"Option %s expects %s", p->name, msg);
686 * if there is a customized way of doing the operation
687 * do it and bypass generic
689 if (p->action) return p->action(p, str);
694 if (p->data == NULL) return 0;
696 buf = adjust_pointer(p);
698 if (*buf != CHAR_NULL) {
699 config_error(L"'%s' already defined", p->name);
702 if (p->check && p->check(str) == -1) return -1;
713 do_string(config_option_t *p)
715 CHAR16 str[MAX_STRING];
717 return do_string_core(p, str, MAX_STRING, L"string");
721 do_file(config_option_t *p)
723 CHAR16 str[FILENAME_MAXLEN];
725 return do_string_core(p, str, FILENAME_MAXLEN, L"filename");
730 do_cmd(config_option_t *p)
732 CHAR16 str[CMDLINE_MAXLEN];
733 return do_string_core(p, str, CMDLINE_MAXLEN, L"kernel options");
740 CHAR16 str[MAX_STRING];
746 tok = get_token(str, MAX_STRING);
748 if (tok == TOK_EOF) break;
750 if (tok == TOK_ERR) return -1;
752 if ( (p = find_option(current_options, str)) == NULL) {
753 config_error(L"Unkown option %s", str);
757 /* make sure we trap in case of error */
777 config_error(L"Unkown option type %d", p->type);
779 if (ret == -1) goto error;
782 ret = image_check(current_img);
784 config_error(L"No image defined !");
786 if (ret == 0) ret = final_check();
792 update_elilo_opt(VOID)
795 * update boolean options first
796 * Rule: by default not set unless explcitely requested on command line
797 * therefore we can just update from global_config is set there.
799 if (global_config.alt_check) elilo_opt.alt_check = 1;
801 if (global_config.debug) elilo_opt.debug = 1;
802 if (global_config.prompt) elilo_opt.prompt = 1;
805 * update only if not set on command line
806 * XXX: rely on the existence of a non-valid value as a marker than
807 * the option was not specified on the command line
809 if (global_config.verbose && elilo_opt.verbose == 0)
810 elilo_opt.verbose = global_config.verbose;
812 if (global_config.chooser[0] && elilo_opt.chooser[0] == 0)
813 StrCpy(elilo_opt.chooser, global_config.chooser);
816 * if edd30_no_force not set by command line option but via config
817 * file, then propagate
819 if (global_config.edd30_no_force && elilo_opt.edd30_no_force == 0)
820 elilo_opt.edd30_no_force = 1;
823 * Difficult case of numeric where 0 can be a valid value
824 * XXX: find a better way of handling these options!
826 if (global_config.delay && elilo_opt.delay_set == 0)
827 elilo_opt.delay = global_config.delay;
829 /* readjusted by caller if necessary. 0 not a valid value here */
830 elilo_opt.timeout = global_config.timeout;
832 /* initrd is updated later when we have an image match */
836 * When called after read_config(), this function returns the config file
837 * used by the loader, or NULL if no file was found.
840 get_config_file(VOID)
842 return global_config.config_file[0] ? global_config.config_file : NULL;
846 read_config(CHAR16 *filename, INTN retry)
851 if (filename == NULL) return EFI_INVALID_PARAMETER;
853 VERB_PRT(3, Print(L"trying config file %s\n", filename));
855 StrCpy(global_config.config_file, filename);
857 status = fops_open(filename, &config_fd);
858 if (EFI_ERROR(status)) {
860 * if the user explicitely specified a filename and we can't
861 * find it, then we must fail.
863 if (elilo_opt.parse_only || retry == 0) {
864 VERB_PRT(3, Print(L"cannot open config file %s\n", filename));
868 * if not already submitted filename,
870 if (StrCmp(filename, ELILO_ARCH_DEFAULT_CONFIG)) {
872 * try the arch default file, now
874 VERB_PRT(3,Print(L"config file %s not found, trying %s\n",
875 filename, ELILO_ARCH_DEFAULT_CONFIG));
877 StrCpy(global_config.config_file,ELILO_ARCH_DEFAULT_CONFIG);
879 status = fops_open(ELILO_ARCH_DEFAULT_CONFIG, &config_fd);
882 * if arch specific did not work, try generic
884 if (EFI_ERROR(status) && StrCmp(filename, ELILO_DEFAULT_CONFIG)) {
886 * try the default file as a last resort
888 VERB_PRT(3,Print(L"config file %s not found, trying %s\n",
889 ELILO_ARCH_DEFAULT_CONFIG, ELILO_DEFAULT_CONFIG));
891 StrCpy(global_config.config_file, ELILO_DEFAULT_CONFIG);
892 status = fops_open(ELILO_DEFAULT_CONFIG, &config_fd);
895 * if nothing worked, then bail out
897 if (EFI_ERROR(status)) {
898 VERB_PRT(3, Print(L"no valid config file found\n"));
899 global_config.config_file[0] = CHAR_NULL;
904 * start numbering at line 1
908 ret = config_parse();
910 fops_close(config_fd);
912 DBG_PRT((L"done parsing config file\n"));
914 if (ret != 0) return EFI_INVALID_PARAMETER;
922 print_label_list(VOID)
924 boot_image_t *img, *dfl = global_config.default_image;
926 if (dfl) Print(L"%s ", dfl->label);
928 for (img = image_list; img; img = img->next) {
929 if (img != dfl) Print(L"%s ", img->label);
933 /* Make labels and corresponding descriptions available to choosers. The
934 * idea is that the caller passes NULL for 'prev'; the first time, and
935 * passes the previously returned value on subsequent calls. The caller
936 * repeats until this fn returns NULL.
940 get_next_description(VOID *prev, CHAR16 **label, CHAR16 **description)
942 boot_image_t *img = (boot_image_t *)prev;
951 *description = img->description;
959 * find a description using the label name
960 * return NULL if label not found or no description defined
963 find_description(CHAR16 *label)
967 /* Attempt to find the image name now */
968 for (img = image_list; img; img = img->next) {
969 if (StriCmp(img->label, label) == 0) {
970 return img->description;
977 find_label(CHAR16 *label, CHAR16 *kname, CHAR16 *options, CHAR16 *initrd)
982 if (global_config.default_image == NULL) return -1;
983 img = global_config.default_image;
989 /* Attempt to find the image name now */
990 for (img = image_list; img; img = img->next) {
991 if (StriCmp(img->label, label) == 0) {
996 * when the label does not exist, we still propagate the global options
998 if (global_config.root[0]) {
999 StrCpy(options, L" root=");
1000 StrCat(options, global_config.root);
1003 if (global_config.options[0]) {
1004 StrCat(options, L" ");
1005 StrCat(options, global_config.options);
1007 if (global_config.readonly) StrCat(options, L" ro");
1009 if (global_config.initrd[0]) StrCpy(initrd, global_config.initrd);
1011 /* make sure we don't get garbage here */
1012 elilo_opt.sys_img_opts = NULL;
1016 StrCpy(kname, img->kname);
1019 * literal option overrides any other image-based or global option
1021 * In any case, the image option has priority over the global option
1023 if (img->literal == 0) {
1024 if (img->root[0] || global_config.root[0]) {
1025 StrCat(options, L"root=");
1026 StrCat(options, img->root[0] ? img->root : global_config.root);
1028 /* XXX: check max length */
1029 if (img->options[0] || global_config.options[0]) {
1030 StrCat(options, L" ");
1031 StrCat(options, img->options[0] ? img->options: global_config.options);
1033 if (img->readonly || global_config.readonly) {
1034 StrCat(options, L" ro");
1037 /* literal options replace everything */
1038 StrCpy(options, img->options);
1041 /* per image initrd has precedence over global initrd */
1043 StrCpy(initrd, img->initrd);
1044 else if (global_config.initrd[0])
1045 StrCpy(initrd, global_config.initrd);
1048 * point to architecture dependent options for this image
1050 elilo_opt.sys_img_opts = &img->sys_img_opts;
1052 DBG_PRT((L"label %s: kname=%s options=%s initrd=%s", img->label, kname, options, initrd));
1058 print_options(config_option_group_t *grp, BOOLEAN first)
1060 config_option_t *end, *p;
1065 end = grp->options+grp->nentries;
1076 str = L"%s=filename";
1079 str = L"%s=kernel_options";
1087 if (str && first == FALSE) Print(L", ");
1088 if (str) Print(str, p->name);
1098 print_config_options(VOID)
1100 Print(L"Global options supported:\n");
1102 print_options(global_option_list, TRUE);
1105 Print(L"Image options supported:\n");
1106 print_options(image_option_list, TRUE);
1112 * returns a pointer to filename used for message N (which). NULL if it does
1116 get_message_filename(INTN which)
1118 if (which < 0 || which >= MAX_MESSAGES) return NULL;
1119 return global_config.message_file[which];
1123 register_config_options(config_option_t *opt, UINTN n, config_option_group_scope_t group)
1125 config_option_group_t *newgrp, **grp;
1127 if (opt == NULL || n == 0 || (group != OPTIONS_GROUP_GLOBAL && group != OPTIONS_GROUP_IMAGE)) return -1;
1129 VERB_PRT(3, Print(L"registering %d options for group %s\n", n, group == OPTIONS_GROUP_GLOBAL ? L"global" : L"image"));
1131 newgrp = alloc(sizeof(config_option_group_t), EfiLoaderData);
1132 if (newgrp == NULL) return -1;
1134 grp = group == OPTIONS_GROUP_GLOBAL ? &global_option_list : &image_option_list;
1136 if (*grp) while ((*grp)->next) grp = &(*grp)->next;
1138 newgrp->options = opt;
1139 newgrp->next = NULL;
1140 newgrp->nentries = n;
1143 (*grp)->next = newgrp;
1151 * initialize config options: register global and per image options
1158 ret = register_config_options(global_common_options,
1159 sizeof(global_common_options)/sizeof(config_option_t),
1160 OPTIONS_GROUP_GLOBAL);
1161 if (ret == -1) return -1;
1163 ret = register_config_options(image_common_options,
1164 sizeof(image_common_options)/sizeof(config_option_t),
1165 OPTIONS_GROUP_IMAGE);
1167 current_options = global_option_list;