Move displayFreeMemory in its own file for Utils not to depend on OC.

This commit is contained in:
jief 2023-11-20 20:00:04 +01:00
parent 495dd319c3
commit ca166219f0
4 changed files with 46 additions and 22 deletions

View File

@ -142,23 +142,6 @@ UINT32 GetCrc32(UINT8 *Buffer, UINTN Size)
return x;
}
//#ifndef UNIT_TESTS_MACOS
extern "C" {
#include <Library/OcMemoryLib.h>
}
void displayFreeMemory(const XString8& prefix)
{
UINTN LowMemory;
UINTN TotalMemory;
TotalMemory = OcCountFreePages (&LowMemory);
DebugLog(1, "--> %s: Firmware has %llu free pages (%llu in lower 4 GB)\n", prefix.c_str(), TotalMemory, LowMemory);
}
//#endif
XBool haveError = false;

View File

@ -130,10 +130,5 @@ extern XBool haveError;
#endif // __cplusplus
//#ifndef UNIT_TESTS_MACOS
extern "C" {
void displayFreeMemory(const XString8& prefix);
}
//#endif
#endif // _UTILS_H_

View File

@ -0,0 +1,26 @@
///*++
//
//All rights reserved. This program and the accompanying materials
//are licensed and made available under the terms and conditions of the BSD License
//which accompanies this distribution. The full text of the license may be found at
//http://opensource.org/licenses/bsd-license.php
//
//THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
//WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
//
//
#include <Platform.h> // Only use angled for Platform, else, xcode project won't compile
#include <Efi.h>
extern "C" {
#include <Library/OcMemoryLib.h>
}
void displayFreeMemory(const XString8& prefix)
{
UINTN LowMemory;
UINTN TotalMemory;
TotalMemory = OcCountFreePages (&LowMemory);
DebugLog(1, "--> %s: Firmware has %llu free pages (%llu in lower 4 GB)\n", prefix.c_str(), TotalMemory, LowMemory);
}

20
rEFIt_UEFI/Platform/UtilsEFI.h Executable file
View File

@ -0,0 +1,20 @@
//
//All rights reserved. This program and the accompanying materials
//are licensed and made available under the terms and conditions of the BSD License
//which accompanies this distribution. The full text of the license may be found at
//http://opensource.org/licenses/bsd-license.php
//
//THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
//WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
//
//
#ifndef _UTILSEFI_H_
#define _UTILSEFI_H_
//extern "C" {
void displayFreeMemory(const XString8& prefix);
//}
#endif // _UTILSEFI_H_