Remove the trim to the first space for PartNo, Vendor, SerialNo.

Refactor ACPI_NAME_LIST as XString8Array.
Create ACPI_RENAME_DEVICE and ACPI_NAME to replace ACPI_NAME_LIST.
Change RAM_SLOT_INFO and MEM_STRUCTURE into class.
Improve XObjArray::RemoveWithoutFreeingAtIndex.
Create XStringArray::ExtractFromPos.
Move CheckFatalError and CheckError to BasicIO.
This commit is contained in:
jief666 2021-04-05 11:57:55 +03:00
parent 6ff5bab8a5
commit 946a6428b5
16 changed files with 266 additions and 202 deletions

View File

@ -16,5 +16,8 @@ void PauseForKey(CONST CHAR16* msg);
void EndlessIdleLoop(void);
BOOLEAN CheckFatalError(IN EFI_STATUS Status, IN CONST CHAR16 *where);
BOOLEAN CheckError(IN EFI_STATUS Status, IN CONST CHAR16 *where);
#endif /* PLATFORM_BASICIO_H_ */

View File

@ -5218,7 +5218,8 @@ BOOLEAN isACPI_Char(CHAR8 C)
(C == '_'));
}
BOOLEAN CmpFullName(UINT8* Table, UINTN Len, ACPI_NAME_LIST *Bridge)
// all string in Bridge is supposed to be 4 chars long.
BOOLEAN CmpFullName(UINT8* Table, UINTN Len, const XString8Array& Bridge)
{
// "RP02" NameLen=4
// "_SB_PCI0RP02" NameLen=12
@ -5234,13 +5235,12 @@ BOOLEAN CmpFullName(UINT8* Table, UINTN Len, ACPI_NAME_LIST *Bridge)
Name = (__typeof__(Name))AllocateCopyPool(NameLen + 1, Table);
Name[NameLen] = '\0';
i = NameLen - 4;
while (Bridge && (i >= 0)) {
if (AsciiStrStr(Name + i, Bridge->Name) == NULL) { //compare Bridge->Name with RP02, Next->Name with PCI0 then _SB_
for (size_t idx = 0 ; idx < Bridge.size() && i >= 0 ; ++idx ) {
if (AsciiStrStr(Name + i, Bridge[idx].c_str()) == NULL) { //compare Bridge->Name with RP02, Next->Name with PCI0 then _SB_
FreePool(Name);
return FALSE;
}
i -= 4;
Bridge = Bridge->Next;
}
FreePool(Name);
return TRUE;
@ -5248,11 +5248,8 @@ BOOLEAN CmpFullName(UINT8* Table, UINTN Len, ACPI_NAME_LIST *Bridge)
void RenameDevices(UINT8* table)
{
ACPI_NAME_LIST *List;
ACPI_NAME_LIST *Bridge;
CHAR8 *Replace;
CHAR8 *Find;
DBG("RenameDevices %zu\n", gSettings.ACPI.DeviceRename.size());
if ( gSettings.ACPI.DeviceRename.size() <= 0 ) return; // to avoid message "0 replacement"
INTN i;
@ -5262,24 +5259,30 @@ void RenameDevices(UINT8* table)
INTN adr, shift, Num = 0;
BOOLEAN found;
for (UINTN index = 0; index < gSettings.ACPI.DeviceRename.size(); index++) {
List = gSettings.ACPI.DeviceRename[index].Next;
Replace = gSettings.ACPI.DeviceRename[index].Name;
Find = List->Name;
Bridge = List->Next;
MsgLog("Name: %s, Bridge: %s, Replace: %s\n", Find, Bridge->Name, Replace);
const ACPI_RENAME_DEVICE& deviceRename = gSettings.ACPI.DeviceRename[index];
XString8Array FindList = deviceRename.Name.getSplittedName();
XString8 Replace = deviceRename.getRenameTo();
XString8 LastComponentFind;
if( FindList.notEmpty() ) LastComponentFind = FindList[0];
XString8Array BridgeList = FindList;
if( BridgeList.notEmpty() ) BridgeList.removeAtPos(0);
XString8 Bridge;
if( BridgeList.notEmpty() ) Bridge = BridgeList[0];
MsgLog("Name: %s, Bridge: %s, Replace: %s\n", LastComponentFind.c_str(), Bridge.c_str(), Replace.c_str());
adr = 0;
do
{
shift = FindBin(table + adr, (UINT32)(len - adr), (const UINT8*)Find, 4); //next occurence
shift = FindBin(table + adr, (UINT32)(len - adr), (const UINT8*)LastComponentFind.c_str(), 4); //next occurence
if (shift < 0) {
break; //not found
}
adr += shift;
// DBG("found Name @ 0x%X\n", adr);
if (!Bridge || (FindBin(table + adr - 4, 5, (const UINT8*)(Bridge->Name), 4) == 0)) { // long name like "RP02.PXSX"
CopyMem(table + adr, Replace, 4);
if (Bridge.isEmpty() || (FindBin(table + adr - 4, 5, (const UINT8*)(Bridge.c_str()), 4) == 0)) { // long name like "RP02.PXSX"
DBG("replace without bridge %.*s by %s at table+%llu\n", 4, table + adr, Replace.c_str(), adr);
CopyMem(table + adr, Replace.c_str(), 4);
adr += 5; //at least, it is impossible to see PXSXPXSX
// DBG("replaced\n");
Num++;
continue;
}
@ -5315,10 +5318,11 @@ void RenameDevices(UINT8* table)
else if ((table[k] & 0x80) != 0) {
k += 3;
} //now k points to the outer name
if (CmpFullName(table + k, len - k, Bridge)) {
CopyMem(table + adr, Replace, 4);
adr += 5;
if (CmpFullName(table + k, len - k, BridgeList)) {
DBG("found Bridge device begin=%llX end=%llX\n", k, k+size);
DBG("replace with bridge %.*s by %s at table+%llu\n", 4, table + adr, Replace.c_str(), adr);
CopyMem(table + adr, Replace.c_str(), 4);
adr += 5;
// DBG(" name copied\n");
Num++;
break; //cancel search outer bridge, we found it.

View File

@ -303,41 +303,44 @@ GetCrc32 (
while (Size--) x+= *Fake++;
return x;
}
ACPI_NAME_LIST *
ParseACPIName(const XString8& String)
{
ACPI_NAME_LIST* List = NULL;
ACPI_NAME_LIST* Next = NULL;
INTN i, j, Len, pos0, pos1;
Len = String.length();
// DBG("parse ACPI name: %s\n", String);
if (Len > 0) {
//Parse forward but put in stack LIFO "_SB.PCI0.RP02.PXSX" -1,3,8,13,18
pos0 = -1;
while (pos0 < Len) {
List = (__typeof__(List))AllocateZeroPool(sizeof(ACPI_NAME_LIST));
List->Next = Next;
List->Name = (__typeof__(List->Name))AllocateZeroPool(5);
pos1 = pos0 + 1;
while ((pos1 < Len) && String[pos1] != '.') pos1++; // 3,8,13,18
// if ((pos1 == Len) || (String[pos1] == ',')) { //always
for (i = pos0 + 1, j = 0; i < pos1; i++) {
List->Name[j++] = String.data()[i]; // String[i] return a char32_t. what if there is an utf8 char ?
}
// extend by '_' up to 4 symbols
if (j < 4) {
SetMem(List->Name + j, 4 - j, '_');
}
List->Name[4] = '\0';
// }
// DBG("string between [%d,%d]: %s\n", pos0, pos1, List->Name);
pos0 = pos1; //comma or zero@end
Next = List;
}
}
return List;
}
//
//ACPI_NAME_LIST *
//ParseACPIName(const XString8& String)
//{
// ACPI_NAME_LIST* List = NULL;
// ACPI_NAME_LIST* Next = NULL;
// INTN i, j, Len, pos0, pos1;
// Len = String.length();
// // DBG("parse ACPI name: %s\n", String);
// if (Len > 0) {
// //Parse forward but put in stack LIFO "_SB.PCI0.RP02.PXSX" -1,3,8,13,18
// pos0 = -1;
// while (pos0 < Len) {
// List = (__typeof__(List))AllocateZeroPool(sizeof(ACPI_NAME_LIST));
// List->Next = Next;
// List->Name = (__typeof__(List->Name))AllocateZeroPool(5);
// pos1 = pos0 + 1;
// while ((pos1 < Len) && String[pos1] != '.') pos1++; // 3,8,13,18
// // if ((pos1 == Len) || (String[pos1] == ',')) { //always
// for (i = pos0 + 1, j = 0; i < pos1; i++) {
// List->Name[j++] = String.data()[i]; // String[i] return a char32_t. what if there is an utf8 char ?
// // Jief : if it's an utf8 multibytes char, it'll be properly converted to the corresponding UTF32 char.
// // So this is an unsafe downcast !
// // Plus : this can write more than 5 bytes in List->Name !!
// }
// // extend by '_' up to 4 symbols
// if (j < 4) {
// SetMem(List->Name + j, 4 - j, '_');
// }
// List->Name[4] = '\0';
// // }
// // DBG("string between [%d,%d]: %s\n", pos0, pos1, List->Name);
// pos0 = pos1; //comma or zero@end
// Next = List;
// }
// }
// return List;
//}
void
ParseLoadOptions (
@ -3409,12 +3412,16 @@ ParseSMBIOSSettings(SETTINGS_DATA& gSettings, const TagDict* DictPointer)
if ( !Prop->isString() ) {
MsgLog("ATTENTION : property not string in ProductName\n");
}else{
DBG("ProductName SETTINGS_DATA=%s\n", gSettings.Smbios.ProductName.c_str());
DBG("ProductName setting=%s\n", Prop->getString()->stringValue().c_str());
MACHINE_TYPES Model;
gSettings.Smbios.ProductName = Prop->getString()->stringValue();
DBG("ProductName new SETTINGS_DATA=%s\n", gSettings.Smbios.ProductName.c_str());
// let's fill all other fields based on this ProductName
// to serve as default
Model = GetModelFromString(gSettings.Smbios.ProductName);
if (Model != MaxMachineType) {
DBG("SetDMISettingsForModel=%d\n", Model);
SetDMISettingsForModel(gSettings, Model, FALSE);
Default = TRUE;
} else {
@ -3424,7 +3431,7 @@ ParseSMBIOSSettings(SETTINGS_DATA& gSettings, const TagDict* DictPointer)
}
}
}
DBG("Using ProductName from config: %s\n", gSettings.Smbios.ProductName.c_str());
DBG("Using ProductName : %s\n", gSettings.Smbios.ProductName.c_str());
Prop = DictPointer->propertyForKey("SmbiosVersion");
gSettings.Smbios.SmbiosVersion = (UINT16)GetPropertyAsInteger(Prop, 0x204);
@ -3693,7 +3700,7 @@ ParseSMBIOSSettings(SETTINGS_DATA& gSettings, const TagDict* DictPointer)
if (gSettings.Smbios.gPlatformFeature == 0xFFFF) {
DBG("PlatformFeature will not set in SMBIOS\n");
} else {
DBG("Using PlatformFeature from clover: 0x%llX\n", gSettings.Smbios.gPlatformFeature);
DBG("Using PlatformFeature from clover: 0x%llX\n", gSettings.Smbios.gPlatformFeature);
}
}
@ -3739,6 +3746,7 @@ ParseSMBIOSSettings(SETTINGS_DATA& gSettings, const TagDict* DictPointer)
MsgLog("ATTENTION : property not string in SerialNumber\n");
}else{
gSettings.Smbios.SerialNr = Prop->getString()->stringValue();
DBG("gSettings.Smbios.SerialNr: %s\n", gSettings.Smbios.SerialNr.c_str());
}
}
@ -3796,6 +3804,7 @@ ParseSMBIOSSettings(SETTINGS_DATA& gSettings, const TagDict* DictPointer)
MsgLog("ATTENTION : property not string in BoardVersion\n");
}else{
gSettings.Smbios.BoardVersion = Prop->getString()->stringValue();
DBG("%s : BoardVersion: %s\n",__PRETTY_FUNCTION__, gSettings.Smbios.BoardVersion.c_str());
}
}
@ -4371,17 +4380,16 @@ static void getACPISettings(const TagDict *CfgDict, SETTINGS_DATA& gSettings)
const TagKey* key;
const TagStruct* value;
if ( !EFI_ERROR(RenameDevicesDict->getKeyAndValueAtIndex(j, &key, &value)) ) {
ACPI_NAME_LIST* List = ParseACPIName(key->keyStringValue());
ACPI_NAME_LIST* List2 = (__typeof__(List2))AllocateZeroPool(sizeof(ACPI_NAME_LIST));
List2->Next = List;
gSettings.ACPI.DeviceRename.AddReference(List2, false);
while (List) {
DBG("%s:", List->Name);
List = List->Next;
}
if (value->isString()) {
List2->Name = S8Printf("%s", value->getString()->stringValue().c_str()).forgetDataWithoutFreeing();
DBG("->will be renamed to %s\n", List2->Name);
ACPI_RENAME_DEVICE* List2 = new ACPI_RENAME_DEVICE();
List2->Name.Name = key->keyStringValue();
List2->renameTo = value->getString()->stringValue();
DBG("->will be renamed to %s\n", List2->renameTo.c_str());
gSettings.ACPI.DeviceRename.AddReference(List2, false);
const XString8Array List2Name = List2->Name.getSplittedName();
for (size_t idx = 0 ; idx < List2Name.size() ; ++idx ) {
DBG("%s:", List2Name[idx].c_str());
}
}
}
} //for j < dict size

View File

@ -102,10 +102,37 @@ typedef struct {
CHAR16 *codec_name;
} HDA_PROPERTIES;
typedef struct ACPI_NAME_LIST ACPI_NAME_LIST;
struct ACPI_NAME_LIST {
ACPI_NAME_LIST *Next;
CHAR8 *Name;
class ACPI_NAME
{
public:
XString8 Name = XString8();
XString8Array getSplittedName() const {
XString8Array splittedName = Split<XString8Array>(Name, ".");
for ( size_t idx = 0 ; idx < splittedName.size() ; ++idx) {
XString8& name = splittedName[idx];
while ( name.length() > 4 ) name.deleteCharsAtPos(name.length()-1);
while ( name.length() < 4 ) name.strcat('_');
}
for ( size_t idx = 1 ; idx < splittedName.size() ; ++idx) {
splittedName.insertReferenceAtPos(splittedName.ExtractFromPos(idx), 0, true); // A swap method in XObjARray would be slightly better to avoid memcpy in XObjArray when an object is removed.
}
return splittedName;
}
};
class ACPI_RENAME_DEVICE
{
public:
ACPI_NAME Name = ACPI_NAME();
XString8 renameTo = XString8();
XString8 getRenameTo() const {
if ( renameTo.length() == 4 ) return renameTo;
XString8 newName = renameTo;
while ( newName.length() > 4 ) newName.deleteCharsAtPos(newName.length()-1);
while ( newName.length() < 4 ) newName.strcat('_');
return newName;
}
};
class ACPI_DROP_TABLE
@ -440,14 +467,14 @@ public:
class SLOT_DEVICE
{
public:
UINT16 SegmentGroupNum; // assigned by GetDevices
UINT8 BusNum; // assigned by GetDevices
UINT8 DevFuncNum; // assigned by GetDevices
bool Valid; // assigned by GetDevices
UINT16 SegmentGroupNum = UINT16(); // assigned by GetDevices
UINT8 BusNum = UINT8(); // assigned by GetDevices
UINT8 DevFuncNum = UINT8(); // assigned by GetDevices
bool Valid = bool(); // assigned by GetDevices
//UINT8 DeviceN;
UINT8 SlotID;
MISC_SLOT_TYPE SlotType;
XString8 SlotName;
UINT8 SlotID = UINT8();
MISC_SLOT_TYPE SlotType = MISC_SLOT_TYPE();
XString8 SlotName = XString8();
} ;
@ -517,7 +544,7 @@ public:
XBuffer<UINT8> PatchDsdtFind = XBuffer<UINT8>();
XBuffer<UINT8> PatchDsdtReplace = XBuffer<UINT8>();
XBuffer<UINT8> PatchDsdtTgt = XBuffer<UINT8>();
INPUT_ITEM PatchDsdtMenuItem = INPUT_ITEM();
INPUT_ITEM PatchDsdtMenuItem = INPUT_ITEM(); // Not read from config.plist. Should be moved out.
};
XStringW DsdtName = XStringW();
@ -572,7 +599,7 @@ public:
bool AutoMerge = 0;
XStringWArray DisabledAML = XStringWArray();
XString8Array SortedACPI = XString8Array();
XObjArray<ACPI_NAME_LIST> DeviceRename = XObjArray<ACPI_NAME_LIST>();
XObjArray<ACPI_RENAME_DEVICE> DeviceRename = XObjArray<ACPI_RENAME_DEVICE>();
XObjArray<ACPIDropTablesClass> ACPIDropTablesArray = XObjArray<ACPIDropTablesClass>();
DSDTClass DSDT = DSDTClass();
SSDTClass SSDT = SSDTClass();
@ -608,7 +635,7 @@ public:
XStringW ScreenResolution = XStringW();
bool ProvideConsoleGop = 0;
INTN ConsoleMode = 0;
XString8 Language;
XString8 Language = XString8();
LanguageCode languageCode = english;
bool KbdPrevLang = 0;
XString8Array HVHideStrings = XString8Array();
@ -1049,39 +1076,39 @@ printf("%s", "");
class MemoryClass {
public:
UINT8 SlotCounts;
UINT8 UserChannels;
UINT8 SlotCounts = UINT8();
UINT8 UserChannels = UINT8();
RAM_SLOT_INFO User[MAX_RAM_SLOTS * 4];
};
// SMBIOS TYPE0
XString8 BiosVendor;
XString8 _RomVersion;
XString8 _EfiVersion;
XString8 _ReleaseDate;
XString8 BiosVendor = XString8();
XString8 _RomVersion = XString8();
XString8 _EfiVersion = XString8();
XString8 _ReleaseDate = XString8();
// SMBIOS TYPE1
XString8 ManufactureName;
XString8 ProductName;
XString8 VersionNr;
XString8 SerialNr;
XString8 SmUUID;
XString8 FamilyName;
XString8 ManufactureName = XString8();
XString8 ProductName = XString8();
XString8 VersionNr = XString8();
XString8 SerialNr = XString8();
XString8 SmUUID = XString8();
XString8 FamilyName = XString8();
// SMBIOS TYPE2
XString8 BoardManufactureName;
XString8 BoardSerialNumber;
XString8 BoardNumber; //Board-ID
XString8 LocationInChassis;
XString8 BoardVersion;
UINT8 BoardType;
XString8 BoardManufactureName = XString8();
XString8 BoardSerialNumber = XString8();
XString8 BoardNumber = XString8(); //Board-ID
XString8 LocationInChassis = XString8();
XString8 BoardVersion = XString8();
UINT8 BoardType = UINT8();
// SMBIOS TYPE3
bool Mobile;
UINT8 ChassisType;
XString8 ChassisManufacturer;
XString8 ChassisAssetTag;
bool Mobile = bool();
UINT8 ChassisType = UINT8();
XString8 ChassisManufacturer = XString8();
XString8 ChassisAssetTag = XString8();
// SMBIOS TYPE4
// SMBIOS TYPE17
UINT16 SmbiosVersion;
INT8 Attribute;
UINT16 SmbiosVersion = UINT16();
INT8 Attribute = INT8();
// These were set but never used.
// XString8 MemoryManufacturer;
// XString8 MemorySerialNumber;
@ -1090,14 +1117,14 @@ printf("%s", "");
// SMBIOS TYPE131
// SMBIOS TYPE132
bool TrustSMBIOS = 0;
bool InjectMemoryTables; // same as Memory.SlotCounts
bool InjectMemoryTables = bool(); // same as Memory.SlotCounts
// SMBIOS TYPE133
UINT64 gPlatformFeature;
UINT64 gPlatformFeature = UINT64();
// PatchTableType11
bool NoRomInfo;
bool NoRomInfo = bool();
UINT32 gFwFeatures;
UINT32 gFwFeaturesMask;
UINT32 gFwFeatures = UINT32();
UINT32 gFwFeaturesMask = UINT32();
MemoryClass Memory = MemoryClass();
SLOT_DEVICE SlotDevices[16]; //assume DEV_XXX, Arpt=6
@ -1347,7 +1374,7 @@ public:
UINT32 OptionsBits = 0;
UINT32 FlagsBits = 0;
XStringW BlockKexts;
XStringW BlockKexts = XStringW();
// KernelAndKextPatches
BOOLEAN KextPatchesAllowed = 0;
BOOLEAN KernelPatchesAllowed = 0; //From GUI: Only for user patches, not internal Clover

View File

@ -127,43 +127,3 @@ XString8 Bytes2HexStr(UINT8 *data, UINTN len)
BOOLEAN haveError = FALSE;
BOOLEAN CheckFatalError(IN EFI_STATUS Status, IN CONST CHAR16 *where)
{
// CHAR16 ErrorName[64];
if (!EFI_ERROR(Status))
return FALSE;
MsgLog("Fatal Error: %s %ls\n", efiStrError(Status), where);
// StatusToString(ErrorName, Status);
gST->ConOut->SetAttribute (gST->ConOut, EFI_RED | EFI_BACKGROUND_BLACK);
printf("Fatal Error: %s %ls\n", efiStrError(Status), where);
gST->ConOut->SetAttribute (gST->ConOut, EFI_LIGHTGRAY | EFI_BACKGROUND_BLACK);
haveError = TRUE;
//gBS->Exit(ImageHandle, ExitStatus, ExitDataSize, ExitData);
return TRUE;
}
BOOLEAN CheckError(IN EFI_STATUS Status, IN CONST CHAR16 *where)
{
// CHAR16 ErrorName[64];
if (!EFI_ERROR(Status))
return FALSE;
MsgLog("Fatal Error: %s %ls\n", efiStrError(Status), where);
// StatusToString(ErrorName, Status);
gST->ConOut->SetAttribute (gST->ConOut, EFI_RED | EFI_BACKGROUND_BLACK);
printf("Error: %s %ls\n", efiStrError(Status), where);
gST->ConOut->SetAttribute (gST->ConOut, EFI_LIGHTGRAY | EFI_BACKGROUND_BLACK);
haveError = TRUE;
return TRUE;
}

View File

@ -121,9 +121,6 @@ inline UINTN EFIAPI AsciiStrDecimalToUintn(const XString8& String)
extern BOOLEAN haveError;
BOOLEAN CheckFatalError(IN EFI_STATUS Status, IN CONST CHAR16 *where);
BOOLEAN CheckError(IN EFI_STATUS Status, IN CONST CHAR16 *where);
#endif // __cplusplus
#endif // _UTILS_H_

View File

@ -469,14 +469,21 @@ void PatchTableType0()
GlobalConfig.RomVersionUsed.trim();
if( GlobalConfig.RomVersionUsed.notEmpty() ) {
if( GlobalConfig.EfiVersionUsed.notEmpty() ) {
DBG("UpdateSmbiosString : BiosVersion=EfiVersion=%s\n", GlobalConfig.EfiVersionUsed.c_str());
UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type0->BiosVersion, GlobalConfig.EfiVersionUsed);
} else {
DBG("UpdateSmbiosString : BiosVersion=RomVersion=%s\n", GlobalConfig.RomVersionUsed.c_str());
UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type0->BiosVersion, GlobalConfig.RomVersionUsed);
}
}else{
DBG("UpdateSmbiosString : BiosVersion no update\n");
}
GlobalConfig.ReleaseDateUsed.trim();
if( GlobalConfig.ReleaseDateUsed.notEmpty() ) {
DBG("UpdateSmbiosString : ReleaseDate=%s\n", GlobalConfig.ReleaseDateUsed.c_str());
UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type0->BiosReleaseDate, GlobalConfig.ReleaseDateUsed);
}else{
DBG("UpdateSmbiosString : ReleaseDate no update\n");
}
Handle = LogSmbiosTable(newSmbiosTable);
}
@ -535,6 +542,7 @@ void PatchTableType1()
}
gSettings.Smbios.ProductName.trim();
if( gSettings.Smbios.ProductName.notEmpty() ){
DBG("%s : UpdateSmbiosString ProductName=%s\n", __PRETTY_FUNCTION__, gSettings.Smbios.ProductName.c_str());
UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type1->ProductName, gSettings.Smbios.ProductName);
}
gSettings.Smbios.VersionNr.trim();
@ -544,6 +552,7 @@ void PatchTableType1()
gSettings.Smbios.SerialNr.trim();
if( gSettings.Smbios.SerialNr.notEmpty() ){
UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type1->SerialNumber, gSettings.Smbios.SerialNr);
DBG("%s : UpdateSmbiosString SerialNr=%s\n", __PRETTY_FUNCTION__, gSettings.Smbios.SerialNr.c_str());
}
gSettings.Smbios.BoardNumber.trim();
if( gSettings.Smbios.BoardNumber.notEmpty() ){
@ -620,10 +629,12 @@ void PatchTableType2()
}
gSettings.Smbios.BoardNumber.trim();
if( gSettings.Smbios.BoardNumber.notEmpty() ){
DBG("%s : UpdateSmbiosString ProductName=BoardNumber=%s\n", __PRETTY_FUNCTION__, gSettings.Smbios.BoardNumber.c_str());
UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type2->ProductName, gSettings.Smbios.BoardNumber);
}
gSettings.Smbios.BoardVersion.trim();
if( gSettings.Smbios.BoardVersion.notEmpty() ){
DBG("%s : UpdateSmbiosString Version=BoardVersion=%s\n", __PRETTY_FUNCTION__, gSettings.Smbios.BoardVersion.c_str());
UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type2->Version, gSettings.Smbios.BoardVersion); //iMac17,1 - there is ProductName
}
gSettings.Smbios.BoardSerialNumber.trim();
@ -714,6 +725,7 @@ void PatchTableType3()
gSettings.Smbios.SerialNr.trim();
if( gSettings.Smbios.SerialNr.notEmpty() ){
UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type3->SerialNumber, gSettings.Smbios.SerialNr);
DBG("%s : UpdateSmbiosString SerialNr=%s\n", __PRETTY_FUNCTION__, gSettings.Smbios.SerialNr.c_str());
}
gSettings.Smbios.ChassisAssetTag.trim();
if( gSettings.Smbios.ChassisAssetTag.notEmpty() ){
@ -1285,13 +1297,10 @@ void GetTableType17()
++(gRAM.SMBIOSInUse);
gRAM.SMBIOS[Index].Vendor.takeValueFrom(GetSmbiosString(SmbiosTable, SmbiosTable.Type17->Manufacturer));
gRAM.SMBIOS[Index].Vendor.trim();
gRAM.SMBIOS[Index].Vendor.deleteCharsAtPos(gRAM.SMBIOS[Index].Vendor.indexOf(' '), MAX_XSIZE);
gRAM.SMBIOS[Index].SerialNo.takeValueFrom(GetSmbiosString(SmbiosTable, SmbiosTable.Type17->SerialNumber));
gRAM.SMBIOS[Index].SerialNo.trim();
gRAM.SMBIOS[Index].SerialNo.deleteCharsAtPos(gRAM.SMBIOS[Index].SerialNo.indexOf(' '), MAX_XSIZE);
gRAM.SMBIOS[Index].PartNo.takeValueFrom(GetSmbiosString(SmbiosTable, SmbiosTable.Type17->PartNumber));
gRAM.SMBIOS[Index].PartNo.trim();
gRAM.SMBIOS[Index].PartNo.deleteCharsAtPos(gRAM.SMBIOS[Index].PartNo.indexOf(' '), MAX_XSIZE);
}
// DBG("CntMemorySlots = %d\n", gDMI->CntMemorySlots)
// DBG("gDMI->MemoryModules = %d\n", gDMI->MemoryModules)

