Okay, I get the general idea now...
I've made a keymap, a simple .bin file. I load this as a module (module /boot/keymap.bin). I get the address that the module's loaded at from the multiboot data structure, and then try to load my keymap from there (using the following code - although I strongly suspect the code is right, and that the bug lies in loading the module somehow).
Code:
void loadKeymap(void *mbdata)
{
unsigned long *modadd = mbdata;
modadd = &modadd[6];
unsigned char *modkeymap;
modkeymap = (unsigned char*) *modadd; /* Get a pointer to our keymap
module - lowercase is at the
start and is 88 chars long */
unsigned char *modkeymapshift = &modkeymap[88]; /* Get a pointer to the uppercase
section of our keymap module -
lowercase is 88 chars long, starting
at 0 so our uppercase starts at
index 88 */
puts(" from 0x");
char buf[10];
puts(itoa((long) modkeymap, buf, 16));
for(int i = 0; i < 88; i++)
{
keymap[i] = modkeymap[i];
keymapshift[i] = modkeymapshift[i+88];
}
puts("...");
}
However, this is bizarre, it has to be said. I get all sorts of alternative characters - I'm guessing I'm reading uninitialized memory. Using a debug build of bochs, and doing
xp /8b 0x20B40
I can see that the keymap isn't there, at all (this is the address that is printed as being loaded - and is in the data structure (I've got code that dumps that to the bochs i/o console ports)). So basically - what do I have to do with this address to get where my module has actually been loaded?