Get rid of Print() calls.

This commit is contained in:
Jief L 2020-03-28 18:14:18 +03:00
parent 020fe5a2f0
commit 651f7a02c6
14 changed files with 144 additions and 103 deletions

1
.gitignore vendored
View File

@ -127,3 +127,4 @@ tools
#Eclipse build folder
/DEBUG_*/
/rEFIt_UEFI copy/

View File

@ -632,6 +632,11 @@
9AF41733242CDA5800D2644C /* egemb_icons.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77F6224176C04005CDD5C /* egemb_icons.cpp */; };
9AF41734242CDA5800D2644C /* Edid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77F2824176C04005CDD5C /* Edid.cpp */; };
9AF41735242CDA5800D2644C /* smbios.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77F5124176C04005CDD5C /* smbios.cpp */; };
9AF4173F242F15CC00D2644C /* BootLog.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AF4173C242F15CB00D2644C /* BootLog.h */; };
9AF41740242F15CC00D2644C /* BasicIO.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AF4173D242F15CC00D2644C /* BasicIO.cpp */; };
9AF41741242F15CC00D2644C /* BasicIO.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AF4173E242F15CC00D2644C /* BasicIO.h */; };
9AF41742242F15D600D2644C /* BasicIO.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AF4173D242F15CC00D2644C /* BasicIO.cpp */; };
9AF41743242F15D700D2644C /* BasicIO.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AF4173D242F15CC00D2644C /* BasicIO.cpp */; };
A5E326312428F4EE002240E8 /* XTheme.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5E3262F2428F4EE002240E8 /* XTheme.cpp */; };
A5E326322428F4EE002240E8 /* XTheme.h in Headers */ = {isa = PBXBuildFile; fileRef = A5E326302428F4EE002240E8 /* XTheme.h */; };
/* End PBXBuildFile section */
@ -847,6 +852,9 @@
9AF41567242BAD7D00D2644C /* poolprint-test-cpp_conf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "poolprint-test-cpp_conf.h"; sourceTree = "<group>"; };
9AF4165E242CD75C00D2644C /* libCloverX64 DEBUG_ALL=1.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libCloverX64 DEBUG_ALL=1.a"; sourceTree = BUILT_PRODUCTS_DIR; };
9AF4173B242CDA5800D2644C /* libCloverX64 DEBUG_ALL=2.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libCloverX64 DEBUG_ALL=2.a"; sourceTree = BUILT_PRODUCTS_DIR; };
9AF4173C242F15CB00D2644C /* BootLog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BootLog.h; sourceTree = "<group>"; };
9AF4173D242F15CC00D2644C /* BasicIO.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BasicIO.cpp; sourceTree = "<group>"; };
9AF4173E242F15CC00D2644C /* BasicIO.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BasicIO.h; sourceTree = "<group>"; };
A5E3262F2428F4EE002240E8 /* XTheme.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XTheme.cpp; sourceTree = "<group>"; };
A5E326302428F4EE002240E8 /* XTheme.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XTheme.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
@ -993,7 +1001,6 @@
9AC77F1624176C04005CDD5C /* Platform */ = {
isa = PBXGroup;
children = (
9A28CC99241B66EA00F3D247 /* Posix */,
9AC77F2024176C04005CDD5C /* AcpiPatcher.cpp */,
9AC77F2324176C04005CDD5C /* AmlGenerator.cpp */,
9AC77F1E24176C04005CDD5C /* AmlGenerator.h */,
@ -1002,9 +1009,12 @@
9AC77F4624176C04005CDD5C /* ati.h */,
9AC77F2F24176C04005CDD5C /* b64cdecode.cpp */,
9AC77F4C24176C04005CDD5C /* b64cdecode.h */,
9AF4173D242F15CC00D2644C /* BasicIO.cpp */,
9AF4173E242F15CC00D2644C /* BasicIO.h */,
9AC77F2424176C04005CDD5C /* BdsConnect.cpp */,
9AC77F3824176C04005CDD5C /* boot.h */,
9AC77F3224176C04005CDD5C /* BootLog.cpp */,
9AF4173C242F15CB00D2644C /* BootLog.h */,
9AC77F3A24176C04005CDD5C /* BootOptions.cpp */,
9AC77F5724176C04005CDD5C /* card_vlist.cpp */,
9AC77F2B24176C04005CDD5C /* Console.cpp */,
@ -1048,6 +1058,7 @@
9AC77F4224176C04005CDD5C /* platformdata.cpp */,
9AC77F2724176C04005CDD5C /* PlatformDriverOverride.cpp */,
9AC77F4424176C04005CDD5C /* plist.cpp */,
9A28CC99241B66EA00F3D247 /* Posix */,
9AC77F5924176C04005CDD5C /* Settings.cpp */,
9AC77F2524176C04005CDD5C /* Settings.h */,
9AC77F5124176C04005CDD5C /* smbios.cpp */,
@ -1221,6 +1232,7 @@
9AC780B82417F359005CDD5C /* XStringWP.h in Headers */,
9AC7801C24176C04005CDD5C /* nvidia.h in Headers */,
9AC7808524176C04005CDD5C /* operatorNewDelete.h in Headers */,
9AF41741242F15CC00D2644C /* BasicIO.h in Headers */,
9A57C25C24192D710029A39F /* XUINTN_test.h in Headers */,
9AC77FB924176C04005CDD5C /* XStringWArray_test.h in Headers */,
9AC77FFE24176C04005CDD5C /* syslinux_mbr.h in Headers */,
@ -1235,6 +1247,7 @@
9AC7800724176C04005CDD5C /* AmlGenerator.h in Headers */,
9AC7808F24176C04005CDD5C /* XStringW.h in Headers */,
9AC7809324176C04005CDD5C /* utf8Conversion.h in Headers */,
9AF4173F242F15CC00D2644C /* BootLog.h in Headers */,
9A28CCAA241B66EA00F3D247 /* stdarg.h in Headers */,
9A28CCA9241B66EA00F3D247 /* posix.h in Headers */,
9AC7807B24176C04005CDD5C /* list.h in Headers */,
@ -1701,6 +1714,7 @@
9AF41564242BABC700D2644C /* printlib-test.cpp in Sources */,
9AC77FC524176C04005CDD5C /* XStringW_test.cpp in Sources */,
9AC7806F24176C04005CDD5C /* tool.cpp in Sources */,
9AF41740242F15CC00D2644C /* BasicIO.cpp in Sources */,
9AC7807924176C04005CDD5C /* lib.cpp in Sources */,
9AC7801E24176C04005CDD5C /* Injectors.cpp in Sources */,
9AC7807824176C04005CDD5C /* menu.cpp in Sources */,
@ -1817,6 +1831,7 @@
9AF415FE242CD75C00D2644C /* printlib-test.cpp in Sources */,
9AF415FF242CD75C00D2644C /* XStringW_test.cpp in Sources */,
9AF41600242CD75C00D2644C /* tool.cpp in Sources */,
9AF41742242F15D600D2644C /* BasicIO.cpp in Sources */,
9AF41601242CD75C00D2644C /* lib.cpp in Sources */,
9AF41602242CD75C00D2644C /* Injectors.cpp in Sources */,
9AF41603242CD75C00D2644C /* menu.cpp in Sources */,
@ -1933,6 +1948,7 @@
9AF416DB242CDA5800D2644C /* printlib-test.cpp in Sources */,
9AF416DC242CDA5800D2644C /* XStringW_test.cpp in Sources */,
9AF416DD242CDA5800D2644C /* tool.cpp in Sources */,
9AF41743242F15D700D2644C /* BasicIO.cpp in Sources */,
9AF416DE242CDA5800D2644C /* lib.cpp in Sources */,
9AF416DF242CDA5800D2644C /* Injectors.cpp in Sources */,
9AF416E0242CDA5800D2644C /* menu.cpp in Sources */,

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;
// DBG("XSDT = 0x%x\n\r", Xsdt);
// DBG("XSDT = 0x%x\n", 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

@ -0,0 +1,99 @@
/*
* BasicIO.cpp
*
* Created on: 28 Mar 2020
*
*/
#include <stdio.h>
#include "BasicIO.h"
//#include "EfiExternals.h"
extern "C" {
#include "Library/UefiBootServicesTableLib.h"
}
//
// Keyboard input
//
BOOLEAN ReadAllKeyStrokes(VOID)
{
BOOLEAN GotKeyStrokes;
EFI_STATUS Status;
EFI_INPUT_KEY key;
GotKeyStrokes = FALSE;
for (;;) {
Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &key);
if (Status == EFI_SUCCESS) {
GotKeyStrokes = TRUE;
continue;
}
break;
}
return GotKeyStrokes;
}
VOID PauseForKey(CONST CHAR16* msg)
{
UINTN index;
if (msg) {
printf("\n %ls", msg);
}
printf("\n* Hit any key to continue *");
if (ReadAllKeyStrokes()) { // remove buffered key strokes
gBS->Stall(5000000); // 5 seconds delay
ReadAllKeyStrokes(); // empty the buffer again
}
gBS->WaitForEvent(1, &gST->ConIn->WaitForKey, &index);
ReadAllKeyStrokes(); // empty the buffer to protect the menu
printf("\n");
}
// Jief, TODO : not sure of the difference between this and PauseForKey. Looks like none. Can it be removed ?
VOID
WaitForKeyPress(
CHAR16 *Message
)
{
EFI_STATUS Status;
UINTN index;
EFI_INPUT_KEY key;
printf("%ls", Message);
do {
Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &key);
} while(Status == EFI_SUCCESS);
gBS->WaitForEvent(1, &gST->ConIn->WaitForKey, &index);
do {
Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &key);
} while(Status == EFI_SUCCESS);
}
//#if REFIT_DEBUG > 0
//VOID DebugPause(VOID)
//{
// // show console and wait for key
// SwitchToText(FALSE);
// PauseForKey(L"");
//
// // reset error flag
// haveError = FALSE;
//}
//#endif
VOID EndlessIdleLoop(VOID)
{
UINTN index;
for (;;) {
ReadAllKeyStrokes();
gBS->WaitForEvent(1, &gST->ConIn->WaitForKey, &index);
}
}

