OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Oct 23, 2018 2:33 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Linking the kernel tips?
PostPosted: Wed Jun 13, 2018 6:51 pm 
Offline

Joined: Wed Jun 13, 2018 6:40 pm
Posts: 3
I've started writing an OS and so far I have a boot loader which moves into Protected Mode, however now I wish to start using C for a kernel over Assembly. I am wondering if anyone can provide pointers on linking the C to the boot loader.

-I see lots of people using GCC... Are there any other available choices?
-What is the typically preferred ways of linking a C kernel to the boot loader?
-I'm using VMWare

Thank you very much all!


Top
 Profile  
 
 Post subject: Re: Linking the kernel tips?
PostPosted: Wed Jun 13, 2018 11:21 pm 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 45
Hi,

GCC is not the only choice. Clang also exists; I don't know if it can produce code for "no OS", though. Some people also use Visual Studio, but then some people are just masochists (VS is optimized for C++ development on Windows. You have to bend it over backwards to make it produce freestanding code).

Regarding the bootloader: That generally isn't linked to the kernel in any way. Most bootloaders just load the kernel from disk using BIOS commands, and using either a blocklist (e.g. LILO) or using the actual filesystem (e.g. GRUB). Which way you prefer is up to you, and probably depends on your choice of FS. For instance, FAT is sufficiently simple to parse its root directory from within the boot loader (and the superblock being part of the boot loader certainly doesn't hurt), whereas with something like ext2, you might just want to go with the blocklist idea (or else you have to load the superblock, validate the superblock, open inode 2, find the directory entry for your kernel, open its inode, and load that into memory).

In general, though, try to explore the existing bootloaders before writing your own one. It is a miserable experience others have already gone through, so you don't have to.

Finally, you're using VMware. Good for you. Personally, I'd use qemu or bochs, the former being able to display a serial console (which means you can send debug output even if the screen is in graphical mode) and the latter having an awesome debugger.

Ciao,
Markus


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group