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