View File

@ -0,0 +1,20 @@
/*
* BasicIO.h
*
* Created on: 28 Mar 2020
* Author: jief
*/
#ifndef PLATFORM_BASICIO_H_
#define PLATFORM_BASICIO_H_
BOOLEAN ReadAllKeyStrokes(VOID);
VOID PauseForKey(CONST CHAR16* msg);
//VOID DebugPause(VOID);
VOID EndlessIdleLoop(VOID);
#endif /* PLATFORM_BASICIO_H_ */

View File

@ -9,6 +9,7 @@
#include "Platform.h"
#include "BasicIO.h"
#ifndef DEBUG_ALL
@ -27,25 +28,6 @@
#define BOOT_ORDER_VAR L"BootOrder"
VOID
WaitForKeyPress(
CHAR16 *Message
)
{
EFI_STATUS Status;
UINTN index;
EFI_INPUT_KEY key;
printf("%ls", Message);
do {
Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &key);
} while(Status == EFI_SUCCESS);
gBS->WaitForEvent(1, &gST->ConIn->WaitForKey, &index);
do {
Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &key);
} while(Status == EFI_SUCCESS);
}
/** Returns upper case version of char - valid only for ASCII chars in unicode. */
CHAR16

View File

@ -14,9 +14,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "LegacyBiosThunk.h"
#include <posix.h>
#include "BootLog.h" // for DebugLog
#include "Platform.h"
#include "../refit/screen.h" // just for PauseForKey
#ifndef DEBUG_ALL
#define DEBUG_LBTHUNK 0

