MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / InjectKexts

Method InjectKexts

rEFIt_UEFI/Platform/kext_inject.cpp:712–857  ·  view source on GitHub ↗

/////////////// OnExitBootServices ///////////////

Source from the content-addressed store, hash-verified

710// OnExitBootServices
711////////////////////
712EFI_STATUS LOADER_ENTRY::InjectKexts(IN UINT32 deviceTreeP, IN UINT32* deviceTreeLength)
713{
714 UINT8 *dtEntry = (UINT8*)(UINTN) deviceTreeP;
715 UINTN dtLen = (UINTN) *deviceTreeLength;
716
717 DTEntry platformEntry;
718 DTEntry memmapEntry;
719 CHAR8 *ptr;
720 OpaqueDTPropertyIterator OPropIter;
721 DTPropertyIterator iter = &OPropIter;
722 DeviceTreeNodeProperty *prop = NULL;
723
724 UINT8 *infoPtr = 0;
725 UINT8 *extraPtr = 0;
726 UINT8 *drvPtr = 0;
727 UINTN offset = 0;
728
729 LIST_ENTRY *Link;
730 KEXT_ENTRY *KextEntry;
731 UINTN KextBase = 0;
732 _DeviceTreeBuffer *mm;
733 _BooterKextFileInfo *drvinfo;
734
735 UINT32 KextCount;
736 UINTN Index;
737
738
739 DBG_RT("\nInjectKexts: ");
740 DBG("\nInjectKexts: ");
741 KextCount = GetKextCount();
742 if (KextCount == 0) {
743 DBG_RT("no kexts to inject.\nPausing 5 secs ...\n");
744 if (KernelAndKextPatches.KPDebug) {
745 gBS->Stall(5000000);
746 }
747 return EFI_NOT_FOUND;
748 }
749 DBG_RT("%d kexts ...\n", KextCount);
750
751 // kextsBase = Desc->PhysicalStart + (((UINTN) Desc->NumberOfPages) * EFI_PAGE_SIZE);
752 // kextsPages = EFI_SIZE_TO_PAGES(kext.length);
753 // Status = gBS->AllocatePages(AllocateAddress, EfiLoaderData, kextsPages, &kextsBase);
754 // if (EFI_ERROR(Status)) { MsgLog("Kext inject: could not allocate memory\n"); return Status; }
755 // Desc->NumberOfPages += kextsPages;
756 // CopyMem((VOID*)kextsBase, (VOID*)(UINTN)kext.paddr, kext.length);
757 // drvinfo = (_BooterKextFileInfo*) kextsBase;
758 // drvinfo->infoDictPhysAddr += (UINT32)kextsBase;
759 // drvinfo->executablePhysAddr += (UINT32)kextsBase;
760 // drvinfo->bundlePathPhysAddr += (UINT32)kextsBase;
761
762 DTInit(dtEntry, deviceTreeLength);
763 if(!EFI_ERROR(DTLookupEntry(NULL,"/chosen/memory-map", &memmapEntry))) {
764 if(!EFI_ERROR(DTCreatePropertyIterator(memmapEntry, iter))) {
765 while(!EFI_ERROR(DTIterateProperties(iter, &ptr))) {
766 prop = iter->CurrentProperty;
767 drvPtr = (UINT8*) prop;
768 if(strncmp(prop->Name, "Driver-", 7)==0 || strncmp(prop->Name, "DriversPackage-", 15)==0) {
769 break;

Callers

nothing calls this directly

Calls 13

GetKextCountFunction · 0.85
strncmpFunction · 0.85
printfFunction · 0.85
IsListEmptyFunction · 0.85
snprintfFunction · 0.85
StallMethod · 0.80
DTInitFunction · 0.50
DTLookupEntryFunction · 0.50
DTCreatePropertyIteratorFunction · 0.50
DTIteratePropertiesFunction · 0.50
CopyMemFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected