repaired system info

Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
Sergey Isakov 2020-04-10 10:15:36 +03:00
parent 92ecdbf630
commit d74b431b6f
17 changed files with 130 additions and 107 deletions

View File

@ -1068,7 +1068,7 @@ VOID findCPU(UINT8* dsdt, UINT32 length)
if (!acpi_cpu_count) { if (!acpi_cpu_count) {
for (i=0; i < acpi_cpu_max; i++) { for (i=0; i < acpi_cpu_max; i++) {
acpi_cpu_name[i] = (__typeof_am__(acpi_cpu_name[i]))AllocateZeroPool(5); acpi_cpu_name[i] = (__typeof_am__(acpi_cpu_name[i]))AllocateZeroPool(5);
snprintf(acpi_cpu_name[i], 5, "CPU%1X", i); AsciiSPrint(acpi_cpu_name[i], 5, "CPU%1x", i);
acpi_cpu_processor_id[i] = (UINT8)(i & 0x7F); acpi_cpu_processor_id[i] = (UINT8)(i & 0x7F);
} }
} }
@ -2438,7 +2438,7 @@ UINT32 FIXLPCB (UINT8 *dsdt, UINT32 len)
pack = aml_add_package(met); pack = aml_add_package(met);
aml_add_string(pack, "device-id"); aml_add_string(pack, "device-id");
aml_add_byte_buffer(pack, dataLPC, 4); aml_add_byte_buffer(pack, dataLPC, 4);
snprintf(NameCard, sizeof(NameCard), "pci8086,3a18"); AsciiSPrint(NameCard, sizeof(NameCard), "pci8086,3a18");
aml_add_string(pack, "name"); aml_add_string(pack, "name");
aml_add_string_buffer(pack, &NameCard[0]); aml_add_string_buffer(pack, &NameCard[0]);
aml_add_string(pack, "compatible"); aml_add_string(pack, "compatible");
@ -2961,7 +2961,7 @@ UINT32 FIXNetwork (UINT8 *dsdt, UINT32 len, UINT32 card)
if (gSettings.FakeLAN) { if (gSettings.FakeLAN) {
FakeID = gSettings.FakeLAN >> 16; FakeID = gSettings.FakeLAN >> 16;
FakeVen = gSettings.FakeLAN & 0xFFFF; FakeVen = gSettings.FakeLAN & 0xFFFF;
snprintf(NameCard, 32, "pci%X,%X", FakeVen, FakeID); AsciiSPrint(NameCard, 32, "pci%04x,%04x", FakeVen, FakeID);
LowCase(NameCard); LowCase(NameCard);
Netmodel[card] = get_net_model((FakeVen << 16) + FakeID); Netmodel[card] = get_net_model((FakeVen << 16) + FakeID);
} }
@ -3164,7 +3164,7 @@ UINT32 FIXAirport (UINT8 *dsdt, UINT32 len)
if (gSettings.FakeWIFI) { if (gSettings.FakeWIFI) {
FakeID = gSettings.FakeWIFI >> 16; FakeID = gSettings.FakeWIFI >> 16;
FakeVen = gSettings.FakeWIFI & 0xFFFF; FakeVen = gSettings.FakeWIFI & 0xFFFF;
snprintf(NameCard, 32, "pci%X,%X", FakeVen, FakeID); AsciiSPrint(NameCard, 32, "pci%04x,%04x", FakeVen, FakeID);
LowCase(NameCard); LowCase(NameCard);
} }
@ -4081,18 +4081,18 @@ UINT32 FIXUSB (UINT8 *dsdt, UINT32 len)
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.NameXH00) {
snprintf(UsbName[i], 5, "XH%02llX", XhciCount++); AsciiSPrint(UsbName[i], 5, "XH%02x", XhciCount++);
} else { } else {
snprintf(UsbName[i], 5, "XHC%01llX", XhciCount++); AsciiSPrint(UsbName[i], 5, "XHC%01x", XhciCount++);
} }
} else if (USB20[i]) { } else if (USB20[i]) {
if (gSettings.NameEH00) { if (gSettings.NameEH00) {
snprintf(UsbName[i], 5, "EH%02llX", EhciCount++); AsciiSPrint(UsbName[i], 5, "EH%02x", EhciCount++);
} else { } else {
snprintf(UsbName[i], 5, "EHC%01llX", EhciCount++); AsciiSPrint(UsbName[i], 5, "EHC%01x", EhciCount++);
} }
} else { } else {
snprintf(UsbName[i], 5, "USB%d", i); AsciiSPrint(UsbName[i], 5, "USB%01d", i);
} }
DBG(" %s\n", UsbName[i]); DBG(" %s\n", UsbName[i]);
ReplaceName(dsdt + adr1, Size, device_name[10], UsbName[i]); ReplaceName(dsdt + adr1, Size, device_name[10], UsbName[i]);

View File

