]> code.delx.au - refind/blob - refind/global.h
Fixed bug that caused NTFS filesystems and whole disks to be
[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-2015 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 TAG_NETBOOT (17)
78 #define NUM_TOOLS (18)
79
80 #define NUM_SCAN_OPTIONS 10
81
82 #define DEFAULT_ICONS_DIR L"icons"
83
84 // OS bit codes; used in GlobalConfig.GraphicsOn
85 #define GRAPHICS_FOR_OSX 1
86 #define GRAPHICS_FOR_LINUX 2
87 #define GRAPHICS_FOR_ELILO 4
88 #define GRAPHICS_FOR_GRUB 8
89 #define GRAPHICS_FOR_WINDOWS 16
90
91 // Load types
92 #define TYPE_EFI 1
93 #define TYPE_LEGACY 2
94
95 // Type of legacy (BIOS) boot support detected
96 #define LEGACY_TYPE_NONE 0
97 #define LEGACY_TYPE_MAC 1
98 #define LEGACY_TYPE_UEFI 2
99
100 #ifdef __MAKEWITH_GNUEFI
101 //
102 // define BBS Device Types
103 //
104 #define BBS_FLOPPY 0x01
105 #define BBS_HARDDISK 0x02
106 #define BBS_CDROM 0x03
107 #define BBS_PCMCIA 0x04
108 #define BBS_USB 0x05
109 #define BBS_EMBED_NETWORK 0x06
110 #define BBS_BEV_DEVICE 0x80
111 #define BBS_UNKNOWN 0xff
112 #endif
113
114 // BIOS Boot Specification (BBS) device types, as returned in DevicePath->Type field
115 #define DEVICE_TYPE_HW 0x01
116 #define DEVICE_TYPE_ACPI 0x02 /* returned by UEFI boot loader on USB */
117 #define DEVICE_TYPE_MESSAGING 0x03
118 #define DEVICE_TYPE_MEDIA 0x04 /* returned by EFI boot loaders on hard disk */
119 #define DEVICE_TYPE_BIOS 0x05 /* returned by legacy (BIOS) boot loaders */
120 #define DEVICE_TYPE_END 0x75 /* end of path */
121
122 // Filesystem type identifiers. Not all are yet used....
123 #define FS_TYPE_UNKNOWN 0
124 #define FS_TYPE_FAT 1
125 #define FS_TYPE_EXFAT 2
126 #define FS_TYPE_NTFS 3
127 #define FS_TYPE_EXT2 4
128 #define FS_TYPE_EXT3 5
129 #define FS_TYPE_EXT4 6
130 #define FS_TYPE_HFSPLUS 7
131 #define FS_TYPE_REISERFS 8
132 #define FS_TYPE_BTRFS 9
133 #define FS_TYPE_ISO9660 10
134
135 // How to scale banner images
136 #define BANNER_NOSCALE 0
137 #define BANNER_FILLSCREEN 1
138
139 // Sizes of the default icons; badges are 1/4 the big icon size
140 #define DEFAULT_SMALL_ICON_SIZE 48
141 #define DEFAULT_BIG_ICON_SIZE 128
142
143 // Codes for types of icon sizes; used for indexing into GlobalConfig.IconSizes[]
144 #define ICON_SIZE_BADGE 0
145 #define ICON_SIZE_SMALL 1
146 #define ICON_SIZE_BIG 2
147
148 // Names of binaries that can manage MOKs....
149 #define MOK_NAMES L"MokManager.efi,HashTool.efi,HashTool-signed.efi"
150 // Directories to search for these MOK-managing programs. Note that SelfDir is
151 // searched in addition to these locations....
152 #define MOK_LOCATIONS L"\\,EFI\\tools,EFI\\fedora,EFI\\redhat,EFI\\ubuntu,EFI\\suse,EFI\\opensuse,EFI\\altlinux"
153 // Directories to search for memtest86....
154 #define MEMTEST_LOCATIONS L"EFI\\tools,EFI\\tools\\memtest86,EFI\\tools\\memtest,EFI\\memtest86,EFI\\memtest"
155 // Files that may be Windows recovery files
156 #define WINDOWS_RECOVERY_FILES L"EFI\\Microsoft\\Boot\\LrsBootmgr.efi,Recovery:\\EFI\\BOOT\\bootx64.efi,Recovery:\\EFI\\BOOT\\bootia32.efi"
157
158 // Definitions for the "hideui" option in refind.conf
159 #define HIDEUI_FLAG_NONE (0x0000)
160 #define HIDEUI_FLAG_BANNER (0x0001)
161 #define HIDEUI_FLAG_LABEL (0x0002)
162 #define HIDEUI_FLAG_SINGLEUSER (0x0004)
163 #define HIDEUI_FLAG_HWTEST (0x0008)
164 #define HIDEUI_FLAG_ARROWS (0x0010)
165 #define HIDEUI_FLAG_HINTS (0x0020)
166 #define HIDEUI_FLAG_EDITOR (0x0040)
167 #define HIDEUI_FLAG_SAFEMODE (0x0080)
168 #define HIDEUI_FLAG_BADGES (0x0100)
169 #define HIDEUI_FLAG_ALL ((0xffff))
170
171 // Default hint text for program-launch submenus
172 #define SUBSCREEN_HINT1 L"Use arrow keys to move cursor; Enter to boot;"
173 #define SUBSCREEN_HINT2 L"Insert or F2 to edit options; Esc to return to main menu"
174 #define SUBSCREEN_HINT2_NO_EDITOR L"Esc to return to main menu"
175
176 #define NULL_GUID_VALUE { 0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };
177 #define REFIND_GUID_VALUE { 0x36D08FA7, 0xCF0B, 0x42F5, {0x8F, 0x14, 0x68, 0xDF, 0x73, 0xED, 0x37, 0x40} };
178
179 //
180 // global definitions
181 //
182
183 // global types
184
185 typedef struct {
186 UINT8 Flags;
187 UINT8 StartCHS1;
188 UINT8 StartCHS2;
189 UINT8 StartCHS3;
190 UINT8 Type;
191 UINT8 EndCHS1;
192 UINT8 EndCHS2;
193 UINT8 EndCHS3;
194 UINT32 StartLBA;
195 UINT32 Size;
196 } MBR_PARTITION_INFO;
197
198 typedef struct {
199 EFI_DEVICE_PATH *DevicePath;
200 EFI_HANDLE DeviceHandle;
201 EFI_FILE *RootDir;
202 CHAR16 *VolName;
203 CHAR16 *PartName;
204 EFI_GUID VolUuid;
205 EFI_GUID PartGuid;
206 UINTN VolNumber;
207 EG_IMAGE *VolIconImage;
208 EG_IMAGE *VolBadgeImage;
209 UINTN DiskKind;
210 BOOLEAN IsAppleLegacy;
211 BOOLEAN HasBootCode;
212 CHAR16 *OSIconName;
213 CHAR16 *OSName;
214 BOOLEAN IsMbrPartition;
215 UINTN MbrPartitionIndex;
216 EFI_BLOCK_IO *BlockIO;
217 UINT64 BlockIOOffset;
218 EFI_BLOCK_IO *WholeDiskBlockIO;
219 EFI_DEVICE_PATH *WholeDiskDevicePath;
220 MBR_PARTITION_INFO *MbrPartitionTable;
221 BOOLEAN IsReadable;
222 UINT32 FSType;
223 } REFIT_VOLUME;
224
225 typedef struct _refit_menu_entry {
226 CHAR16 *Title;
227 UINTN Tag;
228 UINTN Row;
229 CHAR16 ShortcutDigit;
230 CHAR16 ShortcutLetter;
231 EG_IMAGE *Image;
232 EG_IMAGE *BadgeImage;
233 struct _refit_menu_screen *SubScreen;
234 } REFIT_MENU_ENTRY;
235
236 typedef struct _refit_menu_screen {
237 CHAR16 *Title;
238 EG_IMAGE *TitleImage;
239 UINTN InfoLineCount;
240 CHAR16 **InfoLines;
241 UINTN EntryCount; // total number of entries registered
242 REFIT_MENU_ENTRY **Entries;
243 UINTN TimeoutSeconds;
244 CHAR16 *TimeoutText;
245 CHAR16 *Hint1;
246 CHAR16 *Hint2;
247 } REFIT_MENU_SCREEN;
248
249 typedef struct {
250 REFIT_MENU_ENTRY me;
251 CHAR16 *Title;
252 CHAR16 *LoaderPath;
253 CHAR16 *VolName;
254 EFI_DEVICE_PATH *DevicePath;
255 BOOLEAN UseGraphicsMode;
256 BOOLEAN Enabled;
257 CHAR16 *LoadOptions;
258 CHAR16 *InitrdPath; // Linux stub loader only
259 CHAR8 OSType;
260 } LOADER_ENTRY;
261
262 typedef struct {
263 REFIT_MENU_ENTRY me;
264 REFIT_VOLUME *Volume;
265 BDS_COMMON_OPTION *BdsOption;
266 CHAR16 *LoadOptions;
267 BOOLEAN Enabled;
268 } LEGACY_ENTRY;
269
270 typedef struct {
271 BOOLEAN TextOnly;
272 BOOLEAN ScanAllLinux;
273 BOOLEAN DeepLegacyScan;
274 BOOLEAN EnableAndLockVMX;
275 UINTN RequestedScreenWidth;
276 UINTN RequestedScreenHeight;
277 UINTN BannerBottomEdge;
278 UINTN RequestedTextMode;
279 UINTN Timeout;
280 UINTN HideUIFlags;
281 UINTN MaxTags; // max. number of OS entries to show simultaneously in graphics mode
282 UINTN GraphicsFor;
283 UINTN LegacyType;
284 UINTN ScanDelay;
285 UINTN ScreensaverTime;
286 UINTN IconSizes[3];
287 UINTN BannerScale;
288 CHAR16 *BannerFileName;
289 EG_IMAGE *ScreenBackground;
290 CHAR16 *ConfigFilename;
291 CHAR16 *SelectionSmallFileName;
292 CHAR16 *SelectionBigFileName;
293 CHAR16 *DefaultSelection;
294 CHAR16 *AlsoScan;
295 CHAR16 *DontScanVolumes;
296 CHAR16 *DontScanDirs;
297 CHAR16 *DontScanFiles;
298 CHAR16 *WindowsRecoveryFiles;
299 CHAR16 *DriverDirs;
300 CHAR16 *IconsDir;
301 UINTN ShowTools[NUM_TOOLS];
302 CHAR8 ScanFor[NUM_SCAN_OPTIONS]; // codes of types of loaders for which to scan
303 } REFIT_CONFIG;
304
305 // Global variables
306
307 extern EFI_HANDLE SelfImageHandle;
308 extern EFI_LOADED_IMAGE *SelfLoadedImage;
309 extern EFI_FILE *SelfRootDir;
310 extern EFI_FILE *SelfDir;
311 extern CHAR16 *SelfDirPath;
312
313 extern REFIT_VOLUME *SelfVolume;
314 extern REFIT_VOLUME **Volumes;
315 extern UINTN VolumesCount;
316
317 extern REFIT_CONFIG GlobalConfig;
318
319 extern EFI_GUID gEfiLegacyBootProtocolGuid;
320 extern EFI_GUID gEfiGlobalVariableGuid;
321
322 EFI_STATUS StartEFIImageList(IN EFI_DEVICE_PATH **DevicePaths,
323 IN CHAR16 *LoadOptions, IN UINTN LoaderType,
324 IN CHAR16 *ImageTitle, IN CHAR8 OSType,
325 OUT UINTN *ErrorInStep,
326 IN BOOLEAN Verbose,
327 IN BOOLEAN IsDriver);
328 LOADER_ENTRY *InitializeLoaderEntry(IN LOADER_ENTRY *Entry);
329 REFIT_MENU_SCREEN *InitializeSubScreen(IN LOADER_ENTRY *Entry);
330 VOID GenerateSubScreen(LOADER_ENTRY *Entry, IN REFIT_VOLUME *Volume);
331 EG_IMAGE * GetDiskBadge(IN UINTN DiskType);
332 LOADER_ENTRY * MakeGenericLoaderEntry(VOID);
333 LOADER_ENTRY * AddLoaderEntry(IN CHAR16 *LoaderPath, IN CHAR16 *LoaderTitle, IN REFIT_VOLUME *Volume);
334 VOID SetLoaderDefaults(LOADER_ENTRY *Entry, CHAR16 *LoaderPath, IN REFIT_VOLUME *Volume);
335 LOADER_ENTRY * AddPreparedLoaderEntry(LOADER_ENTRY *Entry);
336 VOID StoreLoaderName(IN CHAR16 *Name);
337
338 #endif
339
340 /* EOF */