Page 1 of 1

what to do after kernel is in memory

Posted: Thu Oct 24, 2013 6:00 pm
by teodori
Hello,
I have written a simple bootloader and kernel (very basic!). The MBR code loads sectors and jumps to it. The freshly loaded code sets up a temporary 32 bit GDT and jumps to 32 bit Protected Mode without paging. Then it creates the final 64 bit GDT, the final 64 bit IDT and the paging tables PML4, PDPT, PDT and PT, before jumping to 64 bit Long Mode. As soon as it is in 64 bit Long Mode I switch from Assembly to C code with void kmain(uint64_t gdtptr, uint64_t idtptr, uint64_t pml4ptr) as first function. I have written some basic functions like managing the GDT, the IDT, the paging tables and the VESA screen. And here is my question: What should I do next? How do I communicate with the hard disk, the network interface or the keyboard? How do I read the rest of my OS into memory?

Re: what to do after kernel is in memory

Posted: Thu Oct 24, 2013 7:06 pm
by Nable
> What should I do next?
You should do anything _you_ want to do, because that's your OS, written for your reasons.
As for me, writing native keyboard driver should be the next thing (because you can do output via framebuffer but applications w/o input are ~useless, and keyboard is one of the simplest ways of receiving input).
Then IDE/AHCI driver to interract with storage devices and possibly load additional modules of your OS. But I'm not sure about the second step, working multitasking or network support may be more important for you.

> How do I communicate with the hard disk, the network interface or the keyboard?
You can use emulator or CPU mode switching to use BIOS code for these things but it's much better to write native drivers for your OS.

> How do I read the rest of my OS into memory?
You can use GRUB to load additional modules (and even the whole initial RAMFS) or you can implement drivers to load files on your own.

At osdev wiki you can find a lot of interesting articles about all these things.
E.g., http://wiki.osdev.org/Beginner_Mistakes , http://wiki.osdev.org/What_order_should ... _things_in , http://wiki.osdev.org/How_Do_I_Use_A_De ... With_My_OS

Re: what to do after kernel is in memory

Posted: Thu Oct 31, 2013 8:40 am
by nerdguy
Keyboard Driver
Here's a good example in VC++ : http://www.brokenthorn.com/Resources/OSDev19.html

Re: what to do after kernel is in memory

Posted: Fri Nov 01, 2013 2:25 am
by teodori
thank you :)