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