]> code.delx.au - refind/blob - refind/global.h
New support for legacy BIOS booting on PCs
[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_NON_MAC (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 //
85 // global definitions
86 //
87
88 // global types
89
90 typedef struct {
91 UINT8 Flags;
92 UINT8 StartCHS1;
93 UINT8 StartCHS2;
94 UINT8 StartCHS3;
95 UINT8 Type;
96 UINT8 EndCHS1;
97 UINT8 EndCHS2;
98 UINT8 EndCHS3;
99 UINT32 StartLBA;
100 UINT32 Size;
101 } MBR_PARTITION_INFO;
102
103 typedef struct {
104 EFI_DEVICE_PATH *DevicePath;
105 EFI_HANDLE DeviceHandle;
106 EFI_FILE *RootDir;
107 CHAR16 *VolName;
108 EG_IMAGE *VolIconImage;
109 EG_IMAGE *VolBadgeImage;
110 UINTN DiskKind;
111 BOOLEAN IsAppleLegacy;
112 BOOLEAN HasBootCode;
113 CHAR16 *OSIconName;
114 CHAR16 *OSName;
115 BOOLEAN IsMbrPartition;
116 UINTN MbrPartitionIndex;
117 EFI_BLOCK_IO *BlockIO;
118 UINT64 BlockIOOffset;
119 EFI_BLOCK_IO *WholeDiskBlockIO;
120 EFI_DEVICE_PATH *WholeDiskDevicePath;
121 MBR_PARTITION_INFO *MbrPartitionTable;
122 BOOLEAN IsReadable;
123 } REFIT_VOLUME;
124
125 typedef struct _refit_menu_entry {
126 CHAR16 *Title;
127 UINTN Tag;
128 UINTN Row;
129 CHAR16 ShortcutDigit;
130 CHAR16 ShortcutLetter;
131 EG_IMAGE *Image;
132 EG_IMAGE *BadgeImage;
133 struct _refit_menu_screen *SubScreen;
134 } REFIT_MENU_ENTRY;
135
136 typedef struct _refit_menu_screen {
137 CHAR16 *Title;
138 EG_IMAGE *TitleImage;
139 UINTN InfoLineCount;
140 CHAR16 **InfoLines;
141 UINTN EntryCount; // total number of entries registered
142 REFIT_MENU_ENTRY **Entries;
143 UINTN TimeoutSeconds;
144 CHAR16 *TimeoutText;
145 } REFIT_MENU_SCREEN;
146
147 typedef struct {
148 REFIT_MENU_ENTRY me;
149 CHAR16 *Title;
150 CHAR16 *LoaderPath;
151 CHAR16 *VolName;
152 EFI_DEVICE_PATH *DevicePath;
153 BOOLEAN UseGraphicsMode;
154 BOOLEAN Enabled;
155 CHAR16 *LoadOptions;
156 CHAR16 *InitrdPath; // Linux stub loader only
157 CHAR8 OSType;
158 } LOADER_ENTRY;
159
160 typedef struct {
161 REFIT_MENU_ENTRY me;
162 REFIT_VOLUME *Volume;
163 #ifdef __MAKEWITH_TIANO
164 BDS_COMMON_OPTION *BdsOption;
165 #endif // __MAKEWITH_TIANO
166 CHAR16 *LoadOptions;
167 BOOLEAN Enabled;
168 } LEGACY_ENTRY;
169
170 /*
171 #ifdef __MAKEWITH_TIANO
172 typedef struct {
173 REFIT_MENU_ENTRY me;
174 BDS_COMMON_OPTION *BdsOption;
175 BOOLEAN Enabled;
176 } LEGACY_ENTRY_NON_MAC;
177 #endif // __MAKEWITH_TIANO
178 */
179
180 typedef struct {
181 BOOLEAN TextOnly;
182 BOOLEAN ScanAllLinux;
183 UINTN RequestedScreenWidth;
184 UINTN RequestedScreenHeight;
185 UINTN Timeout;
186 UINTN HideUIFlags;
187 UINTN MaxTags; // max. number of OS entries to show simultaneously in graphics mode
188 UINTN GraphicsFor;
189 CHAR16 *BannerFileName;
190 CHAR16 *SelectionSmallFileName;
191 CHAR16 *SelectionBigFileName;
192 CHAR16 *DefaultSelection;
193 CHAR16 *AlsoScan;
194 CHAR16 *DontScan;
195 CHAR16 *DriverDirs;
196 CHAR16 *IconsDir;
197 UINTN ShowTools[NUM_TOOLS];
198 CHAR8 ScanFor[NUM_SCAN_OPTIONS]; // codes of types of loaders for which to scan
199 } REFIT_CONFIG;
200
201 // Global variables
202
203 extern EFI_HANDLE SelfImageHandle;
204 extern EFI_LOADED_IMAGE *SelfLoadedImage;
205 extern EFI_FILE *SelfRootDir;
206 extern EFI_FILE *SelfDir;
207 extern CHAR16 *SelfDirPath;
208
209 extern REFIT_VOLUME *SelfVolume;
210 extern REFIT_VOLUME **Volumes;
211 extern UINTN VolumesCount;
212
213 extern REFIT_CONFIG GlobalConfig;
214
215 LOADER_ENTRY *InitializeLoaderEntry(IN LOADER_ENTRY *Entry);
216 REFIT_MENU_SCREEN *InitializeSubScreen(IN LOADER_ENTRY *Entry);
217 VOID GenerateSubScreen(LOADER_ENTRY *Entry, IN REFIT_VOLUME *Volume);
218 LOADER_ENTRY * MakeGenericLoaderEntry(VOID);
219 LOADER_ENTRY * AddLoaderEntry(IN CHAR16 *LoaderPath, IN CHAR16 *LoaderTitle, IN REFIT_VOLUME *Volume);
220 VOID SetLoaderDefaults(LOADER_ENTRY *Entry, CHAR16 *LoaderPath, IN REFIT_VOLUME *Volume);
221 LOADER_ENTRY * AddPreparedLoaderEntry(LOADER_ENTRY *Entry);
222
223 #endif
224
225 /* EOF */