View File

@ -18,34 +18,35 @@ extern "C" {
// The maximum sane frequency for a RAM module
#define MAX_RAM_FREQUENCY 5000
typedef struct {
UINT32 ModuleSize;
UINT32 Frequency;
XString8 Vendor;
XString8 PartNo;
XString8 SerialNo;
UINT8 Type;
bool InUse;
} RAM_SLOT_INFO;
class RAM_SLOT_INFO {
public:
UINT32 ModuleSize = UINT32();
UINT32 Frequency = UINT32();
XString8 Vendor = XString8();
XString8 PartNo = XString8();
XString8 SerialNo = XString8();
UINT8 Type = UINT8();
bool InUse = bool();
};
typedef struct
class MEM_STRUCTURE
{
UINT32 Frequency;
UINT32 Divider;
UINT8 TRC;
UINT8 TRP;
UINT8 RAS;
UINT8 Channels;
UINT8 Slots;
UINT8 Type;
UINT8 SPDInUse;
UINT8 SMBIOSInUse;
UINT8 pad[2];
public:
UINT32 Frequency = UINT32();
UINT32 Divider = UINT32();
UINT8 TRC = UINT8();
UINT8 TRP = UINT8();
UINT8 RAS = UINT8();
UINT8 Channels = UINT8();
UINT8 Slots = UINT8();
UINT8 Type = UINT8();
UINT8 SPDInUse = UINT8();
UINT8 SMBIOSInUse = UINT8();
RAM_SLOT_INFO SPD[MAX_RAM_SLOTS * 4];
RAM_SLOT_INFO SMBIOS[MAX_RAM_SLOTS * 4];
} MEM_STRUCTURE;
};
extern APPLE_SMBIOS_STRUCTURE_POINTER SmbiosTable;

