orphan
[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.14"
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 #ifndef UINT32_MAX
58 #define UINT32_MAX      ((UINT32)-1)
59 #endif
60
61 /*
62  * Elilo Boot modes
63  */
64 #define ELILO_LOAD_SUCCESS      0
65 #define ELILO_LOAD_ABORTED      1
66 #define ELILO_LOAD_ERROR        2
67 #define ELILO_LOAD_RETRY        3
68
69 #define ELILO_DEFAULT_TIMEOUT   ELILO_TIMEOUT_INFINITY
70 #define ELILO_TIMEOUT_INFINITY  (~0UL)
71
72 #define CMDLINE_MAXLEN          2048
73 #define PATHNAME_MAXLEN         512
74 #define FILENAME_MAXLEN         256
75 #define MAX_ARGS                256
76 /* Just pick an arbitrary number that's high enough for now :o) */
77 #define MAX_DEFAULT_CONFIGS     16
78
79 typedef struct {
80         UINT8 nothing_yet;
81 } image_opt_t;
82
83 typedef struct config_file {
84         CHAR16 fname[FILENAME_MAXLEN];
85 } config_file_t;
86
87 typedef struct {
88         /*
89          * list of options controllable from both the command line
90          * and the config file
91          */
92         UINTN alt_check;        /* always check for alternate kernel */
93         UINTN debug;            /* debug print() on */
94         UINTN delay;            /* delay before booting the image */
95         UINTN verbose;          /* verbosity level [1-5] */
96         CHAR16 initrd[FILENAME_MAXLEN];         /* name of file for initial ramdisk */
97         CHAR16 vmcode[FILENAME_MAXLEN]; /* name of file for boot time module*/
98         UINT8 delay_set;        /* mark whether or not delay was specified on cmdline */
99         UINT8 edd30_on;         /* true is EDD30 variable is TRUE */
100         UINT8 edd30_no_force;   /* don't force EDD30 variable to true */
101         /*
102          * list of options controllable from either the command line
103          * or the config file
104          */
105         UINTN prompt;           /* enter interactive mode */
106         UINTN parse_only;       /* only parses the config file */
107         UINTN timeout;          /* timeout before leaving interactive mode*/
108
109         image_opt_t img_opt;    /* architecture independent per image options*/
110
111         sys_img_options_t *sys_img_opts;        /* architecture depdendent per image options */
112
113         CHAR16 default_kernel[FILENAME_MAXLEN];
114         /* CHAR16 default_config[FILENAME_MAXLEN]; */
115         config_file_t default_configs[MAX_DEFAULT_CONFIGS];
116
117         CHAR16 config[FILENAME_MAXLEN];         /* name of config file */
118         CHAR16 chooser[FILENAME_MAXLEN];        /* image chooser to use */
119 } elilo_config_t;
120
121
122 extern elilo_config_t elilo_opt;
123
124 extern EFI_SYSTEM_TABLE *systab;
125
126 typedef struct {
127         VOID    *start_addr;
128         UINTN   pgcnt;
129         UINTN   size;
130 } memdesc_t;
131
132 typedef struct {
133         VOID *kstart;
134         VOID *kend;
135         VOID *kentry;
136 } kdesc_t;
137
138 typedef struct {
139         EFI_MEMORY_DESCRIPTOR   *md;
140         UINTN                   map_size;
141         UINTN                   desc_size;
142         UINTN                   cookie;
143         UINT32                  desc_version;
144 } mmap_desc_t;
145
146 #ifndef MAX
147 #define MAX(a,b)        ((a)>(b) ? (a) : (b))
148 #endif
149
150 #ifndef MIN
151 #define MIN(a,b)        ((a)>(b) ? (b) : (a))
152 #endif
153
154 #define VERB_PRT(n,cmd) \
155         { if (elilo_opt.verbose >= (n)) { cmd; } }
156
157
158 /* from alloc.c */
159 extern INTN alloc_init(VOID);
160 extern VOID *alloc(UINTN, EFI_MEMORY_TYPE);
161 extern VOID free(VOID *);
162 extern VOID *alloc_pages(UINTN, EFI_MEMORY_TYPE, EFI_ALLOCATE_TYPE, VOID *);
163 extern VOID free_pages(VOID *);
164 extern VOID free_all(VOID);
165 extern INTN alloc_kmem(VOID *, UINTN);
166 extern INTN alloc_kmem_anywhere(VOID **, UINTN);
167 extern VOID free_kmem(VOID);
168 extern VOID free_all_memory(VOID);
169
170 /* from util.c */
171 extern INTN read_file(UINTN fd, UINTN, CHAR8 *);
172 extern EFI_STATUS check_abort(VOID);
173 extern VOID reset_input(VOID);
174 extern INTN wait_timeout(UINTN);
175 extern INTN argify(CHAR16 *, UINTN, CHAR16 **);
176 extern VOID unargify(CHAR16 **, CHAR16 **);
177 extern void split_args(CHAR16 *, CHAR16 *, CHAR16 *);
178 extern INTN get_memmap(mmap_desc_t *);
179 extern VOID free_memmap(mmap_desc_t *);
180 extern INTN find_kernel_memory(VOID *low_addr, VOID *max_addr, UINTN alignment, VOID ** start);
181 extern VOID print_memmap(mmap_desc_t *);
182 extern VOID ascii2U(CHAR8 *, CHAR16 *, UINTN);
183 extern VOID U2ascii(CHAR16 *, CHAR8 *, UINTN);
184
185 /* from config.c (more in config.h) */
186 extern EFI_STATUS read_config(CHAR16 *);
187 extern VOID print_config_options(VOID);
188 extern INTN find_label(CHAR16 *, CHAR16 *, CHAR16 *, CHAR16 *, CHAR16 *);
189 extern VOID print_label_list(VOID);
190 extern INTN config_init(VOID);
191 extern CHAR16 *get_message_filename(INTN which);
192 extern CHAR16 *find_description(CHAR16 *label);
193 extern VOID *get_next_description(VOID *prev, CHAR16 **label, CHAR16 **description);
194 extern CHAR16 *get_config_file(VOID);
195
196 /* from initrd.c */
197 extern INTN load_file(CHAR16 *, memdesc_t *);
198
199 /* from alternate.c */
200 extern INTN alternate_kernel(CHAR16 *, UINTN);
201
202 /* from bootparams.c */
203 extern VOID *create_boot_params (CHAR16 *, memdesc_t *, memdesc_t *, UINTN *);
204 extern VOID free_boot_params(VOID *bp);
205
206 /*
207  * architecture-specific API
208  */
209
210
211 extern INTN sysdeps_create_boot_params(boot_params_t *, CHAR8 *, memdesc_t *, memdesc_t *, UINTN *);
212 extern VOID sysdeps_free_boot_params(boot_params_t *);
213 extern INTN sysdeps_init(EFI_HANDLE dev);
214 extern INTN sysdeps_initrd_get_addr(kdesc_t *, memdesc_t *);
215 extern INTN sysdeps_preloop_actions(EFI_HANDLE, CHAR16 **, INTN, INTN, EFI_HANDLE);
216 extern CHAR16 *sysdeps_get_cmdline_opts(VOID);
217 extern INTN sysdeps_getopt(INTN, INTN, CHAR16 *);
218 extern VOID sysdeps_print_cmdline_opts(VOID);
219 extern INTN sysdeps_register_options(VOID);
220 extern VOID *sysdeps_checkfix_initrd(VOID *, memdesc_t *);
221
222 #define CHAR_SLASH      L'/'
223 #define CHAR_BACKSLASH  L'\\'
224
225 #endif /* __ELILO_H__ */