Boot NetBSD with custom bootloader via multiboot
Posted: Thu Feb 28, 2013 3:21 pm
Hi all,
My first post, so apologies in advance if this is the wrong forum!
Anyway, here is my situation. I have a standard NetBSD kernel (stripped down to about 4MB) and a custom bootloader (similar to BSDs but ending up in good ol' C and long mode).
At the end of my boot2 routine, I create the MIS structure for NetBSD and push the location into EBX. The magic number 0xBAD2B002 is being pushed into EAX. When I release control to the OS, I can see the first few assembler instructions being executed. An objdump -D netbsd | less tells me:
netbsd: file format elf64-x86-64
Disassembly of section .text:
ffffffff80100000 <start>:
ffffffff80100000: 66 c7 05 72 04 00 00 movw $0x1234,0x472(%rip) # ffffffff8010047b <cpu_switchto+0x7b>
ffffffff80100007: 34 12
ffffffff80100009: 8b 44 24 04 mov 0x4(%rsp),%eax
ffffffff8010000d: a3 18 66 4c 00 8b 44 movabs %eax,0xc24448b004c6618
ffffffff80100014: 24 0c
ffffffff80100016: 85 c0 test %eax,%eax
ffffffff80100018: 74 64 je ffffffff8010007e <start+0x7e>
The first few steps, as I said, are being executed. However, the movabs instruction fails and Bochs tells me that the operand is not a valid canonical address. That is correct, it is not. But the BSD bootloader must do something to avoid this?
What is this instruction being used for? Does anyone have an idea?
Thanks for any ideas/pointers.
My first post, so apologies in advance if this is the wrong forum!
Anyway, here is my situation. I have a standard NetBSD kernel (stripped down to about 4MB) and a custom bootloader (similar to BSDs but ending up in good ol' C and long mode).
At the end of my boot2 routine, I create the MIS structure for NetBSD and push the location into EBX. The magic number 0xBAD2B002 is being pushed into EAX. When I release control to the OS, I can see the first few assembler instructions being executed. An objdump -D netbsd | less tells me:
netbsd: file format elf64-x86-64
Disassembly of section .text:
ffffffff80100000 <start>:
ffffffff80100000: 66 c7 05 72 04 00 00 movw $0x1234,0x472(%rip) # ffffffff8010047b <cpu_switchto+0x7b>
ffffffff80100007: 34 12
ffffffff80100009: 8b 44 24 04 mov 0x4(%rsp),%eax
ffffffff8010000d: a3 18 66 4c 00 8b 44 movabs %eax,0xc24448b004c6618
ffffffff80100014: 24 0c
ffffffff80100016: 85 c0 test %eax,%eax
ffffffff80100018: 74 64 je ffffffff8010007e <start+0x7e>
The first few steps, as I said, are being executed. However, the movabs instruction fails and Bochs tells me that the operand is not a valid canonical address. That is correct, it is not. But the BSD bootloader must do something to avoid this?
What is this instruction being used for? Does anyone have an idea?
Thanks for any ideas/pointers.