View File

@ -810,13 +810,10 @@ STATIC void read_smb(EFI_PCI_IO_PROTOCOL *PciIo, UINT16 vid, UINT16 did)
//gRAM Type = spd_mem_to_smbios[spd_type];
gRAM.SPD[i].PartNo.takeValueFrom(getDDRPartNum(spdbuf, base, i));
gRAM.SPD[i].PartNo.trim();
gRAM.SPD[i].PartNo.deleteCharsAtPos(gRAM.SPD[i].PartNo.indexOf(' '), MAX_XSIZE);
gRAM.SPD[i].Vendor.takeValueFrom(getVendorName(&(gRAM.SPD[i]), spdbuf, base, i));
gRAM.SPD[i].Vendor.trim();
gRAM.SPD[i].Vendor.deleteCharsAtPos(gRAM.SPD[i].Vendor.indexOf(' '), MAX_XSIZE);
gRAM.SPD[i].SerialNo.takeValueFrom(getDDRSerial(spdbuf));
gRAM.SPD[i].SerialNo.trim();
gRAM.SPD[i].SerialNo.deleteCharsAtPos(gRAM.SPD[i].SerialNo.indexOf(' '), MAX_XSIZE);
//XXX - when we can FreePool allocated for these buffers? No this is pointer copy
// determine spd speed
speed = getDDRspeedMhz(spdbuf);

