Computer crashes once bootloader tries to jump to kernel cod
-
distantvoices
- Member

- Posts: 1600
- Joined: Wed Oct 18, 2006 11:59 am
- Location: Vienna/Austria
- Contact:
Re:Computer crashes once bootloader tries to jump to kernel
<me>
hands over a buncha hankies to Pype
Here, have a good snort and let it go lad. *chuckle*
</me>
@kofrad: honestly, align your kernel at 0x10000 and get it out of the bootloaders way. I'm sure this will save you quite some troubles later on. Believe me, your kernel gonna grow faster than you 'll believe once you've got a certain knack.
hands over a buncha hankies to Pype
Here, have a good snort and let it go lad. *chuckle*
</me>
@kofrad: honestly, align your kernel at 0x10000 and get it out of the bootloaders way. I'm sure this will save you quite some troubles later on. Believe me, your kernel gonna grow faster than you 'll believe once you've got a certain knack.
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
BlueillusionOS iso image
-
kofrad
Re:Computer crashes once bootloader tries to jump to kernel
I changed my linker script and my bootloader code to load the kernel at 0x10000, but when I run make, I get this
If I try to run it anyway, bochs will panic. I'm sorry if I dont seem to get it, but I'm still really new to this. Maybe it'll be easier and better if I was to convert my kernel to use the multiboot spec and just use grub?
Code: Select all
bootsect.asm:23: warning: word value exceeds boundsRe:Computer crashes once bootloader tries to jump to kernel
Hi,
Take a look at line number 23 in "bootsect.asm", and see if you can find a word value that is exceeding it's bounds (ie. one that doesn't fit in 16 bits)...
Cheers,
Brendan
If you're having trouble with something like this, then trying to find bugs in a full blown kernel is going to give you nightmares. My advice is to make the boot code work perfectly (just for experience) and then use GRUB (if you still feel like it) after that.kofrad wrote:If I try to run it anyway, bochs will panic. I'm sorry if I dont seem to get it, but I'm still really new to this. Maybe it'll be easier and better if I was to convert my kernel to use the multiboot spec and just use grub?Code: Select all
bootsect.asm:23: warning: word value exceeds bounds
Take a look at line number 23 in "bootsect.asm", and see if you can find a word value that is exceeding it's bounds (ie. one that doesn't fit in 16 bits)...
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
-
kofrad
Re:Computer crashes once bootloader tries to jump to kernel
OK, a word's maximum integer value is 65,535 and the hex number 0x10000 = 65,536. The register that I am placing the hex value into is only 16 bits. How am I able to tell it to use a 32 bit number, or can I?
- Pype.Clicker
- Member

- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Computer crashes once bootloader tries to jump to kernel
you could make it a 32bits register, but the BIOS would discard the highest bits.
Most likely, you need to set the segment register at 0x1000 and the offset at 0. That'll make you 0x1000*16 + 0 = 65536
That question confirms my first impression that you definitely need more assembly skillz. Ever tried "the Art Of Assembly programming" tutorials ?
Most likely, you need to set the segment register at 0x1000 and the offset at 0. That'll make you 0x1000*16 + 0 = 65536
That question confirms my first impression that you definitely need more assembly skillz. Ever tried "the Art Of Assembly programming" tutorials ?
-
kofrad
Re:Computer crashes once bootloader tries to jump to kernel
I'm real sorry to still be bothering you with this problem, I have my linker script set to align everything at 0x10000 and I wasnt exactly sure of how to set the segment register, so I used this code in the part where I tell the BIOS where to load my kernel data
and for the jmp instruction to jump to the kernel I used this
When I enable tracing for bochs, it runs through and then freezes on the jmp instruction. I'm pretty sure I messed something up here because I know bochs will clear all memory to zero when it starts and it might be freezing trying to execute all zeros. I'm not even entirely sure my link.ld is correct, this might be because the link.ld is aligning everything at 0x10000. Here is my link.ld
Also, I found the art of assembly tutorials and I'm going through them right now. Thanks for the tip 
Code: Select all
mov ax,0x1000
mov es,ax
mov bx,0x0Code: Select all
jmp 0x1000:0x0Code: Select all
SECTIONS
{
. = 0x10000;
.text :
{
stub.o(asmstub);
*(.text)
}
.rodata ALIGN (0x10000) :
{
*(.rodata)
}
.data ALIGN (0x10000) :
{
*(.data)
}
.bss :
{
_sbss = .;
*(COMMON)
*(.bss)
_ebss = .;
}
}
- Pype.Clicker
- Member

- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Computer crashes once bootloader tries to jump to kernel
erhm. Since you're enabling pmode in your bootloader, you should rather have
The parameters for loading and the linker script seems both fine.
btw, you should try to gather more information from bochs than just "it crashes".
It might have told you "running in bogus memory" or "tripple fault". Those things are explained in the TroubleShooting category of the FAQ
Code: Select all
jmp 8:0x10000
btw, you should try to gather more information from bochs than just "it crashes".
It might have told you "running in bogus memory" or "tripple fault". Those things are explained in the TroubleShooting category of the FAQ
-
kofrad
Re:Computer crashes once bootloader tries to jump to kernel
Now I have my kernel working at 0x10000, but I still have the problem with my print() function. Bochs seems to freeze right after it leaves the function and the function dosent print anything.
Here is my print() function if you could possibly help me out:
Code: Select all
void print(const char *_message)
{
unsigned short offset;
unsigned long i;
unsigned char *vidmem = (unsigned char *)0xB8000;
// Read cursor position
out(0x3D4, 14);
offset = in(0x3D5) << 8;
out(0x3D4, 15);
offset |= in(0x3D5);
// Start at writing at cursor position
vidmem += offset*2;
// Continue until we reach null character
i = 0;
while (_message[i] != 0) {
*vidmem = _message[i++];
_message++;
vidmem++;
*vidmem = 0x0F;
//*vidmem = foreground + (background << 4) + (blink << 7);
vidmem++;
}
// Set new cursor position
offset += i;
out(0x3D5, (unsigned char)(offset));
out(0x3D4, 14);
out(0x3D5, (unsigned char)(offset >> 8));
}- Pype.Clicker
- Member

- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Computer crashes once bootloader tries to jump to kernel
there are hint for that too in the TroubleShooting category. I'd guess either non-zero-based datasegment or .rodata section missing in the image.