Imported Debian patch 3.12-4.1
[debian/elilo] / elilo.h
1 /*
2  *  Copyright (C) 2001-2003 Hewlett-Packard Co.
3  *      Contributed by Stephane Eranian <eranian@hpl.hp.com>
4  *
5  *  Copyright (C) 2001 Silicon Graphics, Inc.
6  *      Contributed by Brent Casavant <bcasavan@sgi.com>
7  *
8  * This file is part of the ELILO, the EFI Linux boot loader.
9  *
10  *  GNU EFI 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)
13  *  any later version.
14  *
15  *  GNU EFI 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.
19  *
20  *  You should have received a copy of the GNU General Public License
21  *  along with GNU EFI; see the file COPYING.  If not, write to the Free
22  *  Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23  *  02111-1307, USA.
24  *
25  * Please check out the elilo.txt for complete documentation on how
26  * to use this program.
27  */
28
29 #ifndef __ELILO_H__
30 #define __ELILO_H__
31
32 #define ELILO_VERSION L"3.12"
33
34 #include <efi.h>
35
36 #ifdef CONFIG_ia32
37 #define PTR_FMT L"0x%x"
38 #else
39 #define PTR_FMT L"0x%lx"
40 #endif
41
42 #include "elilo_debug.h"
43
44 #include "fileops.h"
45 #include "chooser.h"
46
47 #include "strops.h"
48
49 #include "sysdeps.h"
50
51 #define MB              (1024*1024) /* 1 megabyte */
52
53 /* Round X up/down to A, which must be an integer power of two.  */
54 #define ROUNDUP(x,a)    (((x) + (a) - 1) & ~((a) - 1))
55 #define ROUNDDOWN(x,a)  ((x) & ~((a) - 1))
56
57 /*
58  * Elilo Boot modes
59  */
60 #define ELILO_LOAD_SUCCESS      0
61 #define ELILO_LOAD_ABORTED      1
62 #define ELILO_LOAD_ERROR        2
63 #define ELILO_LOAD_RETRY        3
64
65 #define ELILO_DEFAULT_TIMEOUT   ELILO_TIMEOUT_INFINITY
66 #define ELILO_TIMEOUT_INFINITY  (~0UL)
67
68 #define CMDLINE_MAXLEN          512 /* needed by ia32 */
69 #define FILENAME_MAXLEN         256
70 #define MAX_ARGS                256
71 /* Just pick an arbitrary number that's high enough for now :o) */
72 #define MAX_DEFAULT_CONFIGS     16
73
74 typedef struct {
75         UINT8 nothing_yet;
76 } image_opt_t;
77
78 typedef struct config_file {
79         CHAR16 fname[FILENAME_MAXLEN];
80 } config_file_t;
81
82 typedef struct {
83         /*
84          * list of options controllable from both the command line
85          * and the config file
86          */
87         UINTN alt_check;        /* always check for alternate kernel */
88         UINTN debug;            /* debug print() on */
89         UINTN delay;            /* delay before booting the image */
90         UINTN verbose;          /* verbosity level [1-5] */
91         CHAR16 initrd[FILENAME_MAXLEN];         /* name of file for initial ramdisk */
92         CHAR16 vmcode[FILENAME_MAXLEN]; /* name of file for boot time module*/
93         UINT8 delay_set;        /* mark whether or not delay was specified on cmdline */
94         UINT8 edd30_on;         /* true is EDD30 variable is TRUE */
95         UINT8 edd30_no_force;   /* don't force EDD30 variable to true */
96         /*
97          * list of options controllable from either the command line
98          * or the config file
99          */
100         UINTN prompt;           /* enter interactive mode */
101         UINTN parse_only;       /* only parses the config file */
102         UINTN timeout;          /* timeout before leaving interactive mode*/
103
104         image_opt_t img_opt;    /* architecture independent per image options*/
105
106         sys_img_options_t *sys_img_opts;        /* architecture depdendent per image options */
107
108         CHAR16 default_kernel[FILENAME_MAXLEN];
109         /* CHAR16 default_config[FILENAME_MAXLEN]; */
110         config_file_t default_configs[MAX_DEFAULT_CONFIGS];
111
112         CHAR16 config[FILENAME_MAXLEN];         /* name of config file */
113         CHAR16 chooser[FILENAME_MAXLEN];        /* image chooser to use */
114 } elilo_config_t;
115
116
117 extern elilo_config_t elilo_opt;
118
119 extern EFI_SYSTEM_TABLE *systab;
120
121 typedef struct {
122         VOID    *start_addr;
123         UINTN   pgcnt;
124         UINTN   size;
125 } memdesc_t;
126
127 typedef struct {
128         VOID *kstart;
129         VOID *kend;
130         VOID *kentry;
131 } kdesc_t;
132
133 typedef struct {
134         EFI_MEMORY_DESCRIPTOR   *md;
135         UINTN                   map_size;
136         UINTN                   desc_size;
137         UINTN                   cookie;
138         UINT32                  desc_version;
139 } mmap_desc_t;
140
141 #ifndef MAX
142 #define MAX(a,b)        ((a)>(b) ? (a) : (b))
143 #endif
144
145 #ifndef MIN
146 #define MIN(a,b)        ((a)>(b) ? (b) : (a))
147 #endif
148
149 #define VERB_PRT(n,cmd) \
150         { if (elilo_opt.verbose >= (n)) { cmd; } }
151
152
153 /* from alloc.c */
154 extern INTN alloc_init(VOID);
155 extern VOID *alloc(UINTN, EFI_MEMORY_TYPE);
156 extern VOID free(VOID *);
157 extern VOID *alloc_pages(UINTN, EFI_MEMORY_TYPE, EFI_ALLOCATE_TYPE, VOID *);
158 extern VOID free_pages(VOID *);
159 extern VOID free_all(VOID);
160 extern INTN alloc_kmem(VOID *, UINTN);
161 extern INTN alloc_kmem_anywhere(VOID **, UINTN);
162 extern VOID free_kmem(VOID);
163 extern VOID free_all_memory(VOID);
164
165 /* from util.c */
166 extern INTN read_file(UINTN fd, UINTN, CHAR8 *);
167 extern EFI_STATUS check_abort(VOID);
168 extern VOID reset_input(VOID);
169 extern INTN wait_timeout(UINTN);
170 extern INTN argify(CHAR16 *, UINTN, CHAR16 **);
171 extern VOID unargify(CHAR16 **, CHAR16 **);
172 extern void split_args(CHAR16 *, CHAR16 *, CHAR16 *);
173 extern INTN get_memmap(mmap_desc_t *);
174 extern VOID free_memmap(mmap_desc_t *);
175 extern INTN find_kernel_memory(VOID *low_addr, VOID *max_addr, UINTN alignment, VOID ** start);
176 extern VOID print_memmap(mmap_desc_t *);
177 extern VOID ascii2U(CHAR8 *, CHAR16 *, UINTN);
178 extern VOID U2ascii(CHAR16 *, CHAR8 *, UINTN);
179
180 /* from config.c (more in config.h) */
181 extern EFI_STATUS read_config(CHAR16 *);
182 extern VOID print_config_options(VOID);
183 extern INTN find_label(CHAR16 *, CHAR16 *, CHAR16 *, CHAR16 *, CHAR16 *);
184 extern VOID print_label_list(VOID);
185 extern INTN config_init(VOID);
186 extern CHAR16 *get_message_filename(INTN which);
187 extern CHAR16 *find_description(CHAR16 *label);
188 extern VOID *get_next_description(VOID *prev, CHAR16 **label, CHAR16 **description);
189 extern CHAR16 *get_config_file(VOID);
190
191 /* from initrd.c */
192 extern INTN load_file(CHAR16 *, memdesc_t *);
193
194 /* from alternate.c */
195 extern INTN alternate_kernel(CHAR16 *, UINTN);
196
197 /* from bootparams.c */
198 extern VOID *create_boot_params (CHAR16 *, memdesc_t *, memdesc_t *, UINTN *);
199 extern VOID free_boot_params(VOID *bp);
200
201 /*
202  * architecture-specific API
203  */
204
205
206 extern INTN sysdeps_create_boot_params(boot_params_t *, CHAR8 *, memdesc_t *, memdesc_t *, UINTN *);
207 extern VOID sysdeps_free_boot_params(boot_params_t *);
208 extern INTN sysdeps_init(EFI_HANDLE dev);
209 extern INTN sysdeps_initrd_get_addr(kdesc_t *, memdesc_t *);
210 extern INTN sysdeps_preloop_actions(EFI_HANDLE, CHAR16 **, INTN, INTN, EFI_HANDLE);
211 extern CHAR16 *sysdeps_get_cmdline_opts(VOID);
212 extern INTN sysdeps_getopt(INTN, INTN, CHAR16 *);
213 extern VOID sysdeps_print_cmdline_opts(VOID);
214 extern INTN sysdeps_register_options(VOID);
215
216 #define CHAR_SLASH      L'/'
217 #define CHAR_BACKSLASH  L'\\'
218
219 #endif /* __ELILO_H__ */