OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Apr 19, 2024 3:07 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Writing bytes to a drive
PostPosted: Sat Sep 01, 2018 7:23 pm 
Offline

Joined: Sat Nov 11, 2017 8:33 pm
Posts: 8
Hello! I am creating my own Hobby OS and I would like to know if I can write raw bytes to certain sectors to a drive. Is there anyway I can do this in C. And if not can I do it in assembly then link it with C.
Eventually I want to do something like this...
Code:
char data[512] = "...";
write(data,[SECTOR])


Thank you in advance :)


Top
 Profile  
 
 Post subject: Re: Writing bytes to a drive
PostPosted: Sat Sep 01, 2018 9:08 pm 
Offline
Member
Member
User avatar

Joined: Sat Nov 22, 2014 6:33 pm
Posts: 934
Location: USA
Well, if it was that easy, we would have Operating Systems coming out of our...well you know. Besides, each OS would be almost the same anyway, since the C language/compiler would pretty much indicate what kind of OS it could be.

Sorry/Happily to say (depending on how you look at it), you have to do all of it yourself. Period. Yes, you can port libraries and other's code to your project, but by doing that, you aren't really making your own, are you?

There are many tutorials, posts, etc., on this site as well as others. Might I suggest a few good books?

Ben
- http://www.fysnet.net/osdesign_book_series.htm


Top
 Profile  
 
 Post subject: Re: Writing bytes to a drive
PostPosted: Sun Sep 02, 2018 5:30 pm 
Offline

Joined: Sat Nov 11, 2017 8:33 pm
Posts: 8
Oh okay, I don't mind some extra work put into my OS. Are there any external articles that can get me started?

Thanks anyway! :wink:


Top
 Profile  
 
 Post subject: Re: Writing bytes to a drive
PostPosted: Sun Sep 02, 2018 5:45 pm 
Offline
Member
Member
User avatar

Joined: Sat Nov 22, 2014 6:33 pm
Posts: 934
Location: USA
Well, of course. Where are you at?

If you are at the point where you can use C to "start" to read from the disk, does this mean you have a boot loader which has now loaded your kernel? Have you made it that far yet?

If you are at the boot loader part, you need to write the boot code and use the firmware (Legacy BIOS or UEFI) and read from the disk that way.

If you have a loaded kernel, you need to write a driver for the desired media, in this case, probably an ATA drive.

Where are you at? Boot loader? Have a look at https://github.com/fysnet/FYSOS. This is the boot loader code for the book series I might of hinted to before.

If you are at the Kernel stage, there is a post at https://forum.osdev.org/viewtopic.php?f=1&t=33152 of someone asking how to read from the disk.

- Ben


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot], klange and 149 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