vkernel64 - Start work on kld support
authorMatthew Dillon <dillon@apollo.backplane.com>
Fri, 15 Apr 2011 15:29:55 +0000 (08:29 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Fri, 15 Apr 2011 15:29:55 +0000 (08:29 -0700)
* This is a non-working commit but it progresses the issue a bit.

sys/platform/vkernel64/platform/init.c

index fab9a6c..ad6af17 100644 (file)
@@ -52,6 +52,7 @@
 #include <sys/sysctl.h>
 #include <sys/un.h>
 #include <vm/vm_page.h>
+#include <vm/vm_map.h>
 #include <sys/mplock2.h>
 
 #include <machine/cpu.h>
@@ -1296,3 +1297,45 @@ setrealcpu(void)
                break;
        }
 }
+
+/*
+ * Allocate and free memory for module loading.  The loaded module
+ * has to be placed somewhere near the current kernel binary load
+ * point or the relocations will not work.
+ *
+ * I'm not sure why this isn't working.
+ */
+int
+vkernel_module_memory_alloc(vm_offset_t *basep, size_t bytes)
+{
+       kprintf("module loading for vkernel64's not currently supported\n");
+       *basep = 0;
+       return ENOMEM;
+#if 0
+#if 1
+       size_t xtra;
+       xtra = (PAGE_SIZE - (vm_offset_t)sbrk(0)) & PAGE_MASK;
+       *basep = (vm_offset_t)sbrk(xtra + bytes) + xtra;
+       bzero((void *)*basep, bytes);
+#else
+       *basep = (vm_offset_t)mmap((void *)0x000000000, bytes,
+                                  PROT_READ|PROT_WRITE|PROT_EXEC,
+                                  MAP_ANON|MAP_SHARED, -1, 0);
+       if ((void *)*basep == MAP_FAILED)
+               return ENOMEM;
+#endif
+       kprintf("basep %p %p %zd\n",
+               (void *)vkernel_module_memory_alloc, (void *)*basep, bytes);
+       return 0;
+#endif
+}
+
+void
+vkernel_module_memory_free(vm_offset_t base, size_t bytes)
+{
+#if 0
+#if 0
+       munmap((void *)base, bytes);
+#endif
+#endif
+}