Final refactoring of plist : now each tag is a class.

Rename strerror to efiStrError because of conflict when run cpp_tests on
Mac.
Switch base64_decode_block to long to avoid warning and cast.
Correct GetTableType4(). Size was used without being initialized.
This commit is contained in:
jief666 2020-08-25 18:35:19 +03:00
parent d8c912e420
commit 9cb4016bc5
80 changed files with 5230 additions and 3234 deletions

File diff suppressed because it is too large Load Diff

View File

@ -69,7 +69,7 @@ ld -arch x86_64 -u __ModuleEntryPoint -e __ModuleEntryPoint -preload -segalign
source ./mtoc_path.txt source ./mtoc_path.txt
[[ $? == 0 ]] && "$MTOC" -subsystem UEFI_APPLICATION -align 0x20 ./"$outputname".dll ./"$outputname".pecoff [[ $? == 0 ]] && "$MTOC" -subsystem UEFI_APPLICATION -align 0x20 ./"$outputname".dll ./"$outputname".pecoff
[[ $? == 0 ]] && dsymutil ./"$outputname".dll [[ $? == 0 ]] && dsymutil ./"$outputname".dll 2>&1 | sed "s/warning//g"
[[ $? == 0 ]] && "$edk2prefix"/BaseTools/Source/C/bin/GenFw -e UEFI_APPLICATION -o ./"$outputname".efi ./"$outputname".pecoff [[ $? == 0 ]] && "$edk2prefix"/BaseTools/Source/C/bin/GenFw -e UEFI_APPLICATION -o ./"$outputname".efi ./"$outputname".pecoff

View File

@ -947,7 +947,7 @@ VOID DumpChildSsdt(EFI_ACPI_DESCRIPTION_HEADER *TableEntry, CONST CHAR16 *DirNam
MarkTableAsSaved((VOID*)adr); MarkTableAsSaved((VOID*)adr);
ChildCount++; ChildCount++;
} else { } else {
DBG(" -> %s", strerror(Status)); DBG(" -> %s", efiStrError(Status));
} }
} }
DBG("\n"); DBG("\n");
@ -990,7 +990,7 @@ VOID DumpChildSsdt(EFI_ACPI_DESCRIPTION_HEADER *TableEntry, CONST CHAR16 *DirNam
MarkTableAsSaved((VOID*)adr); MarkTableAsSaved((VOID*)adr);
ChildCount++; ChildCount++;
} else { } else {
DBG(" -> %s", strerror(Status)); DBG(" -> %s", efiStrError(Status));
} }
} }
DBG("\n"); DBG("\n");
@ -1135,7 +1135,7 @@ EFI_STATUS DumpFadtTables(EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt, CONST
TableEntry = (EFI_ACPI_DESCRIPTION_HEADER*)(UINTN)DsdtAdr; TableEntry = (EFI_ACPI_DESCRIPTION_HEADER*)(UINTN)DsdtAdr;
Status = DumpTable(TableEntry, "DSDT", DirName, L""_XSW, FileNamePrefix, NULL); Status = DumpTable(TableEntry, "DSDT", DirName, L""_XSW, FileNamePrefix, NULL);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG(" - %s\n", strerror(Status)); DBG(" - %s\n", efiStrError(Status));
return Status; return Status;
} }
DBG("\n"); DBG("\n");
@ -1168,7 +1168,7 @@ EFI_STATUS DumpFadtTables(EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt, CONST
Status = SaveBufferToDisk(Facs, Facs->Length, DirName, FileName.wc_str()); Status = SaveBufferToDisk(Facs, Facs->Length, DirName, FileName.wc_str());
MarkTableAsSaved(Facs); MarkTableAsSaved(Facs);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG(" - %s\n", strerror(Status)); DBG(" - %s\n", efiStrError(Status));
return Status; return Status;
} }
} }
@ -1290,7 +1290,7 @@ VOID DumpTables(VOID *RsdPtrVoid, CONST CHAR16 *DirName)
Status = SaveBufferToDisk(RsdPtr, Length, DirName, L"RSDP.aml"); Status = SaveBufferToDisk(RsdPtr, Length, DirName, L"RSDP.aml");
MarkTableAsSaved(RsdPtr); MarkTableAsSaved(RsdPtr);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG(" - %s\n", strerror(Status)); DBG(" - %s\n", efiStrError(Status));
return; return;
} }
} }
@ -1320,7 +1320,7 @@ VOID DumpTables(VOID *RsdPtrVoid, CONST CHAR16 *DirName)
DBG(" "); DBG(" ");
Status = DumpTable((EFI_ACPI_DESCRIPTION_HEADER *)Xsdt, "XSDT", DirName, L"XSDT.aml"_XSW, FileNamePrefix, NULL); Status = DumpTable((EFI_ACPI_DESCRIPTION_HEADER *)Xsdt, "XSDT", DirName, L"XSDT.aml"_XSW, FileNamePrefix, NULL);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG(" - %s", strerror(Status)); DBG(" - %s", efiStrError(Status));
Xsdt = NULL; Xsdt = NULL;
} }
DBG("\n"); DBG("\n");
@ -1332,7 +1332,7 @@ VOID DumpTables(VOID *RsdPtrVoid, CONST CHAR16 *DirName)
DBG(" "); DBG(" ");
Status = DumpTable((EFI_ACPI_DESCRIPTION_HEADER *)Rsdt, "RSDT", DirName, L"RSDT.aml"_XSW, FileNamePrefix, NULL); Status = DumpTable((EFI_ACPI_DESCRIPTION_HEADER *)Rsdt, "RSDT", DirName, L"RSDT.aml"_XSW, FileNamePrefix, NULL);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG(" - %s", strerror(Status)); DBG(" - %s", efiStrError(Status));
Rsdt = NULL; Rsdt = NULL;
} }
DBG("\n"); DBG("\n");
@ -1365,7 +1365,7 @@ VOID DumpTables(VOID *RsdPtrVoid, CONST CHAR16 *DirName)
// Fadt - save Dsdt and Facs // Fadt - save Dsdt and Facs
Status = DumpTable(Table, NULL, DirName, L""_XSW, FileNamePrefix, &SsdtCount); Status = DumpTable(Table, NULL, DirName, L""_XSW, FileNamePrefix, &SsdtCount);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG(" - %s\n", strerror(Status)); DBG(" - %s\n", efiStrError(Status));
return; return;
} }
DBG("\n"); DBG("\n");
@ -1377,7 +1377,7 @@ VOID DumpTables(VOID *RsdPtrVoid, CONST CHAR16 *DirName)
} else { } else {
Status = DumpTable(Table, NULL, DirName, L""_XSW, FileNamePrefix, &SsdtCount); Status = DumpTable(Table, NULL, DirName, L""_XSW, FileNamePrefix, &SsdtCount);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG(" - %s\n", strerror(Status)); DBG(" - %s\n", efiStrError(Status));
return; return;
} }
DBG("\n"); DBG("\n");
@ -1408,7 +1408,7 @@ VOID DumpTables(VOID *RsdPtrVoid, CONST CHAR16 *DirName)
// Fadt - save Dsdt and Facs // Fadt - save Dsdt and Facs
Status = DumpTable(Table, NULL, DirName, L""_XSW, FileNamePrefix, &SsdtCount); Status = DumpTable(Table, NULL, DirName, L""_XSW, FileNamePrefix, &SsdtCount);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG(" - %s\n", strerror(Status)); DBG(" - %s\n", efiStrError(Status));
return; return;
} }
DBG("\n"); DBG("\n");
@ -1420,7 +1420,7 @@ VOID DumpTables(VOID *RsdPtrVoid, CONST CHAR16 *DirName)
} else { } else {
Status = DumpTable(Table, NULL, DirName, L""_XSW, FileNamePrefix, &SsdtCount); Status = DumpTable(Table, NULL, DirName, L""_XSW, FileNamePrefix, &SsdtCount);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG(" - %s\n", strerror(Status)); DBG(" - %s\n", efiStrError(Status));
return; return;
} }
DBG("\n"); DBG("\n");
@ -1564,7 +1564,7 @@ VOID SaveOemDsdt(BOOLEAN FullPatch)
if (!EFI_ERROR(Status)) { if (!EFI_ERROR(Status)) {
MsgLog("DSDT saved to %ls\n", OriginDsdt.wc_str()); MsgLog("DSDT saved to %ls\n", OriginDsdt.wc_str());
} else { } else {
MsgLog("Saving DSDT to %ls failed - %s\n", OriginDsdt.wc_str(), strerror(Status)); MsgLog("Saving DSDT to %ls failed - %s\n", OriginDsdt.wc_str(), efiStrError(Status));
} }
gBS->FreePages(dsdt, Pages); gBS->FreePages(dsdt, Pages);
} }
@ -1607,7 +1607,7 @@ BOOLEAN LoadPatchedAML(CONST CHAR16* AcpiOemPath, CONST CHAR16* PartName, UINTN
} }
FreePool(buffer); FreePool(buffer);
} }
DBG("... %s\n", strerror(Status)); DBG("... %s\n", efiStrError(Status));
return !EFI_ERROR(Status); return !EFI_ERROR(Status);
} }
@ -2059,7 +2059,7 @@ EFI_STATUS PatchACPI(IN REFIT_VOLUME *Volume, const XString8& OSVersion)
} }
} }
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG("...saving DSDT failed with status=%s\n", strerror(Status)); DBG("...saving DSDT failed with status=%s\n", efiStrError(Status));
} }
} }
@ -2236,7 +2236,7 @@ EFI_STATUS PatchACPI(IN REFIT_VOLUME *Volume, const XString8& OSVersion)
Status = InsertTable(Ssdt, Ssdt->Length); Status = InsertTable(Ssdt, Ssdt->Length);
} }
if(EFI_ERROR(Status)){ if(EFI_ERROR(Status)){
DBG("GeneratePStates failed: Status=%s\n", strerror(Status)); DBG("GeneratePStates failed: Status=%s\n", efiStrError(Status));
} }
} }
@ -2247,7 +2247,7 @@ EFI_STATUS PatchACPI(IN REFIT_VOLUME *Volume, const XString8& OSVersion)
Status = InsertTable(Ssdt, Ssdt->Length); Status = InsertTable(Ssdt, Ssdt->Length);
} }
if(EFI_ERROR(Status)){ if(EFI_ERROR(Status)){
DBG("GenerateCStates failed Status=%s\n", strerror(Status)); DBG("GenerateCStates failed Status=%s\n", efiStrError(Status));
} }
} }
@ -2386,7 +2386,7 @@ EFI_STATUS LoadAndInjectAcpiTable(CONST CHAR16 *PathPatched,
} }
} }
} else { } else {
DBG("Insert return status %s\n", strerror(Status)); DBG("Insert return status %s\n", efiStrError(Status));
} }
FreePool(Buffer); FreePool(Buffer);

View File

@ -436,7 +436,7 @@ AddToBootOrder (
BootOrderLen * sizeof(UINT16), BootOrderLen * sizeof(UINT16),
BootOrderNew BootOrderNew
); );
DBG("SetVariable: %ls = %s\n", BOOT_ORDER_VAR, strerror(Status)); DBG("SetVariable: %ls = %s\n", BOOT_ORDER_VAR, efiStrError(Status));
PrintBootOrder(BootOrderNew, BootOrderLen); PrintBootOrder(BootOrderNew, BootOrderLen);
FreePool(BootOrder); FreePool(BootOrder);
@ -506,7 +506,7 @@ DeleteFromBootOrder (
BootOrderLen * sizeof(UINT16), BootOrderLen * sizeof(UINT16),
BootOrder BootOrder
); );
DBG("SetVariable: %ls = %s\n", BOOT_ORDER_VAR, strerror(Status)); DBG("SetVariable: %ls = %s\n", BOOT_ORDER_VAR, efiStrError(Status));
FreePool(BootOrder); FreePool(BootOrder);
@ -797,7 +797,7 @@ FindBootOptionForFile (
// //
Status = GetBootOption (BootOrder[Index], &BootOption); Status = GetBootOption (BootOrder[Index], &BootOption);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG("FindBootOptionForFile: Boot%04hX: %s\n", BootOrder[Index], strerror(Status)); DBG("FindBootOptionForFile: Boot%04hX: %s\n", BootOrder[Index], efiStrError(Status));
//WaitForKeyPress(L"press a key to continue\n\n"); //WaitForKeyPress(L"press a key to continue\n\n");
continue; continue;
} }
@ -863,7 +863,7 @@ PrintBootOptions (
// //
Status = GetBootOption (BootOrder[Index], &BootOption); Status = GetBootOption (BootOrder[Index], &BootOption);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG("%2llu) Boot%04hX: ERROR, not found: %s\n", Index, BootOrder[Index], strerror(Status)); DBG("%2llu) Boot%04hX: ERROR, not found: %s\n", Index, BootOrder[Index], efiStrError(Status));
continue; continue;
} }
@ -941,7 +941,7 @@ AddBootOption (
// //
Status = FindFreeBootNum (&BootOption->BootNum); Status = FindFreeBootNum (&BootOption->BootNum);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG("FindFreeBootNum: %s\n", strerror(Status)); DBG("FindFreeBootNum: %s\n", efiStrError(Status));
return Status; return Status;
} }
DBG(" Found BootNum: %04hX\n", BootOption->BootNum); DBG(" Found BootNum: %04hX\n", BootOption->BootNum);
@ -967,7 +967,7 @@ AddBootOption (
BootOption->Variable BootOption->Variable
); );
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG("SetVariable: %ls = %s\n", VarName, strerror(Status)); DBG("SetVariable: %ls = %s\n", VarName, efiStrError(Status));
return Status; return Status;
} }
DBG(" %ls saved\n", VarName); DBG(" %ls saved\n", VarName);
@ -1036,7 +1036,7 @@ AddBootOptionForFile (
Status = AddBootOption (&BootOption, BootIndex); Status = AddBootOption (&BootOption, BootIndex);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
FreePool(BootOption.FilePathList); FreePool(BootOption.FilePathList);
DBG("AddBootOptionForFile: Error: %s\n", strerror(Status)); DBG("AddBootOptionForFile: Error: %s\n", efiStrError(Status));
return Status; return Status;
} }
@ -1082,7 +1082,7 @@ DeleteBootOption (
NULL NULL
); );
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG(" Error del. variable: %ls = %s\n", VarName, strerror(Status)); DBG(" Error del. variable: %ls = %s\n", VarName, efiStrError(Status));
return Status; return Status;
} }
DBG(" %ls deleted\n", VarName); DBG(" %ls deleted\n", VarName);
@ -1166,7 +1166,7 @@ DeleteBootOptionsContainingFile (
// //
Status = GetBootOption (BootOrder[Index], &BootOption); Status = GetBootOption (BootOrder[Index], &BootOption);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG("DeleteBootOptionContainingFile: Boot%04hX: ERROR: %s\n", BootOrder[Index], strerror(Status)); DBG("DeleteBootOptionContainingFile: Boot%04hX: ERROR: %s\n", BootOrder[Index], efiStrError(Status));
//WaitForKeyPress(L"press a key to continue\n\n"); //WaitForKeyPress(L"press a key to continue\n\n");
continue; continue;
} }
@ -1189,7 +1189,7 @@ DeleteBootOptionsContainingFile (
FreePool(BootOption.Variable); FreePool(BootOption.Variable);
} }
DBG("DeleteBootOptionContainingFile: %s\n", strerror(ReturnStatus)); DBG("DeleteBootOptionContainingFile: %s\n", efiStrError(ReturnStatus));
return ReturnStatus; return ReturnStatus;
} }

View File

@ -10,6 +10,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*/ */
#include <Platform.h>
#include "../entry_scan/entry_scan.h" #include "../entry_scan/entry_scan.h"
//#include "device_tree.h" //#include "device_tree.h"
#include "kernel_patcher.h" #include "kernel_patcher.h"

View File

@ -380,10 +380,10 @@ GetSleepImageLocation(IN REFIT_VOLUME *Volume, REFIT_VOLUME **SleepImageVolume,
EFI_STATUS Status = EFI_NOT_FOUND; EFI_STATUS Status = EFI_NOT_FOUND;
UINT8 *PrefBuffer = NULL; UINT8 *PrefBuffer = NULL;
UINTN PrefBufferLen = 0; UINTN PrefBufferLen = 0;
TagStruct* PrefDict; // TagDict* PrefDict;
const TagStruct* dict; // const TagStruct* dict;
const TagStruct* dict2; // const TagStruct* dict2;
const TagStruct* prop; // const TagStruct* prop;
CONST CHAR16 *PrefName = L"\\Library\\Preferences\\SystemConfiguration\\com.apple.PowerManagement.plist"; CONST CHAR16 *PrefName = L"\\Library\\Preferences\\SystemConfiguration\\com.apple.PowerManagement.plist";
CONST CHAR16 *PrefName2 = L"\\Library\\Preferences\\com.apple.PowerManagement.plist"; CONST CHAR16 *PrefName2 = L"\\Library\\Preferences\\com.apple.PowerManagement.plist";
REFIT_VOLUME *ImageVolume = Volume; REFIT_VOLUME *ImageVolume = Volume;
@ -399,31 +399,32 @@ GetSleepImageLocation(IN REFIT_VOLUME *Volume, REFIT_VOLUME **SleepImageVolume,
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
Status = egLoadFile(Volume->RootDir, PrefName2, &PrefBuffer, &PrefBufferLen); Status = egLoadFile(Volume->RootDir, PrefName2, &PrefBuffer, &PrefBufferLen);
if (!EFI_ERROR(Status)) { if (!EFI_ERROR(Status)) {
DBG(" read prefs %ls status=%s\n", PrefName2, strerror(Status)); DBG(" read prefs %ls status=%s\n", PrefName2, efiStrError(Status));
} }
} else { } else {
DBG(" read prefs %ls status=%s\n", PrefName3.wc_str(), strerror(Status)); DBG(" read prefs %ls status=%s\n", PrefName3.wc_str(), efiStrError(Status));
} }
} else { } else {
DBG(" read prefs %ls status=%s\n", PrefName, strerror(Status)); DBG(" read prefs %ls status=%s\n", PrefName, efiStrError(Status));
} }
} }
if (!EFI_ERROR(Status)) { if (!EFI_ERROR(Status)) {
Status = ParseXML((const CHAR8*)PrefBuffer, &PrefDict, (UINT32)PrefBufferLen); TagDict* PrefDict;
Status = ParseXML((const CHAR8*)PrefBuffer, &PrefDict, PrefBufferLen);
if (!EFI_ERROR(Status)) { if (!EFI_ERROR(Status)) {
dict = PrefDict->dictPropertyForKey("Custom Profile"); const TagDict* dict = PrefDict->dictPropertyForKey("Custom Profile");
if (dict) { if (dict) {
dict2 = dict->dictPropertyForKey("AC Power"); const TagDict* dict2 = dict->dictPropertyForKey("AC Power");
if (dict2) { if (dict2) {
prop = dict2->dictPropertyForKey("Hibernate File"); const TagStruct* prop = dict2->propertyForKey("Hibernate File");
if (prop && prop->isString() ) { if (prop && prop->isString() ) {
if (prop->stringValue().contains("/Volumes/")) { if (prop->getString()->stringValue().contains("/Volumes/")) {
CHAR8 *VolNameStart = NULL, *VolNameEnd = NULL; CHAR8 *VolNameStart = NULL, *VolNameEnd = NULL;
XStringW VolName; XStringW VolName;
UINTN VolNameSize = 0; UINTN VolNameSize = 0;
// Extract Volumes Name // Extract Volumes Name
VolNameStart = AsciiStrStr(prop->stringValue().c_str() + 1, "/") + 1; VolNameStart = AsciiStrStr(prop->getString()->stringValue().c_str() + 1, "/") + 1;
if (VolNameStart) { if (VolNameStart) {
VolNameEnd = AsciiStrStr(VolNameStart, "/"); VolNameEnd = AsciiStrStr(VolNameStart, "/");
if (VolNameEnd) { if (VolNameEnd) {
@ -441,10 +442,10 @@ GetSleepImageLocation(IN REFIT_VOLUME *Volume, REFIT_VOLUME **SleepImageVolume,
ImageVolume = Volume; ImageVolume = Volume;
} }
} }
} else if ( prop->stringValue().contains("/var") && !prop->stringValue().contains("private")) { } else if ( prop->getString()->stringValue().contains("/var") && !prop->getString()->stringValue().contains("private")) {
SleepImageName = SWPrintf("\\private%s", prop->stringValue().c_str()); SleepImageName = SWPrintf("\\private%s", prop->getString()->stringValue().c_str());
} else { } else {
SleepImageName = SWPrintf("%s", prop->stringValue().c_str()); SleepImageName = SWPrintf("%s", prop->getString()->stringValue().c_str());
} }
wchar_t* p = SleepImageName.data(0); wchar_t* p = SleepImageName.data(0);
while (*p) { while (*p) {
@ -517,7 +518,7 @@ GetSleepImagePosition (IN REFIT_VOLUME *Volume, REFIT_VOLUME **SleepImageVolume)
// Open sleepimage // Open sleepimage
Status = ImageVolume->RootDir->Open(ImageVolume->RootDir, &File, ImageName.wc_str(), EFI_FILE_MODE_READ, 0); Status = ImageVolume->RootDir->Open(ImageVolume->RootDir, &File, ImageName.wc_str(), EFI_FILE_MODE_READ, 0);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG(" sleepimage not found -> %s\n", strerror(Status)); DBG(" sleepimage not found -> %s\n", efiStrError(Status));
return 0; return 0;
} }
} }
@ -553,7 +554,7 @@ GetSleepImagePosition (IN REFIT_VOLUME *Volume, REFIT_VOLUME **SleepImageVolume)
if (Status == EFI_INVALID_PARAMETER) { if (Status == EFI_INVALID_PARAMETER) {
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
} }
// DBG(" Reading completed -> %s\n", strerror(Status)); // DBG(" Reading completed -> %s\n", efiStrError(Status));
// Close sleepimage // Close sleepimage
File->Close(File); File->Close(File);
@ -564,7 +565,7 @@ GetSleepImagePosition (IN REFIT_VOLUME *Volume, REFIT_VOLUME **SleepImageVolume)
} }
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG(" can not read sleepimage -> %s\n", strerror(Status)); DBG(" can not read sleepimage -> %s\n", efiStrError(Status));
return 0; return 0;
} }
@ -618,7 +619,7 @@ IsSleepImageValidBySleepTime (IN REFIT_VOLUME *Volume)
} }
Status = BlockIo->ReadBlocks(BlockIo, BlockIo->Media->MediaId, 2, BlockIo->Media->BlockSize, Buffer); Status = BlockIo->ReadBlocks(BlockIo, BlockIo->Media->MediaId, 2, BlockIo->Media->BlockSize, Buffer);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG(" can not read HFS+ header -> %s\n", strerror(Status)); DBG(" can not read HFS+ header -> %s\n", efiStrError(Status));
FreePages(Buffer, Pages); FreePages(Buffer, Pages);
return FALSE; return FALSE;
} }
@ -945,7 +946,7 @@ IsOsxHibernated (IN LOADER_ENTRY *Entry)
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
Size , Value); Size , Value);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG(" can not write boot-image -> %s\n", strerror(Status)); DBG(" can not write boot-image -> %s\n", efiStrError(Status));
ret = FALSE; ret = FALSE;
} }
} }
@ -1023,7 +1024,7 @@ PrepareHibernation (IN REFIT_VOLUME *Volume)
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
Size , BootImageDevPath); Size , BootImageDevPath);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG(" can not write boot-image -> %s\n", strerror(Status)); DBG(" can not write boot-image -> %s\n", efiStrError(Status));
return FALSE; return FALSE;
} }
} }
@ -1031,7 +1032,7 @@ PrepareHibernation (IN REFIT_VOLUME *Volume)
// now we should delete boot0082 to do hibernate only once // now we should delete boot0082 to do hibernate only once
Status = DeleteBootOption(0x82); Status = DeleteBootOption(0x82);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG("Options 0082 was not deleted: %s\n", strerror(Status)); DBG("Options 0082 was not deleted: %s\n", efiStrError(Status));
} }
// //
@ -1066,7 +1067,7 @@ PrepareHibernation (IN REFIT_VOLUME *Volume)
// Prior to 10.13.6. // Prior to 10.13.6.
// //
Status = GetVariable2 (L"IOHibernateRTCVariables", &gEfiAppleBootGuid, &Value, &Size); Status = GetVariable2 (L"IOHibernateRTCVariables", &gEfiAppleBootGuid, &Value, &Size);
DBG("get IOHR variable status=%s, size=%llu, RTC info=%d\n", strerror(Status), Size, HasHibernateInfoInRTC); DBG("get IOHR variable status=%s, size=%llu, RTC info=%d\n", efiStrError(Status), Size, HasHibernateInfoInRTC);
if (!HasHibernateInfo && !EFI_ERROR(Status) && Size == sizeof (RtcVars)) { if (!HasHibernateInfo && !EFI_ERROR(Status) && Size == sizeof (RtcVars)) {
CopyMem(RtcRawVars, Value, sizeof (RtcVars)); CopyMem(RtcRawVars, Value, sizeof (RtcVars));
HasHibernateInfo = (RtcVars.signature[0] == 'A' && RtcVars.signature[1] == 'A' && HasHibernateInfo = (RtcVars.signature[0] == 'A' && RtcVars.signature[1] == 'A' &&
@ -1171,7 +1172,7 @@ PrepareHibernation (IN REFIT_VOLUME *Volume)
} }
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG(" can not write boot-switch-vars -> %s\n", strerror(Status)); DBG(" can not write boot-switch-vars -> %s\n", efiStrError(Status));
return FALSE; return FALSE;
} }

View File

@ -178,7 +178,7 @@ DisconnectVga ( VOID )
// disconnect VGA // disconnect VGA
DBG("Disonnecting VGA\n"); DBG("Disonnecting VGA\n");
Status = gBS->DisconnectController(Handles[Index], NULL, NULL); Status = gBS->DisconnectController(Handles[Index], NULL, NULL);
DBG("disconnect %s", strerror(Status)); DBG("disconnect %s", efiStrError(Status));
} }
} }
} }

View File

@ -225,7 +225,7 @@ EFI_STATUS BiosReadSectorsFromDrive(UINT8 DriveNum, UINT64 Lba, UINTN NumSectors
LegacyBiosInt86(0x13, &Regs); LegacyBiosInt86(0x13, &Regs);
Status = EFI_NOT_FOUND; Status = EFI_NOT_FOUND;
} }
DBG("LegacyBiosInt86 status=%s, AH=%hhX\n", strerror(Status), Regs.H.AH); DBG("LegacyBiosInt86 status=%s, AH=%hhX\n", efiStrError(Status), Regs.H.AH);
return Status; return Status;
} }
@ -337,7 +337,7 @@ EFI_STATUS bootElTorito(REFIT_VOLUME* volume)
Status = pBlockIO->ReadBlocks(pBlockIO, pBlockIO->Media->MediaId, 0x11, 2048, sectorBuffer); Status = pBlockIO->ReadBlocks(pBlockIO, pBlockIO->Media->MediaId, 0x11, 2048, sectorBuffer);
} }
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG("CDROMBoot: Unable to read block %X: %s\n", 0x11, strerror(Status)); DBG("CDROMBoot: Unable to read block %X: %s\n", 0x11, efiStrError(Status));
return Status; return Status;
} }
} }
@ -351,7 +351,7 @@ EFI_STATUS bootElTorito(REFIT_VOLUME* volume)
lba = sectorBuffer[0x47] + sectorBuffer[0x48] * 256 + sectorBuffer[0x49] * 65536 + sectorBuffer[0x4A] * 16777216; lba = sectorBuffer[0x47] + sectorBuffer[0x48] * 256 + sectorBuffer[0x49] * 65536 + sectorBuffer[0x4A] * 16777216;
Status = pBlockIO->ReadBlocks(pBlockIO, pBlockIO->Media->MediaId, lba, 2048, sectorBuffer); Status = pBlockIO->ReadBlocks(pBlockIO, pBlockIO->Media->MediaId, lba, 2048, sectorBuffer);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG("CDROMBoot: Unable to read block %llX: %s\n", lba, strerror(Status)); DBG("CDROMBoot: Unable to read block %llX: %s\n", lba, efiStrError(Status));
return Status; return Status;
} }
@ -393,7 +393,7 @@ EFI_STATUS bootElTorito(REFIT_VOLUME* volume)
// Read the boot sectors into the boot load address // Read the boot sectors into the boot load address
Status = pBlockIO->ReadBlocks(pBlockIO, pBlockIO->Media->MediaId, lba, bootSize, addrToPointer(bootLoadAddress)); Status = pBlockIO->ReadBlocks(pBlockIO, pBlockIO->Media->MediaId, lba, bootSize, addrToPointer(bootLoadAddress));
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG("CDROMBoot: Unable to read block %llu: %s\n", lba, strerror(Status)); DBG("CDROMBoot: Unable to read block %llu: %s\n", lba, efiStrError(Status));
return Status; return Status;
} }
@ -500,7 +500,7 @@ EFI_STATUS bootMBR(REFIT_VOLUME* volume)
// Read the MBR // Read the MBR
Status = pDisk->ReadBlocks(pDisk, pDisk->Media->MediaId, 0, 512, pMBR); Status = pDisk->ReadBlocks(pDisk, pDisk->Media->MediaId, 0, 512, pMBR);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG("HDBoot: Unable to read MBR: %s\n", strerror(Status)); DBG("HDBoot: Unable to read MBR: %s\n", efiStrError(Status));
return Status; return Status;
} }
@ -570,7 +570,7 @@ EFI_STATUS bootMBR(REFIT_VOLUME* volume)
// Read the boot sector // Read the boot sector
Status = pDisk->ReadBlocks(pDisk, pDisk->Media->MediaId, activePartition->StartLBA, 512, pBootSector); Status = pDisk->ReadBlocks(pDisk, pDisk->Media->MediaId, activePartition->StartLBA, 512, pBootSector);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG("HDBoot: Unable to read partition %d's boot sector: %s\n", partitionIndex, strerror(Status)); DBG("HDBoot: Unable to read partition %d's boot sector: %s\n", partitionIndex, efiStrError(Status));
Status = EFI_NOT_FOUND; Status = EFI_NOT_FOUND;
return Status; return Status;
} }
@ -774,7 +774,7 @@ EFI_STATUS bootPBR(REFIT_VOLUME* volume, BOOLEAN SataReset)
// get EfiLegacy8259Protocol - mandatory // get EfiLegacy8259Protocol - mandatory
// //
Status = gBS->LocateProtocol(&gEfiLegacy8259ProtocolGuid, NULL, (VOID**)&gLegacy8259); Status = gBS->LocateProtocol(&gEfiLegacy8259ProtocolGuid, NULL, (VOID**)&gLegacy8259);
DBG("EfiLegacy8259ProtocolGuid: %s\n", strerror(Status)); DBG("EfiLegacy8259ProtocolGuid: %s\n", efiStrError(Status));
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
return Status; return Status;
} }
@ -787,16 +787,16 @@ EFI_STATUS bootPBR(REFIT_VOLUME* volume, BOOLEAN SataReset)
// get EfiLegacyBiosProtocol - optional // get EfiLegacyBiosProtocol - optional
// //
Status = gBS->LocateProtocol(&gEfiLegacyBiosProtocolGuid, NULL, (VOID**)&LegacyBios); Status = gBS->LocateProtocol(&gEfiLegacyBiosProtocolGuid, NULL, (VOID**)&LegacyBios);
DBG("EfiLegacyBiosProtocolGuid: %s\n", strerror(Status)); DBG("EfiLegacyBiosProtocolGuid: %s\n", efiStrError(Status));
if (!EFI_ERROR(Status)) { if (!EFI_ERROR(Status)) {
// //
// call PrepareToBootEfi() to init BIOS drives // call PrepareToBootEfi() to init BIOS drives
// //
//Status = LegacyBios->GetBbsInfo(LegacyBios, &HddCount, &HddInfo, &BbsCount, &BbsTable); //Status = LegacyBios->GetBbsInfo(LegacyBios, &HddCount, &HddInfo, &BbsCount, &BbsTable);
//DBG("GetBbsInfo = %s, HddCnt=%d, HddInfo=%p, BbsCount=%d, BbsTabl%p\n", strerror(Status), HddCount, HddInfo, BbsCount, BbsTable); //DBG("GetBbsInfo = %s, HddCnt=%d, HddInfo=%p, BbsCount=%d, BbsTabl%p\n", efiStrError(Status), HddCount, HddInfo, BbsCount, BbsTable);
Status = LegacyBios->PrepareToBootEfi(LegacyBios, &BbsCount, &BbsTable); Status = LegacyBios->PrepareToBootEfi(LegacyBios, &BbsCount, &BbsTable);
DBG("PrepareToBootEfi = %s, BbsCount=%d, BbsTabl%p\n", strerror(Status), BbsCount, BbsTable); DBG("PrepareToBootEfi = %s, BbsCount=%d, BbsTabl%p\n", efiStrError(Status), BbsCount, BbsTable);
//PauseForKey(L"continue ...\n"); //PauseForKey(L"continue ...\n");
// //
@ -1055,7 +1055,7 @@ EFI_STATUS bootLegacyBiosDefault(IN UINT16 LegacyBiosDefaultEntry)
// get EfiLegacyBiosProtocol - optional // get EfiLegacyBiosProtocol - optional
// //
Status = gBS->LocateProtocol(&gEfiLegacyBiosProtocolGuid, NULL, (VOID**)&LegacyBios); Status = gBS->LocateProtocol(&gEfiLegacyBiosProtocolGuid, NULL, (VOID**)&LegacyBios);
DBG("EfiLegacyBiosProtocolGuid: %s\n", strerror(Status)); DBG("EfiLegacyBiosProtocolGuid: %s\n", efiStrError(Status));
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
return Status; return Status;
} }
@ -1079,7 +1079,7 @@ EFI_STATUS bootLegacyBiosDefault(IN UINT16 LegacyBiosDefaultEntry)
BbsDPN = (BBS_BBS_DEVICE_PATH *) CreateDeviceNode(BBS_DEVICE_PATH, BBS_BBS_DP, sizeof(BBS_BBS_DEVICE_PATH)); BbsDPN = (BBS_BBS_DEVICE_PATH *) CreateDeviceNode(BBS_DEVICE_PATH, BBS_BBS_DP, sizeof(BBS_BBS_DEVICE_PATH));
BbsDPN->DeviceType = BBS_TYPE_HARDDRIVE; // BBS_TYPE_CDROM; BbsDPN->DeviceType = BBS_TYPE_HARDDRIVE; // BBS_TYPE_CDROM;
BbsDPN->StatusFlag = 0; BbsDPN->StatusFlag = 0;
BbsDPN->stringValue()[0] = '\0'; BbsDPN->getString()->stringValue()[0] = '\0';
// appends end-of-device-path node and returns complete DP // appends end-of-device-path node and returns complete DP
BbsDP = (BBS_BBS_DEVICE_PATH *) AppendDevicePathNode(NULL, (EFI_DEVICE_PATH_PROTOCOL *) BbsDPN); BbsDP = (BBS_BBS_DEVICE_PATH *) AppendDevicePathNode(NULL, (EFI_DEVICE_PATH_PROTOCOL *) BbsDPN);
@ -1090,7 +1090,7 @@ EFI_STATUS bootLegacyBiosDefault(IN UINT16 LegacyBiosDefaultEntry)
// do boot from default MBR hard disk // do boot from default MBR hard disk
// //
Status = LegacyBios->LegacyBoot(LegacyBios, BbsDP, 0, NULL); Status = LegacyBios->LegacyBoot(LegacyBios, BbsDP, 0, NULL);
DBG("LegacyBios->LegacyBoot(): %s\n", strerror(Status)); DBG("LegacyBios->LegacyBoot(): %s\n", efiStrError(Status));
return Status; return Status;
} }

