Hi guys! I'm developing a kernel that I need to test using a custom made bootloader. I've checked out all the tutorials but I can't seem to find a good example on how to load the kernel.bin file from a certain directory and then jump to it! I'd also like to set the video mode to VGA (BIOS interrupt 0x10 I believe?) AND THEN switch to protected mode. Any suggestions?
P.S. I would like to program this in C, but it's not possible/not practical, I'll stick to good ol assembly.
Thanks in advance!
Help making a simple bootloader.
Re: Help making a simple bootloader.
You're (probably) not going to fit more than entering protected mode and reading sectors off the disk within 512 bytes (although, we do have a contest for that)
I suggest using a second stage loader written in C to do the file system stuff
Also, note that, you cant use BIOS interrupts for reading the disk in protected mode, so you will probably need to write your own code for that too
I suggest using a second stage loader written in C to do the file system stuff
Also, note that, you cant use BIOS interrupts for reading the disk in protected mode, so you will probably need to write your own code for that too
Re: Help making a simple bootloader.
Hello,
Most of that can be technically done in C. I believe you also have answered your own question regarding setting the VGA mode -- just issue BIOS INT 0x10 function 0 prior to entering protected mode. I personally do not recommend going into graphics mode so early however.
Regarding your request for an example of loading a file off disk, there are plenty of resources for this. By supporting a filesystem, you can load your program file off disk which can then be executed. Because this is a filesystem detail, you have to look into tutorials for the filesystem.
Assuming you are working on a floppy disk, look for FAT12 reading tutorials--
Wiki link. Look at the external links for additional references.
Very nice info linked from Wiki.
My site, tutorial 6
Hope this helps.
Most of that can be technically done in C. I believe you also have answered your own question regarding setting the VGA mode -- just issue BIOS INT 0x10 function 0 prior to entering protected mode. I personally do not recommend going into graphics mode so early however.
Regarding your request for an example of loading a file off disk, there are plenty of resources for this. By supporting a filesystem, you can load your program file off disk which can then be executed. Because this is a filesystem detail, you have to look into tutorials for the filesystem.
Assuming you are working on a floppy disk, look for FAT12 reading tutorials--
Wiki link. Look at the external links for additional references.
Very nice info linked from Wiki.
My site, tutorial 6
Hope this helps.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
Re: Help making a simple bootloader.
I can enable A20, load a kernel.bin from FAT, and copy to 1M using unreal mode, query memory map, then (re)enable protect mode and jump to kernel, all within a VBR (with is slightly less than 512 bytes with some bytes to store BIOS parameter block, and with 3 bytes to spareTobba wrote:You're (probably) not going to fit more than entering protected mode and reading sectors off the disk within 512 bytes (although, we do have a contest for that)
Someone here may well do more things than that too.
But anyway, I agree to introduce 2nd stage as it give more room for checks, validation, and features.
If you plan to implement in C, you still need a minimal amount of assembly code, which can be inline assembly,
since in C you cannot directly assign values to registers.