View File

@ -95,6 +95,7 @@ extern "C" {
#endif
#include "BootLog.h"
#include "BasicIO.h"
#include "../refit/lib.h"
#include "../refit/screen.h" // for PauseForKey
#include "string.h"
@ -1668,8 +1669,6 @@ extern CHAR8 *AppleBoardID[];
extern CHAR8 *AppleChassisAsset[];
extern CONST CHAR8 *AppleBoardSN;
extern CONST CHAR8 *AppleBoardLocation;
extern EFI_SYSTEM_TABLE *gST;
extern EFI_BOOT_SERVICES *gBS;
extern SETTINGS_DATA gSettings;
extern LANGUAGES gLanguage;
extern BOOLEAN gFirmwareClover;

View File

@ -3,7 +3,7 @@
#include "../cpp_foundation/XArray.h"
#include "../cpp_foundation/XObjArray.h"
#include "../refit/screen.h" // just for PauseForKey
#include "../Platform/BasicIO.h" // for PauseForKey
#include "XArray_tests.h"
#include "XObjArray_tests.h"

View File

@ -36,7 +36,7 @@
#define __menu_items_H__
#include "../libeg/libeg.h"
#include "../../libeg/libeg.h"
#include "../../refit/lib.h"
#ifdef __cplusplus
#include "../../cpp_foundation/XObjArray.h"

View File

@ -76,10 +76,6 @@ extern XTheme ThemeX; //global variable defined in lib.cpp
extern "C" {
#endif
extern EFI_HANDLE gImageHandle;
extern EFI_SYSTEM_TABLE* gST;
extern EFI_BOOT_SERVICES* gBS;
extern EFI_RUNTIME_SERVICES* gRT;
#include <Protocol/SimpleFileSystem.h>

View File

@ -88,12 +88,6 @@ BOOLEAN gThemeNeedInit = TRUE;
BOOLEAN DoHibernateWake = FALSE;
BOOLEAN APFSSupport = FALSE;
//extern EFI_HANDLE gImageHandle;
//extern EFI_SYSTEM_TABLE* gST;
//extern EFI_BOOT_SERVICES* gBS;
//extern EFI_DXE_SERVICES* gDS;
//EFI_RUNTIME_SERVICES* gRS;
DRIVERS_FLAGS gDriversFlags; //the initializer is not needed for global variables
EMU_VARIABLE_CONTROL_PROTOCOL *gEmuVariableControl = NULL;

View File

@ -38,6 +38,7 @@
#include "screen.h"
#include "../libeg/libegint.h" // included Platform.h
#include "../libeg/XTheme.h"
#include "../Platform/BasicIO.h"
#ifndef DEBUG_ALL
#define DEBUG_SCR 1
@ -276,70 +277,6 @@ static VOID DrawScreenHeader(IN CONST CHAR16 *Title)
gST->ConOut->SetCursorPosition (gST->ConOut, 0, 4);
}
//
// Keyboard input
//
BOOLEAN ReadAllKeyStrokes(VOID)
{
BOOLEAN GotKeyStrokes;
EFI_STATUS Status;
EFI_INPUT_KEY key;
GotKeyStrokes = FALSE;
for (;;) {
Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &key);
if (Status == EFI_SUCCESS) {
GotKeyStrokes = TRUE;
continue;
}
break;
}
return GotKeyStrokes;
}
VOID PauseForKey(CONST CHAR16* msg)
{
#if REFIT_DEBUG > 0
UINTN index;
if (msg) {
printf("\n %ls", msg);
}
printf("\n* Hit any key to continue *");
if (ReadAllKeyStrokes()) { // remove buffered key strokes
gBS->Stall(5000000); // 5 seconds delay
ReadAllKeyStrokes(); // empty the buffer again
}
gBS->WaitForEvent(1, &gST->ConIn->WaitForKey, &index);
ReadAllKeyStrokes(); // empty the buffer to protect the menu
printf("\n");
#endif
}
#if REFIT_DEBUG > 0
VOID DebugPause(VOID)
{
// show console and wait for key
SwitchToText(FALSE);
PauseForKey(L"");
// reset error flag
haveError = FALSE;
}
#endif
VOID EndlessIdleLoop(VOID)
{
UINTN index;
for (;;) {
ReadAllKeyStrokes();
gBS->WaitForEvent(1, &gST->ConIn->WaitForKey, &index);
}
}
//
// Error handling

View File

@ -1,5 +1,4 @@
#include "../gui/menu_items/menu_items.h"
#include "../libeg/libeg.h"
VOID InitScreen(IN BOOLEAN SetMaxResolution);
VOID SetupScreen(VOID);
@ -29,4 +28,4 @@ VOID BltImageCompositeBadge(IN EG_IMAGE *BaseImage, IN EG_IMAGE *TopImage, IN EG
INTN HybridRepositioning(INTN Edge, INTN Value, INTN ImageDimension, INTN ScreenDimension, INTN DesignScreenDimension);
INTN CalculateNudgePosition(INTN Position, INTN NudgeValue, INTN ImageDimension, INTN ScreenDimension);
VOID PauseForKey(CONST CHAR16* msg);