mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-11-23 11:35:19 +01:00
use unified DeviceTreeLib
Signed-off-by: Сергей Исаков <sergey@Sergejs-iMac.local>
This commit is contained in:
parent
6c7ec5f7c5
commit
0979cd808a
@ -468,7 +468,7 @@ DumpDeviceTreeNodeRecusively (
|
||||
if (!EFI_ERROR (Status)) {
|
||||
PropertyParent = "/";
|
||||
|
||||
while ((Status = DTIterateProperties (PropIter, &PropertyName)) == EFI_SUCCESS) {
|
||||
while (!EFI_ERROR(DTIterateProperties (PropIter, &PropertyName))) {
|
||||
if ((Status = DTGetProperty (Entry, (CHAR8 *)PropertyName, (void *)&PropertyValue, &PropertySize)) != EFI_SUCCESS) {
|
||||
DEBUG ((DEBUG_WARN, "DeviceTree is probably invalid - %r\n", Status));
|
||||
break;
|
||||
@ -553,7 +553,7 @@ DumpDeviceTree (
|
||||
///
|
||||
///
|
||||
/// @param[in] Base Pointer to the Device Tree
|
||||
/// @param[in] Length Pointer to location containg the Device Tree length
|
||||
/// @param[in] Length Pointer to location containing the Device Tree length
|
||||
///
|
||||
|
||||
VOID
|
||||
|
@ -610,12 +610,12 @@ DevTreeFix(BootArgs *BA)
|
||||
|
||||
DBG("Fixing DevTree at %p\n", DevTree);
|
||||
DBGnvr("Fixing DevTree at %p\n", DevTree);
|
||||
DTInit(DevTree);
|
||||
if (DTLookupEntry(NULL, "/chosen/memory-map", &MemMap) == kSuccess) {
|
||||
DTInit(DevTree, BA->deviceTreeLength);
|
||||
if (!EFI_ERROR(DTLookupEntry(NULL, "/chosen/memory-map", &MemMap))) {
|
||||
DBG("Found /chosen/memory-map\n");
|
||||
if (DTCreatePropertyIteratorNoAlloc(MemMap, PropIter) == kSuccess) {
|
||||
if (!EFI_ERROR(DTCreatePropertyIterator(MemMap, PropIter))) {
|
||||
DBG("DTCreatePropertyIterator OK\n");
|
||||
while (DTIterateProperties(PropIter, &PropName) == kSuccess) {
|
||||
while (!EFI_ERROR(DTIterateProperties(PropIter, &PropName))) {
|
||||
DBG("= %a, val len=%d: ", PropName, PropIter->currentProperty->length);
|
||||
// all /chosen/memory-map props have DTMemMapEntry (address, length)
|
||||
// values. we need to correct the address
|
||||
|
@ -765,25 +765,26 @@ RuntimeServicesFix(BootArgs *BA)
|
||||
VOID
|
||||
DevTreeFix(BootArgs *BA)
|
||||
{
|
||||
DTEntry DevTree;
|
||||
DTEntry MemMap;
|
||||
struct OpaqueDTPropertyIterator OPropIter;
|
||||
DTPropertyIterator PropIter = &OPropIter;
|
||||
CHAR8 *PropName;
|
||||
DTMemMapEntry *PropValue;
|
||||
DTEntry DevTree;
|
||||
DTEntry MemMap;
|
||||
CHAR8 *PropName;
|
||||
DTMemMapEntry *PropValue;
|
||||
BooterKextFileInfo *KextInfo;
|
||||
|
||||
struct OpaqueDTPropertyIterator OPropIter;
|
||||
DTPropertyIterator PropIter = &OPropIter;
|
||||
|
||||
|
||||
DevTree = (DTEntry)(UINTN)(*BA->deviceTreeP);
|
||||
|
||||
DBG("Fixing DevTree at %p\n", DevTree);
|
||||
DBGnvr("Fixing DevTree at %p\n", DevTree);
|
||||
DTInit(DevTree);
|
||||
if (DTLookupEntry(NULL, "/chosen/memory-map", &MemMap) == kSuccess) {
|
||||
DTInit(DevTree, BA->deviceTreeLength);
|
||||
if (!EFI_ERROR(DTLookupEntry(NULL, "/chosen/memory-map", &MemMap))) {
|
||||
DBG("Found /chosen/memory-map\n");
|
||||
if (DTCreatePropertyIteratorNoAlloc(MemMap, PropIter) == kSuccess) {
|
||||
if (!EFI_ERROR(DTCreatePropertyIterator(MemMap, PropIter))) {
|
||||
DBG("DTCreatePropertyIterator OK\n");
|
||||
while (DTIterateProperties(PropIter, &PropName) == kSuccess) {
|
||||
while (!EFI_ERROR(DTIterateProperties(PropIter, &PropName))) {
|
||||
DBG("= %a, val len=%d: ", PropName, PropIter->currentProperty->length);
|
||||
// all /chosen/memory-map props have DTMemMapEntry (address, length)
|
||||
// values. we need to correct the address
|
||||
@ -801,8 +802,8 @@ DevTreeFix(BootArgs *BA)
|
||||
|
||||
// second check - Address is in our reloc block
|
||||
// (note: *BA->kaddr is not fixed yet and points to reloc block)
|
||||
if ((PropValue->Address < *BA->kaddr)
|
||||
|| (PropValue->Address >= *BA->kaddr + *BA->ksize))
|
||||
if ((PropValue->Address < *BA->kaddr) ||
|
||||
(PropValue->Address >= *BA->kaddr + *BA->ksize))
|
||||
{
|
||||
DBG("DTMemMapEntry->Address is not in reloc block, skipping\n");
|
||||
continue;
|
||||
@ -828,7 +829,7 @@ DevTreeFix(BootArgs *BA)
|
||||
|
||||
}
|
||||
|
||||
/** boot.efi zerod original RT areas after they were relocated to new place.
|
||||
/** boot.efi zeroed original RT areas after they were relocated to new place.
|
||||
* This breaks sleep on some UEFIs and we'll return the content back.
|
||||
* We'll find previous RT areas by reusing gVirtualMemoryMap.
|
||||
*
|
||||
|
@ -191,7 +191,9 @@ INTN find_entry(CONST CHAR8 *propName, CONST CHAR8 *propValue, DTEntry *entryH)
|
||||
}
|
||||
return(kError);
|
||||
}
|
||||
|
||||
//if(DTLookupEntry(NULL,"/",&efiPlatform)==kSuccess)
|
||||
|
||||
INTN
|
||||
DTLookupEntry(CONST DTEntry searchPoint, CONST CHAR8 *pathName, DTEntry *foundEntry)
|
||||
{
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/PrintLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
#include <Library/DeviceTreeLib.h>
|
||||
|
||||
#include <Protocol/LoadedImage.h>
|
||||
#include <Protocol/BlockIo.h>
|
||||
|
@ -29,6 +29,7 @@
|
||||
BaseLib
|
||||
CpuLib
|
||||
DevicePathLib
|
||||
DeviceTreeLib
|
||||
|
||||
[Sources]
|
||||
OsxAptioFix2Drv.c
|
||||
@ -43,8 +44,8 @@
|
||||
VMem.h
|
||||
Lib.c
|
||||
Lib.h
|
||||
FlatDevTree/device_tree.h
|
||||
FlatDevTree/device_tree.c
|
||||
# FlatDevTree/device_tree.h
|
||||
# FlatDevTree/device_tree.c
|
||||
NVRAMDebug.h
|
||||
NVRAMDebug.c
|
||||
Mach-O/UefiLoader.h
|
||||
|
@ -29,6 +29,7 @@
|
||||
BaseLib
|
||||
CpuLib
|
||||
DevicePathLib
|
||||
DeviceTreeLib
|
||||
|
||||
[Sources]
|
||||
OsxAptioFix3Drv.c
|
||||
@ -43,8 +44,8 @@
|
||||
VMem.h
|
||||
Lib.c
|
||||
Lib.h
|
||||
FlatDevTree/device_tree.h
|
||||
FlatDevTree/device_tree.c
|
||||
# FlatDevTree/device_tree.h
|
||||
# FlatDevTree/device_tree.c
|
||||
NVRAMDebug.h
|
||||
NVRAMDebug.c
|
||||
Mach-O/UefiLoader.h
|
||||
|
@ -29,6 +29,7 @@
|
||||
BaseLib
|
||||
CpuLib
|
||||
DevicePathLib
|
||||
DeviceTreeLib
|
||||
|
||||
[Sources]
|
||||
OsxAptioFixDrv.c
|
||||
@ -43,8 +44,8 @@
|
||||
VMem.h
|
||||
Lib.c
|
||||
Lib.h
|
||||
FlatDevTree/device_tree.h
|
||||
FlatDevTree/device_tree.c
|
||||
# FlatDevTree/device_tree.h
|
||||
# FlatDevTree/device_tree.c
|
||||
NVRAMDebug.h
|
||||
NVRAMDebug.c
|
||||
Mach-O/UefiLoader.h
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/PrintLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
#include <Library/DeviceTreeLib.h>
|
||||
|
||||
#include <Protocol/LoadedImage.h>
|
||||
#include <Protocol/BlockIo.h>
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/PrintLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
#include <Library/DeviceTreeLib.h>
|
||||
|
||||
#include <Protocol/LoadedImage.h>
|
||||
#include <Protocol/BlockIo.h>
|
||||
|
@ -22,6 +22,7 @@ Headers collection for procedures
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
#include <Library/DeviceTreeLib.h>
|
||||
#include <Library/GenericBdsLib.h>
|
||||
#include <Library/HiiLib.h>
|
||||
#include <Library/HdaModels.h>
|
||||
|
@ -30,6 +30,7 @@ EFI_PHYSICAL_ADDRESS KernelRelocBase = 0;
|
||||
BootArgs1 *bootArgs1 = NULL;
|
||||
BootArgs2 *bootArgs2 = NULL;
|
||||
CHAR8 *dtRoot = NULL;
|
||||
UINT32 *dtLength;
|
||||
VOID *KernelData = NULL;
|
||||
UINT32 KernelSlide = 0;
|
||||
BOOLEAN isKernelcache = FALSE;
|
||||
@ -1677,6 +1678,7 @@ FindBootArgs(IN LOADER_ENTRY *Entry)
|
||||
) {
|
||||
// set vars
|
||||
dtRoot = (CHAR8*)(UINTN)bootArgs2->deviceTreeP;
|
||||
dtLength = bootArgs2->deviceTreeLength;
|
||||
KernelSlide = bootArgs2->kslide;
|
||||
|
||||
DBG_RT(Entry, "Found bootArgs2 at 0x%08x, DevTree at %p\n", ptr, dtRoot);
|
||||
@ -1706,6 +1708,7 @@ FindBootArgs(IN LOADER_ENTRY *Entry)
|
||||
) {
|
||||
// set vars
|
||||
dtRoot = (CHAR8*)(UINTN)bootArgs1->deviceTreeP;
|
||||
dtLength = bootArgs1->deviceTreeLength;
|
||||
|
||||
DBG_RT(Entry, "Found bootArgs1 at 0x%08x, DevTree at %p\n", ptr, dtRoot);
|
||||
//DBG("bootArgs1->kaddr = 0x%08x and bootArgs1->ksize = 0x%08x\n", bootArgs1->kaddr, bootArgs1->ksize);
|
||||
|
@ -76,6 +76,7 @@ extern EFI_PHYSICAL_ADDRESS KernelRelocBase;
|
||||
extern BootArgs1 *bootArgs1;
|
||||
extern BootArgs2 *bootArgs2;
|
||||
extern CHAR8 *dtRoot;
|
||||
extern UINT32 *dtLength;
|
||||
extern VOID *KernelData;
|
||||
extern UINT32 KernelSlide;
|
||||
extern BOOLEAN isKernelcache;
|
||||
|
@ -563,7 +563,7 @@ EFI_STATUS LoadKexts(IN LOADER_ENTRY *Entry)
|
||||
EFI_STATUS InjectKexts(/*IN EFI_MEMORY_DESCRIPTOR *Desc*/ IN UINT32 deviceTreeP, IN UINT32* deviceTreeLength, LOADER_ENTRY *Entry)
|
||||
{
|
||||
UINT8 *dtEntry = (UINT8*)(UINTN) deviceTreeP;
|
||||
UINTN dtLength = (UINTN) *deviceTreeLength;
|
||||
UINTN dtLen = (UINTN) *deviceTreeLength;
|
||||
|
||||
DTEntry platformEntry;
|
||||
DTEntry memmapEntry;
|
||||
@ -609,10 +609,10 @@ EFI_STATUS InjectKexts(/*IN EFI_MEMORY_DESCRIPTOR *Desc*/ IN UINT32 deviceTreeP,
|
||||
// drvinfo->executablePhysAddr += (UINT32)kextsBase;
|
||||
// drvinfo->bundlePathPhysAddr += (UINT32)kextsBase;
|
||||
|
||||
DTInit(dtEntry);
|
||||
if(DTLookupEntry(NULL,"/chosen/memory-map",&memmapEntry)==kSuccess) {
|
||||
if(DTCreatePropertyIteratorNoAlloc(memmapEntry,iter)==kSuccess) {
|
||||
while(DTIterateProperties(iter,&ptr)==kSuccess) {
|
||||
DTInit(dtEntry, deviceTreeLength);
|
||||
if(!EFI_ERROR(DTLookupEntry(NULL,"/chosen/memory-map",&memmapEntry))) {
|
||||
if(!EFI_ERROR(DTCreatePropertyIterator(memmapEntry,iter))) {
|
||||
while(!EFI_ERROR(DTIterateProperties(iter,&ptr))) {
|
||||
prop = iter->currentProperty;
|
||||
drvPtr = (UINT8*) prop;
|
||||
if(AsciiStrnCmp(prop->name, "Driver-", 7)==0 || AsciiStrnCmp(prop->name, "DriversPackage-", 15)==0) {
|
||||
@ -622,14 +622,14 @@ EFI_STATUS InjectKexts(/*IN EFI_MEMORY_DESCRIPTOR *Desc*/ IN UINT32 deviceTreeP,
|
||||
}
|
||||
}
|
||||
|
||||
if(DTLookupEntry(NULL,"/efi/platform",&platformEntry)==kSuccess) {
|
||||
if(DTCreatePropertyIteratorNoAlloc(platformEntry,iter)==kSuccess) {
|
||||
while(DTIterateProperties(iter,&ptr)==kSuccess) {
|
||||
if(!EFI_ERROR(DTLookupEntry(NULL,"/efi/platform",&platformEntry))) {
|
||||
if(!EFI_ERROR(DTCreatePropertyIterator(platformEntry,iter))) {
|
||||
while(!EFI_ERROR(DTIterateProperties(iter,&ptr))) {
|
||||
prop = iter->currentProperty;
|
||||
if(AsciiStrCmp(prop->name,"mm_extra")==0) {
|
||||
if(AsciiStrnCmp(prop->name, "mm_extra", 8)==0) {
|
||||
infoPtr = (UINT8*) prop;
|
||||
}
|
||||
if(AsciiStrCmp(prop->name,"extra")==0) {
|
||||
if(AsciiStrnCmp(prop->name, "extra", 5)==0) {
|
||||
extraPtr = (UINT8*) prop;
|
||||
}
|
||||
}
|
||||
@ -650,7 +650,7 @@ EFI_STATUS InjectKexts(/*IN EFI_MEMORY_DESCRIPTOR *Desc*/ IN UINT32 deviceTreeP,
|
||||
// make space behind device tree
|
||||
// platformEntry->nProperties--;
|
||||
offset = sizeof(DeviceTreeNodeProperty)+((DeviceTreeNodeProperty*) extraPtr)->length;
|
||||
CopyMem(extraPtr, extraPtr+offset, dtLength-(UINTN)(extraPtr-dtEntry)-offset);
|
||||
CopyMem(extraPtr, extraPtr+offset, dtLen-(UINTN)(extraPtr-dtEntry)-offset);
|
||||
*deviceTreeLength -= (UINT32)offset;
|
||||
|
||||
KextBase = RoundPage(dtEntry + *deviceTreeLength);
|
||||
|
@ -1384,15 +1384,15 @@ VOID PatchLoadedKexts(LOADER_ENTRY *Entry)
|
||||
|
||||
DBG(L"\nPatchLoadedKexts ... dtRoot = %p\n", dtRoot);
|
||||
|
||||
if (!dtRoot) {
|
||||
if (!dtRoot || !dtLength) {
|
||||
return;
|
||||
}
|
||||
|
||||
DTInit(dtRoot);
|
||||
DTInit(dtRoot, dtLength);
|
||||
|
||||
if (DTLookupEntry(NULL,"/chosen/memory-map", &MMEntry) == kSuccess) {
|
||||
if (DTCreatePropertyIteratorNoAlloc(MMEntry, PropIter) == kSuccess) {
|
||||
while (DTIterateProperties(PropIter, &PropName) == kSuccess) {
|
||||
if (!EFI_ERROR(DTLookupEntry(NULL,"/chosen/memory-map", &MMEntry))) {
|
||||
if (!EFI_ERROR(DTCreatePropertyIterator(MMEntry, PropIter))) {
|
||||
while (!EFI_ERROR(DTIterateProperties(PropIter, &PropName))) {
|
||||
//DBG(L"Prop: %a\n", PropName);
|
||||
if (AsciiStrStr(PropName,"Driver-")) {
|
||||
// PropEntry _DeviceTreeBuffer is the value of Driver-XXXXXX property
|
||||
@ -1415,11 +1415,7 @@ VOID PatchLoadedKexts(LOADER_ENTRY *Entry)
|
||||
Entry
|
||||
);
|
||||
|
||||
// Check for FakeSMC here
|
||||
// CheckForFakeSMC(InfoPlist, Entry); //Slice - no reason to check loaded kext to disable load kexts
|
||||
|
||||
InfoPlist[KextFileInfo->infoDictLength] = SavedValue;
|
||||
//DbgCount++;
|
||||
}
|
||||
//if(AsciiStrStr(PropName,"DriversPackage-")!=0)
|
||||
//{
|
||||
|
@ -102,6 +102,7 @@
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
#include <Library/DeviceTreeLib.h>
|
||||
#include <Library/DxeServicesLib.h>
|
||||
#include <Library/DxeServicesTableLib.h>
|
||||
//#include <Library/EblCmdLib.h>
|
||||
|
@ -98,8 +98,8 @@
|
||||
# Platform/DataHubRecords.h
|
||||
Platform/device_inject.c
|
||||
Platform/device_inject.h
|
||||
Platform/device_tree.c
|
||||
Platform/device_tree.h
|
||||
# Platform/device_tree.c
|
||||
# Platform/device_tree.h
|
||||
Platform/Edid.c
|
||||
Platform/Events.c
|
||||
Platform/hda.c
|
||||
@ -178,6 +178,7 @@
|
||||
BaseMemoryLib
|
||||
BaseLib
|
||||
DevicePathLib
|
||||
DeviceTreeLib
|
||||
DebugLib
|
||||
DxeServicesLib
|
||||
DxeServicesTableLib
|
||||
|
Loading…
Reference in New Issue
Block a user