@ -36,6 +36,7 @@ extern "C" {
#include <Library/HdaModels.h> #include <Library/HdaModels.h>
#include <Library/MemoryAllocationLib.h> #include <Library/MemoryAllocationLib.h>
#include <Library/PcdLib.h> #include <Library/PcdLib.h>
#include <Library/PrintLib.h>
#include <Library/PerformanceLib.h> #include <Library/PerformanceLib.h>
#include <Library/PeCoffGetEntryPointLib.h> #include <Library/PeCoffGetEntryPointLib.h>
#include <Library/TimerLib.h> #include <Library/TimerLib.h>

View File

@ -49,6 +49,7 @@ const char* strerror(EFI_STATUS Status)
return stdio_static_buf.data(); return stdio_static_buf.data();
} }
//this function print guid in LittleEndian format while we need BigEndian as Apple do
const char* strguid(EFI_GUID* guid) const char* strguid(EFI_GUID* guid)
{ {
UINTN n = 0; UINTN n = 0;

View File

@ -5566,17 +5566,17 @@ ParseSMBIOSSettings(
} else if ((i[3] == j[3]) && (i[4] == j[4])) { } else if ((i[3] == j[3]) && (i[4] == j[4])) {
//DBG ("Found same BiosReleaseDate in clover and config\n"); //DBG ("Found same BiosReleaseDate in clover and config\n");
} else { } else {
snprintf (Res1, 9, "%c%c/%c%c/%c%c\n", j[0], j[1], j[3], j[4], j[8], j[9]); AsciiSPrint (Res1, 9, "%c%c/%c%c/%c%c\n", j[0], j[1], j[3], j[4], j[8], j[9]);
AsciiStrCpyS (gSettings.ReleaseDate, 64, Res1); AsciiStrCpyS (gSettings.ReleaseDate, 64, Res1);
//DBG ("Using latest BiosReleaseDate from config\n"); //DBG ("Using latest BiosReleaseDate from config\n");
} }
} else { } else {
snprintf (Res1, 9, "%c%c/%c%c/%c%c\n", j[0], j[1], j[3], j[4], j[8], j[9]); AsciiSPrint (Res1, 9, "%c%c/%c%c/%c%c\n", j[0], j[1], j[3], j[4], j[8], j[9]);
AsciiStrCpyS (gSettings.ReleaseDate, 64, Res1); AsciiStrCpyS (gSettings.ReleaseDate, 64, Res1);
//DBG ("Using latest BiosReleaseDate from config\n"); //DBG ("Using latest BiosReleaseDate from config\n");
} }
} else { } else {
snprintf (Res1, 9, "%c%c/%c%c/%c%c\n", j[0], j[1], j[3], j[4], j[8], j[9]); AsciiSPrint (Res1, 9, "%c%c/%c%c/%c%c\n", j[0], j[1], j[3], j[4], j[8], j[9]);
AsciiStrCpyS (gSettings.ReleaseDate, 64, Res1); AsciiStrCpyS (gSettings.ReleaseDate, 64, Res1);
//DBG ("Using latest BiosReleaseDate from config\n"); //DBG ("Using latest BiosReleaseDate from config\n");
} }
@ -5623,17 +5623,17 @@ ParseSMBIOSSettings(
} else if ((i[3] == j[3]) && (i[4] == j[4])) { } else if ((i[3] == j[3]) && (i[4] == j[4])) {
//DBG ("Found same BiosReleaseDate in clover and config\n"); //DBG ("Found same BiosReleaseDate in clover and config\n");
} else { } else {
snprintf (Res2, 11, "%c%c/%c%c/20%c%c\n", j[0], j[1], j[3], j[4], j[6], j[7]); AsciiSPrint (Res2, 11, "%c%c/%c%c/20%c%c\n", j[0], j[1], j[3], j[4], j[6], j[7]);
AsciiStrCpyS (gSettings.ReleaseDate, 64, Res2); AsciiStrCpyS (gSettings.ReleaseDate, 64, Res2);
//DBG ("Using latest BiosReleaseDate from config\n"); //DBG ("Using latest BiosReleaseDate from config\n");
} }
} else { } else {
snprintf (Res2, 11, "%c%c/%c%c/20%c%c\n", j[0], j[1], j[3], j[4], j[6], j[7]); AsciiSPrint (Res2, 11, "%c%c/%c%c/20%c%c\n", j[0], j[1], j[3], j[4], j[6], j[7]);
AsciiStrCpyS (gSettings.ReleaseDate, 64, Res2); AsciiStrCpyS (gSettings.ReleaseDate, 64, Res2);
//DBG ("Using latest BiosReleaseDate from config\n"); //DBG ("Using latest BiosReleaseDate from config\n");
} }
} else { } else {
snprintf (Res2, 11, "%c%c/%c%c/20%c%c\n", j[0], j[1], j[3], j[4], j[6], j[7]); AsciiSPrint (Res2, 11, "%c%c/%c%c/20%c%c\n", j[0], j[1], j[3], j[4], j[6], j[7]);
AsciiStrCpyS (gSettings.ReleaseDate, 64, Res2); AsciiStrCpyS (gSettings.ReleaseDate, 64, Res2);
//DBG ("Using latest BiosReleaseDate from config\n"); //DBG ("Using latest BiosReleaseDate from config\n");
} }
@ -5649,11 +5649,11 @@ ParseSMBIOSSettings(
} }
if ((AsciiStrLen(i) == 8)) { if ((AsciiStrLen(i) == 8)) {
snprintf (Res1, 9, "%c%c/%c%c/%c%c\n", j[3], j[4], j[5], j[6], j[1], j[2]); AsciiSPrint (Res1, 9, "%c%c/%c%c/%c%c\n", j[3], j[4], j[5], j[6], j[1], j[2]);
AsciiStrCpyS (gSettings.ReleaseDate, 64, Res1); AsciiStrCpyS (gSettings.ReleaseDate, 64, Res1);
//DBG ("Using the date of used BiosVersion\n"); //DBG ("Using the date of used BiosVersion\n");
} else if ((AsciiStrLen(i) == 10)) { } else if ((AsciiStrLen(i) == 10)) {
snprintf (Res2, 11, "%c%c/%c%c/20%c%c\n", j[3], j[4], j[5], j[6], j[1], j[2]); AsciiSPrint (Res2, 11, "%c%c/%c%c/20%c%c\n", j[3], j[4], j[5], j[6], j[1], j[2]);
AsciiStrCpyS (gSettings.ReleaseDate, 64, Res2); AsciiStrCpyS (gSettings.ReleaseDate, 64, Res2);
//DBG ("Using the date of used BiosVersion\n"); //DBG ("Using the date of used BiosVersion\n");
} }
@ -5676,11 +5676,11 @@ ParseSMBIOSSettings(
} }
if ((AsciiStrLen(i) == 8)) { if ((AsciiStrLen(i) == 8)) {
snprintf (Res1, 9, "%c%c/%c%c/%c%c\n", j[3], j[4], j[5], j[6], j[1], j[2]); AsciiSPrint (Res1, 9, "%c%c/%c%c/%c%c\n", j[3], j[4], j[5], j[6], j[1], j[2]);
AsciiStrCpyS (gSettings.ReleaseDate, 64, Res1); AsciiStrCpyS (gSettings.ReleaseDate, 64, Res1);
//DBG ("BiosReleaseDate: not set, Using the date of used BiosVersion\n"); //DBG ("BiosReleaseDate: not set, Using the date of used BiosVersion\n");
} else if ((AsciiStrLen(i) == 10)) { } else if ((AsciiStrLen(i) == 10)) {
snprintf (Res2, 11, "%c%c/%c%c/20%c%c\n", j[3], j[4], j[5], j[6], j[1], j[2]); AsciiSPrint (Res2, 11, "%c%c/%c%c/20%c%c\n", j[3], j[4], j[5], j[6], j[1], j[2]);
AsciiStrCpyS (gSettings.ReleaseDate, 64, Res2); AsciiStrCpyS (gSettings.ReleaseDate, 64, Res2);
//DBG ("BiosReleaseDate: not set, Using the date of used BiosVersion\n"); //DBG ("BiosReleaseDate: not set, Using the date of used BiosVersion\n");
} }
@ -6171,7 +6171,7 @@ GetUserSettings(
Dev = hexstrtouint8(&Str[3]); Dev = hexstrtouint8(&Str[3]);
Func = hexstrtouint8(&Str[6]); Func = hexstrtouint8(&Str[6]);
DeviceAddr = PCIADDR(Bus, Dev, Func); DeviceAddr = PCIADDR(Bus, Dev, Func);
snprintf(Label, 64, "[%02llX:%02llX.%02llX] ", Bus, Dev, Func); AsciiSPrint(Label, 64, "[%02x:%02x.%02x] ", Bus, Dev, Func);
DBG(" %s", Label); DBG(" %s", Label);
} else { } else {
DBG (" no PciAddr\n"); DBG (" no PciAddr\n");
@ -7201,7 +7201,7 @@ GetUserSettings(
if (Prop2 && (Prop2->type == kTagTypeString) && Prop2->string) { if (Prop2 && (Prop2->type == kTagTypeString) && Prop2->string) {
snprintf (SlotDevice->SlotName, 31, "%s", Prop2->string); snprintf (SlotDevice->SlotName, 31, "%s", Prop2->string);
} else { } else {
snprintf (SlotDevice->SlotName, 31, "PCI Slot %lld", DeviceN); AsciiSPrint (SlotDevice->SlotName, 31, "PCI Slot %d", DeviceN);
} }
DBG (" - %s\n", SlotDevice->SlotName); DBG (" - %s\n", SlotDevice->SlotName);
@ -7717,49 +7717,49 @@ CHAR8 *GetOSVersion(IN LOADER_ENTRY *Entry)
// s = SearchString(targetString, fileLen, "Running OS Build: Mac OS X ", 27); // s = SearchString(targetString, fileLen, "Running OS Build: Mac OS X ", 27);
s = AsciiStrStr(targetString, "Running OS Build: Mac OS X "); s = AsciiStrStr(targetString, "Running OS Build: Mac OS X ");
if (s[31] == ' ') { if (s[31] == ' ') {
snprintf (Res5, 5, "%c%c.%c\n", s[27], s[28], s[30]); AsciiSPrint (Res5, 5, "%c%c.%c\n", s[27], s[28], s[30]);
OSVersion = (__typeof__(OSVersion))AllocateCopyPool (AsciiStrSize (Res5), Res5); OSVersion = (__typeof__(OSVersion))AllocateCopyPool (AsciiStrSize (Res5), Res5);
if (s[38] == ')') { if (s[38] == ')') {
snprintf (Res6, 6, "%c%c%c%c%c\n", s[33], s[34], s[35], s[36], s[37]); AsciiSPrint (Res6, 6, "%c%c%c%c%c\n", s[33], s[34], s[35], s[36], s[37]);
Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Res6), Res6); Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Res6), Res6);
} else if (s[39] == ')') { } else if (s[39] == ')') {
snprintf (Res7, 7, "%c%c%c%c%c%c\n", s[33], s[34], s[35], s[36], s[37], s[38]); AsciiSPrint (Res7, 7, "%c%c%c%c%c%c\n", s[33], s[34], s[35], s[36], s[37], s[38]);
Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Res7), Res7); Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Res7), Res7);
} }
} else if (s[31] == '.') { } else if (s[31] == '.') {
snprintf (Res7, 7, "%c%c.%c.%c\n", s[27], s[28], s[30], s[32]); AsciiSPrint (Res7, 7, "%c%c.%c.%c\n", s[27], s[28], s[30], s[32]);
OSVersion = (__typeof__(OSVersion))AllocateCopyPool (AsciiStrSize (Res7), Res7); OSVersion = (__typeof__(OSVersion))AllocateCopyPool (AsciiStrSize (Res7), Res7);
if (s[40] == ')') { if (s[40] == ')') {
snprintf (Res6, 6, "%c%c%c%c%c\n", s[35], s[36], s[37], s[38], s[39]); AsciiSPrint (Res6, 6, "%c%c%c%c%c\n", s[35], s[36], s[37], s[38], s[39]);
Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Res6), Res6); Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Res6), Res6);
} else if (s[41] == ')') { } else if (s[41] == ')') {
snprintf (Res7, 7, "%c%c%c%c%c%c\n", s[35], s[36], s[37], s[38], s[39], s[40]); AsciiSPrint (Res7, 7, "%c%c%c%c%c%c\n", s[35], s[36], s[37], s[38], s[39], s[40]);
Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Res7), Res7); Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Res7), Res7);
} }
} else if (s[32] == ' ') { } else if (s[32] == ' ') {
snprintf (Res6, 6, "%c%c.%c%c\n", s[27], s[28], s[30], s[31]); AsciiSPrint (Res6, 6, "%c%c.%c%c\n", s[27], s[28], s[30], s[31]);
OSVersion = (__typeof__(OSVersion))AllocateCopyPool (AsciiStrSize (Res6), Res6); OSVersion = (__typeof__(OSVersion))AllocateCopyPool (AsciiStrSize (Res6), Res6);
if (s[39] == ')') { if (s[39] == ')') {
snprintf (Res6, 6, "%c%c%c%c%c\n", s[34], s[35], s[36], s[37], s[38]); AsciiSPrint (Res6, 6, "%c%c%c%c%c\n", s[34], s[35], s[36], s[37], s[38]);
Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Res6), Res6); Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Res6), Res6);
} else if (s[40] == ')') { } else if (s[40] == ')') {
snprintf (Res7, 7, "%c%c%c%c%c%c\n", s[34], s[35], s[36], s[37], s[38], s[39]); AsciiSPrint (Res7, 7, "%c%c%c%c%c%c\n", s[34], s[35], s[36], s[37], s[38], s[39]);
Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Res7), Res7); Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Res7), Res7);
} else if (s[41] == ')') { } else if (s[41] == ')') {
snprintf (Res8, 8, "%c%c%c%c%c%c%c\n", s[34], s[35], s[36], s[37], s[38], s[39], s[40]); AsciiSPrint (Res8, 8, "%c%c%c%c%c%c%c\n", s[34], s[35], s[36], s[37], s[38], s[39], s[40]);
Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Res8), Res8); Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Res8), Res8);
} }
} else if (s[32] == '.') { } else if (s[32] == '.') {
snprintf (Res8, 8, "%c%c.%c%c.%c\n", s[27], s[28], s[30], s[31], s[33]); AsciiSPrint (Res8, 8, "%c%c.%c%c.%c\n", s[27], s[28], s[30], s[31], s[33]);
OSVersion = (__typeof__(OSVersion))AllocateCopyPool (AsciiStrSize (Res8), Res8); OSVersion = (__typeof__(OSVersion))AllocateCopyPool (AsciiStrSize (Res8), Res8);
if (s[41] == ')') { if (s[41] == ')') {
snprintf (Res6, 6, "%c%c%c%c%c\n", s[36], s[37], s[38], s[39], s[40]); AsciiSPrint (Res6, 6, "%c%c%c%c%c\n", s[36], s[37], s[38], s[39], s[40]);
Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Res6), Res6); Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Res6), Res6);
} else if (s[42] == ')') { } else if (s[42] == ')') {
snprintf (Res7, 7, "%c%c%c%c%c%c\n", s[36], s[37], s[38], s[39], s[40], s[41]); AsciiSPrint (Res7, 7, "%c%c%c%c%c%c\n", s[36], s[37], s[38], s[39], s[40], s[41]);
Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Res7), Res7); Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Res7), Res7);
} else if (s[43] == ')') { } else if (s[43] == ')') {
snprintf (Res8, 8, "%c%c%c%c%c%c%c\n", s[36], s[37], s[38], s[39], s[40], s[41], s[42]); AsciiSPrint (Res8, 8, "%c%c%c%c%c%c%c\n", s[36], s[37], s[38], s[39], s[40], s[41], s[42]);
Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Res8), Res8); Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Res8), Res8);
} }
} }
@ -8160,13 +8160,13 @@ GetDevices ()
} }
snprintf ( snprintf (
gfx->Model, gfx->Model,
64, 64,
"%s", "%s",
get_nvidia_model (((Pci.Hdr.VendorId << 16) | Pci.Hdr.DeviceId), get_nvidia_model (((Pci.Hdr.VendorId << 16) | Pci.Hdr.DeviceId),
((Pci.Device.SubsystemVendorID << 16) | Pci.Device.SubsystemID), ((Pci.Device.SubsystemVendorID << 16) | Pci.Device.SubsystemID),
NULL) //NULL: get from generic lists NULL) //NULL: get from generic lists
); );
DBG(" - GFX: Model=%s family %X (%s)\n", gfx->Model, gfx->Family, CardFamily); DBG(" - GFX: Model=%s family %X (%s)\n", gfx->Model, gfx->Family, CardFamily);
gfx->Ports = 0; gfx->Ports = 0;
@ -8183,7 +8183,8 @@ GetDevices ()
default: default:
gfx->Vendor = Unknown; gfx->Vendor = Unknown;
snprintf (gfx->Model, 64, "pci%X,%X", Pci.Hdr.VendorId, Pci.Hdr.DeviceId); AsciiSPrint (gfx->Model, 64, "pci%04x,%04x", Pci.Hdr.VendorId, Pci.Hdr.DeviceId);
LowCase(gfx->Model);
gfx->Ports = 1; gfx->Ports = 1;
gfx->Connectors = (1 << NGFX); gfx->Connectors = (1 << NGFX);
gfx->ConnChanged = FALSE; gfx->ConnChanged = FALSE;

View File

@ -339,10 +339,10 @@ SSDT_TABLE *generate_pss_ssdt(UINTN Number)
AML_CHUNK* metPCT; AML_CHUNK* metPCT;
AML_CHUNK* root = aml_create_node(NULL); AML_CHUNK* root = aml_create_node(NULL);
aml_add_buffer(root, (UINT8*)&pss_ssdt_header[0], sizeof(pss_ssdt_header)); // SSDT header aml_add_buffer(root, (UINT8*)&pss_ssdt_header[0], sizeof(pss_ssdt_header)); // SSDT header
snprintf(name, 31, "%s%4s", acpi_cpu_score, acpi_cpu_name[0]); AsciiSPrint(name, 31, "%a%4a", acpi_cpu_score, acpi_cpu_name[0]);
snprintf(name1, 31, "%s%4sPSS_", acpi_cpu_score, acpi_cpu_name[0]); AsciiSPrint(name1, 31, "%a%4aPSS_", acpi_cpu_score, acpi_cpu_name[0]);
snprintf(name2, 31, "%s%4sPCT_", acpi_cpu_score, acpi_cpu_name[0]); AsciiSPrint(name2, 31, "%a%4aPCT_", acpi_cpu_score, acpi_cpu_name[0]);
snprintf(name3, 31, "%s%4s_PPC", acpi_cpu_score, acpi_cpu_name[0]); AsciiSPrint(name3, 31, "%a%4a_PPC", acpi_cpu_score, acpi_cpu_name[0]);
scop = aml_add_scope(root, name); scop = aml_add_scope(root, name);
@ -406,7 +406,7 @@ SSDT_TABLE *generate_pss_ssdt(UINTN Number)
// Add CPUs // Add CPUs
for (decltype(Number) i = 1; i < Number; i++) { for (decltype(Number) i = 1; i < Number; i++) {
snprintf(name, 31, "%s%4s", acpi_cpu_score, acpi_cpu_name[i]); AsciiSPrint(name, 31, "%a%4a", acpi_cpu_score, acpi_cpu_name[i]);
scop = aml_add_scope(root, name); scop = aml_add_scope(root, name);
metPSS = aml_add_method(scop, "_PSS", 0); metPSS = aml_add_method(scop, "_PSS", 0);
aml_add_return_name(metPSS, name1); aml_add_return_name(metPSS, name1);
@ -488,8 +488,8 @@ SSDT_TABLE *generate_cst_ssdt(EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE* fadt, U
root = aml_create_node(NULL); root = aml_create_node(NULL);
aml_add_buffer(root, cst_ssdt_header, sizeof(cst_ssdt_header)); // SSDT header aml_add_buffer(root, cst_ssdt_header, sizeof(cst_ssdt_header)); // SSDT header
snprintf(name0, 31, "%s%4s", acpi_cpu_score, acpi_cpu_name[0]); AsciiSPrint(name0, 31, "%a%4a", acpi_cpu_score, acpi_cpu_name[0]);
snprintf(name1, 31, "%s%4sCST_", acpi_cpu_score, acpi_cpu_name[0]); AsciiSPrint(name1, 31, "%a%4aCST_", acpi_cpu_score, acpi_cpu_name[0]);
scop = aml_add_scope(root, name0); scop = aml_add_scope(root, name0);
name = aml_add_name(scop, "CST_"); name = aml_add_name(scop, "CST_");
pack = aml_add_package(name); pack = aml_add_package(name);
@ -632,7 +632,7 @@ SSDT_TABLE *generate_cst_ssdt(EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE* fadt, U
// Aliases // Aliases
for (i = 1; i < Number; i++) { for (i = 1; i < Number; i++) {
snprintf(name2, 31, "%s%4s", acpi_cpu_score, acpi_cpu_name[i]); AsciiSPrint(name2, 31, "%a%4a", acpi_cpu_score, acpi_cpu_name[i]);
scop = aml_add_scope(root, name2); scop = aml_add_scope(root, name2);
met = aml_add_method(scop, "_CST", 0); met = aml_add_method(scop, "_CST", 0);

View File

@ -1322,7 +1322,7 @@ BOOLEAN get_name_pci_val(value_t *val, INTN index, BOOLEAN Sier)
return FALSE; return FALSE;
} }
snprintf(pciName, 15, "pci1002,%X", gSettings.FakeATI >> 16); AsciiSPrint(pciName, 15, "pci1002,%04x", gSettings.FakeATI >> 16);
LowCase(pciName); LowCase(pciName);
val->type = kStr; val->type = kStr;
val->size = 13; val->size = 13;
@ -1343,25 +1343,25 @@ BOOLEAN get_model_val(value_t *val, INTN index, BOOLEAN Sier)
} else { } else {
switch (card->pci_dev->revision) { switch (card->pci_dev->revision) {
case 0xC4: case 0xC4:
snprintf(ModelName, 35, "AMD Radeon %s", "Pro 550"); AsciiSPrint(ModelName, 35, "AMD Radeon %a", "Pro 550");
break; break;
case 0xC7: case 0xC7:
snprintf(ModelName, 35, "AMD Radeon %s", "RX 480"); AsciiSPrint(ModelName, 35, "AMD Radeon %a", "RX 480");
break; break;
case 0xC5: case 0xC5:
case 0xCF: case 0xCF:
case 0xD7: case 0xD7:
case 0xE0: case 0xE0:
snprintf(ModelName, 35, "AMD Radeon %s", "RX 470"); AsciiSPrint(ModelName, 35, "AMD Radeon %a", "RX 470");
break; break;
case 0xC2: case 0xC2:
case 0xC6: case 0xC6:
case 0xEF: case 0xEF:
snprintf(ModelName, 35, "AMD Radeon %s", "RX 570"); AsciiSPrint(ModelName, 35, "AMD Radeon %a", "RX 570");
break; break;
default: default:
snprintf(ModelName, 35, "AMD Radeon %s", "RX 580"); AsciiSPrint(ModelName, 35, "AMD Radeon %a", "RX 580");
break; break;
} }
val->size = (UINT32)AsciiStrLen(ModelName); val->size = (UINT32)AsciiStrLen(ModelName);
@ -2062,13 +2062,13 @@ static BOOLEAN init_card(pci_dt_t *pci_dev)
} }
// //
name = (__typeof__(name))AllocateZeroPool(24); name = (__typeof__(name))AllocateZeroPool(24);
snprintf(name, 24, "ATY,%s", card->cfg_name); AsciiSPrint(name, 24, "ATY,%a", card->cfg_name);
aty_name.type = kStr; aty_name.type = kStr;
aty_name.size = (UINT32)AsciiStrLen(name); aty_name.size = (UINT32)AsciiStrLen(name);
aty_name.data = (UINT8 *)name; aty_name.data = (UINT8 *)name;
name_parent = (__typeof__(name_parent))AllocateZeroPool(24); name_parent = (__typeof__(name_parent))AllocateZeroPool(24);
snprintf(name_parent, 24, "ATY,%sParent", card->cfg_name); AsciiSPrint(name_parent, 24, "ATY,%aParent", card->cfg_name);
aty_nameparent.type = kStr; aty_nameparent.type = kStr;
aty_nameparent.size = (UINT32)AsciiStrLen(name_parent); aty_nameparent.size = (UINT32)AsciiStrLen(name_parent);
aty_nameparent.data = (UINT8 *)name_parent; aty_nameparent.data = (UINT8 *)name_parent;
@ -2113,7 +2113,7 @@ BOOLEAN setup_ati_devprop(LOADER_ENTRY *Entry, pci_dt_t *ati_dev)
FakeID = gSettings.FakeATI >> 16; FakeID = gSettings.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,%04X", FakeID); AsciiSPrint(compatible, 64, "pci1002,%04x", FakeID);
LowCase(compatible); LowCase(compatible);
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.FakeATI & 0xFFFF;

View File

@ -78,7 +78,7 @@ VOID AddCard(CONST CHAR8* Model, UINT32 Id, UINT32 SubId, UINT64 VideoRam, UINTN
new_card->VideoRam = VideoRam; new_card->VideoRam = VideoRam;
new_card->VideoPorts = VideoPorts; new_card->VideoPorts = VideoPorts;
new_card->LoadVBios = LoadVBios; new_card->LoadVBios = LoadVBios;
snprintf(new_card->Model, 64, "%s", Model); AsciiSPrint(new_card->Model, 64, "%a", Model);
InsertTailList (&gCardList, (LIST_ENTRY *)(((UINT8 *)new_card) + OFFSET_OF(CARDLIST, Link))); InsertTailList (&gCardList, (LIST_ENTRY *)(((UINT8 *)new_card) + OFFSET_OF(CARDLIST, Link)));
} }
} }

