From bf7c52537fec15329cb8a1b39073717d10650d4f Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Fri, 15 Apr 2011 08:29:55 -0700 Subject: [PATCH] vkernel64 - Start work on kld support * This is a non-working commit but it progresses the issue a bit. --- sys/platform/vkernel64/platform/init.c | 43 ++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/sys/platform/vkernel64/platform/init.c b/sys/platform/vkernel64/platform/init.c index fab9a6c877..ad6af1721a 100644 --- a/sys/platform/vkernel64/platform/init.c +++ b/sys/platform/vkernel64/platform/init.c @@ -52,6 +52,7 @@ #include #include #include +#include #include #include @@ -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 +} -- 2.11.4.GIT