#! /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;