Do not use Print() anymore.

This commit is contained in:
jief 2020-03-28 09:36:07 +03:00
parent ace46a5646
commit 020fe5a2f0
11 changed files with 28 additions and 29 deletions

View File

@ -1797,7 +1797,7 @@ EFI_STATUS PatchACPI(IN REFIT_VOLUME *Volume, CHAR8 *OSVersion)
DBG("RsdPointer Acpi 2.0 installed\n");
}
Xsdt = (XSDT_TABLE*)(UINTN)BufferPtr;
// Print(L"XSDT = 0x%x\n\r", Xsdt);
// DBG("XSDT = 0x%x\n\r", Xsdt);
Xsdt->Header.Signature = 0x54445358; //EFI_ACPI_2_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE
eCntR = (Rsdt->Header.Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / sizeof(UINT32);
Xsdt->Header.Length = eCntR * sizeof(UINT64) + sizeof (EFI_ACPI_DESCRIPTION_HEADER);

View File

@ -36,7 +36,7 @@ WaitForKeyPress(
UINTN index;
EFI_INPUT_KEY key;
Print(Message);
printf("%ls", Message);
do {
Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &key);
} while(Status == EFI_SUCCESS);

View File

@ -23,7 +23,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#endif
#if PATCH_DEBUG
#define DBG(...) Print(__VA_ARGS__);
#define DBG(...) printf(__VA_ARGS__);
#else
#define DBG(...)
#endif
@ -290,7 +290,7 @@ OnExitBootServices(IN EFI_EVENT Event, IN VOID *Context)
ptr+=0x1000;
if((UINT32)(UINTN)ptr > 0x3000000)
{
// Print(L"bootArgs not found!\n");
// DBG("bootArgs not found!\n");
gST->ConOut->OutputString (gST->ConOut, L"bootArgs not found!");
gBS->Stall(5000000);
// return;

View File

@ -215,7 +215,7 @@ EFI_STATUS EFIAPI GetScreenInfo(VOID* This, UINT64* baseAddress, UINT64* frameBu
if(EFI_ERROR(Status))
return EFI_UNSUPPORTED;
//this print never occured so this procedure is redundant
// Print(L"GetScreenInfo called with args: %lx %lx %lx %lx %lx %lx\n",
// printf("GetScreenInfo called with args: %lx %lx %lx %lx %lx %lx\n",
// baseAddress, frameBufferSize, bpr, w, h, colorDepth);
*frameBufferSize = (UINT64)mGraphicsOutput->Mode->FrameBufferSize;
*baseAddress = (UINT64)mGraphicsOutput->Mode->FrameBufferBase;
@ -223,7 +223,7 @@ EFI_STATUS EFIAPI GetScreenInfo(VOID* This, UINT64* baseAddress, UINT64* frameBu
*h = (UINT32)mGraphicsOutput->Mode->Info->VerticalResolution;
*colorDepth = 32;
*bpr = (UINT32)(mGraphicsOutput->Mode->Info->PixelsPerScanLine*32) >> 3;
// Print(L" Screen info: FBsize=%lx FBaddr=%lx w=%d h=%d\n",
// printf(" Screen info: FBsize=%lx FBaddr=%lx w=%d h=%d\n",
// *frameBufferSize, *baseAddress, *w, *h);
// PauseForKey(L"--- press any key ---\n");
return EFI_SUCCESS;

View File

@ -10,23 +10,24 @@ extern "C" {
}
#include "../../cpp_foundation/XString.h"
#include "../../cpp_foundation/XStringW.h"
static XString stdio_static_buf;
static XStringW stdio_static_wbuf;
int printf(const char* format, ...)
{
va_list va;
char buf[1024]; // that's quick and dirty !!!
// AsciiPrint seems no to work with utf8 chars. We have to use Print instead
va_start (va, format);
vsnprintf(buf, sizeof(buf), format, va);
buf[sizeof(buf)-1] = 0; // just in case
int ret = (int)AsciiPrint("%a", buf);
stdio_static_wbuf.vSPrintf(format, va);
int ret = (int)Print(L"%s", stdio_static_wbuf.wc_str());
va_end(va);
return ret;
}
static XString stdio_static_buf;
const char* strerror(EFI_STATUS Status)
{
UINTN n = 0;

View File

@ -809,7 +809,7 @@ EFI_STATUS InjectKexts(/*IN EFI_MEMORY_DESCRIPTOR *Desc*/ IN UINT32 deviceTreeP,
}
if (drvPtr == 0 || infoPtr == 0 || extraPtr == 0 || drvPtr > infoPtr || drvPtr > extraPtr || infoPtr > extraPtr) {
Print(L"\nInvalid device tree for kext injection\n");
printf("\nInvalid device tree for kext injection\n");
gBS->Stall(5000000);
return EFI_INVALID_PARAMETER;
}

View File

@ -347,7 +347,7 @@ VOID ATIConnectorsPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPlist, UINT
Num = SearchAndCount(Driver, DriverSize, Entry->KernelAndKextPatches->KPATIConnectorsData, Entry->KernelAndKextPatches->KPATIConnectorsDataLen);
if (Num > 1) {
// error message - shoud always be printed
Print(L"==> KPATIConnectorsData found %d times in %a - skipping patching!\n", Num, gKextBundleIdentifier);
printf("==> KPATIConnectorsData found %llu times in %s - skipping patching!\n", Num, gKextBundleIdentifier);
gBS->Stall(5*1000000);
return;
}
@ -511,7 +511,7 @@ VOID AppleRTCPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPlist, UINT32 In
if (NumLion_X64 + NumLion_i386 + NumML + NumMavMoj3 + NumMoj4 > 1) {
// more then one pattern found - we do not know what to do with it
// and we'll skip it
Print(L"AppleRTCPatch: ERROR: multiple patterns found (LionX64: %d, Lioni386: %d, ML: %d, MavMoj3: %d, Moj4: %d) - skipping patching!\n",
printf("AppleRTCPatch: ERROR: multiple patterns found (LionX64: %llu, Lioni386: %llu, ML: %llu, MavMoj3: %llu, Moj4: %llu) - skipping patching!\n",
NumLion_X64, NumLion_i386, NumML, NumMavMoj3, NumMoj4);
gBS->Stall(5000000);
return;

View File

@ -201,7 +201,7 @@ VOID ScanTool(VOID)
if (GlobalConfig.DisableFlags & HIDEUI_FLAG_TOOLS)
return;
// Print(L"Scanning for tools...\n");
// DBG("Scanning for tools...\n");
// look for the EFI shell
if (!(GlobalConfig.DisableFlags & HIDEUI_FLAG_SHELL)) {

View File

@ -880,7 +880,7 @@ static EFI_STATUS ScanVolume(IN OUT REFIT_VOLUME *Volume)
// TODO: also check for Boot Camp GUID
//gEfiPartTypeSystemPartGuid
Bootable = FALSE; // this handle's BlockIO is just an alias for the whole device
Print(L"AppleLegacy device\n");
DBG("AppleLegacy device\n");
}
*/
}
@ -901,7 +901,7 @@ static EFI_STATUS ScanVolume(IN OUT REFIT_VOLUME *Volume)
}
// DBG("DevicePath scanned\n");
if (HdPath) {
// Print(L"Partition found %s\n", DevicePathToStr((EFI_DEVICE_PATH *)HdPath));
// printf("Partition found %s\n", DevicePathToStr((EFI_DEVICE_PATH *)HdPath));
PartialLength = (UINTN)((UINT8 *)HdPath - (UINT8 *)(RemainingDevicePath));
if (PartialLength > 0x1000) {
@ -911,7 +911,6 @@ static EFI_STATUS ScanVolume(IN OUT REFIT_VOLUME *Volume)
DiskDevicePath = (EFI_DEVICE_PATH *)AllocatePool(PartialLength + sizeof(EFI_DEVICE_PATH));
CopyMem(DiskDevicePath, Volume->DevicePath, PartialLength);
CopyMem((UINT8 *)DiskDevicePath + PartialLength, DevicePath, sizeof(EFI_DEVICE_PATH)); //EndDevicePath
// Print(L"WholeDevicePath %s\n", DevicePathToStr(DiskDevicePath));
// DBG("WholeDevicePath %ls\n", DevicePathToStr(DiskDevicePath));
RemainingDevicePath = DiskDevicePath;
Status = gBS->LocateDevicePath(&gEfiDevicePathProtocolGuid, &RemainingDevicePath, &WholeDiskHandle);

View File

@ -70,7 +70,6 @@ extern XTheme ThemeX; //global variable defined in lib.cpp
#endif
#define REFIT_DEBUG (2)
#define Print if ((!GlobalConfig.Quiet) || (GlobalConfig.TextOnly)) Print
#ifdef __cplusplus

View File

@ -249,27 +249,27 @@ static VOID DrawScreenHeader(IN CONST CHAR16 *Title)
BannerLine[0] = BOXDRAW_DOWN_RIGHT;
BannerLine[ConWidth-1] = BOXDRAW_DOWN_LEFT;
gST->ConOut->SetCursorPosition (gST->ConOut, 0, 0);
Print(BannerLine);
printf("%ls", BannerLine);
for (i = 1; i < ConWidth-1; i++)
BannerLine[i] = ' ';
BannerLine[0] = BOXDRAW_VERTICAL;
BannerLine[ConWidth-1] = BOXDRAW_VERTICAL;
gST->ConOut->SetCursorPosition (gST->ConOut, 0, 1);
Print(BannerLine);
printf("%ls", BannerLine);
for (i = 1; i < ConWidth-1; i++)
BannerLine[i] = BOXDRAW_HORIZONTAL;
BannerLine[0] = BOXDRAW_UP_RIGHT;
BannerLine[ConWidth-1] = BOXDRAW_UP_LEFT;
gST->ConOut->SetCursorPosition (gST->ConOut, 0, 2);
Print(BannerLine);
printf("%ls", BannerLine);
FreePool(BannerLine);
// print header text
gST->ConOut->SetCursorPosition (gST->ConOut, 3, 1);
Print(L"Clover rev %s - %s", gFirmwareRevision, Title);
printf("Clover rev %ls - %ls", gFirmwareRevision, Title);
// reposition cursor
gST->ConOut->SetAttribute (gST->ConOut, ATTR_BASIC);
@ -303,9 +303,9 @@ VOID PauseForKey(CONST CHAR16* msg)
#if REFIT_DEBUG > 0
UINTN index;
if (msg) {
Print(L"\n %s", msg);
printf("\n %ls", msg);
}
Print(L"\n* Hit any key to continue *");
printf("\n* Hit any key to continue *");
if (ReadAllKeyStrokes()) { // remove buffered key strokes
gBS->Stall(5000000); // 5 seconds delay
@ -315,7 +315,7 @@ VOID PauseForKey(CONST CHAR16* msg)
gBS->WaitForEvent(1, &gST->ConIn->WaitForKey, &index);
ReadAllKeyStrokes(); // empty the buffer to protect the menu
Print(L"\n");
printf("\n");
#endif
}
@ -364,7 +364,7 @@ BOOLEAN CheckFatalError(IN EFI_STATUS Status, IN CONST CHAR16 *where)
// StatusToString(ErrorName, Status);
gST->ConOut->SetAttribute (gST->ConOut, ATTR_ERROR);
Print(L"Fatal Error: %r %s\n", Status, where);
printf("Fatal Error: %s %ls\n", strerror(Status), where);
gST->ConOut->SetAttribute (gST->ConOut, ATTR_BASIC);
haveError = TRUE;
@ -382,7 +382,7 @@ BOOLEAN CheckError(IN EFI_STATUS Status, IN CONST CHAR16 *where)
// StatusToString(ErrorName, Status);
gST->ConOut->SetAttribute (gST->ConOut, ATTR_ERROR);
Print(L"Error: %r %s\n", Status, where);
printf("Error: %s %ls\n", strerror(Status), where);
gST->ConOut->SetAttribute (gST->ConOut, ATTR_BASIC);
haveError = TRUE;