5 * Copyright (c) 2006-2009 Christoph Pfisterer
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
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
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.
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.
37 * Modifications copyright (c) 2012 Roderick W. Smith
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.
48 #ifdef __MAKEWITH_GNUEFI
52 #include "../include/tiano_includes.h"
57 #define REFIT_DEBUG (0)
59 // Tag classifications; used in various ways.
61 #define TAG_REBOOT (2)
62 #define TAG_SHUTDOWN (3)
64 #define TAG_LOADER (5)
65 #define TAG_LEGACY (6)
68 #define TAG_GPTSYNC (9)
71 #define NUM_SCAN_OPTIONS 10
73 #define DEFAULT_ICONS_DIR L"icons"
75 // OS bit codes; used in GlobalConfig.GraphicsOn
76 #define GRAPHICS_FOR_OSX 1
77 #define GRAPHICS_FOR_LINUX 2
78 #define GRAPHICS_FOR_ELILO 4
79 #define GRAPHICS_FOR_GRUB 8
80 #define GRAPHICS_FOR_WINDOWS 16
102 EFI_DEVICE_PATH
*DevicePath
;
103 EFI_HANDLE DeviceHandle
;
106 EG_IMAGE
*VolIconImage
;
107 EG_IMAGE
*VolBadgeImage
;
109 BOOLEAN IsAppleLegacy
;
113 BOOLEAN IsMbrPartition
;
114 UINTN MbrPartitionIndex
;
115 EFI_BLOCK_IO
*BlockIO
;
116 UINT64 BlockIOOffset
;
117 EFI_BLOCK_IO
*WholeDiskBlockIO
;
118 EFI_DEVICE_PATH
*WholeDiskDevicePath
;
119 MBR_PARTITION_INFO
*MbrPartitionTable
;
123 typedef struct _refit_menu_entry
{
127 CHAR16 ShortcutDigit
;
128 CHAR16 ShortcutLetter
;
130 EG_IMAGE
*BadgeImage
;
131 struct _refit_menu_screen
*SubScreen
;
134 typedef struct _refit_menu_screen
{
136 EG_IMAGE
*TitleImage
;
139 UINTN EntryCount
; // total number of entries registered
140 REFIT_MENU_ENTRY
**Entries
;
141 UINTN TimeoutSeconds
;
150 EFI_DEVICE_PATH
*DevicePath
;
151 BOOLEAN UseGraphicsMode
;
154 CHAR16
*InitrdPath
; // Linux stub loader only
160 REFIT_VOLUME
*Volume
;
167 BOOLEAN ScanAllLinux
;
168 UINTN RequestedScreenWidth
;
169 UINTN RequestedScreenHeight
;
172 UINTN MaxTags
; // max. number of OS entries to show simultaneously in graphics mode
174 CHAR16
*BannerFileName
;
175 CHAR16
*SelectionSmallFileName
;
176 CHAR16
*SelectionBigFileName
;
177 CHAR16
*DefaultSelection
;
182 UINTN ShowTools
[NUM_TOOLS
];
183 CHAR8 ScanFor
[NUM_SCAN_OPTIONS
]; // codes of types of loaders for which to scan
188 extern EFI_HANDLE SelfImageHandle
;
189 extern EFI_LOADED_IMAGE
*SelfLoadedImage
;
190 extern EFI_FILE
*SelfRootDir
;
191 extern EFI_FILE
*SelfDir
;
192 extern CHAR16
*SelfDirPath
;
194 extern REFIT_VOLUME
*SelfVolume
;
195 extern REFIT_VOLUME
**Volumes
;
196 extern UINTN VolumesCount
;
198 extern REFIT_CONFIG GlobalConfig
;
200 LOADER_ENTRY
*InitializeLoaderEntry(IN LOADER_ENTRY
*Entry
);
201 REFIT_MENU_SCREEN
*InitializeSubScreen(IN LOADER_ENTRY
*Entry
);
202 VOID
GenerateSubScreen(LOADER_ENTRY
*Entry
, IN REFIT_VOLUME
*Volume
);
203 LOADER_ENTRY
* MakeGenericLoaderEntry(VOID
);
204 LOADER_ENTRY
* AddLoaderEntry(IN CHAR16
*LoaderPath
, IN CHAR16
*LoaderTitle
, IN REFIT_VOLUME
*Volume
);
205 VOID
SetLoaderDefaults(LOADER_ENTRY
*Entry
, CHAR16
*LoaderPath
, IN REFIT_VOLUME
*Volume
);
206 LOADER_ENTRY
* AddPreparedLoaderEntry(LOADER_ENTRY
*Entry
);