How to R/W hard disk when CPU is in Protect Mode?

All off topic discussions go here. Everything from the funny thing your cat did to your favorite tv shows. Non-programming computer questions are ok too.
Post Reply
User avatar
smwikipedia
Member
Member
Posts: 49
Joined: Tue Apr 20, 2010 1:11 am

How to R/W hard disk when CPU is in Protect Mode?

Post by smwikipedia »

I am doing some OS experiment. Until now, all my code utilized the real mode BIOS interrupt to manipulate hard disk and floppy. But once my code enabled the Protect Mode of the CPU, all the real mode BIOS interrupt service routine won't be available. How could I R/W the hard disk and floppy? I have a feeling that I need to do some hardware drivers now. Am I right? Is this why an OS is so difficult to develop?


I know that hardwares are all controlled by reading from and writing to certain control or data registers. For example, I know that the Command Block Registers of hard disk range from 0x1F0 to 0x1F7. But I am wondering whether the register addresses of so many different hardwares are the same on the PC platform? Or do I have to detect that before using them? How to detect them??

Since I am not sure about how to R/W floppy or hard disk in Protect Mode, I have to use the BIOS interrupt to load all my necessary kernel file from floppy into memory for now. But I am wondering what could I do if my kernel file exceeds the real mode 1M space limit?

For any responses I present my deep appreciation.
User avatar
zity
Member
Member
Posts: 99
Joined: Mon Jul 13, 2009 5:52 am
Location: Denmark

Re: How to R/W hard disk when CPU is in Protect Mode?

Post by zity »

All your questions should be answered in the wiki, it has some good articles on both floppy and hard disks.

http://wiki.osdev.org/IDE
http://wiki.osdev.org/Floppy_Disk_Controller
User avatar
smwikipedia
Member
Member
Posts: 49
Joined: Tue Apr 20, 2010 1:11 am

Re: How to R/W hard disk when CPU is in Protect Mode?

Post by smwikipedia »

Thanks zity. I will take a look. :)
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: How to R/W hard disk when CPU is in Protect Mode?

Post by bewing »

The http://wiki.osdev.org/ATA_PIO_Mode is better than the IDE article, if you want detail.
Post Reply