View File

@ -100,3 +100,44 @@ void EndlessIdleLoop(void)
gBS->WaitForEvent(1, &gST->ConIn->WaitForKey, &index);
}
}
BOOLEAN CheckFatalError(IN EFI_STATUS Status, IN CONST CHAR16 *where)
{
// CHAR16 ErrorName[64];
if (!EFI_ERROR(Status))
return FALSE;
MsgLog("Fatal Error: %s %ls\n", efiStrError(Status), where);
// StatusToString(ErrorName, Status);
gST->ConOut->SetAttribute (gST->ConOut, EFI_RED | EFI_BACKGROUND_BLACK);
printf("Fatal Error: %s %ls\n", efiStrError(Status), where);
gST->ConOut->SetAttribute (gST->ConOut, EFI_LIGHTGRAY | EFI_BACKGROUND_BLACK);
haveError = TRUE;
//gBS->Exit(ImageHandle, ExitStatus, ExitDataSize, ExitData);
return TRUE;
}
BOOLEAN CheckError(IN EFI_STATUS Status, IN CONST CHAR16 *where)
{
// CHAR16 ErrorName[64];
if (!EFI_ERROR(Status))
return FALSE;
MsgLog("Fatal Error: %s %ls\n", efiStrError(Status), where);
// StatusToString(ErrorName, Status);
gST->ConOut->SetAttribute (gST->ConOut, EFI_RED | EFI_BACKGROUND_BLACK);
printf("Error: %s %ls\n", efiStrError(Status), where);
gST->ConOut->SetAttribute (gST->ConOut, EFI_LIGHTGRAY | EFI_BACKGROUND_BLACK);
haveError = TRUE;
return TRUE;
}

