Loading...
libsa/bootstrap.cpp xnu-201 xnu-123.5
--- xnu/xnu-201/libsa/bootstrap.cpp
+++ xnu/xnu-123.5/libsa/bootstrap.cpp
@@ -29,8 +29,6 @@
 #include <libsa/malloc.h>
 };
 
-#include "kld_patch.h"
-
 extern "C" {
 /*****
  * This function is used by IOCatalogue to load a kernel
@@ -51,6 +49,8 @@
  * about loading and matching drivers.
  */
 extern int kernelLinkerPresent;
+
+extern IOLock * kld_lock;
 };
 
 
@@ -69,6 +69,9 @@
  */
 KLDBootstrap::KLDBootstrap() {
 
+    kld_lock = IOLockAlloc();
+    IOLockLock(kld_lock);
+
     kmod_load_function = &load_kernel_extension;
 
     record_startup_extensions_function = &recordStartupExtensions;
@@ -76,6 +79,8 @@
     remove_startup_extension_function = &removeStartupExtension;
 
     kernelLinkerPresent = 1;
+
+    IOLockUnlock(kld_lock);
 }
 
 /* The destructor frees all wired memory regions held
@@ -83,15 +88,16 @@
  */
 KLDBootstrap::~KLDBootstrap() {
 
-    kld_file_cleanup_all_resources();
+    OSDictionary * startupExtensions;
 
-   /* Dump all device-tree entries for boot drivers, and all
-    * info on startup extensions. The IOCatalogue will now
-    * get personalities from kextd.
-    */
-    clearStartupExtensionsAndLoaderInfo();
+    IOLockLock(kld_lock);
 
-   /* Free all temporary malloc memory.
-    */
     malloc_reset();
+
+    startupExtensions = getStartupExtensions();
+    if (startupExtensions) startupExtensions->release();
+
+    IOLockUnlock(kld_lock);
+    IOLockFree(kld_lock);
+
 }