View File

@ -285,17 +285,17 @@ CHAR8 *devprop_generate_string(DevPropString *StringBuf)
if(!buffer) if(!buffer)
return NULL; return NULL;
snprintf(buffer, len, "%08X%08X%04X%04X", SwapBytes32(StringBuf->length), StringBuf->WHAT2, AsciiSPrint(buffer, len, "%08X%08X%04X%04X", SwapBytes32(StringBuf->length), StringBuf->WHAT2,
SwapBytes16(StringBuf->numentries), StringBuf->WHAT3); SwapBytes16(StringBuf->numentries), StringBuf->WHAT3);
buffer += 24; buffer += 24;
while(i < StringBuf->numentries) { while(i < StringBuf->numentries) {
UINT8 *dataptr = StringBuf->entries[i]->data; UINT8 *dataptr = StringBuf->entries[i]->data;
snprintf(buffer, len, "%08X%04X%04X", SwapBytes32(StringBuf->entries[i]->length), AsciiSPrint(buffer, len, "%08X%04X%04X", SwapBytes32(StringBuf->entries[i]->length),
SwapBytes16(StringBuf->entries[i]->numentries), StringBuf->entries[i]->WHAT2); //FIXME: wrong buffer sizes! SwapBytes16(StringBuf->entries[i]->numentries), StringBuf->entries[i]->WHAT2); //FIXME: wrong buffer sizes!
buffer += 16; buffer += 16;
snprintf(buffer, len, "%02X%02X%04X%08X%08X", StringBuf->entries[i]->acpi_dev_path.type, AsciiSPrint(buffer, len, "%02X%02X%04X%08X%08X", StringBuf->entries[i]->acpi_dev_path.type,
StringBuf->entries[i]->acpi_dev_path.subtype, StringBuf->entries[i]->acpi_dev_path.subtype,
SwapBytes16(StringBuf->entries[i]->acpi_dev_path.length), SwapBytes16(StringBuf->entries[i]->acpi_dev_path.length),
SwapBytes32(StringBuf->entries[i]->acpi_dev_path._HID), SwapBytes32(StringBuf->entries[i]->acpi_dev_path._HID),
@ -303,7 +303,7 @@ CHAR8 *devprop_generate_string(DevPropString *StringBuf)
buffer += 24; buffer += 24;
for(x = 0; x < StringBuf->entries[i]->num_pci_devpaths; x++) { for(x = 0; x < StringBuf->entries[i]->num_pci_devpaths; x++) {
snprintf(buffer, len, "%02X%02X%04X%02X%02X", StringBuf->entries[i]->pci_dev_path[x].type, AsciiSPrint(buffer, len, "%02X%02X%04X%02X%02X", StringBuf->entries[i]->pci_dev_path[x].type,
StringBuf->entries[i]->pci_dev_path[x].subtype, StringBuf->entries[i]->pci_dev_path[x].subtype,
SwapBytes16(StringBuf->entries[i]->pci_dev_path[x].length), SwapBytes16(StringBuf->entries[i]->pci_dev_path[x].length),
StringBuf->entries[i]->pci_dev_path[x].function, StringBuf->entries[i]->pci_dev_path[x].function,
@ -311,13 +311,13 @@ CHAR8 *devprop_generate_string(DevPropString *StringBuf)
buffer += 12; buffer += 12;
} }
snprintf(buffer, len, "%02X%02X%04X", StringBuf->entries[i]->path_end.type, AsciiSPrint(buffer, len, "%02X%02X%04X", StringBuf->entries[i]->path_end.type,
StringBuf->entries[i]->path_end.subtype, StringBuf->entries[i]->path_end.subtype,
SwapBytes16(StringBuf->entries[i]->path_end.length)); SwapBytes16(StringBuf->entries[i]->path_end.length));
buffer += 8; buffer += 8;
for(x = 0; x < (StringBuf->entries[i]->length) - (24 + (6 * StringBuf->entries[i]->num_pci_devpaths)); x++) { for(x = 0; x < (StringBuf->entries[i]->length) - (24 + (6 * StringBuf->entries[i]->num_pci_devpaths)); x++) {
snprintf(buffer, len, "%02X", *dataptr++); AsciiSPrint(buffer, len, "%02X", *dataptr++);
buffer += 2; buffer += 2;
} }
i++; i++;
@ -408,7 +408,7 @@ BOOLEAN set_eth_props(pci_dt_t *eth_dev)
if (gSettings.FakeLAN) { if (gSettings.FakeLAN) {
UINT32 FakeID = gSettings.FakeLAN >> 16; UINT32 FakeID = gSettings.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); AsciiSPrint(compatible, 64, "pci%04x,%04x", (gSettings.FakeLAN & 0xFFFF), FakeID);
LowCase(compatible); LowCase(compatible);
devprop_add_value(device, "compatible", (UINT8*)&compatible[0], 12); devprop_add_value(device, "compatible", (UINT8*)&compatible[0], 12);
FakeID = gSettings.FakeLAN & 0xFFFF; FakeID = gSettings.FakeLAN & 0xFFFF;

View File

@ -843,7 +843,7 @@ EFI_STATUS InjectKexts(/*IN EFI_MEMORY_DESCRIPTOR *Desc*/ IN UINT32 deviceTreeP,
mm = (_DeviceTreeBuffer*) (((UINT8*)prop) + sizeof(DeviceTreeNodeProperty)); mm = (_DeviceTreeBuffer*) (((UINT8*)prop) + sizeof(DeviceTreeNodeProperty));
mm->paddr = (UINT32)KextBase; mm->paddr = (UINT32)KextBase;
mm->length = KextEntry->kext.length; mm->length = KextEntry->kext.length;
snprintf(prop->Name, 31, "Driver-%llX", KextBase); AsciiSPrint(prop->Name, 31, "Driver-%x", KextBase);
drvPtr += sizeof(DeviceTreeNodeProperty) + sizeof(_DeviceTreeBuffer); drvPtr += sizeof(DeviceTreeNodeProperty) + sizeof(_DeviceTreeBuffer);
KextBase = RoundPage(KextBase + KextEntry->kext.length); KextBase = RoundPage(KextBase + KextEntry->kext.length);

View File

@ -284,15 +284,15 @@ VOID ATIConnectorsPatchInit(LOADER_ENTRY *Entry)
// //
// Lion, SnowLeo 10.6.7 2011 MBP // Lion, SnowLeo 10.6.7 2011 MBP
snprintf(ATIKextBundleId[0], AsciiSPrint(ATIKextBundleId[0],
sizeof(ATIKextBundleId[0]), sizeof(ATIKextBundleId[0]),
"com.apple.kext.ATI%lsController", "com.apple.kext.ATI%aController",
Entry->KernelAndKextPatches->KPATIConnectorsController Entry->KernelAndKextPatches->KPATIConnectorsController
); );
// ML // ML
snprintf(ATIKextBundleId[1], AsciiSPrint(ATIKextBundleId[1],
sizeof(ATIKextBundleId[1]), sizeof(ATIKextBundleId[1]),
"com.apple.kext.AMD%lsController", "com.apple.kext.AMD%aController",
Entry->KernelAndKextPatches->KPATIConnectorsController Entry->KernelAndKextPatches->KPATIConnectorsController
); );

View File

@ -2073,18 +2073,18 @@ static INT32 devprop_add_nvidia_template(DevPropDevice *device, INTN n_ports)
} }
for (pnum = 0; pnum < n_ports; pnum++) { for (pnum = 0; pnum < n_ports; pnum++) {
snprintf(nkey, 24, "@%lld,name", pnum); AsciiSPrint(nkey, 24, "@%d,name", pnum);
snprintf(nval, 24, "NVDA,Display-%c", (char)(65+pnum)); AsciiSPrint(nval, 24, "NVDA,Display-%c", (char)(65+pnum));
//DBG("Nvidia: insert [%s : %s]\n", nkey, nval); //DBG("Nvidia: insert [%s : %s]\n", nkey, nval);
devprop_add_value(device, nkey, (UINT8*)nval, 14); devprop_add_value(device, nkey, (UINT8*)nval, 14);
snprintf(nkey, 24, "@%lld,compatible", pnum); AsciiSPrint(nkey, 24, "@%d,compatible", pnum);
devprop_add_value(device, nkey, (UINT8*)"NVDA,NVMac", 10); devprop_add_value(device, nkey, (UINT8*)"NVDA,NVMac", 10);
snprintf(nkey, 24, "@%lld,device_type", pnum); AsciiSPrint(nkey, 24, "@%d,device_type", pnum);
devprop_add_value(device, nkey, (UINT8*)"display", 7); devprop_add_value(device, nkey, (UINT8*)"display", 7);
snprintf(nkey, 24, "@%lld,display-cfg", pnum); AsciiSPrint(nkey, 24, "@%d,display-cfg", pnum);
if (pnum == 0) { if (pnum == 0) {
devprop_add_value(device, nkey, (gSettings.Dcfg[0] != 0) ? &gSettings.Dcfg[0] : default_dcfg_0, DCFG0_LEN); devprop_add_value(device, nkey, (gSettings.Dcfg[0] != 0) ? &gSettings.Dcfg[0] : default_dcfg_0, DCFG0_LEN);
} else { } else {
@ -2472,7 +2472,7 @@ BOOLEAN setup_nvidia_devprop(pci_dt_t *nvda_dev)
if ((devices_number == 1) && if ((devices_number == 1) &&
((gSettings.BootDisplay >= 0) && (gSettings.BootDisplay < (INT8)n_ports))) { ((gSettings.BootDisplay >= 0) && (gSettings.BootDisplay < (INT8)n_ports))) {
CHAR8 nkey[24]; CHAR8 nkey[24];
snprintf(nkey, 24, "@%d,AAPL,boot-display", gSettings.BootDisplay); AsciiSPrint(nkey, 24, "@%d,AAPL,boot-display", gSettings.BootDisplay);
devprop_add_value(device, nkey, (UINT8*)&boot_display, 4); devprop_add_value(device, nkey, (UINT8*)&boot_display, 4);
DBG("Nvidia: BootDisplay: %d\n", gSettings.BootDisplay); DBG("Nvidia: BootDisplay: %d\n", gSettings.BootDisplay);
} }

View File

@ -610,7 +610,7 @@ VOID SetDMISettingsForModel(MACHINE_TYPES Model, BOOLEAN Redefine)
while (*i != '.') { while (*i != '.') {
i--; i--;
} }
snprintf (Res1, 9, "%c%c/%c%c/%c%c\n", i[3], i[4], i[5], i[6], i[1], i[2]); AsciiSPrint (Res1, 9, "%c%c/%c%c/%c%c\n", i[3], i[4], i[5], i[6], i[1], i[2]);
AsciiStrCpyS (gSettings.ReleaseDate, 64, Res1); AsciiStrCpyS (gSettings.ReleaseDate, 64, Res1);
break; break;
@ -621,7 +621,7 @@ VOID SetDMISettingsForModel(MACHINE_TYPES Model, BOOLEAN Redefine)
while (*i != '.') { while (*i != '.') {
i--; i--;
} }
snprintf (Res2, 11, "%c%c/%c%c/20%c%c\n", i[3], i[4], i[5], i[6], i[1], i[2]); AsciiSPrint (Res2, 11, "%c%c/%c%c/20%c%c\n", i[3], i[4], i[5], i[6], i[1], i[2]);
AsciiStrCpyS (gSettings.ReleaseDate, 64, Res2); AsciiStrCpyS (gSettings.ReleaseDate, 64, Res2);
break; break;
} }

View File

@ -20,6 +20,11 @@
**/ **/
#include "Platform.h" #include "Platform.h"
#ifdef __cplusplus
extern "C" {
#include <Library/PrintLib.h>
}
#endif
#ifndef DEBUG_ALL #ifndef DEBUG_ALL
#define DEBUG_SMBIOS 1 #define DEBUG_SMBIOS 1
@ -909,7 +914,7 @@ VOID PatchTableType4()
UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type4->AssetTag, BrandStr); //like mac UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type4->AssetTag, BrandStr); //like mac
// looks to be MicroCode revision // looks to be MicroCode revision
if(gCPUStructure.MicroCode > 0){ if(gCPUStructure.MicroCode > 0){
snprintf(BrandStr, 20, "%llX", gCPUStructure.MicroCode); AsciiSPrint(BrandStr, 20, "%X", gCPUStructure.MicroCode);
UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type4->SerialNumber, BrandStr); UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type4->SerialNumber, BrandStr);
} }
@ -1092,9 +1097,9 @@ VOID PatchTableType11()
//AsciiStrnCatS(OEMString, MAX_OEM_STRING, gSettings.RomVersion, iStrLen(gSettings.RomVersion, 64)); //AsciiStrnCatS(OEMString, MAX_OEM_STRING, gSettings.RomVersion, iStrLen(gSettings.RomVersion, 64));
// AsciiStrCatS(OEMString, MAX_OEM_STRING, "\n EFI Version:"); // AsciiStrCatS(OEMString, MAX_OEM_STRING, "\n EFI Version:");
// AsciiStrnCatS(OEMString, MAX_OEM_STRING, gSettings.EfiVersion, iStrLen(gSettings.EfiVersion, 64)); // AsciiStrnCatS(OEMString, MAX_OEM_STRING, gSettings.EfiVersion, iStrLen(gSettings.EfiVersion, 64));
AsciiStrCatS(OEMString, MAX_OEM_STRING, "\n Board-ID : "); AsciiStrCatS(OEMString, MAX_OEM_STRING, " Board-ID : ");
AsciiStrnCatS(OEMString, MAX_OEM_STRING, gSettings.BoardNumber, iStrLen(gSettings.BoardNumber, 64)); AsciiStrnCatS(OEMString, MAX_OEM_STRING, gSettings.BoardNumber, iStrLen(gSettings.BoardNumber, 64));
snprintf(TempRev, MAX_OEM_STRING, "\n⌘ Powered by Clover %ls\n", gFirmwareRevision); AsciiSPrint(TempRev, MAX_OEM_STRING, "\n⌘ Powered by Clover %s\n", gFirmwareRevision);
AsciiStrCatS(OEMString, MAX_OEM_STRING, TempRev); AsciiStrCatS(OEMString, MAX_OEM_STRING, TempRev);
UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type11->StringCount, OEMString); UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type11->StringCount, OEMString);
@ -1343,14 +1348,19 @@ VOID PatchTableType17()
newSmbiosTable.Type17->DeviceSet = bank + 1; newSmbiosTable.Type17->DeviceSet = bank + 1;
newSmbiosTable.Type17->MemoryArrayHandle = mHandle16; newSmbiosTable.Type17->MemoryArrayHandle = mHandle16;
if (isMacPro) { if (isMacPro) {
snprintf(deviceLocator, 10, "DIMM%d", gRAMCount + 1); AsciiSPrint(deviceLocator, 10, "DIMM%d", gRAMCount + 1);
} else { } else {
snprintf(deviceLocator, 10, "DIMM%d", bank); AsciiSPrint(deviceLocator, 10, "DIMM%d", bank);
snprintf(bankLocator, 10, "BANK %llu", Index % channels); AsciiSPrint(bankLocator, 10, "BANK %llu", Index % channels);
UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->BankLocator, (CONST CHAR8*)&bankLocator[0]); UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->BankLocator, (CONST CHAR8*)&bankLocator[0]);
} }
UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->DeviceLocator, (CONST CHAR8*)&deviceLocator[0]); UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->DeviceLocator, (CONST CHAR8*)&deviceLocator[0]);
if ((gRAM.User[UserIndex].InUse) && (gRAM.User[UserIndex].ModuleSize > 0)) { if ((gRAM.User[UserIndex].InUse) && (gRAM.User[UserIndex].ModuleSize > 0)) {
DBG("user SMBIOS data:\n");
DBG("SmbiosTable.Type17->Vendor = %s\n", gRAM.User[UserIndex].Vendor);
DBG("SmbiosTable.Type17->SerialNumber = %s\n", gRAM.User[UserIndex].SerialNo);
DBG("SmbiosTable.Type17->PartNumber = %s\n", gRAM.User[UserIndex].PartNo);
if (iStrLen(gRAM.User[UserIndex].Vendor, 64) > 0) { if (iStrLen(gRAM.User[UserIndex].Vendor, 64) > 0) {
UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, gRAM.User[UserIndex].Vendor); UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, gRAM.User[UserIndex].Vendor);
} else { } else {
@ -1574,28 +1584,33 @@ VOID PatchTableType17()
!gRAM.SPD[SPDIndex].InUse && (!trustSMBIOS || !gRAM.SMBIOS[SMBIOSIndex].InUse)) { !gRAM.SPD[SPDIndex].InUse && (!trustSMBIOS || !gRAM.SMBIOS[SMBIOSIndex].InUse)) {
continue; continue;
} }
SmbiosTable = GetSmbiosTableFromType (EntryPoint, EFI_SMBIOS_TYPE_MEMORY_DEVICE, SMBIOSIndex); SmbiosTable = GetSmbiosTableFromType(EntryPoint, EFI_SMBIOS_TYPE_MEMORY_DEVICE, SMBIOSIndex);
if (trustSMBIOS && gRAM.SMBIOS[SMBIOSIndex].InUse && (SmbiosTable.Raw != NULL)) { if (trustSMBIOS && gRAM.SMBIOS[SMBIOSIndex].InUse && (SmbiosTable.Raw != NULL)) {
DBG("trusted SMBIOS data:\n");
DBG("SmbiosTable.Type17->Vendor = %s\n", gRAM.SMBIOS[SMBIOSIndex].Vendor);
DBG("SmbiosTable.Type17->SerialNumber = %s\n", gRAM.SMBIOS[SMBIOSIndex].SerialNo);
DBG("SmbiosTable.Type17->PartNumber = %s\n", gRAM.SMBIOS[SMBIOSIndex].PartNo);
TableSize = SmbiosTableLength(SmbiosTable); TableSize = SmbiosTableLength(SmbiosTable);
CopyMem((VOID*)newSmbiosTable.Type17, (VOID *)SmbiosTable.Type17, TableSize); CopyMem((VOID*)newSmbiosTable.Type17, (VOID *)SmbiosTable.Type17, TableSize);
newSmbiosTable.Type17->AssetTag = 0; newSmbiosTable.Type17->AssetTag = 0;
if (iStrLen(gRAM.SMBIOS[SMBIOSIndex].Vendor, 64) > 0) { if (iStrLen(gRAM.SMBIOS[SMBIOSIndex].Vendor, 64) > 0) {
UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, gRAM.SMBIOS[SMBIOSIndex].Vendor); UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, gRAM.SMBIOS[SMBIOSIndex].Vendor);
snprintf(gSettings.MemoryManufacturer, 64, "%s", gRAM.SMBIOS[SMBIOSIndex].Vendor); AsciiSPrint(gSettings.MemoryManufacturer, 64, "%a", gRAM.SMBIOS[SMBIOSIndex].Vendor);
} else { } else {
// newSmbiosTable.Type17->Manufacturer = 0; // newSmbiosTable.Type17->Manufacturer = 0;
UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, unknown); UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, unknown);
} }
if (iStrLen(gRAM.SMBIOS[SMBIOSIndex].SerialNo, 64) > 0) { if (iStrLen(gRAM.SMBIOS[SMBIOSIndex].SerialNo, 64) > 0) {
UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->SerialNumber, gRAM.SMBIOS[SMBIOSIndex].SerialNo); UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->SerialNumber, gRAM.SMBIOS[SMBIOSIndex].SerialNo);
snprintf(gSettings.MemorySerialNumber, 64, "%s", gRAM.SMBIOS[SMBIOSIndex].SerialNo); AsciiSPrint(gSettings.MemorySerialNumber, 64, "%a", gRAM.SMBIOS[SMBIOSIndex].SerialNo);
} else { } else {
// newSmbiosTable.Type17->SerialNumber = 0; // newSmbiosTable.Type17->SerialNumber = 0;
UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->SerialNumber, unknown); UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->SerialNumber, unknown);
} }
if (iStrLen(gRAM.SMBIOS[SMBIOSIndex].PartNo, 64) > 0) { if (iStrLen(gRAM.SMBIOS[SMBIOSIndex].PartNo, 64) > 0) {
UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->PartNumber, gRAM.SMBIOS[SMBIOSIndex].PartNo); UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->PartNumber, gRAM.SMBIOS[SMBIOSIndex].PartNo);
snprintf(gSettings.MemoryPartNumber, 64, "%s", gRAM.SMBIOS[SMBIOSIndex].PartNo); AsciiSPrint(gSettings.MemoryPartNumber, 64, "%a", gRAM.SMBIOS[SMBIOSIndex].PartNo);
DBG(" partNum=%s\n", gRAM.SMBIOS[SMBIOSIndex].PartNo); DBG(" partNum=%s\n", gRAM.SMBIOS[SMBIOSIndex].PartNo);
} else { } else {
// newSmbiosTable.Type17->PartNumber = 0; // newSmbiosTable.Type17->PartNumber = 0;
@ -1617,21 +1632,26 @@ VOID PatchTableType17()
newSmbiosTable.Type17->MemoryArrayHandle = mHandle16; newSmbiosTable.Type17->MemoryArrayHandle = mHandle16;
if (gRAM.SPD[SPDIndex].InUse) { if (gRAM.SPD[SPDIndex].InUse) {
DBG("SPD data in use:\n");
DBG("SmbiosTable.Type17->Vendor = %s\n", gRAM.SPD[SPDIndex].Vendor);
DBG("SmbiosTable.Type17->SerialNumber = %s\n", gRAM.SPD[SPDIndex].SerialNo);
DBG("SmbiosTable.Type17->PartNumber = %s\n", gRAM.SPD[SPDIndex].PartNo);
if (iStrLen(gRAM.SPD[SPDIndex].Vendor, 64) > 0) { if (iStrLen(gRAM.SPD[SPDIndex].Vendor, 64) > 0) {
UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, gRAM.SPD[SPDIndex].Vendor); UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, gRAM.SPD[SPDIndex].Vendor);
snprintf(gSettings.MemoryManufacturer, 64, "%s", gRAM.SPD[SPDIndex].Vendor); AsciiSPrint(gSettings.MemoryManufacturer, 64, "%a", gRAM.SPD[SPDIndex].Vendor);
} else { } else {
UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, unknown); UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, unknown);
} }
if (iStrLen(gRAM.SPD[SPDIndex].SerialNo, 64) > 0) { if (iStrLen(gRAM.SPD[SPDIndex].SerialNo, 64) > 0) {
UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->SerialNumber, gRAM.SPD[SPDIndex].SerialNo); UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->SerialNumber, gRAM.SPD[SPDIndex].SerialNo);
snprintf(gSettings.MemorySerialNumber, 64, "%s", gRAM.SPD[SPDIndex].SerialNo); AsciiSPrint(gSettings.MemorySerialNumber, 64, "%a", gRAM.SPD[SPDIndex].SerialNo);
} else { } else {
UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->SerialNumber, unknown); UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->SerialNumber, unknown);
} }
if (iStrLen(gRAM.SPD[SPDIndex].PartNo, 64) > 0) { if (iStrLen(gRAM.SPD[SPDIndex].PartNo, 64) > 0) {
UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->PartNumber, gRAM.SPD[SPDIndex].PartNo); UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->PartNumber, gRAM.SPD[SPDIndex].PartNo);
snprintf(gSettings.MemoryPartNumber, 64, "%s", gRAM.SPD[SPDIndex].PartNo); AsciiSPrint(gSettings.MemoryPartNumber, 64, "%a", gRAM.SPD[SPDIndex].PartNo);
} else { } else {
UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->PartNumber, unknown); UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->PartNumber, unknown);
} }
@ -1660,7 +1680,7 @@ VOID PatchTableType17()
UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, gRAM.SMBIOS[SMBIOSIndex].Vendor); UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, gRAM.SMBIOS[SMBIOSIndex].Vendor);
} }
snprintf(gSettings.MemorySpeed, 64, "%d", newSmbiosTable.Type17->Speed); AsciiSPrint(gSettings.MemorySpeed, 64, "%d", newSmbiosTable.Type17->Speed);
// Assume DDR3 unless explicitly set to DDR2/DDR/DDR4 // Assume DDR3 unless explicitly set to DDR2/DDR/DDR4
if ((newSmbiosTable.Type17->MemoryType != MemoryTypeDdr2) && if ((newSmbiosTable.Type17->MemoryType != MemoryTypeDdr2) &&
@ -1671,12 +1691,12 @@ VOID PatchTableType17()
//now I want to update deviceLocator and bankLocator //now I want to update deviceLocator and bankLocator
if (isMacPro) { if (isMacPro) {
snprintf(deviceLocator, 10, "DIMM%d", gRAMCount + 1); AsciiSPrint(deviceLocator, 10, "DIMM%d", gRAMCount + 1);
// snprintf(bankLocator, 10, ""); // AsciiSPrint(bankLocator, 10, "");
bankLocator[0] = 0; bankLocator[0] = 0;
} else { } else {
snprintf(deviceLocator, 10, "DIMM%d", bank); AsciiSPrint(deviceLocator, 10, "DIMM%d", bank);
snprintf(bankLocator, 10, "BANK %llu", Index % channels); AsciiSPrint(bankLocator, 10, "BANK %d", Index % channels);
} }
UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->DeviceLocator, (CONST CHAR8*)&deviceLocator[0]); UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->DeviceLocator, (CONST CHAR8*)&deviceLocator[0]);
if (isMacPro) { if (isMacPro) {

View File

@ -542,12 +542,12 @@ CHAR8* getDDRSerial(UINT8* spd)
CHAR8* asciiSerial; //[16]; CHAR8* asciiSerial; //[16];
asciiSerial = (__typeof__(asciiSerial))AllocatePool(17); asciiSerial = (__typeof__(asciiSerial))AllocatePool(17);
if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR4) { // DDR4 if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR4) { // DDR4
snprintf(asciiSerial, 17, "%2X%2X%2X%2X%2X%2X%2X%2X", SMST(325) /*& 0x7*/, SLST(325), SMST(326), SLST(326), SMST(327), SLST(327), SMST(328), SLST(328)); AsciiSPrint(asciiSerial, 17, "%2X%2X%2X%2X%2X%2X%2X%2X", SMST(325) /*& 0x7*/, SLST(325), SMST(326), SLST(326), SMST(327), SLST(327), SMST(328), SLST(328));
} else if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR3) { // DDR3 } else if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR3) { // DDR3
snprintf(asciiSerial, 17, "%2X%2X%2X%2X%2X%2X%2X%2X", SMST(122) /*& 0x7*/, SLST(122), SMST(123), SLST(123), SMST(124), SLST(124), SMST(125), SLST(125)); AsciiSPrint(asciiSerial, 17, "%2X%2X%2X%2X%2X%2X%2X%2X", SMST(122) /*& 0x7*/, SLST(122), SMST(123), SLST(123), SMST(124), SLST(124), SMST(125), SLST(125));
} else if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR2 || } else if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR2 ||
spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR) { // DDR2 or DDR spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR) { // DDR2 or DDR
snprintf(asciiSerial, 17, "%2X%2X%2X%2X%2X%2X%2X%2X", SMST(95) /*& 0x7*/, SLST(95), SMST(96), SLST(96), SMST(97), SLST(97), SMST(98), SLST(98)); AsciiSPrint(asciiSerial, 17, "%2X%2X%2X%2X%2X%2X%2X%2X", SMST(95) /*& 0x7*/, SLST(95), SMST(96), SLST(96), SMST(97), SLST(97), SMST(98), SLST(98));
} else { } else {
AsciiStrCpyS(asciiSerial, 17, "0000000000000000"); AsciiStrCpyS(asciiSerial, 17, "0000000000000000");
} }