View File

@ -26,7 +26,7 @@
extern XObjArray<REFIT_VOLUME> Volumes; extern XObjArray<REFIT_VOLUME> Volumes;
// for saving nvram.plist and it's data // for saving nvram.plist and it's data
TagStruct* gNvramDict; TagDict* gNvramDict;
// //
// vars filled after call to GetEfiBootDeviceFromNvram () // vars filled after call to GetEfiBootDeviceFromNvram ()
@ -208,11 +208,11 @@ SetNvramVariable (
// not the same - delete previous one if attributes are different // not the same - delete previous one if attributes are different
if (OldAttributes != Attributes) { if (OldAttributes != Attributes) {
DeleteNvramVariable (VariableName, VendorGuid); DeleteNvramVariable (VariableName, VendorGuid);
//DBG(", diff. attr: deleting old (%s)", strerror(Status)); //DBG(", diff. attr: deleting old (%s)", efiStrError(Status));
} }
} }
//DBG("\n"); // for debug without Status //DBG("\n"); // for debug without Status
//DBG(" -> writing new (%s)\n", strerror(Status)); //DBG(" -> writing new (%s)\n", efiStrError(Status));
//return Status; //return Status;
return gRT->SetVariable(VariableName, VendorGuid, Attributes, DataSize, (VOID*)Data); // CONST missing in EFI_SET_VARIABLE->SetVariable return gRT->SetVariable(VariableName, VendorGuid, Attributes, DataSize, (VOID*)Data); // CONST missing in EFI_SET_VARIABLE->SetVariable
@ -247,7 +247,7 @@ AddNvramVariable (
{ {
// set new value // set new value
return gRT->SetVariable(VariableName, VendorGuid, Attributes, DataSize, Data); return gRT->SetVariable(VariableName, VendorGuid, Attributes, DataSize, Data);
// DBG(" -> writing new (%s)\n", strerror(Status)); // DBG(" -> writing new (%s)\n", efiStrError(Status));
} else { } else {
FreePool(OldData); FreePool(OldData);
return EFI_ABORTED; return EFI_ABORTED;
@ -276,7 +276,7 @@ DeleteNvramVariable (
// Delete: attributes and data size = 0 // Delete: attributes and data size = 0
Status = gRT->SetVariable (VariableName, VendorGuid, 0, 0, NULL); Status = gRT->SetVariable (VariableName, VendorGuid, 0, 0, NULL);
//DBG("DeleteNvramVariable (%ls, guid = %s):\n", VariableName, strerror(Status)); //DBG("DeleteNvramVariable (%ls, guid = %s):\n", VariableName, efiStrError(Status));
return Status; return Status;
} }
@ -382,7 +382,7 @@ ResetNativeNvram ()
//DBG("OK\n"); //DBG("OK\n");
Restart = TRUE; Restart = TRUE;
} else { } else {
//DBG("FAIL (%s)\n", strerror(Status)); //DBG("FAIL (%s)\n", efiStrError(Status));
break; break;
} }
} }
@ -521,7 +521,7 @@ GetSmcKeys (BOOLEAN WriteToSMC)
Status = gAppleSmc->SmcAddKey(gAppleSmc, KeyFromName(Name), (SMC_DATA_SIZE)DataSize, TypeFromName(Name), 0xC0); Status = gAppleSmc->SmcAddKey(gAppleSmc, KeyFromName(Name), (SMC_DATA_SIZE)DataSize, TypeFromName(Name), 0xC0);
if (!EFI_ERROR(Status)) { if (!EFI_ERROR(Status)) {
Status = gAppleSmc->SmcWriteValue(gAppleSmc, KeyFromName(Name), (SMC_DATA_SIZE)DataSize, Data); Status = gAppleSmc->SmcWriteValue(gAppleSmc, KeyFromName(Name), (SMC_DATA_SIZE)DataSize, Data);
// DBG("Write to AppleSMC status=%s\n", strerror(Status)); // DBG("Write to AppleSMC status=%s\n", efiStrError(Status));
} }
NumKey++; NumKey++;
} }
@ -904,7 +904,7 @@ LoadNvramPlist(
// //
// parse it into gNvramDict // parse it into gNvramDict
// //
Status = ParseXML((const CHAR8*)NvramPtr, &gNvramDict, (UINT32)Size); Status = ParseXML((const CHAR8*)NvramPtr, &gNvramDict, Size);
// if(Status != EFI_SUCCESS) { // if(Status != EFI_SUCCESS) {
// DBG(" parsing error\n"); // DBG(" parsing error\n");
// } // }
@ -971,7 +971,7 @@ LoadLatestNvramPlist()
// DBG(" - no nvram.plist - skipping!\n"); // DBG(" - no nvram.plist - skipping!\n");
continue; continue;
} }
// DBG(" Status=%s\n", strerror(Status)); // DBG(" Status=%s\n", efiStrError(Status));
if (GlobalConfig.FastBoot) { if (GlobalConfig.FastBoot) {
VolumeWithLatestNvramPlist = Volume; VolumeWithLatestNvramPlist = Volume;
break; break;
@ -1018,7 +1018,7 @@ LoadLatestNvramPlist()
// else { // else {
// DBG(" nvram.plist not found!\n"); // DBG(" nvram.plist not found!\n");
// } // }
DBG("loaded Status=%s\n", strerror(Status)); DBG("loaded Status=%s\n", efiStrError(Status));
return Status; return Status;
} }
@ -1050,9 +1050,9 @@ PutNvramPlistToRtVars ()
size_t count = gNvramDict->dictKeyCount(); // ok size_t count = gNvramDict->dictKeyCount(); // ok
for (size_t tagIdx = 0 ; tagIdx < count ; tagIdx++ ) for (size_t tagIdx = 0 ; tagIdx < count ; tagIdx++ )
{ {
const TagStruct* keyTag; const TagKey* keyTag;
const TagStruct* valueTag; const TagStruct* valueTag;
if ( EFI_ERROR(gNvramDict->dictKeyAndValueAtIndex(tagIdx, &keyTag, &valueTag)) ) { //If GetKeyValueAtIndex return success, key and value != NULL if ( EFI_ERROR(gNvramDict->getKeyAndValueAtIndex(tagIdx, &keyTag, &valueTag)) ) { //If GetKeyValueAtIndex return success, key and value != NULL
MsgLog("MALFORMED PLIST nvram.plist. A key is expected at pos : %zu\n", tagIdx); MsgLog("MALFORMED PLIST nvram.plist. A key is expected at pos : %zu\n", tagIdx);
continue; continue;
} }
@ -1104,17 +1104,17 @@ PutNvramPlistToRtVars ()
if (valueTag->isString()) { if (valueTag->isString()) {
// <string> element // <string> element
Value = (void*)valueTag->stringValue().c_str(); Value = (void*)valueTag->getString()->stringValue().c_str();
Size = valueTag->stringValue().length(); Size = valueTag->getString()->stringValue().length();
if (!GlobalConfig.DebugLog) { if (!GlobalConfig.DebugLog) {
DBG("String: Size = %zu, Val = '%s'\n", Size, valueTag->stringValue().c_str()); DBG("String: Size = %zu, Val = '%s'\n", Size, valueTag->getString()->stringValue().c_str());
} }
} else if (valueTag->isData()) { } else if (valueTag->isData()) {
// <data> element // <data> element
Size = valueTag->dataLenValue(); Size = valueTag->getData()->getData()->dataLenValue();
Value = valueTag->dataValue(); Value = valueTag->getData()->getData()->dataValue();
if (!GlobalConfig.DebugLog) { if (!GlobalConfig.DebugLog) {
DBG("Size = %zu, Data: ", Size); DBG("Size = %zu, Data: ", Size);
for (size_t i = 0; i < Size; i++) { for (size_t i = 0; i < Size; i++) {
@ -1461,14 +1461,14 @@ RemoveStartupDiskVolume ()
// DBG("RemoveStartupDiskVolume:\n"); // DBG("RemoveStartupDiskVolume:\n");
/*Status =*/ DeleteNvramVariable (L"efi-boot-device", &gEfiAppleBootGuid); /*Status =*/ DeleteNvramVariable (L"efi-boot-device", &gEfiAppleBootGuid);
// DBG(" * efi-boot-device = %s\n", strerror(Status)); // DBG(" * efi-boot-device = %s\n", efiStrError(Status));
/*Status =*/ DeleteNvramVariable (L"efi-boot-device-data", &gEfiAppleBootGuid); /*Status =*/ DeleteNvramVariable (L"efi-boot-device-data", &gEfiAppleBootGuid);
// DBG(" * efi-boot-device-data = %s\n", strerror(Status)); // DBG(" * efi-boot-device-data = %s\n", efiStrError(Status));
/*Status =*/ DeleteNvramVariable (L"BootCampHD", &gEfiAppleBootGuid); /*Status =*/ DeleteNvramVariable (L"BootCampHD", &gEfiAppleBootGuid);
// DBG(" * BootCampHD = %s\n", strerror(Status)); // DBG(" * BootCampHD = %s\n", efiStrError(Status));
// DBG("Removed efi-boot-device-data variable: %s\n", strerror(Status)); // DBG("Removed efi-boot-device-data variable: %s\n", efiStrError(Status));
} }

View File

@ -126,7 +126,7 @@ OurPlatformDriverLoaded (
EFI_OPEN_PROTOCOL_GET_PROTOCOL); EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG(" CompName %s\n", strerror(Status)); DBG(" CompName %s\n", efiStrError(Status));
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
Status = CompName->GetDriverName(CompName, "eng", &DriverName); Status = CompName->GetDriverName(CompName, "eng", &DriverName);
@ -222,7 +222,7 @@ VOID RegisterDriversToHighestPriority(IN EFI_HANDLE *PriorityDrivers)
&mOurPlatformDriverOverrideProtocol, &mOurPlatformDriverOverrideProtocol,
NULL NULL
); );
DBG("%s\n", strerror(Status)); DBG("%s\n", efiStrError(Status));
return; return;
} }

View File

@ -21,7 +21,7 @@ extern "C" {
#include "../../cpp_foundation/XString.h" #include "../../cpp_foundation/XString.h"
static XString8 stdio_static_buf = XString8().takeValueFrom("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX "); // prealloc stdio_static_buf. It has to be at least 2 chars because of 'while ( n > size - 2 )' in strguid and strerror static XString8 stdio_static_buf = XString8().takeValueFrom("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX "); // prealloc stdio_static_buf. It has to be at least 2 chars because of 'while ( n > size - 2 )' in strguid and efiStrError
// = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX "_XS8 won't work because allocatedSize() will stay 0 // = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX "_XS8 won't work because allocatedSize() will stay 0
static XStringW stdio_static_wbuf; static XStringW stdio_static_wbuf;
@ -44,7 +44,7 @@ int printf(const char* format, ...)
} }
const char* strerror(EFI_STATUS Status) const char* efiStrError(EFI_STATUS Status)
{ {
size_t size = stdio_static_buf.allocatedSize(); size_t size = stdio_static_buf.allocatedSize();
UINTN n = 0; UINTN n = 0;

View File

@ -13,9 +13,8 @@ int vprintf(const char* format, VA_LIST ap);
int printf(const char* format, ...) __attribute__((format(printf, 1, 2))); int printf(const char* format, ...) __attribute__((format(printf, 1, 2)));
//int snprintf(char* str, size_t size, const char* format, ...) __attribute__((format(printf, 1, 2)));; //int snprintf(char* str, size_t size, const char* format, ...) __attribute__((format(printf, 1, 2)));
const char* efiStrError(EFI_STATUS errnum);
const char* strerror(EFI_STATUS errnum);
const char* strguid(EFI_GUID* guid); const char* strguid(EFI_GUID* guid);

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@
#define HEIGHT_2K 1100 #define HEIGHT_2K 1100
#include "../gui/menu_items/menu_items.h" #include "../gui/menu_items/menu_items.h"
#include "../Platform/plist.h" #include "../Platform/plist/plist.h"
//class TagStruct; //class TagStruct;
//// SysVariables //// SysVariables
@ -738,7 +738,7 @@ extern UINT16 gBacklightLevel;
//extern BOOLEAN defDSM; //extern BOOLEAN defDSM;
//extern UINT16 dropDSM; //extern UINT16 dropDSM;
extern TagStruct* gConfigDict[]; extern TagDict* gConfigDict[];
// ACPI/PATCHED/AML // ACPI/PATCHED/AML
extern ACPI_PATCHED_AML *ACPIPatchedAML; extern ACPI_PATCHED_AML *ACPIPatchedAML;
@ -890,14 +890,11 @@ GetRootUUID (
EFI_STATUS EFI_STATUS
GetEarlyUserSettings ( GetEarlyUserSettings (
IN EFI_FILE *RootDir, IN EFI_FILE *RootDir,
const TagStruct* CfgDict const TagDict* CfgDict
); );
EFI_STATUS EFI_STATUS
GetUserSettings ( GetUserSettings (const TagDict* CfgDict);
IN EFI_FILE *RootDir,
const TagStruct* CfgDict
);
EFI_STATUS EFI_STATUS
InitTheme ( InitTheme (
@ -922,7 +919,7 @@ InjectKextsFromDir (
VOID VOID
ParseLoadOptions ( ParseLoadOptions (
OUT XStringW* ConfName, OUT XStringW* ConfName,
OUT TagStruct** Dict OUT TagDict** Dict
); );
EFI_STATUS EFI_STATUS
@ -948,12 +945,12 @@ EFI_STATUS
LoadUserSettings ( LoadUserSettings (
IN EFI_FILE *RootDir, IN EFI_FILE *RootDir,
const XStringW& ConfName, const XStringW& ConfName,
TagStruct** dict TagDict** dict
); );
VOID VOID
ParseSMBIOSSettings ( ParseSMBIOSSettings (
const TagStruct* dictPointer const TagDict* dictPointer
); );
//BOOLEAN //BOOLEAN
@ -961,4 +958,6 @@ ParseSMBIOSSettings (
// IN CONST KERNEL_AND_KEXT_PATCHES *Src); // IN CONST KERNEL_AND_KEXT_PATCHES *Src);
void testConfigPlist();
#endif #endif

View File

@ -88,7 +88,7 @@ StartupSoundPlay(EFI_FILE *Dir, CONST CHAR16* SoundFile)
if (SoundFile) { if (SoundFile) {
Status = egLoadFile(Dir, SoundFile, &FileData, &FileDataLength); Status = egLoadFile(Dir, SoundFile, &FileData, &FileDataLength);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
// DBG("file sound read: %ls %s\n", SoundFile, strerror(Status)); // DBG("file sound read: %ls %s\n", SoundFile, efiStrError(Status));
goto DONE_ERROR; goto DONE_ERROR;
} }
} else { } else {
@ -100,7 +100,7 @@ StartupSoundPlay(EFI_FILE *Dir, CONST CHAR16* SoundFile)
Status = WaveGetFileData(FileData, (UINT32)FileDataLength, &WaveData); // Status = WaveGetFileData(FileData, (UINT32)FileDataLength, &WaveData); //
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
MsgLog(" wrong sound file, wave status=%s\n", strerror(Status)); MsgLog(" wrong sound file, wave status=%s\n", efiStrError(Status));
//if error then data not allocated //if error then data not allocated
goto DONE_ERROR; goto DONE_ERROR;
} }
@ -213,24 +213,24 @@ StartupSoundPlay(EFI_FILE *Dir, CONST CHAR16* SoundFile)
Status = AudioIo->SetupPlayback(AudioIo, (UINT8)(AudioList[OutputIndex].Index), OutputVolume, Status = AudioIo->SetupPlayback(AudioIo, (UINT8)(AudioList[OutputIndex].Index), OutputVolume,
freq, bits, (UINT8)(WaveData.Format->Channels)); freq, bits, (UINT8)(WaveData.Format->Channels));
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
MsgLog("StartupSound: Error setting up playback: %s\n", strerror(Status)); MsgLog("StartupSound: Error setting up playback: %s\n", efiStrError(Status));
goto DONE_ERROR; goto DONE_ERROR;
} }
// DBG("playback set\n"); // DBG("playback set\n");
// Start playback. // Start playback.
if (gSettings.PlayAsync) { if (gSettings.PlayAsync) {
Status = AudioIo->StartPlaybackAsync(AudioIo, WaveData.Samples, WaveData.SamplesLength, 0, NULL, NULL); Status = AudioIo->StartPlaybackAsync(AudioIo, WaveData.Samples, WaveData.SamplesLength, 0, NULL, NULL);
// DBG("async started, status=%s\n", strerror(Status)); // DBG("async started, status=%s\n", efiStrError(Status));
} else { } else {
Status = AudioIo->StartPlayback(AudioIo, WaveData.Samples, WaveData.SamplesLength, 0); Status = AudioIo->StartPlayback(AudioIo, WaveData.Samples, WaveData.SamplesLength, 0);
// DBG("sync started, status=%s\n", strerror(Status)); // DBG("sync started, status=%s\n", efiStrError(Status));
// if (!EFI_ERROR(Status)) { // if (!EFI_ERROR(Status)) {
// FreePool(TempData); // FreePool(TempData);
// } // }
} }
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
MsgLog("StartupSound: Error starting playback: %s\n", strerror(Status)); MsgLog("StartupSound: Error starting playback: %s\n", efiStrError(Status));
} }
DONE_ERROR: DONE_ERROR:
@ -244,7 +244,7 @@ DONE_ERROR:
// and we can't free memory up to stop AsyncPlay // and we can't free memory up to stop AsyncPlay
FreeAlignedPages(WaveData.Samples, EFI_SIZE_TO_PAGES(WaveData.SamplesLength + 4095)); FreeAlignedPages(WaveData.Samples, EFI_SIZE_TO_PAGES(WaveData.SamplesLength + 4095));
} }
DBG("sound play end with status=%s\n", strerror(Status)); DBG("sound play end with status=%s\n", efiStrError(Status));
return Status; return Status;
} }
@ -274,7 +274,7 @@ GetStoredOutput()
// Get Audio I/O protocols. // Get Audio I/O protocols.
Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiAudioIoProtocolGuid, NULL, &AudioIoHandleCount, &AudioIoHandles); Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiAudioIoProtocolGuid, NULL, &AudioIoHandleCount, &AudioIoHandles);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
MsgLog("No AudioIoProtocol, status=%s\n", strerror(Status)); MsgLog("No AudioIoProtocol, status=%s\n", efiStrError(Status));
goto DONE; goto DONE;
} }
DBG("found %llu handles with audio\n", AudioIoHandleCount); DBG("found %llu handles with audio\n", AudioIoHandleCount);
@ -335,7 +335,7 @@ GetStoredOutput()
Status = gRT->GetVariable(BOOT_CHIME_VAR_INDEX, &gBootChimeVendorVariableGuid, NULL, Status = gRT->GetVariable(BOOT_CHIME_VAR_INDEX, &gBootChimeVendorVariableGuid, NULL,
&OutputPortIndexSize, &OutputPortIndex); &OutputPortIndexSize, &OutputPortIndex);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
MsgLog("Bad output index, status=%s, set 0\n", strerror(Status)); MsgLog("Bad output index, status=%s, set 0\n", efiStrError(Status));
OutputPortIndex = 0; OutputPortIndex = 0;
} }
} }
@ -424,7 +424,7 @@ VOID GetOutputs()
// Get Audio I/O protocols. // Get Audio I/O protocols.
Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiAudioIoProtocolGuid, NULL, &AudioIoHandleCount, &AudioIoHandles); Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiAudioIoProtocolGuid, NULL, &AudioIoHandleCount, &AudioIoHandles);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
MsgLog("No AudioIoProtocols, status=%s\n", strerror(Status)); MsgLog("No AudioIoProtocols, status=%s\n", efiStrError(Status));
return; return;
} }

View File

