Add OEM path possibilities.

This commit is contained in:
jief 2019-12-11 12:39:06 +01:00
parent bbfdd287be
commit 43dc4fd707

View File

@ -1762,20 +1762,51 @@ VOID ResetNvram ()
// TerminateScreen();
}
extern UINTN nLanCards; // number of LAN cards
extern UINT16 gLanVendor[4]; // their vendors
extern UINT8 *gLanMmio[4]; // their MMIO regions
extern UINT8 gLanMac[4][6]; // their MAC addresses
extern UINTN nLanPaths; // number of LAN pathes
BOOLEAN CheckOEMPathExists(IN EFI_FILE *Root, IN CHAR16 *path, CHAR16 *ConfName)
{
BOOLEAN res = FileExists(Root, path);
if ( res ) {
CHAR16 ConfigPath[1024];
UnicodeSPrint(ConfigPath, sizeof(ConfigPath), L"%s\\%s.plist", path, ConfName);
BOOLEAN res2 = FileExists(Root, ConfigPath);
if ( res2 ) {
OEMPath = path;
DBG ("CheckOEMPathExists: set OEMPath: %s\n", OEMPath);
return 1;
}else{
DBG("CheckOEMPathExists tried %s. '%s.plist' not exists in dir\n", path, ConfName);
FreePool(path);
}
}else{
DBG("CheckOEMPathExists tried %s. Dir not exists\n", path);
FreePool(path);
}
return 0;
}
VOID SetOEMPath(CHAR16 *ConfName)
{
if (ConfName == NULL) {
OEMPath = L"EFI\\CLOVER";
} else if (!gFirmwareClover &&
FileExists(SelfRootDir,
PoolPrint(L"EFI\\CLOVER\\OEM\\%a\\UEFI\\%s.plist", gSettings.OEMBoard, ConfName))) {
OEMPath = PoolPrint(L"EFI\\CLOVER\\OEM\\%a\\UEFI", gSettings.OEMBoard);
} else if (FileExists(SelfRootDir, PoolPrint(L"EFI\\CLOVER\\OEM\\%a\\%s.plist", gSettings.OEMProduct, ConfName))) {
OEMPath = PoolPrint(L"EFI\\CLOVER\\OEM\\%a", gSettings.OEMProduct);
} else if (FileExists(SelfRootDir, PoolPrint(L"EFI\\CLOVER\\OEM\\%a\\%s.plist", gSettings.OEMBoard, ConfName))) {
OEMPath = PoolPrint(L"EFI\\CLOVER\\OEM\\%a", gSettings.OEMBoard);
DBG ("set OEMPath (ConfName == NULL): %s\n", OEMPath);
} else if ( nLanCards > 0 && CheckOEMPathExists(SelfRootDir, PoolPrint(L"EFI\\CLOVER\\OEM\\%a--%02x-%02x-%02x-%02x-%02x-%02x", gSettings.OEMProduct, gLanMac[0][0], gLanMac[0][1], gLanMac[0][2], gLanMac[0][3], gLanMac[0][4], gLanMac[0][5]), ConfName)) {
} else if ( nLanCards > 1 && CheckOEMPathExists(SelfRootDir, PoolPrint(L"EFI\\CLOVER\\OEM\\%a--%02x-%02x-%02x-%02x-%02x-%02x", gSettings.OEMProduct, gLanMac[1][0], gLanMac[1][1], gLanMac[1][2], gLanMac[1][3], gLanMac[1][4], gLanMac[1][5]), ConfName)) {
} else if ( nLanCards > 2 && CheckOEMPathExists(SelfRootDir, PoolPrint(L"EFI\\CLOVER\\OEM\\%a--%02x-%02x-%02x-%02x-%02x-%02x", gSettings.OEMProduct, gLanMac[2][0], gLanMac[2][1], gLanMac[2][2], gLanMac[2][3], gLanMac[2][4], gLanMac[2][5]), ConfName)) {
} else if ( nLanCards > 3 && CheckOEMPathExists(SelfRootDir, PoolPrint(L"EFI\\CLOVER\\OEM\\%a--%02x-%02x-%02x-%02x-%02x-%02x", gSettings.OEMProduct, gLanMac[3][0], gLanMac[3][1], gLanMac[3][2], gLanMac[3][3], gLanMac[3][4], gLanMac[3][5]), ConfName)) {
} else if (!gFirmwareClover && CheckOEMPathExists(SelfRootDir, PoolPrint(L"EFI\\CLOVER\\OEM\\%a\\UEFI", gSettings.OEMBoard), ConfName)) {
} else if (CheckOEMPathExists(SelfRootDir, PoolPrint(L"EFI\\CLOVER\\OEM\\%a", gSettings.OEMProduct), ConfName)) {
} else if (CheckOEMPathExists(SelfRootDir, PoolPrint(L"EFI\\CLOVER\\OEM\\%a-%d", gSettings.OEMProduct, (INT32)(DivU64x32(gCPUStructure.CPUFrequency, Mega))), ConfName)) {
} else if (CheckOEMPathExists(SelfRootDir, PoolPrint(L"EFI\\CLOVER\\OEM\\%a", gSettings.OEMBoard), ConfName)) {
} else if (CheckOEMPathExists(SelfRootDir, PoolPrint(L"EFI\\CLOVER\\OEM\\%a-%d", gSettings.OEMBoard, (INT32)(DivU64x32(gCPUStructure.CPUFrequency, Mega))), ConfName) ) {
} else {
OEMPath = L"EFI\\CLOVER";
DBG ("set OEMPath by default: %s\n", OEMPath);
}
}