View File

@ -50,5 +50,16 @@ void EndlessIdleLoop(void)
}
BOOLEAN CheckFatalError(IN EFI_STATUS Status, IN CONST CHAR16 *where)
{
panic("not yet");
}
BOOLEAN CheckError(IN EFI_STATUS Status, IN CONST CHAR16 *where)
{
panic("not yet");
}

View File

@ -1,6 +1,7 @@
#ifndef __XTOOLSCONF_H__
#define __XTOOLSCONF_H__
#include <posix/posix.h>
#define xsize size_t
//#define xisize INTN

View File

@ -126,7 +126,23 @@ class XObjArrayNC
void Remove(const TYPE &Element);
void RemoveAtIndex(size_t nIndex);
void RemoveAtIndex(int nIndex);
void RemoveWithoutFreeingAtIndex(size_t nIndex); // If you use this, there might be a design problem somewhere ???
template<typename IntegralType, enable_if(is_integral(IntegralType))>
TYPE* RemoveWithoutFreeingAtIndex(IntegralType nIndex)
{
if (nIndex < 0) {
panic("XObjArrayNC::ElementAt() : i < 0. System halted\n");
}
unsigned_type(IntegralType) uIndex = (unsigned_type(IntegralType))nIndex;
if ( uIndex >= _Len ) {
panic("XObjArrayNC::ElementAt() -> operator [] - index (%zu) greater than length (%zu)\n", (size_t)nIndex, _Len);
}
TYPE* tmp = _Data[uIndex].Object;
if ( uIndex < _Len-1 ) memcpy(&_Data[nIndex], &_Data[uIndex+1], (_Len-uIndex-1)*sizeof(XObjArrayEntry<TYPE>));
_Len -= 1;
return tmp;
}
//void Remove(int nIndex);
void RemoveAllBut(const TYPE *Element);
@ -710,23 +726,6 @@ void XObjArrayNC<TYPE>::RemoveAtIndex(size_t nIndex)
return;
}
//-------------------------------------------------------------------------------------------------
//
//-------------------------------------------------------------------------------------------------
/* RemoveWithoutFreeing(size_t) */
template<class TYPE>
void XObjArrayNC<TYPE>::RemoveWithoutFreeingAtIndex(size_t nIndex)
{
if ( nIndex < _Len )
{
if ( nIndex<_Len-1 ) memcpy(&_Data[nIndex], &_Data[nIndex+1], (_Len-nIndex-1)*sizeof(XObjArrayEntry<TYPE>));
_Len -= 1;
return;
}
#if defined(_DEBUG)
panic("XObjArray::RemoveWithoutFreeing(size_t) -> nIndex > _Len");
#endif
}
//-------------------------------------------------------------------------------------------------
//