@ -23,7 +23,7 @@ void base64_init_decodestate(base64_decodestate* state_in)
state_in->plainchar = 0; state_in->plainchar = 0;
} }
int base64_decode_block(const char* code_in, const int length_in, char* plaintext_out, base64_decodestate* state_in) long base64_decode_block(const char* code_in, const int length_in, char* plaintext_out, base64_decodestate* state_in)
{ {
const char* codechar = code_in; const char* codechar = code_in;
char* plainchar = plaintext_out; char* plainchar = plaintext_out;
@ -41,7 +41,7 @@ int base64_decode_block(const char* code_in, const int length_in, char* plaintex
{ {
state_in->step = step_a; state_in->step = step_a;
state_in->plainchar = *plainchar; state_in->plainchar = *plainchar;
return (int)(plainchar - plaintext_out); return plainchar - plaintext_out;
} }
fragment = base64_decode_value(*codechar++); fragment = base64_decode_value(*codechar++);
} while (fragment < 0); } while (fragment < 0);
@ -52,7 +52,7 @@ int base64_decode_block(const char* code_in, const int length_in, char* plaintex
{ {
state_in->step = step_b; state_in->step = step_b;
state_in->plainchar = *plainchar; state_in->plainchar = *plainchar;
return (int)(plainchar - plaintext_out); return plainchar - plaintext_out;
} }
fragment = base64_decode_value(*codechar++); fragment = base64_decode_value(*codechar++);
} while (fragment < 0); } while (fragment < 0);
@ -64,7 +64,7 @@ int base64_decode_block(const char* code_in, const int length_in, char* plaintex
{ {
state_in->step = step_c; state_in->step = step_c;
state_in->plainchar = *plainchar; state_in->plainchar = *plainchar;
return (int)(plainchar - plaintext_out); return plainchar - plaintext_out;
} }
fragment = base64_decode_value(*codechar++); fragment = base64_decode_value(*codechar++);
} while (fragment < 0); } while (fragment < 0);
@ -76,7 +76,7 @@ int base64_decode_block(const char* code_in, const int length_in, char* plaintex
{ {
state_in->step = step_d; state_in->step = step_d;
state_in->plainchar = *plainchar; state_in->plainchar = *plainchar;
return (int)(plainchar - plaintext_out); return plainchar - plaintext_out;
} }
fragment = base64_decode_value(*codechar++); fragment = base64_decode_value(*codechar++);
} while (fragment < 0); } while (fragment < 0);
@ -84,7 +84,7 @@ int base64_decode_block(const char* code_in, const int length_in, char* plaintex
} }
} }
/* control should not reach here */ /* control should not reach here */
return (int)(plainchar - plaintext_out); return plainchar - plaintext_out;
} }
@ -95,14 +95,14 @@ int base64_decode_block(const char* code_in, const int length_in, char* plaintex
UINT8 *Base64DecodeClover(IN CONST CHAR8 *EncodedData, OUT UINTN *DecodedSize) UINT8 *Base64DecodeClover(IN CONST CHAR8 *EncodedData, OUT UINTN *DecodedSize)
{ {
UINTN EncodedSize; UINTN EncodedSize;
UINTN DecodedSizeInternal; INTN DecodedSizeInternal;
UINT8 *DecodedData; UINT8 *DecodedData;
base64_decodestate state_in; base64_decodestate state_in;
if (EncodedData == NULL) { if (EncodedData == NULL) {
return NULL; return NULL;
} }
EncodedSize = AsciiStrLen(EncodedData); EncodedSize = strlen(EncodedData);
if (EncodedSize == 0) { if (EncodedSize == 0) {
return NULL; return NULL;
} }
@ -113,7 +113,8 @@ UINT8 *Base64DecodeClover(IN CONST CHAR8 *EncodedData, OUT UINTN *DecodedSize)
DecodedSizeInternal = base64_decode_block(EncodedData, (const int)EncodedSize, (char*) DecodedData, &state_in); DecodedSizeInternal = base64_decode_block(EncodedData, (const int)EncodedSize, (char*) DecodedData, &state_in);
if (DecodedSize != NULL) { if (DecodedSize != NULL) {
*DecodedSize = DecodedSizeInternal; if ( DecodedSizeInternal < 0 ) panic("Base64DecodeClover : DecodedSizeInternal < 0");
*DecodedSize = (UINTN)DecodedSizeInternal;
} }
return DecodedData; return DecodedData;

View File

@ -48,7 +48,7 @@ int base64_decode_value(char value_in);
int base64_decode_block(const char* code_in, const int length_in, char* plaintext_out, base64_decodestate* state_in); long base64_decode_block(const char* code_in, const int length_in, char* plaintext_out, base64_decodestate* state_in);
UINT8 UINT8

View File

@ -101,17 +101,16 @@ CARDLIST* FindCardWithIds(UINT32 Id, UINT32 SubId)
return NULL; return NULL;
} }
VOID FillCardList(const TagStruct* CfgDict) VOID FillCardList(const TagDict* CfgDict)
{ {
if (IsListEmpty(&gCardList) && (CfgDict != NULL)) { if (IsListEmpty(&gCardList) && (CfgDict != NULL)) {
CONST CHAR8 *VEN[] = { "NVIDIA", "ATI" }; CONST CHAR8 *VEN[] = { "NVIDIA", "ATI" };
INTN Index, Count = sizeof(VEN) / sizeof(VEN[0]); size_t Count = sizeof(VEN) / sizeof(VEN[0]);
const TagStruct* prop;
for (Index = 0; Index < Count; Index++) { for (size_t Index = 0; Index < Count; Index++) {
CONST CHAR8 *key = VEN[Index]; CONST CHAR8 *key = VEN[Index];
prop = CfgDict->dictPropertyForKey(key); const TagArray* prop = CfgDict->arrayPropertyForKey(key);
if( prop && prop->isArray() ) { if( prop && prop->isArray() ) {
INTN i; INTN i;
INTN count; INTN count;
@ -131,27 +130,28 @@ VOID FillCardList(const TagStruct* CfgDict)
MsgLog("MALFORMED PLIST in FillCardList() : element is not a dict"); MsgLog("MALFORMED PLIST in FillCardList() : element is not a dict");
continue; continue;
} }
const TagDict* dictElement = element->getDict();
prop2 = element->dictPropertyForKey("Model"); prop2 = dictElement->propertyForKey("Model");
if ( prop2->isString() && prop2->stringValue().notEmpty() ) { if ( prop2->isString() && prop2->getString()->stringValue().notEmpty() ) {
model_name = prop2->stringValue().c_str(); model_name = prop2->getString()->stringValue().c_str();
} else { } else {
model_name = "VideoCard"; model_name = "VideoCard";
} }
prop2 = element->dictPropertyForKey("IOPCIPrimaryMatch"); prop2 = dictElement->propertyForKey("IOPCIPrimaryMatch");
dev_id = (UINT32)GetPropertyAsInteger(prop2, 0); dev_id = (UINT32)GetPropertyAsInteger(prop2, 0);
prop2 = element->dictPropertyForKey("IOPCISubDevId"); prop2 = dictElement->propertyForKey("IOPCISubDevId");
subdev_id = (UINT32)GetPropertyAsInteger(prop2, 0); subdev_id = (UINT32)GetPropertyAsInteger(prop2, 0);
prop2 = element->dictPropertyForKey("VRAM"); prop2 = dictElement->propertyForKey("VRAM");
VramSize = LShiftU64((UINTN)GetPropertyAsInteger(prop2, (INTN)VramSize), 20); //Mb -> bytes VramSize = LShiftU64((UINTN)GetPropertyAsInteger(prop2, (INTN)VramSize), 20); //Mb -> bytes
prop2 = element->dictPropertyForKey("VideoPorts"); prop2 = dictElement->propertyForKey("VideoPorts");
VideoPorts = (UINT16)GetPropertyAsInteger(prop2, VideoPorts); VideoPorts = (UINT16)GetPropertyAsInteger(prop2, VideoPorts);
prop2 = element->dictPropertyForKey("LoadVBios"); prop2 = dictElement->propertyForKey("LoadVBios");
if (prop2 != NULL && IsPropertyNotNullAndTrue(prop2)) { if (prop2 != NULL && IsPropertyNotNullAndTrue(prop2)) {
LoadVBios = TRUE; LoadVBios = TRUE;
} }

View File

@ -8,7 +8,7 @@
#ifndef PLATFORM_CARD_VLIST_H_ #ifndef PLATFORM_CARD_VLIST_H_
#define PLATFORM_CARD_VLIST_H_ #define PLATFORM_CARD_VLIST_H_
#include "../Platform/plist.h" #include "../Platform/plist/plist.h"
typedef struct { typedef struct {
@ -28,7 +28,7 @@ typedef struct {
VOID VOID
FillCardList ( FillCardList (
const TagStruct* CfgDict const TagDict* CfgDict
); );
CARDLIST CARDLIST

View File

@ -109,7 +109,7 @@ UINT32 pci_config_read32(pci_dt_t *PciDt, UINT8 reg)
&res &res
); );
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG("pci_config_read32 failed %s\n", strerror(Status)); DBG("pci_config_read32 failed %s\n", efiStrError(Status));
return 0; return 0;
} }
return res; return res;

View File

@ -11,6 +11,9 @@
#include "../cpp_foundation/XStringArray.h" #include "../cpp_foundation/XStringArray.h"
#include "../cpp_foundation/unicode_conversions.h" #include "../cpp_foundation/unicode_conversions.h"
extern "C" EFI_GUID gEfiMiscSubClassGuid;
/** Returns TRUE is Str is ascii Guid in format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx */ /** Returns TRUE is Str is ascii Guid in format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx */
template <typename T, enable_if( is___String(T) )> template <typename T, enable_if( is___String(T) )>
BOOLEAN IsValidGuidAsciiString(const T& Str) BOOLEAN IsValidGuidAsciiString(const T& Str)

View File

@ -93,21 +93,21 @@ UINT32 HDA_IC_sendVerb(EFI_PCI_IO_PROTOCOL *PciIo, UINT32 codecAdr, UINT32 nodeI
// poll ICS[0] to become 0 // poll ICS[0] to become 0
Status = PciIo->PollMem(PciIo, EfiPciIoWidthUint16, 0/*bar*/, HDA_ICS/*offset*/, 0x1/*mask*/, 0/*value*/, 100000/*delay in 100ns*/, &data64); Status = PciIo->PollMem(PciIo, EfiPciIoWidthUint16, 0/*bar*/, HDA_ICS/*offset*/, 0x1/*mask*/, 0/*value*/, 100000/*delay in 100ns*/, &data64);
ics = (UINT16)(data64 & 0xFFFF); ics = (UINT16)(data64 & 0xFFFF);
//DBG("poll ICS[0] == 0: Status=%s, ICS=%X, ICS[0]=%d\n", strerror(Status), ics, (ics & 0x0001)); //DBG("poll ICS[0] == 0: Status=%s, ICS=%X, ICS[0]=%d\n", efiStrError(Status), ics, (ics & 0x0001));
if (EFI_ERROR(Status)) return 0; if (EFI_ERROR(Status)) return 0;
// prepare and write verb to ICO // prepare and write verb to ICO
data32 = codecAdr << 28 | ((nodeId & 0xFF)<<20) | (verb & 0xFFFFF); data32 = codecAdr << 28 | ((nodeId & 0xFF)<<20) | (verb & 0xFFFFF);
Status = PciIo->Mem.Write(PciIo, EfiPciIoWidthUint32, 0, HDA_ICO, 1, &data32); Status = PciIo->Mem.Write(PciIo, EfiPciIoWidthUint32, 0, HDA_ICO, 1, &data32);
//DBG("ICO write verb Codec=%X, Node=%X, verb=%X, command verb=%X: Status=%s\n", codecAdr, nodeId, verb, data32, strerror(Status)); //DBG("ICO write verb Codec=%X, Node=%X, verb=%X, command verb=%X: Status=%s\n", codecAdr, nodeId, verb, data32, efiStrError(Status));
if (EFI_ERROR(Status)) return 0; if (EFI_ERROR(Status)) return 0;
// write 11b to ICS[1:0] to send command // write 11b to ICS[1:0] to send command
ics |= 0x3; ics |= 0x3;
Status = PciIo->Mem.Write(PciIo, EfiPciIoWidthUint16, 0, HDA_ICS, 1, &ics); Status = PciIo->Mem.Write(PciIo, EfiPciIoWidthUint16, 0, HDA_ICS, 1, &ics);
//DBG("ICS[1:0] = 11b: Status=%s\n", strerror(Status)); //DBG("ICS[1:0] = 11b: Status=%s\n", efiStrError(Status));
if (EFI_ERROR(Status)) return 0; if (EFI_ERROR(Status)) return 0;
// poll ICS[1:0] to become 10b // poll ICS[1:0] to become 10b
Status = PciIo->PollMem(PciIo, EfiPciIoWidthUint16, 0/*bar*/, HDA_ICS/*offset*/, 0x3/*mask*/, 0x2/*value*/, 100000/*delay in 100ns*/, &data64); Status = PciIo->PollMem(PciIo, EfiPciIoWidthUint16, 0/*bar*/, HDA_ICS/*offset*/, 0x3/*mask*/, 0x2/*value*/, 100000/*delay in 100ns*/, &data64);
//DBG("poll ICS[0] == 0: Status=%s\n", strerror(Status)); //DBG("poll ICS[0] == 0: Status=%s\n", efiStrError(Status));
if (EFI_ERROR(Status)) return 0; if (EFI_ERROR(Status)) return 0;
// read IRI for VendorId/DeviceId // read IRI for VendorId/DeviceId
Status = PciIo->Mem.Read(PciIo, EfiPciIoWidthUint32, 0, HDA_IRI, 1, &data32); Status = PciIo->Mem.Read(PciIo, EfiPciIoWidthUint32, 0, HDA_IRI, 1, &data32);

View File

@ -1,8 +1,9 @@
#include <Platform.h> // Only use angled for Platform, else, xcode project won't compile #include <Platform.h> // Only use angled for Platform, else, xcode project won't compile
#include "kext_inject.h" #include "kext_inject.h"
#include "DataHubCpu.h" #include "DataHubCpu.h"
#include "../Platform/plist.h" #include "../Platform/plist/plist.h"
#include "../Platform/Settings.h" #include "../Platform/Settings.h"
#include "../Platform/guid.h"
#ifndef DEBUG_ALL #ifndef DEBUG_ALL
#define KEXT_INJECT_DEBUG 1 #define KEXT_INJECT_DEBUG 1
@ -95,15 +96,15 @@ void toLowerStr(CHAR8 *tstr, IN CONST CHAR8 *str) {
*tstr = '\0'; *tstr = '\0';
} }
BOOLEAN checkOSBundleRequired(UINT8 loaderType, const TagStruct* dict) BOOLEAN checkOSBundleRequired(UINT8 loaderType, const TagDict* dict)
{ {
BOOLEAN inject = TRUE; BOOLEAN inject = TRUE;
const TagStruct* osBundleRequiredTag; const TagStruct* osBundleRequiredTag;
XString8 osbundlerequired; XString8 osbundlerequired;
osBundleRequiredTag = dict->dictPropertyForKey("OSBundleRequired"); osBundleRequiredTag = dict->propertyForKey("OSBundleRequired");
if (osBundleRequiredTag) { if (osBundleRequiredTag) {
osbundlerequired = osBundleRequiredTag->stringValue(); osbundlerequired = osBundleRequiredTag->getString()->stringValue();
osbundlerequired.lowerAscii(); osbundlerequired.lowerAscii();
} }
@ -135,7 +136,7 @@ EFI_STATUS LOADER_ENTRY::LoadKext(IN EFI_FILE *RootDir, IN CONST CHAR16 *FileNam
UINTN bundlePathBufferLength = 0; UINTN bundlePathBufferLength = 0;
XStringW TempName; XStringW TempName;
XStringW Executable; XStringW Executable;
TagStruct* dict = NULL; TagDict* dict = NULL;
const TagStruct* prop = NULL; const TagStruct* prop = NULL;
BOOLEAN NoContents = FALSE; BOOLEAN NoContents = FALSE;
BOOLEAN inject = FALSE; BOOLEAN inject = FALSE;
@ -152,12 +153,12 @@ EFI_STATUS LOADER_ENTRY::LoadKext(IN EFI_FILE *RootDir, IN CONST CHAR16 *FileNam
infoDictBufferLength = 0; infoDictBufferLength = 0;
Status = egLoadFile(RootDir, TempName.wc_str(), &infoDictBuffer, &infoDictBufferLength); Status = egLoadFile(RootDir, TempName.wc_str(), &infoDictBuffer, &infoDictBufferLength);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
MsgLog("Failed to load extra kext : %ls status=%s\n", TempName.wc_str(), strerror(Status)); MsgLog("Failed to load extra kext : %ls status=%s\n", TempName.wc_str(), efiStrError(Status));
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
NoContents = TRUE; NoContents = TRUE;
} }
if( ParseXML((CHAR8*)infoDictBuffer, &dict,(UINT32)infoDictBufferLength)!=0 ) { if( ParseXML((CHAR8*)infoDictBuffer, &dict,infoDictBufferLength)!=0 ) {
FreePool(infoDictBuffer); FreePool(infoDictBuffer);
MsgLog("Failed to load extra kext (failed to parse Info.plist): %ls\n", FileName); MsgLog("Failed to load extra kext (failed to parse Info.plist): %ls\n", FileName);
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
@ -169,10 +170,10 @@ EFI_STATUS LOADER_ENTRY::LoadKext(IN EFI_FILE *RootDir, IN CONST CHAR16 *FileNam
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
prop = dict->dictPropertyForKey("CFBundleExecutable"); prop = dict->propertyForKey("CFBundleExecutable");
if( prop != NULL && prop->isString() && prop->stringValue().notEmpty() ) { if( prop != NULL && prop->isString() && prop->getString()->stringValue().notEmpty() ) {
Executable.takeValueFrom(prop->stringValue()); Executable.takeValueFrom(prop->getString()->stringValue());
// AsciiStrToUnicodeStrS(prop->stringValue(), Executable, 256); // AsciiStrToUnicodeStrS(prop->getString()->stringValue(), Executable, 256);
if (NoContents) { if (NoContents) {
TempName = SWPrintf("%ls\\%ls", FileName, Executable.wc_str()); TempName = SWPrintf("%ls\\%ls", FileName, Executable.wc_str());
// snwprintf(TempName, 512, "%s\\%s", FileName, Executable); // snwprintf(TempName, 512, "%s\\%s", FileName, Executable);

View File

@ -1,309 +0,0 @@
/*
* plist.h
*
* Created on: 31 Mar 2020
* Author: jief
*/
#ifndef PLATFORM_PLIST_H_
#define PLATFORM_PLIST_H_
/* XML Tags */
#define kXMLTagPList "plist"
#define kXMLTagDict "dict"
#define kXMLTagKey "key"
#define kXMLTagString "string"
#define kXMLTagInteger "integer"
#define kXMLTagData "data"
#define kXMLTagDate "date"
#define kXMLTagFalse "false/"
#define kXMLTagTrue "true/"
#define kXMLTagArray "array"
#define kXMLTagReference "reference"
#define kXMLTagID "ID="
#define kXMLTagIDREF "IDREF="
#define kXMLTagFloat "real"
typedef enum {
kTagTypeNone,
kTagTypeDict, // 1
kTagTypeKey, // 2
kTagTypeString, // 3
kTagTypeInteger,// 4
kTagTypeData, // 5
kTagTypeDate, // 6
kTagTypeFalse, // 7
kTagTypeTrue, // 8
kTagTypeArray, // 9
kTagTypeFloat // 10
} TAG_TYPE;
class TagStruct;
extern XObjArray<TagStruct> gTagsFree;
class TagStruct
{
UINTN type; // type is private. Use is...() functions.
XString8 _string;
INTN _intValue;
float _floatValue;
UINT8 *_data;
UINTN _dataLen;
XObjArray<TagStruct> _dictOrArrayContent;
public:
TagStruct() : type(kTagTypeNone), _string(), _intValue(0), _floatValue(0), _data(0), _dataLen(0), _dictOrArrayContent() {}
TagStruct(const TagStruct& other) = delete; // Can be defined if needed
const TagStruct& operator = ( const TagStruct & ) = delete; // Can be defined if needed
~TagStruct() { delete _data; }
static TagStruct* getEmptyTag();
static TagStruct* getEmptyDictTag();
static TagStruct* getEmptyArrayTag();
void FreeTag();
// Property<XString8> string();
bool isDict() const { return type == kTagTypeDict; }
bool isKey() const { return type == kTagTypeKey; }
bool isString() const { return type == kTagTypeString; }
bool isInt() const { return type == kTagTypeInteger; }
bool isFloat() const { return type == kTagTypeFloat; }
bool isBool() const { return type == kTagTypeTrue || type == kTagTypeFalse; }
bool isData() const { return type == kTagTypeData; }
bool isDate() const { return type == kTagTypeDate; }
bool isArray() const { return type == kTagTypeArray; }
const XString8 getTypeAsXString8() const {
if ( isDict() ) return "Dict"_XS8;
if ( isKey() ) return "Key"_XS8;
if ( isString() ) return "String"_XS8;
if ( isInt() ) return "Int"_XS8;
if ( isFloat() ) return "Float"_XS8;
if ( isBool() ) return "Bool"_XS8;
if ( isData() ) return "Data"_XS8;
if ( isDate() ) return "Date"_XS8;
if ( isArray() ) return "Array"_XS8;
panic("Unknown type %lld : this is bug", type);
}
/*
* getters and setters
*/
/* data */
const UINT8* dataValue() const
{
if ( !isData() ) panic("TagStruct::dataValue() : !isData() ");
return _data;
}
UINT8* dataValue()
{
if ( !isData() ) panic("TagStruct::dataValue() : !isData() ");
return _data;
}
// const XString8& dataStringValue()
// {
// if ( !isData() ) panic("TagStruct::dataStringValue() : !isData() ");
// return _string;
// }
UINTN dataLenValue() const
{
if ( !isData() ) panic("TagStruct::dataLenValue() : !isData() ");
return _dataLen;
}
void setDataValue(UINT8* data, UINTN dataLen)
{
if ( data == NULL ) panic("TagStruct::setDataValue() : _data == NULL ");
_data = data;
_dataLen = dataLen;
type = kTagTypeData;
}
/* date */
const XString8& dateValue()
{
if ( !isDict() ) panic("TagStruct::dictValue() : !isDict() ");
return _string;
}
void setDateValue(const XString8& xstring)
{
if ( xstring.isEmpty() ) panic("TagStruct::setDateValue() : xstring.isEmpty() ");
type = kTagTypeDate;
_string = xstring;
}
/* dict */
const XObjArray<TagStruct>& dictContent() const
{
if ( !isDict() ) panic("TagStruct::dictContent() : !isDict() ");
return _dictOrArrayContent;
}
XObjArray<TagStruct>& dictContent()
{
if ( !isDict() ) panic("TagStruct::dictContent() : !isDict() ");
return _dictOrArrayContent;
}
INTN dictKeyCount() const;
EFI_STATUS dictKeyAndValueAtIndex(INTN id, const TagStruct** key, const TagStruct** value) const;
const TagStruct* dictPropertyForKey(const CHAR8* key ) const;
/* array */
const XObjArray<TagStruct>& arrayContent() const
{
if ( isArray() ) return _dictOrArrayContent;
panic("TagStruct::arrayContent() const : !isArray() ");
}
XObjArray<TagStruct>& arrayContent()
{
if ( isArray() ) return _dictOrArrayContent;
panic("TagStruct::arrayContent() : !isDict() && !isArray() ");
}
/* key */
const XString8& keyStringValue() const
{
if ( !isKey() ) panic("TagStruct::keyStringValue() const : !isKey() ");
return _string;
}
XString8& keyStringValue()
{
if ( !isKey() ) panic("TagStruct::keyStringValue() : !isKey() ");
return _string;
}
void setKeyValue(const XString8& xstring)
{
if ( xstring.isEmpty() ) panic("TagStruct::setKeyValue() : xstring.isEmpty() ");
type = kTagTypeKey;
_string = xstring;
}
/* string */
const XString8& stringValue() const
{
if ( !isString() ) panic("TagStruct::stringValue() : !isString() ");
return _string;
}
XString8& stringValue()
{
if ( !isString() ) panic("TagStruct::stringValue() : !isString() ");
return _string;
}
void setStringValue(const XString8& xstring)
{
// empty string is allowed
//if ( xstring.isEmpty() ) panic("TagStruct::setStringValue() : xstring.isEmpty() ");
type = kTagTypeString;
_string = xstring;
}
/* int */
INTN intValue() const
{
if ( !isInt() ) panic("TagStruct::intValue() : !isInt() ");
return _intValue;
}
void setIntValue(INTN i)
{
type = kTagTypeInteger;
_intValue = i;
}
/* float */
float floatValue() const
{
if ( !isFloat() ) panic("TagStruct::floatValue() : !isFloat() ");
return _floatValue;
}
void setFloatValue(float f)
{
type = kTagTypeFloat;
_floatValue = f;
}
/* bool */
INTN boolValue() const
{
if ( !isBool() ) panic("TagStruct::boolValue() : !isBool() ");
return type == kTagTypeTrue;
}
void setBoolValue(bool b)
{
if ( b ) type = kTagTypeTrue;
else type = kTagTypeFalse;
}
// Convenience method
bool isTrue() const
{
if ( isBool() ) return boolValue();
return false;
}
bool isFalse() const
{
if ( isBool() ) return !boolValue();
return false;
}
bool isTrueOrYy() const
{
if ( isBool() ) return boolValue();
if ( isString() && stringValue().notEmpty() && (stringValue()[0] == 'y' || stringValue()[0] == 'Y') ) return true;
return false;
}
bool isTrueOrYes() const
{
if ( isBool() ) return boolValue();
if ( isString() && stringValue().equal("Yes"_XS8) ) return true;
return false;
}
bool isFalseOrNn() const
{
if ( isBool() ) return !boolValue();
if ( isString() && stringValue().notEmpty() && (stringValue()[0] == 'n' || stringValue()[0] == 'N') ) return true;
return false;
}
};
CHAR8*
XMLDecode (
CHAR8 *src
);
EFI_STATUS
ParseXML(
CONST CHAR8 *buffer,
TagStruct* *dict,
UINT32 bufSize
);
EFI_STATUS
GetNextTag (
UINT8 *buffer,
CHAR8 **tag,
UINT32 *start,
UINT32 *length
);
BOOLEAN
IsPropertyNotNullAndTrue(
const TagStruct* Prop
);
BOOLEAN
IsPropertyNotNullAndFalse(
const TagStruct* Prop
);
INTN
GetPropertyAsInteger(
const TagStruct* Prop,
INTN Default
);
float GetPropertyFloat (const TagStruct* Prop, float Default);
#endif /* PLATFORM_PLIST_H_ */

View File

@ -0,0 +1,170 @@
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
* plist.c - plist parsing functions
*
* Copyright (c) 2000-2005 Apple Computer, Inc.
*
* DRI: Josh de Cesare
* code split out from drivers.c by Soren Spies, 2005
*/
#include <Platform.h> // Only use angled for Platform, else, xcode project won't compile
#include "TagArray.h"
#ifndef DEBUG_ALL
#define DEBUG_TagArray 1
#else
#define DEBUG_TagArray DEBUG_ALL
#endif
#if DEBUG_TagArray == 0
#define DBG(...)
#else
#define DBG(...) DebugLog(DEBUG_TagArray, __VA_ARGS__)
#endif
#include "TagArray.h"
XObjArray<TagArray> TagArray::tagsFree;
bool TagArray::operator == (const TagStruct& other) const
{
if ( !other.isArray() ) return false;
if ( _arrayContent.size() != other.getArray()->arrayContent().size() ) {
return false;
}
for (size_t tagIdx = 0 ; tagIdx < _arrayContent.size() ; tagIdx++ ) {
if ( _arrayContent[tagIdx] != other.getArray()->arrayContent()[tagIdx] ) {
return false;
}
}
return true;
}
bool TagArray::debugIsEqual(const TagStruct& other, const XString8& label) const
{
if ( !other.isArray() ) {
MsgLog("counterpart of '%s' is not an array\n", label.c_str());
return false;
}
if ( _arrayContent.size() != other.getArray()->arrayContent().size() ) {
MsgLog("array '%s' is different size\n", label.c_str());
return false;
}
for (size_t tagIdx = 0 ; tagIdx < _arrayContent.size() ; tagIdx++ ) {
if ( !_arrayContent[tagIdx].debugIsEqual(other.getArray()->arrayContent()[tagIdx], label + "/array"_XS8) ) {
return false;
}
}
return true;
}
//UINTN newtagcount = 0;
//UINTN tagcachehit = 0;
TagArray* TagArray::getEmptyTag()
{
TagArray* tag;
if ( tagsFree.size() > 0 ) {
tag = &tagsFree[0];
tagsFree.RemoveWithoutFreeingAtIndex(0);
//tagcachehit++;
//DBG("tagcachehit=%lld\n", tagcachehit);
return tag;
}
tag = new TagArray();
//newtagcount += 1;
//DBG("newtagcount=%lld\n", newtagcount);
return tag;
}
void TagArray::FreeTag()
{
//while ( tagIdx < _dictOrArrayContent.notEmpty() ) {
// _dictOrArrayContent[0].FreeTag();
// _dictOrArrayContent.RemoveWithoutFreeingAtIndex(0);
//}
// this loop is better because removing objects from the end don't do any memory copying.
for (size_t tagIdx = _arrayContent.size() ; tagIdx > 0 ; ) {
tagIdx--;
_arrayContent[tagIdx].FreeTag();
_arrayContent.RemoveWithoutFreeingAtIndex(tagIdx);
}
tagsFree.AddReference(this, true);
}
const TagStruct* TagArray::elementAt(size_t idx) const
{
if ( idx >= _arrayContent.size() ) {
panic("TagArray::elementAt(%zu) -> trying to access element at %zu, but array has only %zu element(s)\n", idx, idx, _arrayContent.size());
}
return &_arrayContent[idx];
}
const TagDict* TagArray::dictElementAt(size_t idx, const XString8& currentTag) const
{
const TagStruct* tag = elementAt(idx);
if ( !tag->isDict() ) {
MsgLog("MALFORMED PLIST in '%s' : TagArray::dictElementAt(%zu) -> trying to get a dict element at %zu, but element is %s\n", currentTag.c_str(), idx, idx, tag->getTypeAsXString8().c_str());
}
return _arrayContent[idx].getDict();
}
const TagArray* TagArray::arrayElementAt(size_t idx, const XString8& currentTag) const
{
const TagStruct* tag = elementAt(idx);
if ( !tag->isArray() ) {
MsgLog("MALFORMED PLIST in '%s' : TagArray::dictElementAt(%zu) -> trying to get a array element at %zu, but element is %s\n", currentTag.c_str(), idx, idx, tag->getTypeAsXString8().c_str());
}
return _arrayContent[idx].getArray();
}
const TagDict* TagArray::dictElementAt(size_t idx) const
{
const TagStruct* tag = elementAt(idx);
if ( !tag->isDict() ) {
MsgLog("MALFORMED PLIST : TagArray::dictElementAt(%zu) -> trying to get a dict element at %zu, but element is %s\n", idx, idx, tag->getTypeAsXString8().c_str());
}
return _arrayContent[idx].getDict();
}
const TagArray* TagArray::arrayElementAt(size_t idx) const
{
const TagStruct* tag = elementAt(idx);
if ( !tag->isArray() ) {
MsgLog("MALFORMED PLIST : TagArray::dictElementAt(%zu) -> trying to get a array element at %zu, but element is %s\n", idx, idx, tag->getTypeAsXString8().c_str());
}
return _arrayContent[idx].getArray();
}
void TagArray::sprintf(unsigned int ident, XString8* s) const
{
for (size_t i = 0 ; i < (size_t)ident ; i++) *s += " ";
*s += "<array>\n"_XS8;
for (size_t i = 0 ; i < _arrayContent.size() ; i++) {
_arrayContent[i].sprintf(ident+8, s);
}
for (size_t i = 0 ; i < (size_t)ident ; i++) *s += " ";
*s += "</array>\n"_XS8;
}

View File

@ -0,0 +1,60 @@
/*
* TagArray.h
*
* Created on: 23 August 2020
* Author: jief
*/
#ifndef __TagArray_h__
#define __TagArray_h__
#include "plist.h"
class TagArray : public TagStruct
{
static XObjArray<TagArray> tagsFree;
XObjArray<TagStruct> _arrayContent;
public:
TagArray() : _arrayContent() {}
TagArray(const TagArray& other) = delete; // Can be defined if needed
const TagArray& operator = (const TagArray&); // Can be defined if needed
virtual ~TagArray() { }
virtual bool operator == (const TagStruct& other) const;
virtual bool debugIsEqual(const TagStruct& other, const XString8& label) const;
virtual TagArray* getArray() { return this; }
virtual const TagArray* getArray() const { return this; }
virtual bool isArray() const { return true; }
virtual const XString8 getTypeAsXString8() const { return "Array"_XS8; }
static TagArray* getEmptyTag();
virtual void FreeTag();
virtual void sprintf(unsigned int ident, XString8* s) const;
/*
* getters and setters
*/
const XObjArray<TagStruct>& arrayContent() const
{
// if ( !isArray() ) panic("TagArray::arrayContent() const : !isArray() ");
return _arrayContent;
}
XObjArray<TagStruct>& arrayContent()
{
// if ( !isArray() ) panic("TagArray::arrayContent() : !isArray() ");
return _arrayContent;
}
const TagStruct* elementAt(size_t idx) const;
const TagDict* dictElementAt(size_t idx) const;
const TagDict* dictElementAt(size_t idx, const XString8& currentTag) const; // currentTag is just for error msg
const TagArray* arrayElementAt(size_t idx) const;
const TagArray* arrayElementAt(size_t idx, const XString8& currentTag) const; // currentTag is just for error msg
};
#endif /* __TagArray_h__ */

View File

@ -0,0 +1,85 @@
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
* plist.c - plist parsing functions
*
* Copyright (c) 2000-2005 Apple Computer, Inc.
*
* DRI: Josh de Cesare
* code split out from drivers.c by Soren Spies, 2005
*/
#include <Platform.h> // Only use angled for Platform, else, xcode project won't compile
#include "TagBool.h"
#ifndef DEBUG_ALL
#define DEBUG_TagBool 1
#else
#define DEBUG_TagBool DEBUG_ALL
#endif
#if DEBUG_TagBool == 0
#define DBG(...)
#else
#define DBG(...) DebugLog(DEBUG_TagBool, __VA_ARGS__)
#endif
#include "TagBool.h"
XObjArray<TagBool> TagBool::tagsFree;
//UINTN newtagcount = 0;
//UINTN tagcachehit = 0;
TagBool* TagBool::getEmptyTag()
{
TagBool* tag;
if ( tagsFree.size() > 0 ) {
tag = &tagsFree[0];
tagsFree.RemoveWithoutFreeingAtIndex(0);
//tagcachehit++;
//DBG("tagcachehit=%lld\n", tagcachehit);
return tag;
}
tag = new TagBool();
//newtagcount += 1;
//DBG("newtagcount=%lld\n", newtagcount);
return tag;
}
void TagBool::FreeTag()
{
value = false;
tagsFree.AddReference(this, true);
}
bool TagBool::operator == (const TagStruct& other) const
{
if ( !other.isBool() ) return false;
return value == other.getBool()->value;
}
void TagBool::sprintf(unsigned int ident, XString8* s) const
{
for (size_t i = 0 ; i < (size_t)ident ; i++) *s += " ";
if ( value ) *s += "<true/>\n"_XS8;
else *s += "<false/>\n"_XS8;
}

View File

@ -0,0 +1,55 @@
/*
* TagBool.h
*
* Created on: 23 August 2020
* Author: jief
*/
#ifndef __TagBool_h__
#define __TagBool_h__
#include "plist.h"
class TagBool : public TagStruct
{
static XObjArray<TagBool> tagsFree;
bool value;
public:
TagBool() : value(false) {}
TagBool(const TagBool& other) = delete; // Can be defined if needed
const TagBool& operator = (const TagBool&); // Can be defined if needed
virtual ~TagBool() { }
virtual bool operator == (const TagStruct& other) const;
virtual TagBool* getBool() { return this; }
virtual const TagBool* getBool() const { return this; }
virtual bool isBool() const { return true; }
virtual const XString8 getTypeAsXString8() const { return "Bool"_XS8; }
static TagBool* getEmptyTag();
virtual void FreeTag();
virtual void sprintf(unsigned int ident, XString8* s) const;
/*
* getters and setters
*/
bool boolValue() const
{
// if ( !isBool() ) panic("TagBool::boolValue() : !isBool() ");
return value;
}
void setBoolValue(bool b)
{
// if ( !isBool() ) panic("TagBool::setIntValue(bool) : !isBool() ");
value = b;
}
};
#endif /* __TagBool_h__ */

View File

@ -0,0 +1,101 @@
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
* plist.c - plist parsing functions
*
* Copyright (c) 2000-2005 Apple Computer, Inc.
*
* DRI: Josh de Cesare
* code split out from drivers.c by Soren Spies, 2005
*/
#include <Platform.h> // Only use angled for Platform, else, xcode project won't compile
#include "TagData.h"
#include "base64.h"
#ifndef DEBUG_ALL
#define DEBUG_TagData 1
#else
#define DEBUG_TagData DEBUG_ALL
#endif
#if DEBUG_TagData == 0
#define DBG(...)
#else
#define DBG(...) DebugLog(DEBUG_TagData, __VA_ARGS__)
#endif
#include "TagData.h"
XObjArray<TagData> TagData::tagsFree;
//UINTN newtagcount = 0;
//UINTN tagcachehit = 0;
TagData* TagData::getEmptyTag()
{
TagData* tag;
if ( tagsFree.size() > 0 ) {
tag = &tagsFree[0];
tagsFree.RemoveWithoutFreeingAtIndex(0);
//tagcachehit++;
//DBG("tagcachehit=%lld\n", tagcachehit);
return tag;
}
tag = new TagData();
//newtagcount += 1;
//DBG("newtagcount=%lld\n", newtagcount);
return tag;
}
void TagData::FreeTag()
{
if ( _data ) FreePool(_data);
_data = NULL;
_dataLen = 0;
tagsFree.AddReference(this, true);
}
bool TagData::operator == (const TagStruct& other) const
{
if ( !other.isData() ) return false;
if ( _dataLen != other.getData()->_dataLen ) return false;
if ( _dataLen > 0 ) { // if dataLen > 0, data cannot be NULL. Enforce by ctor and set setDataValue
if ( memcmp((void*)_data, (void*)other.getData()->_data, _dataLen) != 0 ) return false;
}
return true;
}
void TagData::sprintf(unsigned int ident, XString8* s) const
{
for (size_t i = 0 ; i < (size_t)ident ; i++) *s += " ";
*s += "<data>\n"_XS8;
if ( _dataLen > 0 ) {
size_t outputLen;
char* output = base64_encode(_data, _dataLen, &outputLen);
for (size_t i = 0 ; i < (size_t)ident ; i++) *s += " ";
(*s).strncat(output, outputLen);
free(output);
}
for (size_t i = 0 ; i < (size_t)ident ; i++) *s += " ";
*s += "</data>\n"_XS8;
}

View File

@ -0,0 +1,67 @@
/*
* TagData.h
*
* Created on: 23 August 2020
* Author: jief
*/
#ifndef __TagData_h__
#define __TagData_h__
#include "plist.h"
class TagData : public TagStruct
{
static XObjArray<TagData> tagsFree;
UINT8 *_data;
UINTN _dataLen;
public:
TagData() : _data(NULL), _dataLen(0) {}
TagData(const TagData& other) = delete; // Can be defined if needed
const TagData& operator = (const TagData&); // Can be defined if needed
virtual ~TagData() { delete _data; }
virtual bool operator == (const TagStruct& other) const;
virtual TagData* getData() { return this; }
virtual const TagData* getData() const { return this; }
virtual bool isData() const { return true; }
virtual const XString8 getTypeAsXString8() const { return "Data"_XS8; }
static TagData* getEmptyTag();
virtual void FreeTag();
virtual void sprintf(unsigned int ident, XString8* s) const;
/*
* getters and setters
*/
const UINT8* dataValue() const
{
// if ( !isData() ) panic("TagData::dataValue() : !isData() ");
return _data;
}
UINT8* dataValue()
{
// if ( !isData() ) panic("TagData::dataValue() : !isData() ");
return _data;
}
UINTN dataLenValue() const
{
// if ( !isData() ) panic("TagData::dataLenValue() : !isData() ");
return _dataLen;
}
void setDataValue(UINT8* data, UINTN dataLen)
{
if ( data == NULL ) panic("TagData::setDataValue() : _data == NULL ");
_data = data;
_dataLen = dataLen;
}
};
#endif /* __TagData_h__ */

View File

@ -0,0 +1,85 @@
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
* plist.c - plist parsing functions
*
* Copyright (c) 2000-2005 Apple Computer, Inc.
*
* DRI: Josh de Cesare
* code split out from drivers.c by Soren Spies, 2005
*/
#include <Platform.h> // Only use angled for Platform, else, xcode project won't compile
#include "TagDate.h"
#ifndef DEBUG_ALL
#define DEBUG_TagDate 1
#else
#define DEBUG_TagDate DEBUG_ALL
#endif
#if DEBUG_TagDate == 0
#define DBG(...)
#else
#define DBG(...) DebugLog(DEBUG_TagDate, __VA_ARGS__)
#endif
#include "TagDate.h"
XObjArray<TagDate> TagDate::tagsFree;
//UINTN newtagcount = 0;
//UINTN tagcachehit = 0;
TagDate* TagDate::getEmptyTag()
{
TagDate* tag;
if ( tagsFree.size() > 0 ) {
tag = &tagsFree[0];
tagsFree.RemoveWithoutFreeingAtIndex(0);
//tagcachehit++;
//DBG("tagcachehit=%lld\n", tagcachehit);
return tag;
}
tag = new TagDate();
//newtagcount += 1;
//DBG("newtagcount=%lld\n", newtagcount);
return tag;
}
void TagDate::FreeTag()
{
string.setEmpty();
tagsFree.AddReference(this, true);
}
bool TagDate::operator == (const TagStruct& other) const
{
if ( !other.isDate() ) return false;
return string == other.getDate()->string;
}
void TagDate::sprintf(unsigned int ident, XString8* s) const
{
for (size_t i = 0 ; i < (size_t)ident ; i++) *s += " ";
*s += string;
}

View File

@ -0,0 +1,55 @@
/*
* TagDate.h
*
* Created on: 23 August 2020
* Author: jief
*/
#ifndef __TagDate_h__
#define __TagDate_h__
#include "plist.h"
class TagDate : public TagStruct
{
static XObjArray<TagDate> tagsFree;
XString8 string;
public:
TagDate() : string() {}
TagDate(const TagDate& other) = delete; // Can be defined if needed
const TagDate& operator = (const TagDate&); // Can be defined if needed
virtual ~TagDate() { }
virtual bool operator == (const TagStruct& other) const;
virtual TagDate* getDate() { return this; }
virtual const TagDate* getDate() const { return this; }
virtual bool isDict() const { return true; }
virtual const XString8 getTypeAsXString8() const { return "Dict"_XS8; }
static TagDate* getEmptyTag();
virtual void FreeTag();
virtual void sprintf(unsigned int ident, XString8* s) const;
/*
* getters and setters
*/
const XString8& dateValue()
{
// if ( !isDate() ) panic("TagDate::dateValue() : !isDate() ");
return string;
}
void setDateValue(const XString8& xstring)
{
if ( xstring.isEmpty() ) panic("TagDate::setDateValue() : xstring.isEmpty() ");
string = xstring;
}
};
#endif /* __TagDate_h__ */

View File

@ -0,0 +1,197 @@
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
* plist.c - plist parsing functions
*
* Copyright (c) 2000-2005 Apple Computer, Inc.
*
* DRI: Josh de Cesare
* code split out from drivers.c by Soren Spies, 2005
*/
#include <Platform.h> // Only use angled for Platform, else, xcode project won't compile
#include "TagDict.h"
#ifndef DEBUG_ALL
#define DEBUG_TagDict 1
#else
#define DEBUG_TagDict DEBUG_ALL
#endif
#if DEBUG_TagDict == 0
#define DBG(...)
#else
#define DBG(...) DebugLog(DEBUG_TagDict, __VA_ARGS__)
#endif
#include "TagDict.h"
XObjArray<TagDict> TagDict::tagsFree;
//UINTN newtagcount = 0;
//UINTN tagcachehit = 0;
TagDict* TagDict::getEmptyTag()
{
TagDict* tag;
if ( tagsFree.size() > 0 ) {
tag = &tagsFree[0];
tagsFree.RemoveWithoutFreeingAtIndex(0);
//tagcachehit++;
//DBG("tagcachehit=%lld\n", tagcachehit);
return tag;
}
tag = new TagDict();
//newtagcount += 1;
//DBG("newtagcount=%lld\n", newtagcount);
return tag;
}
void TagDict::FreeTag()
{
for (size_t tagIdx = _dictContent.size() ; tagIdx > 0 ; ) {
tagIdx--;
_dictContent[tagIdx].FreeTag();
_dictContent.RemoveWithoutFreeingAtIndex(tagIdx);
}
tagsFree.AddReference(this, true);
}
bool TagDict::operator == (const TagStruct& other) const
{
if ( !other.isDict() ) return false;
if ( _dictContent.size() != other.getDict()->_dictContent.size() ) {
return false;
}
for (size_t tagIdx = 0 ; tagIdx < _dictContent.size() ; tagIdx++ ) {
if ( _dictContent[tagIdx] != other.getDict()->_dictContent[tagIdx] ) {
return false;
}
}
return true;
}
bool TagDict::debugIsEqual(const TagStruct& other, const XString8& label) const
{
if ( !other.isDict()) {
MsgLog("counterpart of '%s' is not a dict\n", label.c_str());
return false;
}
if ( _dictContent.size() != other.getDict()->_dictContent.size() ) {
MsgLog("array '%s' is different size\n", label.c_str());
return false;
}
for (size_t tagIdx = 0 ; tagIdx < _dictContent.size() ; tagIdx++ ) {
XString8 subLabel = label;
if ( _dictContent[tagIdx].isKey() ) subLabel += "/dict key=" + _dictContent[tagIdx].getKey()->keyStringValue();
else if ( tagIdx > 0 && _dictContent[tagIdx-1].isKey() ) subLabel += "/dict value of key=" + _dictContent[tagIdx-1].getKey()->keyStringValue();
else subLabel += S8Printf("/dict value of key %zu", tagIdx);
if ( !_dictContent[tagIdx].debugIsEqual(other.getDict()->_dictContent[tagIdx], subLabel ) ) {
return false;
}
}
return true;
}
INTN TagDict::dictKeyCount() const
{
if ( !isDict() ) panic("TagStruct::dictKeyCount() : !isDict() ");
INTN count = 0;
for (size_t tagIdx = 0 ; tagIdx + 1 < _dictContent.size() ; tagIdx++ ) { // tagIdx + 1 because a key as a last element cannot have value and is ignored. Can't do size()-1, because it's unsigned.
if ( _dictContent[tagIdx].isKey() && !_dictContent[tagIdx+1].isKey() ) { // if this key is followed by another key, it'll be ignored
count++;
}
}
return count;
}
EFI_STATUS TagDict::getKeyAndValueAtIndex(INTN id, const TagKey** key, const TagStruct** value) const
{
INTN element = 0;
*key = NULL;
*value = NULL;
if ( id < 0 ) return EFI_UNSUPPORTED;
const XObjArray<TagStruct>& tagList = _dictContent;
size_t tagIdx;
for (tagIdx = 0 ; tagIdx + 1 < tagList.size() ; tagIdx++ ) { // tagIdx + 1 because a key as a last element cannot have value and is ignored. Can't do size()-1, because it's unsigned.
if ( tagList[tagIdx].isKey() && !tagList[tagIdx+1].isKey() ) {
if ( element == id ) {
*key = tagList[tagIdx].getKey();
*value = &tagList[tagIdx+1];
return EFI_SUCCESS;
}
element++;
}
}
return EFI_UNSUPPORTED;
}
const TagStruct* TagDict::propertyForKey(const CHAR8* key) const
{
const XObjArray<TagStruct>& tagList = _dictContent;
for (size_t tagIdx = 0 ; tagIdx < tagList.size() ; tagIdx++ )
{
if ( tagList[tagIdx].isKey() && tagList[tagIdx].getKey()->keyStringValue().equalIC(key) ) {
if ( tagIdx+1 >= tagList.size() ) return NULL;
if ( tagList[tagIdx+1].isKey() ) return NULL;
return &tagList[tagIdx+1];
}
}
return NULL;
}
const TagDict* TagDict::dictPropertyForKey(const CHAR8* key) const
{
const TagStruct* tag = propertyForKey(key);
if ( tag == NULL ) return NULL;
if ( !tag->isDict() ) {
MsgLog("MALFORMED PLIST : Property value for key %s must be a dict\n", key);
return NULL;
}
return tag->getDict();
}
const TagArray* TagDict::arrayPropertyForKey(const CHAR8* key) const
{
const TagStruct* tag = propertyForKey(key);
if ( tag == NULL ) return NULL;
if ( !tag->isArray() ) {
MsgLog("MALFORMED PLIST : Property value for key %s must be an array\n", key);
return NULL;
}
return tag->getArray();
}
void TagDict::sprintf(unsigned int ident, XString8* s) const
{
for (size_t i = 0 ; i < (size_t)ident ; i++) *s += " ";
*s += "<dict>\n"_XS8;
for (size_t i = 0 ; i < _dictContent.size() ; i++) {
_dictContent[i].sprintf(ident+8, s);
}
for (size_t i = 0 ; i < (size_t)ident ; i++) *s += " ";
*s += "</dict>\n"_XS8;
}

View File

@ -0,0 +1,70 @@
/*
* TagDict.h
*
* Created on: 23 August 2020
* Author: jief
*/
#ifndef __TagDict_h__
#define __TagDict_h__
#include <Platform.h>
#include "plist.h"
class TagDict : public TagStruct
{
static XObjArray<TagDict> tagsFree;
XObjArray<TagStruct> _dictContent;
public:
TagDict() : _dictContent() {}
TagDict(const TagDict& other) = delete; // Can be defined if needed
const TagDict& operator = (const TagDict&); // Can be defined if needed
virtual ~TagDict() { }
virtual bool operator == (const TagStruct& other) const;
virtual bool debugIsEqual(const TagStruct& other, const XString8& label) const;
virtual TagDict* getDict() { return this; }
virtual const TagDict* getDict() const { return this; }
virtual bool isDict() const { return true; }
virtual const XString8 getTypeAsXString8() const { return "Dict"_XS8; }
static TagDict* getEmptyTag();
virtual void FreeTag();
virtual void sprintf(unsigned int ident, XString8* s) const;
/*
* getters and setters
*/
const XObjArray<TagStruct>& dictContent() const
{
if ( !isDict() ) panic("TagDict::dictContent() : !isDict() ");
return _dictContent;
}
XObjArray<TagStruct>& dictContent()
{
if ( !isDict() ) panic("TagDict::dictContent() : !isDict() ");
return _dictContent;
}
INTN dictKeyCount() const;
EFI_STATUS getKeyAndValueAtIndex(INTN id, const TagKey** key, const TagStruct** value) const;
const TagStruct* propertyForKey(const CHAR8* key ) const;
const TagDict* dictPropertyForKey(const CHAR8* key) const;
const TagArray* arrayPropertyForKey(const CHAR8* key) const;
};
EFI_STATUS
ParseXML(
CONST CHAR8 *buffer,
TagDict** dict,
size_t bufSize
);
#endif /* __TagDict_h__ */

View File

@ -0,0 +1,86 @@
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
* plist.c - plist parsing functions
*
* Copyright (c) 2000-2005 Apple Computer, Inc.
*
* DRI: Josh de Cesare
* code split out from drivers.c by Soren Spies, 2005
*/
#include <Platform.h> // Only use angled for Platform, else, xcode project won't compile
#include "TagFloat.h"
#ifndef DEBUG_ALL
#define DEBUG_TagFloat 1
#else
#define DEBUG_TagFloat DEBUG_ALL
#endif
#if DEBUG_TagFloat == 0
#define DBG(...)
#else
#define DBG(...) DebugLog(DEBUG_TagFloat, __VA_ARGS__)
#endif
#include "TagFloat.h"
XObjArray<TagFloat> TagFloat::tagsFree;
//UINTN newtagcount = 0;
//UINTN tagcachehit = 0;
TagFloat* TagFloat::getEmptyTag()
{
TagFloat* tag;
if ( tagsFree.size() > 0 ) {
tag = &tagsFree[0];
tagsFree.RemoveWithoutFreeingAtIndex(0);
//tagcachehit++;
//DBG("tagcachehit=%lld\n", tagcachehit);
return tag;
}
tag = new TagFloat();
//newtagcount += 1;
//DBG("newtagcount=%lld\n", newtagcount);
return tag;
}
void TagFloat::FreeTag()
{
value = 0;
tagsFree.AddReference(this, true);
}
bool TagFloat::operator == (const TagStruct& other) const
{
if ( !other.isFloat() ) return false;
return value == other.getFloat()->value;
}
void TagFloat::sprintf(unsigned int ident, XString8* s) const
{
for (size_t i = 0 ; i < (size_t)ident ; i++) *s += " ";
*s += S8Printf("%f", value);
}

View File

@ -0,0 +1,54 @@
/*
* TagFloat.h
*
* Created on: 23 August 2020
* Author: jief
*/
#ifndef __TagFloat_h__
#define __TagFloat_h__
#include "plist.h"
class TagFloat : public TagStruct
{
static XObjArray<TagFloat> tagsFree;
float value;
public:
TagFloat() : value(0) {}
TagFloat(const TagFloat& other) = delete; // Can be defined if needed
const TagFloat& operator = (const TagFloat&); // Can be defined if needed
virtual ~TagFloat() { }
virtual bool operator == (const TagStruct& other) const;
virtual TagFloat* getFloat() { return this; }
virtual const TagFloat* getFloat() const { return this; }
virtual bool isFloat() const { return true; }
virtual const XString8 getTypeAsXString8() const { return "Float"_XS8; }
static TagFloat* getEmptyTag();
virtual void FreeTag();
virtual void sprintf(unsigned int ident, XString8* s) const;
/*
* getters and setters
*/
float floatValue() const
{
// if ( !isFloat() ) panic("TagFloat::floatValue() : !isFloat() ");
return value;
}
void setFloatValue(float f)
{
value = f;
}
};
#endif /* __TagFloat_h__ */

View File

@ -0,0 +1,88 @@
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
* plist.c - plist parsing functions
*
* Copyright (c) 2000-2005 Apple Computer, Inc.
*
* DRI: Josh de Cesare
* code split out from drivers.c by Soren Spies, 2005
*/
#include <Platform.h> // Only use angled for Platform, else, xcode project won't compile
#include "TagInt64.h"
#ifndef DEBUG_ALL
#define DEBUG_TagInt64 1
#else
#define DEBUG_TagInt64 DEBUG_ALL
#endif
#if DEBUG_TagInt64 == 0
#define DBG(...)
#else
#define DBG(...) DebugLog(DEBUG_TagInt64, __VA_ARGS__)
#endif
#include "TagInt64.h"
XObjArray<TagInt64> TagInt64::tagsFree;
//UINTN newtagcount = 0;
//UINTN tagcachehit = 0;
TagInt64* TagInt64::getEmptyTag()
{
TagInt64* tag;
if ( tagsFree.size() > 0 ) {
tag = &tagsFree[0];
tagsFree.RemoveWithoutFreeingAtIndex(0);
//tagcachehit++;
//DBG("tagcachehit=%lld\n", tagcachehit);
return tag;
}
tag = new TagInt64();
//newtagcount += 1;
//DBG("newtagcount=%lld\n", newtagcount);
return tag;
}
void TagInt64::FreeTag()
{
value = 0;
tagsFree.AddReference(this, true);
}
bool TagInt64::operator == (const TagStruct& other) const
{
if ( !other.isInt64() ) return false;
return value == other.getInt64()->value;
}
void TagInt64::sprintf(unsigned int ident, XString8* s) const
{
for (size_t i = 0 ; i < (size_t)ident ; i++) *s += " ";
*s += "<integer>"_XS8;
*s += S8Printf("%lld", value);
*s += "</integer>\n"_XS8;
}

View File

@ -0,0 +1,54 @@
/*
* TagInt64.h
*
* Created on: 23 August 2020
* Author: jief
*/
#ifndef __TagInt64_h__
#define __TagInt64_h__
#include "plist.h"
class TagInt64 : public TagStruct
{
static XObjArray<TagInt64> tagsFree;
INT64 value;
public:
TagInt64() : value(0) {}
TagInt64(const TagInt64& other) = delete; // Can be defined if needed
const TagInt64& operator = (const TagInt64&); // Can be defined if needed
virtual ~TagInt64() { }
virtual bool operator == (const TagStruct& other) const;
virtual TagInt64* getInt64() { return this; }
virtual const TagInt64* getInt64() const { return this; }
virtual bool isInt64() const { return true; }
virtual const XString8 getTypeAsXString8() const { return "Int64"_XS8; }
static TagInt64* getEmptyTag();
virtual void FreeTag();
virtual void sprintf(unsigned int ident, XString8* s) const;
/*
* getters and setters
*/
INTN intValue() const
{
// if ( !isInt() ) panic("TagInt64::intValue() : !isInt() ");
return value;
}
void setIntValue(INTN i)
{
value = i;
}
};
#endif /* __TagInt64_h__ */

View File

@ -0,0 +1,88 @@
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
* plist.c - plist parsing functions
*
* Copyright (c) 2000-2005 Apple Computer, Inc.
*
* DRI: Josh de Cesare
* code split out from drivers.c by Soren Spies, 2005
*/
#include <Platform.h> // Only use angled for Platform, else, xcode project won't compile
#include "TagKey.h"
#ifndef DEBUG_ALL
#define DEBUG_TagKey 1
#else
#define DEBUG_TagKey DEBUG_ALL
#endif
#if DEBUG_TagKey == 0
#define DBG(...)
#else
#define DBG(...) DebugLog(DEBUG_TagKey, __VA_ARGS__)
#endif
#include "TagKey.h"
XObjArray<TagKey> TagKey::tagsFree;
//UINTN newtagcount = 0;
//UINTN tagcachehit = 0;
TagKey* TagKey::getEmptyTag()
{
TagKey* tag;
if ( tagsFree.size() > 0 ) {
tag = &tagsFree[0];
tagsFree.RemoveWithoutFreeingAtIndex(0);
//tagcachehit++;
//DBG("tagcachehit=%lld\n", tagcachehit);
return tag;
}
tag = new TagKey();
//newtagcount += 1;
//DBG("newtagcount=%lld\n", newtagcount);
return tag;
}
void TagKey::FreeTag()
{
_string.setEmpty();
tagsFree.AddReference(this, true);
}
bool TagKey::operator == (const TagStruct& other) const
{
if ( !other.isKey() ) return false;
return _string == other.getKey()->_string;
}
void TagKey::sprintf(unsigned int ident, XString8* s) const
{
for (size_t i = 0 ; i < (size_t)ident ; i++) *s += " ";
*s += "<key>"_XS8;
*s += _string;
*s += "</key>\n"_XS8;
}

View File

@ -0,0 +1,60 @@
/*
* TagKey.h
*
* Created on: 23 August 2020
* Author: jief
*/
#ifndef __TagKey_h__
#define __TagKey_h__
#include "plist.h"
class TagKey : public TagStruct
{
static XObjArray<TagKey> tagsFree;
XString8 _string;
public:
TagKey() : _string() {}
TagKey(const TagKey& other) = delete; // Can be defined if needed
const TagKey& operator = (const TagKey&); // Can be defined if needed
virtual ~TagKey() { }
virtual bool operator == (const TagStruct& other) const;
virtual TagKey* getKey() { return this; }
virtual const TagKey* getKey() const { return this; }
virtual bool isKey() const { return true; }
virtual const XString8 getTypeAsXString8() const { return "Key"_XS8; }
static TagKey* getEmptyTag();
virtual void FreeTag();
virtual void sprintf(unsigned int ident, XString8* s) const;
/*
* getters and setters
*/
const XString8& keyStringValue() const
{
// if ( !isKey() ) panic("TagKey::keyStringValue() const : !isKey() ");
return _string;
}
XString8& keyStringValue()
{
// if ( !isKey() ) panic("TagKey::keyStringValue() : !isKey() ");
return _string;
}
void setKeyValue(const XString8& xstring)
{
if ( xstring.isEmpty() ) panic("TagKey::setKeyValue() : xstring.isEmpty() ");
_string = xstring;
}
};
#endif /* __TagKey_h__ */

View File

@ -0,0 +1,87 @@
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
* plist.c - plist parsing functions
*
* Copyright (c) 2000-2005 Apple Computer, Inc.
*
* DRI: Josh de Cesare
* code split out from drivers.c by Soren Spies, 2005
*/
#include <Platform.h> // Only use angled for Platform, else, xcode project won't compile
#include "TagString8.h"
#ifndef DEBUG_ALL
#define DEBUG_TagString 1
#else
#define DEBUG_TagString DEBUG_ALL
#endif
#if DEBUG_TagString == 0
#define DBG(...)
#else
#define DBG(...) DebugLog(DEBUG_TagString, __VA_ARGS__)
#endif
#include "TagString8.h"
XObjArray<TagString> TagString::tagsFree;
//UINTN newtagcount = 0;
//UINTN tagcachehit = 0;
TagString* TagString::getEmptyTag()
{
TagString* tag;
if ( tagsFree.size() > 0 ) {
tag = &tagsFree[0];
tagsFree.RemoveWithoutFreeingAtIndex(0);
//tagcachehit++;
//DBG("tagcachehit=%lld\n", tagcachehit);
return tag;
}
tag = new TagString();
//newtagcount += 1;
//DBG("newtagcount=%lld\n", newtagcount);
return tag;
}
void TagString::FreeTag()
{
_string.setEmpty();
tagsFree.AddReference(this, true);
}
bool TagString::operator == (const TagStruct& other) const
{
if ( !other.isString() ) return false;
return _string == other.getString()->_string;
}
void TagString::sprintf(unsigned int ident, XString8* s) const
{
for (size_t i = 0 ; i < (size_t)ident ; i++) *s += " ";
*s += "<string>"_XS8;
*s += _string;
*s += "</string>\n"_XS8;
}

View File

@ -0,0 +1,61 @@
/*
* TagString.h
*
* Created on: 23 August 2020
* Author: jief
*/
#ifndef __TagString8_h__
#define __TagString8_h__
#include "plist.h"
class TagString : public TagStruct
{
static XObjArray<TagString> tagsFree;
XString8 _string;
public:
TagString() : _string() {}
TagString(const TagString& other) = delete; // Can be defined if needed
const TagString& operator = (const TagString&); // Can be defined if needed
virtual ~TagString() { }
virtual bool operator == (const TagStruct& other) const;
virtual TagString* getString() { return this; }
virtual const TagString* getString() const { return this; }
virtual bool isString() const { return true; }
virtual const XString8 getTypeAsXString8() const { return "String8"_XS8; }
static TagString* getEmptyTag();
virtual void FreeTag();
virtual void sprintf(unsigned int ident, XString8* s) const;
/*
* getters and setters
*/
const XString8& stringValue() const
{
// if ( !isString() ) panic("TagString::stringValue() : !isString() ");
return _string;
}
XString8& stringValue()
{
// if ( !isString() ) panic("TagString::stringValue() : !isString() ");
return _string;
}
void setStringValue(const XString8& xstring)
{
// empty string is allowed
//if ( xstring.isEmpty() ) panic("TagStruct::setStringValue() : xstring.isEmpty() ");
_string = xstring;
}
};
#endif /* __TagString_h__ */

View File

@ -0,0 +1,43 @@
#include <Platform.h>
static char encoding_table[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/'};
//static char *decoding_table = NULL;
static size_t mod_table[] = {0, 2, 1};
char *base64_encode(const unsigned char *data,
size_t input_length,
size_t *output_length) {
*output_length = 4 * ((input_length + 2) / 3);
char *encoded_data = (char*)malloc(*output_length);
if (encoded_data == NULL) return NULL;
for (size_t i = 0, j = 0; i < input_length;) {
uint32_t octet_a = i < input_length ? (unsigned char)data[i++] : 0;
uint32_t octet_b = i < input_length ? (unsigned char)data[i++] : 0;
uint32_t octet_c = i < input_length ? (unsigned char)data[i++] : 0;
uint32_t triple = (octet_a << 0x10) + (octet_b << 0x08) + octet_c;
encoded_data[j++] = encoding_table[(triple >> 3 * 6) & 0x3F];
encoded_data[j++] = encoding_table[(triple >> 2 * 6) & 0x3F];
encoded_data[j++] = encoding_table[(triple >> 1 * 6) & 0x3F];
encoded_data[j++] = encoding_table[(triple >> 0 * 6) & 0x3F];
}
for (size_t i = 0; i < mod_table[input_length % 3]; i++)
encoded_data[*output_length - 1 - i] = '=';
return encoded_data;
}

View File

@ -0,0 +1,16 @@
//
// base64.h
// cpp_tests
//
// Created by Jief on 24/08/2020.
// Copyright © 2020 JF Knudsen. All rights reserved.
//
#ifndef base64_h
#define base64_h
char *base64_encode(const unsigned char *data,
size_t input_length,
size_t *output_length);
#endif /* base64_h */

View File

@ -29,12 +29,13 @@
*/ */
//Slice - rewrite for UEFI with more functions like Copyright (c) 2003 Apple Computer //Slice - rewrite for UEFI with more functions like Copyright (c) 2003 Apple Computer
#include <Platform.h> // Only use angled for Platform, else, xcode project won't compile #include <Platform.h> // Only use angled for Platform, else, xcode project won't compile
#include "b64cdecode.h" #include "../b64cdecode.h"
#include "plist.h" #include "plist.h"
#include "../libeg/FloatLib.h" #include "../../libeg/FloatLib.h"
#include "xml.h"
#ifndef DEBUG_ALL #ifndef DEBUG_ALL
#define DEBUG_PLIST 1 #define DEBUG_PLIST 0
#else #else
#define DEBUG_PLIST DEBUG_ALL #define DEBUG_PLIST DEBUG_ALL
#endif #endif
@ -45,12 +46,6 @@
#define DBG(...) DebugLog(DEBUG_PLIST, __VA_ARGS__) #define DBG(...) DebugLog(DEBUG_PLIST, __VA_ARGS__)
#endif #endif
CHAR8* buffer_start = NULL; CHAR8* buffer_start = NULL;
// Forward declarations // Forward declarations
@ -62,206 +57,87 @@ EFI_STATUS ParseTagInteger(CHAR8* buffer, TagStruct* * tag, UINT32* lenPtr);
EFI_STATUS ParseTagFloat(CHAR8* buffer, TagStruct* * tag, UINT32* lenPtr); EFI_STATUS ParseTagFloat(CHAR8* buffer, TagStruct* * tag, UINT32* lenPtr);
EFI_STATUS ParseTagData(CHAR8* buffer, TagStruct* * tag, UINT32* lenPtr); EFI_STATUS ParseTagData(CHAR8* buffer, TagStruct* * tag, UINT32* lenPtr);
EFI_STATUS ParseTagDate(CHAR8* buffer, TagStruct* * tag, UINT32* lenPtr); EFI_STATUS ParseTagDate(CHAR8* buffer, TagStruct* * tag, UINT32* lenPtr);
EFI_STATUS ParseTagBoolean(CHAR8* buffer, TagStruct* * tag, bool value, UINT32* lenPtr); EFI_STATUS ParseTagBoolean(TagStruct* * tag, bool value, UINT32* lenPtr);
EFI_STATUS XMLParseNextTag (CHAR8 *buffer, TagStruct**tag, UINT32 *lenPtr); EFI_STATUS XMLParseNextTag (CHAR8 *buffer, TagStruct**tag, UINT32 *lenPtr);
EFI_STATUS FixDataMatchingTag( CHAR8* buffer, CONST CHAR8* tag,UINT32* lenPtr); EFI_STATUS FixDataMatchingTag( CHAR8* buffer, CONST CHAR8* tag,UINT32* lenPtr);
/* Function for basic XML character entities parsing */
class XMLEntity
{
public:
const XString8 name;
size_t nameLen;
CHAR8 value;
XMLEntity() : name(), nameLen(0), value(0) { }
XMLEntity(const XString8& _name, CHAR8 _value) : name(_name), nameLen(name.length()), value(_value) { }
// Not sure if default are valid. Delete them. If needed, proper ones can be created
XMLEntity(const XMLEntity&) = delete;
XMLEntity& operator=(const XMLEntity&) = delete;
};
const XMLEntity ents[] = {
{ "quot;"_XS8, '"' },
{"apos;"_XS8,'\''},
{"lt;"_XS8, '<'},
{"gt;"_XS8, '>'},
{"amp;"_XS8, '&'}
};
/* Replace XML entities by their value */
CHAR8*
XMLDecode(CHAR8* src)
{
UINTN len;
CONST CHAR8 *s;
CHAR8 *out, *o;
if (!src) {
return 0;
}
len = AsciiStrLen(src);
#if 0
out = (__typeof__(out))AllocateZeroPool(len+1);
if (!out)
return 0;
#else // unsafe
// out is always <= src, let's overwrite src
out = src;
#endif
o = out;
s = src;
while (s <= src+len) /* Make sure the terminator is also copied */
{
if ( *s == '&' ) {
BOOLEAN entFound = FALSE;
UINTN i;
s++;
for (i = 0; i < sizeof(ents)/sizeof(ents[0]); i++) {
if ( ents[i].name.strncmp(s, ents[i].nameLen) == 0 ) {
entFound = TRUE;
break;
}
}
if ( entFound ) {
*o++ = ents[i].value;
s += ents[i].nameLen;
continue;
}
}
*o++ = *s++;
}
return out;
}
/**************************************** TagStruct ****************************************/ /**************************************** TagStruct ****************************************/
XObjArray<TagStruct> gTagsFree; #include "TagDict.h"
#include "TagKey.h"
#include "TagBool.h"
#include "TagData.h"
#include "TagDate.h"
#include "TagArray.h"
#include "TagFloat.h"
#include "TagInt64.h"
#include "TagString8.h"
//
////UINTN newtagcount = 0;
////UINTN tagcachehit = 0;
//TagStruct* TagStruct::getEmptyTag()
//{
// TagStruct* tag;
//
// if ( gTagsFree.size() > 0 ) {
// tag = &gTagsFree[0];
// gTagsFree.RemoveWithoutFreeingAtIndex(0);
////tagcachehit++;
////DBG("tagcachehit=%lld\n", tagcachehit);
// return tag;
// }
// tag = new TagStruct();
////newtagcount += 1;
////DBG("newtagcount=%lld\n", newtagcount);
// return tag;
//}
//
//TagStruct* TagStruct::getEmptyDictTag()
//{
// TagStruct* newDictTag = getEmptyTag();
// newDictTag->type = kTagTypeDict;
// return newDictTag;
//}
//
//TagStruct* TagStruct::getEmptyArrayTag()
//{
// TagStruct* newArrayTag = getEmptyTag();
// newArrayTag->type = kTagTypeArray;
// return newArrayTag;
//}
//UINTN newtagcount = 0; //void TagStruct::FreeTag()
//UINTN tagcachehit = 0; //{
TagStruct* TagStruct::getEmptyTag() // // Clear and free the tag.
{ // type = kTagTypeNone;
TagStruct* tag; //
// _string.setEmpty();
// _intValue = 0;
// _floatValue = 0;
//
// if ( _data ) {
// FreePool(_data);
// _data = NULL;
// }
// _dataLen = 0;
//
// //while ( tagIdx < _dictOrArrayContent.notEmpty() ) {
// // _dictOrArrayContent[0].FreeTag();
// // _dictOrArrayContent.RemoveWithoutFreeingAtIndex(0);
// //}
// // this loop is better because removing objects from the end don't do any memory copying.
// for (size_t tagIdx = _dictOrArrayContent.size() ; tagIdx > 0 ; ) {
// tagIdx--;
// _dictOrArrayContent[tagIdx].FreeTag();
// _dictOrArrayContent.RemoveWithoutFreeingAtIndex(tagIdx);
// }
//
// gTagsFree.AddReference(this, false);
//}
if ( gTagsFree.size() > 0 ) {
tag = &gTagsFree[0];
gTagsFree.RemoveWithoutFreeingAtIndex(0);
//tagcachehit++;
//DBG("tagcachehit=%lld\n", tagcachehit);
return tag;
}
tag = new TagStruct();
//newtagcount += 1;
//DBG("newtagcount=%lld\n", newtagcount);
return tag;
}
TagStruct* TagStruct::getEmptyDictTag()
{
TagStruct* newDictTag = getEmptyTag();
newDictTag->type = kTagTypeDict;
return newDictTag;
}
TagStruct* TagStruct::getEmptyArrayTag()
{
TagStruct* newArrayTag = getEmptyTag();
newArrayTag->type = kTagTypeArray;
return newArrayTag;
}
void TagStruct::FreeTag()
{
// Clear and free the tag.
type = kTagTypeNone;
_string.setEmpty();
_intValue = 0;
_floatValue = 0;
if ( _data ) {
FreePool(_data);
_data = NULL;
}
_dataLen = 0;
//while ( tagIdx < _dictOrArrayContent.notEmpty() ) {
// _dictOrArrayContent[0].FreeTag();
// _dictOrArrayContent.RemoveWithoutFreeingAtIndex(0);
//}
// this loop is better because removing objects from the end don't do any memory copying.
for (size_t tagIdx = _dictOrArrayContent.size() ; tagIdx > 0 ; ) {
tagIdx--;
_dictOrArrayContent[tagIdx].FreeTag();
_dictOrArrayContent.RemoveWithoutFreeingAtIndex(tagIdx);
}
gTagsFree.AddReference(this, false);
}
INTN TagStruct::dictKeyCount() const
{
if ( !isDict() ) panic("TagStruct::dictKeyCount() : !isDict() ");
INTN count = 0;
for (size_t tagIdx = 0 ; tagIdx + 1 < _dictOrArrayContent.size() ; tagIdx++ ) { // tagIdx + 1 because a key as a last element cannot have value and is ignored. Can't do size()-1, because it's unsigned.
if ( _dictOrArrayContent[tagIdx].isKey() && !_dictOrArrayContent[tagIdx+1].isKey() ) { // if this key is followed by another key, it'll be ignored
count++;
}
}
return count;
}
EFI_STATUS TagStruct::dictKeyAndValueAtIndex(INTN id, const TagStruct** key, const TagStruct** value) const
{
INTN element = 0;
*key = NULL;
*value = NULL;
if ( id < 0 ) return EFI_UNSUPPORTED;
const XObjArray<TagStruct>& tagList = _dictOrArrayContent;
size_t tagIdx;
for (tagIdx = 0 ; tagIdx + 1 < tagList.size() ; tagIdx++ ) { // tagIdx + 1 because a key as a last element cannot have value and is ignored. Can't do size()-1, because it's unsigned.
if ( tagList[tagIdx].isKey() && !tagList[tagIdx+1].isKey() ) {
if ( element == id ) {
*key = &tagList[tagIdx];
*value = &tagList[tagIdx+1];
return EFI_SUCCESS;
}
element++;
}
}
return EFI_UNSUPPORTED;
}
const TagStruct* TagStruct::dictPropertyForKey(const CHAR8* key) const
{
const XObjArray<TagStruct>& tagList = _dictOrArrayContent;
for (size_t tagIdx = 0 ; tagIdx < tagList.size() ; tagIdx++ )
{
if ( tagList[tagIdx].isKey() && tagList[tagIdx].keyStringValue().equalIC(key) ) {
if ( tagIdx+1 >= tagList.size() ) return NULL;
if ( tagList[tagIdx+1].isKey() ) return NULL;
return &tagList[tagIdx+1];
}
}
return NULL;
}
//TagStruct* GetNextProperty(TagStruct* dict) //TagStruct* GetNextProperty(TagStruct* dict)
//{ //{
@ -287,7 +163,55 @@ const TagStruct* TagStruct::dictPropertyForKey(const CHAR8* key) const
// //
// return NULL; // return NULL;
//} //}
//
bool TagStruct::debugIsEqual(const TagStruct& other, const XString8& label) const
{
if ( *this != other ) {
MsgLog("Difference at %s\n", label.c_str());
if ( *this != other ) {
}
return false;
}
return true;
}
void TagStruct::printf(unsigned int ident) const
{
XString8 s;
sprintf(0, &s);
MsgLog("%s", s.c_str());
}
// Convenience method
bool TagStruct::isTrue() const
{
if ( isBool() ) return getBool()->boolValue();
return false;
}
bool TagStruct::isFalse() const
{
if ( isBool() ) return !getBool()->boolValue();
return false;
}
bool TagStruct::isTrueOrYy() const
{
if ( isBool() ) return getBool()->boolValue();
if ( isString() && getString()->stringValue().notEmpty() && (getString()->stringValue()[0] == 'y' || getString()->stringValue()[0] == 'Y') ) return true;
return false;
}
bool TagStruct::isTrueOrYes() const
{
if ( isBool() ) return getBool()->boolValue();
if ( isString() && getString()->stringValue().equal("Yes"_XS8) ) return true;
return false;
}
bool TagStruct::isFalseOrNn() const
{
if ( isBool() ) return !getBool()->boolValue();
if ( isString() && getString()->stringValue().notEmpty() && (getString()->stringValue()[0] == 'n' || getString()->stringValue()[0] == 'N') ) return true;
return false;
}
/**************************************** XML ****************************************/ /**************************************** XML ****************************************/
@ -295,23 +219,23 @@ const TagStruct* TagStruct::dictPropertyForKey(const CHAR8* key) const
// Expects to see one dictionary in the XML file, the final pos will be returned // Expects to see one dictionary in the XML file, the final pos will be returned
// If the pos is not equal to the strlen, then there are multiple dicts // If the pos is not equal to the strlen, then there are multiple dicts
// Puts the first dictionary it finds in the // Puts the first dictionary it finds in the
// tag pointer and returns the end of the dic, or returns -1 if not found. // tag pointer and returns the end of the dic, or returns ?? if not found.
// //
EFI_STATUS ParseXML(const CHAR8* buffer, TagStruct** dict, UINT32 bufSize) EFI_STATUS ParseXML(const CHAR8* buffer, TagDict** dict, size_t bufSize)
{ {
EFI_STATUS Status; EFI_STATUS Status;
UINT32 length = 0; UINT32 length = 0;
UINT32 pos = 0; UINT32 pos = 0;
TagStruct* tag = NULL; TagStruct* tag = NULL;
CHAR8* configBuffer = NULL; CHAR8* configBuffer = NULL;
UINT32 bufferSize = 0; size_t bufferSize = 0;
UINTN i; UINTN i;
if (bufSize) { if (bufSize) {
bufferSize = bufSize; bufferSize = bufSize;
} else { } else {
bufferSize = (UINT32)AsciiStrLen(buffer); bufferSize = (UINT32)strlen(buffer);
} }
if(dict == NULL) { if(dict == NULL) {
@ -323,7 +247,7 @@ EFI_STATUS ParseXML(const CHAR8* buffer, TagStruct** dict, UINT32 bufSize)
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
CopyMem(configBuffer, buffer, bufferSize); memmove(configBuffer, buffer, bufferSize);
for (i=0; i<bufferSize; i++) { for (i=0; i<bufferSize; i++) {
if (configBuffer[i] == 0) { if (configBuffer[i] == 0) {
configBuffer[i] = 0x20; //replace random zero bytes to spaces configBuffer[i] = 0x20; //replace random zero bytes to spaces
@ -358,7 +282,7 @@ EFI_STATUS ParseXML(const CHAR8* buffer, TagStruct** dict, UINT32 bufSize)
return Status; return Status;
} }
*dict = tag; *dict = tag->getDict();
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -383,7 +307,7 @@ EFI_STATUS XMLParseNextTag(CHAR8* buffer, TagStruct** tag, UINT32* lenPtr)
Status = GetNextTag((UINT8*)buffer, &tagName, 0, &length); Status = GetNextTag((UINT8*)buffer, &tagName, 0, &length);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG("NextTag error %s\n", strerror(Status)); DBG("NextTag error %s\n", efiStrError(Status));
return Status; return Status;
} }
@ -393,12 +317,12 @@ EFI_STATUS XMLParseNextTag(CHAR8* buffer, TagStruct** tag, UINT32* lenPtr)
Status=EFI_SUCCESS; Status=EFI_SUCCESS;
} }
/***** dict ****/ /***** dict ****/
else if (!AsciiStrCmp(tagName, kXMLTagDict)) else if (!strcmp(tagName, kXMLTagDict))
{ {
DBG("begin dict len=%d\n", length); DBG("begin dict len=%d\n", length);
Status = ParseTagDict(buffer + pos, tag, 0, &length); Status = ParseTagDict(buffer + pos, tag, 0, &length);
} }
else if (!AsciiStrCmp(tagName, kXMLTagDict "/")) else if (!strcmp(tagName, kXMLTagDict "/"))
{ {
DBG("end dict len=%d\n", length); DBG("end dict len=%d\n", length);
Status = ParseTagDict(buffer + pos, tag, 1, &length); Status = ParseTagDict(buffer + pos, tag, 1, &length);
@ -409,13 +333,13 @@ EFI_STATUS XMLParseNextTag(CHAR8* buffer, TagStruct** tag, UINT32* lenPtr)
Status = ParseTagDict(buffer + pos, tag, 0, &length); Status = ParseTagDict(buffer + pos, tag, 0, &length);
} }
/***** key ****/ /***** key ****/
else if (!AsciiStrCmp(tagName, kXMLTagKey)) else if (!strcmp(tagName, kXMLTagKey))
{ {
DBG("parse key\n"); DBG("parse key\n");
Status = ParseTagKey(buffer + pos, tag, &length); Status = ParseTagKey(buffer + pos, tag, &length);
} }
/***** string ****/ /***** string ****/
else if (!AsciiStrCmp(tagName, kXMLTagString)) else if (!strcmp(tagName, kXMLTagString))
{ {
DBG("parse String\n"); DBG("parse String\n");
Status = ParseTagString(buffer + pos, tag, &length); Status = ParseTagString(buffer + pos, tag, &length);
@ -427,7 +351,7 @@ EFI_STATUS XMLParseNextTag(CHAR8* buffer, TagStruct** tag, UINT32* lenPtr)
Status = ParseTagString(buffer + pos, tag, &length); Status = ParseTagString(buffer + pos, tag, &length);
} }
/***** integer ****/ /***** integer ****/
else if (!AsciiStrCmp(tagName, kXMLTagInteger)) else if (!strcmp(tagName, kXMLTagInteger))
{ {
Status = ParseTagInteger(buffer + pos, tag, &length); Status = ParseTagInteger(buffer + pos, tag, &length);
} }
@ -436,7 +360,7 @@ EFI_STATUS XMLParseNextTag(CHAR8* buffer, TagStruct** tag, UINT32* lenPtr)
Status = ParseTagInteger(buffer + pos, tag, &length); Status = ParseTagInteger(buffer + pos, tag, &length);
} }
/***** float ****/ /***** float ****/
else if (!AsciiStrCmp(tagName, kXMLTagFloat)) else if (!strcmp(tagName, kXMLTagFloat))
{ {
Status = ParseTagFloat(buffer + pos, tag, &length); Status = ParseTagFloat(buffer + pos, tag, &length);
} }
@ -445,7 +369,7 @@ EFI_STATUS XMLParseNextTag(CHAR8* buffer, TagStruct** tag, UINT32* lenPtr)
Status = ParseTagFloat(buffer + pos, tag, &length); Status = ParseTagFloat(buffer + pos, tag, &length);
} }
/***** data ****/ /***** data ****/
else if (!AsciiStrCmp(tagName, kXMLTagData)) else if (!strcmp(tagName, kXMLTagData))
{ {
Status = ParseTagData(buffer + pos, tag, &length); Status = ParseTagData(buffer + pos, tag, &length);
} }
@ -454,22 +378,22 @@ EFI_STATUS XMLParseNextTag(CHAR8* buffer, TagStruct** tag, UINT32* lenPtr)
Status = ParseTagData(buffer + pos, tag, &length); Status = ParseTagData(buffer + pos, tag, &length);
} }
/***** date ****/ /***** date ****/
else if (!AsciiStrCmp(tagName, kXMLTagDate)) else if (!strcmp(tagName, kXMLTagDate))
{ {
Status = ParseTagDate(buffer + pos, tag, &length); Status = ParseTagDate(buffer + pos, tag, &length);
} }
/***** FALSE ****/ /***** FALSE ****/
else if (!AsciiStrCmp(tagName, kXMLTagFalse)) else if (!strcmp(tagName, kXMLTagFalse))
{ {
Status = ParseTagBoolean(buffer + pos, tag, false, &length); Status = ParseTagBoolean(tag, false, &length);
} }
/***** TRUE ****/ /***** TRUE ****/
else if (!AsciiStrCmp(tagName, kXMLTagTrue)) else if (!strcmp(tagName, kXMLTagTrue))
{ {
Status = ParseTagBoolean(buffer + pos, tag, true, &length); Status = ParseTagBoolean(tag, true, &length);
} }
/***** array ****/ /***** array ****/
else if (!AsciiStrCmp(tagName, kXMLTagArray)) else if (!strcmp(tagName, kXMLTagArray))
{ {
Status = ParseTagArray(buffer + pos, tag, 0, &length); Status = ParseTagArray(buffer + pos, tag, 0, &length);
} }
@ -478,7 +402,7 @@ EFI_STATUS XMLParseNextTag(CHAR8* buffer, TagStruct** tag, UINT32* lenPtr)
DBG("begin array len=%d\n", length); DBG("begin array len=%d\n", length);
Status = ParseTagArray(buffer + pos, tag, 0, &length); Status = ParseTagArray(buffer + pos, tag, 0, &length);
} }
else if (!AsciiStrCmp(tagName, kXMLTagArray "/")) else if (!strcmp(tagName, kXMLTagArray "/"))
{ {
DBG("end array len=%d\n", length); DBG("end array len=%d\n", length);
Status = ParseTagArray(buffer + pos, tag, 1, &length); Status = ParseTagArray(buffer + pos, tag, 1, &length);
@ -494,12 +418,6 @@ EFI_STATUS XMLParseNextTag(CHAR8* buffer, TagStruct** tag, UINT32* lenPtr)
return Status; return Status;
} }
// TODO jief : seems to me that length cannot be -1. Added the cast anyway to avoid regression. If confirmed, the next 3 lines must be removed.
if (length == (UINT32)-1) {
DBG("(length == -1)\n");
return EFI_UNSUPPORTED;
}
*lenPtr = pos + length; *lenPtr = pos + length;
DBG(" len after success parse next tag %d\n", *lenPtr); DBG(" len after success parse next tag %d\n", *lenPtr);
return EFI_SUCCESS; return EFI_SUCCESS;
@ -526,11 +444,11 @@ EFI_STATUS __ParseTagList(bool isArray, CHAR8* buffer, TagStruct** tag, UINT32 e
TagStruct* dictOrArrayTag; TagStruct* dictOrArrayTag;
XObjArray<TagStruct>* tagListPtr; XObjArray<TagStruct>* tagListPtr;
if (isArray) { if (isArray) {
dictOrArrayTag = TagStruct::getEmptyArrayTag(); dictOrArrayTag = TagArray::getEmptyTag();
tagListPtr = &dictOrArrayTag->arrayContent(); tagListPtr = &dictOrArrayTag->getArray()->arrayContent();
} else { } else {
dictOrArrayTag = TagStruct::getEmptyDictTag(); dictOrArrayTag = TagDict::getEmptyTag();
tagListPtr = &dictOrArrayTag->dictContent(); tagListPtr = &dictOrArrayTag->getDict()->dictContent();
} }
XObjArray<TagStruct>& tagList = *tagListPtr; XObjArray<TagStruct>& tagList = *tagListPtr;
@ -539,7 +457,7 @@ EFI_STATUS __ParseTagList(bool isArray, CHAR8* buffer, TagStruct** tag, UINT32 e
TagStruct* newDictOrArrayTag = NULL; TagStruct* newDictOrArrayTag = NULL;
Status = XMLParseNextTag(buffer + pos, &newDictOrArrayTag, &length); Status = XMLParseNextTag(buffer + pos, &newDictOrArrayTag, &length);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG("error XMLParseNextTag in array: %s\n", strerror(Status)); DBG("error XMLParseNextTag in array: %s\n", efiStrError(Status));
break; break;
} }
@ -582,11 +500,11 @@ EFI_STATUS ParseTagKey( char * buffer, TagStruct** tag, UINT32* lenPtr)
EFI_STATUS Status; EFI_STATUS Status;
UINT32 length = 0; UINT32 length = 0;
UINT32 length2 = 0; UINT32 length2 = 0;
TagStruct* tmpTag; TagKey* tmpTag;
// TagStruct* subTag = NULL; // TagStruct* subTag = NULL;
Status = FixDataMatchingTag(buffer, kXMLTagKey, &length); Status = FixDataMatchingTag(buffer, kXMLTagKey, &length);
DBG("fixing key len=%d status=%s\n", length, strerror(Status)); DBG("fixing key len=%d status=%s\n", length, efiStrError(Status));
if (EFI_ERROR(Status)){ if (EFI_ERROR(Status)){
return Status; return Status;
} }
@ -595,7 +513,7 @@ EFI_STATUS ParseTagKey( char * buffer, TagStruct** tag, UINT32* lenPtr)
// if (EFI_ERROR(Status)) { // if (EFI_ERROR(Status)) {
// return Status; // return Status;
// } // }
tmpTag = TagStruct::getEmptyTag(); tmpTag = TagKey::getEmptyTag();
tmpTag->setKeyValue(LString8(buffer)); tmpTag->setKeyValue(LString8(buffer));
*tag = tmpTag; *tag = tmpTag;
@ -611,14 +529,14 @@ EFI_STATUS ParseTagString(CHAR8* buffer, TagStruct* * tag,UINT32* lenPtr)
{ {
EFI_STATUS Status; EFI_STATUS Status;
UINT32 length = 0; UINT32 length = 0;
TagStruct* tmpTag; TagString* tmpTag;
Status = FixDataMatchingTag(buffer, kXMLTagString, &length); Status = FixDataMatchingTag(buffer, kXMLTagString, &length);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
return Status; return Status;
} }
tmpTag = TagStruct::getEmptyTag(); tmpTag = TagString::getEmptyTag();
if (tmpTag == NULL) { if (tmpTag == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
@ -626,14 +544,14 @@ EFI_STATUS ParseTagString(CHAR8* buffer, TagStruct* * tag,UINT32* lenPtr)
tmpTag->setStringValue(LString8(XMLDecode(buffer))); tmpTag->setStringValue(LString8(XMLDecode(buffer)));
*tag = tmpTag; *tag = tmpTag;
*lenPtr = length; *lenPtr = length;
DBG(" parse string %s\n", tmpTag->stringValue().c_str()); DBG(" parse string %s\n", tmpTag->getString()->stringValue().c_str());
return EFI_SUCCESS; return EFI_SUCCESS;
} }
//========================================================================== //==========================================================================
// ParseTagInteger // ParseTagInteger
EFI_STATUS ParseTagInteger(CHAR8* buffer, TagStruct* * tag, UINT32* lenPtr) EFI_STATUS ParseTagInteger(CHAR8* buffer, TagStruct** tag, UINT32* lenPtr)
{ {
EFI_STATUS Status; EFI_STATUS Status;
UINT32 length = 0; UINT32 length = 0;
@ -641,14 +559,14 @@ EFI_STATUS ParseTagInteger(CHAR8* buffer, TagStruct* * tag, UINT32* lenPtr)
UINT32 size; UINT32 size;
BOOLEAN negative = FALSE; BOOLEAN negative = FALSE;
CHAR8* val = buffer; CHAR8* val = buffer;
TagStruct* tmpTag; TagInt64* tmpTag;
Status = FixDataMatchingTag(buffer, kXMLTagInteger, &length); Status = FixDataMatchingTag(buffer, kXMLTagInteger, &length);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
return Status; return Status;
} }
tmpTag = TagStruct::getEmptyTag(); tmpTag = TagInt64::getEmptyTag();
tmpTag->setIntValue(0); tmpTag->setIntValue(0);
size = length; size = length;
@ -719,17 +637,14 @@ EFI_STATUS ParseTagFloat(CHAR8* buffer, TagStruct* * tag, UINT32* lenPtr)
{ {
EFI_STATUS Status; EFI_STATUS Status;
UINT32 length; UINT32 length;
TagStruct* tmpTag; TagFloat* tmpTag;
Status = FixDataMatchingTag(buffer, kXMLTagFloat, &length); Status = FixDataMatchingTag(buffer, kXMLTagFloat, &length);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
return Status; return Status;
} }
tmpTag = TagStruct::getEmptyTag(); tmpTag = TagFloat::getEmptyTag();
if (tmpTag == NULL) {
return EFI_OUT_OF_RESOURCES;
}
//---- //----
float f; float f;
AsciiStrToFloat(buffer, NULL, &f); AsciiStrToFloat(buffer, NULL, &f);
@ -748,17 +663,14 @@ EFI_STATUS ParseTagData(CHAR8* buffer, TagStruct* * tag, UINT32* lenPtr)
{ {
EFI_STATUS Status; EFI_STATUS Status;
UINT32 length = 0; UINT32 length = 0;
TagStruct* tmpTag; TagData* tmpTag;
Status = FixDataMatchingTag(buffer, kXMLTagData,&length); Status = FixDataMatchingTag(buffer, kXMLTagData,&length);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
return Status; return Status;
} }
tmpTag = TagStruct::getEmptyTag(); tmpTag = TagData::getEmptyTag();
if (tmpTag == NULL) {
return EFI_OUT_OF_RESOURCES;
}
//Slice - correction as Apple 2003 //Slice - correction as Apple 2003
// tmpTag->setStringValue(LString8(buffer)); // tmpTag->setStringValue(LString8(buffer));
// dmazar: base64 decode data // dmazar: base64 decode data
@ -779,7 +691,7 @@ EFI_STATUS ParseTagDate(CHAR8* buffer, TagStruct* * tag,UINT32* lenPtr)
{ {
EFI_STATUS Status; EFI_STATUS Status;
UINT32 length = 0; UINT32 length = 0;
TagStruct* tmpTag; TagDate* tmpTag;
Status = FixDataMatchingTag(buffer, kXMLTagDate,&length); Status = FixDataMatchingTag(buffer, kXMLTagDate,&length);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
@ -787,11 +699,7 @@ EFI_STATUS ParseTagDate(CHAR8* buffer, TagStruct* * tag,UINT32* lenPtr)
} }
tmpTag = TagStruct::getEmptyTag(); tmpTag = TagDate::getEmptyTag();
if (tmpTag == NULL) {
return EFI_OUT_OF_RESOURCES;
}
tmpTag->setDateValue(LString8(buffer)); tmpTag->setDateValue(LString8(buffer));
*tag = tmpTag; *tag = tmpTag;
@ -803,15 +711,11 @@ EFI_STATUS ParseTagDate(CHAR8* buffer, TagStruct* * tag,UINT32* lenPtr)
//========================================================================== //==========================================================================
// ParseTagBoolean // ParseTagBoolean
EFI_STATUS ParseTagBoolean(CHAR8* buffer, TagStruct* * tag, bool value, UINT32* lenPtr) EFI_STATUS ParseTagBoolean(TagStruct** tag, bool value, UINT32* lenPtr)
{ {
TagStruct* tmpTag; TagBool* tmpTag;
tmpTag = TagStruct::getEmptyTag();
if (tmpTag == NULL) {
return EFI_OUT_OF_RESOURCES;
}
tmpTag = TagBool::getEmptyTag();
tmpTag->setBoolValue(value); tmpTag->setBoolValue(value);
*tag = tmpTag; *tag = tmpTag;
@ -861,11 +765,6 @@ EFI_STATUS GetNextTag( UINT8* buffer, CHAR8** tag, UINT32* start, UINT32* length
*length = cnt2 + 1; //unreal to be -1. This is UINT32 *length = cnt2 + 1; //unreal to be -1. This is UINT32
if (*length == (UINT32)-1) {
DBG("GetNextTag with *length == -1\n");
return EFI_UNSUPPORTED;
}
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -890,7 +789,7 @@ EFI_STATUS FixDataMatchingTag( CHAR8* buffer, CONST CHAR8* tag, UINT32* lenPtr)
return Status; return Status;
} }
if ((*endTag == '/') && !AsciiStrCmp(endTag + 1, tag)) { if ((*endTag == '/') && !strcmp(endTag + 1, tag)) {
break; break;
} }
start += length; start += length;
@ -899,10 +798,6 @@ EFI_STATUS FixDataMatchingTag( CHAR8* buffer, CONST CHAR8* tag, UINT32* lenPtr)
buffer[start + stop] = '\0'; buffer[start + stop] = '\0';
*lenPtr = start + length; *lenPtr = start + length;
if (*lenPtr == (__typeof_am__(*lenPtr))-1) { // Why is this test. -1 is UINTN_MAX.
return EFI_UNSUPPORTED;
}
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -946,19 +841,19 @@ GetPropertyAsInteger(
return Default; return Default;
} }
if (Prop->isInt()) { if (Prop->isInt64()) {
return Prop->intValue(); return Prop->getInt64()->intValue();
} else if ((Prop->isString()) && Prop->stringValue().notEmpty()) { } else if ((Prop->isString()) && Prop->getString()->stringValue().notEmpty()) {
if ( Prop->stringValue().length() > 1 && (Prop->stringValue()[1] == 'x' || Prop->stringValue()[1] == 'X') ) { if ( Prop->getString()->stringValue().length() > 1 && (Prop->getString()->stringValue()[1] == 'x' || Prop->getString()->stringValue()[1] == 'X') ) {
return (INTN)AsciiStrHexToUintn(Prop->stringValue()); return (INTN)AsciiStrHexToUintn(Prop->getString()->stringValue());
} }
if (Prop->stringValue()[0] == '-') { if (Prop->getString()->stringValue()[0] == '-') {
return -(INTN)AsciiStrDecimalToUintn (Prop->stringValue().c_str() + 1); return -(INTN)AsciiStrDecimalToUintn (Prop->getString()->stringValue().c_str() + 1);
} }
// return (INTN)AsciiStrDecimalToUintn (Prop->stringValue()); // return (INTN)AsciiStrDecimalToUintn (Prop->getString()->stringValue());
return (INTN)AsciiStrDecimalToUintn((Prop->stringValue()[0] == '+') ? (Prop->stringValue().c_str() + 1) : Prop->stringValue().c_str()); return (INTN)AsciiStrDecimalToUintn((Prop->getString()->stringValue()[0] == '+') ? (Prop->getString()->stringValue().c_str() + 1) : Prop->getString()->stringValue().c_str());
} }
return Default; return Default;
} }
@ -969,10 +864,10 @@ float GetPropertyFloat (const TagStruct* Prop, float Default)
return Default; return Default;
} }
if (Prop->isFloat()) { if (Prop->isFloat()) {
return Prop->floatValue(); //this is union char* or float return Prop->getFloat()->floatValue(); //this is union char* or float
} else if ((Prop->isString()) && Prop->stringValue().notEmpty()) { } else if ((Prop->isString()) && Prop->getString()->stringValue().notEmpty()) {
float fVar = 0.f; float fVar = 0.f;
if(!AsciiStrToFloat(Prop->stringValue().c_str(), NULL, &fVar)) //if success then return 0 if(!AsciiStrToFloat(Prop->getString()->stringValue().c_str(), NULL, &fVar)) //if success then return 0
return fVar; return fVar;
} }

View File

@ -0,0 +1,152 @@
/*
* plist.h
*
* Created on: 31 Mar 2020
* Author: jief
*/
#ifndef PLATFORM_PLIST_H_
#define PLATFORM_PLIST_H_
/* XML Tags */
#define kXMLTagPList "plist"
#define kXMLTagDict "dict"
#define kXMLTagKey "key"
#define kXMLTagString "string"
#define kXMLTagInteger "integer"
#define kXMLTagData "data"
#define kXMLTagDate "date"
#define kXMLTagFalse "false/"
#define kXMLTagTrue "true/"
#define kXMLTagArray "array"
#define kXMLTagReference "reference"
#define kXMLTagID "ID="
#define kXMLTagIDREF "IDREF="
#define kXMLTagFloat "real"
typedef enum {
kTagTypeNone,
kTagTypeDict, // 1
kTagTypeKey, // 2
kTagTypeString, // 3
kTagTypeInteger,// 4
kTagTypeData, // 5
kTagTypeDate, // 6
kTagTypeFalse, // 7
kTagTypeTrue, // 8
kTagTypeArray, // 9
kTagTypeFloat // 10
} TAG_TYPE;
class TagDict;
class TagKey;
class TagString;
class TagInt64;
class TagFloat;
class TagBool;
class TagData;
class TagDate;
class TagArray;
class TagStruct
{
public:
TagStruct() {}
TagStruct(const TagStruct& other) = delete; // Can be defined if needed
const TagStruct& operator = ( const TagStruct & ) = delete; // Can be defined if needed
virtual ~TagStruct() { }
// static TagStruct* getEmptyTag();
// static TagStruct* getEmptyDictTag();
// static TagStruct* getEmptyArrayTag();
virtual void FreeTag() = 0;
virtual bool operator == (const TagStruct& other) const = 0;
virtual bool operator != (const TagStruct& other) const { return !(*this == other); };
virtual bool debugIsEqual(const TagStruct& other, const XString8& label) const;
virtual void sprintf(unsigned int ident, XString8* s) const = 0;
void printf(unsigned int ident) const;
virtual void printf() const { printf(0); }
virtual const TagDict* getDict() const { return NULL; }
virtual const TagKey* getKey() const { return NULL; }
virtual const TagString* getString() const { return NULL; }
virtual const TagInt64* getInt64() const { return NULL; }
virtual const TagFloat* getFloat() const { return NULL; }
virtual const TagBool* getBool() const { return NULL; }
virtual const TagData* getData() const { return NULL; }
virtual const TagDate* getDate() const { return NULL; }
virtual const TagArray* getArray() const { return NULL; }
virtual TagDict* getDict() { return NULL; }
virtual TagKey* getKey() { return NULL; }
virtual TagString* getString() { return NULL; }
virtual TagInt64* getInt64() { return NULL; }
virtual TagFloat* getFloat() { return NULL; }
virtual TagBool* getBool() { return NULL; }
virtual TagData* getData() { return NULL; }
virtual TagDate* getDate() { return NULL; }
virtual TagArray* getArray() { return NULL; }
virtual bool isDict() const { return false; }
virtual bool isKey() const { return false; }
virtual bool isString() const { return false; }
virtual bool isInt64() const { return false; }
virtual bool isFloat() const { return false; }
virtual bool isBool() const { return false; }
virtual bool isData() const { return false; }
virtual bool isDate() const { return false; }
virtual bool isArray() const { return false; }
virtual const XString8 getTypeAsXString8() const = 0;
// Convenience method
bool isTrue() const;
bool isFalse() const;
bool isTrueOrYy() const;
bool isTrueOrYes() const;
bool isFalseOrNn() const;
};
#include "TagDict.h"
#include "TagKey.h"
#include "TagBool.h"
#include "TagData.h"
#include "TagDate.h"
#include "TagArray.h"
#include "TagFloat.h"
#include "TagInt64.h"
#include "TagString8.h"
EFI_STATUS
GetNextTag (
UINT8 *buffer,
CHAR8 **tag,
UINT32 *start,
UINT32 *length
);
BOOLEAN
IsPropertyNotNullAndTrue(
const TagStruct* Prop
);
BOOLEAN
IsPropertyNotNullAndFalse(
const TagStruct* Prop
);
INTN
GetPropertyAsInteger(
const TagStruct* Prop,
INTN Default
);
float GetPropertyFloat (const TagStruct* Prop, float Default);
#endif /* PLATFORM_PLIST_H_ */

122
rEFIt_UEFI/Platform/plist/xml.cpp Executable file
View File

@ -0,0 +1,122 @@
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
* plist.c - plist parsing functions
*
* Copyright (c) 2000-2005 Apple Computer, Inc.
*
* DRI: Josh de Cesare
* code split out from drivers.c by Soren Spies, 2005
*/
//Slice - rewrite for UEFI with more functions like Copyright (c) 2003 Apple Computer
#include <Platform.h> // Only use angled for Platform, else, xcode project won't compile
#ifndef DEBUG_ALL
#define DEBUG_XML 1
#else
#define DEBUG_XML DEBUG_ALL
#endif
#if DEBUG_PLIST == 0
#define DBG(...)
#else
#define DBG(...) DebugLog(DEBUG_XML, __VA_ARGS__)
#endif
/* Function for basic XML character entities parsing */
class XMLEntity
{
public:
const XString8 name;
size_t nameLen;
CHAR8 value;
XMLEntity() : name(), nameLen(0), value(0) { }
XMLEntity(const XString8& _name, CHAR8 _value) : name(_name), nameLen(name.length()), value(_value) { }
// Not sure if default are valid. Delete them. If needed, proper ones can be created
XMLEntity(const XMLEntity&) = delete;
XMLEntity& operator=(const XMLEntity&) = delete;
};
const XMLEntity ents[] = {
{ "quot;"_XS8, '"' },
{"apos;"_XS8,'\''},
{"lt;"_XS8, '<'},
{"gt;"_XS8, '>'},
{"amp;"_XS8, '&'}
};
/* Replace XML entities by their value */
CHAR8*
XMLDecode(CHAR8* src)
{
UINTN len;
CONST CHAR8 *s;
CHAR8 *out, *o;
if (!src) {
return 0;
}
len = strlen(src);
#if 0
out = (__typeof__(out))AllocateZeroPool(len+1);
if (!out)
return 0;
#else // unsafe
// out is always <= src, let's overwrite src
out = src;
#endif
o = out;
s = src;
while (s <= src+len) /* Make sure the terminator is also copied */
{
if ( *s == '&' ) {
BOOLEAN entFound = FALSE;
UINTN i;
s++;
for (i = 0; i < sizeof(ents)/sizeof(ents[0]); i++) {
if ( ents[i].name.strncmp(s, ents[i].nameLen) == 0 ) {
entFound = TRUE;
break;
}
}
if ( entFound ) {
*o++ = ents[i].value;
s += ents[i].nameLen;
continue;
}
}
*o++ = *s++;
}
return out;
}

View File

@ -0,0 +1,33 @@
/*
* plist.h
*
* Created on: 31 Mar 2020
* Author: jief
*/
#ifndef __xml_h__
#define __xml_h__
/* XML Tags */
#define kXMLTagPList "plist"
#define kXMLTagDict "dict"
#define kXMLTagKey "key"
#define kXMLTagString "string"
#define kXMLTagInteger "integer"
#define kXMLTagData "data"
#define kXMLTagDate "date"
#define kXMLTagFalse "false/"
#define kXMLTagTrue "true/"
#define kXMLTagArray "array"
#define kXMLTagReference "reference"
#define kXMLTagID "ID="
#define kXMLTagIDREF "IDREF="
#define kXMLTagFloat "real"
CHAR8*
XMLDecode (
CHAR8 *src
);
#endif /* __xml_h__ */

View File

@ -750,7 +750,8 @@ VOID GetTableType4()
gCPUStructure.CurrentSpeed = SmbiosTable.Type4->CurrentSpeed; gCPUStructure.CurrentSpeed = SmbiosTable.Type4->CurrentSpeed;
gCPUStructure.MaxSpeed = SmbiosTable.Type4->MaxSpeed; gCPUStructure.MaxSpeed = SmbiosTable.Type4->MaxSpeed;
if (Size > 0x23) { //Smbios <=2.3 size_t off = OFFSET_OF(SMBIOS_TABLE_TYPE4, EnabledCoreCount);
if (SmbiosTable.Type4->Hdr.Length > off) { //Smbios >= 2.5
gSettings.EnabledCores = SmbiosTable.Type4->EnabledCoreCount; gSettings.EnabledCores = SmbiosTable.Type4->EnabledCoreCount;
} else { } else {
gSettings.EnabledCores = 0; //to change later gSettings.EnabledCores = 0; //to change later
@ -1281,12 +1282,14 @@ VOID GetTableType17()
} }
// DBG("CntMemorySlots = %d\n", gDMI->CntMemorySlots) // DBG("CntMemorySlots = %d\n", gDMI->CntMemorySlots)
// DBG("gDMI->MemoryModules = %d\n", gDMI->MemoryModules) // DBG("gDMI->MemoryModules = %d\n", gDMI->MemoryModules)
if ((SmbiosTable.Type17->Speed > 0) && (SmbiosTable.Type17->Speed <= MAX_RAM_FREQUENCY)) {
DBG("SmbiosTable.Type17->Speed = %dMHz\n", gRAM.SMBIOS[Index].Frequency); DBG("SmbiosTable.Type17->Speed = %dMHz\n", gRAM.SMBIOS[Index].Frequency);
DBG("SmbiosTable.Type17->Size = %dMB\n", gRAM.SMBIOS[Index].ModuleSize); DBG("SmbiosTable.Type17->Size = %dMB\n", gRAM.SMBIOS[Index].ModuleSize);
DBG("SmbiosTable.Type17->Bank/Device = %s %s\n", GetSmbiosString(SmbiosTable, SmbiosTable.Type17->BankLocator), GetSmbiosString(SmbiosTable, SmbiosTable.Type17->DeviceLocator)); DBG("SmbiosTable.Type17->Bank/Device = %s %s\n", GetSmbiosString(SmbiosTable, SmbiosTable.Type17->BankLocator), GetSmbiosString(SmbiosTable, SmbiosTable.Type17->DeviceLocator));
DBG("SmbiosTable.Type17->Vendor = %s\n", gRAM.SMBIOS[Index].Vendor); DBG("SmbiosTable.Type17->Vendor = %s\n", gRAM.SMBIOS[Index].Vendor);
DBG("SmbiosTable.Type17->SerialNumber = %s\n", gRAM.SMBIOS[Index].SerialNo); DBG("SmbiosTable.Type17->SerialNumber = %s\n", gRAM.SMBIOS[Index].SerialNo);
DBG("SmbiosTable.Type17->PartNumber = %s\n", gRAM.SMBIOS[Index].PartNo); DBG("SmbiosTable.Type17->PartNumber = %s\n", gRAM.SMBIOS[Index].PartNo);
}
/* /*
if ((SmbiosTable.Type17->Size & 0x8000) == 0) { if ((SmbiosTable.Type17->Size & 0x8000) == 0) {
@ -1690,7 +1693,7 @@ VOID PatchTableType17()
} }
if (trustSMBIOS && gRAM.SMBIOS[SMBIOSIndex].InUse && if (trustSMBIOS && gRAM.SMBIOS[SMBIOSIndex].InUse &&
(iStrLen(gRAM.SMBIOS[SMBIOSIndex].Vendor, 64) > 0) && (iStrLen(gRAM.SMBIOS[SMBIOSIndex].Vendor, 64) > 0) &&
(strncmp(gRAM.SPD[SPDIndex].Vendor, "NoName", 6) == 0)) { (!gRAM.SPD[SPDIndex].Vendor || strncmp(gRAM.SPD[SPDIndex].Vendor, "NoName", 6) == 0)) {
DBG("Type17->Manufacturer corrected by SMBIOS from NoName to %s\n", gRAM.SMBIOS[SMBIOSIndex].Vendor); DBG("Type17->Manufacturer corrected by SMBIOS from NoName to %s\n", gRAM.SMBIOS[SMBIOSIndex].Vendor);
UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, LString8(gRAM.SMBIOS[SMBIOSIndex].Vendor)); UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, LString8(gRAM.SMBIOS[SMBIOSIndex].Vendor));
} }
@ -2000,7 +2003,6 @@ EFI_STATUS PrepatchSmbios()
// DBG("OEM SMBIOS EPS=%p\n", Smbios); // DBG("OEM SMBIOS EPS=%p\n", Smbios);
// DBG("OEM Tables = %X\n", ((SMBIOS_TABLE_ENTRY_POINT*)Smbios)->TableAddress); // DBG("OEM Tables = %X\n", ((SMBIOS_TABLE_ENTRY_POINT*)Smbios)->TableAddress);
if (!Smbios) { if (!Smbios) {
Status = EFI_NOT_FOUND;
// DBG("Original SMBIOS System Table not found! Getting from Hob...\n"); // DBG("Original SMBIOS System Table not found! Getting from Hob...\n");
Smbios = GetSmbiosTablesFromHob(); Smbios = GetSmbiosTablesFromHob();
// DBG("HOB SMBIOS EPS=%p\n", Smbios); // DBG("HOB SMBIOS EPS=%p\n", Smbios);

View File

@ -904,7 +904,7 @@ VOID ScanSPD()
gPci.Hdr.ClassCode[2], gPci.Hdr.ClassCode[2],
gPci.Hdr.ClassCode[1], gPci.Hdr.ClassCode[1],
gPci.Hdr.ClassCode[0], gPci.Hdr.ClassCode[0],
strerror(Status) efiStrError(Status)
); );
read_smb(PciIo, gPci.Hdr.VendorId, gPci.Hdr.DeviceId); read_smb(PciIo, gPci.Hdr.VendorId, gPci.Hdr.DeviceId);
} }

View File

@ -196,10 +196,10 @@ XObjArray<TYPE>::XObjArray(bool FreeThem, TYPE* n1, ...)
va_start (va, n1); va_start (va, n1);
size_t count = 0; size_t count = 0;
TYPE* t = VA_ARG(va, TYPE*); TYPE* t = va_arg(va, TYPE*);
while ( t != nullptr ) { while ( t != nullptr ) {
count++; count++;
t = VA_ARG(va, TYPE*); t = va_arg(va, TYPE*);
} }
va_end(va); va_end(va);
@ -208,10 +208,10 @@ XObjArray<TYPE>::XObjArray(bool FreeThem, TYPE* n1, ...)
XObjArrayNC<TYPE>::AddReference(n1, FreeThem); XObjArrayNC<TYPE>::AddReference(n1, FreeThem);
va_start (va, n1); va_start (va, n1);
t = VA_ARG(va, TYPE*); t = va_arg(va, TYPE*);
while ( t != nullptr ) { while ( t != nullptr ) {
XObjArrayNC<TYPE>::AddReference(t, FreeThem); XObjArrayNC<TYPE>::AddReference(t, FreeThem);
t = VA_ARG(va, TYPE*); t = va_arg(va, TYPE*);
} }
va_end(va); va_end(va);
} }

View File

@ -78,9 +78,14 @@ int XStringAbstract__startWith(const S* src, const O* other, bool ignoreCase)
return src_char32 != 0; return src_char32 != 0;
} }
/*
* Returns 1 if src > other
*/
template<typename S, typename O> template<typename S, typename O>
int XStringAbstract__compare(const S* src, const O* other, bool ignoreCase) int XStringAbstract__compare(const S* src, const O* other, bool ignoreCase)
{ {
if ( src == NULL || *src == 0 ) return other == NULL || *other == 0 ? 0 : -1;
if ( other == NULL || *other == 0 ) return 1;
// size_t len_s = length_of_utf_string(src); // size_t len_s = length_of_utf_string(src);
// size_t len_other = length_of_utf_string(other); // size_t len_other = length_of_utf_string(other);
size_t nb = 0; size_t nb = 0;
@ -729,10 +734,11 @@ public:
/* Copy Assign */ // Only other XString, no litteral at the moment. /* Copy Assign */ // Only other XString, no litteral at the moment.
XStringAbstract& operator=(const XStringAbstract &S) { takeValueFrom(S); return *this; } XStringAbstract& operator=(const XStringAbstract &S) { takeValueFrom(S); return *this; }
/* Assign */ /* Assign */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++" #pragma GCC diagnostic ignored "-Weffc++"
template<typename O, class OtherXStringClass> template<typename O, class OtherXStringClass>
ThisXStringClass& operator =(const __String<O, OtherXStringClass>& S) { strcpy(S.s()); return *((ThisXStringClass*)this); } ThisXStringClass& operator =(const __String<O, OtherXStringClass>& S) { strcpy(S.s()); return *((ThisXStringClass*)this); }
#pragma GCC diagnostic warning "-Weffc++" #pragma GCC diagnostic pop
// TEMPORARILY DISABLED // TEMPORARILY DISABLED
// template<class O> // template<class O>
// ThisXStringClass& operator =(const O* S) { strcpy(S); return *this; } // ThisXStringClass& operator =(const O* S) { strcpy(S); return *this; }
@ -966,7 +972,7 @@ public:
char32_t char32; char32_t char32;
T* previousData = m_data; T* previousData = m_data;
T* previousP = m_data; T* previousP = m_data;
T* p = get_char32_from_string(previousP, &char32);; T* p = get_char32_from_string(previousP, &char32);
while ( char32 ) { while ( char32 ) {
if (!char32) break; if (!char32) break;
if ( char32 == charToSearch ) { if ( char32 == charToSearch ) {
@ -983,7 +989,7 @@ public:
utf_stringnn_from_utf_string(previousP, charToReplaceBySize, &charToReplaceBy); utf_stringnn_from_utf_string(previousP, charToReplaceBySize, &charToReplaceBy);
} }
previousP = p; previousP = p;
p = get_char32_from_string(previousP, &char32);; p = get_char32_from_string(previousP, &char32);
} }
return *((ThisXStringClass*)this); return *((ThisXStringClass*)this);
} }

View File

@ -15,6 +15,7 @@
#include "LoadOptions_test.h" #include "LoadOptions_test.h"
#include "XToolsCommon_test.h" #include "XToolsCommon_test.h"
#include "XBuffer_tests.h" #include "XBuffer_tests.h"
#include "plist_tests.h"
#if defined(JIEF_DEBUG) && defined(CLOVER_BUILD) #if defined(JIEF_DEBUG) && defined(CLOVER_BUILD)
#include "printlib-test.h" #include "printlib-test.h"
@ -38,16 +39,16 @@ bool all_tests()
// all_ok = false; // all_ok = false;
// } // }
#if defined(JIEF_DEBUG) #if defined(JIEF_DEBUG)
ret = XBuffer_tests(); ret = plist_tests();
if ( ret != 0 ) { if ( ret != 0 ) {
printf("XBuffer_tests() failed at test %d\n", ret); printf("plist_tests() failed at test %d\n", ret);
all_ok = false;
}
ret = XToolsCommon_tests();
if ( ret != 0 ) {
printf("printlib_tests() failed at test %d\n", ret);
all_ok = false; all_ok = false;
} }
// ret = XBuffer_tests();
// if ( ret != 0 ) {
// printf("XBuffer_tests() failed at test %d\n", ret);
// all_ok = false;
// }
//return ret; //return ret;
// ret = XUINTN_tests(); // ret = XUINTN_tests();
// if ( ret != 0 ) { // if ( ret != 0 ) {
@ -84,6 +85,11 @@ bool all_tests()
printf("strncmp_tests() failed at test %d\n", ret); printf("strncmp_tests() failed at test %d\n", ret);
all_ok = false; all_ok = false;
} }
ret = XToolsCommon_tests();
if ( ret != 0 ) {
printf("printlib_tests() failed at test %d\n", ret);
all_ok = false;
}
ret = XArray_tests(); ret = XArray_tests();
if ( ret != 0 ) { if ( ret != 0 ) {
printf("XArray_tests() failed at test %d\n", ret); printf("XArray_tests() failed at test %d\n", ret);
@ -114,11 +120,11 @@ bool all_tests()
printf("XBuffer_tests() failed at test %d\n", ret); printf("XBuffer_tests() failed at test %d\n", ret);
all_ok = false; all_ok = false;
} }
// ret = XUINTN_tests(); ret = plist_tests();
// if ( ret != 0 ) { if ( ret != 0 ) {
// printf("XUINTN_tests() failed at test %d\n", ret); printf("plist_tests() failed at test %d\n", ret);
// all_ok = false; all_ok = false;
// } }
if ( !all_ok ) { if ( !all_ok ) {
printf("A test failed\n"); printf("A test failed\n");

View File

@ -0,0 +1,927 @@
#include <Platform.h> // Only use angled for Platform, else, xcode project won't compile
#include "../cpp_foundation/XString.h"
#include "../cpp_foundation/unicode_conversions.h"
#include "../Platform/plist/plist.h"
const char* config_all =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?> \
<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"> \
<plist version=\"1.0\"> \
<dict> \
<key>ACPI</key> \
<dict> \
<key>AutoMerge</key> \
<true/> \
<key>DSDT</key> \
<dict> \
<key>Debug</key> \
<true/> \
<key>DropOEM_DSM</key> \
<dict> \
<key>ATI</key> \
<true/> \
<key>Firewire</key> \
<false/> \
<key>HDA</key> \
<false/> \
<key>HDMI</key> \
<false/> \
<key>IDE</key> \
<true/> \
<key>IntelGFX</key> \
<false/> \
<key>LAN</key> \
<false/> \
<key>LPC</key> \
<false/> \
<key>NVidia</key> \
<false/> \
<key>SATA</key> \
<false/> \
<key>SmBUS</key> \
<false/> \
<key>USB</key> \
<false/> \
<key>WIFI</key> \
<false/> \
</dict> \
<key>Fixes</key> \
<dict> \
<key>FixDarwin</key> \
<true/> \
<key>FixDisplay</key> \
<true/> \
<key>FixS3D</key> \
<true/> \
</dict> \
<key>Name</key> \
<string>aa</string> \
<key>Patches</key> \
<array> \
<dict> \
<key>Comment</key> \
<string>ACPI1</string> \
<key>Disabled</key> \
<false/> \
<key>Find</key> \
<data> \
AA== \
</data> \
<key>Replace</key> \
<data> \
AQ== \
</data> \
</dict> \
<dict> \
<key>Comment</key> \
<string>ACPI2</string> \
<key>Disabled</key> \
<true/> \
<key>Find</key> \
<data> \
Ag== \
</data> \
<key>Replace</key> \
<data> \
Aw== \
</data> \
</dict> \
<dict> \
<key>Comment</key> \
<string>change EHC1 to EH01</string> \
<key>Disabled</key> \
<false/> \
<key>Find</key> \
<data> \
RUhDMQ== \
</data> \
<key>Replace</key> \
<data> \
RUgwMQ== \
</data> \
</dict> \
</array> \
<key>ReuseFFFF</key> \
<true/> \
<key>Rtc8Allowed</key> \
<true/> \
<key>SlpSmiAtWake</key> \
<true/> \
<key>SuspendOverride</key> \
<true/> \
</dict> \
<key>DisableAPSNAPLF</key> \
<true/> \
<key>DisableASPM</key> \
<true/> \
<key>DisabledAML</key> \
<array> \
<string>aa</string> \
<string>bb</string> \
</array> \
<key>DropTables</key> \
<array> \
<dict> \
<key>Signature</key> \
<string>SSDT</string> \
<key>TableId</key> \
<string>CpuPm</string> \
</dict> \
</array> \
<key>HaltEnabler</key> \
<true/> \
<key>PatchAPIC</key> \
<true/> \
<key>ResetAddress</key> \
<string>01</string> \
<key>ResetValue</key> \
<string>02</string> \
<key>SortedOrder</key> \
<array> \
<string>dd</string> \
<string>cc</string> \
</array> \
<key>smartUPS</key> \
<true/> \
</dict> \
<key>Boot</key> \
<dict> \
<key>Arguments</key> \
<string>-v arch=i386 slide=0 dart=0 -xcpm darkwake=1 npci=0x2000 cpus=1 debug=0x100 aa</string> \
<key>BlackList</key> \
<array> \
<string>hh</string> \
</array> \
<key>CustomLogo</key> \
<string>Apple</string> \
<key>Debug</key> \
<true/> \
<key>DefaultLoader</key> \
<string>ii</string> \
<key>DefaultVolume</key> \
<string>LastBootedVolume</string> \
<key>DisableCloverHotkeys</key> \
<true/> \
<key>HibernationFixup</key> \
<true/> \
<key>Legacy</key> \
<string>LegacyBiosDefault</string> \
<key>LegacyBiosDefaultEntry</key> \
<integer>12</integer> \
<key>NeverDoRecovery</key> \
<true/> \
<key>NeverHibernate</key> \
<true/> \
<key>NoEarlyProgress</key> \
<true/> \
<key>Policy</key> \
<string>Allow</string> \
<key>Secure</key> \
<true/> \
<key>SignatureFixup</key> \
<true/> \
<key>SkipHibernateTimeout</key> \
<true/> \
<key>StrictHibernate</key> \
<true/> \
<key>Timeout</key> \
<integer>2</integer> \
<key>WhiteList</key> \
<array> \
<string>ff</string> \
<string>gg</string> \
</array> \
<key>XMPDetection</key> \
<integer>1</integer> \
</dict> \
<key>BootGraphics</key> \
<dict> \
<key>DefaultBackgroundColor</key> \
<string>0xF1F1F1</string> \
<key>EFILoginHiDPI</key> \
<integer>2</integer> \
<key>UIScale</key> \
<integer>4</integer> \
<key>flagstate</key> \
<integer>3</integer> \
</dict> \
<key>CPU</key> \
<dict> \
<key>BusSpeedkHz</key> \
<integer>800</integer> \
<key>C2</key> \
<true/> \
<key>C4</key> \
<true/> \
<key>C6</key> \
<true/> \
<key>FrequencyMHz</key> \
<integer>2000</integer> \
<key>HWPEnable</key> \
<true/> \
<key>HWPValue</key> \
<string>0x7</string> \
<key>Latency</key> \
<string>0x3</string> \
<key>QEMU</key> \
<true/> \
<key>QPI</key> \
<integer>4</integer> \
<key>TDP</key> \
<integer>6</integer> \
<key>TurboDisable</key> \
<true/> \
<key>Type</key> \
<string>0x5</string> \
<key>UseARTFrequency</key> \
<true/> \
</dict> \
<key>Devices</key> \
<dict> \
<key>AddProperties</key> \
<array> \
<dict> \
<key>Device</key> \
<string>SATA</string> \
<key>Disabled</key> \
<false/> \
<key>Key</key> \
<string>10</string> \
<key>Value</key> \
<integer>11</integer> \
</dict> \
<dict> \
<key>Device</key> \
<string>LPC</string> \
<key>Disabled</key> \
<true/> \
<key>Key</key> \
<string>12</string> \
<key>Value</key> \
<integer>13</integer> \
</dict> \
<dict> \
<key>Device</key> \
<string>SmBUS</string> \
<key>Disabled</key> \
<false/> \
<key>Key</key> \
<string>kk</string> \
<key>Value</key> \
<string>ll</string> \
</dict> \
<dict> \
<key>Device</key> \
<string>Firewire</string> \
<key>Disabled</key> \
<false/> \
<key>Key</key> \
<string>14</string> \
<key>Value</key> \
<data> \
FQ== \
</data> \
</dict> \
</array> \
<key>AirportBridgeDeviceName</key> \
<string>airportbridge</string> \
<key>Arbitrary</key> \
<array> \
<dict> \
<key>Comment</key> \
<string>C1</string> \
<key>CustomProperties</key> \
<array> \
<dict> \
<key>Disabled</key> \
<false/> \
<key>Key</key> \
<string>ll</string> \
<key>Value</key> \
<string>mm</string> \
</dict> \
<dict> \
<key>Disabled</key> \
<true/> \
<key>Key</key> \
<string>nn</string> \
<key>Value</key> \
<integer>1</integer> \
</dict> \
<dict> \
<key>Disabled</key> \
<false/> \
<key>Key</key> \
<string>oo</string> \
<key>Value</key> \
<data> \
Ag== \
</data> \
</dict> \
</array> \
<key>PciAddr</key> \
<string>00:00.01</string> \
</dict> \
</array> \
<key>Audio</key> \
<dict> \
<key>AFGLowPowerState</key> \
<true/> \
<key>Inject</key> \
<string>Detect</string> \
<key>ResetHDA</key> \
<true/> \
</dict> \
<key>DisableFunctions</key> \
<true/> \
<key>FakeID</key> \
<dict> \
<key>ATI</key> \
<string>0x22221002</string> \
<key>IMEI</key> \
<string>0x22221002</string> \
<key>IntelGFX</key> \
<string>0x22221002</string> \
<key>LAN</key> \
<string>0x22221002</string> \
<key>NVidia</key> \
<string>0x22221002</string> \
<key>SATA</key> \
<string>0x22221002</string> \
<key>WIFI</key> \
<string>0x22221002</string> \
<key>XHCI</key> \
<string>0x22221002</string> \
</dict> \
<key>ForceHPET</key> \
<true/> \
<key>Inject</key> \
<true/> \
<key>IntelMaxValue</key> \
<true/> \
<key>LpcTune</key> \
<true/> \
<key>NoDefaultProperties</key> \
<true/> \
<key>Properties</key> \
<string>jj \
kk</string> \
<key>SetIntelBacklight</key> \
<true/> \
<key>SetIntelMaxBacklight</key> \
<true/> \
<key>USB</key> \
<dict> \
<key>AddClockID</key> \
<true/> \
<key>FixOwnership</key> \
<true/> \
<key>HighCurrent</key> \
<true/> \
<key>Inject</key> \
<true/> \
</dict> \
<key>UseIntelHDMI</key> \
<true/> \
</dict> \
<key>DisableDrivers</key> \
<array> \
<string>OsxAptioFixDrv</string> \
<string>Ps2KeyboardDxe</string> \
<string>Ps2MouseDxe</string> \
</array> \
<key>GUI</key> \
<dict> \
<key>ConsoleMode</key> \
<string>Max</string> \
<key>Custom</key> \
<dict> \
<key>Entries</key> \
<array> \
<dict> \
<key>AddArguments</key> \
<string>addarg</string> \
<key>Arguments</key> \
<string>arg</string> \
<key>BootBgColor</key> \
<string>bootbgcolor</string> \
<key>CustomLogo</key> \
<string>Apple</string> \
<key>Disabled</key> \
<true/> \
<key>DriveImage</key> \
<string>driveimage</string> \
<key>FullTitle</key> \
<string>title</string> \
<key>Hidden</key> \
<false/> \
<key>Hotkey</key> \
<string>H</string> \
<key>Ignore</key> \
<true/> \
<key>Image</key> \
<string>image</string> \
<key>Path</key> \
<string>path</string> \
<key>Settings</key> \
<string>settings</string> \
<key>SubEntries</key> \
<array> \
<dict> \
<key>AddArguments</key> \
<string>arg2</string> \
<key>FullTitle</key> \
<string>title1</string> \
</dict> \
<dict> \
<key>AddArguments</key> \
<string>arg3</string> \
<key>Title</key> \
<string>title2</string> \
</dict> \
<dict> \
<key>AddArguments</key> \
<string>arg4</string> \
<key>FullTitle</key> \
<string>title3</string> \
</dict> \
<dict> \
<key>AddArguments</key> \
<string>arg5</string> \
<key>Title</key> \
<string>title4</string> \
</dict> \
</array> \
<key>Type</key> \
<string>Oldest</string> \
<key>Volume</key> \
<string>v1</string> \
<key>VolumeType</key> \
<string>Internal</string> \
</dict> \
</array> \
<key>Legacy</key> \
<array> \
<dict> \
<key>Disabled</key> \
<true/> \
<key>FullTitle</key> \
<string>title</string> \
<key>Hidden</key> \
<true/> \
<key>Hotkey</key> \
<string></string> \
<key>Ignore</key> \
<true/> \
<key>Type</key> \
<string>Windows</string> \
<key>Volume</key> \
<string>v2</string> \
</dict> \
</array> \
<key>Tool</key> \
<array> \
<dict> \
<key>Arguments</key> \
<string>b</string> \
<key>Disabled</key> \
<true/> \
<key>Hidden</key> \
<true/> \
<key>Hotkey</key> \
<string>b</string> \
<key>Ignore</key> \
<true/> \
<key>Path</key> \
<string>path</string> \
<key>Title</key> \
<string>title</string> \
<key>Volume</key> \
<string>tool1</string> \
</dict> \
</array> \
</dict> \
<key>CustomIcons</key> \
<true/> \
<key>Hide</key> \
<array> \
<string>sdfsdfdf</string> \
<string>sdfsfdf</string> \
</array> \
<key>Language</key> \
<string>es:0</string> \
<key>Mouse</key> \
<dict> \
<key>DoubleClick</key> \
<integer>501</integer> \
<key>Enabled</key> \
<true/> \
<key>Mirror</key> \
<true/> \
<key>Speed</key> \
<integer>5</integer> \
</dict> \
<key>Scan</key> \
<dict> \
<key>Entries</key> \
<true/> \
<key>Kernel</key> \
<string>First</string> \
<key>Legacy</key> \
<string>First</string> \
<key>Linux</key> \
<true/> \
<key>Tool</key> \
<true/> \
</dict> \
<key>ScreenResolution</key> \
<string>1366x768</string> \
<key>ShowOptimus</key> \
<true/> \
<key>TextOnly</key> \
<true/> \
<key>Theme</key> \
<string>th</string> \
</dict> \
<key>Graphics</key> \
<dict> \
<key>ATI</key> \
<array> \
<dict> \
<key>IOPCIPrimaryMatch</key> \
<string>0x1002888</string> \
<key>IOPCISubDevId</key> \
<string>0x106B</string> \
<key>LoadVBios</key> \
<true/> \
<key>Model</key> \
<string>cc</string> \
<key>VRAM</key> \
<integer>2000</integer> \
<key>VideoPorts</key> \
<integer>3</integer> \
</dict> \
</array> \
<key>BootDisplay</key> \
<integer>12</integer> \
<key>DualLink</key> \
<integer>1</integer> \
<key>EDID</key> \
<dict> \
<key>Custom</key> \
<data> \
AQID \
</data> \
<key>Inject</key> \
<true/> \
<key>ProductID</key> \
<string>0x9777</string> \
<key>VendorID</key> \
<string>0x1007</string> \
</dict> \
<key>FBName</key> \
<string>Exmoor</string> \
<key>Inject</key> \
<dict> \
<key>ATI</key> \
<true/> \
<key>Intel</key> \
<true/> \
<key>NVidia</key> \
<true/> \
</dict> \
<key>LoadVBios</key> \
<true/> \
<key>NVCAP</key> \
<string>0304</string> \
<key>NVIDIA</key> \
<array> \
<dict> \
<key>IOPCIPrimaryMatch</key> \
<string>0x10DE999</string> \
<key>IOPCISubDevId</key> \
<string>0x106B</string> \
<key>LoadVBios</key> \
<false/> \
<key>Model</key> \
<string>aa</string> \
<key>VRAM</key> \
<integer>1000</integer> \
<key>VideoPorts</key> \
<integer>1</integer> \
</dict> \
<dict> \
<key>IOPCIPrimaryMatch</key> \
<string>0x10DE999</string> \
<key>IOPCISubDevId</key> \
<string>0x106B</string> \
<key>LoadVBios</key> \
<true/> \
<key>Model</key> \
<string>bb</string> \
<key>VRAM</key> \
<integer>1000</integer> \
<key>VideoPorts</key> \
<integer>2</integer> \
</dict> \
</array> \
<key>NvidiaGeneric</key> \
<true/> \
<key>NvidiaNoEFI</key> \
<true/> \
<key>NvidiaSingle</key> \
<true/> \
<key>PatchVBios</key> \
<true/> \
<key>PatchVBiosBytes</key> \
<array> \
<dict> \
<key>Find</key> \
<data> \
AwQF \
</data> \
<key>Replace</key> \
<data> \
BgcI \
</data> \
</dict> \
</array> \
<key>VRAM</key> \
<integer>1500</integer> \
<key>VideoPorts</key> \
<integer>2</integer> \
<key>display-cfg</key> \
<string>04</string> \
<key>ig-platform-id</key> \
<string>0x59230000</string> \
</dict> \
<key>KernelAndKextPatches</key> \
<dict> \
<key>ATIConnectorsController</key> \
<string>ATICtl</string> \
<key>ATIConnectorsData</key> \
<string>111213</string> \
<key>ATIConnectorsPatch</key> \
<string>141516</string> \
<key>AppleIntelCPUPM</key> \
<true/> \
<key>AppleRTC</key> \
<true/> \
<key>BootPatches</key> \
<array> \
<dict> \
<key>Comment</key> \
<string>c3</string> \
<key>Disabled</key> \
<true/> \
<key>Find</key> \
<data> \
MTI= \
</data> \
<key>MatchBuild</key> \
<string>10.12.6</string> \
<key>MatchOS</key> \
<string>10.12</string> \
<key>Replace</key> \
<data> \
MzQ= \
</data> \
</dict> \
</array> \
<key>Debug</key> \
<true/> \
<key>DellSMBIOSPatch</key> \
<true/> \
<key>FakeCPUID</key> \
<string>0x0306D0</string> \
<key>ForceKextsToLoad</key> \
<array> \
<string>ForceKext</string> \
</array> \
<key>KernelCpu</key> \
<true/> \
<key>KernelLapic</key> \
<true/> \
<key>KernelPm</key> \
<true/> \
<key>KernelToPatch</key> \
<array> \
<dict> \
<key>Comment</key> \
<string>c2</string> \
<key>Disabled</key> \
<true/> \
<key>Find</key> \
<data> \
ISI= \
</data> \
<key>MatchBuild</key> \
<string>10.13.6</string> \
<key>MatchOS</key> \
<string>10.13</string> \
<key>Replace</key> \
<data> \
IyQ= \
</data> \
</dict> \
</array> \
<key>KernelXCPM</key> \
<true/> \
<key>KextsToPatch</key> \
<array> \
<dict> \
<key>Comment</key> \
<string>c1</string> \
<key>Disabled</key> \
<true/> \
<key>Find</key> \
<data> \
AQ== \
</data> \
<key>InfoPlistPatch</key> \
<true/> \
<key>MatchBuild</key> \
<string>10.14.6</string> \
<key>MatchOS</key> \
<string>10.14</string> \
<key>Name</key> \
<string>k1</string> \
<key>Replace</key> \
<data> \
Ag== \
</data> \
</dict> \
<dict> \
<key>Comment</key> \
<string>IONVMeFamily IONameMatch</string> \
<key>Disabled</key> \
<false/> \
<key>Find</key> \
<data> \
PHN0cmluZz5wY2kxNDRkLGE4MDQ8L3N0cmluZz4= \
</data> \
<key>InfoPlistPatch</key> \
<true/> \
<key>Name</key> \
<string>IONVMeFamily</string> \
<key>Replace</key> \
<data> \
PHN0cmluZz5wY2kxNDRkLGE4MDI8L3N0cmluZz4= \
</data> \
</dict> \
</array> \
</dict> \
<key>RtVariables</key> \
<dict> \
<key>BooterConfig</key> \
<string>0x1</string> \
<key>CsrActiveConfig</key> \
<string>0x2</string> \
<key>MLB</key> \
<string>12345678901234567</string> \
<key>ROM</key> \
<data> \
MBRwYnHo \
</data> \
</dict> \
<key>SMBIOS</key> \
<dict> \
<key>BiosReleaseDate</key> \
<string>08/08/17</string> \
<key>BiosVendor</key> \
<string>Apple Inc.</string> \
<key>BiosVersion</key> \
<string>MBP81.88Z.004D.B00.1708080655</string> \
<key>Board-ID</key> \
<string>Mac-94245B3640C91C81</string> \
<key>BoardManufacturer</key> \
<string>Apple Inc.</string> \
<key>BoardSerialNumber</key> \
<string>W89135306OPDM6CAD</string> \
<key>BoardType</key> \
<integer>10</integer> \
<key>BoardVersion</key> \
<string>1.0</string> \
<key>ChassisAssetTag</key> \
<string>MacBook-Aluminum</string> \
<key>ChassisManufacturer</key> \
<string>Apple Inc.</string> \
<key>ChassisType</key> \
<string>0x0A</string> \
<key>Family</key> \
<string>MacBook Pro</string> \
<key>FirmwareFeatures</key> \
<string>0xC00DE137</string> \
<key>FirmwareFeaturesMask</key> \
<string>0xFF1FFF3F</string> \
<key>LocationInChassis</key> \
<string>Part Component</string> \
<key>Manufacturer</key> \
<string>Apple Inc.</string> \
<key>Memory</key> \
<dict> \
<key>Channels</key> \
<integer>2</integer> \
<key>Modules</key> \
<array> \
<dict> \
<key>Frequency</key> \
<integer>333</integer> \
<key>Part</key> \
<string>Part1</string> \
<key>Serial</key> \
<string>Ser1</string> \
<key>Size</key> \
<integer>2048</integer> \
<key>Slot</key> \
<integer>1</integer> \
<key>Type</key> \
<string>DDR</string> \
<key>Vendor</key> \
<string>v1</string> \
</dict> \
<dict> \
<key>Frequency</key> \
<integer>366</integer> \
<key>Part</key> \
<string>Part2</string> \
<key>Serial</key> \
<string>Ser2</string> \
<key>Size</key> \
<integer>4096</integer> \
<key>Slot</key> \
<integer>2</integer> \
<key>Type</key> \
<string>DDR2</string> \
<key>Vendor</key> \
<string>v2</string> \
</dict> \
</array> \
<key>SlotCount</key> \
<integer>4</integer> \
</dict> \
<key>Mobile</key> \
<true/> \
<key>PlatformFeature</key> \
<string>0xFFFF</string> \
<key>ProductName</key> \
<string>MacBookPro8,1</string> \
<key>SerialNumber</key> \
<string>W89G91VFDH2G</string> \
<key>Slots</key> \
<array> \
<dict> \
<key>Device</key> \
<string>NVidia</string> \
<key>ID</key> \
<integer>1</integer> \
<key>Name</key> \
<string>APPL,sdfsdf</string> \
<key>Type</key> \
<integer>1</integer> \
</dict> \
</array> \
<key>SmUUID</key> \
<string>F1AB23C0-C35A-473E-BDB7-455C3A6271E8</string> \
<key>Version</key> \
<string>1.0</string> \
</dict> \
<key>SystemParameters</key> \
<dict> \
<key>BacklightLevel</key> \
<string>2</string> \
<key>CustomUUID</key> \
<string>2926A57C-FF0E-4A64-980F-23483BD41969</string> \
<key>ExposeSysVariables</key> \
<true/> \
<key>InjectKexts</key> \
<string>Yes</string> \
<key>InjectSystemID</key> \
<true/> \
<key>NoCaches</key> \
<true/> \
<key>NvidiaWeb</key> \
<true/> \
</dict> \
</dict> \
</plist>";
int plist_tests()
{
TagDict* dict = NULL;
EFI_STATUS Status = ParseXML(config_all, &dict, (UINT32)strlen(config_all));
if ( !EFI_ERROR(Status) ) {
XString8 s;
dict->sprintf(0, &s);
TagDict* dict2 = NULL;
Status = ParseXML(s.c_str(), &dict2, s.length());
if ( !EFI_ERROR(Status) ) {
if ( !(*dict).debugIsEqual(*dict2, "plist"_XS8) ) {
// printf("%s", s.c_str());
return 1;
}
}
}
return 0;
}

View File

@ -0,0 +1 @@
int plist_tests();

View File

@ -42,8 +42,7 @@ static int strcmp_reference(const char *p1, const char *p2)
static int compare(const char*s1, const char*s2) static int compare(const char*s1, const char*s2)
{ {
int ret1 = strcmp(s1, s2); int ret1 = strcmp(s1, s2);
int ret2 = strcmp_reference(s1, s2);; int ret2 = strcmp_reference(s1, s2);
if ( sign(ret1) != sign(ret2) ) { if ( sign(ret1) != sign(ret2) ) {
printf("Comparing '%s' and '%s' gives %d and should have given %d\n", s1, s2, ret1, ret2); printf("Comparing '%s' and '%s' gives %d and should have given %d\n", s1, s2, ret1, ret2);
return 1; // whatever if not 0 return 1; // whatever if not 0

View File

@ -33,14 +33,3 @@ void* memset(void* dst, int ch, size_t count)
#endif #endif
} // extern "C" } // extern "C"
CONST CHAR16 *
EFIAPI
ConstStrStr (
IN CONST CHAR16 *String,
IN CONST CHAR16 *SearchString
)
{
return StrStr((CHAR16*)String, SearchString);
}

View File

@ -0,0 +1,13 @@
//
// pure_virtual.cpp
// CloverX64
//
// Created by Jief on 24/08/2020.
//
#include "../Platform/Platform.h"
extern "C" void __cxa_pure_virtual()
{
panic("Pure virtual function called");
}

View File

@ -124,7 +124,7 @@ VOID EnableSecureBoot(VOID)
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
XStringW Str = SWPrintf("Enabling secure boot failed because\n%ls", ErrorString); XStringW Str = SWPrintf("Enabling secure boot failed because\n%ls", ErrorString);
AlertMessage(L"Enable Secure Boot", Str); AlertMessage(L"Enable Secure Boot", Str);
DBG("Enabling secure boot failed because %ls! Status: %s\n", ErrorString.wc_str(), strerror(Status)); DBG("Enabling secure boot failed because %ls! Status: %s\n", ErrorString.wc_str(), efiStrError(Status));
DisableSecureBoot(); DisableSecureBoot();
} }
} }
@ -166,9 +166,9 @@ STATIC VOID DisableMessage(IN EFI_STATUS Status,
{ {
XStringW Str; XStringW Str;
if (ErrorString != NULL) { if (ErrorString != NULL) {
Str = SWPrintf(L"%ls\n%ls\n%ls", String, ErrorString, strerror(Status)); Str = SWPrintf(L"%ls\n%ls\n%ls", String, ErrorString, efiStrError(Status));
} else { } else {
Str = SWPrintf(L"%s\n%s", String, strerror(Status)); Str = SWPrintf(L"%s\n%s", String, efiStrError(Status));
} }
DBG("Secure Boot: %ls", Str.wc_str()); DBG("Secure Boot: %ls", Str.wc_str());
AlertMessage(L"Disable Secure Boot", Str); AlertMessage(L"Disable Secure Boot", Str);
@ -358,7 +358,7 @@ InternalFileAuthentication(IN CONST EFI_SECURITY_ARCH_PROTOCOL *This,
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
CHAR16 *DevicePathStr = FileDevicePathToStr((EFI_DEVICE_PATH_PROTOCOL *)DevicePath); CHAR16 *DevicePathStr = FileDevicePathToStr((EFI_DEVICE_PATH_PROTOCOL *)DevicePath);
if (DevicePathStr) { if (DevicePathStr) {
DBG("VerifySecureBootImage(1): %s %ls\n", strerror(Status), DevicePathStr); DBG("VerifySecureBootImage(1): %s %ls\n", efiStrError(Status), DevicePathStr);
FreePool(DevicePathStr); FreePool(DevicePathStr);
} }
} }
@ -385,7 +385,7 @@ Internal2FileAuthentication(IN CONST EFI_SECURITY2_ARCH_PROTOCOL *This,
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
CHAR16 *DevicePathStr = FileDevicePathToStr((EFI_DEVICE_PATH_PROTOCOL *)DevicePath); CHAR16 *DevicePathStr = FileDevicePathToStr((EFI_DEVICE_PATH_PROTOCOL *)DevicePath);
if (DevicePathStr) { if (DevicePathStr) {
DBG("VerifySecureBootImage(2): %s %ls\n", strerror(Status), DevicePathStr); DBG("VerifySecureBootImage(2): %s %ls\n", efiStrError(Status), DevicePathStr);
FreePool(DevicePathStr); FreePool(DevicePathStr);
} }
} }
@ -404,7 +404,7 @@ EFI_STATUS VerifySecureBootImage(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath)
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
CHAR16 *DevicePathStr = FileDevicePathToStr((EFI_DEVICE_PATH_PROTOCOL *)DevicePath); CHAR16 *DevicePathStr = FileDevicePathToStr((EFI_DEVICE_PATH_PROTOCOL *)DevicePath);
if (DevicePathStr) { if (DevicePathStr) {
DBG("VerifySecureBootImage: %s %ls\n", strerror(Status), DevicePathStr); DBG("VerifySecureBootImage: %s %ls\n", efiStrError(Status), DevicePathStr);
FreePool(DevicePathStr); FreePool(DevicePathStr);
} }
} }

View File

@ -118,7 +118,7 @@ EFI_STATUS EnrollSecureBootKeys(IN VOID *AuthorizedDatabase,
if (Database != NULL) { if (Database != NULL) {
FreePool(Database); FreePool(Database);
} }
DBG("Failed to modify authorized database with Canonical key! %s\n", strerror(Status)); DBG("Failed to modify authorized database with Canonical key! %s\n", efiStrError(Status));
return Status; return Status;
} }
Status = AppendSignatureToDatabase(&Database, &DatabaseSize, &gEfiCertX509Guid, (VOID *)gSecureBootMSPCADatabaseKey, sizeof(gSecureBootMSPCADatabaseKey)); Status = AppendSignatureToDatabase(&Database, &DatabaseSize, &gEfiCertX509Guid, (VOID *)gSecureBootMSPCADatabaseKey, sizeof(gSecureBootMSPCADatabaseKey));
@ -126,7 +126,7 @@ EFI_STATUS EnrollSecureBootKeys(IN VOID *AuthorizedDatabase,
if (Database != NULL) { if (Database != NULL) {
FreePool(Database); FreePool(Database);
} }
DBG("Failed to modify authorized database with MS PCA key! %s\n", strerror(Status)); DBG("Failed to modify authorized database with MS PCA key! %s\n", efiStrError(Status));
return Status; return Status;
} }
Status = AppendSignatureToDatabase(&Database, &DatabaseSize, &gEfiCertX509Guid, (VOID *)gSecureBootMSUEFICADatabaseKey, sizeof(gSecureBootMSUEFICADatabaseKey)); Status = AppendSignatureToDatabase(&Database, &DatabaseSize, &gEfiCertX509Guid, (VOID *)gSecureBootMSUEFICADatabaseKey, sizeof(gSecureBootMSUEFICADatabaseKey));
@ -134,7 +134,7 @@ EFI_STATUS EnrollSecureBootKeys(IN VOID *AuthorizedDatabase,
if (Database != NULL) { if (Database != NULL) {
FreePool(Database); FreePool(Database);
} }
DBG("Failed to modify authorized database with MS UEFICA key! %s\n", strerror(Status)); DBG("Failed to modify authorized database with MS UEFICA key! %s\n", efiStrError(Status));
return Status; return Status;
} }
} }
@ -148,7 +148,7 @@ EFI_STATUS EnrollSecureBootKeys(IN VOID *AuthorizedDatabase,
// Append keys if needed... // Append keys if needed...
} }
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG("Failed to set the authorized database! %s\n", strerror(Status)); DBG("Failed to set the authorized database! %s\n", efiStrError(Status));
return Status; return Status;
} }
// We set the unauthorized database // We set the unauthorized database
@ -168,7 +168,7 @@ EFI_STATUS EnrollSecureBootKeys(IN VOID *AuthorizedDatabase,
FreePool(Database); FreePool(Database);
DatabaseSize = 0; DatabaseSize = 0;
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG("Failed to set the unauthorized database! %s\n", strerror(Status)); DBG("Failed to set the unauthorized database! %s\n", efiStrError(Status));
return Status; return Status;
} }
} }
@ -194,7 +194,7 @@ EFI_STATUS EnrollSecureBootKeys(IN VOID *AuthorizedDatabase,
if (Database != NULL) { if (Database != NULL) {
FreePool(Database); FreePool(Database);
} }
DBG("Failed to modify exchange database with MS exchange key! %s\n", strerror(Status)); DBG("Failed to modify exchange database with MS exchange key! %s\n", efiStrError(Status));
return Status; return Status;
} }
} }
@ -207,7 +207,7 @@ EFI_STATUS EnrollSecureBootKeys(IN VOID *AuthorizedDatabase,
if (Database != NULL) { if (Database != NULL) {
FreePool(Database); FreePool(Database);
} }
DBG("Failed to modify exchange database! %s\n", strerror(Status)); DBG("Failed to modify exchange database! %s\n", efiStrError(Status));
return Status; return Status;
} }
DBG("Setting the exchange database ...\n"); DBG("Setting the exchange database ...\n");
@ -216,7 +216,7 @@ EFI_STATUS EnrollSecureBootKeys(IN VOID *AuthorizedDatabase,
DatabaseSize = 0; DatabaseSize = 0;
Database = NULL; Database = NULL;
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG("Failed to set exchange database key! %s\n", strerror(Status)); DBG("Failed to set exchange database key! %s\n", efiStrError(Status));
return Status; return Status;
} }
// Unsure if default platform database should be enrolled.....??? // Unsure if default platform database should be enrolled.....???

