Jump to content

How to write data to a hard drive

- - - - -

  • Please log in to reply
6 replies to this topic

#1
Robotnik

Robotnik

    Newbie

  • Members
  • Pip
  • 5 posts
I have been interested in making my own simple operating system lately, but one thing that has been stopping me is, how do I write something to a hard drive. I have found a few simple tutorials for printing to the screen without an operating system, but how would one simply write just one byte to a hard drive?

#2
DocSavage

DocSavage

    Newbie

  • Members
  • Pip
  • 7 posts
In Assembly Language, that is very hardware specific.
If you are creating your own OS, you have to use the hardware BIOS.
You need to read-up on the BIOS for your type of computer.
Generally speaking, all BIOS calls are done via Interupts.
Assuming you are using an x86 type machine, read-up on the x86 BIOS.
Google: "x86 BIOS"

#3
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,705 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
Note that that will only work if you stay in real mode. Once you switch to protected mode, you're going to have to write your own generic drivers.

Interrupt table
Take a look at interrupt 13H, subfunctions 0, 2, and 3.
sudo rm -rf /

#4
Robotnik

Robotnik

    Newbie

  • Members
  • Pip
  • 5 posts
Thanks for your help i will definitely look into the bios interrupt, but I am interested in learning how to write my own drivers. Does anyone know a good tutorial or book on this subject?

#5
mebob

mebob

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 490 posts
I may have the code I wrote for writing to an IDE hard drive laying around somewhere... I'll try to find it if you are interested.
Latinamne loqueris?

#6
RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,252 posts
  • Location:C:\Countries\US
This link might help, I think:
Category:ATA - OSDev Wiki

#7
mebob

mebob

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 490 posts
If you look there, you will probably want to look at the page "ATA PIO Mode" or "IDE".
Latinamne loqueris?




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users