From 7228158b62daa4a506d7fdd9e27942843e4b19e7 Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Fri, 5 Jan 2024 17:24:44 +0100 Subject: [PATCH] added patches from https://patches.ubuntu.com/doh/r/refit/extracted/ to build refit.efi added icons and default configuration file [release 0.14-2mamba;Wed Jul 11 2012] --- README.md | 2 + refit-0.14-disable_EFI110_features.patch | 81 +++ refit-0.14-gptsync_64bit_fix.patch | 31 + refit-0.14-gptsync_nom_nom_nom_newline.patch | 25 + refit-0.14-gptsync_uefi_call_wrapper.patch | 77 +++ refit-0.14-libeg_uefi_call_wrapper.patch | 167 +++++ refit-0.14-refit_uefi_call_wrapper.patch | 627 +++++++++++++++++++ refit.spec | 125 ++++ 8 files changed, 1135 insertions(+) create mode 100644 refit-0.14-disable_EFI110_features.patch create mode 100644 refit-0.14-gptsync_64bit_fix.patch create mode 100644 refit-0.14-gptsync_nom_nom_nom_newline.patch create mode 100644 refit-0.14-gptsync_uefi_call_wrapper.patch create mode 100644 refit-0.14-libeg_uefi_call_wrapper.patch create mode 100644 refit-0.14-refit_uefi_call_wrapper.patch create mode 100644 refit.spec diff --git a/README.md b/README.md index 33d37b9..42d0022 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # refit +rEFIt is a boot menu and maintenance toolkit for EFI-based machines like the Intel Macs. You can use it to boot multiple operating systems easily, including triple-boot setups with Boot Camp. It also provides an easy way to enter and explore the EFI pre-boot environment. + diff --git a/refit-0.14-disable_EFI110_features.patch b/refit-0.14-disable_EFI110_features.patch new file mode 100644 index 0000000..b02f63b --- /dev/null +++ b/refit-0.14-disable_EFI110_features.patch @@ -0,0 +1,81 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 40_disable_EFI110_features.dpatch by +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Disable features that require EFI110, which gnu-efi doesn't support. + +@DPATCH@ +diff -urNad refit-0.13~/refit/main.c refit-0.13/refit/main.c +--- refit-0.13~/refit/main.c 2009-03-27 22:15:12.858281766 +0100 ++++ refit-0.13/refit/main.c 2009-03-27 22:15:13.167307923 +0100 +@@ -61,14 +61,18 @@ + + #define TAG_ABOUT (1) + #define TAG_RESET (2) ++#ifdef DEBIAN_ENABLE_EFI110 + #define TAG_SHUTDOWN (3) ++#endif /* DEBIAN_ENABLE_EFI110 */ + #define TAG_TOOL (4) + #define TAG_LOADER (5) + #define TAG_LEGACY (6) + + static REFIT_MENU_ENTRY MenuEntryAbout = { L"About rEFIt", TAG_ABOUT, 1, 0, 'A', NULL, NULL, NULL }; + static REFIT_MENU_ENTRY MenuEntryReset = { L"Restart Computer", TAG_RESET, 1, 0, 'R', NULL, NULL, NULL }; ++#ifdef DEBIAN_ENABLE_EFI110 + static REFIT_MENU_ENTRY MenuEntryShutdown = { L"Shut Down Computer", TAG_SHUTDOWN, 1, 0, 'U', NULL, NULL, NULL }; ++#endif /* DEBIAN_ENABLE_EFI110 */ + static REFIT_MENU_ENTRY MenuEntryReturn = { L"Return to Main Menu", TAG_RETURN, 0, 0, 0, NULL, NULL, NULL }; + + static REFIT_MENU_SCREEN MainMenu = { L"Main Menu", NULL, 0, NULL, 0, NULL, 0, L"Automatic boot" }; +@@ -884,6 +888,8 @@ + } + } + ++ ++#ifdef DEBIAN_ENABLE_EFI110 + // + // pre-boot driver functions + // +@@ -995,6 +1001,7 @@ + // connect all devices + ConnectAllDriversToAllControllers(); + } ++#endif /* DEBIAN_ENABLE_EFI110 */ + + // + // main entry point +@@ -1031,7 +1038,9 @@ + + // further bootstrap (now with config available) + SetupScreen(); ++#ifdef DEBIAN_ENABLE_EFI110 + LoadDrivers(); ++#endif /* DEBIAN_ENABLE_EFI110 */ + ScanVolumes(); + DebugPause(); + +@@ -1050,8 +1059,10 @@ + AddMenuEntry(&MainMenu, &MenuEntryAbout); + } + if (!(GlobalConfig.HideUIFlags & HIDEUI_FLAG_FUNCS) || MainMenu.EntryCount == 0) { ++#ifdef DEBIAN_ENABLE_EFI110 + MenuEntryShutdown.Image = BuiltinIcon(BUILTIN_ICON_FUNC_SHUTDOWN); + AddMenuEntry(&MainMenu, &MenuEntryShutdown); ++#endif /* DEBIAN_ENABLE_EFI110 */ + MenuEntryReset.Image = BuiltinIcon(BUILTIN_ICON_FUNC_RESET); + AddMenuEntry(&MainMenu, &MenuEntryReset); + } +@@ -1078,11 +1089,13 @@ + MainLoopRunning = FALSE; // just in case we get this far + break; + ++#ifdef DEBIAN_ENABLE_EFI110 + case TAG_SHUTDOWN: // Shut Down + TerminateScreen(); + RT->ResetSystem(EfiResetShutdown, EFI_SUCCESS, 0, NULL); + MainLoopRunning = FALSE; // just in case we get this far + break; ++#endif /* DEBIAN_ENABLE_EFI110 */ + + case TAG_ABOUT: // About rEFIt + AboutRefit(); diff --git a/refit-0.14-gptsync_64bit_fix.patch b/refit-0.14-gptsync_64bit_fix.patch new file mode 100644 index 0000000..cf44ebb --- /dev/null +++ b/refit-0.14-gptsync_64bit_fix.patch @@ -0,0 +1,31 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 01_gptsync_64bit_fix.dpatch by +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Fix type issues on 64bit platforms. Causes runtime failure. + +@DPATCH@ +diff -urNad refit-src-0.11~/gptsync/gptsync.h refit-src-0.11/gptsync/gptsync.h +--- refit-src-0.11~/gptsync/gptsync.h 2007-06-12 06:44:17.000000000 +0200 ++++ refit-src-0.11/gptsync/gptsync.h 2008-05-21 22:06:45.071831818 +0200 +@@ -77,7 +77,7 @@ + typedef unsigned int UINTN; + typedef unsigned char UINT8; + typedef unsigned short UINT16; +-typedef unsigned long UINT32; ++typedef unsigned int UINT32; + typedef unsigned long long UINT64; + typedef void VOID; + +diff -urNad refit-src-0.11~/gptsync/lib.c refit-src-0.11/gptsync/lib.c +--- refit-src-0.11~/gptsync/lib.c 2007-04-05 06:58:35.000000000 +0200 ++++ refit-src-0.11/gptsync/lib.c 2008-05-21 22:06:45.071831818 +0200 +@@ -245,7 +245,7 @@ + Print(L" No GPT partition table present!\n"); + return 0; + } +- if (header->spec_revision != 0x00010000UL) { ++ if (header->spec_revision != 0x00010000) { + Print(L" Warning: Unknown GPT spec revision 0x%08x\n", header->spec_revision); + } + if ((512 % header->entry_size) > 0 || header->entry_size > 512) { diff --git a/refit-0.14-gptsync_nom_nom_nom_newline.patch b/refit-0.14-gptsync_nom_nom_nom_newline.patch new file mode 100644 index 0000000..1c0e6a6 --- /dev/null +++ b/refit-0.14-gptsync_nom_nom_nom_newline.patch @@ -0,0 +1,25 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 04_gptsync_nom_nom_nom_newline.dpatch by +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: When prompting for user input, consume characters up to the +## DP: newline character; avoids leaving characters behind that end +## DP: up being consumed by the shell after gptsync terminates. + +@DPATCH@ +diff -urNad refit-src-0.11~/gptsync/os_unix.c refit-src-0.11/gptsync/os_unix.c +--- refit-src-0.11~/gptsync/os_unix.c 2006-11-28 04:26:27.000000000 +0100 ++++ refit-src-0.11/gptsync/os_unix.c 2008-05-21 22:06:54.885831483 +0200 +@@ -150,7 +150,11 @@ + printf("No\n"); + *bool_out = FALSE; + } +- ++ ++ /* Consume everything up to and including newline */ ++ while (getchar() != '\n') ++ ; ++ + return 0; + } + diff --git a/refit-0.14-gptsync_uefi_call_wrapper.patch b/refit-0.14-gptsync_uefi_call_wrapper.patch new file mode 100644 index 0000000..594de43 --- /dev/null +++ b/refit-0.14-gptsync_uefi_call_wrapper.patch @@ -0,0 +1,77 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 41_gptsync_uefi_call_wrapper.dpatch by +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Wrap EFI API calls with uefi_call_wrapper(), mandatory for GNU EFI +## DP: especially on x86_64. + +@DPATCH@ +diff -urNad refit-src-0.11~/gptsync/os_efi.c refit-src-0.11/gptsync/os_efi.c +--- refit-src-0.11~/gptsync/os_efi.c 2006-05-12 21:00:09.000000000 +0200 ++++ refit-src-0.11/gptsync/os_efi.c 2008-05-21 22:20:28.422831977 +0200 +@@ -48,7 +48,7 @@ + { + EFI_STATUS Status; + +- Status = BlockIO->ReadBlocks(BlockIO, BlockIO->Media->MediaId, lba, 512, buffer); ++ Status = uefi_call_wrapper(BlockIO->ReadBlocks, 5, BlockIO, BlockIO->Media->MediaId, lba, 512, buffer); + if (EFI_ERROR(Status)) { + // TODO: report error + return 1; +@@ -60,7 +60,7 @@ + { + EFI_STATUS Status; + +- Status = BlockIO->WriteBlocks(BlockIO, BlockIO->Media->MediaId, lba, 512, buffer); ++ Status = uefi_call_wrapper(BlockIO->WriteBlocks, 5, BlockIO, BlockIO->Media->MediaId, lba, 512, buffer); + if (EFI_ERROR(Status)) { + // TODO: report error + return 1; +@@ -80,7 +80,7 @@ + + GotKeyStrokes = FALSE; + for (;;) { +- Status = ST->ConIn->ReadKeyStroke(ST->ConIn, &Key); ++ Status = uefi_call_wrapper(ST->ConIn->ReadKeyStroke, 2, ST->ConIn, &Key); + if (Status == EFI_SUCCESS) { + GotKeyStrokes = TRUE; + continue; +@@ -97,11 +97,11 @@ + Print(L"\n* Hit any key to continue *"); + + if (ReadAllKeyStrokes()) { // remove buffered key strokes +- BS->Stall(5000000); // 5 seconds delay ++ uefi_call_wrapper(BS->Stall, 1, 5000000); // 5 seconds delay + ReadAllKeyStrokes(); // empty the buffer again + } + +- BS->WaitForEvent(1, &ST->ConIn->WaitForKey, &Index); ++ uefi_call_wrapper(BS->WaitForEvent, 3, 1, &ST->ConIn->WaitForKey, &Index); + ReadAllKeyStrokes(); // empty the buffer to protect the menu + + Print(L"\n"); +@@ -116,12 +116,12 @@ + Print(prompt); + + if (ReadAllKeyStrokes()) { // remove buffered key strokes +- BS->Stall(500000); // 0.5 seconds delay ++ uefi_call_wrapper(BS->Stall, 1, 500000); // 0.5 seconds delay + ReadAllKeyStrokes(); // empty the buffer again + } + +- BS->WaitForEvent(1, &ST->ConIn->WaitForKey, &Index); +- Status = ST->ConIn->ReadKeyStroke(ST->ConIn, &Key); ++ uefi_call_wrapper(BS->WaitForEvent, 3, 1, &ST->ConIn->WaitForKey, &Index); ++ Status = uefi_call_wrapper(ST->ConIn->ReadKeyStroke, 2, ST->ConIn, &Key); + if (EFI_ERROR(Status)) + return 1; + +@@ -188,7 +188,7 @@ + if (!Usable) + continue; + +- Status = BS->HandleProtocol(DeviceHandle, &BlockIoProtocol, (VOID **) &BlockIO); ++ Status = uefi_call_wrapper(BS->HandleProtocol, 3, DeviceHandle, &BlockIoProtocol, (VOID **) &BlockIO); + if (EFI_ERROR(Status)) { + // TODO: report error + BlockIO = NULL; diff --git a/refit-0.14-libeg_uefi_call_wrapper.patch b/refit-0.14-libeg_uefi_call_wrapper.patch new file mode 100644 index 0000000..5c0364c --- /dev/null +++ b/refit-0.14-libeg_uefi_call_wrapper.patch @@ -0,0 +1,167 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 43_libeg_uefi_call_wrapper.dpatch by +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Wrap EFI API calls with uefi_call_wrapper(), mandatory for GNU EFI +## DP: especially on x86_64. + +@DPATCH@ +diff -urNad refit-0.12~/libeg/image.c refit-0.12/libeg/image.c +--- refit-0.12~/libeg/image.c 2008-10-23 18:35:42.000000000 +0200 ++++ refit-0.12/libeg/image.c 2008-10-23 18:36:02.603613917 +0200 +@@ -108,13 +108,13 @@ + UINTN BufferSize; + UINT8 *Buffer; + +- Status = BaseDir->Open(BaseDir, &FileHandle, FileName, EFI_FILE_MODE_READ, 0); ++ Status = uefi_call_wrapper(BaseDir->Open, 5, BaseDir, &FileHandle, FileName, EFI_FILE_MODE_READ, 0); + if (EFI_ERROR(Status)) + return Status; + + FileInfo = LibFileInfo(FileHandle); + if (FileInfo == NULL) { +- FileHandle->Close(FileHandle); ++ uefi_call_wrapper(FileHandle->Close, 1, FileHandle); + return EFI_NOT_FOUND; + } + ReadSize = FileInfo->FileSize; +@@ -125,12 +125,12 @@ + BufferSize = (UINTN)ReadSize; // was limited to 1 GB above, so this is safe + Buffer = (UINT8 *) AllocatePool(BufferSize); + if (Buffer == NULL) { +- FileHandle->Close(FileHandle); ++ uefi_call_wrapper(FileHandle->Close, 1, FileHandle); + return EFI_OUT_OF_RESOURCES; + } + +- Status = FileHandle->Read(FileHandle, &BufferSize, Buffer); +- FileHandle->Close(FileHandle); ++ Status = uefi_call_wrapper(FileHandle->Read, 3, FileHandle, &BufferSize, Buffer); ++ uefi_call_wrapper(FileHandle->Close, 1, FileHandle); + if (EFI_ERROR(Status)) { + FreePool(Buffer); + return Status; +@@ -172,14 +172,14 @@ + return Status; + } + +- Status = BaseDir->Open(BaseDir, &FileHandle, FileName, ++ Status = uefi_call_wrapper(BaseDir->Open, 5, BaseDir, &FileHandle, FileName, + EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, 0); + if (EFI_ERROR(Status)) + return Status; + + BufferSize = FileDataLength; +- Status = FileHandle->Write(FileHandle, &BufferSize, FileData); +- FileHandle->Close(FileHandle); ++ Status = uefi_call_wrapper(FileHandle->Write, 3, FileHandle, &BufferSize, FileData); ++ uefi_call_wrapper(FileHandle->Close, 1, FileHandle); + + return Status; + } +diff -urNad refit-0.12~/libeg/screen.c refit-0.12/libeg/screen.c +--- refit-0.12~/libeg/screen.c 2008-10-23 18:35:42.000000000 +0200 ++++ refit-0.12/libeg/screen.c 2008-10-23 18:36:47.797628379 +0200 +@@ -37,7 +37,7 @@ + #include "libegint.h" + + #include +-#include ++/* #include */ + #include + + // Console defines and variables +@@ -84,7 +84,7 @@ + egScreenHeight = GraphicsOutput->Mode->Info->VerticalResolution; + egHasGraphics = TRUE; + } else if (UgaDraw != NULL) { +- Status = UgaDraw->GetMode(UgaDraw, &UGAWidth, &UGAHeight, &UGADepth, &UGARefreshRate); ++ Status = uefi_call_wrapper(UgaDraw->GetMode, 5, UgaDraw, &UGAWidth, &UGAHeight, &UGADepth, &UGARefreshRate); + if (EFI_ERROR(Status)) { + UgaDraw = NULL; // graphics not available + } else { +@@ -130,7 +130,7 @@ + EFI_CONSOLE_CONTROL_SCREEN_MODE CurrentMode; + + if (ConsoleControl != NULL) { +- ConsoleControl->GetMode(ConsoleControl, &CurrentMode, NULL, NULL); ++ uefi_call_wrapper(ConsoleControl->GetMode, 4, ConsoleControl, &CurrentMode, NULL, NULL); + return (CurrentMode == EfiConsoleControlScreenGraphics) ? TRUE : FALSE; + } + +@@ -143,12 +143,12 @@ + EFI_CONSOLE_CONTROL_SCREEN_MODE NewMode; + + if (ConsoleControl != NULL) { +- ConsoleControl->GetMode(ConsoleControl, &CurrentMode, NULL, NULL); ++ uefi_call_wrapper(ConsoleControl->GetMode, 4, ConsoleControl, &CurrentMode, NULL, NULL); + + NewMode = Enable ? EfiConsoleControlScreenGraphics + : EfiConsoleControlScreenText; + if (CurrentMode != NewMode) +- ConsoleControl->SetMode(ConsoleControl, NewMode); ++ uefi_call_wrapper(ConsoleControl->SetMode, 2, ConsoleControl, NewMode); + } + } + +@@ -172,10 +172,10 @@ + // EFI_GRAPHICS_OUTPUT_BLT_PIXEL and EFI_UGA_PIXEL have the same + // layout, and the header from TianoCore actually defines them + // to be the same type. +- GraphicsOutput->Blt(GraphicsOutput, (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)&FillColor, EfiBltVideoFill, ++ uefi_call_wrapper(GraphicsOutput->Blt, 10, GraphicsOutput, (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)&FillColor, EfiBltVideoFill, + 0, 0, 0, 0, egScreenWidth, egScreenHeight, 0); + } else if (UgaDraw != NULL) { +- UgaDraw->Blt(UgaDraw, &FillColor, EfiUgaVideoFill, ++ uefi_call_wrapper(UgaDraw->Blt, 10, UgaDraw, &FillColor, EfiUgaVideoFill, + 0, 0, 0, 0, egScreenWidth, egScreenHeight, 0); + } + } +@@ -191,10 +191,10 @@ + } + + if (GraphicsOutput != NULL) { +- GraphicsOutput->Blt(GraphicsOutput, (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)Image->PixelData, EfiBltBufferToVideo, ++ uefi_call_wrapper(GraphicsOutput->Blt, 10, GraphicsOutput, (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)Image->PixelData, EfiBltBufferToVideo, + 0, 0, ScreenPosX, ScreenPosY, Image->Width, Image->Height, 0); + } else if (UgaDraw != NULL) { +- UgaDraw->Blt(UgaDraw, (EFI_UGA_PIXEL *)Image->PixelData, EfiUgaBltBufferToVideo, ++ uefi_call_wrapper(UgaDraw->Blt, 10, UgaDraw, (EFI_UGA_PIXEL *)Image->PixelData, EfiUgaBltBufferToVideo, + 0, 0, ScreenPosX, ScreenPosY, Image->Width, Image->Height, 0); + } + } +@@ -217,10 +217,10 @@ + } + + if (GraphicsOutput != NULL) { +- GraphicsOutput->Blt(GraphicsOutput, (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)Image->PixelData, EfiBltBufferToVideo, ++ uefi_call_wrapper(GraphicsOutput->Blt, 10, GraphicsOutput, (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)Image->PixelData, EfiBltBufferToVideo, + AreaPosX, AreaPosY, ScreenPosX, ScreenPosY, AreaWidth, AreaHeight, Image->Width * 4); + } else if (UgaDraw != NULL) { +- UgaDraw->Blt(UgaDraw, (EFI_UGA_PIXEL *)Image->PixelData, EfiUgaBltBufferToVideo, ++ uefi_call_wrapper(UgaDraw->Blt, 10, UgaDraw, (EFI_UGA_PIXEL *)Image->PixelData, EfiUgaBltBufferToVideo, + AreaPosX, AreaPosY, ScreenPosX, ScreenPosY, AreaWidth, AreaHeight, Image->Width * 4); + } + } +@@ -249,10 +249,10 @@ + + // get full screen image + if (GraphicsOutput != NULL) { +- GraphicsOutput->Blt(GraphicsOutput, (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)Image->PixelData, EfiBltVideoToBltBuffer, ++ uefi_call_wrapper(GraphicsOutput->Blt, 10, GraphicsOutput, (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)Image->PixelData, EfiBltVideoToBltBuffer, + 0, 0, 0, 0, Image->Width, Image->Height, 0); + } else if (UgaDraw != NULL) { +- UgaDraw->Blt(UgaDraw, (EFI_UGA_PIXEL *)Image->PixelData, EfiUgaVideoToBltBuffer, ++ uefi_call_wrapper(UgaDraw->Blt, 10, UgaDraw, (EFI_UGA_PIXEL *)Image->PixelData, EfiUgaVideoToBltBuffer, + 0, 0, 0, 0, Image->Width, Image->Height, 0); + } + +@@ -277,7 +277,7 @@ + // DEBUG: switch to text mode + bailout_wait: + egSetGraphicsModeEnabled(FALSE); +- BS->WaitForEvent(1, &ST->ConIn->WaitForKey, &Index); ++ uefi_call_wrapper(BS->WaitForEvent, 3, 1, &ST->ConIn->WaitForKey, &Index); + } + + /* EOF */ diff --git a/refit-0.14-refit_uefi_call_wrapper.patch b/refit-0.14-refit_uefi_call_wrapper.patch new file mode 100644 index 0000000..3b8df1b --- /dev/null +++ b/refit-0.14-refit_uefi_call_wrapper.patch @@ -0,0 +1,627 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 42_refit_uefi_call_wrapper.dpatch by +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Wrap EFI API calls with uefi_call_wrapper(), mandatory for GNU EFI +## DP: especially on x86_64. + +@DPATCH@ +diff -urNad refit-0.13~/refit/config.c refit-0.13/refit/config.c +--- refit-0.13~/refit/config.c 2008-02-17 20:00:50.000000000 +0100 ++++ refit-0.13/refit/config.c 2009-03-27 22:21:26.238308071 +0100 +@@ -64,14 +64,14 @@ + File->BufferSize = 0; + + // read the file, allocating a buffer on the woy +- Status = BaseDir->Open(BaseDir, &FileHandle, FileName, EFI_FILE_MODE_READ, 0); ++ Status = uefi_call_wrapper(BaseDir->Open, 5, BaseDir, &FileHandle, FileName, EFI_FILE_MODE_READ, 0); + if (CheckError(Status, L"while loading the configuration file")) + return Status; + + FileInfo = LibFileInfo(FileHandle); + if (FileInfo == NULL) { + // TODO: print and register the error +- FileHandle->Close(FileHandle); ++ uefi_call_wrapper(FileHandle->Close, 1, FileHandle); + return EFI_LOAD_ERROR; + } + ReadSize = FileInfo->FileSize; +@@ -81,14 +81,14 @@ + + File->BufferSize = (UINTN)ReadSize; // was limited to a few K before, so this is safe + File->Buffer = AllocatePool(File->BufferSize); +- Status = FileHandle->Read(FileHandle, &File->BufferSize, File->Buffer); ++ Status = uefi_call_wrapper(FileHandle->Read, 3, FileHandle, &File->BufferSize, File->Buffer); + if (CheckError(Status, L"while loading the configuration file")) { + FreePool(File->Buffer); + File->Buffer = NULL; +- FileHandle->Close(FileHandle); ++ uefi_call_wrapper(FileHandle->Close, 1, FileHandle); + return Status; + } +- Status = FileHandle->Close(FileHandle); ++ Status = uefi_call_wrapper(FileHandle->Close, 1, FileHandle); + + // setup for reading + File->Current8Ptr = (CHAR8 *)File->Buffer; +diff -urNad refit-0.13~/refit/lib.c refit-0.13/refit/lib.c +--- refit-0.13~/refit/lib.c 2009-03-22 19:18:56.000000000 +0100 ++++ refit-0.13/refit/lib.c 2009-03-27 22:21:26.238308071 +0100 +@@ -67,7 +67,7 @@ + UINTN i; + + SelfImageHandle = ImageHandle; +- Status = BS->HandleProtocol(SelfImageHandle, &LoadedImageProtocol, (VOID **) &SelfLoadedImage); ++ Status = uefi_call_wrapper(BS->HandleProtocol, 3, SelfImageHandle, &LoadedImageProtocol, (VOID **) &SelfLoadedImage); + if (CheckFatalError(Status, L"while getting a LoadedImageProtocol handle")) + return EFI_LOAD_ERROR; + +@@ -105,12 +105,12 @@ + UninitVolumes(); + + if (SelfDir != NULL) { +- SelfDir->Close(SelfDir); ++ uefi_call_wrapper(SelfDir->Close, 1, SelfDir); + SelfDir = NULL; + } + + if (SelfRootDir != NULL) { +- SelfRootDir->Close(SelfRootDir); ++ uefi_call_wrapper(SelfRootDir->Close, 1, SelfRootDir); + SelfRootDir = NULL; + } + } +@@ -141,7 +141,7 @@ + } + } + +- Status = SelfRootDir->Open(SelfRootDir, &SelfDir, SelfDirPath, EFI_FILE_MODE_READ, 0); ++ Status = uefi_call_wrapper(SelfRootDir->Open, 5, SelfRootDir, &SelfDir, SelfDirPath, EFI_FILE_MODE_READ, 0); + if (CheckFatalError(Status, L"while opening our installation directory")) + return EFI_LOAD_ERROR; + +@@ -233,11 +233,11 @@ + for (HandleIndex = 0; HandleIndex < HandleCount && PathCount < MaxPaths; HandleIndex++) { + Handle = Handles[HandleIndex]; + +- Status = BS->HandleProtocol(Handle, &LoadedImageProtocol, (VOID **) &LoadedImage); ++ Status = uefi_call_wrapper(BS->HandleProtocol, 3, Handle, &LoadedImageProtocol, (VOID **) &LoadedImage); + if (EFI_ERROR(Status)) + continue; // This can only happen if the firmware scewed up, ignore it. + +- Status = BS->HandleProtocol(LoadedImage->DeviceHandle, &DevicePathProtocol, (VOID **) &DevicePath); ++ Status = uefi_call_wrapper(BS->HandleProtocol, 3, LoadedImage->DeviceHandle, &DevicePathProtocol, (VOID **) &DevicePath); + if (EFI_ERROR(Status)) + continue; // This happens, ignore it. + +@@ -293,8 +293,9 @@ + return; // our buffer is too small... + + // look at the boot sector (this is used for both hard disks and El Torito images!) +- Status = Volume->BlockIO->ReadBlocks(Volume->BlockIO, Volume->BlockIO->Media->MediaId, +- Volume->BlockIOOffset, 2048, SectorBuffer); ++ Status = uefi_call_wrapper(Volume->BlockIO->ReadBlocks, 5, ++ Volume->BlockIO, Volume->BlockIO->Media->MediaId, ++ Volume->BlockIOOffset, 2048, SectorBuffer); + if (!EFI_ERROR(Status)) { + + if (*((UINT16 *)(SectorBuffer + 510)) == 0xaa55 && SectorBuffer[0] != 0) { +@@ -445,7 +446,7 @@ + Volume->DiskKind = DISK_KIND_INTERNAL; // default + + // get block i/o +- Status = BS->HandleProtocol(Volume->DeviceHandle, &BlockIoProtocol, (VOID **) &(Volume->BlockIO)); ++ Status = uefi_call_wrapper(BS->HandleProtocol, 3, Volume->DeviceHandle, &BlockIoProtocol, (VOID **) &(Volume->BlockIO)); + if (EFI_ERROR(Status)) { + Volume->BlockIO = NULL; + Print(L"Warning: Can't get BlockIO protocol.\n"); +@@ -492,7 +493,7 @@ + // get the handle for that path + RemainingDevicePath = DiskDevicePath; + //Print(L" * looking at %s\n", DevicePathToStr(RemainingDevicePath)); +- Status = BS->LocateDevicePath(&BlockIoProtocol, &RemainingDevicePath, &WholeDiskHandle); ++ Status = uefi_call_wrapper(BS->LocateDevicePath, 3, &BlockIoProtocol, &RemainingDevicePath, &WholeDiskHandle); + //Print(L" * remaining: %s\n", DevicePathToStr(RemainingDevicePath)); + FreePool(DiskDevicePath); + +@@ -500,13 +501,13 @@ + //Print(L" - original handle: %08x - disk handle: %08x\n", (UINT32)DeviceHandle, (UINT32)WholeDiskHandle); + + // get the device path for later +- Status = BS->HandleProtocol(WholeDiskHandle, &DevicePathProtocol, (VOID **) &DiskDevicePath); ++ Status = uefi_call_wrapper(BS->HandleProtocol, 3, WholeDiskHandle, &DevicePathProtocol, (VOID **) &DiskDevicePath); + if (!EFI_ERROR(Status)) { + Volume->WholeDiskDevicePath = DuplicateDevicePath(DiskDevicePath); + } + + // look at the BlockIO protocol +- Status = BS->HandleProtocol(WholeDiskHandle, &BlockIoProtocol, (VOID **) &Volume->WholeDiskBlockIO); ++ Status = uefi_call_wrapper(BS->HandleProtocol, 3, WholeDiskHandle, &BlockIoProtocol, (VOID **) &Volume->WholeDiskBlockIO); + if (!EFI_ERROR(Status)) { + + // check the media block size +@@ -579,9 +580,10 @@ + + for (ExtCurrent = ExtBase; ExtCurrent; ExtCurrent = NextExtCurrent) { + // read current EMBR +- Status = WholeDiskVolume->BlockIO->ReadBlocks(WholeDiskVolume->BlockIO, +- WholeDiskVolume->BlockIO->Media->MediaId, +- ExtCurrent, 512, SectorBuffer); ++ Status = uefi_call_wrapper(WholeDiskVolume->BlockIO->ReadBlocks, 5, ++ WholeDiskVolume->BlockIO, ++ WholeDiskVolume->BlockIO->Media->MediaId, ++ ExtCurrent, 512, SectorBuffer); + if (EFI_ERROR(Status)) + break; + if (*((UINT16 *)(SectorBuffer + 510)) != 0xaa55) +@@ -703,12 +705,14 @@ + continue; + + // compare boot sector read through offset vs. directly +- Status = Volume->BlockIO->ReadBlocks(Volume->BlockIO, Volume->BlockIO->Media->MediaId, +- Volume->BlockIOOffset, 512, SectorBuffer1); ++ Status = uefi_call_wrapper(Volume->BlockIO->ReadBlocks, 5, ++ Volume->BlockIO, Volume->BlockIO->Media->MediaId, ++ Volume->BlockIOOffset, 512, SectorBuffer1); + if (EFI_ERROR(Status)) + break; +- Status = Volume->WholeDiskBlockIO->ReadBlocks(Volume->WholeDiskBlockIO, Volume->WholeDiskBlockIO->Media->MediaId, +- MbrTable[PartitionIndex].StartLBA, 512, SectorBuffer2); ++ Status = uefi_call_wrapper(Volume->WholeDiskBlockIO->ReadBlocks, 5, ++ Volume->WholeDiskBlockIO, Volume->WholeDiskBlockIO->Media->MediaId, ++ MbrTable[PartitionIndex].StartLBA, 512, SectorBuffer2); + if (EFI_ERROR(Status)) + break; + if (CompareMem(SectorBuffer1, SectorBuffer2, 512) != 0) +@@ -745,7 +749,7 @@ + Volume = Volumes[VolumeIndex]; + + if (Volume->RootDir != NULL) { +- Volume->RootDir->Close(Volume->RootDir); ++ uefi_call_wrapper(Volume->RootDir->Close, 1, Volume->RootDir); + Volume->RootDir = NULL; + } + +@@ -769,7 +773,7 @@ + if (Volume->DevicePath != NULL) { + // get the handle for that path + RemainingDevicePath = Volume->DevicePath; +- Status = BS->LocateDevicePath(&BlockIoProtocol, &RemainingDevicePath, &DeviceHandle); ++ Status = uefi_call_wrapper(BS->LocateDevicePath, 3, &BlockIoProtocol, &RemainingDevicePath, &DeviceHandle); + + if (!EFI_ERROR(Status)) { + Volume->DeviceHandle = DeviceHandle; +@@ -784,11 +788,11 @@ + if (Volume->WholeDiskDevicePath != NULL) { + // get the handle for that path + RemainingDevicePath = Volume->WholeDiskDevicePath; +- Status = BS->LocateDevicePath(&BlockIoProtocol, &RemainingDevicePath, &WholeDiskHandle); ++ Status = uefi_call_wrapper(BS->LocateDevicePath, 3, &BlockIoProtocol, &RemainingDevicePath, &WholeDiskHandle); + + if (!EFI_ERROR(Status)) { + // get the BlockIO protocol +- Status = BS->HandleProtocol(WholeDiskHandle, &BlockIoProtocol, (VOID **) &Volume->WholeDiskBlockIO); ++ Status = uefi_call_wrapper(BS->HandleProtocol, 3, WholeDiskHandle, &BlockIoProtocol, (VOID **) &Volume->WholeDiskBlockIO); + if (EFI_ERROR(Status)) { + Volume->WholeDiskBlockIO = NULL; + CheckError(Status, L"from HandleProtocol"); +@@ -808,9 +812,9 @@ + EFI_STATUS Status; + EFI_FILE *TestFile; + +- Status = BaseDir->Open(BaseDir, &TestFile, RelativePath, EFI_FILE_MODE_READ, 0); ++ Status = uefi_call_wrapper(BaseDir->Open, 5, BaseDir, &TestFile, RelativePath, EFI_FILE_MODE_READ, 0); + if (Status == EFI_SUCCESS) { +- TestFile->Close(TestFile); ++ uefi_call_wrapper(TestFile->Close, 1, TestFile); + return TRUE; + } + return FALSE; +@@ -835,7 +839,7 @@ + LastBufferSize = BufferSize = 256; + Buffer = AllocatePool(BufferSize); + for (IterCount = 0; ; IterCount++) { +- Status = Directory->Read(Directory, &BufferSize, Buffer); ++ Status = uefi_call_wrapper(Directory->Read, 3, Directory, &BufferSize, Buffer); + if (Status != EFI_BUFFER_TOO_SMALL || IterCount >= 4) + break; + if (BufferSize <= LastBufferSize) { +@@ -884,7 +888,7 @@ + DirIter->DirHandle = BaseDir; + DirIter->CloseDirHandle = FALSE; + } else { +- DirIter->LastStatus = BaseDir->Open(BaseDir, &(DirIter->DirHandle), RelativePath, EFI_FILE_MODE_READ, 0); ++ DirIter->LastStatus = uefi_call_wrapper(BaseDir->Open, 5, BaseDir, &(DirIter->DirHandle), RelativePath, EFI_FILE_MODE_READ, 0); + DirIter->CloseDirHandle = EFI_ERROR(DirIter->LastStatus) ? FALSE : TRUE; + } + DirIter->LastFileInfo = NULL; +@@ -928,7 +932,7 @@ + DirIter->LastFileInfo = NULL; + } + if (DirIter->CloseDirHandle) +- DirIter->DirHandle->Close(DirIter->DirHandle); ++ uefi_call_wrapper(DirIter->DirHandle->Close, 1, DirIter->DirHandle); + return DirIter->LastStatus; + } + +diff -urNad refit-0.13~/refit/main.c refit-0.13/refit/main.c +--- refit-0.13~/refit/main.c 2009-03-27 22:21:25.975281346 +0100 ++++ refit-0.13/refit/main.c 2009-03-27 22:21:26.242306973 +0100 +@@ -129,7 +129,7 @@ + // load the image into memory + ReturnStatus = Status = EFI_NOT_FOUND; // in case the list is empty + for (DevicePathIndex = 0; DevicePaths[DevicePathIndex] != NULL; DevicePathIndex++) { +- ReturnStatus = Status = BS->LoadImage(FALSE, SelfImageHandle, DevicePaths[DevicePathIndex], NULL, 0, &ChildImageHandle); ++ ReturnStatus = Status = uefi_call_wrapper(BS->LoadImage, 6, FALSE, SelfImageHandle, DevicePaths[DevicePathIndex], NULL, 0, &ChildImageHandle); + if (ReturnStatus != EFI_NOT_FOUND) + break; + } +@@ -142,7 +142,7 @@ + + // set load options + if (LoadOptions != NULL) { +- ReturnStatus = Status = BS->HandleProtocol(ChildImageHandle, &LoadedImageProtocol, (VOID **) &ChildLoadedImage); ++ ReturnStatus = Status = uefi_call_wrapper(BS->HandleProtocol, 3, ChildImageHandle, &LoadedImageProtocol, (VOID **) &ChildLoadedImage); + if (CheckError(Status, L"while getting a LoadedImageProtocol handle")) { + if (ErrorInStep != NULL) + *ErrorInStep = 2; +@@ -166,7 +166,7 @@ + + // turn control over to the image + // TODO: (optionally) re-enable the EFI watchdog timer! +- ReturnStatus = Status = BS->StartImage(ChildImageHandle, NULL, NULL); ++ ReturnStatus = Status = uefi_call_wrapper(BS->StartImage, 3, ChildImageHandle, NULL, NULL); + // control returns here when the child image calls Exit() + SPrint(ErrorInfo, 255, L"returned from %s", ImageTitle); + if (CheckError(Status, ErrorInfo)) { +@@ -179,7 +179,7 @@ + + bailout_unload: + // unload the image, we don't care if it works or not... +- Status = BS->UnloadImage(ChildImageHandle); ++ Status = uefi_call_wrapper(BS->UnloadImage, 1, ChildImageHandle); + bailout: + if (FullLoadOptions != NULL) + FreePool(FullLoadOptions); +@@ -530,7 +530,7 @@ + BOOLEAN HaveBootCode; + + // read MBR +- Status = BlockIO->ReadBlocks(BlockIO, BlockIO->Media->MediaId, 0, 512, SectorBuffer); ++ Status = uefi_call_wrapper(BlockIO->ReadBlocks, 5, BlockIO, BlockIO->Media->MediaId, 0, 512, SectorBuffer); + if (EFI_ERROR(Status)) + return Status; + if (*((UINT16 *)(SectorBuffer + 510)) != 0xaa55) +@@ -566,7 +566,7 @@ + } + + // write MBR +- Status = BlockIO->WriteBlocks(BlockIO, BlockIO->Media->MediaId, 0, 512, SectorBuffer); ++ Status = uefi_call_wrapper(BlockIO->WriteBlocks, 5, BlockIO, BlockIO->Media->MediaId, 0, 512, SectorBuffer); + if (EFI_ERROR(Status)) + return Status; + +@@ -576,7 +576,7 @@ + // NOTE: ExtBase was set above while looking at the MBR table + for (ExtCurrent = ExtBase; ExtCurrent; ExtCurrent = NextExtCurrent) { + // read current EMBR +- Status = BlockIO->ReadBlocks(BlockIO, BlockIO->Media->MediaId, ExtCurrent, 512, SectorBuffer); ++ Status = uefi_call_wrapper(BlockIO->ReadBlocks, 5, BlockIO, BlockIO->Media->MediaId, ExtCurrent, 512, SectorBuffer); + if (EFI_ERROR(Status)) + return Status; + if (*((UINT16 *)(SectorBuffer + 510)) != 0xaa55) +@@ -603,7 +603,7 @@ + } + + // write current EMBR +- Status = BlockIO->WriteBlocks(BlockIO, BlockIO->Media->MediaId, ExtCurrent, 512, SectorBuffer); ++ Status = uefi_call_wrapper(BlockIO->WriteBlocks, 5, BlockIO, BlockIO->Media->MediaId, ExtCurrent, 512, SectorBuffer); + if (EFI_ERROR(Status)) + return Status; + +@@ -965,10 +965,11 @@ + + if (!Parent) { + if (HandleType[Index] & EFI_HANDLE_TYPE_DEVICE_HANDLE) { +- Status = BS->ConnectController(AllHandleBuffer[Index], +- NULL, +- NULL, +- TRUE); ++ Status = uefi_call_wrapper(BS->ConnectController, 4, ++ AllHandleBuffer[Index], ++ NULL, ++ NULL, ++ TRUE); + } + } + } +@@ -1031,7 +1032,7 @@ + MainMenu.TimeoutSeconds = GlobalConfig.Timeout; + + // disable EFI watchdog timer +- BS->SetWatchdogTimer(0x0000, 0x0000, 0x0000, NULL); ++ uefi_call_wrapper(BS->SetWatchdogTimer, 4, 0x0000, 0x0000, 0x0000, NULL); + + // further bootstrap (now with config available) + SetupScreen(); +@@ -1082,14 +1083,14 @@ + + case TAG_RESET: // Restart + TerminateScreen(); +- RT->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL); ++ uefi_call_wrapper(RT->ResetSystem, 4, EfiResetCold, EFI_SUCCESS, 0, NULL); + MainLoopRunning = FALSE; // just in case we get this far + break; + + #ifdef DEBIAN_ENABLE_EFI110 + case TAG_SHUTDOWN: // Shut Down + TerminateScreen(); +- RT->ResetSystem(EfiResetShutdown, EFI_SUCCESS, 0, NULL); ++ uefi_call_wrapper(RT->ResetSystem, 4, EfiResetShutdown, EFI_SUCCESS, 0, NULL); + MainLoopRunning = FALSE; // just in case we get this far + break; + #endif /* DEBIAN_ENABLE_EFI110 */ +@@ -1115,7 +1116,7 @@ + + // If we end up here, things have gone wrong. Try to reboot, and if that + // fails, go into an endless loop. +- RT->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL); ++ uefi_call_wrapper(RT->ResetSystem, 4, EfiResetCold, EFI_SUCCESS, 0, NULL); + EndlessIdleLoop(); + + return EFI_SUCCESS; +diff -urNad refit-0.13~/refit/menu.c refit-0.13/refit/menu.c +--- refit-0.13~/refit/menu.c 2006-09-03 16:39:29.000000000 +0200 ++++ refit-0.13/refit/menu.c 2009-03-27 22:21:26.242306973 +0100 +@@ -327,17 +327,17 @@ + } + + // read key press (and wait for it if applicable) +- Status = ST->ConIn->ReadKeyStroke(ST->ConIn, &key); ++ Status = uefi_call_wrapper(ST->ConIn->ReadKeyStroke, 2, ST->ConIn, &key); + if (Status == EFI_NOT_READY) { + if (HaveTimeout && TimeoutCountdown == 0) { + // timeout expired + MenuExit = MENU_EXIT_TIMEOUT; + break; + } else if (HaveTimeout) { +- BS->Stall(100000); ++ uefi_call_wrapper(BS->Stall, 1, 100000); + TimeoutCountdown--; + } else +- BS->WaitForEvent(1, &ST->ConIn->WaitForKey, &index); ++ uefi_call_wrapper(BS->WaitForEvent, 3, 1, &ST->ConIn->WaitForKey, &index); + continue; + } + if (HaveTimeout) { +@@ -458,10 +458,10 @@ + // initial painting + BeginTextScreen(Screen->Title); + if (Screen->InfoLineCount > 0) { +- ST->ConOut->SetAttribute(ST->ConOut, ATTR_BASIC); ++ uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, ATTR_BASIC); + for (i = 0; i < (INTN)Screen->InfoLineCount; i++) { +- ST->ConOut->SetCursorPosition(ST->ConOut, 3, 4 + i); +- ST->ConOut->OutputString(ST->ConOut, Screen->InfoLines[i]); ++ uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, 3, 4 + i); ++ uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, Screen->InfoLines[i]); + } + } + +@@ -478,50 +478,50 @@ + // paint the whole screen (initially and after scrolling) + for (i = 0; i <= State->MaxIndex; i++) { + if (i >= State->FirstVisible && i <= State->LastVisible) { +- ST->ConOut->SetCursorPosition(ST->ConOut, 2, MenuPosY + (i - State->FirstVisible)); ++ uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, 2, MenuPosY + (i - State->FirstVisible)); + if (i == State->CurrentSelection) +- ST->ConOut->SetAttribute(ST->ConOut, ATTR_CHOICE_CURRENT); ++ uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, ATTR_CHOICE_CURRENT); + else +- ST->ConOut->SetAttribute(ST->ConOut, ATTR_CHOICE_BASIC); +- ST->ConOut->OutputString(ST->ConOut, DisplayStrings[i]); ++ uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, ATTR_CHOICE_BASIC); ++ uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, DisplayStrings[i]); + } + } + // scrolling indicators +- ST->ConOut->SetAttribute(ST->ConOut, ATTR_SCROLLARROW); +- ST->ConOut->SetCursorPosition(ST->ConOut, 0, MenuPosY); ++ uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, ATTR_SCROLLARROW); ++ uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, 0, MenuPosY); + if (State->FirstVisible > 0) +- ST->ConOut->OutputString(ST->ConOut, ArrowUp); ++ uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, ArrowUp); + else +- ST->ConOut->OutputString(ST->ConOut, L" "); +- ST->ConOut->SetCursorPosition(ST->ConOut, 0, MenuPosY + State->MaxVisible); ++ uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, L" "); ++ uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, 0, MenuPosY + State->MaxVisible); + if (State->LastVisible < State->MaxIndex) +- ST->ConOut->OutputString(ST->ConOut, ArrowDown); ++ uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, ArrowDown); + else +- ST->ConOut->OutputString(ST->ConOut, L" "); ++ uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, L" "); + break; + + case MENU_FUNCTION_PAINT_SELECTION: + // redraw selection cursor +- ST->ConOut->SetCursorPosition(ST->ConOut, 2, MenuPosY + (State->LastSelection - State->FirstVisible)); +- ST->ConOut->SetAttribute(ST->ConOut, ATTR_CHOICE_BASIC); +- ST->ConOut->OutputString(ST->ConOut, DisplayStrings[State->LastSelection]); +- ST->ConOut->SetCursorPosition(ST->ConOut, 2, MenuPosY + (State->CurrentSelection - State->FirstVisible)); +- ST->ConOut->SetAttribute(ST->ConOut, ATTR_CHOICE_CURRENT); +- ST->ConOut->OutputString(ST->ConOut, DisplayStrings[State->CurrentSelection]); ++ uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, 2, MenuPosY + (State->LastSelection - State->FirstVisible)); ++ uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, ATTR_CHOICE_BASIC); ++ uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, DisplayStrings[State->LastSelection]); ++ uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, 2, MenuPosY + (State->CurrentSelection - State->FirstVisible)); ++ uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, ATTR_CHOICE_CURRENT); ++ uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, DisplayStrings[State->CurrentSelection]); + break; + + case MENU_FUNCTION_PAINT_TIMEOUT: + if (ParamText[0] == 0) { + // clear message +- ST->ConOut->SetAttribute(ST->ConOut, ATTR_BASIC); +- ST->ConOut->SetCursorPosition(ST->ConOut, 0, ConHeight - 1); +- ST->ConOut->OutputString(ST->ConOut, BlankLine + 1); ++ uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, ATTR_BASIC); ++ uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, 0, ConHeight - 1); ++ uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, BlankLine + 1); + } else { + // paint or update message +- ST->ConOut->SetAttribute(ST->ConOut, ATTR_ERROR); +- ST->ConOut->SetCursorPosition(ST->ConOut, 3, ConHeight - 1); ++ uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, ATTR_ERROR); ++ uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, 3, ConHeight - 1); + TimeoutMessage = PoolPrint(L"%s ", ParamText); +- ST->ConOut->OutputString(ST->ConOut, TimeoutMessage); ++ uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, TimeoutMessage); + FreePool(TimeoutMessage); + } + break; +@@ -612,6 +612,7 @@ + EntriesPosX, EntriesPosY + i * TEXT_LINE_HEIGHT); + } + // TODO: account for scrolling ++ // TODO: uefi_call_wrapper() if this code gets enabled someday + /* + for (i = 0; i <= State->MaxIndex; i++) { + if (i >= State->FirstVisible && i <= State->LastVisible) { +@@ -645,6 +646,7 @@ + DrawMenuText(Screen->Entries[State->CurrentSelection]->Title, MenuWidth, + EntriesPosX, EntriesPosY + State->CurrentSelection * TEXT_LINE_HEIGHT); + // TODO: account for scrolling ++ // TODO: uefi_call_wrapper() if this code gets enabled someday + /* + ST->ConOut->SetCursorPosition(ST->ConOut, 2, 4 + (State->LastSelection - State->FirstVisible)); + ST->ConOut->SetAttribute(ST->ConOut, ATTR_CHOICE_BASIC); +diff -urNad refit-0.13~/refit/screen.c refit-0.13/refit/screen.c +--- refit-0.13~/refit/screen.c 2008-02-17 20:00:50.000000000 +0100 ++++ refit-0.13/refit/screen.c 2009-03-27 22:21:26.242306973 +0100 +@@ -85,10 +85,10 @@ + GraphicsScreenDirty = TRUE; + + // disable cursor +- ST->ConOut->EnableCursor(ST->ConOut, FALSE); ++ uefi_call_wrapper(ST->ConOut->EnableCursor, 2, ST->ConOut, FALSE); + + // get size of text console +- if (ST->ConOut->QueryMode(ST->ConOut, ST->ConOut->Mode->Mode, &ConWidth, &ConHeight) != EFI_SUCCESS) { ++ if (uefi_call_wrapper(ST->ConOut->QueryMode, 4, ST->ConOut, ST->ConOut->Mode->Mode, &ConWidth, &ConHeight) != EFI_SUCCESS) { + // use default values on error + ConWidth = 80; + ConHeight = 25; +@@ -122,7 +122,7 @@ + static VOID SwitchToText(IN BOOLEAN CursorEnabled) + { + egSetGraphicsModeEnabled(FALSE); +- ST->ConOut->EnableCursor(ST->ConOut, CursorEnabled); ++ uefi_call_wrapper(ST->ConOut->EnableCursor, 2, ST->ConOut, CursorEnabled); + } + + static VOID SwitchToGraphics(VOID) +@@ -194,11 +194,11 @@ + VOID TerminateScreen(VOID) + { + // clear text screen +- ST->ConOut->SetAttribute(ST->ConOut, ATTR_BASIC); +- ST->ConOut->ClearScreen(ST->ConOut); ++ uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, ATTR_BASIC); ++ uefi_call_wrapper(ST->ConOut->ClearScreen, 1, ST->ConOut); + + // enable cursor +- ST->ConOut->EnableCursor(ST->ConOut, TRUE); ++ uefi_call_wrapper(ST->ConOut->EnableCursor, 2, ST->ConOut, TRUE); + } + + static VOID DrawScreenHeader(IN CHAR16 *Title) +@@ -206,23 +206,23 @@ + UINTN y; + + // clear to black background +- ST->ConOut->SetAttribute(ST->ConOut, ATTR_BASIC); +- ST->ConOut->ClearScreen(ST->ConOut); ++ uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, ATTR_BASIC); ++ uefi_call_wrapper(ST->ConOut->ClearScreen, 1, ST->ConOut); + + // paint header background +- ST->ConOut->SetAttribute(ST->ConOut, ATTR_BANNER); ++ uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, ATTR_BANNER); + for (y = 0; y < 3; y++) { +- ST->ConOut->SetCursorPosition(ST->ConOut, 0, y); ++ uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, 0, y); + Print(BlankLine); + } + + // print header text +- ST->ConOut->SetCursorPosition(ST->ConOut, 3, 1); ++ uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, 3, 1); + Print(L"rEFIt - %s", Title); + + // reposition cursor +- ST->ConOut->SetAttribute(ST->ConOut, ATTR_BASIC); +- ST->ConOut->SetCursorPosition(ST->ConOut, 0, 4); ++ uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, ATTR_BASIC); ++ uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, 0, 4); + } + + // +@@ -237,7 +237,7 @@ + + GotKeyStrokes = FALSE; + for (;;) { +- Status = ST->ConIn->ReadKeyStroke(ST->ConIn, &key); ++ Status = uefi_call_wrapper(ST->ConIn->ReadKeyStroke, 2, ST->ConIn, &key); + if (Status == EFI_SUCCESS) { + GotKeyStrokes = TRUE; + continue; +@@ -254,11 +254,11 @@ + Print(L"\n* Hit any key to continue *"); + + if (ReadAllKeyStrokes()) { // remove buffered key strokes +- BS->Stall(5000000); // 5 seconds delay ++ uefi_call_wrapper(BS->Stall, 1, 5000000); // 5 seconds delay + ReadAllKeyStrokes(); // empty the buffer again + } + +- BS->WaitForEvent(1, &ST->ConIn->WaitForKey, &index); ++ uefi_call_wrapper(BS->WaitForEvent, 3, 1, &ST->ConIn->WaitForKey, &index); + ReadAllKeyStrokes(); // empty the buffer to protect the menu + + Print(L"\n"); +@@ -282,7 +282,7 @@ + + for (;;) { + ReadAllKeyStrokes(); +- BS->WaitForEvent(1, &ST->ConIn->WaitForKey, &index); ++ uefi_call_wrapper(BS->WaitForEvent, 3, 1, &ST->ConIn->WaitForKey, &index); + } + } + +@@ -298,9 +298,9 @@ + return FALSE; + + StatusToString(ErrorName, Status); +- ST->ConOut->SetAttribute(ST->ConOut, ATTR_ERROR); ++ uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, ATTR_ERROR); + Print(L"Fatal Error: %s %s\n", ErrorName, where); +- ST->ConOut->SetAttribute(ST->ConOut, ATTR_BASIC); ++ uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, ATTR_BASIC); + haveError = TRUE; + + //BS->Exit(ImageHandle, ExitStatus, ExitDataSize, ExitData); +@@ -316,9 +316,9 @@ + return FALSE; + + StatusToString(ErrorName, Status); +- ST->ConOut->SetAttribute(ST->ConOut, ATTR_ERROR); ++ uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, ATTR_ERROR); + Print(L"Error: %s %s\n", ErrorName, where); +- ST->ConOut->SetAttribute(ST->ConOut, ATTR_BASIC); ++ uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, ATTR_BASIC); + haveError = TRUE; + + return TRUE; diff --git a/refit.spec b/refit.spec new file mode 100644 index 0000000..368689a --- /dev/null +++ b/refit.spec @@ -0,0 +1,125 @@ +Name: refit +Version: 0.14 +Release: 2mamba +Summary: A boot menu and maintenance toolkit for EFI-based machines like the Intel Macs +Group: System/Kernel and Hardware +Vendor: openmamba +Distribution: openmamba +Packager: Silvan Calarco +URL: http://refit.sourceforge.net +Source: http://downloads.sourceforge.net/sourceforge/refit/refit-src-%{version}.tar.gz +# Binary contains some resources missing in source package e.g. icons +Source1: http://downloads.sourceforge.net/sourceforge/refit/refit-bin-%{version}.tar.gz +Patch0: %{name}-0.14-disable_EFI110_features.patch +Patch1: %{name}-0.14-libeg_uefi_call_wrapper.patch +Patch2: %{name}-0.14-refit_uefi_call_wrapper.patch +Patch3: %{name}-0.14-gptsync_uefi_call_wrapper.patch +Patch4: %{name}-0.14-gptsync_64bit_fix.patch +Patch5: %{name}-0.14-gptsync_nom_nom_nom_newline.patch +License: GPL +BuildRoot: %{_tmppath}/%{name}-%{version}-root +## AUTOBUILDREQ-BEGIN +BuildRequires: glibc-devel +## AUTOBUILDREQ-END +BuildRequires: gnu-efi + +%description +rEFIt is a boot menu and maintenance toolkit for EFI-based machines like the Intel Macs. You can use it to boot multiple operating systems easily, including triple-boot setups with Boot Camp. It also provides an easy way to enter and explore the EFI pre-boot environment. + +%package tools +Summary: Tools for refit, a boot menu and maintenance toolkit for EFI-based machines +Group: Development/Libraries + +%description tools +rEFIt is a boot menu and maintenance toolkit for EFI-based machines like the Intel Macs. You can use it to boot multiple operating systems easily, including triple-boot setups with Boot Camp. It also provides an easy way to enter and explore the EFI pre-boot environment. + +%package efi +Summary: refit EFI binaries +Group: Development/Libraries + +%description efi +rEFIt is a boot menu and maintenance toolkit for EFI-based machines like the Intel Macs. You can use it to boot multiple operating systems easily, including triple-boot setups with Boot Camp. It also provides an easy way to enter and explore the EFI pre-boot environment. +This package contains the efi binaries. + +%prep +%setup -q -n refit-src-%{version} -a1 +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 +%patch5 -p1 + +%build +cd libeg +make \ +%ifarch x86_64 + CFLAGS="-fpic -fshort-wchar" +%endif + +cd ../gptsync +make -f Makefile.unix +make -f Makefile.gnuefi \ +%ifarch x86_64 + CFLAGS="-fpic -fshort-wchar" \ + EFILIB=%{_libdir} \ + GNUEFILIB=%{_libdir} \ + EFICRT0=%{_libdir} +%endif + +cd ../refit +make \ +%ifarch x86_64 + CFLAGS="-fpic -fshort-wchar" \ + EFILIB=%{_libdir} \ + GNUEFILIB=%{_libdir} \ + EFICRT0=%{_libdir} +%endif + +%install +[ "%{buildroot}" != / ] && rm -rf "%{buildroot}" +install -D -m0755 gptsync/gptsync %{buildroot}%{_sbindir}/gptsync +install -D -m0755 gptsync/showpart %{buildroot}%{_sbindir}/showpart +install -D -m0644 gptsync/gptsync.8 %{buildroot}%{_mandir}/man8/gptsync.8 +install -D -m0755 gptsync/gptsync.efi %{buildroot}%{_datadir}/refit/efi/tools/gptsync.efi +install -D -m0755 refit/refit.efi %{buildroot}%{_datadir}/refit/efi/refit/refit.efi +install -D -m0644 refit-bin-%{version}/efi/refit/refit.conf %{buildroot}%{_datadir}/refit/efi/refit/refit.conf +cp -a refit-bin-%{version}/efi/refit/icons %{buildroot}%{_datadir}/refit/efi/refit/ + +%clean +[ "%{buildroot}" != / ] && rm -rf "%{buildroot}" + +%files tools +%defattr(-,root,root) +%{_sbindir}/gptsync +%{_sbindir}/showpart +%{_mandir}/man8/gptsync.8.gz + +%files efi +%defattr(-,root,root) +%dir %{_datadir}/refit +%dir %{_datadir}/refit/efi +%dir %{_datadir}/refit/efi/tools +%{_datadir}/refit/efi/tools/gptsync.efi +%dir %{_datadir}/refit/efi/refit +%{_datadir}/refit/efi/refit/refit.efi +%{_datadir}/refit/efi/refit/refit.conf +%dir %{_datadir}/refit/efi/refit/icons +%{_datadir}/refit/efi/refit/icons/* + +%changelog +* Wed Jul 11 2012 Silvan Calarco 0.14-2mamba +- added patches from https://patches.ubuntu.com/doh/r/refit/extracted/ to build refit.efi +- added icons and default configuration file + +* Thu Jun 03 2010 Silvan Calarco 0.14-1mamba +- update to 0.14 + +* Mon Mar 30 2009 Silvan Calarco 0.13-1mamba +- automatic update by autodist + +* Tue Jan 27 2009 Silvan Calarco 0.12-1mamba +- automatic update by autodist + +* Fri Sep 14 2007 Silvan Calarco 0.10-1mamba +- package created by autospec