Create SETTINGS_DATA Devices section.

Convert AddProperties to XObjArray<DEV_ADDPROPERTY>.
This commit is contained in:
jief666 2021-03-29 11:50:02 +03:00
parent 773f9bdaf7
commit a5494a89f6
19 changed files with 463 additions and 455 deletions

2
Qemu/.gitignore vendored
View File

@ -1,5 +1,5 @@
/__MACOSX/ /__MACOSX/
/serial0_qemu_out.log /serial0_qemu_out.log
/disk_image_gpt.img /disk_image_gpt.img*
/cmds.txt /cmds.txt
/lldb_launch /lldb_launch

View File

@ -377,7 +377,7 @@ AML_CHUNK* aml_add_store(AML_CHUNK* parent)
return node; return node;
} }
AML_CHUNK* aml_add_byte_buffer(AML_CHUNK* parent, /* CONST*/ UINT8* data, UINT32 size) AML_CHUNK* aml_add_byte_buffer(AML_CHUNK* parent, CONST UINT8* data, UINT32 size)
{ {
AML_CHUNK* node = aml_create_node(parent); AML_CHUNK* node = aml_create_node(parent);

View File

@ -91,7 +91,7 @@ UINT32 aml_write_size(UINT32 size, CHAR8* buffer, UINT32 offset);
// add by pcj // add by pcj
AML_CHUNK* aml_add_string(AML_CHUNK* parent, CONST CHAR8* string); AML_CHUNK* aml_add_string(AML_CHUNK* parent, CONST CHAR8* string);
AML_CHUNK* aml_add_byte_buffer(AML_CHUNK* parent, /* CONST*/ UINT8* data,UINT32 size); AML_CHUNK* aml_add_byte_buffer(AML_CHUNK* parent, CONST UINT8* data,UINT32 size);
AML_CHUNK* aml_add_string_buffer(AML_CHUNK* parent, CONST CHAR8* string); AML_CHUNK* aml_add_string_buffer(AML_CHUNK* parent, CONST CHAR8* string);
AML_CHUNK* aml_add_device(AML_CHUNK* parent, CONST CHAR8* name); AML_CHUNK* aml_add_device(AML_CHUNK* parent, CONST CHAR8* name);
AML_CHUNK* aml_add_local0(AML_CHUNK* parent); AML_CHUNK* aml_add_local0(AML_CHUNK* parent);

View File

@ -337,7 +337,7 @@ OnExitBootServices(IN EFI_EVENT Event, IN void *Context)
} }
#endif #endif
if (gSettings.USBFixOwnership) { if (gSettings.Devices.USB.USBFixOwnership) {
FixOwnership(); FixOwnership();
} }
} }

View File

