59e7b10c5f9e62f9d92e525f7de249757da6312a
[debian/elilo] / x86_64 / config.c
1 /*
2  *  Copyright (C) 2001-2003 Hewlett-Packard Co.
3  *      Contributed by Stephane Eranian <eranian@hpl.hp.com>
4  *      Contributed by Chris Ahna <christopher.j.ahna@intel.com>
5  *
6  * This file is part of the ELILO, the EFI Linux boot loader.
7  *
8  *  ELILO is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2, or (at your option)
11  *  any later version.
12  *
13  *  ELILO is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with ELILO; see the file COPYING.  If not, write to the Free
20  *  Software Foundation, 59 Temple Place - Suite 330, Boston, MA
21  *  02111-1307, USA.
22  *
23  * Please check out the elilo.txt for complete documentation on how
24  * to use this program.
25  */
26
27 #include <efi.h>
28 #include <efilib.h>
29
30 #include "elilo.h"
31 #include "config.h"
32 #include "private.h"
33
34 typedef struct {
35         UINTN legacy_free_boot;
36         UINTN text_mode;
37 } x86_64_global_config_t;
38
39
40 #define x86_64_opt_offsetof(option)    (&((sys_img_options_t *)(0x0))->option)
41
42 static x86_64_global_config_t x86_64_gconf;
43
44 static config_option_t sysdeps_global_options[]={
45         {OPT_BOOL,      OPT_GLOBAL, L"legacy-free",     NULL,   NULL,   &x86_64_gconf.legacy_free_boot}
46 };
47
48 static config_option_t sysdeps_image_options[]={
49         {OPT_BOOL,      OPT_IMAGE_SYS, L"text-mode",    NULL,   NULL,   x86_64_opt_offsetof(text_mode)}
50 };
51
52
53 /*
54  * X86_64 operations that need to be done only once and just before 
55  * entering the main loop of the loader
56  * Return:
57  *       0 if sucessful
58  *      -1 otherwise (will abort execution)
59  */
60 INTN
61 sysdeps_preloop_actions(EFI_HANDLE dev, CHAR16 **argv, INTN argc, INTN index, EFI_HANDLE image)
62 {
63         return 0;
64 }
65         
66 #define X86_64_CMDLINE_OPTIONS  L""
67
68 CHAR16 *
69 sysdeps_get_cmdline_opts(VOID)
70 {
71         return X86_64_CMDLINE_OPTIONS;
72 }
73
74 INTN
75 sysdeps_getopt(INTN c, INTN optind, CHAR16 *optarg)
76 {
77         return -1;
78 }
79
80 VOID
81 sysdeps_print_cmdline_opts(VOID)
82 {
83 }
84
85
86 INTN
87 x86_64_use_legacy_free_boot(VOID)
88 {
89         return x86_64_gconf.legacy_free_boot ? 1 : 0;
90 }
91
92
93 INTN
94 x86_64_text_mode(VOID)
95 {
96         return (elilo_opt.sys_img_opts &&
97                 elilo_opt.sys_img_opts->text_mode == TRUE) ? 1 : 0;
98 }
99
100 INTN
101 sysdeps_register_options(VOID)
102 {
103         INTN ret;
104
105         ret = register_config_options(sysdeps_global_options, 
106                                       sizeof(sysdeps_global_options)/sizeof(config_option_t),
107                                       OPTIONS_GROUP_GLOBAL);
108         if (ret == -1 ) return ret;
109
110         ret = register_config_options(sysdeps_image_options, 
111                                       sizeof(sysdeps_image_options)/sizeof(config_option_t),
112                                       OPTIONS_GROUP_IMAGE);
113
114         return ret;
115 }