View File

@ -987,10 +987,10 @@ UINTN REFIT_MENU_SCREEN::RunGenericMenu(IN MENU_STYLE_FUNC StyleFunc, IN OUT INT
/* just a sample code /* just a sample code
case SCAN_F7: case SCAN_F7:
Status = egMkDir(SelfRootDir, L"EFI\\CLOVER\\new_folder"); Status = egMkDir(SelfRootDir, L"EFI\\CLOVER\\new_folder");
DBG("create folder %s\n", strerror(Status)); DBG("create folder %s\n", efiStrError(Status));
if (!EFI_ERROR(Status)) { if (!EFI_ERROR(Status)) {
Status = egSaveFile(SelfRootDir, L"EFI\\CLOVER\\new_folder\\new_file.txt", (UINT8*)SomeText, sizeof(*SomeText)+1); Status = egSaveFile(SelfRootDir, L"EFI\\CLOVER\\new_folder\\new_file.txt", (UINT8*)SomeText, sizeof(*SomeText)+1);
DBG("create file %s\n", strerror(Status)); DBG("create file %s\n", efiStrError(Status));
} }
break; break;
*/ */
@ -999,7 +999,7 @@ UINTN REFIT_MENU_SCREEN::RunGenericMenu(IN MENU_STYLE_FUNC StyleFunc, IN OUT INT
OldChosenAudio = 0; //security correction OldChosenAudio = 0; //security correction
} }
Status = gBS->HandleProtocol(AudioList[OldChosenAudio].Handle, &gEfiAudioIoProtocolGuid, (VOID**)&AudioIo); Status = gBS->HandleProtocol(AudioList[OldChosenAudio].Handle, &gEfiAudioIoProtocolGuid, (VOID**)&AudioIo);
DBG("open %llu audio handle status=%s\n", OldChosenAudio, strerror(Status)); DBG("open %llu audio handle status=%s\n", OldChosenAudio, efiStrError(Status));
if (!EFI_ERROR(Status)) { if (!EFI_ERROR(Status)) {
StartupSoundPlay(SelfRootDir, NULL); //play embedded sound StartupSoundPlay(SelfRootDir, NULL); //play embedded sound
} }
@ -1819,7 +1819,7 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
TitleLen = ResultString.length(); TitleLen = ResultString.length();
if ( EntryC->getREFIT_MENU_SWITCH() ) { if ( EntryC->getREFIT_MENU_SWITCH() ) {
if (EntryC->getREFIT_MENU_SWITCH()->Item->IValue == 3) { if (EntryC->getREFIT_MENU_SWITCH()->Item->IValue == 3) {
OldChosenItem = (OldChosenTheme == 0xFFFF) ? 0: OldChosenTheme + 1;; OldChosenItem = (OldChosenTheme == 0xFFFF) ? 0: OldChosenTheme + 1;
} else if (EntryC->getREFIT_MENU_SWITCH()->Item->IValue == 90) { } else if (EntryC->getREFIT_MENU_SWITCH()->Item->IValue == 90) {
OldChosenItem = OldChosenConfig; OldChosenItem = OldChosenConfig;
} else if (EntryC->getREFIT_MENU_SWITCH()->Item->IValue == 116) { } else if (EntryC->getREFIT_MENU_SWITCH()->Item->IValue == 116) {
@ -2429,7 +2429,7 @@ VOID REFIT_MENU_SCREEN::MainMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamT
// DBG("MouseBirth\n"); // DBG("MouseBirth\n");
Status = MouseBirth(); Status = MouseBirth();
if(EFI_ERROR(Status)) { if(EFI_ERROR(Status)) {
DBG("can't bear mouse at all! Status=%s\n", strerror(Status)); DBG("can't bear mouse at all! Status=%s\n", efiStrError(Status));
} }
break; break;
@ -2466,7 +2466,7 @@ VOID REFIT_MENU_SCREEN::MainMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamT
DrawTextCorner(TEXT_CORNER_REVISION, X_IS_RIGHT); DrawTextCorner(TEXT_CORNER_REVISION, X_IS_RIGHT);
Status = MouseBirth(); Status = MouseBirth();
if(EFI_ERROR(Status)) { if(EFI_ERROR(Status)) {
DBG("can't bear mouse at sel! Status=%s\n", strerror(Status)); DBG("can't bear mouse at sel! Status=%s\n", efiStrError(Status));
} }
break; break;
@ -2486,7 +2486,7 @@ VOID REFIT_MENU_SCREEN::MainMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamT
DrawTextCorner(TEXT_CORNER_REVISION, X_IS_RIGHT); DrawTextCorner(TEXT_CORNER_REVISION, X_IS_RIGHT);
Status = MouseBirth(); Status = MouseBirth();
if(EFI_ERROR(Status)) { if(EFI_ERROR(Status)) {
DBG("can't bear mouse at timeout! Status=%s\n", strerror(Status)); DBG("can't bear mouse at timeout! Status=%s\n", efiStrError(Status));
} }
break; break;

View File

@ -38,7 +38,7 @@
#include "../../libeg/libeg.h" #include "../../libeg/libeg.h"
#include "../../refit/lib.h" #include "../../refit/lib.h"
//#include "../../Platform/LoaderUefi.h" #include <UefiLoader.h>
#include "../../Platform/boot.h" #include "../../Platform/boot.h"
#include "../../cpp_foundation/XObjArray.h" #include "../../cpp_foundation/XObjArray.h"

View File

@ -22,6 +22,10 @@ extern "C" {
#include <Guid/EventGroup.h> #include <Guid/EventGroup.h>
#include <Guid/SmBios.h> #include <Guid/SmBios.h>
#include <Guid/Mps.h> #include <Guid/Mps.h>
#include <Guid/FileInfo.h>
#include <Guid/GlobalVariable.h>
#include <Pi/PiDxeCis.h>
#include <Library/BaseLib.h> #include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h> #include <Library/BaseMemoryLib.h>
@ -47,6 +51,8 @@ extern "C" {
#include <Library/MemLogLib.h> #include <Library/MemLogLib.h>
#include <Library/WaveLib.h> #include <Library/WaveLib.h>
#include <Library/IoLib.h> #include <Library/IoLib.h>
#include <Library/DxeServicesTableLib.h>
#include <Library/HobLib.h>
#include <Framework/FrameworkInternalFormRepresentation.h> #include <Framework/FrameworkInternalFormRepresentation.h>
@ -76,6 +82,11 @@ extern "C" {
#include <Protocol/VariableWrite.h> #include <Protocol/VariableWrite.h>
#include <Protocol/Variable.h> #include <Protocol/Variable.h>
#include <Protocol/UgaDraw.h> #include <Protocol/UgaDraw.h>
#include <Protocol/LoadedImage.h>
#include <Protocol/UnicodeCollation.h>
#include <Protocol/ScsiIo.h>
#include <Protocol/LegacyBios.h>
#include <Protocol/EdidActive.h>
#include <Protocol/FSInjectProtocol.h> #include <Protocol/FSInjectProtocol.h>
#include <Protocol/MsgLog.h> #include <Protocol/MsgLog.h>

View File

@ -5,6 +5,7 @@
// Created by Slice on 20.06.2018. // Created by Slice on 20.06.2018.
// //
#include <Platform.h>
#include "FloatLib.h" #include "FloatLib.h"
//#define memcpy(dest,source,count) CopyMem(dest,(void*)source,(UINTN)(count)) //#define memcpy(dest,source,count) CopyMem(dest,(void*)source,(UINTN)(count))
@ -282,8 +283,9 @@ AsciiStrToFloat(IN CONST CHAR8 *String,
} }
Temp = 0; Temp = 0;
Status = AsciiStrDecimalToUintnS(String, &TmpStr, &Temp); Status = AsciiStrDecimalToUintnS(String, &TmpStr, &Temp);
if ( Temp > MAX_INTN ) return RETURN_UNSUPPORTED;
if (Status == RETURN_SUCCESS) { if (Status == RETURN_SUCCESS) {
Ftemp = PowF(10.0f, ExpSign * Temp); Ftemp = PowF(10.0f, ExpSign * (INTN)Temp); // cast to avoid warning
Mantissa *= Ftemp; Mantissa *= Ftemp;
} }
} }

View File

@ -8,15 +8,6 @@
#ifndef FloatLib_h #ifndef FloatLib_h
#define FloatLib_h #define FloatLib_h
extern "C" {
#include <Uefi.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/BaseLib.h>
#include <Library/MemoryAllocationLib.h>
//#include <Library/PrintLib.h>
}
#define PI (3.1415926536f) #define PI (3.1415926536f)
#define PI2 (6.283185307179586f) #define PI2 (6.283185307179586f)
#define PI5 (1.570796326794897f) #define PI5 (1.570796326794897f)

View File

@ -199,7 +199,7 @@ EFI_STATUS XTheme::ParseSVGXIcon(INTN Id, const XString8& IconNameX, OUT XImage*
XImage NewImage(iWidth, iHeight); //empty XImage NewImage(iWidth, iHeight); //empty
if (IconImage->shapes == NULL) { if (IconImage->shapes == NULL) {
*Image = NewImage; *Image = NewImage;
// DBG("return empty with status=%s\n", strerror(Status)); // DBG("return empty with status=%s\n", efiStrError(Status));
return Status; return Status;
} }
IconImage->scale = Scale; IconImage->scale = Scale;
@ -293,13 +293,13 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer)
} }
XIcon* NewIcon = new XIcon(i, false); //initialize without embedded XIcon* NewIcon = new XIcon(i, false); //initialize without embedded
Status = ParseSVGXIcon(i, NewIcon->Name, &NewIcon->Image, &NewIcon->ImageSVG); Status = ParseSVGXIcon(i, NewIcon->Name, &NewIcon->Image, &NewIcon->ImageSVG);
// DBG("parse %s status %s\n", NewIcon->Name.c_str(), strerror(Status)); // DBG("parse %s status %s\n", NewIcon->Name.c_str(), efiStrError(Status));
NewIcon->Native = !EFI_ERROR(Status); NewIcon->Native = !EFI_ERROR(Status);
if (!EFI_ERROR(Status)) { if (!EFI_ERROR(Status)) {
NewIcon->setFilled(); NewIcon->setFilled();
ParseSVGXIcon(i, NewIcon->Name + "_night"_XS8, &NewIcon->ImageNight, &NewIcon->ImageSVGnight); ParseSVGXIcon(i, NewIcon->Name + "_night"_XS8, &NewIcon->ImageNight, &NewIcon->ImageSVGnight);
} }
// DBG("parse night %s status %s\n", NewIcon->Name.c_str(), strerror(Status)); // DBG("parse night %s status %s\n", NewIcon->Name.c_str(), efiStrError(Status));
Icons.AddReference(NewIcon, true); Icons.AddReference(NewIcon, true);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
if (i >= BUILTIN_ICON_VOL_INTERNAL_HFS && i <= BUILTIN_ICON_VOL_INTERNAL_REC) { if (i >= BUILTIN_ICON_VOL_INTERNAL_HFS && i <= BUILTIN_ICON_VOL_INTERNAL_REC) {
@ -316,7 +316,7 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer)
if (AsciiStrLen(IconsNames[i]) == 0) break; if (AsciiStrLen(IconsNames[i]) == 0) break;
XIcon* NewIcon = new XIcon(i, false); //initialize without embedded XIcon* NewIcon = new XIcon(i, false); //initialize without embedded
Status = ParseSVGXIcon(i, NewIcon->Name, &NewIcon->Image, &NewIcon->ImageSVG); Status = ParseSVGXIcon(i, NewIcon->Name, &NewIcon->Image, &NewIcon->ImageSVG);
// DBG("parse %s i=%lld status %s\n", NewIcon->Name.c_str(), i, strerror(Status)); // DBG("parse %s i=%lld status %s\n", NewIcon->Name.c_str(), i, efiStrError(Status));
NewIcon->Native = !EFI_ERROR(Status); NewIcon->Native = !EFI_ERROR(Status);
if (!EFI_ERROR(Status)) { if (!EFI_ERROR(Status)) {
ParseSVGXIcon(i, NewIcon->Name + "_night"_XS8, &NewIcon->ImageNight, &NewIcon->ImageSVGnight); ParseSVGXIcon(i, NewIcon->Name + "_night"_XS8, &NewIcon->ImageNight, &NewIcon->ImageSVGnight);
@ -366,8 +366,8 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer)
NewFilm->SetIndex((UINTN)GetPropertyInteger(Dict2, 1)); //default=main screen NewFilm->SetIndex((UINTN)GetPropertyInteger(Dict2, 1)); //default=main screen
Dict2 = GetProperty(Dict3, "Path"); Dict2 = GetProperty(Dict3, "Path");
if (Dict2 != NULL && (Dict2->isString()) && Dict2->stringValue().notEmpty() ) { if (Dict2 != NULL && (Dict2->isString()) && Dict2->getString()->stringValue().notEmpty() ) {
NewFilm->Path.takeValueFrom(Dict2->stringValue()); NewFilm->Path.takeValueFrom(Dict2->getString()->stringValue());
} }
Dict2 = GetProperty(Dict3, "Frames"); Dict2 = GetProperty(Dict3, "Frames");
@ -377,19 +377,19 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer)
NewFilm->FrameTime = (UINTN)GetPropertyInteger(Dict2, 50); //default will be 50ms NewFilm->FrameTime = (UINTN)GetPropertyInteger(Dict2, 50); //default will be 50ms
Dict2 = GetProperty(Dict3, "ScreenEdgeX"); Dict2 = GetProperty(Dict3, "ScreenEdgeX");
if (Dict2 != NULL && (Dict2->isString()) && Dict2->stringValue().notEmpty() ) { if (Dict2 != NULL && (Dict2->isString()) && Dict2->getString()->stringValue().notEmpty() ) {
if (Dict2->stringValue().equal("left")) { if (Dict2->getString()->stringValue().equal("left")) {
NewFilm->ScreenEdgeHorizontal = SCREEN_EDGE_LEFT; NewFilm->ScreenEdgeHorizontal = SCREEN_EDGE_LEFT;
} else if (Dict2->stringValue().equal("right")) { } else if (Dict2->getString()->stringValue().equal("right")) {
NewFilm->ScreenEdgeHorizontal = SCREEN_EDGE_RIGHT; NewFilm->ScreenEdgeHorizontal = SCREEN_EDGE_RIGHT;
} }
} }
Dict2 = GetProperty(Dict3, "ScreenEdgeY"); Dict2 = GetProperty(Dict3, "ScreenEdgeY");
if (Dict2 != NULL && (Dict2->isString()) && Dict2->stringValue().notEmpty() ) { if (Dict2 != NULL && (Dict2->isString()) && Dict2->getString()->stringValue().notEmpty() ) {
if (Dict2->stringValue().equal("top")) { if (Dict2->getString()->stringValue().equal("top")) {
NewFilm->ScreenEdgeVertical = SCREEN_EDGE_TOP; NewFilm->ScreenEdgeVertical = SCREEN_EDGE_TOP;
} else if (Dict2->stringValue().equal("bottom")) { } else if (Dict2->getString()->stringValue().equal("bottom")) {
NewFilm->ScreenEdgeVertical = SCREEN_EDGE_BOTTOM; NewFilm->ScreenEdgeVertical = SCREEN_EDGE_BOTTOM;
} }
} }
@ -440,7 +440,7 @@ EFI_STATUS XTheme::LoadSvgFrame(INTN i, OUT XImage* XFrame)
XString8 XFrameName = S8Printf("frame_%04lld", i+1); XString8 XFrameName = S8Printf("frame_%04lld", i+1);
Status = ParseSVGXIcon(BUILTIN_ICON_ANIME, XFrameName, XFrame, NULL); //svg anime will be full redesigned Status = ParseSVGXIcon(BUILTIN_ICON_ANIME, XFrameName, XFrame, NULL); //svg anime will be full redesigned
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG("frame '%s' not loaded, status=%s\n", XFrameName.c_str(), strerror(Status)); DBG("frame '%s' not loaded, status=%s\n", XFrameName.c_str(), efiStrError(Status));
} }
return Status; return Status;
@ -654,7 +654,7 @@ VOID testSVG()
// DBG("create test textbuffer\n"); // DBG("create test textbuffer\n");
XImage TextBufferXY(Width, Height); XImage TextBufferXY(Width, Height);
Status = egLoadFile(SelfRootDir, L"Font.svg", &FileData, &FileDataLength); Status = egLoadFile(SelfRootDir, L"Font.svg", &FileData, &FileDataLength);
DBG("test Font.svg loaded status=%s\n", strerror(Status)); DBG("test Font.svg loaded status=%s\n", efiStrError(Status));
if (!EFI_ERROR(Status)) { if (!EFI_ERROR(Status)) {
p = nsvgParse((CHAR8*)FileData, 72, 1.f); p = nsvgParse((CHAR8*)FileData, 72, 1.f);
if (!p) { if (!p) {

View File

@ -142,7 +142,7 @@ void FILM::GetFrames(XTheme& TheTheme /*, const XStringW& Path*/) // Path alread
if (FileExists(ThemeDir, Name)) { if (FileExists(ThemeDir, Name)) {
Status = NewImage.LoadXImage(ThemeDir, Name); Status = NewImage.LoadXImage(ThemeDir, Name);
} }
// DBG(" read status=%s\n", strerror(Status)); // DBG(" read status=%s\n", efiStrError(Status));
} }
if (!EFI_ERROR(Status)) { if (!EFI_ERROR(Status)) {
AddFrame(&NewImage, Index); AddFrame(&NewImage, Index);

View File

@ -630,7 +630,7 @@ EFI_STATUS XImage::LoadXImage(EFI_FILE *BaseDir, const XStringW& IconName)
// decode it // decode it
Status = FromPNG(FileData, FileDataLength); Status = FromPNG(FileData, FileDataLength);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG("%ls not decoded. Status=%s\n", IconName.wc_str(), strerror(Status)); DBG("%ls not decoded. Status=%s\n", IconName.wc_str(), efiStrError(Status));
} }
FreePool(FileData); FreePool(FileData);
return Status; return Status;

View File

@ -9,6 +9,8 @@
#include "XIcon.h" #include "XIcon.h"
#include "XCinema.h" #include "XCinema.h"
class TagDict;
class TagStruct; class TagStruct;
#define INDICATOR_SIZE (52) #define INDICATOR_SIZE (52)
@ -143,11 +145,11 @@ public:
// void AddIcon(XIcon& NewIcon); //return EFI_STATUS? // void AddIcon(XIcon& NewIcon); //return EFI_STATUS?
void FillByEmbedded(); void FillByEmbedded();
void FillByDir(); void FillByDir();
EFI_STATUS GetThemeTagSettings(const TagStruct* DictPointer); EFI_STATUS GetThemeTagSettings(const TagDict* DictPointer);
void parseTheme(void* p, const char** dict); //in nano project void parseTheme(void* p, const char** dict); //in nano project
EFI_STATUS ParseSVGXTheme(const CHAR8* buffer); // in VectorTheme EFI_STATUS ParseSVGXTheme(const CHAR8* buffer); // in VectorTheme
EFI_STATUS ParseSVGXIcon(INTN Id, const XString8& IconNameX, XImage* Image, void **SVGIcon); EFI_STATUS ParseSVGXIcon(INTN Id, const XString8& IconNameX, XImage* Image, void **SVGIcon);
TagStruct* LoadTheme(const XStringW& TestTheme); //return TagStruct* why? TagDict* LoadTheme(const XStringW& TestTheme); //return TagStruct* why?
EFI_STATUS LoadSvgFrame(INTN i, OUT XImage* XFrame); // for animation EFI_STATUS LoadSvgFrame(INTN i, OUT XImage* XFrame); // for animation
//screen operations //screen operations

View File

@ -147,7 +147,7 @@ EFI_STATUS egSaveFile(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CONST CHAR16 *File
if (BaseDir == NULL) { if (BaseDir == NULL) {
Status = egFindESP(&BaseDir); Status = egFindESP(&BaseDir);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG("no ESP %s\n", strerror(Status)); DBG("no ESP %s\n", efiStrError(Status));
return Status; return Status;
} }
} }
@ -165,10 +165,10 @@ EFI_STATUS egSaveFile(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CONST CHAR16 *File
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
// make dir // make dir
// DBG("no dir %s\n", strerror(Status)); // DBG("no dir %s\n", efiStrError(Status));
Status = BaseDir->Open(BaseDir, &FileHandle, DirName, Status = BaseDir->Open(BaseDir, &FileHandle, DirName,
EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, EFI_FILE_DIRECTORY); EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, EFI_FILE_DIRECTORY);
// DBG("cant make dir %s\n", strerror(Status)); // DBG("cant make dir %s\n", efiStrError(Status));
} }
// end of folder checking // end of folder checking
@ -180,7 +180,7 @@ EFI_STATUS egSaveFile(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CONST CHAR16 *File
if (Status == EFI_WARN_DELETE_FAILURE) { if (Status == EFI_WARN_DELETE_FAILURE) {
//This is READ_ONLY file system //This is READ_ONLY file system
CreateNew = FALSE; // will write into existing file (Slice - ???) CreateNew = FALSE; // will write into existing file (Slice - ???)
// DBG("RO FS %s\n", strerror(Status)); // DBG("RO FS %s\n", efiStrError(Status));
} }
} }
@ -189,7 +189,7 @@ EFI_STATUS egSaveFile(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CONST CHAR16 *File
Status = BaseDir->Open(BaseDir, &FileHandle, FileName, Status = BaseDir->Open(BaseDir, &FileHandle, FileName,
EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, 0); EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, 0);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
// DBG("no write %s\n", strerror(Status)); // DBG("no write %s\n", efiStrError(Status));
return Status; return Status;
} }
} else { } else {
@ -197,7 +197,7 @@ EFI_STATUS egSaveFile(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CONST CHAR16 *File
EFI_FILE_INFO *Info = EfiLibFileInfo(FileHandle); EFI_FILE_INFO *Info = EfiLibFileInfo(FileHandle);
if (Info) { if (Info) {
if (Info->FileSize < FileDataLength) { if (Info->FileSize < FileDataLength) {
// DBG("no old file %s\n", strerror(Status)); // DBG("no old file %s\n", efiStrError(Status));
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
FreePool(Info); FreePool(Info);
@ -205,14 +205,14 @@ EFI_STATUS egSaveFile(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CONST CHAR16 *File
} }
if (!FileHandle) { if (!FileHandle) {
// DBG("no FileHandle %s\n", strerror(Status)); // DBG("no FileHandle %s\n", efiStrError(Status));
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
BufferSize = FileDataLength; BufferSize = FileDataLength;
Status = FileHandle->Write(FileHandle, &BufferSize, (VOID*)FileData); // CONST missing in EFI_FILE_HANDLE->write Status = FileHandle->Write(FileHandle, &BufferSize, (VOID*)FileData); // CONST missing in EFI_FILE_HANDLE->write
FileHandle->Close(FileHandle); FileHandle->Close(FileHandle);
// DBG("not written %s\n", strerror(Status)); // DBG("not written %s\n", efiStrError(Status));
return Status; return Status;
} }
@ -227,7 +227,7 @@ EFI_STATUS egMkDir(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CHAR16 *DirName)
if (BaseDir == NULL) { if (BaseDir == NULL) {
Status = egFindESP(&BaseDir); Status = egFindESP(&BaseDir);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
//DBG(" %s\n", strerror(Status)); //DBG(" %s\n", efiStrError(Status));
return Status; return Status;
} }
} }
@ -237,12 +237,12 @@ EFI_STATUS egMkDir(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CHAR16 *DirName)
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
// Write new dir // Write new dir
//DBG("%s, attempt to create one:", strerror(Status)); //DBG("%s, attempt to create one:", efiStrError(Status));
Status = BaseDir->Open(BaseDir, &FileHandle, DirName, Status = BaseDir->Open(BaseDir, &FileHandle, DirName,
EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, EFI_FILE_DIRECTORY); EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, EFI_FILE_DIRECTORY);
} }
//DBG(" %s\n", strerror(Status)); //DBG(" %s\n", efiStrError(Status));
return Status; return Status;
} }

