0
|
1 /*
|
|
2 * Copyright (C) 2001-2003 Hewlett-Packard Co.
|
|
3 * Contributed by Stephane Eranian <eranian@hpl.hp.com>
|
|
4 *
|
|
5 * This file is part of the ELILO, the EFI Linux boot loader.
|
|
6 *
|
|
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)
|
|
10 * any later version.
|
|
11 *
|
|
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.
|
|
16 *
|
|
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
|
|
20 * 02111-1307, USA.
|
|
21 *
|
|
22 * Please check out the elilo.txt for complete documentation on how
|
|
23 * to use this program.
|
|
24 */
|
|
25
|
|
26 #include <efi.h>
|
|
27 #include <efilib.h>
|
|
28
|
|
29 #include "elilo.h"
|
|
30 #include "config.h"
|
|
31 #include "private.h"
|
|
32 #include "sysdeps.h"
|
|
33 #include "getopt.h"
|
|
34
|
|
35 typedef struct {
|
|
36 CHAR16 fpswa[FILENAME_MAXLEN];
|
|
37 CHAR16 cmd_fpswa[FILENAME_MAXLEN];
|
|
38 UINTN allow_relocation;
|
|
39 } ia64_global_config_t;
|
|
40
|
|
41 #define ia64_opt_offsetof(option) (&((sys_img_options_t *)(0x0))->option)
|
|
42
|
|
43 static ia64_global_config_t ia64_gconf;
|
|
44
|
|
45 /*
|
|
46 * No IA-64 specific options at this point
|
|
47 * The last entry in each table MUST be use the OPT_NULL type to terminate
|
|
48 * the chain.
|
|
49 */
|
|
50 config_option_t sysdeps_global_options[]={
|
|
51 {OPT_FILE, OPT_GLOBAL, L"fpswa", NULL, NULL, ia64_gconf.fpswa},
|
|
52 {OPT_BOOL, OPT_GLOBAL, L"relocatable", NULL, NULL, &ia64_gconf.allow_relocation},
|
|
53 };
|
|
54
|
|
55 config_option_t sysdeps_image_options[]={
|
|
56 {OPT_BOOL, OPT_IMAGE_SYS, L"relocatable", NULL, NULL, ia64_opt_offsetof(allow_relocation)},
|
|
57 };
|
|
58
|
|
59
|
|
60 /*
|
|
61 * IA-64 operations that need to be done only once and just before
|
|
62 * entering the main loop of the loader
|
|
63 * Return:
|
|
64 * 0 if sucessful
|
|
65 * -1 otherwise (will abort execution)
|
|
66 */
|
|
67 INTN
|
|
68 sysdeps_preloop_actions(EFI_HANDLE dev, CHAR16 **argv, INTN argc, INTN index, EFI_HANDLE image)
|
|
69 {
|
|
70 /*
|
|
71 * we have separate string to make sure that the command line take precedence over
|
|
72 * the config file
|
|
73 */
|
|
74 if (ia64_gconf.cmd_fpswa[0] != CHAR_NULL) {
|
|
75 check_fpswa(image, dev, ia64_gconf.cmd_fpswa);
|
|
76 } else if (ia64_gconf.fpswa[0] != CHAR_NULL)
|
|
77 check_fpswa(image, dev, ia64_gconf.fpswa);
|
|
78 else
|
|
79 check_fpswa(image, dev, NULL);
|
|
80
|
|
81 return 0;
|
|
82 }
|
|
83
|
|
84 /*
|
|
85 * Return:
|
|
86 * 1: if image or global configuration allows relocation
|
|
87 * 0: otherwise
|
|
88 *
|
|
89 * It is written has a function rather than a macro to avoid
|
|
90 * exposing config data structure to the rest of the code in ia64
|
|
91 */
|
|
92 INTN
|
|
93 ia64_can_relocate(VOID)
|
|
94 {
|
|
95 return ia64_gconf.allow_relocation == TRUE
|
|
96 || (elilo_opt.sys_img_opts && elilo_opt.sys_img_opts->allow_relocation ==TRUE) ? 1 : 0;
|
|
97 }
|
|
98
|
|
99 #define IA64_CMDLINE_OPTIONS L"rF:"
|
|
100
|
|
101 CHAR16 *
|
|
102 sysdeps_get_cmdline_opts(VOID)
|
|
103 {
|
|
104 return IA64_CMDLINE_OPTIONS;
|
|
105 }
|
|
106
|
|
107 INTN
|
|
108 sysdeps_getopt(INTN c, INTN optind, CHAR16 *optarg)
|
|
109 {
|
|
110 INTN ret = 0; /* let's be optimistic ! */
|
|
111
|
|
112 /*
|
|
113 * XXX: for now these command line options have to be global
|
|
114 */
|
|
115 switch(c) {
|
|
116 case L'r':
|
|
117 ia64_gconf.allow_relocation = 1;
|
|
118 break;
|
|
119 case L'F':
|
|
120 if (StrLen(Optarg) >= FILENAME_MAXLEN) {
|
|
121 Print(L"FPSWA filename is limited to %d characters\n", FILENAME_MAXLEN);
|
|
122 return -1;
|
|
123 }
|
|
124 StrCpy(ia64_gconf.cmd_fpswa, Optarg);
|
|
125 break;
|
|
126 default:
|
|
127 ret = -1;
|
|
128 }
|
|
129 return ret;
|
|
130 }
|
|
131
|
|
132 VOID
|
|
133 sysdeps_print_cmdline_opts(VOID)
|
|
134 {
|
|
135 Print(L"-r kernel image can be relocated if load address inexistent\n");
|
|
136 Print(L"-F file name of a specific FPSWA EFI driver to load\n");
|
|
137 }
|
|
138
|
|
139 INTN
|
|
140 sysdeps_register_options(VOID)
|
|
141 {
|
|
142 INTN ret;
|
|
143
|
|
144 ret = register_config_options(sysdeps_global_options,
|
|
145 sizeof(sysdeps_global_options)/sizeof(config_option_t),
|
|
146 OPTIONS_GROUP_GLOBAL);
|
|
147 if (ret == -1 ) return ret;
|
|
148
|
|
149 ret = register_config_options(sysdeps_image_options,
|
|
150 sizeof(sysdeps_image_options)/sizeof(config_option_t),
|
|
151 OPTIONS_GROUP_IMAGE);
|
|
152
|
|
153 return ret;
|
|
154 }
|