OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Mar 29, 2024 1:40 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: How to go about writing an OS and bootloader to disk?
PostPosted: Thu May 11, 2017 4:43 am 
Offline

Joined: Thu May 11, 2017 4:37 am
Posts: 2
Hello everyone.

So, after I get myself an ATA driver or something to be able to read and and write to and from the disk, how exactly do I go about writing things like the MBR, a bootloader and my kernel to the disk?
The bootloader I'm aiming for is GRUB2, on normal BIOS.
I do not exactly understand how they all fit together, what needs to get written where, things like that.
And another question, is there a way for me to write a GRUB2 module for my own file system?

Cheers,
Chronium.


Top
 Profile  
 
 Post subject: Re: Writing an OS and bootloader to disk.
PostPosted: Thu May 11, 2017 4:49 am 
Offline
Member
Member
User avatar

Joined: Thu Jul 12, 2012 7:29 am
Posts: 723
Location: Tallinn, Estonia
chronium wrote:
Hello everyone.

So, after I get myself an ATA driver or something to be able to read and and write to and from the disk, how exactly do I go about writing things like the MBR, a bootloader and my kernel to the disk?


grub-install does grub installation for you, just give it a drive specification (hd0) etc - see GRUB manual for that, it's all detailed there.

chronium wrote:
I do not exactly understand how they all fit together, what needs to get written where, things like that.


If you're using grub, you can write the kernel anywhere on a fileystem that is understood by grub.

chronium wrote:
And another question, is there a way for me to write a GRUB2 module for my own file system?


Yes, it is possible. Get grub sources https://www.gnu.org/software/grub/grub-download.html and look for implementation of filesystem modules, it's fairly straightforward. E.g. grub-core/fs/fat.c defines a FAT filesystem driver.

_________________
Learn to read.


Top
 Profile  
 
 Post subject: Re: How to go about writing an OS and bootloader to disk?
PostPosted: Thu May 11, 2017 7:58 am 
Offline

Joined: Thu May 11, 2017 4:37 am
Posts: 2
I don't want to install it using external tools. I'm interested on how to do the installation from inside my kernel. There should be a way to get the stage 1 and 2 files, write the stage 1 where it should be and then do the rest for stage 2, but that's what I don't quite get how to do.

Where exactly each part of the bootloader should go


Top
 Profile  
 
 Post subject: Re: How to go about writing an OS and bootloader to disk?
PostPosted: Thu May 11, 2017 8:01 am 
Offline
Member
Member
User avatar

Joined: Sun Jul 14, 2013 6:01 pm
Posts: 442
the first ,,stage'' goes to the first sector.

the second goes
Image

_________________
Operating system for SUBLEQ cpu architecture:
http://users.atw.hu/gerigeri/DawnOS/download.html


Top
 Profile  
 
 Post subject: Re: How to go about writing an OS and bootloader to disk?
PostPosted: Thu May 11, 2017 9:33 am 
Offline
Member
Member
User avatar

Joined: Thu Jul 12, 2012 7:29 am
Posts: 723
Location: Tallinn, Estonia
chronium wrote:
Where exactly each part of the bootloader should go


You can inspect the sources of grub-install and figure where, how and why it is written.

Learn to read already.

_________________
Learn to read.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Amazonbot [bot], Bing [Bot], DotBot [Bot], Google [Bot], Majestic-12 [Bot] and 153 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