SETTINGS serialize method.

This commit is contained in:
jief666 2020-08-13 15:07:40 +03:00
parent 052732eba0
commit 8947e66382
10 changed files with 488 additions and 46 deletions

View File

@ -122,6 +122,8 @@
9A637AE82430D927000B9474 /* XTheme.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5E3262F2428F4EE002240E8 /* XTheme.cpp */; };
9A637AE92430D928000B9474 /* XTheme.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5E3262F2428F4EE002240E8 /* XTheme.cpp */; };
9A637AEA2430D928000B9474 /* XTheme.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5E3262F2428F4EE002240E8 /* XTheme.cpp */; };
9A670D2224E53FD500B5D780 /* XBuffer_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A670D2024E53FD400B5D780 /* XBuffer_tests.cpp */; };
9A670D2324E53FD500B5D780 /* XBuffer_tests.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A670D2124E53FD500B5D780 /* XBuffer_tests.h */; };
9A7AEDE7245963BF003AAD04 /* XToolsCommon.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A7AEDE6245963BF003AAD04 /* XToolsCommon.h */; };
9A9AEB94243F7B5600FBD7D8 /* unicode_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9AEB90243F7B5600FBD7D8 /* unicode_conversions.cpp */; };
9A9AEB97243F7B5600FBD7D8 /* unicode_conversions.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A9AEB93243F7B5600FBD7D8 /* unicode_conversions.h */; };
@ -873,6 +875,8 @@
9A35A6172451FE1500CAFF76 /* XStringAbstract.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XStringAbstract.h; sourceTree = "<group>"; };
9A4185B42439F29D00BEAFB8 /* LoadOptions_test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoadOptions_test.h; sourceTree = "<group>"; };
9A4185B52439F29D00BEAFB8 /* LoadOptions_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadOptions_test.cpp; sourceTree = "<group>"; };
9A670D2024E53FD400B5D780 /* XBuffer_tests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XBuffer_tests.cpp; sourceTree = "<group>"; };
9A670D2124E53FD500B5D780 /* XBuffer_tests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XBuffer_tests.h; sourceTree = "<group>"; };
9A7AEDE6245963BF003AAD04 /* XToolsCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XToolsCommon.h; sourceTree = "<group>"; };
9A9AEB90243F7B5600FBD7D8 /* unicode_conversions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = unicode_conversions.cpp; sourceTree = "<group>"; };
9A9AEB93243F7B5600FBD7D8 /* unicode_conversions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = unicode_conversions.h; sourceTree = "<group>"; };
@ -1161,9 +1165,6 @@
9AC77ECA24176C04005CDD5C /* cpp_unit_test */ = {
isa = PBXGroup;
children = (
9A9EA7FD245AD97F0076EC02 /* XToolsCommon_test.cpp */,
9A9EA7FC245AD97E0076EC02 /* XToolsCommon_test.h */,
9A9AEB98243F7B7900FBD7D8 /* printf_lite-test.h */,
9AC77ED424176C04005CDD5C /* all_tests.cpp */,
9AC77ED724176C04005CDD5C /* all_tests.h */,
9AC780B22417EE4A005CDD5C /* global_test.cpp */,
@ -1172,6 +1173,7 @@
9A4185B42439F29D00BEAFB8 /* LoadOptions_test.h */,
9AF41565242BAD5600D2644C /* printf_lite-test-cpp_conf.h */,
9A9D3B2124221563006D8CD9 /* printf_lite-test.cpp */,
9A9AEB98243F7B7900FBD7D8 /* printf_lite-test.h */,
9AF4155F242BABC700D2644C /* printlib-test-cpp_conf.h */,
9AF41561242BABC700D2644C /* printlib-test.cpp */,
9AF41560242BABC700D2644C /* printlib-test.h */,
@ -1183,12 +1185,16 @@
9A28CD30241BC0DF00F3D247 /* strncmp_test.h */,
9AC77ED624176C04005CDD5C /* XArray_tests.cpp */,
9AC77ECD24176C04005CDD5C /* XArray_tests.h */,
9A670D2024E53FD400B5D780 /* XBuffer_tests.cpp */,
9A670D2124E53FD500B5D780 /* XBuffer_tests.h */,
9AC77ED524176C04005CDD5C /* XObjArray_tests.cpp */,
9AC77ED324176C04005CDD5C /* XObjArray_tests.h */,
9A28CC95241AB34800F3D247 /* XString_test.cpp */,
9A28CC96241AB34800F3D247 /* XString_test.h */,
9AC77ECE24176C04005CDD5C /* XStringArray_test.cpp */,
9AC77ECC24176C04005CDD5C /* XStringArray_test.h */,
9A9EA7FD245AD97F0076EC02 /* XToolsCommon_test.cpp */,
9A9EA7FC245AD97E0076EC02 /* XToolsCommon_test.h */,
);
path = cpp_unit_test;
sourceTree = "<group>";
@ -1535,6 +1541,7 @@
9AC7804A24176C04005CDD5C /* XPointer.h in Headers */,
9A35A6182451FE1600CAFF76 /* XStringAbstract.h in Headers */,
9AC7806D24176C04005CDD5C /* bootscreen.h in Headers */,
9A670D2324E53FD500B5D780 /* XBuffer_tests.h in Headers */,
9AC7800E24176C04005CDD5C /* Settings.h in Headers */,
9A105B3924483AD50006DE06 /* image.h in Headers */,
9A105B7A24483AE40006DE06 /* cpu.h in Headers */,
@ -2061,6 +2068,7 @@
9AC7805024176C04005CDD5C /* scroll_images.cpp in Sources */,
9AC7809024176C04005CDD5C /* XStringArray.cpp in Sources */,
9AEFE64C24E2C64B005D56D8 /* XBuffer.cpp in Sources */,
9A670D2224E53FD500B5D780 /* XBuffer_tests.cpp in Sources */,
9AC7801024176C04005CDD5C /* PlatformDriverOverride.cpp in Sources */,
9AC7800224176C04005CDD5C /* HdaCodecDump.cpp in Sources */,
9AC7801A24176C04005CDD5C /* Nvram.cpp in Sources */,

View File

@ -81,6 +81,10 @@
9A57C2252418B9A00029A39F /* XStringArray_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B084F2402FE9B00E2B470 /* XStringArray_test.cpp */; };
9A57C2272418B9A00029A39F /* XArray_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B08532402FE9B00E2B470 /* XArray_tests.cpp */; };
9A57C2282418B9A00029A39F /* Platform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B085D240300E000E2B470 /* Platform.cpp */; };
9A670D1C24E535AB00B5D780 /* XBuffer_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A670D1B24E535AB00B5D780 /* XBuffer_tests.cpp */; };
9A670D1D24E535AB00B5D780 /* XBuffer_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A670D1B24E535AB00B5D780 /* XBuffer_tests.cpp */; };
9A670D1E24E535AB00B5D780 /* XBuffer_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A670D1B24E535AB00B5D780 /* XBuffer_tests.cpp */; };
9A670D1F24E535AB00B5D780 /* XBuffer_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A670D1B24E535AB00B5D780 /* XBuffer_tests.cpp */; };
9A9223312402FD1000483CBA /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9223302402FD1000483CBA /* main.cpp */; };
9A9AEB8D243F73CE00FBD7D8 /* unicode_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9AEB8C243F73CE00FBD7D8 /* unicode_conversions.cpp */; };
9A9AEB8E243F752C00FBD7D8 /* unicode_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9AEB8C243F73CE00FBD7D8 /* unicode_conversions.cpp */; };
@ -174,6 +178,8 @@
9A57C20A2418A1FD0029A39F /* global_test.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = global_test.h; sourceTree = "<group>"; };
9A57C22F2418B9A00029A39F /* cpp_tests UTF16 unsigned char */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "cpp_tests UTF16 unsigned char"; sourceTree = BUILT_PRODUCTS_DIR; };
9A57C266241A799B0029A39F /* XString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XString.h; sourceTree = "<group>"; };
9A670D1A24E535AB00B5D780 /* XBuffer_tests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XBuffer_tests.h; sourceTree = "<group>"; };
9A670D1B24E535AB00B5D780 /* XBuffer_tests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XBuffer_tests.cpp; sourceTree = "<group>"; };
9A6BA73C2449977300BDA52C /* XStringAbstract.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XStringAbstract.h; sourceTree = "<group>"; };
9A7AEDE82459696C003AAD04 /* XToolsCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XToolsCommon.h; sourceTree = "<group>"; };
9A92232D2402FD1000483CBA /* cpp_tests UTF16 signed char */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "cpp_tests UTF16 signed char"; sourceTree = BUILT_PRODUCTS_DIR; };
@ -292,6 +298,8 @@
9A0B084D2402FE9B00E2B470 /* XStringArray_test.h */,
9A9EA7F7245AAB310076EC02 /* XToolsCommon_test.cpp */,
9A9EA7F6245AAB310076EC02 /* XToolsCommon_test.h */,
9A670D1B24E535AB00B5D780 /* XBuffer_tests.cpp */,
9A670D1A24E535AB00B5D780 /* XBuffer_tests.h */,
);
name = cpp_unit_test;
path = ../../rEFIt_UEFI/cpp_unit_test;
@ -524,6 +532,7 @@
9A28CD11241B9EF800F3D247 /* strcmp.cpp in Sources */,
9A4185C12439F73A00BEAFB8 /* XStringArray.cpp in Sources */,
9A0B087E2403B08400E2B470 /* XArray_tests.cpp in Sources */,
9A670D1D24E535AB00B5D780 /* XBuffer_tests.cpp in Sources */,
9AA0458B2425F94D000D6970 /* printf_lite-test.cpp in Sources */,
9A0B087F2403B08400E2B470 /* Platform.cpp in Sources */,
);
@ -553,6 +562,7 @@
9A2A7C7C24576CCE00422263 /* strcmp.cpp in Sources */,
9A2A7C7D24576CCE00422263 /* XStringArray.cpp in Sources */,
9A2A7C7E24576CCE00422263 /* XArray_tests.cpp in Sources */,
9A670D1F24E535AB00B5D780 /* XBuffer_tests.cpp in Sources */,
9A2A7C7F24576CCE00422263 /* printf_lite-test.cpp in Sources */,
9A2A7C8024576CCE00422263 /* Platform.cpp in Sources */,
);
@ -582,6 +592,7 @@
9A28CD12241B9EF800F3D247 /* strcmp.cpp in Sources */,
9A4185C22439F73A00BEAFB8 /* XStringArray.cpp in Sources */,
9A57C2272418B9A00029A39F /* XArray_tests.cpp in Sources */,
9A670D1E24E535AB00B5D780 /* XBuffer_tests.cpp in Sources */,
9AA0458C2425F94D000D6970 /* printf_lite-test.cpp in Sources */,
9A57C2282418B9A00029A39F /* Platform.cpp in Sources */,
);
@ -611,6 +622,7 @@
9A4185C02439F73A00BEAFB8 /* XStringArray.cpp in Sources */,
9A28CD10241B9EF800F3D247 /* strcmp.cpp in Sources */,
9A0B085B2402FF8700E2B470 /* XArray_tests.cpp in Sources */,
9A670D1C24E535AB00B5D780 /* XBuffer_tests.cpp in Sources */,
9AA0458A2425F94D000D6970 /* printf_lite-test.cpp in Sources */,
9A0B085E240300E000E2B470 /* Platform.cpp in Sources */,
);

