I've got KGDB in place and it works without too many dramas.
I've got the relocations in place and the relocations seem to be
calculated correctly.
I've got the patch at the nd of this message in place to keep the
module within 26 bits of the make kernel text. I'm not 100%
convinced that this code fragment means what it looks like it means,
which is a somewhat hazardous position to be in when you are dealing
with kernel memory, but it works for me and I'm not interested in
generalising for arm32 until _after_ I get modules to load properly.
The modules loaded from disk still crash. I'm doing my tests with
tmpfs and it dies in tmpfs_modcmd with some damage to the stack as
far as I can see. I've added these two printfs to tmpfs_modcmd()
before the switch statement.
printf ("tmpfs_modcmd called\n");
printf ("MODULE_CMD_INIT calling %p with %p\n", vfs_attach,
&tmpfs_vfsops);
They print out exactly what they should print out. If I move the
second printf after the "case MODULE_CMD_INIT", but before the
"return vfs_attach", then only the first printf gets executed.
The trap I get is "Fatal kernel mode prefetch abort at 0xc1ff3574".
I don't think there is any memory there, and I have no idea why the
system tried executing there. It looks as if something went wrong
with the return from printf.
diff -u -r1.59 arm32_machdep.c
--- arm32_machdep.c 19 Nov 2008 06:22:15 -0000 1.59
+++ arm32_machdep.c 1 Jan 2009 22:06:39 -0000
@@ -74,6 +74,9 @@
struct vm_map *mb_map = NULL;
struct vm_map *phys_map = NULL;
+vaddr_t module_start, module_end;
+extern struct vm_map *module_map;
+
extern int physmem;
#if NMD > 0 && defined(MEMORY_DISK_HOOKS) && !
defined(MEMORY_DISK_ROOT_SIZE)
@@ -266,6 +269,10 @@
nmbclusters * mclbytes,
VM_MAP_INTRSAFE,
false, NULL);
+ module_start = 0xc0000000;
+ module_end = 0xc2000000;
+ module_map = uvm_km_suballoc (kernel_map, &module_start,
&module_end, 0x100000, false, false, NULL);
+
format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
printf("avail memory = %s\n", pbuf);