Bootloader doesn't load a kernel bigger than 512 bytes.
Posted: Mon Sep 07, 2015 11:26 am
Sorry if this is already asked/answered on here or somewhere else. I've searched and couldn't find a good answer so I make this post.
NOTE: I will not use GRUB bootloader or any other premade bootloader. I want to code both the bootloader and the kernel from scratch.
So, I posted a question recently where I had a problem with saving my kernel to the second sector of the first track. now I managed to do that, and my kernel has been working perfectly fine. I'll point out that I have a boot.asm/boot.bin and a kernel.asm/kernel.bin which gets assembled using 'nasm boot.asm -f bin -o boot.bin' and the same for the kernel. at the end of the boot.asm file I have
and at the end of the kernel (which is in only 1 sector) I have
Now when the kernel grew bigger I wanted to make the kernel have 4096 bytes size instead of 512.
so I changed the end of the kernel to
When I then move the boot.bin and the kernel.bin to the floppy disk I do
) and it was.
Now to the part where I run my OS. I followed this stackoverflow tutorial/thread and it all worked during the time where the kernel was 512 bytes. and now when I moved to 4096 bytes, it somehow doesn't work anymore. And it's not that I've forgot to load it all. on the int 13h/ah=02h, there is an 'al' register saying how many sectors should get loaded. I've set it to 8 because 512 (length of 1 sector) * 8 (new value for 'al' register) = 4096 (kernel size). it all loads fine, no problem there. but the problem comes when I jump to the kernel. Nothing happens atall. in the kernel I have a message to print "Welcome to my OS" which ran fine when it was 512 bytes. but now with 4096 bytes, not atall. And I've double checked, the RAM position of the kernel is correct.
I don't know anymore details to point out. If anyone has questions and wanna help me. please do!
NOTE: I will not use GRUB bootloader or any other premade bootloader. I want to code both the bootloader and the kernel from scratch.
So, I posted a question recently where I had a problem with saving my kernel to the second sector of the first track. now I managed to do that, and my kernel has been working perfectly fine. I'll point out that I have a boot.asm/boot.bin and a kernel.asm/kernel.bin which gets assembled using 'nasm boot.asm -f bin -o boot.bin' and the same for the kernel. at the end of the boot.asm file I have
Code: Select all
times 510-($-$$) db 0
dw 0xAA55
Code: Select all
times 512-($-$$) db 0so I changed the end of the kernel to
Code: Select all
times 4096-($-$$) db 0I code the OS on WindowsXP 32-bit using VirtualBox and the floppy disk is a virtual floppy disk that I have inputted to VirtualBox WindowsXP. so when I copied it into the floppy disk I went to my real OS (Windows 10) to check the .img file (the floppy) to see if it was changed (cheaty cheatypartcopy boot.bin 0 200 -f0
partcopy kernel.bin 0 1000 -f0 200
Now to the part where I run my OS. I followed this stackoverflow tutorial/thread and it all worked during the time where the kernel was 512 bytes. and now when I moved to 4096 bytes, it somehow doesn't work anymore. And it's not that I've forgot to load it all. on the int 13h/ah=02h, there is an 'al' register saying how many sectors should get loaded. I've set it to 8 because 512 (length of 1 sector) * 8 (new value for 'al' register) = 4096 (kernel size). it all loads fine, no problem there. but the problem comes when I jump to the kernel. Nothing happens atall. in the kernel I have a message to print "Welcome to my OS" which ran fine when it was 512 bytes. but now with 4096 bytes, not atall. And I've double checked, the RAM position of the kernel is correct.
I don't know anymore details to point out. If anyone has questions and wanna help me. please do!