View File

@ -15,7 +15,7 @@
#define XStringGrowByDefault 10
#define XArrayGrowByDefault 8
//extern xsize XBufferGrowByDefault;
#define XBufferGrowByDefault 16
/* For convience, operator [] is define with int parameter.
* Defining __XTOOLS_CHECK_OVERFLOW__ make a check that the parameter is >= 0

View File

@ -520,7 +520,8 @@ SetupDataForOSX(BOOLEAN Hibernate)
LogDataHub(&gEfiMiscSubClassGuid, L"BEMB", &gSettings.Mobile, 1);
// all current settings
LogDataHub(&gEfiMiscSubClassGuid, L"Settings", &gSettings, sizeof(gSettings));
XBuffer<UINT8> xb = gSettings.serialize();
LogDataHub(&gEfiMiscSubClassGuid, L"Settings", xb.data(), (UINT32)xb.size());
}
if (!gAppleSmc) {
return;

View File

@ -7961,3 +7961,364 @@ EFI_STATUS LOADER_ENTRY::SetFSInjection ()
return Status;
}
//namespace old {
//#include "../../CloverApp/Clover/Clover-Bridging-Header.h"
//}
XBuffer<UINT8> SETTINGS_DATA::serialize() const
{
XBuffer<UINT8> xb;
// SMBIOS TYPE0
xb.ncat(VendorName, sizeof(VendorName));
xb.ncat(RomVersion, sizeof(RomVersion));
xb.ncat(EfiVersion.c_str(), MIN(EfiVersion.length(), 64)); xb.memsetAtPos(xb.size(), 0, 64-MIN(EfiVersion.length(), 64));
xb.ncat(ReleaseDate, sizeof(ReleaseDate));
// SMBIOS TYPE1
xb.ncat(ManufactureName ,sizeof(ManufactureName));
xb.ncat(ProductName, sizeof(ProductName));
xb.ncat(VersionNr, sizeof(VersionNr));
xb.ncat(SerialNr, sizeof(SerialNr));
xb.ncat(&SmUUID, sizeof(SmUUID));
xb.cat(SmUUIDConfig);
xb.ncat(&pad0, sizeof(pad0));
//CHAR8 Uuid[64]);
//CHAR8 SKUNumber[64]);
xb.ncat(&FamilyName, sizeof(FamilyName));
xb.ncat(&OEMProduct, sizeof(OEMProduct));
xb.ncat(&OEMVendor, sizeof(OEMVendor));
// SMBIOS TYPE2
xb.ncat(&BoardManufactureName, sizeof(BoardManufactureName));
xb.ncat(&BoardSerialNumber, sizeof(BoardSerialNumber));
xb.ncat(&BoardNumber, sizeof(BoardNumber)); //Board-ID
xb.ncat(&LocationInChassis, sizeof(LocationInChassis));
xb.ncat(&BoardVersion, sizeof(BoardVersion));
xb.ncat(&OEMBoard, sizeof(OEMBoard));
xb.cat(BoardType);
xb.cat(pad1);
// SMBIOS TYPE3
xb.cat(Mobile);
xb.cat(ChassisType);
xb.ncat(&ChassisManufacturer, sizeof(ChassisManufacturer));
xb.ncat(&ChassisAssetTag, sizeof(ChassisAssetTag));
// SMBIOS TYPE4
xb.cat(CpuFreqMHz);
xb.cat(BusSpeed); //in kHz
xb.cat(Turbo);
xb.cat(EnabledCores);
xb.cat(UserChange);
xb.cat(QEMU);
// SMBIOS TYPE17
xb.cat(SmbiosVersion);
xb.cat(Attribute);
xb.ncat(&pad17, sizeof(pad17));
xb.ncat(&MemoryManufacturer, sizeof(MemoryManufacturer));
xb.ncat(&MemorySerialNumber, sizeof(MemorySerialNumber));
xb.ncat(&MemoryPartNumber, sizeof(MemoryPartNumber));
xb.ncat(&MemorySpeed, sizeof(MemorySpeed));
// SMBIOS TYPE131
xb.cat(CpuType);
// SMBIOS TYPE132
xb.cat(QPI);
xb.cat(SetTable132);
xb.cat(TrustSMBIOS);
xb.cat(InjectMemoryTables);
xb.cat(XMPDetection);
xb.cat(UseARTFreq);
// SMBIOS TYPE133
xb.ncat(&pad18, sizeof(pad18));
xb.cat(PlatformFeature);
// PatchTableType11
xb.cat(NoRomInfo);
// OS parameters
xb.ncat(&Language, sizeof(Language));
xb.ncat(&BootArgs, sizeof(BootArgs));
xb.ncat(&pad19, sizeof(pad19));
xb.ncat(&CustomUuid, sizeof(CustomUuid));
xb.ncat(&pad20, sizeof(pad20));
xb.cat(DefaultVolume);
xb.cat(DefaultLoader);
//Boot
xb.cat(LastBootedVolume);
xb.cat(SkipHibernateTimeout);
//Monitor
xb.cat(IntelMaxBacklight);
xb.ncat(&pad21, sizeof(pad21));
xb.cat(VendorEDID);
xb.cat(ProductEDID);
xb.cat(BacklightLevel);
xb.cat(BacklightLevelConfig);
xb.cat(IntelBacklight);
//Boot options
xb.cat(MemoryFix);
xb.cat(WithKexts);
xb.cat(WithKextsIfNoFakeSMC);
xb.cat(FakeSMCFound);
xb.cat(NoCaches);
// GUI parameters
xb.cat(Debug);
// BOOLEAN Proportional); //never used
xb.ncat(&pad22, sizeof(pad22));
xb.cat(DefaultBackgroundColor);
//ACPI
xb.cat(ResetAddr);
xb.cat(ResetVal);
xb.cat(NoASPM);
xb.cat(DropSSDT);
xb.cat(NoOemTableId);
xb.cat(NoDynamicExtract);
xb.cat(AutoMerge);
xb.cat(GeneratePStates);
xb.cat(GenerateCStates);
xb.cat(GenerateAPSN);
xb.cat(GenerateAPLF);
xb.cat(GeneratePluginType);
xb.cat(PLimitDict);
xb.cat(UnderVoltStep);
xb.cat(DoubleFirstState);
xb.cat(SuspendOverride);
xb.cat(EnableC2);
xb.cat(EnableC4);
xb.cat(EnableC6);
xb.cat(EnableISS);
xb.cat(SlpSmiEnable);
xb.cat(FixHeaders);
xb.ncat(&pad23, sizeof(pad23));
xb.cat(C3Latency);
xb.cat(smartUPS);
xb.cat(PatchNMI);
xb.cat(EnableC7);
xb.cat(SavingMode);
xb.ncat(&DsdtName, sizeof(DsdtName));
xb.cat(FixDsdt);
xb.cat(MinMultiplier);
xb.cat(MaxMultiplier);
xb.cat(PluginType);
// BOOLEAN DropMCFG);
xb.cat(FixMCFG);
xb.cat(DeviceRenameCount);
xb.cat(DeviceRename);
//Injections
xb.cat(StringInjector);
xb.cat(InjectSystemID);
xb.cat(NoDefaultProperties);
xb.cat(ReuseFFFF);
//PCI devices
xb.cat(FakeATI); //97
xb.cat(FakeNVidia);
xb.cat(FakeIntel);
xb.cat(FakeLAN); //100
xb.cat(FakeWIFI);
xb.cat(FakeSATA);
xb.cat(FakeXHCI); //103
xb.cat(FakeIMEI); //106
//Graphics
// UINT16 PCIRootUID);
xb.cat(GraphicsInjector);
xb.cat(InjectIntel);
xb.cat(InjectATI);
xb.cat(InjectNVidia);
xb.cat(DeInit);
xb.cat(LoadVBios);
xb.cat(PatchVBios);
xb.ncat(&pad24, sizeof(pad24));
xb.cat(PatchVBiosBytes);
xb.cat(PatchVBiosBytesCount);
xb.cat(InjectEDID);
xb.cat(LpcTune);
xb.cat(DropOEM_DSM); //vacant
xb.ncat(&pad25, sizeof(pad25));
xb.cat(CustomEDID);
xb.cat(CustomEDIDsize);
xb.cat(EdidFixHorizontalSyncPulseWidth);
xb.cat(EdidFixVideoInputSignal);
xb.ncat(&pad26, sizeof(pad26));
xb.ncat(&FBName, sizeof(FBName));
xb.cat(VideoPorts);
xb.cat(NvidiaGeneric);
xb.cat(NvidiaNoEFI);
xb.cat(NvidiaSingle);
xb.ncat(&pad27, sizeof(pad27));
xb.cat(VRAM);
xb.ncat(&Dcfg, sizeof(Dcfg));
xb.ncat(&NVCAP, sizeof(NVCAP));
xb.cat(BootDisplay);
xb.cat(NvidiaWeb);
xb.ncat(&pad41, sizeof(pad41));
xb.cat(DualLink);
xb.cat(IgPlatform);
// Secure boot white/black list
xb.cat(SecureBootWhiteListCount);
xb.cat(SecureBootBlackListCount);
xb.cat(SecureBootWhiteList);
xb.cat(SecureBootBlackList);
// Secure boot
xb.cat(SecureBoot);
xb.cat(SecureBootSetupMode);
xb.cat(SecureBootPolicy);
// HDA
xb.cat(HDAInjection);
xb.cat(HDALayoutId);
// USB DeviceTree injection
xb.cat(USBInjection);
xb.cat(USBFixOwnership);
xb.cat(InjectClockID);
xb.cat(HighCurrent);
xb.cat(NameEH00);
xb.cat(NameXH00);
xb.cat(LANInjection);
xb.cat(HDMIInjection);
// UINT8 pad61[2]);
// LegacyBoot
xb.ncat(&LegacyBoot, sizeof(LegacyBoot));
xb.cat(LegacyBiosDefaultEntry);
//SkyLake
xb.cat(HWP);
xb.cat(TDP);
xb.cat(HWPValue);
//Volumes hiding
xb.cat(HVHideStrings);
xb.cat(HVCount);
// KernelAndKextPatches
xb.memsetAtPos(xb.size(), 0, 112); //KernelAndKextPatches was 112 bytes
xb.cat(KextPatchesAllowed);
xb.cat(KernelPatchesAllowed); //From GUI: Only for user patches, not internal Clover
xb.ncat(&AirportBridgeDeviceName, sizeof(AirportBridgeDeviceName));
// Pre-language
xb.cat(KbdPrevLang);
//Pointer
xb.cat(PointerEnabled);
xb.ncat(&pad28, sizeof(pad28));
xb.cat(PointerSpeed);
xb.cat(DoubleClickTime);
xb.cat(PointerMirror);
// UINT8 pad7[6]);
xb.cat(CustomBoot);
xb.ncat(&pad29, sizeof(pad29));
xb.cat(CustomLogo);
xb.cat(RefCLK);
// SysVariables
xb.ncat(&pad30, sizeof(pad30));
xb.cat(RtMLB);
xb.cat(RtROM);
xb.cat(RtROMLen);
xb.cat(CsrActiveConfig);
xb.cat(BooterConfig);
xb.ncat(&BooterCfgStr, sizeof(BooterCfgStr));
xb.cat(DisableCloverHotkeys);
xb.cat(NeverDoRecovery);
// Multi-config
xb.ncat(&ConfigName, sizeof(ConfigName));
xb.ncat(&pad31, sizeof(pad31));
xb.cat(MainConfigName);
//Drivers
xb.cat(BlackListCount);
xb.cat(BlackList);
//SMC keys
xb.ncat(&RPlt, sizeof(RPlt));
xb.ncat(&RBr, sizeof(RBr));
xb.ncat(&EPCI, sizeof(EPCI));
xb.ncat(&REV, sizeof(REV));
//other devices
xb.cat(Rtc8Allowed);
xb.cat(ForceHPET);
xb.cat(ResetHDA);
xb.cat(PlayAsync);
xb.ncat(&pad32, sizeof(pad32));
xb.cat(DisableFunctions);
//Patch DSDT arbitrary
xb.cat(PatchDsdtNum);
xb.cat(PatchDsdtFind);
xb.cat(LenToFind);
xb.cat(PatchDsdtReplace);
xb.cat(LenToReplace);
xb.cat(DebugDSDT);
xb.cat(SlpWak);
xb.cat(UseIntelHDMI);
xb.cat(AFGLowPowerState);
xb.cat(PNLF_UID);
// UINT8 pad83[4]);
// Table dropping
xb.ncat(&pad34, sizeof(pad34));
xb.cat(ACPIDropTables);
// Custom entries
xb.cat(DisableEntryScan);
xb.cat(DisableToolScan);
xb.cat(ShowHiddenEntries);
xb.cat(KernelScan);
xb.cat(LinuxScan);
// UINT8 pad84[3]);
xb.ncat(&pad35, sizeof(pad35));
xb.cat(CustomEntries);
xb.cat(CustomLegacy);
xb.cat(CustomTool);
//Add custom properties
xb.cat(NrAddProperties);
xb.cat(AddProperties);
//BlackListed kexts
xb.ncat(&BlockKexts, sizeof(BlockKexts));
//ACPI tables
xb.cat(SortedACPICount);
xb.cat(SortedACPI);
// ACPI/PATCHED/AML
xb.cat(DisabledAMLCount);
xb.ncat(&pad36, sizeof(pad36));
xb.cat(DisabledAML);
xb.cat(PatchDsdtLabel);
xb.cat(PatchDsdtTgt);
xb.cat(PatchDsdtMenuItem);
//other
xb.cat(IntelMaxValue);
// UINT32 AudioVolume);
// boot.efi
xb.cat(OptionsBits);
xb.cat(FlagsBits);
xb.cat(UIScale);
xb.cat(EFILoginHiDPI);
xb.ncat(&flagstate, sizeof(flagstate));
xb.ncat(&pad37, sizeof(pad37));
xb.cat(ArbProperties);
// xb.cat(QuirksMask);
// xb.ncat(&pad38, sizeof(pad38));
// xb.cat(MaxSlide);
// if ( xb.size() != sizeof(old::SETTINGS_DATA) ) {
if ( xb.size() != 3088 ) {
DBG("BUG\n");
}
return xb;
}

View File

@ -211,6 +211,8 @@ public:
DEV_PROPERTY& operator=(const DEV_PROPERTY&) = delete;
};
#pragma GCC diagnostic error "-Wpadded"
class SETTINGS_DATA {
public:
// SMBIOS TYPE0
@ -239,7 +241,7 @@ public:
CHAR8 BoardVersion[64];
CHAR8 OEMBoard[64];
UINT8 BoardType;
UINT8 Pad1;
UINT8 pad1;
// SMBIOS TYPE3
BOOLEAN Mobile;
UINT8 ChassisType;
@ -255,7 +257,7 @@ public:
// SMBIOS TYPE17
UINT16 SmbiosVersion;
INT8 Attribute;
INT8 Pad17[1];
INT8 pad17[1];
CHAR8 MemoryManufacturer[64];
CHAR8 MemorySerialNumber[64];
CHAR8 MemoryPartNumber[64];
@ -269,6 +271,8 @@ public:
BOOLEAN InjectMemoryTables;
INT8 XMPDetection;
BOOLEAN UseARTFreq;
INT8 pad18[3];
// SMBIOS TYPE133
UINT64 PlatformFeature;
@ -278,8 +282,10 @@ public:
// OS parameters
CHAR8 Language[16];
CHAR8 BootArgs[256];
INT8 pad19[1];
CHAR16 CustomUuid[40];
INT8 pad20[6];
CHAR16 *DefaultVolume;
CHAR16 *DefaultLoader;
//Boot
@ -287,7 +293,7 @@ public:
BOOLEAN SkipHibernateTimeout;
//Monitor
BOOLEAN IntelMaxBacklight;
// UINT8 Pad21[1];
UINT8 pad21[1];
UINT16 VendorEDID;
UINT16 ProductEDID;
UINT16 BacklightLevel;
@ -303,7 +309,7 @@ public:
// GUI parameters
BOOLEAN Debug;
// BOOLEAN Proportional; //never used
UINT8 Pad22[1];
UINT8 pad22[2];
UINT32 DefaultBackgroundColor;
//ACPI
@ -329,6 +335,7 @@ public:
BOOLEAN EnableISS;
BOOLEAN SlpSmiEnable;
BOOLEAN FixHeaders;
UINT8 pad23[1];
UINT16 C3Latency;
BOOLEAN smartUPS;
BOOLEAN PatchNMI;
@ -371,21 +378,25 @@ public:
BOOLEAN DeInit;
BOOLEAN LoadVBios;
BOOLEAN PatchVBios;
UINT8 pad24[5];
VBIOS_PATCH_BYTES *PatchVBiosBytes;
UINTN PatchVBiosBytesCount;
BOOLEAN InjectEDID;
BOOLEAN LpcTune;
UINT16 DropOEM_DSM; //vacant
UINT8 pad25[4];
UINT8 *CustomEDID;
UINT16 CustomEDIDsize;
UINT16 EdidFixHorizontalSyncPulseWidth;
UINT8 EdidFixVideoInputSignal;
UINT8 pad26[1];
CHAR16 FBName[16];
UINT16 VideoPorts;
BOOLEAN NvidiaGeneric;
BOOLEAN NvidiaNoEFI;
BOOLEAN NvidiaSingle;
UINT8 pad27[5];
UINT64 VRAM;
UINT8 Dcfg[8];
UINT8 NVCAP[20];
@ -450,17 +461,20 @@ public:
//Pointer
BOOLEAN PointerEnabled;
UINT8 pad28[7];
INTN PointerSpeed;
UINT64 DoubleClickTime;
BOOLEAN PointerMirror;
// UINT8 pad7[6];
UINT8 CustomBoot;
UINT8 pad29[6];
XImage *CustomLogo;
UINT32 RefCLK;
// SysVariables
UINT8 pad30[4];
CHAR8 *RtMLB;
UINT8 *RtROM;
UINTN RtROMLen;
@ -473,6 +487,7 @@ public:
// Multi-config
CHAR16 ConfigName[30];
UINT8 pad31[4];
CHAR16 *MainConfigName;
//Drivers
@ -490,6 +505,7 @@ public:
BOOLEAN ForceHPET;
BOOLEAN ResetHDA;
BOOLEAN PlayAsync;
UINT8 pad32[2];
UINT32 DisableFunctions;
//Patch DSDT arbitrary
@ -508,6 +524,7 @@ public:
// Table dropping
UINT8 pad34[3];
ACPI_DROP_TABLE *ACPIDropTables;
// Custom entries
@ -516,7 +533,7 @@ public:
BOOLEAN ShowHiddenEntries;
UINT8 KernelScan;
BOOLEAN LinuxScan;
// UINT8 pad84[3];
UINT8 pad35[3];
CUSTOM_LOADER_ENTRY *CustomEntries;
CUSTOM_LEGACY_ENTRY *CustomLegacy;
CUSTOM_TOOL_ENTRY *CustomTool;
@ -539,6 +556,7 @@ public:
// ACPI/PATCHED/AML
UINT32 DisabledAMLCount;
UINT8 pad36[4];
CHAR16 **DisabledAML;
CHAR8 **PatchDsdtLabel;
CHAR8 **PatchDsdtTgt;
@ -555,20 +573,22 @@ public:
UINT32 EFILoginHiDPI;
UINT8 flagstate[32];
UINT8 pad37[4];
DEV_PROPERTY *ArbProperties;
UINT32 QuirksMask;
UINT8 pad38[4];
UINTN MaxSlide;
SETTINGS_DATA() : VendorName{0}, RomVersion{0}, EfiVersion{0}, ReleaseDate{0}, ManufactureName{0}, ProductName{0}, VersionNr{0}, SerialNr{0}, SmUUID({0,0,0,{0}}),
SmUUIDConfig(0), pad0{0}, FamilyName{0}, OEMProduct{0}, OEMVendor{0}, BoardManufactureName{0}, BoardSerialNumber{0}, BoardNumber{0}, LocationInChassis{0},
BoardVersion{0}, OEMBoard{0}, BoardType(0), Pad1(0), Mobile(0), ChassisType(0), ChassisManufacturer{0}, ChassisAssetTag{0}, CpuFreqMHz(0),
BusSpeed(0), Turbo(0), EnabledCores(0), UserChange(0), QEMU(0), SmbiosVersion(0), Attribute(0), Pad17{0}, MemoryManufacturer{0},
BoardVersion{0}, OEMBoard{0}, BoardType(0), pad1(0), Mobile(0), ChassisType(0), ChassisManufacturer{0}, ChassisAssetTag{0}, CpuFreqMHz(0),
BusSpeed(0), Turbo(0), EnabledCores(0), UserChange(0), QEMU(0), SmbiosVersion(0), Attribute(0), pad17{0}, MemoryManufacturer{0},
MemorySerialNumber{0}, MemoryPartNumber{0}, MemorySpeed{0}, CpuType(0), QPI(0), SetTable132(0), TrustSMBIOS(0), InjectMemoryTables(0), XMPDetection(0),
UseARTFreq(0), PlatformFeature(0), NoRomInfo(0), Language{0}, BootArgs{0}, CustomUuid{0}, DefaultVolume(0), DefaultLoader(0), LastBootedVolume(0),
SkipHibernateTimeout(0), IntelMaxBacklight(0), VendorEDID(0), ProductEDID(0), BacklightLevel(0), BacklightLevelConfig(0), IntelBacklight(0), MemoryFix(0), WithKexts(0),
WithKextsIfNoFakeSMC(0), FakeSMCFound(0), NoCaches(0), Debug(0), Pad22{0}, DefaultBackgroundColor(0), ResetAddr(0), ResetVal(0), NoASPM(0),
WithKextsIfNoFakeSMC(0), FakeSMCFound(0), NoCaches(0), Debug(0), pad22{0}, DefaultBackgroundColor(0), ResetAddr(0), ResetVal(0), NoASPM(0),
DropSSDT(0), NoOemTableId(0), NoDynamicExtract(0), AutoMerge(0), GeneratePStates(0), GenerateCStates(0), GenerateAPSN(0), GenerateAPLF(0), GeneratePluginType(0),
PLimitDict(0), UnderVoltStep(0), DoubleFirstState(0), SuspendOverride(0), EnableC2(0), EnableC4(0), EnableC6(0), EnableISS(0), SlpSmiEnable(0),
FixHeaders(0), C3Latency(0), smartUPS(0), PatchNMI(0), EnableC7(0), SavingMode(0), DsdtName{0}, FixDsdt(0), MinMultiplier(0),
@ -591,10 +611,15 @@ public:
{};
SETTINGS_DATA(const SETTINGS_DATA& other) = delete; // Can be defined if needed
const SETTINGS_DATA& operator = ( const SETTINGS_DATA & ) = delete; // Can be defined if needed
XBuffer<UINT8> serialize() const;
~SETTINGS_DATA() {}
};
#pragma GCC diagnostic ignored "-Wpadded"
typedef enum {
english = 0, //en
russian, //ru

View File

@ -54,6 +54,8 @@ class XBuffer : public XBuffer_Super
template<typename IntegralType, enable_if(is_integral(IntegralType))>
const T* data(IntegralType i) const { return XBuffer_Super::data(i); }
template<typename IntegralType, enable_if(is_integral(IntegralType))>
T* data(IntegralType i) { return _WData + i; }
template<typename IntegralType, enable_if(is_integral(IntegralType))>
T* dataSized(IntegralType size) {
@ -77,6 +79,7 @@ class XBuffer : public XBuffer_Super
template<typename IntegralType, enable_if(is_integral(IntegralType))>
void setSize(IntegralType size) { CheckSize(size); XBuffer_Super::m_size = size; };
void setEmpty() { setSize(0); };
/* [] */
@ -112,26 +115,30 @@ class XBuffer : public XBuffer_Super
void ncpy(const void *buf, size_t len);
// Cat
void Cat(const void *buf, size_t len);
void ncat(const void *buf, size_t len);
void Cat(bool b) { Cat(&b, sizeof(b)); };
void cat(bool b) { ncat(&b, sizeof(b)); };
void Cat(char c) { Cat(&c, sizeof(c)); };
void Cat(unsigned char b) { Cat(&b, sizeof(b)); };
void Cat(short s) { Cat(&s, sizeof(s)); };
void Cat(unsigned short us) { Cat(&us, sizeof(us)); };
void Cat(int i) { Cat(&i, sizeof(i)); };
void Cat(unsigned int ui) { Cat(&ui, sizeof(ui)); };
void Cat(long l) { Cat(&l, sizeof(l)); };
void Cat(unsigned long ul) { Cat(&ul, sizeof(ul)); };
void Cat(unsigned long long ull) { Cat(&ull, sizeof(ull)); };
void cat(char c) { ncat(&c, sizeof(c)); };
void cat(unsigned char c) { ncat(&c, sizeof(c)); };
void cat(signed char c) { ncat(&c, sizeof(c)); };
void cat(signed short s) { ncat(&s, sizeof(s)); };
void cat(unsigned short us) { ncat(&us, sizeof(us)); };
void cat(signed int i) { ncat(&i, sizeof(i)); };
void cat(unsigned int ui) { ncat(&ui, sizeof(ui)); };
void cat(signed long l) { ncat(&l, sizeof(l)); };
void cat(unsigned long ul) { ncat(&ul, sizeof(ul)); };
void cat(signed long long ull) { ncat(&ull, sizeof(ull)); };
void cat(unsigned long long ull) { ncat(&ull, sizeof(ull)); };
void Cat(float f) { Cat(&f, sizeof(f)); };
void Cat(double d) { Cat(&d, sizeof(d)); };
void cat(float f) { ncat(&f, sizeof(f)); };
void cat(double d) { ncat(&d, sizeof(d)); };
void Cat(const XString8 &aXString8);
void Cat(const XBuffer &unXBuffer) { Cat(unXBuffer.Length()); Cat(unXBuffer.Data(), unXBuffer.Length()); }
void Delete(unsigned int pos, unsigned int count=1);
void cat(void* p) { ncat(&p, sizeof(p)); };
void cat(const XString8 &aXString8);
void cat(const XBuffer &unXBuffer) { ncat(unXBuffer.Length()); ncat(unXBuffer.Data(), unXBuffer.Length()); }
void deleteAtPos(unsigned int pos, unsigned int count=1);
const XBuffer &operator += (const XRBuffer<T> &aBuffer);
@ -267,24 +274,24 @@ void XBuffer<T>::ncpy(const void *buf, size_t len)
}
template <typename T>
void XBuffer<T>::Cat(const void *buf, size_t len)
void XBuffer<T>::ncat(const void *buf, size_t len)
{
if ( buf && len > 0 ) {
CheckSize(size()+len);
memcpy(Data(size()), buf, len);
SetLength(size()+len);
memcpy(data(size()), buf, len);
setSize(size()+len);
}
}
template <typename T>
void XBuffer<T>::Cat(const XString8 &aXString8)
void XBuffer<T>::cat(const XString8 &aXString8)
{
Cat(aXString8.sizeInBytes());
Cat(aXString8.data(),aXString8.sizeInBytes());
cat(aXString8.sizeInBytes());
cat(aXString8.data(),aXString8.sizeInBytes());
};
template <typename T>
void XBuffer<T>::Delete(unsigned int pos, unsigned int count)
void XBuffer<T>::deleteAtPos(unsigned int pos, unsigned int count)
{
if ( pos < size() ) {
if ( pos + count < size() ) {

View File

@ -0,0 +1,20 @@
#include <Platform.h>
#include "../cpp_foundation/XBuffer.h"
int XBuffer_tests()
{
#ifdef JIEF_DEBUG
// printf("XBuffer_tests -> Enter\n");
#endif
XBuffer<UINT8> xb_uint8;
void* p = (void*)1;
char* p2 = (char*)2;
xb_uint8.cat(p);
xb_uint8.cat(p2);
xb_uint8.cat(uintptr_t(0));
return 0;
}

View File

@ -0,0 +1,2 @@
int XBuffer_tests();

View File

@ -14,6 +14,7 @@
#include "printf_lite-test.h"
#include "LoadOptions_test.h"
#include "XToolsCommon_test.h"
#include "XBuffer_tests.h"
#if defined(JIEF_DEBUG) && defined(CLOVER_BUILD)
#include "printlib-test.h"
@ -37,11 +38,11 @@ bool all_tests()
// all_ok = false;
// }
#if defined(JIEF_DEBUG)
ret = XStringArray_tests();
if ( ret != 0 ) {
printf("XStringArray_tests() failed at test %d\n", ret);
all_ok = false;
}
ret = XBuffer_tests();
if ( ret != 0 ) {
printf("XBuffer_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);
@ -103,11 +104,16 @@ bool all_tests()
printf("XStringArray_tests() failed at test %d\n", ret);
all_ok = false;
}
ret = BootOptions_tests();
if ( ret != 0 ) {
printf("BootOptions_tests() failed at test %d\n", ret);
all_ok = false;
}
ret = BootOptions_tests();
if ( ret != 0 ) {
printf("BootOptions_tests() failed at test %d\n", ret);
all_ok = false;
}
ret = XBuffer_tests();
if ( ret != 0 ) {
printf("XBuffer_tests() failed at test %d\n", ret);
all_ok = false;
}
// ret = XUINTN_tests();
// if ( ret != 0 ) {
// printf("XUINTN_tests() failed at test %d\n", ret);