Loading...
--- xnu/xnu-123.5/libsa/bootstrap.cpp
+++ xnu/xnu-792.6.76/libsa/bootstrap.cpp
@@ -23,13 +23,12 @@
#include <mach/kmod.h>
#include <libkern/c++/OSDictionary.h>
-#include <libsa/kmod.h>
+#include <libsa/kext.h>
#include <libsa/catalogue.h>
-extern "C" {
#include <libsa/malloc.h>
-};
-extern "C" {
+#include "kld_patch.h"
+
/*****
* This function is used by IOCatalogue to load a kernel
* extension. libsa initially sets it to be a function
@@ -50,9 +49,6 @@
*/
extern int kernelLinkerPresent;
-extern IOLock * kld_lock;
-};
-
class KLDBootstrap {
public:
@@ -69,8 +65,7 @@
*/
KLDBootstrap::KLDBootstrap() {
- kld_lock = IOLockAlloc();
- IOLockLock(kld_lock);
+ malloc_init();
kmod_load_function = &load_kernel_extension;
@@ -79,8 +74,6 @@
remove_startup_extension_function = &removeStartupExtension;
kernelLinkerPresent = 1;
-
- IOLockUnlock(kld_lock);
}
/* The destructor frees all wired memory regions held
@@ -88,16 +81,15 @@
*/
KLDBootstrap::~KLDBootstrap() {
- OSDictionary * startupExtensions;
+ kld_file_cleanup_all_resources();
- IOLockLock(kld_lock);
+ /* Dump all device-tree entries for boot drivers, and all
+ * info on startup extensions. The IOCatalogue will now
+ * get personalities from kextd.
+ */
+ clearStartupExtensionsAndLoaderInfo();
+ /* Free all temporary malloc memory.
+ */
malloc_reset();
-
- startupExtensions = getStartupExtensions();
- if (startupExtensions) startupExtensions->release();
-
- IOLockUnlock(kld_lock);
- IOLockFree(kld_lock);
-
}