View File

@ -37,109 +37,7 @@
#ifndef __LIBEG_LIBEG_H__ #ifndef __LIBEG_LIBEG_H__
#define __LIBEG_LIBEG_H__ #define __LIBEG_LIBEG_H__
#ifdef __cplusplus #include "../include/Efi.h"
extern "C" {
#endif
#include <PiDxe.h>
#include <Base.h>
#include <Uefi.h>
#include <FrameworkDxe.h>
// Protocol Includes
#include <Protocol/AbsolutePointer.h>
#include <Protocol/AcpiTable.h>
#include <Protocol/BlockIo.h>
#include <Protocol/BlockIo2.h>
#include <Protocol/Cpu.h>
#include <Protocol/DataHub.h>
#include <Protocol/DebugPort.h>
#include <Protocol/Decompress.h>
#include <Protocol/DevicePath.h>
#include <Protocol/DevicePathFromText.h>
#include <Protocol/DevicePathToText.h>
#include <Protocol/DiskIo.h>
#include <Protocol/EdidActive.h>
#include <Protocol/EdidDiscovered.h>
#include <Protocol/FirmwareVolume2.h>
#include <Protocol/FrameworkHii.h>
#include <Protocol/GraphicsOutput.h>
#include <Protocol/HiiDatabase.h>
#include <Protocol/HiiImage.h>
#include <Protocol/LegacyBios.h>
#include <Protocol/LoadedImage.h>
#include <Protocol/LoadedImage.h>
#include <Protocol/PciIo.h>
#include <Protocol/ScsiIo.h>
#include <Protocol/ScsiPassThru.h>
#include <Protocol/ScsiPassThruExt.h>
#include <Protocol/SimpleFileSystem.h>
#include <Protocol/SimpleNetwork.h>
#include <Protocol/SimplePointer.h>
#include <Protocol/SimpleTextIn.h>
#include <Protocol/SimpleTextOut.h>
#include <Protocol/Smbios.h>
#include <Protocol/SmbusHc.h>
#include <Protocol/UgaDraw.h>
#include <Protocol/UgaIo.h>
#include <Protocol/UnicodeCollation.h>
#include <Protocol/UsbIo.h>
// Guid Includes
#include <Guid/Acpi.h>
#include <Guid/ConsoleInDevice.h>
#include <Guid/ConsoleOutDevice.h>
#include <Guid/DataHubRecords.h>
#include <Guid/DxeServices.h>
#include <Guid/EventGroup.h>
#include <Guid/FileInfo.h>
#include <Guid/FileSystemInfo.h>
#include <Guid/FileSystemVolumeLabelInfo.h>
#include <Guid/GlobalVariable.h>
#include <Guid/HobList.h>
#include <Guid/MemoryTypeInformation.h>
#include <Guid/MemoryAllocationHob.h>
#include <Guid/SmBios.h>
#include <Guid/StandardErrorDevice.h>
// Library Includes
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/DevicePathLib.h>
#include <Library/DeviceTreeLib.h>
#include <Library/DxeServicesLib.h>
#include <Library/DxeServicesTableLib.h>
//#include <Library/EblCmdLib.h>
//#include <Library/EblNetworkLib.h>
//#include "EfiFileLib.h"
#include <Library/HiiLib.h>
#include <Library/HobLib.h>
#include <Library/IoLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PcdLib.h>
//#include <Library/PrintLib.h>
#include <Library/TimerLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiScsiLib.h>
// IndustryStandard Includes
#include <IndustryStandard/Pci.h>
#include <IndustryStandard/SmBus.h>
#include <IndustryStandard/Acpi.h>
//#include <IndustryStandard/Acpi20.h>
//#include <IndustryStandard/Acpi30.h>
//#include <IndustryStandard/Acpi40.h>
#include <IndustryStandard/HighPrecisionEventTimerTable.h>
#include <IndustryStandard/Scsi.h>
#include <IndustryStandard/Atapi.h>
#include <IndustryStandard/AppleSmBios.h>
#include <IndustryStandard/AppleIntelCpuInfo.h>
#ifdef __cplusplus
} // extern "C"
#endif
#include "../cpp_foundation/XString.h" #include "../cpp_foundation/XString.h"
#include "../cpp_foundation/XStringArray.h" #include "../cpp_foundation/XStringArray.h"