View File

@ -197,8 +197,11 @@ class XStringArray_/* : public XStringArraySuper*/
template<typename XStringClass1, enable_if(is___String(XStringClass1))>
void insertAtPos(const XStringClass1 &aString, size_t pos) { array.InsertRef(new XStringClass1(aString), pos, true); }
void AddReference(XStringClass *newElement, bool FreeIt) { array.AddReference(newElement, FreeIt); }
void insertReferenceAtPos(XStringClass *newElement, size_t pos, bool FreeIt) { array.InsertRef(newElement, pos, FreeIt); }
void AddReference(XStringClass* newElement, bool FreeIt) { array.AddReference(newElement, FreeIt); }
void insertReferenceAtPos(XStringClass* newElement, size_t pos, bool FreeIt) { array.InsertRef(newElement, pos, FreeIt); }
template<typename IntegralType, enable_if(is_integral(IntegralType))>
XStringClass* ExtractFromPos(IntegralType i) { return array.RemoveWithoutFreeingAtIndex(i); }
template<class OtherXStringClass, class OtherXStringArrayClass>
void import(const XStringArray_<OtherXStringClass, OtherXStringArrayClass> &aStrings)

View File

@ -11,6 +11,8 @@
#ifdef __cplusplus
#include <stddef.h> // size_t
struct _xtools__false_type {
static constexpr bool value = false;
bool v() const { return false; }

View File

@ -39,6 +39,7 @@
#include "../include/OSTypes.h"
#include "lib.h"
#include "screen.h"
#include "../Platform/BasicIO.h"
#include "../Platform/BootLog.h"
#include "../Platform/guid.h"
#include "../Platform/APFS.h"