Imported Debian patch 3.4-9
[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 #include <efi.h>
33
34 #include "elilo_debug.h"
35
36 #include "fileops.h"
37 #include "chooser.h"
38
39 #include "strops.h"
40
41 #include "sysdeps.h"
42
43 #define MB              (1024*1024) /* 1 megabyte */
44
45 /* Round X up/down to A, which must be an integer power of two.  */
46 #define ROUNDUP(x,a)    (((x) + (a) - 1) & ~((a) - 1))
47 #define ROUNDDOWN(x,a)  ((x) & ~((a) - 1))
48
49 /*
50  * Elilo Boot modes
51  */
52 #define ELILO_LOAD_SUCCESS      0
53 #define ELILO_LOAD_ABORTED      1
54 #define ELILO_LOAD_ERROR        2
55 #define ELILO_LOAD_RETRY        3
56
57 #define ELILO_DEFAULT_TIMEOUT   ELILO_TIMEOUT_INFINITY
58 #define ELILO_TIMEOUT_INFINITY  (~0UL)
59
60 #define CMDLINE_MAXLEN          512 /* needed by ia32 */
61 #define FILENAME_MAXLEN         256
62 #define MAX_ARGS                256
63
64 typedef struct {
65         UINT8 nothing_yet;
66 } image_opt_t;
67
68 typedef struct {
69         /*
70          * list of options controllable from both the command line
71          * and the config file
72          */
73         UINTN alt_check;        /* always check for alternate kernel */
74         UINTN debug;            /* debug print() on */
75         UINTN delay;            /* delay before booting the image */
76         UINTN verbose;          /* verbosity level [1-5] */
77         CHAR16 initrd[FILENAME_MAXLEN];         /* name of file for initial ramdisk */
78         UINT8 delay_set;        /* mark whether or not delay was specified on cmdline */
79         UINT8 edd30_on;         /* true is EDD30 variable is TRUE */
80         UINT8 edd30_no_force;   /* don't force EDD30 variable to true */
81         /*
82          * list of options controllable from either the command line
83          * or the config file
84          */
85         UINTN prompt;           /* enter interactive mode */
86         UINTN parse_only;       /* only parses the config file */
87         UINTN timeout;          /* timeout before leaving interactive mode*/
88
89         image_opt_t img_opt;    /* architecture independent per image options*/
90
91         sys_img_options_t *sys_img_opts;        /* architecture depdendent per image options */
92
93         CHAR16 default_kernel[FILENAME_MAXLEN];
94         CHAR16 default_config[FILENAME_MAXLEN];
95
96         CHAR16 config[FILENAME_MAXLEN];         /* name of config file */
97         CHAR16 chooser[FILENAME_MAXLEN];        /* image chooser to use */
98 } elilo_config_t;
99
100
101 extern elilo_config_t elilo_opt;
102
103 extern EFI_SYSTEM_TABLE *systab;
104
105 typedef struct {
106         VOID    *start_addr;
107         UINTN   pgcnt;
108 } memdesc_t;
109
110 typedef struct {
111         VOID *kstart;
112         VOID *kend;
113         VOID *kentry;
114 } kdesc_t;
115
116 typedef struct {
117         EFI_MEMORY_DESCRIPTOR   *md;
118         UINTN                   map_size;
119         UINTN                   desc_size;
120         UINTN                   cookie;
121         UINT32                  desc_version;
122 } mmap_desc_t;
123
124 #ifndef MAX
125 #define MAX(a,b)        ((a)>(b) ? (a) : (b))
126 #endif
127
128 #ifndef MIN
129 #define MIN(a,b)        ((a)>(b) ? (b) : (a))
130 #endif
131
132 #define VERB_PRT(n,cmd) \
133         { if (elilo_opt.verbose >= (n)) { cmd; } }
134
135
136 /* from alloc.c */
137 extern INTN alloc_init(VOID);
138 extern VOID *alloc(UINTN, EFI_MEMORY_TYPE);
139 extern VOID free(VOID *);
140 extern VOID *alloc_pages(UINTN, EFI_MEMORY_TYPE, EFI_ALLOCATE_TYPE, VOID *);
141 extern VOID free_pages(VOID *);
142 extern VOID free_all(VOID);
143 extern INTN alloc_kmem(VOID *, UINTN);
144 extern VOID free_kmem(VOID);
145 extern VOID free_all_memory(VOID);
146
147 /* from util.c */
148 extern INTN read_file(UINTN fd, UINTN, CHAR8 *);
149 extern EFI_STATUS check_abort(VOID);
150 extern VOID reset_input(VOID);
151 extern INTN wait_timeout(UINTN);
152 extern INTN argify(CHAR16 *, UINTN, CHAR16 **);
153 extern VOID unargify(CHAR16 **, CHAR16 **);
154 extern void split_args(CHAR16 *, CHAR16 *, CHAR16 *);
155 extern INTN get_memmap(mmap_desc_t *);
156 extern VOID free_memmap(mmap_desc_t *);
157 extern INTN find_kernel_memory(VOID *low_addr, VOID *max_addr, UINTN alignment, VOID ** start);
158 extern VOID print_memmap(mmap_desc_t *);
159 extern VOID ascii2U(CHAR8 *, CHAR16 *, UINTN);
160 extern VOID U2ascii(CHAR16 *, CHAR8 *, UINTN);
161
162 /* from config.c (more in config.h) */
163 extern EFI_STATUS read_config(CHAR16 *, INTN retry);
164 extern VOID print_config_options(VOID);
165 extern INTN find_label(CHAR16 *, CHAR16 *, CHAR16 *, CHAR16 *);
166 extern VOID print_label_list(VOID);
167 extern INTN config_init(VOID);
168 extern CHAR16 *get_message_filename(INTN which);
169 extern CHAR16 *find_description(CHAR16 *label);
170 extern VOID *get_next_description(VOID *prev, CHAR16 **label, CHAR16 **description);
171 extern CHAR16 *get_config_file(VOID);
172
173 /* from initrd.c */
174 extern INTN load_initrd(CHAR16 *, memdesc_t *);
175
176 /* from alternate.c */
177 extern INTN alternate_kernel(CHAR16 *, INTN);
178
179 /* from bootparams.c */
180 extern VOID *create_boot_params (CHAR16 *, memdesc_t *, UINTN *);
181 extern VOID free_boot_params(VOID *bp);
182
183 /*
184  * architecture-specific API
185  */
186
187
188 extern INTN sysdeps_create_boot_params(boot_params_t *, CHAR8 *, memdesc_t *, UINTN *);
189 extern VOID sysdeps_free_boot_params(boot_params_t *);
190 extern INTN sysdeps_init(EFI_HANDLE dev);
191 extern INTN sysdeps_initrd_get_addr(kdesc_t *, memdesc_t *);
192 extern INTN sysdeps_preloop_actions(EFI_HANDLE, CHAR16 **, INTN, INTN, EFI_HANDLE);
193 extern CHAR16 *sysdeps_get_cmdline_opts(VOID);
194 extern INTN sysdeps_getopt(INTN, INTN, CHAR16 *);
195 extern VOID sysdeps_print_cmdline_opts(VOID);
196 extern INTN sysdeps_register_options(VOID);
197
198 #define CHAR_SLASH      L'/'
199 #define CHAR_BACKSLASH  L'\\'
200
201 #endif /* __ELILO_H__ */