View File

@ -149,7 +149,7 @@ VOID egDumpGOPVideoModes(VOID)
MsgLog("- Mode %d: %dx%d PixFmt = %ls, PixPerScanLine = %d\n", MsgLog("- Mode %d: %dx%d PixFmt = %ls, PixPerScanLine = %d\n",
Mode, Info->HorizontalResolution, Info->VerticalResolution, PixelFormatDesc, Info->PixelsPerScanLine); Mode, Info->HorizontalResolution, Info->VerticalResolution, PixelFormatDesc, Info->PixelsPerScanLine);
} else { } else {
MsgLog("- Mode %d: %s\n", Mode, strerror(Status)); MsgLog("- Mode %d: %s\n", Mode, efiStrError(Status));
} }
} }
@ -199,7 +199,7 @@ VOID egDumpSetConsoleVideoModes(VOID)
// Mode is valid // Mode is valid
if (BestMode-1 != (UINTN)gST->ConOut->Mode->Mode) { if (BestMode-1 != (UINTN)gST->ConOut->Mode->Mode) {
Status = gST->ConOut->SetMode(gST->ConOut, BestMode-1); Status = gST->ConOut->SetMode(gST->ConOut, BestMode-1);
MsgLog(" Setting mode (%llu): %s\n", BestMode, strerror(Status)); MsgLog(" Setting mode (%llu): %s\n", BestMode, efiStrError(Status));
} else { } else {
MsgLog(" Selected mode (%llu) is already set\n", BestMode); MsgLog(" Selected mode (%llu) is already set\n", BestMode);
} }
@ -255,7 +255,7 @@ EFI_STATUS egSetMaxResolution()
MsgLog(" - set\n"); MsgLog(" - set\n");
} else { } else {
// we can not set BestMode - search for first one that we can // we can not set BestMode - search for first one that we can
MsgLog(" - %s\n", strerror(Status)); MsgLog(" - %s\n", efiStrError(Status));
Status = egSetMode(1); Status = egSetMode(1);
} }
} }
@ -283,11 +283,11 @@ EFI_STATUS egSetMode(INT32 Next)
Mode = (Mode >= (INT32)MaxMode)?0:Mode; Mode = (Mode >= (INT32)MaxMode)?0:Mode;
Mode = (Mode < 0)?((INT32)MaxMode - 1):Mode; Mode = (Mode < 0)?((INT32)MaxMode - 1):Mode;
Status = GraphicsOutput->QueryMode(GraphicsOutput, (UINT32)Mode, &SizeOfInfo, &Info); Status = GraphicsOutput->QueryMode(GraphicsOutput, (UINT32)Mode, &SizeOfInfo, &Info);
MsgLog("QueryMode %d Status=%s\n", Mode, strerror(Status)); MsgLog("QueryMode %d Status=%s\n", Mode, efiStrError(Status));
if (Status == EFI_SUCCESS) { if (Status == EFI_SUCCESS) {
//Status = GraphicsOutput->SetMode(GraphicsOutput, (UINT32)Mode); //Status = GraphicsOutput->SetMode(GraphicsOutput, (UINT32)Mode);
Status = GopSetModeAndReconnectTextOut((UINT32)Mode); Status = GopSetModeAndReconnectTextOut((UINT32)Mode);
//MsgLog("SetMode %d Status=%s\n", Mode, strerror(Status)); //MsgLog("SetMode %d Status=%s\n", Mode, efiStrError(Status));
egScreenWidth = GraphicsOutput->Mode->Info->HorizontalResolution; egScreenWidth = GraphicsOutput->Mode->Info->HorizontalResolution;
egScreenHeight = GraphicsOutput->Mode->Info->VerticalResolution; egScreenHeight = GraphicsOutput->Mode->Info->VerticalResolution;
} }
@ -585,7 +585,7 @@ static EFI_STATUS GopSetModeAndReconnectTextOut(IN UINT32 ModeNumber)
} }
Status = GraphicsOutput->SetMode(GraphicsOutput, ModeNumber); Status = GraphicsOutput->SetMode(GraphicsOutput, ModeNumber);
MsgLog("Video mode change to mode #%d: %s\n", ModeNumber, strerror(Status)); MsgLog("Video mode change to mode #%d: %s\n", ModeNumber, efiStrError(Status));
if (gFirmwareClover && !EFI_ERROR(Status)) { if (gFirmwareClover && !EFI_ERROR(Status)) {
// When we change mode on GOP, we need to reconnect the drivers which produce simple text out // When we change mode on GOP, we need to reconnect the drivers which produce simple text out

View File

@ -2879,7 +2879,7 @@ static void nsvg__parseText(NSVGparser* p, const char** dict)
XStringW FontFileName = XStringW().takeValueFrom(text->fontFace->fontFamily) + L".svg"_XSW; XStringW FontFileName = XStringW().takeValueFrom(text->fontFace->fontFamily) + L".svg"_XSW;
// DBG(" file name =%ls\n", FontFileName.wc_str()); // DBG(" file name =%ls\n", FontFileName.wc_str());
Status = egLoadFile(ThemeX.ThemeDir, FontFileName.wc_str(), &FileData, &FileDataLength); Status = egLoadFile(ThemeX.ThemeDir, FontFileName.wc_str(), &FileData, &FileDataLength);
// DBG(" font %s loaded status=%lld, %s\n", text->fontFace->fontFamily, Status, strerror(Status)); // DBG(" font %s loaded status=%lld, %s\n", text->fontFace->fontFamily, Status, efiStrError(Status));
if (!EFI_ERROR(Status)) { if (!EFI_ERROR(Status)) {
p1 = nsvgParse((CHAR8*)FileData, 72, 1.0f); //later we will free parser p1 p1 = nsvgParse((CHAR8*)FileData, 72, 1.0f); //later we will free parser p1
if (!p1) { if (!p1) {

View File

@ -101,7 +101,7 @@ void XTheme::LoadFontImage(IN BOOLEAN UseEmbedded, IN INTN Rows, IN INTN Cols)
MsgLog("Using embedded font\n"); MsgLog("Using embedded font\n");
} else if (isKorean){ } else if (isKorean){
Status = NewImage.LoadXImage(ThemeDir, L"FontKorean.png"_XSW); Status = NewImage.LoadXImage(ThemeDir, L"FontKorean.png"_XSW);
MsgLog("Loading korean font from ThemeDir: %s\n", strerror(Status)); MsgLog("Loading korean font from ThemeDir: %s\n", efiStrError(Status));
if (!EFI_ERROR(Status)) { if (!EFI_ERROR(Status)) {
CharWidth = 22; //standard for korean CharWidth = 22; //standard for korean
} else { } else {

View File

@ -191,8 +191,30 @@
Platform/platformdata.cpp Platform/platformdata.cpp
Platform/PlatformDriverOverride.h Platform/PlatformDriverOverride.h
Platform/PlatformDriverOverride.cpp Platform/PlatformDriverOverride.cpp
Platform/plist.h Platform/plist/base64.h
Platform/plist.cpp Platform/plist/base64.cpp
Platform/plist/plist.h
Platform/plist/plist.cpp
Platform/plist/TagArray.h
Platform/plist/TagArray.cpp
Platform/plist/TagBool.h
Platform/plist/TagBool.cpp
Platform/plist/TagData.h
Platform/plist/TagData.cpp
Platform/plist/TagDate.h
Platform/plist/TagDate.cpp
Platform/plist/TagDict.h
Platform/plist/TagDict.cpp
Platform/plist/TagFloat.h
Platform/plist/TagFloat.cpp
Platform/plist/TagInt64.h
Platform/plist/TagInt64.cpp
Platform/plist/TagKey.h
Platform/plist/TagKey.cpp
Platform/plist/TagString8.h
Platform/plist/TagString8.cpp
Platform/plist/xml.h
Platform/plist/xml.cpp
# Platform/Pointer.cpp # Platform/Pointer.cpp
Platform/Settings.cpp Platform/Settings.cpp
Platform/Settings.h Platform/Settings.h
@ -240,6 +262,7 @@
cpp_util/operatorNewDelete.cpp cpp_util/operatorNewDelete.cpp
cpp_util/operatorNewDelete.h cpp_util/operatorNewDelete.h
cpp_util/remove_ref.h cpp_util/remove_ref.h
cpp_util/pure_virtual.cpp
cpp_foundation/unicode_conversions.cpp cpp_foundation/unicode_conversions.cpp
cpp_foundation/unicode_conversions.h cpp_foundation/unicode_conversions.h
cpp_foundation/XArray.h cpp_foundation/XArray.h
@ -281,6 +304,8 @@
cpp_unit_test/XString_test.h cpp_unit_test/XString_test.h
cpp_unit_test/XStringArray_test.cpp cpp_unit_test/XStringArray_test.cpp
cpp_unit_test/XStringArray_test.h cpp_unit_test/XStringArray_test.h
cpp_unit_test/plist_tests.cpp
cpp_unit_test/plist_tests.h
cpp_unit_test/XToolsCommon_test.h cpp_unit_test/XToolsCommon_test.h
# cpp_unit_test/XUINTN_test.cpp # cpp_unit_test/XUINTN_test.cpp
# cpp_unit_test/XUINTN_test.h # cpp_unit_test/XUINTN_test.h

View File

@ -862,7 +862,7 @@ static EFI_STATUS ScanVolume(IN OUT REFIT_VOLUME *Volume)
RemainingDevicePath = DiskDevicePath; RemainingDevicePath = DiskDevicePath;
Status = gBS->LocateDevicePath(&gEfiDevicePathProtocolGuid, &RemainingDevicePath, &WholeDiskHandle); Status = gBS->LocateDevicePath(&gEfiDevicePathProtocolGuid, &RemainingDevicePath, &WholeDiskHandle);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG("Can't find WholeDevicePath: %s\n", strerror(Status)); DBG("Can't find WholeDevicePath: %s\n", efiStrError(Status));
} else { } else {
Volume->WholeDiskDeviceHandle = WholeDiskHandle; Volume->WholeDiskDeviceHandle = WholeDiskHandle;
Volume->WholeDiskDevicePath = DuplicateDevicePath(RemainingDevicePath); Volume->WholeDiskDevicePath = DuplicateDevicePath(RemainingDevicePath);
@ -876,7 +876,7 @@ static EFI_STATUS ScanVolume(IN OUT REFIT_VOLUME *Volume)
} else { } else {
Volume->WholeDiskBlockIO = NULL; Volume->WholeDiskBlockIO = NULL;
// DBG("no WholeDiskBlockIO: %s\n", strerror(Status)); // DBG("no WholeDiskBlockIO: %s\n", efiStrError(Status));
//CheckError(Status, L"from HandleProtocol"); //CheckError(Status, L"from HandleProtocol");
} }
@ -1358,7 +1358,7 @@ BOOLEAN DeleteFile(IN EFI_FILE *Root, IN CONST CHAR16 *RelativePath)
//DBG("DeleteFile: %ls\n", RelativePath); //DBG("DeleteFile: %ls\n", RelativePath);
// open file for read/write to see if it exists, need write for delete // open file for read/write to see if it exists, need write for delete
Status = Root->Open(Root, &File, RelativePath, EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE, 0); Status = Root->Open(Root, &File, RelativePath, EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE, 0);
//DBG(" Open: %s\n", strerror(Status)); //DBG(" Open: %s\n", efiStrError(Status));
if (Status == EFI_SUCCESS) { if (Status == EFI_SUCCESS) {
// exists - check if it is a file // exists - check if it is a file
FileInfo = EfiLibFileInfo(File); FileInfo = EfiLibFileInfo(File);
@ -1380,7 +1380,7 @@ BOOLEAN DeleteFile(IN EFI_FILE *Root, IN CONST CHAR16 *RelativePath)
// it's a file - delete it // it's a file - delete it
//DBG(" File is file\n"); //DBG(" File is file\n");
Status = File->Delete(File); Status = File->Delete(File);
//DBG(" Delete: %s\n", strerror(Status)); //DBG(" Delete: %s\n", efiStrError(Status));
return Status == EFI_SUCCESS; return Status == EFI_SUCCESS;
} }

View File

@ -56,14 +56,14 @@
*/ */
// Experimental <-- // Experimental <--
#include "../include/Efi.h"
#include "../libeg/libeg.h" #include "../libeg/libeg.h"
#ifdef __cplusplus #ifdef __cplusplus
#include "../cpp_foundation/XObjArray.h" #include "../cpp_foundation/XObjArray.h"
#include "../cpp_foundation/XString.h" #include "../cpp_foundation/XString.h"
#include "../libeg/XTheme.h" #include "../libeg/XTheme.h"
extern XTheme ThemeX; //global variable defined in lib.cpp extern XTheme ThemeX; //global variable defined in lib.cpp
#endif #endif
#define REFIT_DEBUG (2) #define REFIT_DEBUG (2)
@ -74,8 +74,6 @@ extern "C" {
#endif #endif
#include <Protocol/SimpleFileSystem.h>
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -135,6 +135,8 @@ extern UINTN AudioNum;
extern HDA_OUTPUTS AudioList[20]; extern HDA_OUTPUTS AudioList[20];
extern EFI_AUDIO_IO_PROTOCOL *AudioIo; extern EFI_AUDIO_IO_PROTOCOL *AudioIo;
extern EFI_DXE_SERVICES *gDS;
//#ifdef _cplusplus //#ifdef _cplusplus
//void FreePool(const wchar_t * A) //void FreePool(const wchar_t * A)
//{ //{
@ -164,7 +166,7 @@ static EFI_STATUS LoadEFIImageList(IN EFI_DEVICE_PATH **DevicePaths,
ReturnStatus = Status = EFI_NOT_FOUND; // in case the list is empty ReturnStatus = Status = EFI_NOT_FOUND; // in case the list is empty
for (DevicePathIndex = 0; DevicePaths[DevicePathIndex] != NULL; DevicePathIndex++) { for (DevicePathIndex = 0; DevicePaths[DevicePathIndex] != NULL; DevicePathIndex++) {
ReturnStatus = Status = gBS->LoadImage(FALSE, SelfImageHandle, DevicePaths[DevicePathIndex], NULL, 0, &ChildImageHandle); ReturnStatus = Status = gBS->LoadImage(FALSE, SelfImageHandle, DevicePaths[DevicePathIndex], NULL, 0, &ChildImageHandle);
DBG(" status=%s", strerror(Status)); DBG(" status=%s", efiStrError(Status));
if (ReturnStatus != EFI_NOT_FOUND) if (ReturnStatus != EFI_NOT_FOUND)
break; break;
} }
@ -571,7 +573,7 @@ VOID LOADER_ENTRY::StartLoader()
EFI_HANDLE ImageHandle = NULL; EFI_HANDLE ImageHandle = NULL;
EFI_LOADED_IMAGE *LoadedImage = NULL; EFI_LOADED_IMAGE *LoadedImage = NULL;
CONST CHAR8 *InstallerVersion; CONST CHAR8 *InstallerVersion;
TagStruct* dict = NULL; TagDict* dict = NULL;
UINTN i; UINTN i;
NSVGfont *font; // , *nextFont; NSVGfont *font; // , *nextFont;
@ -583,9 +585,9 @@ VOID LOADER_ENTRY::StartLoader()
if (!EFI_ERROR(Status)) { if (!EFI_ERROR(Status)) {
DBG(" - found custom settings for this entry: %ls\n", Settings.wc_str()); DBG(" - found custom settings for this entry: %ls\n", Settings.wc_str());
gBootChanged = TRUE; gBootChanged = TRUE;
Status = GetUserSettings(SelfRootDir, dict); Status = GetUserSettings(dict);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG(" - ... but: %s\n", strerror(Status)); DBG(" - ... but: %s\n", efiStrError(Status));
} else { } else {
if ((gSettings.CpuFreqMHz > 100) && (gSettings.CpuFreqMHz < 20000)) { if ((gSettings.CpuFreqMHz > 100) && (gSettings.CpuFreqMHz < 20000)) {
gCPUStructure.MaxSpeed = gSettings.CpuFreqMHz; gCPUStructure.MaxSpeed = gSettings.CpuFreqMHz;
@ -596,7 +598,7 @@ VOID LOADER_ENTRY::StartLoader()
//DBG("Custom KernelAndKextPatches copyed to started entry\n"); //DBG("Custom KernelAndKextPatches copyed to started entry\n");
} }
} else { } else {
DBG(" - [!] LoadUserSettings failed: %s\n", strerror(Status)); DBG(" - [!] LoadUserSettings failed: %s\n", efiStrError(Status));
} }
} }
@ -656,7 +658,7 @@ VOID LOADER_ENTRY::StartLoader()
// Load image into memory (will be started later) // Load image into memory (will be started later)
Status = LoadEFIImage(DevicePath, LoaderPath.basename(), NULL, &ImageHandle); Status = LoadEFIImage(DevicePath, LoaderPath.basename(), NULL, &ImageHandle);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG("Image is not loaded, status=%s\n", strerror(Status)); DBG("Image is not loaded, status=%s\n", efiStrError(Status));
return; // no reason to continue if loading image failed return; // no reason to continue if loading image failed
} }
egClearScreen(&BootBgColor); //if not set then it is already MenuBackgroundPixel egClearScreen(&BootBgColor); //if not set then it is already MenuBackgroundPixel
@ -939,10 +941,10 @@ VOID LOADER_ENTRY::StartLoader()
// Initialize the boot screen // Initialize the boot screen
if (EFI_ERROR(Status = InitBootScreen(this))) { if (EFI_ERROR(Status = InitBootScreen(this))) {
if (Status != EFI_ABORTED) DBG("Failed to initialize custom boot screen: %s!\n", strerror(Status)); if (Status != EFI_ABORTED) DBG("Failed to initialize custom boot screen: %s!\n", efiStrError(Status));
} }
else if (EFI_ERROR(Status = LockBootScreen())) { else if (EFI_ERROR(Status = LockBootScreen())) {
DBG("Failed to lock custom boot screen: %s!\n", strerror(Status)); DBG("Failed to lock custom boot screen: %s!\n", efiStrError(Status));
} }
} // !OSTYPE_IS_WINDOWS } // !OSTYPE_IS_WINDOWS
@ -988,7 +990,7 @@ VOID LOADER_ENTRY::StartLoader()
StartEFILoadedImage(ImageHandle, LoadOptions, Basename(LoaderPath.wc_str()), LoaderPath.basename(), NULL); StartEFILoadedImage(ImageHandle, LoadOptions, Basename(LoaderPath.wc_str()), LoaderPath.basename(), NULL);
// Unlock boot screen // Unlock boot screen
if (EFI_ERROR(Status = UnlockBootScreen())) { if (EFI_ERROR(Status = UnlockBootScreen())) {
DBG("Failed to unlock custom boot screen: %s!\n", strerror(Status)); DBG("Failed to unlock custom boot screen: %s!\n", efiStrError(Status));
} }
if (OSFLAG_ISSET(Flags, OSFLAG_USEGRAPHICS)) { if (OSFLAG_ISSET(Flags, OSFLAG_USEGRAPHICS)) {
// return back orig OutputString // return back orig OutputString
@ -1270,7 +1272,7 @@ VOID DisconnectInvalidDiskIoChildDrivers(VOID)
(VOID **) &BlockIo (VOID **) &BlockIo
); );
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
//DBG(" BlockIo: %s - skipping\n", strerror(Status)); //DBG(" BlockIo: %s - skipping\n", efiStrError(Status));
continue; continue;
} }
if (BlockIo->Media == NULL) { if (BlockIo->Media == NULL) {
@ -1321,8 +1323,8 @@ VOID DisconnectInvalidDiskIoChildDrivers(VOID)
} }
Found = TRUE; Found = TRUE;
Status = gBS->DisconnectController (Handles[Index], OpenInfo[OpenInfoIndex].AgentHandle, NULL); Status = gBS->DisconnectController (Handles[Index], OpenInfo[OpenInfoIndex].AgentHandle, NULL);
//DBG(" BY_DRIVER Agent: %p, Disconnect: %s", OpenInfo[OpenInfoIndex].AgentHandle, strerror(Status)); //DBG(" BY_DRIVER Agent: %p, Disconnect: %s", OpenInfo[OpenInfoIndex].AgentHandle, efiStrError(Status));
DBG(" - Handle %p with DiskIo, is Partition, no Fs, BY_DRIVER Agent: %p, Disconnect: %s\n", Handles[Index], OpenInfo[OpenInfoIndex].AgentHandle, strerror(Status)); DBG(" - Handle %p with DiskIo, is Partition, no Fs, BY_DRIVER Agent: %p, Disconnect: %s\n", Handles[Index], OpenInfo[OpenInfoIndex].AgentHandle, efiStrError(Status));
} }
} }
FreePool(OpenInfo); FreePool(OpenInfo);
@ -1367,7 +1369,7 @@ VOID DisconnectSomeDevices(VOID)
if (BlockIo->Media->BlockSize == 2048) { if (BlockIo->Media->BlockSize == 2048) {
// disconnect CD controller // disconnect CD controller
Status = gBS->DisconnectController(Handles[Index], NULL, NULL); Status = gBS->DisconnectController(Handles[Index], NULL, NULL);
DBG("CD disconnect %s", strerror(Status)); DBG("CD disconnect %s", efiStrError(Status));
} }
} }
/* for (Index = 0; Index < HandleCount; Index++) { /* for (Index = 0; Index < HandleCount; Index++) {
@ -1395,7 +1397,7 @@ VOID DisconnectSomeDevices(VOID)
for (Index2 = 0; Index2 < ControllerHandleCount; Index2++) { for (Index2 = 0; Index2 < ControllerHandleCount; Index2++) {
Status = gBS->DisconnectController(ControllerHandles[Index2], Status = gBS->DisconnectController(ControllerHandles[Index2],
NULL, NULL); NULL, NULL);
DBG("Driver [%d] disconnect %s\n", Index2, strerror(Status)); DBG("Driver [%d] disconnect %s\n", Index2, efiStrError(Status));
} }
} */ } */
@ -1414,7 +1416,7 @@ VOID DisconnectSomeDevices(VOID)
EFI_OPEN_PROTOCOL_GET_PROTOCOL); EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
// DBG("CompName %s\n", strerror(Status)); // DBG("CompName %s\n", efiStrError(Status));
continue; continue;
} }
Status = CompName->GetDriverName(CompName, "eng", &DriverName); Status = CompName->GetDriverName(CompName, "eng", &DriverName);
@ -1425,7 +1427,7 @@ VOID DisconnectSomeDevices(VOID)
for (Index2 = 0; Index2 < ControllerHandleCount; Index2++) { for (Index2 = 0; Index2 < ControllerHandleCount; Index2++) {
Status = gBS->DisconnectController(ControllerHandles[Index2], Status = gBS->DisconnectController(ControllerHandles[Index2],
Handles[Index], NULL); Handles[Index], NULL);
// DBG("Disconnect [%ls] from %X: %s\n", DriverName, ControllerHandles[Index2], strerror(Status)); // DBG("Disconnect [%ls] from %X: %s\n", DriverName, ControllerHandles[Index2], efiStrError(Status));
} }
} }
} }
@ -1453,7 +1455,7 @@ VOID DisconnectSomeDevices(VOID)
if(IS_PCI_VGA(&Pci) == TRUE) { if(IS_PCI_VGA(&Pci) == TRUE) {
// disconnect VGA // disconnect VGA
Status = gBS->DisconnectController(Handles[Index], NULL, NULL); Status = gBS->DisconnectController(Handles[Index], NULL, NULL);
DBG("disconnect %s", strerror(Status)); DBG("disconnect %s", efiStrError(Status));
} }
} }
} }
@ -1801,7 +1803,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
//UINT64 TscRemainder = 0; //UINT64 TscRemainder = 0;
// LOADER_ENTRY *LoaderEntry; // LOADER_ENTRY *LoaderEntry;
XStringW ConfName; XStringW ConfName;
TagStruct* smbiosTags = NULL; TagDict* smbiosTags = NULL;
BOOLEAN UniteConfigs = FALSE; BOOLEAN UniteConfigs = FALSE;
EFI_TIME Now; EFI_TIME Now;
BOOLEAN HaveDefaultVolume; BOOLEAN HaveDefaultVolume;
@ -1910,14 +1912,14 @@ RefitMain (IN EFI_HANDLE ImageHandle,
Status = InitializeUnicodeCollationProtocol(); Status = InitializeUnicodeCollationProtocol();
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG("UnicodeCollation Status=%s\n", strerror(Status)); DBG("UnicodeCollation Status=%s\n", efiStrError(Status));
} }
Status = gBS->HandleProtocol(ConsoleInHandle, &gEfiSimpleTextInputExProtocolGuid, (VOID **)&SimpleTextEx); Status = gBS->HandleProtocol(ConsoleInHandle, &gEfiSimpleTextInputExProtocolGuid, (VOID **)&SimpleTextEx);
if ( EFI_ERROR(Status) ) { if ( EFI_ERROR(Status) ) {
SimpleTextEx = NULL; SimpleTextEx = NULL;
} }
DBG("SimpleTextEx Status=%s\n", strerror(Status)); DBG("SimpleTextEx Status=%s\n", efiStrError(Status));
PrepatchSmbios(); PrepatchSmbios();
@ -1944,7 +1946,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
SetOEMPath(ConfName); SetOEMPath(ConfName);
Status = LoadUserSettings(SelfRootDir, ConfName, &gConfigDict[1]); Status = LoadUserSettings(SelfRootDir, ConfName, &gConfigDict[1]);
DBG("%ls\\%ls.plist%ls loaded with name from LoadOptions: %s\n", DBG("%ls\\%ls.plist%ls loaded with name from LoadOptions: %s\n",
OEMPath.wc_str(), ConfName.wc_str(), EFI_ERROR(Status) ? L" not" : L"", strerror(Status)); OEMPath.wc_str(), ConfName.wc_str(), EFI_ERROR(Status) ? L" not" : L"", efiStrError(Status));
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
gConfigDict[1] = NULL; gConfigDict[1] = NULL;
} }
@ -1952,7 +1954,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
} }
} }
if (gConfigDict[1]) { if (gConfigDict[1]) {
const TagStruct* UniteTag = gConfigDict[1]->dictPropertyForKey("Unite"); const TagStruct* UniteTag = gConfigDict[1]->propertyForKey("Unite");
if(UniteTag) { if(UniteTag) {
UniteConfigs = UniteTag->isTrueOrYy(); UniteConfigs = UniteTag->isTrueOrYy();
DBG("UniteConfigs = %ls", UniteConfigs ? L"TRUE\n": L"FALSE\n" ); DBG("UniteConfigs = %ls", UniteConfigs ? L"TRUE\n": L"FALSE\n" );
@ -1961,7 +1963,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
if (!gConfigDict[1] || UniteConfigs) { if (!gConfigDict[1] || UniteConfigs) {
SetOEMPath(L"config"_XSW); SetOEMPath(L"config"_XSW);
Status = LoadUserSettings(SelfRootDir, L"config"_XSW, &gConfigDict[0]); Status = LoadUserSettings(SelfRootDir, L"config"_XSW, &gConfigDict[0]);
DBG("%ls\\config.plist%ls loaded: %s\n", OEMPath.wc_str(), EFI_ERROR(Status) ? L" not" : L"", strerror(Status)); DBG("%ls\\config.plist%ls loaded: %s\n", OEMPath.wc_str(), EFI_ERROR(Status) ? L" not" : L"", efiStrError(Status));
} }
snwprintf(gSettings.ConfigName, 64, "%ls%ls%ls", snwprintf(gSettings.ConfigName, 64, "%ls%ls%ls",
gConfigDict[0] ? L"config": L"", gConfigDict[0] ? L"config": L"",
@ -2103,7 +2105,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
//Now we have to reinit handles //Now we have to reinit handles
Status = ReinitSelfLib(); Status = ReinitSelfLib();
if (EFI_ERROR(Status)){ if (EFI_ERROR(Status)){
DebugLog(2, " %s", strerror(Status)); DebugLog(2, " %s", efiStrError(Status));
PauseForKey(L"Error reinit refit\n"); PauseForKey(L"Error reinit refit\n");
#ifdef ENABLE_SECURE_BOOT #ifdef ENABLE_SECURE_BOOT
UninstallSecureBoot(); UninstallSecureBoot();
@ -2183,9 +2185,9 @@ RefitMain (IN EFI_HANDLE ImageHandle,
//Second step. Load config.plist into gSettings //Second step. Load config.plist into gSettings
for (i=0; i<2; i++) { for (i=0; i<2; i++) {
if (gConfigDict[i]) { if (gConfigDict[i]) {
Status = GetUserSettings(SelfRootDir, gConfigDict[i]); Status = GetUserSettings(gConfigDict[i]);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
// DBG("Error in Second part of settings%d: %s\n", i, strerror(Status)); DBG("Error in Second part of settings %llu: %s\n", i, efiStrError(Status));
} }
} }
} }
@ -2218,7 +2220,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
// } // }
// Load any extra SMBIOS information // Load any extra SMBIOS information
if (!EFI_ERROR(LoadUserSettings(SelfRootDir, L"smbios"_XSW, &smbiosTags)) && (smbiosTags != NULL)) { if (!EFI_ERROR(LoadUserSettings(SelfRootDir, L"smbios"_XSW, &smbiosTags)) && (smbiosTags != NULL)) {
const TagStruct* dictPointer = smbiosTags->dictPropertyForKey("SMBIOS"); const TagDict* dictPointer = smbiosTags->dictPropertyForKey("SMBIOS");
if (dictPointer) { if (dictPointer) {
ParseSMBIOSSettings(dictPointer); ParseSMBIOSSettings(dictPointer);
} else { } else {

View File

@ -863,12 +863,12 @@ VOID ApplyInputs(VOID)
i++; //90 i++; //90
if (InputItems[i].Valid) { if (InputItems[i].Valid) {
TagStruct* dict; TagDict* dict;
Status = LoadUserSettings(SelfRootDir, XStringW(ConfigsList[OldChosenConfig]), &dict); Status = LoadUserSettings(SelfRootDir, XStringW(ConfigsList[OldChosenConfig]), &dict);
if (!EFI_ERROR(Status)) { if (!EFI_ERROR(Status)) {
gBootChanged = TRUE; gBootChanged = TRUE;
gThemeChanged = TRUE; gThemeChanged = TRUE;
Status = GetUserSettings(SelfRootDir, dict); Status = GetUserSettings(dict);
if (gConfigDict[2]) gConfigDict[2]->FreeTag(); if (gConfigDict[2]) gConfigDict[2]->FreeTag();
gConfigDict[2] = dict; gConfigDict[2] = dict;
snwprintf(gSettings.ConfigName, 64, "%ls", ConfigsList[OldChosenConfig]); snwprintf(gSettings.ConfigName, 64, "%ls", ConfigsList[OldChosenConfig]);

View File

@ -281,7 +281,7 @@ StatusToString (
EFI_STATUS Status EFI_STATUS Status
) )
{ {
snwprintf(Buffer, 64, "EFI Error %s", strerror(Status)); snwprintf(Buffer, 64, "EFI Error %s", efiStrError(Status));
}*/ }*/
@ -294,7 +294,7 @@ BOOLEAN CheckFatalError(IN EFI_STATUS Status, IN CONST CHAR16 *where)
// StatusToString(ErrorName, Status); // StatusToString(ErrorName, Status);
gST->ConOut->SetAttribute (gST->ConOut, ATTR_ERROR); gST->ConOut->SetAttribute (gST->ConOut, ATTR_ERROR);
printf("Fatal Error: %s %ls\n", strerror(Status), where); printf("Fatal Error: %s %ls\n", efiStrError(Status), where);
gST->ConOut->SetAttribute (gST->ConOut, ATTR_BASIC); gST->ConOut->SetAttribute (gST->ConOut, ATTR_BASIC);
haveError = TRUE; haveError = TRUE;
@ -312,7 +312,7 @@ BOOLEAN CheckError(IN EFI_STATUS Status, IN CONST CHAR16 *where)
// StatusToString(ErrorName, Status); // StatusToString(ErrorName, Status);
gST->ConOut->SetAttribute (gST->ConOut, ATTR_ERROR); gST->ConOut->SetAttribute (gST->ConOut, ATTR_ERROR);
printf("Error: %s %ls\n", strerror(Status), where); printf("Error: %s %ls\n", efiStrError(Status), where);
gST->ConOut->SetAttribute (gST->ConOut, ATTR_BASIC); gST->ConOut->SetAttribute (gST->ConOut, ATTR_BASIC);
haveError = TRUE; haveError = TRUE;