View File

@ -3600,7 +3600,7 @@ UINTN REFIT_MENU_SCREEN::RunMainMenu(IN INTN DefaultSelection, OUT REFIT_ABSTRAC
} }
if (/*MenuExit == MENU_EXIT_ENTER &&*/ MainChosenEntry->getLOADER_ENTRY()) { if (/*MenuExit == MENU_EXIT_ENTER &&*/ MainChosenEntry->getLOADER_ENTRY()) {
if (MainChosenEntry->getLOADER_ENTRY()->LoadOptions.notEmpty()) { if (MainChosenEntry->getLOADER_ENTRY()->LoadOptions.notEmpty()) {
snprintf(gSettings.BootArgs, 255, "%s", MainChosenEntry->getLOADER_ENTRY()->LoadOptions.c_str()); AsciiSPrint(gSettings.BootArgs, 255, "%a", MainChosenEntry->getLOADER_ENTRY()->LoadOptions.c_str());
} else { } else {
ZeroMem(&gSettings.BootArgs, 255); ZeroMem(&gSettings.BootArgs, 255);
} }

View File

@ -756,7 +756,7 @@ EG_IMAGE * LoadSvgFrame(INTN i)
XString XFrameName("frame_"_XS); XString XFrameName("frame_"_XS);
//TODO if extend SVG syntax then we can use dynamic SVG with parameter Frame //TODO if extend SVG syntax then we can use dynamic SVG with parameter Frame
// for example use variable instead of constant like javascript // for example use variable instead of constant like javascript
XFrameName += SPrintf("%lld", i+1); XFrameName += SPrintf("%04lld", i+1); //I need exactly 4 symbols with leading zero
// printf(FrameName, 63, "frame_%lld", i+1); // printf(FrameName, 63, "frame_%lld", i+1);
Status = ThemeX.ParseSVGXIcon(mainParser, BUILTIN_ICON_ANIME, XFrameName, &XFrame); Status = ThemeX.ParseSVGXIcon(mainParser, BUILTIN_ICON_ANIME, XFrameName, &XFrame);
@ -773,7 +773,7 @@ EG_IMAGE * LoadSvgFrame(INTN i)
CHAR8 FrameName[64]; CHAR8 FrameName[64];
//TODO if extend SVG syntax then we can use dynamic SVG with parameter Frame //TODO if extend SVG syntax then we can use dynamic SVG with parameter Frame
// for example use variable instead of constant like javascript // for example use variable instead of constant like javascript
snprintf(FrameName, 63, "frame_%lld", i+1); AsciiSPrint(FrameName, 63, "frame_%04d", i+1); //we need exact number of digits which snprintf not provided
Status = ParseSVGIcon(mainParser, BUILTIN_ICON_ANIME, FrameName, GlobalConfig.Scale, &Frame); Status = ParseSVGIcon(mainParser, BUILTIN_ICON_ANIME, FrameName, GlobalConfig.Scale, &Frame);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DBG("icon '%s' not loaded, status=%s\n", FrameName, strerror(Status)); DBG("icon '%s' not loaded, status=%s\n", FrameName, strerror(Status));

View File

@ -371,7 +371,7 @@ VOID FillInputs(BOOLEAN New)
InputItems[InputItemsCount++].BValue = gSettings.InjectNVidia; InputItems[InputItemsCount++].BValue = gSettings.InjectNVidia;
InputItems[InputItemsCount].ItemType = ASString; //22+6i InputItems[InputItemsCount].ItemType = ASString; //22+6i
for (j=0; j<8; j++) { for (j=0; j<8; j++) {
snprintf((CHAR8*)&tmp[2*j], 3, "%02X", gSettings.Dcfg[j]); AsciiSPrint((CHAR8*)&tmp[2*j], 3, "%02x", gSettings.Dcfg[j]);
} }
if (New) { if (New) {
InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(40); InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(40);
@ -404,7 +404,7 @@ VOID FillInputs(BOOLEAN New)
if (gGraphics[i].Vendor == Nvidia) { if (gGraphics[i].Vendor == Nvidia) {
InputItems[InputItemsCount].ItemType = ASString; //24+6i InputItems[InputItemsCount].ItemType = ASString; //24+6i
for (j=0; j<20; j++) { for (j=0; j<20; j++) {
snprintf((CHAR8*)&tmp[2*j], 3, "%02X", gSettings.NVCAP[j]); AsciiSPrint((CHAR8*)&tmp[2*j], 3, "%02X", gSettings.NVCAP[j]);
} }
if (New) { if (New) {
InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(84); InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(84);
@ -773,7 +773,7 @@ VOID ApplyInputs(VOID)
} }
} while (*(++ch)); } while (*(++ch));
snprintf(gSettings.BootArgs, 255, "%ls ", InputItems[i].SValue); AsciiSPrint(gSettings.BootArgs, 255, "%s ", InputItems[i].SValue);
} }
i++; //1 i++; //1
if (InputItems[i].Valid) { if (InputItems[i].Valid) {