| 337 | } |
| 338 | |
| 339 | EFI_STATUS LOADER_ENTRY::LoadKexts() |
| 340 | { |
| 341 | XStringW SrcDir; |
| 342 | REFIT_DIR_ITER PlugInIter; |
| 343 | EFI_FILE_INFO *PlugInFile; |
| 344 | XStringW FileName; |
| 345 | XStringW PlugIns; |
| 346 | // CONST CHAR16 *Arch = NULL; |
| 347 | // CONST CHAR16 *Ptr = NULL; |
| 348 | #if defined(MDE_CPU_X64) |
| 349 | cpu_type_t archCpuType=CPU_TYPE_X86_64; |
| 350 | #else |
| 351 | cpu_type_t archCpuType=CPU_TYPE_I386; |
| 352 | #endif |
| 353 | UINTN mm_extra_size; |
| 354 | VOID *mm_extra; |
| 355 | UINTN extra_size; |
| 356 | VOID *extra; |
| 357 | |
| 358 | |
| 359 | // Make Arch point to the last appearance of "arch=" in LoadOptions (which is what boot.efi will use). |
| 360 | // if (LoadOptions.notEmpty()) { |
| 361 | // for (Ptr = StrStr(LoadOptions, L"arch="); Ptr != NULL; Arch = Ptr + StrLen(L"arch="), Ptr = StrStr(Arch, L"arch=")); |
| 362 | // } |
| 363 | |
| 364 | // if (Arch != NULL && StrnCmp(Arch,L"x86_64",StrLen(L"x86_64")) == 0) { |
| 365 | if (LoadOptions.contains("arch=x86_64")) { |
| 366 | archCpuType = CPU_TYPE_X86_64; |
| 367 | // } else if (Arch != NULL && StrnCmp(Arch,L"i386",StrLen(L"i386")) == 0) { |
| 368 | } else if (LoadOptions.contains("arch=i386")) { |
| 369 | archCpuType = CPU_TYPE_I386; |
| 370 | } else if (OSVersion.notEmpty()) { |
| 371 | UINT64 os_version = AsciiOSVersionToUint64(OSVersion); |
| 372 | if (os_version >= AsciiOSVersionToUint64("10.8"_XS8)) { |
| 373 | archCpuType = CPU_TYPE_X86_64; // For OSVersion >= 10.8, only x86_64 exists |
| 374 | } else if (os_version < AsciiOSVersionToUint64("10.7"_XS8)) { |
| 375 | archCpuType = CPU_TYPE_I386; // For OSVersion < 10.7, use default of i386 |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | // Force kexts to load |
| 380 | if ( KernelAndKextPatches.ForceKexts.notEmpty() ) { |
| 381 | for (size_t i = 0; i < KernelAndKextPatches.ForceKexts.size(); ++i) { |
| 382 | MsgLog(" Force kext: %ls\n", KernelAndKextPatches.ForceKexts[i].wc_str()); |
| 383 | if (Volume && Volume->RootDir) { |
| 384 | // Check if the entry is a directory |
| 385 | if (StrStr(KernelAndKextPatches.ForceKexts[i].wc_str(), L".kext") == NULL) { |
| 386 | DirIterOpen(Volume->RootDir, KernelAndKextPatches.ForceKexts[i].wc_str(), &PlugInIter); |
| 387 | while (DirIterNext(&PlugInIter, 1, L"*.kext", &PlugInFile)) { |
| 388 | if (PlugInFile->FileName[0] == '.' || StrStr(PlugInFile->FileName, L".kext") == NULL) |
| 389 | continue; // skip this |
| 390 | FileName = SWPrintf("%ls\\%ls", KernelAndKextPatches.ForceKexts[i].wc_str(), PlugInFile->FileName); |
| 391 | // snwprintf(FileName, 512, "%s\\%s", KernelAndKextPatches.ForceKexts[i], PlugInFile->FileName); |
| 392 | MsgLog(" Force kext: %ls\n", FileName.wc_str()); |
| 393 | AddKext( Volume->RootDir, FileName.wc_str(), archCpuType); |
| 394 | PlugIns = SWPrintf("%ls\\Contents\\PlugIns", FileName.wc_str()); |
| 395 | // snwprintf(PlugIns, 512, "%s\\Contents\\PlugIns", FileName); |
| 396 | LoadPlugInKexts(Volume->RootDir, PlugIns.wc_str(), archCpuType, TRUE); |
nothing calls this directly
no test coverage detected