@ -793,9 +793,9 @@ void CheckHardware()
// if ((Pci.Hdr.VendorId == 0x8086) && // if ((Pci.Hdr.VendorId == 0x8086) &&
// ((Pci.Hdr.DeviceId & 0xFF00) != 0x0C00)) { //0x0C0C is HDMI sound // ((Pci.Hdr.DeviceId & 0xFF00) != 0x0C00)) { //0x0C0C is HDMI sound
GetPciADR(DevicePath, &HDAADR1, NULL, NULL); GetPciADR(DevicePath, &HDAADR1, NULL, NULL);
if (gSettings.HDALayoutId > 0) { if (gSettings.Devices.Audio.HDALayoutId > 0) {
// layoutId is specified - use it // layoutId is specified - use it
layoutId = (UINT32)gSettings.HDALayoutId; layoutId = (UINT32)gSettings.Devices.Audio.HDALayoutId;
DBG("Audio HDA (addr:0x%X) setting specified layout-id=%d (0x%X)\n", HDAADR1, layoutId, layoutId); DBG("Audio HDA (addr:0x%X) setting specified layout-id=%d (0x%X)\n", HDAADR1, layoutId, layoutId);
} }
@ -1581,22 +1581,21 @@ BOOLEAN CustProperties(AML_CHUNK* pack, UINT32 Dev)
{ {
UINTN i; UINTN i;
BOOLEAN Injected = FALSE; BOOLEAN Injected = FALSE;
if (gSettings.NrAddProperties == 0xFFFE) { if (gSettings.Devices.AddProperties.size() == 0xFFFE) { // Looks like NrAddProperties == 0xFFFE is not used anymore
return FALSE; // not do this for Arbitrary properties? return FALSE; // not do this for Arbitrary properties?
} }
for (i = 0; i < gSettings.NrAddProperties; i++) { for (i = 0; i < gSettings.Devices.AddProperties.size(); i++) {
if (gSettings.AddProperties[i].Device != Dev) { if (gSettings.Devices.AddProperties[i].Device != Dev) {
continue; continue;
} }
Injected = TRUE; Injected = TRUE;
if (!gSettings.AddProperties[i].MenuItem.BValue) { if (!gSettings.Devices.AddProperties[i].MenuItem.BValue) {
//DBG(" disabled property Key: %s, len: %d\n", gSettings.AddProperties[i].Key, gSettings.AddProperties[i].ValueLen); //DBG(" disabled property Key: %s, len: %d\n", gSettings.Devices.AddProperties[i].Key, gSettings.Devices.AddProperties[i].ValueLen);
} else { } else {
aml_add_string(pack, gSettings.AddProperties[i].Key); aml_add_string(pack, gSettings.Devices.AddProperties[i].Key.c_str());
aml_add_byte_buffer(pack, gSettings.AddProperties[i].Value, aml_add_byte_buffer(pack, gSettings.Devices.AddProperties[i].Value.data(), (UINT32)gSettings.Devices.AddProperties[i].Value.size()); // unsafe cast
(UINT32)gSettings.AddProperties[i].ValueLen); //DBG(" added property Key: %s, len: %d\n", gSettings.Devices.AddProperties[i].Key, gSettings.Devices.AddProperties[i].ValueLen);
//DBG(" added property Key: %s, len: %d\n", gSettings.AddProperties[i].Key, gSettings.AddProperties[i].ValueLen);
} }
} }
return Injected; return Injected;
@ -2634,9 +2633,9 @@ UINT32 FIXDisplay (UINT8 *dsdt, UINT32 len, INT32 VCard)
( (
!NeedHDMI && !NeedHDMI &&
( (
((DisplayVendor[VCard] == 0x8086) && (gSettings.Graphics.InjectAsDict.InjectIntel || !gSettings.FakeIntel)) || ((DisplayVendor[VCard] == 0x8086) && (gSettings.Graphics.InjectAsDict.InjectIntel || !gSettings.Devices.FakeID.FakeIntel)) ||
((DisplayVendor[VCard] == 0x10DE) && (gSettings.Graphics.InjectAsDict.InjectNVidia || !gSettings.FakeNVidia)) || ((DisplayVendor[VCard] == 0x10DE) && (gSettings.Graphics.InjectAsDict.InjectNVidia || !gSettings.Devices.FakeID.FakeNVidia)) ||
((DisplayVendor[VCard] == 0x1002) && (gSettings.Graphics.InjectAsDict.InjectATI || !gSettings.FakeATI)) ((DisplayVendor[VCard] == 0x1002) && (gSettings.Graphics.InjectAsDict.InjectATI || !gSettings.Devices.FakeID.FakeATI))
) )
) )
) { ) {
@ -2651,38 +2650,38 @@ UINT32 FIXDisplay (UINT8 *dsdt, UINT32 len, INT32 VCard)
if (NeedHDMI) { if (NeedHDMI) {
aml_add_string(pack, "hda-gfx"); aml_add_string(pack, "hda-gfx");
aml_add_string_buffer(pack, (gSettings.UseIntelHDMI && DisplayVendor[VCard] != 0x8086) ? "onboard-2" : "onboard-1"); aml_add_string_buffer(pack, (gSettings.Devices.UseIntelHDMI && DisplayVendor[VCard] != 0x8086) ? "onboard-2" : "onboard-1");
} }
switch (DisplayVendor[VCard]) { switch (DisplayVendor[VCard]) {
case 0x8086: case 0x8086:
if (gSettings.FakeIntel) { if (gSettings.Devices.FakeID.FakeIntel) {
FakeID = gSettings.FakeIntel >> 16; FakeID = gSettings.Devices.FakeID.FakeIntel >> 16;
aml_add_string(pack, "device-id"); aml_add_string(pack, "device-id");
aml_add_byte_buffer(pack, (UINT8*)&FakeID, 4); aml_add_byte_buffer(pack, (UINT8*)&FakeID, 4);
FakeVen = gSettings.FakeIntel & 0xFFFF; FakeVen = gSettings.Devices.FakeID.FakeIntel & 0xFFFF;
aml_add_string(pack, "vendor-id"); aml_add_string(pack, "vendor-id");
aml_add_byte_buffer(pack, (UINT8*)&FakeVen, 4); aml_add_byte_buffer(pack, (UINT8*)&FakeVen, 4);
} }
break; break;
case 0x10DE: case 0x10DE:
if (gSettings.FakeNVidia) { if (gSettings.Devices.FakeID.FakeNVidia) {
FakeID = gSettings.FakeNVidia >> 16; FakeID = gSettings.Devices.FakeID.FakeNVidia >> 16;
aml_add_string(pack, "device-id"); aml_add_string(pack, "device-id");
aml_add_byte_buffer(pack, (UINT8*)&FakeID, 4); aml_add_byte_buffer(pack, (UINT8*)&FakeID, 4);
FakeVen = gSettings.FakeNVidia & 0xFFFF; FakeVen = gSettings.Devices.FakeID.FakeNVidia & 0xFFFF;
aml_add_string(pack, "vendor-id"); aml_add_string(pack, "vendor-id");
aml_add_byte_buffer(pack, (UINT8*)&FakeVen, 4); aml_add_byte_buffer(pack, (UINT8*)&FakeVen, 4);
} }
break; break;
case 0x1002: case 0x1002:
if (gSettings.FakeATI) { if (gSettings.Devices.FakeID.FakeATI) {
FakeID = gSettings.FakeATI >> 16; FakeID = gSettings.Devices.FakeID.FakeATI >> 16;
aml_add_string(pack, "device-id"); aml_add_string(pack, "device-id");
aml_add_byte_buffer(pack, (UINT8*)&FakeID, 4); aml_add_byte_buffer(pack, (UINT8*)&FakeID, 4);
aml_add_string(pack, "ATY,DeviceID"); aml_add_string(pack, "ATY,DeviceID");
aml_add_byte_buffer(pack, (UINT8*)&FakeID, 2); aml_add_byte_buffer(pack, (UINT8*)&FakeID, 2);
FakeVen = gSettings.FakeATI & 0xFFFF; FakeVen = gSettings.Devices.FakeID.FakeATI & 0xFFFF;
aml_add_string(pack, "vendor-id"); aml_add_string(pack, "vendor-id");
aml_add_byte_buffer(pack, (UINT8*)&FakeVen, 4); aml_add_byte_buffer(pack, (UINT8*)&FakeVen, 4);
aml_add_string(pack, "ATY,VendorID"); aml_add_string(pack, "ATY,VendorID");
@ -2902,9 +2901,9 @@ UINT32 AddHDMI (UINT8 *dsdt, UINT32 len)
met2 = aml_add_store(met); met2 = aml_add_store(met);
pack = aml_add_package(met2); pack = aml_add_package(met2);
if (!gSettings.NoDefaultProperties) { if (!gSettings.Devices.NoDefaultProperties) {
aml_add_string(pack, "hda-gfx"); aml_add_string(pack, "hda-gfx");
if (gSettings.UseIntelHDMI) { if (gSettings.Devices.UseIntelHDMI) {
aml_add_string_buffer(pack, "onboard-2"); aml_add_string_buffer(pack, "onboard-2");
} else { } else {
aml_add_string_buffer(pack, "onboard-1"); aml_add_string_buffer(pack, "onboard-1");
@ -2973,9 +2972,9 @@ UINT32 FIXNetwork (UINT8 *dsdt, UINT32 len, UINT32 card)
if (!NetworkADR1[card]) return len; if (!NetworkADR1[card]) return len;
DBG("Start NetWork %d Fix\n", card); DBG("Start NetWork %d Fix\n", card);
if (gSettings.FakeLAN) { if (gSettings.Devices.FakeID.FakeLAN) {
FakeID = gSettings.FakeLAN >> 16; FakeID = gSettings.Devices.FakeID.FakeLAN >> 16;
FakeVen = gSettings.FakeLAN & 0xFFFF; FakeVen = gSettings.Devices.FakeID.FakeLAN & 0xFFFF;
snprintf(NameCard, 32, "pci%x,%x", FakeVen, FakeID); snprintf(NameCard, 32, "pci%x,%x", FakeVen, FakeID);
Netmodel[card] = get_net_model((FakeVen << 16) + FakeID); Netmodel[card] = get_net_model((FakeVen << 16) + FakeID);
} }
@ -3082,7 +3081,7 @@ UINT32 FIXNetwork (UINT8 *dsdt, UINT32 len, UINT32 card)
} }
// add Method(_DSM,4,NotSerialized) for network // add Method(_DSM,4,NotSerialized) for network
if (gSettings.FakeLAN || !gSettings.NoDefaultProperties) { if (gSettings.Devices.FakeID.FakeLAN || !gSettings.Devices.NoDefaultProperties) {
met = aml_add_method(dev, "_DSM", 4); met = aml_add_method(dev, "_DSM", 4);
met2 = aml_add_store(met); met2 = aml_add_store(met);
pack = aml_add_package(met2); pack = aml_add_package(met2);
@ -3093,7 +3092,7 @@ UINT32 FIXNetwork (UINT8 *dsdt, UINT32 len, UINT32 card)
aml_add_string_buffer(pack, Netmodel[card]); aml_add_string_buffer(pack, Netmodel[card]);
// aml_add_string(pack, "device_type"); // aml_add_string(pack, "device_type");
// aml_add_string_buffer(pack, "Ethernet"); // aml_add_string_buffer(pack, "Ethernet");
if (gSettings.FakeLAN) { if (gSettings.Devices.FakeID.FakeLAN) {
// aml_add_string(pack, "model"); // aml_add_string(pack, "model");
// aml_add_string_buffer(pack, "Apple LAN card"); // aml_add_string_buffer(pack, "Apple LAN card");
aml_add_string(pack, "device-id"); aml_add_string(pack, "device-id");
@ -3108,8 +3107,8 @@ UINT32 FIXNetwork (UINT8 *dsdt, UINT32 len, UINT32 card)
// Could we just comment this part? (Until remember what was the purposes?) // Could we just comment this part? (Until remember what was the purposes?)
/* if (!CustProperties(pack, DEV_LAN) && /* if (!CustProperties(pack, DEV_LAN) &&
!gSettings.FakeLAN && !gSettings.Devices.FakeID.FakeLAN &&
!gSettings.NoDefaultProperties) { !gSettings.Devices.NoDefaultProperties) {
aml_add_string(pack, "empty"); aml_add_string(pack, "empty");
aml_add_byte(pack, 0); aml_add_byte(pack, 0);
} */ } */
@ -3169,14 +3168,14 @@ UINT32 FIXAirport (UINT8 *dsdt, UINT32 len)
CHAR8 NameCard[32]; CHAR8 NameCard[32];
if (!ArptADR1) return len; // no device - no patch if (!ArptADR1) return len; // no device - no patch
if ( gSettings.AirportBridgeDeviceName.notEmpty() && gSettings.AirportBridgeDeviceName.length() != 4 ) { if ( gSettings.Devices.AirportBridgeDeviceName.notEmpty() && gSettings.Devices.AirportBridgeDeviceName.length() != 4 ) {
MsgLog("AirportBridgeDeviceName must be 4 char long : ignored"); MsgLog("AirportBridgeDeviceName must be 4 char long : ignored");
gSettings.AirportBridgeDeviceName.setEmpty(); gSettings.Devices.AirportBridgeDeviceName.setEmpty();
} }
if (gSettings.FakeWIFI) { if (gSettings.Devices.FakeID.FakeWIFI) {
FakeID = gSettings.FakeWIFI >> 16; FakeID = gSettings.Devices.FakeID.FakeWIFI >> 16;
FakeVen = gSettings.FakeWIFI & 0xFFFF; FakeVen = gSettings.Devices.FakeID.FakeWIFI & 0xFFFF;
snprintf(NameCard, 32, "pci%x,%x", FakeVen, FakeID); snprintf(NameCard, 32, "pci%x,%x", FakeVen, FakeID);
} }
@ -3190,7 +3189,7 @@ UINT32 FIXAirport (UINT8 *dsdt, UINT32 len)
ArptName = FALSE; ArptName = FALSE;
for (i=0x20; len >= 10 && i < len - 10; i++) { for (i=0x20; len >= 10 && i < len - 10; i++) {
// AirPort Address // AirPort Address
if ( CmpAdr(dsdt, i, ArptADR1) || (gSettings.AirportBridgeDeviceName.notEmpty() && CmpDev(dsdt, i, gSettings.AirportBridgeDeviceName)) ) { if ( CmpAdr(dsdt, i, ArptADR1) || (gSettings.Devices.AirportBridgeDeviceName.notEmpty() && CmpDev(dsdt, i, gSettings.Devices.AirportBridgeDeviceName)) ) {
BrdADR = devFind(dsdt, i); BrdADR = devFind(dsdt, i);
if (!BrdADR) { if (!BrdADR) {
continue; continue;
@ -3275,11 +3274,11 @@ UINT32 FIXAirport (UINT8 *dsdt, UINT32 len)
} }
// add Method(_DSM,4,NotSerialized) for network // add Method(_DSM,4,NotSerialized) for network
if (gSettings.FakeWIFI || !gSettings.NoDefaultProperties) { if (gSettings.Devices.FakeID.FakeWIFI || !gSettings.Devices.NoDefaultProperties) {
met = aml_add_method(dev, "_DSM", 4); met = aml_add_method(dev, "_DSM", 4);
met2 = aml_add_store(met); met2 = aml_add_store(met);
pack = aml_add_package(met2); pack = aml_add_package(met2);
if (!gSettings.NoDefaultProperties) { if (!gSettings.Devices.NoDefaultProperties) {
aml_add_string(pack, "built-in"); aml_add_string(pack, "built-in");
aml_add_byte_buffer(pack, dataBuiltin, sizeof(dataBuiltin)); aml_add_byte_buffer(pack, dataBuiltin, sizeof(dataBuiltin));
aml_add_string(pack, "model"); aml_add_string(pack, "model");
@ -3290,7 +3289,7 @@ UINT32 FIXAirport (UINT8 *dsdt, UINT32 len)
// aml_add_string_buffer(pack, "AirPort"); // aml_add_string_buffer(pack, "AirPort");
} }
if (gSettings.FakeWIFI) { if (gSettings.Devices.FakeID.FakeWIFI) {
//aml_add_string(pack, "device-id"); //aml_add_string(pack, "device-id");
//aml_add_byte_buffer(pack, (CHAR8 *)&FakeID, 4); //aml_add_byte_buffer(pack, (CHAR8 *)&FakeID, 4);
//aml_add_string(pack, "vendor-id"); //aml_add_string(pack, "vendor-id");
@ -3301,8 +3300,8 @@ UINT32 FIXAirport (UINT8 *dsdt, UINT32 len)
aml_add_string_buffer(pack, (CHAR8 *)&NameCard[0]); aml_add_string_buffer(pack, (CHAR8 *)&NameCard[0]);
} }
if (!CustProperties(pack, DEV_WIFI) && if (!CustProperties(pack, DEV_WIFI) &&
!gSettings.NoDefaultProperties && !gSettings.Devices.NoDefaultProperties &&
!gSettings.FakeWIFI) { !gSettings.Devices.FakeID.FakeWIFI) {
aml_add_string(pack, "empty"); aml_add_string(pack, "empty");
aml_add_byte(pack, 0); aml_add_byte(pack, 0);
} }
@ -3524,9 +3523,9 @@ UINT32 AddIMEI (UINT8 *dsdt, UINT32 len)
UINT32 FakeID; UINT32 FakeID;
UINT32 FakeVen; UINT32 FakeVen;
if (gSettings.FakeIMEI) { if (gSettings.Devices.FakeID.FakeIMEI) {
FakeID = gSettings.FakeIMEI >> 16; FakeID = gSettings.Devices.FakeID.FakeIMEI >> 16;
FakeVen = gSettings.FakeIMEI & 0xFFFF; FakeVen = gSettings.Devices.FakeID.FakeIMEI & 0xFFFF;
} }
PCIADR = GetPciDevice(dsdt, len); PCIADR = GetPciDevice(dsdt, len);
@ -3565,7 +3564,7 @@ UINT32 AddIMEI (UINT8 *dsdt, UINT32 len)
aml_add_name(device, "_ADR"); aml_add_name(device, "_ADR");
aml_add_dword(device, IMEIADR1); aml_add_dword(device, IMEIADR1);
// add Method(_DSM,4,NotSerialized) // add Method(_DSM,4,NotSerialized)
if (gSettings.FakeIMEI) { if (gSettings.Devices.FakeID.FakeIMEI) {
met = aml_add_method(device, "_DSM", 4); met = aml_add_method(device, "_DSM", 4);
met2 = aml_add_store(met); met2 = aml_add_store(met);
pack = aml_add_package(met2); pack = aml_add_package(met2);
@ -3815,18 +3814,18 @@ UINT32 AddHDEF (UINT8 *dsdt, UINT32 len, const MacOsVersion& OSVersion)
} }
met2 = aml_add_store(met); met2 = aml_add_store(met);
pack = aml_add_package(met2); pack = aml_add_package(met2);
if (gSettings.UseIntelHDMI) { if (gSettings.Devices.UseIntelHDMI) {
aml_add_string(pack, "hda-gfx"); aml_add_string(pack, "hda-gfx");
aml_add_string_buffer(pack, "onboard-1"); aml_add_string_buffer(pack, "onboard-1");
} }
if (!CustProperties(pack, DEV_HDA)) { if (!CustProperties(pack, DEV_HDA)) {
if ( ( OSVersion.notEmpty() && OSVersion < AsciiOSVersionToUint64("10.8") ) || gSettings.HDALayoutId > 0 ) { if ( ( OSVersion.notEmpty() && OSVersion < AsciiOSVersionToUint64("10.8") ) || gSettings.Devices.Audio.HDALayoutId > 0 ) {
aml_add_string(pack, "layout-id"); aml_add_string(pack, "layout-id");
aml_add_byte_buffer(pack, (CHAR8*)&HDAlayoutId, 4); aml_add_byte_buffer(pack, (CHAR8*)&HDAlayoutId, 4);
} }
aml_add_string(pack, "MaximumBootBeepVolume"); aml_add_string(pack, "MaximumBootBeepVolume");
aml_add_byte_buffer(pack, (CHAR8*)&dataBuiltin1[0], 1); aml_add_byte_buffer(pack, (CHAR8*)&dataBuiltin1[0], 1);
if (gSettings.AFGLowPowerState) { if (gSettings.Devices.Audio.AFGLowPowerState) {
aml_add_string(pack, "AFGLowPowerState"); aml_add_string(pack, "AFGLowPowerState");
aml_add_byte_buffer(pack, Yes, 4); aml_add_byte_buffer(pack, Yes, 4);
} }
@ -3902,7 +3901,7 @@ UINT32 FIXUSB (UINT8 *dsdt, UINT32 len)
} else if (USBNForce) { } else if (USBNForce) {
aml_add_string_buffer(pack, "OHCI"); aml_add_string_buffer(pack, "OHCI");
} }
if (gSettings.InjectClockID) { if (gSettings.Devices.USB.InjectClockID) {
aml_add_string(pack, "AAPL,clock-id"); aml_add_string(pack, "AAPL,clock-id");
aml_add_byte_buffer(pack, dataBuiltin, 1); aml_add_byte_buffer(pack, dataBuiltin, 1);
} }
@ -3930,19 +3929,19 @@ UINT32 FIXUSB (UINT8 *dsdt, UINT32 len)
aml_add_byte_buffer(pack1, dataBuiltin, sizeof(dataBuiltin)); aml_add_byte_buffer(pack1, dataBuiltin, sizeof(dataBuiltin));
aml_add_string(pack1, "device_type"); aml_add_string(pack1, "device_type");
aml_add_string_buffer(pack1, "EHCI"); aml_add_string_buffer(pack1, "EHCI");
if (gSettings.InjectClockID) { if (gSettings.Devices.USB.InjectClockID) {
aml_add_string(pack1, "AAPL,clock-id"); aml_add_string(pack1, "AAPL,clock-id");
aml_add_byte_buffer(pack1, dataBuiltin, sizeof(dataBuiltin)); aml_add_byte_buffer(pack1, dataBuiltin, sizeof(dataBuiltin));
} }
if (USBIntel) { if (USBIntel) {
aml_add_string(pack1, "AAPL,current-available"); aml_add_string(pack1, "AAPL,current-available");
if (gSettings.HighCurrent) { if (gSettings.Devices.USB.HighCurrent) {
aml_add_word(pack1, 0x0834); aml_add_word(pack1, 0x0834);
} else { } else {
aml_add_word(pack1, 0x05DC); aml_add_word(pack1, 0x05DC);
} }
aml_add_string(pack1, "AAPL,current-extra"); aml_add_string(pack1, "AAPL,current-extra");
if (gSettings.HighCurrent) { if (gSettings.Devices.USB.HighCurrent) {
aml_add_word(pack1, 0x0C80); aml_add_word(pack1, 0x0C80);
} else { } else {
aml_add_word(pack1, 0x03E8); aml_add_word(pack1, 0x03E8);
@ -4013,7 +4012,7 @@ UINT32 FIXUSB (UINT8 *dsdt, UINT32 len)
aml_add_byte_buffer(pack1, dataBuiltin, sizeof(dataBuiltin)); aml_add_byte_buffer(pack1, dataBuiltin, sizeof(dataBuiltin));
aml_add_string(pack1, "device_type"); aml_add_string(pack1, "device_type");
aml_add_string_buffer(pack1, "XHCI"); aml_add_string_buffer(pack1, "XHCI");
if (gSettings.InjectClockID) { if (gSettings.Devices.USB.InjectClockID) {
aml_add_string(pack1, "AAPL,clock-id"); aml_add_string(pack1, "AAPL,clock-id");
aml_add_byte_buffer(pack1, dataBuiltin, sizeof(dataBuiltin)); aml_add_byte_buffer(pack1, dataBuiltin, sizeof(dataBuiltin));
} }
@ -4072,13 +4071,13 @@ UINT32 FIXUSB (UINT8 *dsdt, UINT32 len)
DBG("found USB device [%08X:%X] at %X and Name was %s ->", DBG("found USB device [%08X:%X] at %X and Name was %s ->",
USBADR[i], USBADR2[i], k, device_name[10]); USBADR[i], USBADR2[i], k, device_name[10]);
if (USB30[i]) { if (USB30[i]) {
if (gSettings.NameXH00) { if (gSettings.Devices.USB.NameXH00) {
snprintf(UsbName[i], 5, "XH%02x", XhciCount++); snprintf(UsbName[i], 5, "XH%02x", XhciCount++);
} else { } else {
snprintf(UsbName[i], 5, "XHC%01x", XhciCount++); snprintf(UsbName[i], 5, "XHC%01x", XhciCount++);
} }
} else if (USB20[i]) { } else if (USB20[i]) {
if (gSettings.NameEH00) { if (gSettings.Devices.USB.NameEH00) {
snprintf(UsbName[i], 5, "EH%02x", EhciCount++); snprintf(UsbName[i], 5, "EH%02x", EhciCount++);
} else { } else {
snprintf(UsbName[i], 5, "EHC%01x", EhciCount++); snprintf(UsbName[i], 5, "EHC%01x", EhciCount++);
@ -4137,8 +4136,8 @@ UINT32 FIXUSB (UINT8 *dsdt, UINT32 len)
} else { } else {
continue; continue;
} }
if (gSettings.FakeXHCI) { if (gSettings.Devices.FakeID.FakeXHCI) {
USBID[i] = gSettings.FakeXHCI >> 16; USBID[i] = gSettings.Devices.FakeID.FakeXHCI >> 16;
} }
CopyMem(USBDATA3+k, (void*)&USBID[i], 4); CopyMem(USBDATA3+k, (void*)&USBID[i], 4);
sizeoffset = size3; sizeoffset = size3;
@ -4425,9 +4424,9 @@ UINT32 FIXSATAAHCI (UINT8 *dsdt, UINT32 len)
UINT32 FakeID; UINT32 FakeID;
UINT32 FakeVen; UINT32 FakeVen;
if (gSettings.FakeSATA) { if (gSettings.Devices.FakeID.FakeSATA) {
FakeID = gSettings.FakeSATA >> 16; FakeID = gSettings.Devices.FakeID.FakeSATA >> 16;
FakeVen = gSettings.FakeSATA & 0xFFFF; FakeVen = gSettings.Devices.FakeID.FakeSATA & 0xFFFF;
} }
if (!SATAAHCIADR1) return len; if (!SATAAHCIADR1) return len;
@ -4465,19 +4464,19 @@ UINT32 FIXSATAAHCI (UINT8 *dsdt, UINT32 len)
root = aml_create_node(NULL); root = aml_create_node(NULL);
// add Method(_DSM,4,NotSerialized) // add Method(_DSM,4,NotSerialized)
if (gSettings.FakeSATA || !gSettings.NoDefaultProperties) { if (gSettings.Devices.FakeID.FakeSATA || !gSettings.Devices.NoDefaultProperties) {
met = aml_add_method(root, "_DSM", 4); met = aml_add_method(root, "_DSM", 4);
met2 = aml_add_store(met); met2 = aml_add_store(met);
pack = aml_add_package(met2); pack = aml_add_package(met2);
if (gSettings.FakeSATA) { if (gSettings.Devices.FakeID.FakeSATA) {
aml_add_string(pack, "device-id"); aml_add_string(pack, "device-id");
aml_add_byte_buffer(pack, (UINT8*)&FakeID, 4); aml_add_byte_buffer(pack, (UINT8*)&FakeID, 4);
aml_add_string(pack, "vendor-id"); aml_add_string(pack, "vendor-id");
aml_add_byte_buffer(pack, (UINT8*)&FakeVen, 4); aml_add_byte_buffer(pack, (UINT8*)&FakeVen, 4);
} }
if (!CustProperties(pack, DEV_SATA) && if (!CustProperties(pack, DEV_SATA) &&
!gSettings.NoDefaultProperties && !gSettings.Devices.NoDefaultProperties &&
!gSettings.FakeSATA) { !gSettings.Devices.FakeID.FakeSATA) {
aml_add_string(pack, "empty"); aml_add_string(pack, "empty");
aml_add_byte(pack, 0); aml_add_byte(pack, 0);
} }
@ -4519,9 +4518,9 @@ UINT32 FIXSATA (UINT8 *dsdt, UINT32 len)
UINT32 FakeID; UINT32 FakeID;
UINT32 FakeVen; UINT32 FakeVen;
if (gSettings.FakeSATA) { if (gSettings.Devices.FakeID.FakeSATA) {
FakeID = gSettings.FakeSATA >> 16; FakeID = gSettings.Devices.FakeID.FakeSATA >> 16;
FakeVen = gSettings.FakeSATA & 0xFFFF; FakeVen = gSettings.Devices.FakeID.FakeSATA & 0xFFFF;
} }
if (!SATAADR1) return len; if (!SATAADR1) return len;
@ -4556,19 +4555,19 @@ UINT32 FIXSATA (UINT8 *dsdt, UINT32 len)
root = aml_create_node(NULL); root = aml_create_node(NULL);
// add Method(_DSM,4,NotSerialized) // add Method(_DSM,4,NotSerialized)
if (gSettings.FakeSATA || !gSettings.NoDefaultProperties) { if (gSettings.Devices.FakeID.FakeSATA || !gSettings.Devices.NoDefaultProperties) {
met = aml_add_method(root, "_DSM", 4); met = aml_add_method(root, "_DSM", 4);
met2 = aml_add_store(met); met2 = aml_add_store(met);
pack = aml_add_package(met2); pack = aml_add_package(met2);
if (gSettings.FakeSATA) { if (gSettings.Devices.FakeID.FakeSATA) {
aml_add_string(pack, "device-id"); aml_add_string(pack, "device-id");
aml_add_byte_buffer(pack, (UINT8*)&FakeID, 4); aml_add_byte_buffer(pack, (UINT8*)&FakeID, 4);
aml_add_string(pack, "vendor-id"); aml_add_string(pack, "vendor-id");
aml_add_byte_buffer(pack, (UINT8*)&FakeVen, 4); aml_add_byte_buffer(pack, (UINT8*)&FakeVen, 4);
} }
if (!CustProperties(pack, DEV_SATA) && if (!CustProperties(pack, DEV_SATA) &&
!gSettings.NoDefaultProperties && !gSettings.Devices.NoDefaultProperties &&
!gSettings.FakeSATA) { !gSettings.Devices.FakeID.FakeSATA) {
aml_add_string(pack, "empty"); aml_add_string(pack, "empty");
aml_add_byte(pack, 0); aml_add_byte(pack, 0);
} }

View File

@ -45,7 +45,6 @@ CHAR8* gDeviceProperties = NULL;
UINT32 cPropSize = 0; UINT32 cPropSize = 0;
UINT8* cProperties = NULL; UINT8* cProperties = NULL;
XString8 cDeviceProperties;
CHAR8* BootOSName = NULL; CHAR8* BootOSName = NULL;
UINT16 KeyboardVendor = 0x05ac; //Apple inc. UINT16 KeyboardVendor = 0x05ac; //Apple inc.
@ -154,7 +153,7 @@ GetDeviceProps(IN APPLE_GETVAR_PROTOCOL *This,
IN OUT UINT32 *BufferSize) IN OUT UINT32 *BufferSize)
{ {
if(!gSettings.StringInjector && (mProperties != NULL) && (mPropSize > 1)) { if(!gSettings.Devices.StringInjector && (mProperties != NULL) && (mPropSize > 1)) {
if (*BufferSize < mPropSize) { if (*BufferSize < mPropSize) {
*BufferSize = mPropSize; *BufferSize = mPropSize;
return EFI_BUFFER_TOO_SMALL; return EFI_BUFFER_TOO_SMALL;

View File

@ -14,7 +14,6 @@ extern UINT8 *mProperties;
extern CHAR8 *gDeviceProperties; extern CHAR8 *gDeviceProperties;
extern UINT32 cPropSize; extern UINT32 cPropSize;
extern UINT8 *cProperties; extern UINT8 *cProperties;
extern XString8 cDeviceProperties;
extern CHAR8 *BootOSName; extern CHAR8 *BootOSName;
//extern OC_ABC_SETTINGS_4CLOVER gQuirks; //extern OC_ABC_SETTINGS_4CLOVER gQuirks;

View File

@ -4544,16 +4544,16 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings)
const TagDict* DevicesDict = CfgDict->dictPropertyForKey("Devices"); const TagDict* DevicesDict = CfgDict->dictPropertyForKey("Devices");
if (DevicesDict != NULL) { if (DevicesDict != NULL) {
const TagStruct* Prop = DevicesDict->propertyForKey("Inject"); const TagStruct* Prop = DevicesDict->propertyForKey("Inject");
gSettings.StringInjector = IsPropertyNotNullAndTrue(Prop); gSettings.Devices.StringInjector = IsPropertyNotNullAndTrue(Prop);
Prop = DevicesDict->propertyForKey("SetIntelBacklight"); Prop = DevicesDict->propertyForKey("SetIntelBacklight");
gSettings.IntelBacklight = IsPropertyNotNullAndTrue(Prop); gSettings.Devices.IntelBacklight = IsPropertyNotNullAndTrue(Prop);
Prop = DevicesDict->propertyForKey("SetIntelMaxBacklight"); Prop = DevicesDict->propertyForKey("SetIntelMaxBacklight");
gSettings.IntelMaxBacklight = IsPropertyNotNullAndTrue(Prop); gSettings.Devices.IntelMaxBacklight = IsPropertyNotNullAndTrue(Prop);
Prop = DevicesDict->propertyForKey("IntelMaxValue"); Prop = DevicesDict->propertyForKey("IntelMaxValue");
gSettings.IntelMaxValue = (UINT16)GetPropertyAsInteger(Prop, gSettings.IntelMaxValue); gSettings.Devices.IntelMaxValue = (UINT16)GetPropertyAsInteger(Prop, gSettings.Devices.IntelMaxValue);
/* /*
* Properties is a single string, or a dict * Properties is a single string, or a dict
@ -4562,10 +4562,10 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings)
if (Prop != NULL) { if (Prop != NULL) {
if (Prop->isString()) { if (Prop->isString()) {
cDeviceProperties = Prop->getString()->stringValue(); gSettings.Devices.Properties.cDeviceProperties = Prop->getString()->stringValue();
if ( cDeviceProperties.sizeInBytesIncludingTerminator() > MAX_UINT32-1 ) { if ( gSettings.Devices.Properties.cDeviceProperties.sizeInBytesIncludingTerminator() > MAX_UINT32-1 ) {
MsgLog("cDeviceProperties is too big"); MsgLog("gSettings.Devices.Properties.cDeviceProperties is too big");
cDeviceProperties.setEmpty(); gSettings.Devices.Properties.cDeviceProperties.setEmpty();
} }
//------- //-------
#ifdef CLOVER_BUILD #ifdef CLOVER_BUILD
@ -4573,14 +4573,14 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings)
EFI_STATUS Status = gBS->AllocatePages ( EFI_STATUS Status = gBS->AllocatePages (
AllocateMaxAddress, AllocateMaxAddress,
EfiACPIReclaimMemory, EfiACPIReclaimMemory,
EFI_SIZE_TO_PAGES (cDeviceProperties.sizeInBytes()) + 1, EFI_SIZE_TO_PAGES (gSettings.Devices.Properties.cDeviceProperties.sizeInBytes()) + 1,
&BufferPtr &BufferPtr
); );
if (!EFI_ERROR(Status)) { if (!EFI_ERROR(Status)) {
cProperties = (UINT8*)(UINTN)BufferPtr; cProperties = (UINT8*)(UINTN)BufferPtr;
//cPropSize = (UINT32)(cDeviceProperties.length() >> 1); //cPropSize = (UINT32)(gSettings.Devices.Properties.cDeviceProperties.length() >> 1);
cPropSize = (UINT32)hex2bin(cDeviceProperties, cProperties, EFI_PAGES_TO_SIZE(EFI_SIZE_TO_PAGES (cDeviceProperties.sizeInBytesIncludingTerminator()))); // cast should be safe cDeviceProperties.sizeInBytesIncludingTerminator() <= MAX_UINT32-1 cPropSize = (UINT32)hex2bin(gSettings.Devices.Properties.cDeviceProperties, cProperties, EFI_PAGES_TO_SIZE(EFI_SIZE_TO_PAGES (gSettings.Devices.Properties.cDeviceProperties.sizeInBytesIncludingTerminator()))); // cast should be safe gSettings.Devices.Properties.cDeviceProperties.sizeInBytesIncludingTerminator() <= MAX_UINT32-1
DBG("Injected EFIString of length %d\n", cPropSize); DBG("Injected EFIString of length %d\n", cPropSize);
} }
//--------- //---------
@ -4590,7 +4590,7 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings)
INTN i; INTN i;
const TagDict* PropertiesDict = Prop->getDict(); const TagDict* PropertiesDict = Prop->getDict();
INTN Count = PropertiesDict->dictKeyCount(); //ok INTN Count = PropertiesDict->dictKeyCount(); //ok
gSettings.AddProperties = new DEV_PROPERTY[Count]; //gSettings.Devices.AddProperties = new DEV_PROPERTY[Count]; // seems bug, only ArbProperties is used in this block
DEV_PROPERTY *DevPropDevice; DEV_PROPERTY *DevPropDevice;
DEV_PROPERTY *DevProps; DEV_PROPERTY *DevProps;
DEV_PROPERTY **Child; DEV_PROPERTY **Child;
@ -4620,14 +4620,14 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings)
} }
#endif #endif
//Create Device node //Create Device node
DevPropDevice = gSettings.ArbProperties; DevPropDevice = gSettings.Devices.ArbProperties;
gSettings.ArbProperties = new DEV_PROPERTY; gSettings.Devices.ArbProperties = new DEV_PROPERTY;
gSettings.ArbProperties->Next = DevPropDevice; //next device gSettings.Devices.ArbProperties->Next = DevPropDevice; //next device
gSettings.ArbProperties->Child = NULL; gSettings.Devices.ArbProperties->Child = NULL;
gSettings.ArbProperties->Device = 0; //to differ from arbitrary gSettings.Devices.ArbProperties->Device = 0; //to differ from arbitrary
gSettings.ArbProperties->DevicePath = DevicePath; //this is pointer gSettings.Devices.ArbProperties->DevicePath = DevicePath; //this is pointer
gSettings.ArbProperties->Label = S8Printf("%s", key->keyStringValue().c_str()).forgetDataWithoutFreeing(); gSettings.Devices.ArbProperties->Label = S8Printf("%s", key->keyStringValue().c_str()).forgetDataWithoutFreeing();
Child = &(gSettings.ArbProperties->Child); Child = &(gSettings.Devices.ArbProperties->Child);
if ((value != NULL) && (value->isDict())) { if ((value != NULL) && (value->isDict())) {
INTN PropCount = 0; INTN PropCount = 0;
@ -4702,13 +4702,13 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings)
} }
Prop = DevicesDict->propertyForKey("LANInjection"); Prop = DevicesDict->propertyForKey("LANInjection");
gSettings.LANInjection = !IsPropertyNotNullAndFalse(Prop); //default = TRUE gSettings.Devices.LANInjection = !IsPropertyNotNullAndFalse(Prop); //default = TRUE
Prop = DevicesDict->propertyForKey("HDMIInjection"); Prop = DevicesDict->propertyForKey("HDMIInjection");
gSettings.HDMIInjection = IsPropertyNotNullAndTrue(Prop); gSettings.Devices.HDMIInjection = IsPropertyNotNullAndTrue(Prop);
Prop = DevicesDict->propertyForKey("NoDefaultProperties"); Prop = DevicesDict->propertyForKey("NoDefaultProperties");
gSettings.NoDefaultProperties = !IsPropertyNotNullAndFalse(Prop); gSettings.Devices.NoDefaultProperties = !IsPropertyNotNullAndFalse(Prop);
const TagArray* ArbitraryArray = DevicesDict->arrayPropertyForKey("Arbitrary"); // array of dict const TagArray* ArbitraryArray = DevicesDict->arrayPropertyForKey("Arbitrary"); // array of dict
if (ArbitraryArray != NULL) { if (ArbitraryArray != NULL) {
@ -4766,59 +4766,59 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings)
for (PropIndex = 0; PropIndex < PropCount; PropIndex++) { for (PropIndex = 0; PropIndex < PropCount; PropIndex++) {
Dict3 = CustomPropertiesArray->dictElementAt(PropIndex, "CustomProperties"_XS8); Dict3 = CustomPropertiesArray->dictElementAt(PropIndex, "CustomProperties"_XS8);
DevProp = gSettings.ArbProperties; DevProp = gSettings.Devices.ArbProperties;
gSettings.ArbProperties = new DEV_PROPERTY; gSettings.Devices.ArbProperties = new DEV_PROPERTY;
gSettings.ArbProperties->Next = DevProp; gSettings.Devices.ArbProperties->Next = DevProp;
gSettings.ArbProperties->Device = (UINT32)DeviceAddr; gSettings.Devices.ArbProperties->Device = (UINT32)DeviceAddr;
gSettings.ArbProperties->Label = (__typeof__(gSettings.ArbProperties->Label))AllocateCopyPool(Label.sizeInBytesIncludingTerminator(), Label.c_str()); gSettings.Devices.ArbProperties->Label = (__typeof__(gSettings.Devices.ArbProperties->Label))AllocateCopyPool(Label.sizeInBytesIncludingTerminator(), Label.c_str());
const TagStruct* DisabledProp = Dict3->propertyForKey("Disabled"); const TagStruct* DisabledProp = Dict3->propertyForKey("Disabled");
gSettings.ArbProperties->MenuItem.BValue = !IsPropertyNotNullAndTrue(DisabledProp); gSettings.Devices.ArbProperties->MenuItem.BValue = !IsPropertyNotNullAndTrue(DisabledProp);
DisabledProp = Dict3->propertyForKey("Key"); DisabledProp = Dict3->propertyForKey("Key");
if (DisabledProp && (DisabledProp->isString()) && DisabledProp->getString()->stringValue().notEmpty()) { if (DisabledProp && (DisabledProp->isString()) && DisabledProp->getString()->stringValue().notEmpty()) {
gSettings.ArbProperties->Key = S8Printf("%s", DisabledProp->getString()->stringValue().c_str()).forgetDataWithoutFreeing(); gSettings.Devices.ArbProperties->Key = S8Printf("%s", DisabledProp->getString()->stringValue().c_str()).forgetDataWithoutFreeing();
} }
DisabledProp = Dict3->propertyForKey("Value"); DisabledProp = Dict3->propertyForKey("Value");
if (DisabledProp && (DisabledProp->isString()) && DisabledProp->getString()->stringValue().notEmpty()) { if (DisabledProp && (DisabledProp->isString()) && DisabledProp->getString()->stringValue().notEmpty()) {
//first suppose it is Ascii string //first suppose it is Ascii string
gSettings.ArbProperties->Value = (UINT8*)S8Printf("%s", DisabledProp->getString()->stringValue().c_str()).forgetDataWithoutFreeing(); gSettings.Devices.ArbProperties->Value = (UINT8*)S8Printf("%s", DisabledProp->getString()->stringValue().c_str()).forgetDataWithoutFreeing();
gSettings.ArbProperties->ValueLen = DisabledProp->getString()->stringValue().sizeInBytesIncludingTerminator(); gSettings.Devices.ArbProperties->ValueLen = DisabledProp->getString()->stringValue().sizeInBytesIncludingTerminator();
gSettings.ArbProperties->ValueType = kTagTypeString; gSettings.Devices.ArbProperties->ValueType = kTagTypeString;
} else if (DisabledProp && (DisabledProp->isInt64())) { } else if (DisabledProp && (DisabledProp->isInt64())) {
if ( DisabledProp->getInt64()->intValue() < MIN_INT32 || DisabledProp->getInt64()->intValue() > MAX_INT32 ) { if ( DisabledProp->getInt64()->intValue() < MIN_INT32 || DisabledProp->getInt64()->intValue() > MAX_INT32 ) {
MsgLog("Invalid int value for key 'Value'\n"); MsgLog("Invalid int value for key 'Value'\n");
}else{ }else{
INT32 intValue = (INT32)DisabledProp->getInt64()->intValue(); INT32 intValue = (INT32)DisabledProp->getInt64()->intValue();
gSettings.ArbProperties->Value = (__typeof__(gSettings.ArbProperties->Value))AllocatePool(sizeof(intValue)); gSettings.Devices.ArbProperties->Value = (__typeof__(gSettings.Devices.ArbProperties->Value))AllocatePool(sizeof(intValue));
// CopyMem(settingsData.ArbProperties->Value, &Prop3->intValue, 4); // CopyMem(settingsData.ArbProperties->Value, &Prop3->intValue, 4);
*(INT32*)(gSettings.ArbProperties->Value) = intValue; *(INT32*)(gSettings.Devices.ArbProperties->Value) = intValue;
gSettings.ArbProperties->ValueLen = sizeof(intValue); gSettings.Devices.ArbProperties->ValueLen = sizeof(intValue);
gSettings.ArbProperties->ValueType = kTagTypeInteger; gSettings.Devices.ArbProperties->ValueType = kTagTypeInteger;
} }
} else if ( DisabledProp && DisabledProp->isTrue() ) { } else if ( DisabledProp && DisabledProp->isTrue() ) {
gSettings.ArbProperties->Value = (__typeof__(gSettings.ArbProperties->Value))AllocateZeroPool(4); gSettings.Devices.ArbProperties->Value = (__typeof__(gSettings.Devices.ArbProperties->Value))AllocateZeroPool(4);
gSettings.ArbProperties->Value[0] = TRUE; gSettings.Devices.ArbProperties->Value[0] = TRUE;
gSettings.ArbProperties->ValueLen = 1; gSettings.Devices.ArbProperties->ValueLen = 1;
gSettings.ArbProperties->ValueType = kTagTypeTrue; gSettings.Devices.ArbProperties->ValueType = kTagTypeTrue;
} else if ( DisabledProp && DisabledProp->isFalse() ) { } else if ( DisabledProp && DisabledProp->isFalse() ) {
gSettings.ArbProperties->Value = (__typeof__(gSettings.ArbProperties->Value))AllocateZeroPool(4); gSettings.Devices.ArbProperties->Value = (__typeof__(gSettings.Devices.ArbProperties->Value))AllocateZeroPool(4);
//settingsData.ArbProperties->Value[0] = FALSE; //settingsData.ArbProperties->Value[0] = FALSE;
gSettings.ArbProperties->ValueLen = 1; gSettings.Devices.ArbProperties->ValueLen = 1;
gSettings.ArbProperties->ValueType = kTagTypeFalse; gSettings.Devices.ArbProperties->ValueType = kTagTypeFalse;
} else { } else {
//else data //else data
UINTN Size = 0; UINTN Size = 0;
gSettings.ArbProperties->Value = GetDataSetting (Dict3, "Value", &Size); gSettings.Devices.ArbProperties->Value = GetDataSetting (Dict3, "Value", &Size);
gSettings.ArbProperties->ValueLen = Size; gSettings.Devices.ArbProperties->ValueLen = Size;
gSettings.ArbProperties->ValueType = kTagTypeData; gSettings.Devices.ArbProperties->ValueType = kTagTypeData;
} }
//Special case. In future there must be more such cases //Special case. In future there must be more such cases
if ((AsciiStrStr(gSettings.ArbProperties->Key, "-platform-id") != NULL)) { if ((AsciiStrStr(gSettings.Devices.ArbProperties->Key, "-platform-id") != NULL)) {
CopyMem((CHAR8*)&gSettings.Graphics.IgPlatform, gSettings.ArbProperties->Value, 4); CopyMem((CHAR8*)&gSettings.Graphics.IgPlatform, gSettings.Devices.ArbProperties->Value, 4);
} }
} //for() device properties } //for() device properties
} }
@ -4835,16 +4835,16 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings)
//count = 0x1F1E1D1C1B1A1918 //count = 0x1F1E1D1C1B1A1918
if (Count > 0) { if (Count > 0) {
DBG("Add %lld properties:\n", Count); DBG("Add %lld properties:\n", Count);
gSettings.AddProperties = new DEV_PROPERTY[Count]; gSettings.Devices.AddProperties.setEmpty();
for (i = 0; i < Count; i++) { for (i = 0; i < Count; i++) {
UINTN Size = 0; UINTN Size = 0;
DBG(" - [%02lld]:", i); DBG(" - [%02lld]:", i);
const TagDict* Dict2 = AddPropertiesArray->dictElementAt(i, "AddProperties"_XS8); const TagDict* Dict2 = AddPropertiesArray->dictElementAt(i, "AddProperties"_XS8);
const TagStruct* DeviceProp = Dict2->propertyForKey("Device"); const TagStruct* DeviceProp = Dict2->propertyForKey("Device");
if (DeviceProp && (DeviceProp->isString()) && DeviceProp->getString()->stringValue().notEmpty()) { DEV_ADDPROPERTY *Property = new DEV_ADDPROPERTY();
DEV_PROPERTY *Property = &gSettings.AddProperties[Index];
if (DeviceProp && (DeviceProp->isString()) && DeviceProp->getString()->stringValue().notEmpty()) {
if (DeviceProp->getString()->stringValue().equalIC("ATI")) { if (DeviceProp->getString()->stringValue().equalIC("ATI")) {
Property->Device = (UINT32)DEV_ATI; Property->Device = (UINT32)DEV_ATI;
} else if (DeviceProp->getString()->stringValue().equalIC("NVidia")) { } else if (DeviceProp->getString()->stringValue().equalIC("NVidia")) {
@ -4880,44 +4880,45 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings)
if ( DeviceProp->isString() ) DBG(" %s ", DeviceProp->getString()->stringValue().c_str()); if ( DeviceProp->isString() ) DBG(" %s ", DeviceProp->getString()->stringValue().c_str());
const TagStruct* Prop2 = Dict2->propertyForKey("Disabled"); const TagStruct* Prop2 = Dict2->propertyForKey("Disabled");
gSettings.AddProperties[Index].MenuItem.BValue = !IsPropertyNotNullAndTrue(Prop2); Property->MenuItem.BValue = !IsPropertyNotNullAndTrue(Prop2);
Prop2 = Dict2->propertyForKey("Key"); Prop2 = Dict2->propertyForKey("Key");
if (Prop2 && (Prop2->isString()) && Prop2->getString()->stringValue().notEmpty()) { if (Prop2 && (Prop2->isString()) && Prop2->getString()->stringValue().notEmpty()) {
gSettings.AddProperties[Index].Key = S8Printf("%s", Prop2->getString()->stringValue().c_str()).forgetDataWithoutFreeing(); Property->Key = Prop2->getString()->stringValue();
} }
Prop2 = Dict2->propertyForKey("Value"); Prop2 = Dict2->propertyForKey("Value");
if (Prop2 && (Prop2->isString()) && Prop2->getString()->stringValue().notEmpty()) { if (Prop2 && (Prop2->isString()) && Prop2->getString()->stringValue().notEmpty()) {
//first suppose it is Ascii string //first suppose it is Ascii string
gSettings.AddProperties[Index].Value = (UINT8*)S8Printf("%s", Prop2->getString()->stringValue().c_str()).forgetDataWithoutFreeing(); Property->Value.ncpy(Prop2->getString()->stringValue().c_str(), Prop2->getString()->stringValue().sizeInBytesIncludingTerminator());
gSettings.AddProperties[Index].ValueLen = Prop2->getString()->stringValue().sizeInBytesIncludingTerminator();
} else if (Prop2 && (Prop2->isInt64())) { } else if (Prop2 && (Prop2->isInt64())) {
if ( Prop2->getInt64()->intValue() < MIN_INT32 || Prop2->getInt64()->intValue() > MAX_INT32 ) { if ( Prop2->getInt64()->intValue() < MIN_INT32 || Prop2->getInt64()->intValue() > MAX_INT32 ) {
MsgLog("Invalid int value for key 'Value'\n"); MsgLog("Invalid int value for key 'Value'\n");
}else{ }else{
INT32 intValue = (INT32)Prop2->getInt64()->intValue(); INT32 intValue = (INT32)Prop2->getInt64()->intValue();
gSettings.AddProperties[Index].Value = (__typeof__(gSettings.AddProperties[Index].Value))AllocatePool (sizeof(intValue)); Property->Value.cat(intValue);
// CopyMem(settingsData.AddProperties[Index].Value, &Prop2->intValue, 4); // Property->Value = (__typeof__(Property->Value))AllocatePool (sizeof(intValue));
*(INT32*)(gSettings.AddProperties[Index].Value) = intValue; // // CopyMem(settingsData.AddProperties[Index].Value, &Prop2->intValue, 4);
gSettings.AddProperties[Index].ValueLen = sizeof(intValue); // *(INT32*)(Property->Value) = intValue;
// Property->ValueLen = sizeof(intValue);
} }
} else { } else {
//else data //else data
gSettings.AddProperties[Index].Value = GetDataSetting (Dict2, "Value", &Size); uint8_t* Data = GetDataSetting (Dict2, "Value", &Size);
gSettings.AddProperties[Index].ValueLen = Size; Property->Value.stealValueFrom(Data, Size);
} }
DBG("Key: %s, len: %llu\n", gSettings.AddProperties[Index].Key, gSettings.AddProperties[Index].ValueLen); DBG("Key: %s, len: %zu\n", Property->Key.c_str(), Property->Value.size());
if (!gSettings.AddProperties[Index].MenuItem.BValue) { if (!Property->MenuItem.BValue) {
DBG(" property disabled at config\n"); DBG(" property disabled at config\n");
} }
gSettings.Devices.AddProperties.AddReference(Property, true);
++Index; ++Index;
} }
gSettings.NrAddProperties = Index; // gSettings.Devices.AddProperties.size() = Index;
} }
} }
//end AddProperties //end AddProperties
@ -4926,54 +4927,54 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings)
if (FakeIDDict != NULL) { if (FakeIDDict != NULL) {
const TagStruct* Prop2 = FakeIDDict->propertyForKey("ATI"); const TagStruct* Prop2 = FakeIDDict->propertyForKey("ATI");
if (Prop2 && (Prop2->isString())) { if (Prop2 && (Prop2->isString())) {
gSettings.FakeATI = (UINT32)AsciiStrHexToUint64(Prop2->getString()->stringValue()); gSettings.Devices.FakeID.FakeATI = (UINT32)AsciiStrHexToUint64(Prop2->getString()->stringValue());
} }
Prop2 = FakeIDDict->propertyForKey("NVidia"); Prop2 = FakeIDDict->propertyForKey("NVidia");
if (Prop2 && (Prop2->isString())) { if (Prop2 && (Prop2->isString())) {
gSettings.FakeNVidia = (UINT32)AsciiStrHexToUint64(Prop2->getString()->stringValue()); gSettings.Devices.FakeID.FakeNVidia = (UINT32)AsciiStrHexToUint64(Prop2->getString()->stringValue());
} }
Prop2 = FakeIDDict->propertyForKey("IntelGFX"); Prop2 = FakeIDDict->propertyForKey("IntelGFX");
if (Prop2 && (Prop2->isString())) { if (Prop2 && (Prop2->isString())) {
gSettings.FakeIntel = (UINT32)AsciiStrHexToUint64(Prop2->getString()->stringValue()); gSettings.Devices.FakeID.FakeIntel = (UINT32)AsciiStrHexToUint64(Prop2->getString()->stringValue());
} }
Prop2 = FakeIDDict->propertyForKey("LAN"); Prop2 = FakeIDDict->propertyForKey("LAN");
if (Prop2 && (Prop2->isString())) { if (Prop2 && (Prop2->isString())) {
gSettings.FakeLAN = (UINT32)AsciiStrHexToUint64(Prop2->getString()->stringValue()); gSettings.Devices.FakeID.FakeLAN = (UINT32)AsciiStrHexToUint64(Prop2->getString()->stringValue());
} }
Prop2 = FakeIDDict->propertyForKey("WIFI"); Prop2 = FakeIDDict->propertyForKey("WIFI");
if (Prop2 && (Prop2->isString())) { if (Prop2 && (Prop2->isString())) {
gSettings.FakeWIFI = (UINT32)AsciiStrHexToUint64(Prop2->getString()->stringValue()); gSettings.Devices.FakeID.FakeWIFI = (UINT32)AsciiStrHexToUint64(Prop2->getString()->stringValue());
} }
Prop2 = FakeIDDict->propertyForKey("SATA"); Prop2 = FakeIDDict->propertyForKey("SATA");
if (Prop2 && (Prop2->isString())) { if (Prop2 && (Prop2->isString())) {
gSettings.FakeSATA = (UINT32)AsciiStrHexToUint64(Prop2->getString()->stringValue()); gSettings.Devices.FakeID.FakeSATA = (UINT32)AsciiStrHexToUint64(Prop2->getString()->stringValue());
} }
Prop2 = FakeIDDict->propertyForKey("XHCI"); Prop2 = FakeIDDict->propertyForKey("XHCI");
if (Prop2 && (Prop2->isString())) { if (Prop2 && (Prop2->isString())) {
gSettings.FakeXHCI = (UINT32)AsciiStrHexToUint64(Prop2->getString()->stringValue()); gSettings.Devices.FakeID.FakeXHCI = (UINT32)AsciiStrHexToUint64(Prop2->getString()->stringValue());
} }
Prop2 = FakeIDDict->propertyForKey("IMEI"); Prop2 = FakeIDDict->propertyForKey("IMEI");
if (Prop2 && (Prop2->isString())) { if (Prop2 && (Prop2->isString())) {
gSettings.FakeIMEI = (UINT32)AsciiStrHexToUint64(Prop2->getString()->stringValue()); gSettings.Devices.FakeID.FakeIMEI = (UINT32)AsciiStrHexToUint64(Prop2->getString()->stringValue());
} }
} }
Prop = DevicesDict->propertyForKey("UseIntelHDMI"); Prop = DevicesDict->propertyForKey("UseIntelHDMI");
gSettings.UseIntelHDMI = IsPropertyNotNullAndTrue(Prop); gSettings.Devices.UseIntelHDMI = IsPropertyNotNullAndTrue(Prop);
Prop = DevicesDict->propertyForKey("ForceHPET"); Prop = DevicesDict->propertyForKey("ForceHPET");
gSettings.ForceHPET = IsPropertyNotNullAndTrue(Prop); gSettings.Devices.ForceHPET = IsPropertyNotNullAndTrue(Prop);
Prop = DevicesDict->propertyForKey("DisableFunctions"); Prop = DevicesDict->propertyForKey("DisableFunctions");
if (Prop && (Prop->isString())) { if (Prop && (Prop->isString())) {
gSettings.DisableFunctions = (UINT32)AsciiStrHexToUint64(Prop->getString()->stringValue()); gSettings.Devices.DisableFunctions = (UINT32)AsciiStrHexToUint64(Prop->getString()->stringValue());
} }
Prop = DevicesDict->propertyForKey("AirportBridgeDeviceName"); Prop = DevicesDict->propertyForKey("AirportBridgeDeviceName");
@ -4981,7 +4982,7 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings)
if ( Prop->getString()->stringValue().length() != 4 ) { if ( Prop->getString()->stringValue().length() != 4 ) {
MsgLog("ERROR IN PLIST : AirportBridgeDeviceName must 4 chars long"); MsgLog("ERROR IN PLIST : AirportBridgeDeviceName must 4 chars long");
}else{ }else{
gSettings.AirportBridgeDeviceName = Prop->getString()->stringValue(); gSettings.Devices.AirportBridgeDeviceName = Prop->getString()->stringValue();
} }
} }
@ -5002,52 +5003,52 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings)
// if hex device is cannot be converted to decimal, injects legacy value 12 decimal // if hex device is cannot be converted to decimal, injects legacy value 12 decimal
// - all other values are equal to HDAInjection=Detect // - all other values are equal to HDAInjection=Detect
if (Prop->isInt64()) { if (Prop->isInt64()) {
gSettings.HDALayoutId = (INT32)Prop->getInt64()->intValue(); //must be signed gSettings.Devices.Audio.HDALayoutId = (INT32)Prop->getInt64()->intValue(); //must be signed
gSettings.HDAInjection = (gSettings.HDALayoutId > 0); gSettings.Devices.Audio.HDAInjection = (gSettings.Devices.Audio.HDALayoutId > 0);
} else if (Prop->isString()){ } else if (Prop->isString()){
if ( Prop->getString()->stringValue().notEmpty() && (Prop->getString()->stringValue()[0] == 'n' || Prop->getString()->stringValue()[0] == 'N') ) { if ( Prop->getString()->stringValue().notEmpty() && (Prop->getString()->stringValue()[0] == 'n' || Prop->getString()->stringValue()[0] == 'N') ) {
// if starts with n or N, then no HDA injection // if starts with n or N, then no HDA injection
gSettings.HDAInjection = FALSE; gSettings.Devices.Audio.HDAInjection = FALSE;
} else if ( Prop->getString()->stringValue().length() > 1 && } else if ( Prop->getString()->stringValue().length() > 1 &&
Prop->getString()->stringValue()[0] == '0' && Prop->getString()->stringValue()[0] == '0' &&
( Prop->getString()->stringValue()[1] == 'x' || Prop->getString()->stringValue()[1] == 'X' ) ) { ( Prop->getString()->stringValue()[1] == 'x' || Prop->getString()->stringValue()[1] == 'X' ) ) {
// assume it's a hex layout id // assume it's a hex layout id
gSettings.HDALayoutId = (INT32)AsciiStrHexToUintn(Prop->getString()->stringValue()); gSettings.Devices.Audio.HDALayoutId = (INT32)AsciiStrHexToUintn(Prop->getString()->stringValue());
gSettings.HDAInjection = TRUE; gSettings.Devices.Audio.HDAInjection = TRUE;
} else { } else {
// assume it's a decimal layout id // assume it's a decimal layout id
gSettings.HDALayoutId = (INT32)AsciiStrDecimalToUintn(Prop->getString()->stringValue()); gSettings.Devices.Audio.HDALayoutId = (INT32)AsciiStrDecimalToUintn(Prop->getString()->stringValue());
gSettings.HDAInjection = TRUE; gSettings.Devices.Audio.HDAInjection = TRUE;
} }
} }
} }
Prop = AudioDict->propertyForKey("AFGLowPowerState"); Prop = AudioDict->propertyForKey("AFGLowPowerState");
gSettings.AFGLowPowerState = IsPropertyNotNullAndTrue(Prop); gSettings.Devices.Audio.AFGLowPowerState = IsPropertyNotNullAndTrue(Prop);
} }
const TagDict* USBDict = DevicesDict->dictPropertyForKey("USB"); const TagDict* USBDict = DevicesDict->dictPropertyForKey("USB");
if (USBDict != NULL) { if (USBDict != NULL) {
// USB // USB
Prop = USBDict->propertyForKey("Inject"); Prop = USBDict->propertyForKey("Inject");
gSettings.USBInjection = !IsPropertyNotNullAndFalse(Prop); // enabled by default gSettings.Devices.USB.USBInjection = !IsPropertyNotNullAndFalse(Prop); // enabled by default
Prop = USBDict->propertyForKey("AddClockID"); Prop = USBDict->propertyForKey("AddClockID");
gSettings.InjectClockID = IsPropertyNotNullAndTrue(Prop); // disabled by default gSettings.Devices.USB.InjectClockID = IsPropertyNotNullAndTrue(Prop); // disabled by default
// enabled by default for CloverEFI // enabled by default for CloverEFI
// disabled for others // disabled for others
gSettings.USBFixOwnership = gFirmwareClover; gSettings.Devices.USB.USBFixOwnership = gFirmwareClover;
Prop = USBDict->propertyForKey("FixOwnership"); Prop = USBDict->propertyForKey("FixOwnership");
if (Prop != NULL) { if (Prop != NULL) {
gSettings.USBFixOwnership = IsPropertyNotNullAndTrue(Prop); gSettings.Devices.USB.USBFixOwnership = IsPropertyNotNullAndTrue(Prop);
} }
DBG("USB FixOwnership: %s\n", gSettings.USBFixOwnership?"yes":"no"); DBG("USB FixOwnership: %s\n", gSettings.Devices.USB.USBFixOwnership?"yes":"no");
Prop = USBDict->propertyForKey("HighCurrent"); Prop = USBDict->propertyForKey("HighCurrent");
gSettings.HighCurrent = IsPropertyNotNullAndTrue(Prop); gSettings.Devices.USB.HighCurrent = IsPropertyNotNullAndTrue(Prop);
Prop = USBDict->propertyForKey("NameEH00"); Prop = USBDict->propertyForKey("NameEH00");
gSettings.NameEH00 = IsPropertyNotNullAndTrue(Prop); gSettings.Devices.USB.NameEH00 = IsPropertyNotNullAndTrue(Prop);
} }
} }
@ -6627,7 +6628,7 @@ SetDevices (LOADER_ENTRY *Entry)
GetEdidDiscovered (); GetEdidDiscovered ();
//First make string from Device->Properties //First make string from Device->Properties
Prop = gSettings.ArbProperties; Prop = gSettings.Devices.ArbProperties;
device = NULL; device = NULL;
if (!device_inject_string) { if (!device_inject_string) {
device_inject_string = devprop_create_string(); device_inject_string = devprop_create_string();
@ -6698,9 +6699,9 @@ SetDevices (LOADER_ENTRY *Entry)
PCIdevice.subsys_id.subsys.device_id = Pci.Device.SubsystemID; PCIdevice.subsys_id.subsys.device_id = Pci.Device.SubsystemID;
PCIdevice.used = FALSE; PCIdevice.used = FALSE;
//if (gSettings.NrAddProperties == 0xFFFE) { //yyyy it means Arbitrary //if (gSettings.Devices.AddProperties.size() == 0xFFFE) { //yyyy it means Arbitrary // Looks like NrAddProperties == 0xFFFE is not used anymore
//------------------ //------------------
Prop = gSettings.ArbProperties; //check for additional properties Prop = gSettings.Devices.ArbProperties; //check for additional properties
device = NULL; device = NULL;
/* if (!string) { /* if (!string) {
string = devprop_create_string(); string = devprop_create_string();
@ -6785,7 +6786,7 @@ SetDevices (LOADER_ENTRY *Entry)
} }
// IntelBacklight reworked by Sherlocks. 2018.10.07 // IntelBacklight reworked by Sherlocks. 2018.10.07
if (gSettings.IntelBacklight || gSettings.IntelMaxBacklight) { if (gSettings.Devices.IntelBacklight || gSettings.Devices.IntelMaxBacklight) {
UINT32 LEV2 = 0, LEVL = 0, P0BL = 0, GRAN = 0; UINT32 LEV2 = 0, LEVL = 0, P0BL = 0, GRAN = 0;
UINT32 LEVW = 0, LEVX = 0, LEVD = 0, PCHL = 0; UINT32 LEVW = 0, LEVX = 0, LEVD = 0, PCHL = 0;
UINT32 ShiftLEVX = 0, FBLEVX = 0; UINT32 ShiftLEVX = 0, FBLEVX = 0;
@ -7149,7 +7150,7 @@ SetDevices (LOADER_ENTRY *Entry)
break; break;
default: default:
if (gSettings.IntelBacklight) { if (gSettings.Devices.IntelBacklight) {
MsgLog (" Write macOS LEVW: 0x%X\n", MACLEVW); MsgLog (" Write macOS LEVW: 0x%X\n", MACLEVW);
/*Status = */PciIo->Mem.Write( /*Status = */PciIo->Mem.Write(
@ -7181,7 +7182,7 @@ SetDevices (LOADER_ENTRY *Entry)
case 0x0166: // "Intel HD Graphics 4000" case 0x0166: // "Intel HD Graphics 4000"
case 0x016A: // "Intel HD Graphics P4000" case 0x016A: // "Intel HD Graphics P4000"
// Write LEVL/LEVX // Write LEVL/LEVX
if (gSettings.IntelMaxBacklight) { if (gSettings.Devices.IntelMaxBacklight) {
if (!LEVL) { if (!LEVL) {
LEVL = FBLEVX; LEVL = FBLEVX;
MsgLog (" Found invalid LEVL, set LEVL: 0x%X\n", LEVL); MsgLog (" Found invalid LEVL, set LEVL: 0x%X\n", LEVL);
@ -7192,8 +7193,8 @@ SetDevices (LOADER_ENTRY *Entry)
MsgLog (" Found invalid LEVX, set LEVX: 0x%X\n", ShiftLEVX); MsgLog (" Found invalid LEVX, set LEVX: 0x%X\n", ShiftLEVX);
} }
if (gSettings.IntelMaxValue) { if (gSettings.Devices.IntelMaxValue) {
FBLEVX = gSettings.IntelMaxValue; FBLEVX = gSettings.Devices.IntelMaxValue;
MsgLog (" Read IntelMaxValue: 0x%X\n", FBLEVX); MsgLog (" Read IntelMaxValue: 0x%X\n", FBLEVX);
} else { } else {
MsgLog (" Read default Framebuffer LEVX: 0x%X\n", FBLEVX); MsgLog (" Read default Framebuffer LEVX: 0x%X\n", FBLEVX);
@ -7236,9 +7237,9 @@ SetDevices (LOADER_ENTRY *Entry)
case 0x9B41: // "Intel UHD Graphics 620" case 0x9B41: // "Intel UHD Graphics 620"
case 0x9BCA: // "Intel UHD Graphics 620" case 0x9BCA: // "Intel UHD Graphics 620"
// Write LEVD // Write LEVD
if (gSettings.IntelMaxBacklight) { if (gSettings.Devices.IntelMaxBacklight) {
if (gSettings.IntelMaxValue) { if (gSettings.Devices.IntelMaxValue) {
FBLEVX = gSettings.IntelMaxValue; FBLEVX = gSettings.Devices.IntelMaxValue;
MsgLog (" Read IntelMaxValue: 0x%X\n", FBLEVX); MsgLog (" Read IntelMaxValue: 0x%X\n", FBLEVX);
} else { } else {
MsgLog (" Read default Framebuffer LEVX: 0x%X\n", FBLEVX); MsgLog (" Read default Framebuffer LEVX: 0x%X\n", FBLEVX);
@ -7260,9 +7261,9 @@ SetDevices (LOADER_ENTRY *Entry)
default: default:
// Write LEVX // Write LEVX
if (gSettings.IntelMaxBacklight) { if (gSettings.Devices.IntelMaxBacklight) {
if (gSettings.IntelMaxValue) { if (gSettings.Devices.IntelMaxValue) {
FBLEVX = gSettings.IntelMaxValue; FBLEVX = gSettings.Devices.IntelMaxValue;
MsgLog (" Read IntelMaxValue: 0x%X\n", FBLEVX); MsgLog (" Read IntelMaxValue: 0x%X\n", FBLEVX);
LEVX = FBLEVX | FBLEVX << 16; LEVX = FBLEVX | FBLEVX << 16;
} else if (!LEVX) { } else if (!LEVX) {
@ -7287,7 +7288,7 @@ SetDevices (LOADER_ENTRY *Entry)
break; break;
} }
if (gSettings.FakeIntel == 0x00008086) { if (gSettings.Devices.FakeID.FakeIntel == 0x00008086) {
UINT32 IntelDisable = 0x03; UINT32 IntelDisable = 0x03;
PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x50, 1, &IntelDisable); PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x50, 1, &IntelDisable);
} }
@ -7319,7 +7320,7 @@ SetDevices (LOADER_ENTRY *Entry)
//USB //USB
else if ((Pci.Hdr.ClassCode[2] == PCI_CLASS_SERIAL) && else if ((Pci.Hdr.ClassCode[2] == PCI_CLASS_SERIAL) &&
(Pci.Hdr.ClassCode[1] == PCI_CLASS_SERIAL_USB)) { (Pci.Hdr.ClassCode[1] == PCI_CLASS_SERIAL_USB)) {
if (gSettings.USBInjection) { if (gSettings.Devices.USB.USBInjection) {
TmpDirty = set_usb_props (&PCIdevice); TmpDirty = set_usb_props (&PCIdevice);
StringDirty |= TmpDirty; StringDirty |= TmpDirty;
} }
@ -7330,7 +7331,7 @@ SetDevices (LOADER_ENTRY *Entry)
((Pci.Hdr.ClassCode[1] == PCI_CLASS_MEDIA_HDA) || ((Pci.Hdr.ClassCode[1] == PCI_CLASS_MEDIA_HDA) ||
(Pci.Hdr.ClassCode[1] == PCI_CLASS_MEDIA_AUDIO))) { (Pci.Hdr.ClassCode[1] == PCI_CLASS_MEDIA_AUDIO))) {
// HDMI injection inside // HDMI injection inside
if (gSettings.HDAInjection ) { if (gSettings.Devices.Audio.HDAInjection ) {
TmpDirty = setup_hda_devprop (PciIo, &PCIdevice, Entry->macOSVersion); TmpDirty = setup_hda_devprop (PciIo, &PCIdevice, Entry->macOSVersion);
StringDirty |= TmpDirty; StringDirty |= TmpDirty;
} }
@ -7412,7 +7413,7 @@ SetDevices (LOADER_ENTRY *Entry)
} }
Rcba &= 0xFFFFC000; Rcba &= 0xFFFFC000;
if (gSettings.ForceHPET) { if (gSettings.Devices.ForceHPET) {
Hptc = REG32 ((UINTN)Rcba, 0x3404); Hptc = REG32 ((UINTN)Rcba, 0x3404);
if ((Hptc & 0x80) != 0) { if ((Hptc & 0x80) != 0) {
DBG("HPET is already enabled\n"); DBG("HPET is already enabled\n");
@ -7429,10 +7430,10 @@ SetDevices (LOADER_ENTRY *Entry)
} }
} }
if (gSettings.DisableFunctions){ if (gSettings.Devices.DisableFunctions){
UINT32 FD = REG32 ((UINTN)Rcba, 0x3418); UINT32 FD = REG32 ((UINTN)Rcba, 0x3418);
DBG("Initial value of FD register 0x%X\n", FD); DBG("Initial value of FD register 0x%X\n", FD);
FD |= gSettings.DisableFunctions; FD |= gSettings.Devices.DisableFunctions;
REG32 ((UINTN)Rcba, 0x3418) = FD; REG32 ((UINTN)Rcba, 0x3418) = FD;
FD = REG32 ((UINTN)Rcba, 0x3418); FD = REG32 ((UINTN)Rcba, 0x3418);
DBG(" recheck value after patch 0x%X\n", FD); DBG(" recheck value after patch 0x%X\n", FD);
@ -7460,27 +7461,27 @@ SetDevices (LOADER_ENTRY *Entry)
); );
if (!EFI_ERROR(Status)) { if (!EFI_ERROR(Status)) {
mProperties = (UINT8*)(UINTN)BufferPtr; // mProperties = (UINT8*)(UINTN)BufferPtr;
gDeviceProperties = devprop_generate_string (device_inject_string); // gDeviceProperties = devprop_generate_string (device_inject_string);
gDeviceProperties[device_inject_stringlength] = 0; // gDeviceProperties[device_inject_stringlength] = 0;
// DBG(gDeviceProperties); // // DBG(gDeviceProperties);
// DBG("\n"); // // DBG("\n");
// StringDirty = FALSE; // // StringDirty = FALSE;
//------- // //-------
//mPropSize = (UINT32)AsciiStrLen(gDeviceProperties) / 2; // //mPropSize = (UINT32)AsciiStrLen(gDeviceProperties) / 2;
// DBG("Preliminary size of mProperties=%d\n", mPropSize); // // DBG("Preliminary size of mProperties=%d\n", mPropSize);
mPropSize = (UINT32)hex2bin (gDeviceProperties, AsciiStrLen(gDeviceProperties), mProperties, EFI_PAGES_TO_SIZE(nbPages)); // cast should be safe as device_inject_string->length <= MAX_UINT32/2-1 // mPropSize = (UINT32)hex2bin (gDeviceProperties, AsciiStrLen(gDeviceProperties), mProperties, EFI_PAGES_TO_SIZE(nbPages)); // cast should be safe as device_inject_string->length <= MAX_UINT32/2-1
// DBG("Final size of mProperties=%d\n", mPropSize); // // DBG("Final size of mProperties=%d\n", mPropSize);
//--------- // //---------
// Status = egSaveFile(&self.getSelfRootDir(), SWPrintf("%ls\\misc\\devprop.bin", self.getCloverDirFullPath().wc_str()).wc_str() , (UINT8*)mProperties, mPropSize); // // Status = egSaveFile(&self.getSelfRootDir(), SWPrintf("%ls\\misc\\devprop.bin", self.getCloverDirFullPath().wc_str()).wc_str() , (UINT8*)mProperties, mPropSize);
//and now we can free memory? // //and now we can free memory?
if (gSettings.AddProperties) { // if (gSettings.Devices.AddProperties) {
FreePool(gSettings.AddProperties); // FreePool(gSettings.Devices.AddProperties);
} // }
if (gSettings.ArbProperties) { if (gSettings.Devices.ArbProperties) {
DEV_PROPERTY *Props; DEV_PROPERTY *Props;
DEV_PROPERTY *Next; DEV_PROPERTY *Next;
Prop = gSettings.ArbProperties; Prop = gSettings.Devices.ArbProperties;
while (Prop) { while (Prop) {
Props = Prop->Child; Props = Prop->Child;
if (Prop->Label) { if (Prop->Label) {

View File

@ -372,22 +372,30 @@ public:
class DEV_PROPERTY class DEV_PROPERTY
{ {
public: public:
UINT32 Device; UINT32 Device = 0;
EFI_DEVICE_PATH_PROTOCOL* DevicePath = NULL; EFI_DEVICE_PATH_PROTOCOL* DevicePath = NULL;
CHAR8 *Key; CHAR8* Key = 0;
UINT8 *Value; UINT8* Value = 0;
UINTN ValueLen; UINTN ValueLen = 0;
DEV_PROPERTY *Next; //next device or next property DEV_PROPERTY* Next = 0; //next device or next property
DEV_PROPERTY *Child; // property list of the device DEV_PROPERTY* Child = 0; // property list of the device
CHAR8 *Label; CHAR8* Label = 0;
INPUT_ITEM MenuItem = INPUT_ITEM(); INPUT_ITEM MenuItem = INPUT_ITEM();
TAG_TYPE ValueType = kTagTypeNone; TAG_TYPE ValueType = kTagTypeNone;
DEV_PROPERTY() : Device(0), Key(0), Value(0), ValueLen(0), Next(0), Child(0), Label(0) { }
DEV_PROPERTY() {};
// Not sure if default are valid. Delete them. If needed, proper ones can be created // Not sure if default are valid. Delete them. If needed, proper ones can be created
DEV_PROPERTY(const DEV_PROPERTY&) = delete; DEV_PROPERTY(const DEV_PROPERTY&) { panic("nope"); };
DEV_PROPERTY& operator=(const DEV_PROPERTY&) = delete; DEV_PROPERTY& operator=(const DEV_PROPERTY&) { panic("nope"); };
};
class DEV_ADDPROPERTY
{
public:
UINT32 Device = 0;
XString8 Key = XString8();
XBuffer<uint8_t> Value = XBuffer<uint8_t>();
INPUT_ITEM MenuItem = INPUT_ITEM();
}; };
/** /**
@ -693,8 +701,58 @@ public:
class AudioClass { class AudioClass {
public: public:
bool ResetHDA = bool(); bool ResetHDA = bool();
} Audio = AudioClass(); bool HDAInjection = bool();
INT32 HDALayoutId = INT32();
UINT8 AFGLowPowerState = UINT8();
};
class USBClass {
public:
bool USBInjection = bool();
bool USBFixOwnership = bool();
bool InjectClockID = bool();
bool HighCurrent = bool();
bool NameEH00 = bool();
bool NameXH00 = bool();
};
class PropertiesClass {
public:
XString8 cDeviceProperties = XString8();
};
class FakeIDClass {
public:
//PCI devices
UINT32 FakeATI = UINT32(); //97
UINT32 FakeNVidia = UINT32();
UINT32 FakeIntel = UINT32();
UINT32 FakeLAN = UINT32(); //100
UINT32 FakeWIFI = UINT32();
UINT32 FakeSATA = UINT32();
UINT32 FakeXHCI = UINT32(); //103
UINT32 FakeIMEI = UINT32(); //106
};
bool StringInjector = bool();
bool IntelMaxBacklight = bool();
bool IntelBacklight = bool();
UINT32 IntelMaxValue = UINT32();
bool LANInjection = bool();
bool HDMIInjection = bool();
bool NoDefaultProperties = bool();
bool UseIntelHDMI = bool();
bool ForceHPET = bool();
UINT32 DisableFunctions = UINT32();
XString8 AirportBridgeDeviceName = XString8();
AudioClass Audio = AudioClass();
USBClass USB = USBClass();
PropertiesClass Properties = PropertiesClass();
FakeIDClass FakeID = FakeIDClass();
// UINTN NrAddProperties;
// DEV_PROPERTY *AddProperties;
XObjArray<DEV_ADDPROPERTY> AddProperties = XObjArray<DEV_ADDPROPERTY>();
DEV_PROPERTY *ArbProperties = 0;
}; };
@ -708,13 +766,13 @@ public:
bool enabled = 0; bool enabled = 0;
}; };
bool FuzzyMatch = bool(); bool FuzzyMatch = bool();
XString8 OcKernelCache = XString8(); XString8 OcKernelCache = XString8();
// UINTN MaxSlide; // UINTN MaxSlide;
OC_KERNEL_QUIRKS OcKernelQuirks = OC_KERNEL_QUIRKS(); OC_KERNEL_QUIRKS OcKernelQuirks = OC_KERNEL_QUIRKS();
OC_BOOTER_QUIRKS ocBooterQuirks = OC_BOOTER_QUIRKS(); OC_BOOTER_QUIRKS ocBooterQuirks = OC_BOOTER_QUIRKS();
XObjArray<MMIOWhiteList> mmioWhiteListArray = XObjArray<MMIOWhiteList>(); XObjArray<MMIOWhiteList> mmioWhiteListArray = XObjArray<MMIOWhiteList>();
UINT32 QuirksMask; UINT32 QuirksMask = 0;
}; };
class RtVariablesClass { class RtVariablesClass {
@ -809,8 +867,6 @@ public:
//Monitor //Monitor
BOOLEAN IntelMaxBacklight;
BOOLEAN IntelBacklight;
//Boot options //Boot options
BOOLEAN MemoryFix; BOOLEAN MemoryFix;
BOOLEAN FakeSMCFound; BOOLEAN FakeSMCFound;
@ -824,19 +880,8 @@ public:
// BOOLEAN DropMCFG; // BOOLEAN DropMCFG;
//Injections //Injections
BOOLEAN StringInjector;
BOOLEAN NoDefaultProperties;
//PCI devices
UINT32 FakeATI; //97
UINT32 FakeNVidia;
UINT32 FakeIntel;
UINT32 FakeLAN; //100
UINT32 FakeWIFI;
UINT32 FakeSATA;
UINT32 FakeXHCI; //103
UINT32 FakeIMEI; //106
//Graphics //Graphics
// UINT16 PCIRootUID; // UINT16 PCIRootUID;
@ -845,20 +890,9 @@ public:
// HDA
BOOLEAN HDAInjection;
INT32 HDALayoutId;
// USB DeviceTree injection // USB DeviceTree injection
BOOLEAN USBInjection;
BOOLEAN USBFixOwnership;
BOOLEAN InjectClockID;
BOOLEAN HighCurrent;
BOOLEAN NameEH00;
BOOLEAN NameXH00;
BOOLEAN LANInjection;
BOOLEAN HDMIInjection;
//SkyLake //SkyLake
@ -869,7 +903,6 @@ public:
BOOLEAN KextPatchesAllowed; BOOLEAN KextPatchesAllowed;
BOOLEAN KernelPatchesAllowed; //From GUI: Only for user patches, not internal Clover BOOLEAN KernelPatchesAllowed; //From GUI: Only for user patches, not internal Clover
XString8 AirportBridgeDeviceName;
// Pre-language // Pre-language
@ -892,18 +925,13 @@ public:
UINT8 REV[6]; UINT8 REV[6];
//other devices //other devices
BOOLEAN ForceHPET;
UINT32 DisableFunctions;
BOOLEAN SlpWak; BOOLEAN SlpWak;
BOOLEAN UseIntelHDMI; BOOLEAN UseIntelHDMI;
UINT8 AFGLowPowerState;
//Add custom properties //Add custom properties
UINTN NrAddProperties;
DEV_PROPERTY *AddProperties;
//BlackListed kexts //BlackListed kexts
CHAR16 BlockKexts[64]; CHAR16 BlockKexts[64];
@ -916,7 +944,6 @@ public:
//ACPI tables //ACPI tables
//other //other
UINT32 IntelMaxValue;
// UINT32 AudioVolume; // UINT32 AudioVolume;
// boot.efi // boot.efi
@ -926,7 +953,6 @@ public:
UINT32 EFILoginHiDPI; UINT32 EFILoginHiDPI;
UINT8 flagstate[32]; UINT8 flagstate[32];
DEV_PROPERTY *ArbProperties;
@ -936,19 +962,15 @@ public:
EnabledCores(0), SmbiosVersion(0), Attribute(0), MemoryManufacturer(), EnabledCores(0), SmbiosVersion(0), Attribute(0), MemoryManufacturer(),
MemorySerialNumber(), MemoryPartNumber(), MemorySpeed(), InjectMemoryTables(0), MemorySerialNumber(), MemoryPartNumber(), MemorySpeed(), InjectMemoryTables(0),
PlatformFeature(0), NoRomInfo(0), Language(), PlatformFeature(0), NoRomInfo(0), Language(),
IntelMaxBacklight(0), IntelBacklight(0), MemoryFix(0), MemoryFix(0),
FakeSMCFound(0), Debug(0), DefaultBackgroundColor(0), StringInjector(0), NoDefaultProperties(0), FakeSMCFound(0), Debug(0), DefaultBackgroundColor(0),
FakeATI(0), FakeNVidia(0), FakeIntel(0), FakeLAN(0), FakeWIFI(0), FakeSATA(0), FakeXHCI(0), FakeIMEI(0),
LpcTune(0), DropOEM_DSM(0), LpcTune(0), DropOEM_DSM(0),
HDAInjection(0),
HDALayoutId(0), USBInjection(0), USBFixOwnership(0), InjectClockID(0), HighCurrent(0), NameEH00(0), NameXH00(0), LANInjection(0), HDMIInjection(0),
KextPatchesAllowed(0), KextPatchesAllowed(0),
KernelPatchesAllowed(0), AirportBridgeDeviceName(), KernelPatchesAllowed(0),
ConfigName{0}, /*MainConfigName(0),*/ /*BlackListCount(0),*/ RPlt{0}, RBr{0}, EPCI{0}, REV{0}, ConfigName{0}, /*MainConfigName(0),*/ /*BlackListCount(0),*/ RPlt{0}, RBr{0}, EPCI{0}, REV{0},
ForceHPET(0), DisableFunctions(0), SlpWak(0), UseIntelHDMI(0), SlpWak(0), UseIntelHDMI(0),
AFGLowPowerState(0), NrAddProperties(0), AddProperties(0), BlockKexts{0}, BlockKexts{0},
IntelMaxValue(0), OptionsBits(0), FlagsBits(0), UIScale(0), EFILoginHiDPI(0), flagstate{0}, OptionsBits(0), FlagsBits(0), UIScale(0), EFILoginHiDPI(0), flagstate{0}
ArbProperties(0)
{}; {};
SETTINGS_DATA(const SETTINGS_DATA& other) = delete; // Can be defined if needed 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 const SETTINGS_DATA& operator = ( const SETTINGS_DATA & ) = delete; // Can be defined if needed

View File

@ -1325,11 +1325,11 @@ BOOLEAN get_name_pci_val(value_t *val, INTN index, BOOLEAN Sier)
{ {
CHAR8* pciName = (__typeof__(pciName))AllocateZeroPool(15); CHAR8* pciName = (__typeof__(pciName))AllocateZeroPool(15);
if (!card->info->model_name || !gSettings.FakeATI) { if (!card->info->model_name || !gSettings.Devices.FakeID.FakeATI) {
return FALSE; return FALSE;
} }
snprintf(pciName, 15, "pci1002,%x", gSettings.FakeATI >> 16); snprintf(pciName, 15, "pci1002,%x", gSettings.Devices.FakeID.FakeATI >> 16);
val->type = kStr; val->type = kStr;
val->size = 13; val->size = 13;
val->data = (UINT8 *)pciName; val->data = (UINT8 *)pciName;
@ -2110,28 +2110,28 @@ BOOLEAN setup_ati_devprop(LOADER_ENTRY *Entry, pci_dt_t *ati_dev)
} }
// ------------------------------------------------- // -------------------------------------------------
if (gSettings.FakeATI) { if (gSettings.Devices.FakeID.FakeATI) {
card->flags &= ~FLAGNOTFAKE; card->flags &= ~FLAGNOTFAKE;
card->flags |= FLAGOLD; card->flags |= FLAGOLD;
FakeID = gSettings.FakeATI >> 16; FakeID = gSettings.Devices.FakeID.FakeATI >> 16;
devprop_add_value(card->device, "device-id", (UINT8*)&FakeID, 4); devprop_add_value(card->device, "device-id", (UINT8*)&FakeID, 4);
devprop_add_value(card->device, "ATY,DeviceID", (UINT8*)&FakeID, 2); devprop_add_value(card->device, "ATY,DeviceID", (UINT8*)&FakeID, 2);
snprintf(compatible, 64, "pci1002,%x", FakeID); snprintf(compatible, 64, "pci1002,%x", FakeID);
devprop_add_value(card->device, "@0,compatible", (UINT8*)&compatible[0], 12); devprop_add_value(card->device, "@0,compatible", (UINT8*)&compatible[0], 12);
FakeID = gSettings.FakeATI & 0xFFFF; FakeID = gSettings.Devices.FakeID.FakeATI & 0xFFFF;
devprop_add_value(card->device, "vendor-id", (UINT8*)&FakeID, 4); devprop_add_value(card->device, "vendor-id", (UINT8*)&FakeID, 4);
devprop_add_value(card->device, "ATY,VendorID", (UINT8*)&FakeID, 2); devprop_add_value(card->device, "ATY,VendorID", (UINT8*)&FakeID, 2);
} }
if (gSettings.NoDefaultProperties) { if (gSettings.Devices.NoDefaultProperties) {
card->flags &= ~FLAGTRUE; card->flags &= ~FLAGTRUE;
DBG("ATI: No default properties injected\n"); DBG("ATI: No default properties injected\n");
} }
devprop_add_list(ati_devprop_list, Entry->macOSVersion); devprop_add_list(ati_devprop_list, Entry->macOSVersion);
if (!gSettings.NoDefaultProperties) { if (!gSettings.Devices.NoDefaultProperties) {
if (gSettings.UseIntelHDMI) { if (gSettings.Devices.UseIntelHDMI) {
devprop_add_value(card->device, "hda-gfx", (UINT8*)"onboard-2", 10); devprop_add_value(card->device, "hda-gfx", (UINT8*)"onboard-2", 10);
} else { } else {
devprop_add_value(card->device, "hda-gfx", (UINT8*)"onboard-1", 10); devprop_add_value(card->device, "hda-gfx", (UINT8*)"onboard-1", 10);
@ -2139,20 +2139,17 @@ BOOLEAN setup_ati_devprop(LOADER_ENTRY *Entry, pci_dt_t *ati_dev)
} }
if (gSettings.NrAddProperties != 0xFFFE) { if (gSettings.Devices.AddProperties.size() != 0xFFFE) { // Looks like NrAddProperties == 0xFFFE is not used anymore
for (i = 0; i < gSettings.NrAddProperties; i++) { for (i = 0; i < gSettings.Devices.AddProperties.size(); i++) {
if (gSettings.AddProperties[i].Device != DEV_ATI) { if (gSettings.Devices.AddProperties[i].Device != DEV_ATI) {
continue; continue;
} }
if (!gSettings.AddProperties[i].MenuItem.BValue) { if (!gSettings.Devices.AddProperties[i].MenuItem.BValue) {
//DBG(" disabled property Key: %s, len: %d\n", gSettings.AddProperties[i].Key, gSettings.AddProperties[i].ValueLen); //DBG(" disabled property Key: %s, len: %d\n", gSettings.Devices.AddProperties[i].Key, gSettings.Devices.AddProperties[i].ValueLen);
} else { } else {
devprop_add_value(card->device, devprop_add_value(card->device, gSettings.Devices.AddProperties[i].Key, gSettings.Devices.AddProperties[i].Value);
gSettings.AddProperties[i].Key, //DBG(" added property Key: %s, len: %d\n", gSettings.Devices.AddProperties[i].Key, gSettings.Devices.AddProperties[i].ValueLen);
(UINT8*)gSettings.AddProperties[i].Value,
gSettings.AddProperties[i].ValueLen);
//DBG(" added property Key: %s, len: %d\n", gSettings.AddProperties[i].Key, gSettings.AddProperties[i].ValueLen);
} }
} }
} }

View File

@ -213,7 +213,7 @@ DevPropDevice *devprop_add_device_pci(DevPropString *StringBuf, pci_dt_t *PciDt,
BOOLEAN devprop_add_value(DevPropDevice *device, CONST CHAR8 *nm, UINT8 *vl, UINTN len) BOOLEAN devprop_add_value(DevPropDevice *device, CONST CHAR8 *nm, const UINT8 *vl, UINTN len)
{ {
UINT32 offset; UINT32 offset;
UINT32 off; UINT32 off;
@ -276,6 +276,11 @@ BOOLEAN devprop_add_value(DevPropDevice *device, CONST CHAR8 *nm, UINT8 *vl, UIN
return TRUE; return TRUE;
} }
bool devprop_add_value(DevPropDevice *device, const XString8& nm, const XBuffer<uint8_t>& vl)
{
return devprop_add_value(device, nm.data(), vl.data(), vl.size());
}
CHAR8 *devprop_generate_string(DevPropString *StringBuf) CHAR8 *devprop_generate_string(DevPropString *StringBuf)
{ {
UINTN len = StringBuf->length * 2; UINTN len = StringBuf->length * 2;
@ -358,7 +363,7 @@ BOOLEAN set_eth_props(pci_dt_t *eth_dev)
UINTN i; UINTN i;
CHAR8 compatible[64]; CHAR8 compatible[64];
if (!gSettings.LANInjection) { if (!gSettings.Devices.LANInjection) {
return FALSE; return FALSE;
} }
@ -383,21 +388,18 @@ BOOLEAN set_eth_props(pci_dt_t *eth_dev)
builtin = 0x01; builtin = 0x01;
} }
if (gSettings.NrAddProperties != 0xFFFE) { if (gSettings.Devices.AddProperties.size() != 0xFFFE) { // Looks like NrAddProperties == 0xFFFE is not used anymore
for (i = 0; i < gSettings.NrAddProperties; i++) { for (i = 0; i < gSettings.Devices.AddProperties.size(); i++) {
if (gSettings.AddProperties[i].Device != DEV_LAN) { if (gSettings.Devices.AddProperties[i].Device != DEV_LAN) {
continue; continue;
} }
Injected = TRUE; Injected = TRUE;
if (!gSettings.AddProperties[i].MenuItem.BValue) { if (!gSettings.Devices.AddProperties[i].MenuItem.BValue) {
//DBG(" disabled property Key: %s, len: %d\n", gSettings.AddProperties[i].Key, gSettings.AddProperties[i].ValueLen); //DBG(" disabled property Key: %s, len: %d\n", gSettings.Devices.AddProperties[i].Key, gSettings.Devices.AddProperties[i].ValueLen);
} else { } else {
devprop_add_value(device, devprop_add_value(device, gSettings.Devices.AddProperties[i].Key, gSettings.Devices.AddProperties[i].Value);
gSettings.AddProperties[i].Key, //DBG(" added property Key: %s, len: %d\n", gSettings.Devices.AddProperties[i].Key, gSettings.Devices.AddProperties[i].ValueLen);
(UINT8*)gSettings.AddProperties[i].Value,
gSettings.AddProperties[i].ValueLen);
//DBG(" added property Key: %s, len: %d\n", gSettings.AddProperties[i].Key, gSettings.AddProperties[i].ValueLen);
} }
} }
} }
@ -408,12 +410,12 @@ BOOLEAN set_eth_props(pci_dt_t *eth_dev)
// DBG("Setting dev.prop built-in=0x%X\n", builtin); // DBG("Setting dev.prop built-in=0x%X\n", builtin);
// devprop_add_value(device, "device_type", (UINT8*)"Ethernet", 9); // devprop_add_value(device, "device_type", (UINT8*)"Ethernet", 9);
if (gSettings.FakeLAN) { if (gSettings.Devices.FakeID.FakeLAN) {
UINT32 FakeID = gSettings.FakeLAN >> 16; UINT32 FakeID = gSettings.Devices.FakeID.FakeLAN >> 16;
devprop_add_value(device, "device-id", (UINT8*)&FakeID, 4); devprop_add_value(device, "device-id", (UINT8*)&FakeID, 4);
snprintf(compatible, 64, "pci%x,%x", (gSettings.FakeLAN & 0xFFFF), FakeID); snprintf(compatible, 64, "pci%x,%x", (gSettings.Devices.FakeID.FakeLAN & 0xFFFF), FakeID);
devprop_add_value(device, "compatible", (UINT8*)&compatible[0], 12); devprop_add_value(device, "compatible", (UINT8*)&compatible[0], 12);
FakeID = gSettings.FakeLAN & 0xFFFF; FakeID = gSettings.Devices.FakeID.FakeLAN & 0xFFFF;
devprop_add_value(device, "vendor-id", (UINT8*)&FakeID, 4); devprop_add_value(device, "vendor-id", (UINT8*)&FakeID, 4);
} }
else if (eth_dev->vendor_id == 0x11AB && eth_dev->device_id == 0x4364) else if (eth_dev->vendor_id == 0x11AB && eth_dev->device_id == 0x4364)
@ -465,21 +467,18 @@ BOOLEAN set_usb_props(pci_dt_t *usb_dev)
// DBG("USB Controller [%04X:%04X] :: %s\n", usb_dev->vendor_id, usb_dev->device_id, devicepath); // DBG("USB Controller [%04X:%04X] :: %s\n", usb_dev->vendor_id, usb_dev->device_id, devicepath);
// DBG("Setting dev.prop built-in=0x%X\n", builtin); // DBG("Setting dev.prop built-in=0x%X\n", builtin);
if (gSettings.NrAddProperties != 0xFFFE) { if (gSettings.Devices.AddProperties.size() != 0xFFFE) { // Looks like NrAddProperties == 0xFFFE is not used anymore
for (i = 0; i < gSettings.NrAddProperties; i++) { for (i = 0; i < gSettings.Devices.AddProperties.size(); i++) {
if (gSettings.AddProperties[i].Device != DEV_USB) { if (gSettings.Devices.AddProperties[i].Device != DEV_USB) {
continue; continue;
} }
Injected = TRUE; Injected = TRUE;
if (!gSettings.AddProperties[i].MenuItem.BValue) { if (!gSettings.Devices.AddProperties[i].MenuItem.BValue) {
//DBG(" disabled property Key: %s, len: %d\n", gSettings.AddProperties[i].Key, gSettings.AddProperties[i].ValueLen); //DBG(" disabled property Key: %s, len: %d\n", gSettings.Devices.AddProperties[i].Key, gSettings.Devices.AddProperties[i].ValueLen);
} else { } else {
devprop_add_value(device, devprop_add_value(device, gSettings.Devices.AddProperties[i].Key, gSettings.Devices.AddProperties[i].Value);
gSettings.AddProperties[i].Key, //DBG(" added property Key: %s, len: %d\n", gSettings.Devices.AddProperties[i].Key, gSettings.Devices.AddProperties[i].ValueLen);
(UINT8*)gSettings.AddProperties[i].Value,
gSettings.AddProperties[i].ValueLen);
//DBG(" added property Key: %s, len: %d\n", gSettings.AddProperties[i].Key, gSettings.AddProperties[i].ValueLen);
} }
} }
} }
@ -488,7 +487,7 @@ BOOLEAN set_usb_props(pci_dt_t *usb_dev)
// return TRUE; // return TRUE;
} }
if (gSettings.InjectClockID) { if (gSettings.Devices.USB.InjectClockID) {
devprop_add_value(device, "AAPL,clock-id", (UINT8*)&clock_id, 1); devprop_add_value(device, "AAPL,clock-id", (UINT8*)&clock_id, 1);
clock_id++; clock_id++;
} }
@ -509,7 +508,7 @@ BOOLEAN set_usb_props(pci_dt_t *usb_dev)
break; break;
case PCI_IF_EHCI: case PCI_IF_EHCI:
devprop_add_value(device, "device_type", (UINT8*)"EHCI", 4); devprop_add_value(device, "device_type", (UINT8*)"EHCI", 4);
if (gSettings.HighCurrent) { if (gSettings.Devices.USB.HighCurrent) {
devprop_add_value(device, "AAPL,current-available", (UINT8*)&current_available_high, 2); devprop_add_value(device, "AAPL,current-available", (UINT8*)&current_available_high, 2);
devprop_add_value(device, "AAPL,current-extra", (UINT8*)&current_extra_high, 2); devprop_add_value(device, "AAPL,current-extra", (UINT8*)&current_extra_high, 2);
} else { } else {
@ -520,7 +519,7 @@ BOOLEAN set_usb_props(pci_dt_t *usb_dev)
break; break;
case PCI_IF_XHCI: case PCI_IF_XHCI:
devprop_add_value(device, "device_type", (UINT8*)"XHCI", 4); devprop_add_value(device, "device_type", (UINT8*)"XHCI", 4);
if (gSettings.HighCurrent) { if (gSettings.Devices.USB.HighCurrent) {
devprop_add_value(device, "AAPL,current-available", (UINT8*)&current_available_high, 2); devprop_add_value(device, "AAPL,current-available", (UINT8*)&current_available_high, 2);
devprop_add_value(device, "AAPL,current-extra", (UINT8*)&current_extra_high, 2); devprop_add_value(device, "AAPL,current-extra", (UINT8*)&current_extra_high, 2);
} else { } else {

View File

@ -12,6 +12,7 @@ extern "C" {
#include <Protocol/DevicePath.h> #include <Protocol/DevicePath.h>
} }
#include "../cpp_foundation/XBuffer.h"
#include "../include/Pci.h" #include "../include/Pci.h"
/* No more used /* No more used
@ -119,7 +120,8 @@ extern UINT32 device_inject_stringlength;
DevPropString *devprop_create_string(void); DevPropString *devprop_create_string(void);
//DevPropDevice *devprop_add_device(DevPropString *string, char *path); //DevPropDevice *devprop_add_device(DevPropString *string, char *path);
DevPropDevice *devprop_add_device_pci(DevPropString *string, pci_dt_t *PciDt, EFI_DEVICE_PATH_PROTOCOL *DevicePath); DevPropDevice *devprop_add_device_pci(DevPropString *string, pci_dt_t *PciDt, EFI_DEVICE_PATH_PROTOCOL *DevicePath);
BOOLEAN devprop_add_value(DevPropDevice *device, CONST CHAR8 *nm, UINT8 *vl, UINTN len); BOOLEAN devprop_add_value(DevPropDevice *device, CONST CHAR8 *nm, const UINT8 *vl, UINTN len); // to be removed
bool devprop_add_value(DevPropDevice *device, const XString8& nm, const XBuffer<uint8_t>& vl);
CHAR8 *devprop_generate_string(DevPropString *string); CHAR8 *devprop_generate_string(DevPropString *string);
void devprop_free_string(DevPropString *string); void devprop_free_string(DevPropString *string);

View File

@ -1336,21 +1336,18 @@ BOOLEAN setup_gma_devprop(LOADER_ENTRY *Entry, pci_dt_t *gma_dev)
return FALSE; return FALSE;
} }
if (gSettings.NrAddProperties != 0xFFFE) { if (gSettings.Devices.AddProperties.size() != 0xFFFE) { // Looks like NrAddProperties == 0xFFFE is not used anymore
for (i = 0; i < gSettings.NrAddProperties; i++) { for (i = 0; i < gSettings.Devices.AddProperties.size(); i++) {
if (gSettings.AddProperties[i].Device != DEV_INTEL) { if (gSettings.Devices.AddProperties[i].Device != DEV_INTEL) {
continue; continue;
} }
Injected = TRUE; Injected = TRUE;
if (!gSettings.AddProperties[i].MenuItem.BValue) { if (!gSettings.Devices.AddProperties[i].MenuItem.BValue) {
//DBG(" disabled property Key: %s, len: %d\n", gSettings.AddProperties[i].Key, gSettings.AddProperties[i].ValueLen); //DBG(" disabled property Key: %s, len: %d\n", gSettings.Devices.AddProperties[i].Key, gSettings.Devices.AddProperties[i].ValueLen);
} else { } else {
devprop_add_value(device, devprop_add_value(device, gSettings.Devices.AddProperties[i].Key, gSettings.Devices.AddProperties[i].Value);
gSettings.AddProperties[i].Key, //DBG(" added property Key: %s, len: %d\n", gSettings.Devices.AddProperties[i].Key, gSettings.Devices.AddProperties[i].ValueLen);
(UINT8*)gSettings.AddProperties[i].Value,
gSettings.AddProperties[i].ValueLen);
//DBG(" added property Key: %s, len: %d\n", gSettings.AddProperties[i].Key, gSettings.AddProperties[i].ValueLen);
} }
} }
} }
@ -1359,7 +1356,7 @@ BOOLEAN setup_gma_devprop(LOADER_ENTRY *Entry, pci_dt_t *gma_dev)
MsgLog(" Additional Intel GFX properties injected, continue\n"); MsgLog(" Additional Intel GFX properties injected, continue\n");
} }
if (gSettings.UseIntelHDMI) { if (gSettings.Devices.UseIntelHDMI) {
devprop_add_value(device, "hda-gfx", (UINT8*)"onboard-1", 10); devprop_add_value(device, "hda-gfx", (UINT8*)"onboard-1", 10);
MsgLog(" IntelHDMI: used\n"); MsgLog(" IntelHDMI: used\n");
} }
@ -1464,13 +1461,13 @@ BOOLEAN setup_gma_devprop(LOADER_ENTRY *Entry, pci_dt_t *gma_dev)
break; break;
} }
if (gSettings.FakeIntel) { if (gSettings.Devices.FakeID.FakeIntel) {
FakeID = gSettings.FakeIntel >> 16; FakeID = gSettings.Devices.FakeID.FakeIntel >> 16;
devprop_add_value(device, "device-id", (UINT8*)&FakeID, 4); devprop_add_value(device, "device-id", (UINT8*)&FakeID, 4);
FakeID = gSettings.FakeIntel & 0xFFFF; FakeID = gSettings.Devices.FakeID.FakeIntel & 0xFFFF;
devprop_add_value(device, "vendor-id", (UINT8*)&FakeID, 4); devprop_add_value(device, "vendor-id", (UINT8*)&FakeID, 4);
SetFake = TRUE; SetFake = TRUE;
MsgLog(" FakeID Intel GFX = 0x%08x\n", gSettings.FakeIntel); MsgLog(" FakeID Intel GFX = 0x%08x\n", gSettings.Devices.FakeID.FakeIntel);
} else { } else {
DBG(" FakeID Intel GFX: not set\n"); DBG(" FakeID Intel GFX: not set\n");
} }
@ -1503,7 +1500,7 @@ BOOLEAN setup_gma_devprop(LOADER_ENTRY *Entry, pci_dt_t *gma_dev)
break; break;
} }
if (gSettings.NoDefaultProperties) { if (gSettings.Devices.NoDefaultProperties) {
MsgLog(" Intel: no default properties\n"); MsgLog(" Intel: no default properties\n");
return TRUE; return TRUE;
} }

View File

@ -163,7 +163,7 @@ BOOLEAN setup_hda_devprop(EFI_PCI_IO_PROTOCOL *PciIo, pci_dt_t *hda_dev, const M
device_inject_string = devprop_create_string(); device_inject_string = devprop_create_string();
} }
if (IsHDMIAudio(hda_dev->DeviceHandle)) { if (IsHDMIAudio(hda_dev->DeviceHandle)) {
if (!gSettings.HDMIInjection) { if (!gSettings.Devices.HDMIInjection) {
return FALSE; return FALSE;
} }
@ -175,21 +175,18 @@ BOOLEAN setup_hda_devprop(EFI_PCI_IO_PROTOCOL *PciIo, pci_dt_t *hda_dev, const M
return FALSE; return FALSE;
} }
if (gSettings.NrAddProperties != 0xFFFE) { if (gSettings.Devices.AddProperties.size() != 0xFFFE) { // Looks like NrAddProperties == 0xFFFE is not used anymore
for (i = 0; i < gSettings.NrAddProperties; i++) { for (i = 0; i < gSettings.Devices.AddProperties.size(); i++) {
if (gSettings.AddProperties[i].Device != DEV_HDMI) { if (gSettings.Devices.AddProperties[i].Device != DEV_HDMI) {
continue; continue;
} }
Injected = TRUE; Injected = TRUE;
if (!gSettings.AddProperties[i].MenuItem.BValue) { if (!gSettings.Devices.AddProperties[i].MenuItem.BValue) {
//DBG(" disabled property Key: %s, len: %d\n", gSettings.AddProperties[i].Key, gSettings.AddProperties[i].ValueLen); //DBG(" disabled property Key: %s, len: %d\n", gSettings.Devices.AddProperties[i].Key, gSettings.Devices.AddProperties[i].ValueLen);
} else { } else {
devprop_add_value(device, devprop_add_value(device, gSettings.Devices.AddProperties[i].Key, gSettings.Devices.AddProperties[i].Value);
gSettings.AddProperties[i].Key, //DBG(" added property Key: %s, len: %d\n", gSettings.Devices.AddProperties[i].Key, gSettings.Devices.AddProperties[i].ValueLen);
(UINT8*)gSettings.AddProperties[i].Value,
gSettings.AddProperties[i].ValueLen);
//DBG(" added property Key: %s, len: %d\n", gSettings.AddProperties[i].Key, gSettings.AddProperties[i].ValueLen);
} }
} }
} }
@ -197,7 +194,7 @@ BOOLEAN setup_hda_devprop(EFI_PCI_IO_PROTOCOL *PciIo, pci_dt_t *hda_dev, const M
DBG("Additional HDMI properties injected, continue\n"); DBG("Additional HDMI properties injected, continue\n");
//return TRUE; //return TRUE;
} else { } else {
if (gSettings.UseIntelHDMI) { if (gSettings.Devices.UseIntelHDMI) {
DBG(" HDMI Audio, used with HDA setting hda-gfx=onboard-2\n"); DBG(" HDMI Audio, used with HDA setting hda-gfx=onboard-2\n");
devprop_add_value(device, "hda-gfx", (UINT8*)"onboard-2", 10); devprop_add_value(device, "hda-gfx", (UINT8*)"onboard-2", 10);
} else { } else {
@ -206,7 +203,7 @@ BOOLEAN setup_hda_devprop(EFI_PCI_IO_PROTOCOL *PciIo, pci_dt_t *hda_dev, const M
} }
} }
} else { } else {
if (!gSettings.HDAInjection) { if (!gSettings.Devices.Audio.HDAInjection) {
return FALSE; return FALSE;
} }
if (hda_dev && !hda_dev->used) { if (hda_dev && !hda_dev->used) {
@ -217,41 +214,38 @@ BOOLEAN setup_hda_devprop(EFI_PCI_IO_PROTOCOL *PciIo, pci_dt_t *hda_dev, const M
return FALSE; return FALSE;
} }
// HDA - determine layout-id // HDA - determine layout-id
if (gSettings.HDALayoutId > 0) { if (gSettings.Devices.Audio.HDALayoutId > 0) {
// layoutId is specified - use it // layoutId is specified - use it
layoutId = (UINT32)gSettings.HDALayoutId; layoutId = (UINT32)gSettings.Devices.Audio.HDALayoutId;
DBG(" setting specified layout-id=%d (0x%X)\n", layoutId, layoutId); DBG(" setting specified layout-id=%d (0x%X)\n", layoutId, layoutId);
} else { } else {
layoutId = 12; layoutId = 12;
} }
if (gSettings.NrAddProperties != 0xFFFE) { if (gSettings.Devices.AddProperties.size() != 0xFFFE) { // Looks like NrAddProperties == 0xFFFE is not used anymore
for (i = 0; i < gSettings.NrAddProperties; i++) { for (i = 0; i < gSettings.Devices.AddProperties.size(); i++) {
if (gSettings.AddProperties[i].Device != DEV_HDA) { if (gSettings.Devices.AddProperties[i].Device != DEV_HDA) {
continue; continue;
} }
Injected = TRUE; Injected = TRUE;
if (!gSettings.AddProperties[i].MenuItem.BValue) { if (!gSettings.Devices.AddProperties[i].MenuItem.BValue) {
//DBG(" disabled property Key: %s, len: %d\n", gSettings.AddProperties[i].Key, gSettings.AddProperties[i].ValueLen); //DBG(" disabled property Key: %s, len: %d\n", gSettings.Devices.AddProperties[i].Key, gSettings.Devices.AddProperties[i].ValueLen);
} else { } else {
devprop_add_value(device, devprop_add_value(device, gSettings.Devices.AddProperties[i].Key, gSettings.Devices.AddProperties[i].Value);
gSettings.AddProperties[i].Key, //DBG(" added property Key: %s, len: %d\n", gSettings.Devices.AddProperties[i].Key, gSettings.Devices.AddProperties[i].ValueLen);
(UINT8*)gSettings.AddProperties[i].Value,
gSettings.AddProperties[i].ValueLen);
//DBG(" added property Key: %s, len: %d\n", gSettings.AddProperties[i].Key, gSettings.AddProperties[i].ValueLen);
} }
} }
} }
if (!Injected) { if (!Injected) {
if ( (OSVersion.notEmpty() && OSVersion < MacOsVersion("10.8"_XS8)) || gSettings.HDALayoutId > 0 ) { if ( (OSVersion.notEmpty() && OSVersion < MacOsVersion("10.8"_XS8)) || gSettings.Devices.Audio.HDALayoutId > 0 ) {
devprop_add_value(device, "layout-id", (UINT8 *)&layoutId, 4); devprop_add_value(device, "layout-id", (UINT8 *)&layoutId, 4);
} }
layoutId = 0; // reuse variable layoutId = 0; // reuse variable
if (gSettings.UseIntelHDMI) { if (gSettings.Devices.UseIntelHDMI) {
devprop_add_value(device, "hda-gfx", (UINT8 *)"onboard-1", 10); devprop_add_value(device, "hda-gfx", (UINT8 *)"onboard-1", 10);
} }
codecId = 1; // reuse variable again codecId = 1; // reuse variable again
if (gSettings.AFGLowPowerState) { if (gSettings.Devices.Audio.AFGLowPowerState) {
devprop_add_value(device, "AFGLowPowerState", (UINT8 *)&codecId, 4); devprop_add_value(device, "AFGLowPowerState", (UINT8 *)&codecId, 4);
} }

View File

@ -2427,21 +2427,18 @@ BOOLEAN setup_nvidia_devprop(pci_dt_t *nvda_dev)
goto done; goto done;
} }
if (gSettings.NrAddProperties != 0xFFFE) { if (gSettings.Devices.AddProperties.size() != 0xFFFE) { // Looks like NrAddProperties == 0xFFFE is not used anymore
for (i = 0; i < gSettings.NrAddProperties; i++) { for (i = 0; i < gSettings.Devices.AddProperties.size(); i++) {
if (gSettings.AddProperties[i].Device != DEV_NVIDIA) { if (gSettings.Devices.AddProperties[i].Device != DEV_NVIDIA) {
continue; continue;
} }
Injected = TRUE; Injected = TRUE;
if (!gSettings.AddProperties[i].MenuItem.BValue) { if (!gSettings.Devices.AddProperties[i].MenuItem.BValue) {
//DBG(" disabled property Key: %s, len: %d\n", gSettings.AddProperties[i].Key, gSettings.AddProperties[i].ValueLen); //DBG(" disabled property Key: %s, len: %d\n", gSettings.Devices.AddProperties[i].Key, gSettings.Devices.AddProperties[i].ValueLen);
} else { } else {
devprop_add_value(device, devprop_add_value(device, gSettings.Devices.AddProperties[i].Key, gSettings.Devices.AddProperties[i].Value);
gSettings.AddProperties[i].Key, //DBG(" added property Key: %s, len: %d\n", gSettings.Devices.AddProperties[i].Key, gSettings.Devices.AddProperties[i].ValueLen);
(UINT8*)gSettings.AddProperties[i].Value,
gSettings.AddProperties[i].ValueLen);
//DBG(" added property Key: %s, len: %d\n", gSettings.AddProperties[i].Key, gSettings.AddProperties[i].ValueLen);
} }
} }
if (Injected) { if (Injected) {
@ -2450,11 +2447,11 @@ BOOLEAN setup_nvidia_devprop(pci_dt_t *nvda_dev)
} }
} }
if (gSettings.FakeNVidia) { if (gSettings.Devices.FakeID.FakeNVidia) {
UINT32 FakeID = gSettings.FakeNVidia >> 16; UINT32 FakeID = gSettings.Devices.FakeID.FakeNVidia >> 16;
DBG("NVidia: FakeID %X:%X\n",gSettings.FakeNVidia & 0xFFFF, FakeID); DBG("NVidia: FakeID %X:%X\n",gSettings.Devices.FakeID.FakeNVidia & 0xFFFF, FakeID);
devprop_add_value(device, "device-id", (UINT8*)&FakeID, 4); devprop_add_value(device, "device-id", (UINT8*)&FakeID, 4);
FakeID = gSettings.FakeNVidia & 0xFFFF; FakeID = gSettings.Devices.FakeID.FakeNVidia & 0xFFFF;
devprop_add_value(device, "vendor-id", (UINT8*)&FakeID, 4); devprop_add_value(device, "vendor-id", (UINT8*)&FakeID, 4);
} }
@ -2481,7 +2478,7 @@ BOOLEAN setup_nvidia_devprop(pci_dt_t *nvda_dev)
} }
//there are default or calculated properties, can be skipped //there are default or calculated properties, can be skipped
//if (gSettings.NoDefaultProperties) { //if (gSettings.Devices.NoDefaultProperties) {
// DBG("Nvidia: no default properties injected\n"); // DBG("Nvidia: no default properties injected\n");
// goto done; // goto done;
//} //}
@ -2493,13 +2490,13 @@ BOOLEAN setup_nvidia_devprop(pci_dt_t *nvda_dev)
DBG("Nvidia: BootDisplay: %hhX\n", gSettings.Graphics.BootDisplay); DBG("Nvidia: BootDisplay: %hhX\n", gSettings.Graphics.BootDisplay);
}*/ }*/
if (gSettings.UseIntelHDMI) { if (gSettings.Devices.UseIntelHDMI) {
devprop_add_value(device, "hda-gfx", (UINT8*)"onboard-2", 10); devprop_add_value(device, "hda-gfx", (UINT8*)"onboard-2", 10);
} else { } else {
devprop_add_value(device, "hda-gfx", (UINT8*)"onboard-1", 10); devprop_add_value(device, "hda-gfx", (UINT8*)"onboard-1", 10);
} }
if (!gSettings.NoDefaultProperties) { if (!gSettings.Devices.NoDefaultProperties) {
if (videoRam != 0) { if (videoRam != 0) {
devprop_add_value(device, "VRAM,totalsize", (UINT8*)&videoRam, 8); devprop_add_value(device, "VRAM,totalsize", (UINT8*)&videoRam, 8);
} }

View File

@ -1414,9 +1414,9 @@ void GetDefaultSettings()
CopyMem(&gSettings.Graphics.Dcfg[4], default_dcfg_1, 4); CopyMem(&gSettings.Graphics.Dcfg[4], default_dcfg_1, 4);
//gSettings.Graphics.EDID.CustomEDID = NULL; //no sense to assign 0 as the structure is zeroed //gSettings.Graphics.EDID.CustomEDID = NULL; //no sense to assign 0 as the structure is zeroed
gSettings.Graphics.DualLink = 0xA; // A(auto): DualLink auto-detection gSettings.Graphics.DualLink = 0xA; // A(auto): DualLink auto-detection
gSettings.HDAInjection = FALSE; gSettings.Devices.Audio.HDAInjection = FALSE;
//gSettings.HDALayoutId = 0; //gSettings.Devices.Audio.HDALayoutId = 0;
gSettings.USBInjection = TRUE; // enabled by default to have the same behavior as before gSettings.Devices.USB.USBInjection = TRUE; // enabled by default to have the same behavior as before
gSettings.ACPI.DSDT.DsdtName = L"DSDT.aml"_XSW; gSettings.ACPI.DSDT.DsdtName = L"DSDT.aml"_XSW;
gSettings.SystemParameters.BacklightLevel = 0xFFFF; //0x0503; -- the value from MBA52 gSettings.SystemParameters.BacklightLevel = 0xFFFF; //0x0503; -- the value from MBA52
gSettings.SystemParameters.BacklightLevelConfig = FALSE; gSettings.SystemParameters.BacklightLevelConfig = FALSE;

View File

@ -19,6 +19,9 @@
template <typename T> template <typename T>
class XBuffer : public XBuffer_Super class XBuffer : public XBuffer_Super
{ {
public:
static XBuffer<T> NullXBuffer;
protected: protected:
T*_WData; // same as RData (see XRBuffer) T*_WData; // same as RData (see XRBuffer)
size_t m_allocatedSize; size_t m_allocatedSize;
@ -30,7 +33,7 @@ protected:
XBuffer(const XBuffer<T>& aBuffer) : _WData(NULL), m_allocatedSize(0) { Initialize(aBuffer.data(), aBuffer.size(), aBuffer.index()); } XBuffer(const XBuffer<T>& aBuffer) : _WData(NULL), m_allocatedSize(0) { Initialize(aBuffer.data(), aBuffer.size(), aBuffer.index()); }
XBuffer(XRBuffer<T> &aBuffer, size_t pos = 0, size_t count = MAX_XSIZE); XBuffer(XRBuffer<T> &aBuffer, size_t pos = 0, size_t count = MAX_XSIZE);
// XBuffer(XBuffer &aBuffer, size_t pos = 0, size_t count = MAX_XSIZE); // XBuffer(XBuffer &aBuffer, size_t pos = 0, size_t count = MAX_XSIZE);
XBuffer(void *p, size_t count); XBuffer(const void *p, size_t count);
const XBuffer &operator =(const XRBuffer<T> &aBuffer); const XBuffer &operator =(const XRBuffer<T> &aBuffer);
const XBuffer &operator =(const XBuffer &aBuffer); const XBuffer &operator =(const XBuffer &aBuffer);
@ -67,7 +70,6 @@ protected:
~XBuffer(); ~XBuffer();
public: public:
static XBuffer<T> NullXBuffer;
void CheckSize(size_t nNewSize, size_t nGrowBy = XBufferGrowByDefault); void CheckSize(size_t nNewSize, size_t nGrowBy = XBufferGrowByDefault);
@ -306,7 +308,7 @@ XBuffer<T>::XBuffer(XRBuffer<T> &aXRBuffer, size_t pos, size_t count) : _WData(N
//} //}
template <typename T> template <typename T>
XBuffer<T>::XBuffer(void *p, size_t count) : _WData(NULL), m_allocatedSize(0) // initialisation to avoid effc++ warning XBuffer<T>::XBuffer(const void *p, size_t count) : _WData(NULL), m_allocatedSize(0) // initialisation to avoid effc++ warning
{ {
Initialize((const unsigned char*)p, count, 0); Initialize((const unsigned char*)p, count, 0);
} }

View File

@ -1437,7 +1437,7 @@ void LOADER_ENTRY::StartLoader()
} }
} }
// DBG("Set FakeCPUID: 0x%X\n", gSettings.FakeCPUID); // DBG("Set FakeCPUID: 0x%X\n", gSettings.Devices.FakeID.FakeCPUID);
// DBG("LoadKexts\n"); // DBG("LoadKexts\n");
// LoadKexts writes to DataHub, where large writes can prevent hibernate wake (happens when several kexts present in Clover's kexts dir) // LoadKexts writes to DataHub, where large writes can prevent hibernate wake (happens when several kexts present in Clover's kexts dir)

View File

@ -282,11 +282,11 @@ void FillInputs(BOOLEAN New)
InputItems[InputItemsCount].ItemType = BoolValue; //57 InputItems[InputItemsCount].ItemType = BoolValue; //57
InputItems[InputItemsCount++].BValue = gSettings.Devices.Audio.ResetHDA; InputItems[InputItemsCount++].BValue = gSettings.Devices.Audio.ResetHDA;
InputItems[InputItemsCount].ItemType = BoolValue; //58 InputItems[InputItemsCount].ItemType = BoolValue; //58
InputItems[InputItemsCount++].BValue = gSettings.AFGLowPowerState; InputItems[InputItemsCount++].BValue = gSettings.Devices.Audio.AFGLowPowerState;
InputItems[InputItemsCount].ItemType = BoolValue; //59 InputItems[InputItemsCount].ItemType = BoolValue; //59
InputItems[InputItemsCount++].BValue = gSettings.HDAInjection; InputItems[InputItemsCount++].BValue = gSettings.Devices.Audio.HDAInjection;
InputItems[InputItemsCount].ItemType = Decimal; // 60 InputItems[InputItemsCount].ItemType = Decimal; // 60
InputItems[InputItemsCount++].SValue.SWPrintf("%d", gSettings.HDALayoutId); InputItems[InputItemsCount++].SValue.SWPrintf("%d", gSettings.Devices.Audio.HDALayoutId);
// syscl change here // syscl change here
InputItems[InputItemsCount].ItemType = BoolValue; //61 InputItems[InputItemsCount].ItemType = BoolValue; //61
@ -329,7 +329,7 @@ void FillInputs(BOOLEAN New)
InputItemsCount = 74; InputItemsCount = 74;
InputItems[InputItemsCount].ItemType = BoolValue; //74 InputItems[InputItemsCount].ItemType = BoolValue; //74
InputItems[InputItemsCount++].BValue = gSettings.USBFixOwnership; InputItems[InputItemsCount++].BValue = gSettings.Devices.USB.USBFixOwnership;
InputItems[InputItemsCount].ItemType = Hex; //75 InputItems[InputItemsCount].ItemType = Hex; //75
InputItems[InputItemsCount++].SValue.SWPrintf("0x%04hX", GlobalConfig.C3Latency); InputItems[InputItemsCount++].SValue.SWPrintf("0x%04hX", GlobalConfig.C3Latency);
@ -370,32 +370,32 @@ void FillInputs(BOOLEAN New)
InputItems[InputItemsCount++].BValue = gSettings.KernelAndKextPatches.KPKernelLapic; InputItems[InputItemsCount++].BValue = gSettings.KernelAndKextPatches.KPKernelLapic;
InputItems[InputItemsCount].ItemType = BoolValue; //92 InputItems[InputItemsCount].ItemType = BoolValue; //92
InputItems[InputItemsCount++].BValue = gSettings.USBInjection; InputItems[InputItemsCount++].BValue = gSettings.Devices.USB.USBInjection;
InputItems[InputItemsCount].ItemType = BoolValue; //93 InputItems[InputItemsCount].ItemType = BoolValue; //93
InputItems[InputItemsCount++].BValue = gSettings.InjectClockID; InputItems[InputItemsCount++].BValue = gSettings.Devices.USB.InjectClockID;
InputItems[InputItemsCount].ItemType = Hex; //94 InputItems[InputItemsCount].ItemType = Hex; //94
InputItems[InputItemsCount++].SValue.SWPrintf("0x%08X", gSettings.FakeATI); InputItems[InputItemsCount++].SValue.SWPrintf("0x%08X", gSettings.Devices.FakeID.FakeATI);
InputItems[InputItemsCount].ItemType = Hex; //95 InputItems[InputItemsCount].ItemType = Hex; //95
InputItems[InputItemsCount++].SValue.SWPrintf("0x%08X", gSettings.FakeNVidia); InputItems[InputItemsCount++].SValue.SWPrintf("0x%08X", gSettings.Devices.FakeID.FakeNVidia);
InputItems[InputItemsCount].ItemType = Hex; //96 InputItems[InputItemsCount].ItemType = Hex; //96
InputItems[InputItemsCount++].SValue.SWPrintf("0x%08X", gSettings.FakeIntel); InputItems[InputItemsCount++].SValue.SWPrintf("0x%08X", gSettings.Devices.FakeID.FakeIntel);
InputItems[InputItemsCount].ItemType = Hex; //97 InputItems[InputItemsCount].ItemType = Hex; //97
InputItems[InputItemsCount++].SValue.SWPrintf("0x%08X", gSettings.FakeLAN); InputItems[InputItemsCount++].SValue.SWPrintf("0x%08X", gSettings.Devices.FakeID.FakeLAN);
InputItems[InputItemsCount].ItemType = Hex; //98 InputItems[InputItemsCount].ItemType = Hex; //98
InputItems[InputItemsCount++].SValue.SWPrintf("0x%08X", gSettings.FakeWIFI); InputItems[InputItemsCount++].SValue.SWPrintf("0x%08X", gSettings.Devices.FakeID.FakeWIFI);
InputItems[InputItemsCount].ItemType = Hex; //99 InputItems[InputItemsCount].ItemType = Hex; //99
InputItems[InputItemsCount++].SValue.SWPrintf("0x%08X", gSettings.FakeSATA); InputItems[InputItemsCount++].SValue.SWPrintf("0x%08X", gSettings.Devices.FakeID.FakeSATA);
InputItems[InputItemsCount].ItemType = Hex; //100 InputItems[InputItemsCount].ItemType = Hex; //100
InputItems[InputItemsCount++].SValue.SWPrintf("0x%08X", gSettings.FakeXHCI); InputItems[InputItemsCount++].SValue.SWPrintf("0x%08X", gSettings.Devices.FakeID.FakeXHCI);
InputItems[InputItemsCount].ItemType = CheckBit; //101 - Quirks InputItems[InputItemsCount].ItemType = CheckBit; //101 - Quirks
InputItems[InputItemsCount++].IValue = gSettings.Quirks.QuirksMask; // InputItems[InputItemsCount++].IValue = gSettings.Quirks.QuirksMask; //
InputItems[InputItemsCount].ItemType = BoolValue; //102 InputItems[InputItemsCount].ItemType = BoolValue; //102
InputItems[InputItemsCount++].BValue = gSettings.ACPI.DSDT.DebugDSDT; InputItems[InputItemsCount++].BValue = gSettings.ACPI.DSDT.DebugDSDT;
InputItems[InputItemsCount].ItemType = Hex; //103 InputItems[InputItemsCount].ItemType = Hex; //103
InputItems[InputItemsCount++].SValue.SWPrintf("0x%08X", gSettings.FakeIMEI); InputItems[InputItemsCount++].SValue.SWPrintf("0x%08X", gSettings.Devices.FakeID.FakeIMEI);
InputItems[InputItemsCount].ItemType = Hex; //104 InputItems[InputItemsCount].ItemType = Hex; //104
InputItems[InputItemsCount++].SValue.SWPrintf("0x%08X", gSettings.KernelAndKextPatches.FakeCPUID); InputItems[InputItemsCount++].SValue.SWPrintf("0x%08X", gSettings.KernelAndKextPatches.FakeCPUID);
@ -404,9 +404,9 @@ void FillInputs(BOOLEAN New)
InputItems[InputItemsCount++].BValue = gSettings.KernelAndKextPatches.KPKernelXCPM; InputItems[InputItemsCount++].BValue = gSettings.KernelAndKextPatches.KPKernelXCPM;
InputItems[InputItemsCount].ItemType = BoolValue; //106 InputItems[InputItemsCount].ItemType = BoolValue; //106
InputItems[InputItemsCount++].BValue = gSettings.StringInjector; InputItems[InputItemsCount++].BValue = gSettings.Devices.StringInjector;
InputItems[InputItemsCount].ItemType = BoolValue; //107 InputItems[InputItemsCount].ItemType = BoolValue; //107
InputItems[InputItemsCount++].BValue = gSettings.NoDefaultProperties; InputItems[InputItemsCount++].BValue = gSettings.Devices.NoDefaultProperties;
InputItems[InputItemsCount].ItemType = BoolValue; //108 InputItems[InputItemsCount].ItemType = BoolValue; //108
InputItems[InputItemsCount++].BValue = gSettings.KernelPatchesAllowed; InputItems[InputItemsCount++].BValue = gSettings.KernelPatchesAllowed;
@ -419,7 +419,7 @@ void FillInputs(BOOLEAN New)
InputItems[InputItemsCount++].BValue = gSettings.Graphics.NvidiaSingle; InputItems[InputItemsCount++].BValue = gSettings.Graphics.NvidiaSingle;
InputItems[InputItemsCount].ItemType = Hex; //112 InputItems[InputItemsCount].ItemType = Hex; //112
InputItems[InputItemsCount++].SValue.SWPrintf("0x%04X", gSettings.IntelMaxValue); InputItems[InputItemsCount++].SValue.SWPrintf("0x%04X", gSettings.Devices.IntelMaxValue);
InputItems[InputItemsCount].ItemType = BoolValue; //113 InputItems[InputItemsCount].ItemType = BoolValue; //113
InputItems[InputItemsCount++].BValue = gSettings.ACPI.AutoMerge; InputItems[InputItemsCount++].BValue = gSettings.ACPI.AutoMerge;
@ -693,15 +693,15 @@ void ApplyInputs(void)
} }
i++; //58 i++; //58
if (InputItems[i].Valid) { if (InputItems[i].Valid) {
gSettings.AFGLowPowerState = InputItems[i].BValue; gSettings.Devices.Audio.AFGLowPowerState = InputItems[i].BValue;
} }
i++; //59 i++; //59
if (InputItems[i].Valid) { if (InputItems[i].Valid) {
gSettings.HDAInjection = InputItems[i].BValue; gSettings.Devices.Audio.HDAInjection = InputItems[i].BValue;
} }
i++; //60 i++; //60
if (InputItems[i].Valid) { if (InputItems[i].Valid) {
gSettings.HDALayoutId = (UINT32)(StrDecimalToUintn(InputItems[i].SValue.wc_str())); gSettings.Devices.Audio.HDALayoutId = (UINT32)(StrDecimalToUintn(InputItems[i].SValue.wc_str()));
} }
i++; //61 i++; //61
if (InputItems[i].Valid) { if (InputItems[i].Valid) {
@ -775,7 +775,7 @@ void ApplyInputs(void)
i = 74; i = 74;
if (InputItems[i].Valid) { if (InputItems[i].Valid) {
gSettings.USBFixOwnership = InputItems[i].BValue; gSettings.Devices.USB.USBFixOwnership = InputItems[i].BValue;
} }
i++; //75 i++; //75
if (InputItems[i].Valid) { if (InputItems[i].Valid) {
@ -870,40 +870,40 @@ void ApplyInputs(void)
} }
i++; //92 i++; //92
if (InputItems[i].Valid) { if (InputItems[i].Valid) {
gSettings.USBInjection = InputItems[i].BValue; gSettings.Devices.USB.USBInjection = InputItems[i].BValue;
} }
i++; //93 i++; //93
if (InputItems[i].Valid) { if (InputItems[i].Valid) {
gSettings.InjectClockID = InputItems[i].BValue; gSettings.Devices.USB.InjectClockID = InputItems[i].BValue;
} }
i++; //94 i++; //94
if (InputItems[i].Valid) { if (InputItems[i].Valid) {
gSettings.FakeATI = (UINT32)StrHexToUint64(InputItems[i].SValue.wc_str()); gSettings.Devices.FakeID.FakeATI = (UINT32)StrHexToUint64(InputItems[i].SValue.wc_str());
} }
i++; //95 i++; //95
if (InputItems[i].Valid) { if (InputItems[i].Valid) {
gSettings.FakeNVidia = (UINT32)StrHexToUint64(InputItems[i].SValue.wc_str()); gSettings.Devices.FakeID.FakeNVidia = (UINT32)StrHexToUint64(InputItems[i].SValue.wc_str());
} }
i++; //96 i++; //96
if (InputItems[i].Valid) { if (InputItems[i].Valid) {
gSettings.FakeIntel = (UINT32)StrHexToUint64(InputItems[i].SValue.wc_str()); gSettings.Devices.FakeID.FakeIntel = (UINT32)StrHexToUint64(InputItems[i].SValue.wc_str());
DBG("applied FakeIntel=0x%X\n", gSettings.FakeIntel); DBG("applied FakeIntel=0x%X\n", gSettings.Devices.FakeID.FakeIntel);
} }
i++; //97 i++; //97
if (InputItems[i].Valid) { if (InputItems[i].Valid) {
gSettings.FakeLAN = (UINT32)StrHexToUint64(InputItems[i].SValue.wc_str()); gSettings.Devices.FakeID.FakeLAN = (UINT32)StrHexToUint64(InputItems[i].SValue.wc_str());
} }
i++; //98 i++; //98
if (InputItems[i].Valid) { if (InputItems[i].Valid) {
gSettings.FakeWIFI = (UINT32)StrHexToUint64(InputItems[i].SValue.wc_str()); gSettings.Devices.FakeID.FakeWIFI = (UINT32)StrHexToUint64(InputItems[i].SValue.wc_str());
} }
i++; //99 i++; //99
if (InputItems[i].Valid) { if (InputItems[i].Valid) {
gSettings.FakeSATA = (UINT32)StrHexToUint64(InputItems[i].SValue.wc_str()); gSettings.Devices.FakeID.FakeSATA = (UINT32)StrHexToUint64(InputItems[i].SValue.wc_str());
} }
i++; //100 i++; //100
if (InputItems[i].Valid) { if (InputItems[i].Valid) {
gSettings.FakeXHCI = (UINT32)StrHexToUint64(InputItems[i].SValue.wc_str()); gSettings.Devices.FakeID.FakeXHCI = (UINT32)StrHexToUint64(InputItems[i].SValue.wc_str());
} }
i++; //101 - Quirks i++; //101 - Quirks
@ -933,7 +933,7 @@ void ApplyInputs(void)
} }
i++; //103 i++; //103
if (InputItems[i].Valid) { if (InputItems[i].Valid) {
gSettings.FakeIMEI = (UINT32)StrHexToUint64(InputItems[i].SValue.wc_str()); gSettings.Devices.FakeID.FakeIMEI = (UINT32)StrHexToUint64(InputItems[i].SValue.wc_str());
} }
i++; //104 i++; //104
@ -952,12 +952,12 @@ void ApplyInputs(void)
i++; //106 i++; //106
if (InputItems[i].Valid) { if (InputItems[i].Valid) {
gSettings.StringInjector = InputItems[i].BValue; gSettings.Devices.StringInjector = InputItems[i].BValue;
} }
i++; //107 i++; //107
if (InputItems[i].Valid) { if (InputItems[i].Valid) {
gSettings.NoDefaultProperties = InputItems[i].BValue; gSettings.Devices.NoDefaultProperties = InputItems[i].BValue;
} }
i++; //108 i++; //108
@ -983,7 +983,7 @@ void ApplyInputs(void)
} }
i++; //112 i++; //112
if (InputItems[i].Valid) { if (InputItems[i].Valid) {
gSettings.IntelMaxValue = (UINT16)StrHexToUint64(InputItems[i].SValue.wc_str()); gSettings.Devices.IntelMaxValue = (UINT16)StrHexToUint64(InputItems[i].SValue.wc_str());
} }
i++; //113 i++; //113
if (InputItems[i].Valid) { if (InputItems[i].Valid) {
@ -1573,7 +1573,7 @@ REFIT_ABSTRACT_MENU_ENTRY *SubMenuGraphics()
SubScreen->AddMenuItemInput(53, "Fake Vendor EDID:", TRUE); SubScreen->AddMenuItemInput(53, "Fake Vendor EDID:", TRUE);
SubScreen->AddMenuItemInput(54, "Fake Product EDID:", TRUE); SubScreen->AddMenuItemInput(54, "Fake Product EDID:", TRUE);
SubScreen->AddMenuItemInput(18, "Backlight Level:", TRUE); SubScreen->AddMenuItemInput(18, "Backlight Level:", TRUE);
SubScreen->AddMenuItemInput(112, "Intel Max Backlight:", TRUE); //gSettings.IntelMaxValue SubScreen->AddMenuItemInput(112, "Intel Max Backlight:", TRUE); //gSettings.Devices.IntelMaxValue
for (UINTN i = 0; i < NGFX; i++) { for (UINTN i = 0; i < NGFX; i++) {
@ -1670,7 +1670,7 @@ REFIT_ABSTRACT_MENU_ENTRY *SubMenuAudio()
} }
//SubScreen->AddMenuItemInput(59, "HDAInjection", FALSE); //SubScreen->AddMenuItemInput(59, "HDAInjection", FALSE);
if (gSettings.HDAInjection) { if (gSettings.Devices.Audio.HDAInjection) {
SubScreen->AddMenuItemInput(60, "HDALayoutId:", TRUE); SubScreen->AddMenuItemInput(60, "HDALayoutId:", TRUE);
} }
@ -2218,37 +2218,37 @@ REFIT_ABSTRACT_MENU_ENTRY* SubMenuCustomDevices()
Entry = newREFIT_MENU_ITEM_OPTIONS(&SubScreen, ActionEnter, SCREEN_DEVICES, "Custom properties->"_XS8); Entry = newREFIT_MENU_ITEM_OPTIONS(&SubScreen, ActionEnter, SCREEN_DEVICES, "Custom properties->"_XS8);
if (gSettings.ArbProperties) { if (gSettings.Devices.ArbProperties) {
DEV_PROPERTY *Prop = gSettings.ArbProperties; DEV_PROPERTY *Prop = gSettings.Devices.ArbProperties;
if (Prop && (Prop->Device == 0)) if (Prop && (Prop->Device == 0))
{ {
DEV_PROPERTY *Props = NULL; DEV_PROPERTY *Props = NULL;
while (Prop) { while (Prop) {
SubScreen->AddMenuInfo_f("------------");
SubScreen->AddMenuInfo_f("%s", Prop->Label);
Props = Prop->Child;
while (Props) {
CreateMenuProps(SubScreen, Props);
Props = Props->Next;
}
Prop = Prop->Next;
}
}
while (Prop) {
DevAddr = Prop->Device;
if (DevAddr != 0 && DevAddr != OldDevAddr) {
OldDevAddr = DevAddr;
SubScreen->AddMenuInfo_f("------------"); SubScreen->AddMenuInfo_f("------------");
SubScreen->AddMenuInfo_f("%s", Prop->Label); SubScreen->AddMenuInfo_f("%s", Prop->Label);
CreateMenuProps(SubScreen, Prop); Props = Prop->Child;
while (Props) {
CreateMenuProps(SubScreen, Props);
Props = Props->Next;
}
Prop = Prop->Next;
} }
Prop = Prop->Next;
} }
while (Prop) {
DevAddr = Prop->Device;
if (DevAddr != 0 && DevAddr != OldDevAddr) {
OldDevAddr = DevAddr;
SubScreen->AddMenuInfo_f("------------");
SubScreen->AddMenuInfo_f("%s", Prop->Label);
CreateMenuProps(SubScreen, Prop);
}
Prop = Prop->Next;
}
}
SubScreen->AddMenuEntry(&MenuEntryReturn, false);
Entry->SubScreen = SubScreen;
return Entry;
} }
SubScreen->AddMenuEntry(&MenuEntryReturn, false);
Entry->SubScreen = SubScreen;
return Entry;
}
REFIT_ABSTRACT_MENU_ENTRY* SubMenuPCI() REFIT_ABSTRACT_MENU_ENTRY* SubMenuPCI()