]> code.delx.au - refind/blob - refind/global.h
BIOS-mode boot support now works when compiled with GNU-EFI
[refind] / refind / global.h
1 /*
2 * refit/global.h
3 * Global header file
4 *
5 * Copyright (c) 2006-2009 Christoph Pfisterer
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the
18 * distribution.
19 *
20 * * Neither the name of Christoph Pfisterer nor the names of the
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 */
36 /*
37 * Modifications copyright (c) 2012-2014 Roderick W. Smith
38 *
39 * Modifications distributed under the terms of the GNU General Public
40 * License (GPL) version 3 (GPLv3), a copy of which must be distributed
41 * with this source code or binaries made from it.
42 *
43 */
44
45 #ifndef __GLOBAL_H_
46 #define __GLOBAL_H_
47
48 #ifdef __MAKEWITH_GNUEFI
49 #include <efi.h>
50 #include <efilib.h>
51 #else
52 #include "../include/tiano_includes.h"
53 #endif
54 #include "../EfiLib/GenericBdsLib.h"
55
56 #include "libeg.h"
57
58 #define REFIT_DEBUG (0)
59
60 // Tag classifications; used in various ways.
61 #define TAG_ABOUT (1)
62 #define TAG_REBOOT (2)
63 #define TAG_SHUTDOWN (3)
64 #define TAG_TOOL (4)
65 #define TAG_LOADER (5)
66 #define TAG_LEGACY (6)
67 #define TAG_EXIT (7)
68 #define TAG_SHELL (8)
69 #define TAG_GPTSYNC (9)
70 #define TAG_LEGACY_UEFI (10)
71 #define TAG_APPLE_RECOVERY (11)
72 #define TAG_WINDOWS_RECOVERY (12)
73 #define TAG_MOK_TOOL (13)
74 #define TAG_FIRMWARE (14)
75 #define TAG_MEMTEST (15)
76 #define TAG_GDISK (16)
77 #define NUM_TOOLS (17)
78
79 #define NUM_SCAN_OPTIONS 10
80
81 #define DEFAULT_ICONS_DIR L"icons"
82
83 // OS bit codes; used in GlobalConfig.GraphicsOn
84 #define GRAPHICS_FOR_OSX 1
85 #define GRAPHICS_FOR_LINUX 2
86 #define GRAPHICS_FOR_ELILO 4
87 #define GRAPHICS_FOR_GRUB 8
88 #define GRAPHICS_FOR_WINDOWS 16
89
90 // Type of legacy (BIOS) boot support detected
91 #define LEGACY_TYPE_NONE 0
92 #define LEGACY_TYPE_MAC 1
93 #define LEGACY_TYPE_UEFI 2
94
95 #ifdef __MAKEWITH_GNUEFI
96 //
97 // define BBS Device Types
98 //
99 #define BBS_FLOPPY 0x01
100 #define BBS_HARDDISK 0x02
101 #define BBS_CDROM 0x03
102 #define BBS_PCMCIA 0x04
103 #define BBS_USB 0x05
104 #define BBS_EMBED_NETWORK 0x06
105 #define BBS_BEV_DEVICE 0x80
106 #define BBS_UNKNOWN 0xff
107 #endif
108
109 // BIOS Boot Specification (BBS) device types, as returned in DevicePath->Type field
110 #define DEVICE_TYPE_HW 0x01
111 #define DEVICE_TYPE_ACPI 0x02 /* returned by UEFI boot loader on USB */
112 #define DEVICE_TYPE_MESSAGING 0x03
113 #define DEVICE_TYPE_MEDIA 0x04 /* returned by EFI boot loaders on hard disk */
114 #define DEVICE_TYPE_BIOS 0x05 /* returned by legacy (BIOS) boot loaders */
115 #define DEVICE_TYPE_END 0x75 /* end of path */
116
117 // Filesystem type identifiers. Not all are yet used....
118 #define FS_TYPE_UNKNOWN 0
119 #define FS_TYPE_FAT 1
120 #define FS_TYPE_EXT2 2
121 #define FS_TYPE_EXT3 3
122 #define FS_TYPE_EXT4 4
123 #define FS_TYPE_HFSPLUS 5
124 #define FS_TYPE_REISERFS 6
125 #define FS_TYPE_BTRFS 7
126 #define FS_TYPE_ISO9660 8
127
128 // How to scale banner images
129 #define BANNER_NOSCALE 0
130 #define BANNER_FILLSCREEN 1
131
132 // Sizes of the default icons; badges are 1/4 the big icon size
133 #define DEFAULT_SMALL_ICON_SIZE 48
134 #define DEFAULT_BIG_ICON_SIZE 128
135
136 // Codes for types of icon sizes; used for indexing into GlobalConfig.IconSizes[]
137 #define ICON_SIZE_BADGE 0
138 #define ICON_SIZE_SMALL 1
139 #define ICON_SIZE_BIG 2
140
141 // Names of binaries that can manage MOKs....
142 #define MOK_NAMES L"MokManager.efi,HashTool.efi,HashTool-signed.efi"
143 // Directories to search for these MOK-managing programs. Note that SelfDir is
144 // searched in addition to these locations....
145 #define MOK_LOCATIONS L"\\,EFI\\tools,EFI\\fedora,EFI\\redhat,EFI\\ubuntu,EFI\\suse,EFI\\opensuse,EFI\\altlinux"
146 // Directories to search for memtest86....
147 #define MEMTEST_LOCATIONS L"EFI\\tools,EFI\\tools\\memtest86,EFI\\tools\\memtest,EFI\\memtest86,EFI\\memtest"
148 // Files that may be Windows recovery files
149 #define WINDOWS_RECOVERY_FILES L"EFI\\Microsoft\\Boot\\LrsBootmgr.efi"
150
151 #define NULL_GUID_VALUE { 00000000, 0000, 0000, {0000, 0000, 0000, 0000} };
152
153 //
154 // global definitions
155 //
156
157 // global types
158
159 typedef struct {
160 UINT8 Flags;
161 UINT8 StartCHS1;
162 UINT8 StartCHS2;
163 UINT8 StartCHS3;
164 UINT8 Type;
165 UINT8 EndCHS1;
166 UINT8 EndCHS2;
167 UINT8 EndCHS3;
168 UINT32 StartLBA;
169 UINT32 Size;
170 } MBR_PARTITION_INFO;
171
172 typedef struct {
173 EFI_DEVICE_PATH *DevicePath;
174 EFI_HANDLE DeviceHandle;
175 EFI_FILE *RootDir;
176 CHAR16 *VolName;
177 CHAR16 *PartName;
178 EFI_GUID VolUuid;
179 EFI_GUID PartGuid;
180 UINTN VolNumber;
181 EG_IMAGE *VolIconImage;
182 EG_IMAGE *VolBadgeImage;
183 UINTN DiskKind;
184 BOOLEAN IsAppleLegacy;
185 BOOLEAN HasBootCode;
186 CHAR16 *OSIconName;
187 CHAR16 *OSName;
188 BOOLEAN IsMbrPartition;
189 UINTN MbrPartitionIndex;
190 EFI_BLOCK_IO *BlockIO;
191 UINT64 BlockIOOffset;
192 EFI_BLOCK_IO *WholeDiskBlockIO;
193 EFI_DEVICE_PATH *WholeDiskDevicePath;
194 MBR_PARTITION_INFO *MbrPartitionTable;
195 BOOLEAN IsReadable;
196 UINT32 FSType;
197 } REFIT_VOLUME;
198
199 typedef struct _refit_menu_entry {
200 CHAR16 *Title;
201 UINTN Tag;
202 UINTN Row;
203 CHAR16 ShortcutDigit;
204 CHAR16 ShortcutLetter;
205 EG_IMAGE *Image;
206 EG_IMAGE *BadgeImage;
207 struct _refit_menu_screen *SubScreen;
208 } REFIT_MENU_ENTRY;
209
210 typedef struct _refit_menu_screen {
211 CHAR16 *Title;
212 EG_IMAGE *TitleImage;
213 UINTN InfoLineCount;
214 CHAR16 **InfoLines;
215 UINTN EntryCount; // total number of entries registered
216 REFIT_MENU_ENTRY **Entries;
217 UINTN TimeoutSeconds;
218 CHAR16 *TimeoutText;
219 CHAR16 *Hint1;
220 CHAR16 *Hint2;
221 } REFIT_MENU_SCREEN;
222
223 typedef struct {
224 REFIT_MENU_ENTRY me;
225 CHAR16 *Title;
226 CHAR16 *LoaderPath;
227 CHAR16 *VolName;
228 EFI_DEVICE_PATH *DevicePath;
229 BOOLEAN UseGraphicsMode;
230 BOOLEAN Enabled;
231 CHAR16 *LoadOptions;
232 CHAR16 *InitrdPath; // Linux stub loader only
233 CHAR8 OSType;
234 } LOADER_ENTRY;
235
236 typedef struct {
237 REFIT_MENU_ENTRY me;
238 REFIT_VOLUME *Volume;
239 //#ifndef __MAKEWITH_GNUEFI
240 BDS_COMMON_OPTION *BdsOption;
241 //#endif
242 CHAR16 *LoadOptions;
243 BOOLEAN Enabled;
244 } LEGACY_ENTRY;
245
246 typedef struct {
247 BOOLEAN TextOnly;
248 BOOLEAN ScanAllLinux;
249 UINTN RequestedScreenWidth;
250 UINTN RequestedScreenHeight;
251 UINTN BannerBottomEdge;
252 UINTN RequestedTextMode;
253 UINTN Timeout;
254 UINTN HideUIFlags;
255 UINTN MaxTags; // max. number of OS entries to show simultaneously in graphics mode
256 UINTN GraphicsFor;
257 UINTN LegacyType;
258 UINTN ScanDelay;
259 UINTN ScreensaverTime;
260 UINTN IconSizes[3];
261 UINTN BannerScale;
262 CHAR16 *BannerFileName;
263 EG_IMAGE *ScreenBackground;
264 CHAR16 *ConfigFilename;
265 CHAR16 *SelectionSmallFileName;
266 CHAR16 *SelectionBigFileName;
267 CHAR16 *DefaultSelection;
268 CHAR16 *AlsoScan;
269 CHAR16 *DontScanVolumes;
270 CHAR16 *DontScanDirs;
271 CHAR16 *DontScanFiles;
272 CHAR16 *WindowsRecoveryFiles;
273 CHAR16 *DriverDirs;
274 CHAR16 *IconsDir;
275 UINTN ShowTools[NUM_TOOLS];
276 CHAR8 ScanFor[NUM_SCAN_OPTIONS]; // codes of types of loaders for which to scan
277 } REFIT_CONFIG;
278
279 // Global variables
280
281 extern EFI_HANDLE SelfImageHandle;
282 extern EFI_LOADED_IMAGE *SelfLoadedImage;
283 extern EFI_FILE *SelfRootDir;
284 extern EFI_FILE *SelfDir;
285 extern CHAR16 *SelfDirPath;
286
287 extern REFIT_VOLUME *SelfVolume;
288 extern REFIT_VOLUME **Volumes;
289 extern UINTN VolumesCount;
290
291 extern REFIT_CONFIG GlobalConfig;
292
293 extern EFI_GUID gEfiLegacyBootProtocolGuid;
294 extern EFI_GUID gEfiGlobalVariableGuid;
295
296 LOADER_ENTRY *InitializeLoaderEntry(IN LOADER_ENTRY *Entry);
297 REFIT_MENU_SCREEN *InitializeSubScreen(IN LOADER_ENTRY *Entry);
298 VOID GenerateSubScreen(LOADER_ENTRY *Entry, IN REFIT_VOLUME *Volume);
299 LOADER_ENTRY * MakeGenericLoaderEntry(VOID);
300 LOADER_ENTRY * AddLoaderEntry(IN CHAR16 *LoaderPath, IN CHAR16 *LoaderTitle, IN REFIT_VOLUME *Volume);
301 VOID SetLoaderDefaults(LOADER_ENTRY *Entry, CHAR16 *LoaderPath, IN REFIT_VOLUME *Volume);
302 LOADER_ENTRY * AddPreparedLoaderEntry(LOADER_ENTRY *Entry);
303
304 #endif
305
306 /* EOF */