2

So I am currently developing my toy os, and want to know how I can load the kernel into RAM from my bootloader?

I already looked in the internet, but after searching on the sixth Google Result page I want to ask here before doing more research.

My later goal is to write the kernel in C, maybe I can get some tips for that as well. Thanks.

Daniel O
  • 365
  • 1
  • 2
  • 7
  • 2
    What platform are you trying to run on? If x86 It is far easier to write the bootloader in assembly. If you want to do it in C I recommend Open Watcom (and not GCC). You can use the BIOS to read sectors from disk to get the kernel, enable A20, enter protected mode and then run your kernel. You can save yourself the hassles and use a Multiboot compliant bootloader like grub to do it for you. If you have an (U)EFI BIOS you can use that too. A good resource for all this is [OSDev Wiki](http://wiki.osdev.org/Expanded_Main_Page) – Michael Petch Dec 14 '17 at 20:00
  • 1
    If you're developing something new, for a current (not obsolete) platform, I recommend you use UEFI rather than legacy BIOS to run your boot loader. UEFI provides a more convenient programming interface that is fairly well documented and standardized, compared to the chaos that is the programming interface to legacy BIOS. Also, with UEFI, your boot loader starts in 32- or 64-bit mode rather than 16-bit mode. – prl Dec 14 '17 at 20:41
  • @MichaelPetch Thanks for the small introduction. I want to run it on a x86 system. – Daniel O Dec 14 '17 at 20:41
  • You should have stopped at the first google page, which almost *certainly* directed you to osdev.org. Go read the wiki. – David Hoelzer Dec 15 '17 at 03:51
  • closed as a duplicate of a working example of a bootloader that calls a `main()` function in 32-bit protected mode + guidelines for legacy `int 10h` BIOS. @prl, do you know if there's a similar Q&A for UEFI with a working example? (If so, we should have a link to that in the x86 tag wiki as well.) – Peter Cordes Dec 15 '17 at 05:18

0 Answers0