]> code.delx.au - refind/blob - refind/global.h
ddcc24ecc318f27111b71dfd116ea34fc6747f3e
[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-2013 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 #include "../EfiLib/GenericBdsLib.h"
54 #endif
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_MOK_TOOL (12)
73 #define TAG_FIRMWARE (13)
74 #define TAG_MEMTEST (14)
75 #define NUM_TOOLS (14)
76
77 #define NUM_SCAN_OPTIONS 10
78
79 #define DEFAULT_ICONS_DIR L"icons"
80
81 // OS bit codes; used in GlobalConfig.GraphicsOn
82 #define GRAPHICS_FOR_OSX 1
83 #define GRAPHICS_FOR_LINUX 2
84 #define GRAPHICS_FOR_ELILO 4
85 #define GRAPHICS_FOR_GRUB 8
86 #define GRAPHICS_FOR_WINDOWS 16
87
88 // Type of legacy (BIOS) boot support detected
89 #define LEGACY_TYPE_NONE 0
90 #define LEGACY_TYPE_MAC 1
91 #define LEGACY_TYPE_UEFI 2
92
93 #ifdef __MAKEWITH_GNUEFI
94 //
95 // define BBS Device Types
96 //
97 #define BBS_FLOPPY 0x01
98 #define BBS_HARDDISK 0x02
99 #define BBS_CDROM 0x03
100 #define BBS_PCMCIA 0x04
101 #define BBS_USB 0x05
102 #define BBS_EMBED_NETWORK 0x06
103 #define BBS_BEV_DEVICE 0x80
104 #define BBS_UNKNOWN 0xff
105 #endif
106
107 // BIOS Boot Specification (BBS) device types, as returned in DevicePath->Type field
108 #define DEVICE_TYPE_HW 0x01
109 #define DEVICE_TYPE_ACPI 0x02 /* returned by UEFI boot loader on USB */
110 #define DEVICE_TYPE_MESSAGING 0x03
111 #define DEVICE_TYPE_MEDIA 0x04 /* returned by EFI boot loaders on hard disk */
112 #define DEVICE_TYPE_BIOS 0x05 /* returned by legacy (BIOS) boot loaders */
113 #define DEVICE_TYPE_END 0x75 /* end of path */
114
115 // Filesystem type identifiers. Not all are yet used....
116 #define FS_TYPE_UNKNOWN 0
117 #define FS_TYPE_FAT 1
118 #define FS_TYPE_EXT2 2
119 #define FS_TYPE_EXT3 3
120 #define FS_TYPE_EXT4 4
121 #define FS_TYPE_HFSPLUS 5
122 #define FS_TYPE_REISERFS 6
123 #define FS_TYPE_BTRFS 7
124 #define FS_TYPE_ISO9660 8
125
126 // Names of binaries that can manage MOKs....
127 #define MOK_NAMES L"MokManager.efi,HashTool.efi,HashTool-signed.efi"
128 // Directories to search for these MOK-managing programs. Note that SelfDir is
129 // searched in addition to these locations....
130 #define MOK_LOCATIONS L"\\,EFI\\tools,EFI\\fedora,EFI\\redhat,EFI\\ubuntu,EFI\\suse,EFI\\opensuse,EFI\\altlinux"
131 // Directories to search for memtest86....
132 #define MEMTEST_LOCATIONS L"EFI\\tools,EFI\\tools\\memtest86,EFI\\tools\\memtest,EFI\\memtest86,EFI\\memtest"
133
134 //
135 // global definitions
136 //
137
138 // global types
139
140 typedef struct {
141 UINT8 Flags;
142 UINT8 StartCHS1;
143 UINT8 StartCHS2;
144 UINT8 StartCHS3;
145 UINT8 Type;
146 UINT8 EndCHS1;
147 UINT8 EndCHS2;
148 UINT8 EndCHS3;
149 UINT32 StartLBA;
150 UINT32 Size;
151 } MBR_PARTITION_INFO;
152
153 typedef struct {
154 EFI_DEVICE_PATH *DevicePath;
155 EFI_HANDLE DeviceHandle;
156 EFI_FILE *RootDir;
157 CHAR16 *VolName;
158 UINTN VolNumber;
159 EG_IMAGE *VolIconImage;
160 EG_IMAGE *VolBadgeImage;
161 UINTN DiskKind;
162 BOOLEAN IsAppleLegacy;
163 BOOLEAN HasBootCode;
164 CHAR16 *OSIconName;
165 CHAR16 *OSName;
166 BOOLEAN IsMbrPartition;
167 UINTN MbrPartitionIndex;
168 EFI_BLOCK_IO *BlockIO;
169 UINT64 BlockIOOffset;
170 EFI_BLOCK_IO *WholeDiskBlockIO;
171 EFI_DEVICE_PATH *WholeDiskDevicePath;
172 MBR_PARTITION_INFO *MbrPartitionTable;
173 BOOLEAN IsReadable;
174 UINT32 FSType;
175 } REFIT_VOLUME;
176
177 typedef struct _refit_menu_entry {
178 CHAR16 *Title;
179 UINTN Tag;
180 UINTN Row;
181 CHAR16 ShortcutDigit;
182 CHAR16 ShortcutLetter;
183 EG_IMAGE *Image;
184 EG_IMAGE *BadgeImage;
185 struct _refit_menu_screen *SubScreen;
186 } REFIT_MENU_ENTRY;
187
188 typedef struct _refit_menu_screen {
189 CHAR16 *Title;
190 EG_IMAGE *TitleImage;
191 UINTN InfoLineCount;
192 CHAR16 **InfoLines;
193 UINTN EntryCount; // total number of entries registered
194 REFIT_MENU_ENTRY **Entries;
195 UINTN TimeoutSeconds;
196 CHAR16 *TimeoutText;
197 CHAR16 *Hint1;
198 CHAR16 *Hint2;
199 } REFIT_MENU_SCREEN;
200
201 typedef struct {
202 REFIT_MENU_ENTRY me;
203 CHAR16 *Title;
204 CHAR16 *LoaderPath;
205 CHAR16 *VolName;
206 EFI_DEVICE_PATH *DevicePath;
207 BOOLEAN UseGraphicsMode;
208 BOOLEAN Enabled;
209 CHAR16 *LoadOptions;
210 CHAR16 *InitrdPath; // Linux stub loader only
211 CHAR8 OSType;
212 } LOADER_ENTRY;
213
214 typedef struct {
215 REFIT_MENU_ENTRY me;
216 REFIT_VOLUME *Volume;
217 #ifndef __MAKEWITH_GNUEFI
218 BDS_COMMON_OPTION *BdsOption;
219 #endif
220 CHAR16 *LoadOptions;
221 BOOLEAN Enabled;
222 } LEGACY_ENTRY;
223
224 typedef struct {
225 BOOLEAN TextOnly;
226 BOOLEAN ScanAllLinux;
227 UINTN RequestedScreenWidth;
228 UINTN RequestedScreenHeight;
229 UINTN BannerBottomEdge;
230 UINTN RequestedTextMode;
231 UINTN Timeout;
232 UINTN HideUIFlags;
233 UINTN MaxTags; // max. number of OS entries to show simultaneously in graphics mode
234 UINTN GraphicsFor;
235 UINTN LegacyType;
236 UINTN ScanDelay;
237 UINTN ScreensaverTime;
238 CHAR16 *BannerFileName;
239 EG_IMAGE *ScreenBackground;
240 CHAR16 *SelectionSmallFileName;
241 CHAR16 *SelectionBigFileName;
242 CHAR16 *DefaultSelection;
243 CHAR16 *AlsoScan;
244 CHAR16 *DontScanVolumes;
245 CHAR16 *DontScanDirs;
246 CHAR16 *DontScanFiles;
247 CHAR16 *DriverDirs;
248 CHAR16 *IconsDir;
249 UINTN ShowTools[NUM_TOOLS];
250 CHAR8 ScanFor[NUM_SCAN_OPTIONS]; // codes of types of loaders for which to scan
251 } REFIT_CONFIG;
252
253 // Global variables
254
255 extern EFI_HANDLE SelfImageHandle;
256 extern EFI_LOADED_IMAGE *SelfLoadedImage;
257 extern EFI_FILE *SelfRootDir;
258 extern EFI_FILE *SelfDir;
259 extern CHAR16 *SelfDirPath;
260
261 extern REFIT_VOLUME *SelfVolume;
262 extern REFIT_VOLUME **Volumes;
263 extern UINTN VolumesCount;
264
265 extern REFIT_CONFIG GlobalConfig;
266
267 extern EFI_GUID gEfiLegacyBootProtocolGuid;
268 extern EFI_GUID gEfiGlobalVariableGuid;
269
270 LOADER_ENTRY *InitializeLoaderEntry(IN LOADER_ENTRY *Entry);
271 REFIT_MENU_SCREEN *InitializeSubScreen(IN LOADER_ENTRY *Entry);
272 VOID GenerateSubScreen(LOADER_ENTRY *Entry, IN REFIT_VOLUME *Volume);
273 LOADER_ENTRY * MakeGenericLoaderEntry(VOID);
274 LOADER_ENTRY * AddLoaderEntry(IN CHAR16 *LoaderPath, IN CHAR16 *LoaderTitle, IN REFIT_VOLUME *Volume);
275 VOID SetLoaderDefaults(LOADER_ENTRY *Entry, CHAR16 *LoaderPath, IN REFIT_VOLUME *Volume);
276 LOADER_ENTRY * AddPreparedLoaderEntry(LOADER_ENTRY *Entry);
277
278 #endif
279
280 /* EOF */