The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: brodeur235 on July 25, 2010, 05:00:23 AM

Title: Reading from and writing to disk sectors in protected mode
Post by: brodeur235 on July 25, 2010, 05:00:23 AM
I am writing an OS using the Netwide Assembler, not Microsoft's; I know that violates the license. What I'm look for is the simplest conventional way to read from and write to an HDD (in p-mode, so no BIOS ints). Simple documentation links, explanations, and asm code snippets are what I find to be the most helpful. Help appreciated,

Brodeur235
Title: Re: Reading from and writing to disk sectors in protected mode
Post by: MichaelW on July 25, 2010, 07:32:09 AM
The ATA/ATAPI standards should be useful. You used to be able to get the working drafts for free from the committee responsible for the standards:

http://www.t13.org/Default.aspx

But they are apparently no longer available, so you're probably left with buying the published standards. Try the Global Engineering Documents link on the t13 Published Standards page. The download price seems to be in the vicinity of $30.

PIO mode through the command/control block registers used to be easy to do, at least for the purposes of identifying the drive.

Title: Re: Reading from and writing to disk sectors in protected mode
Post by: sinsi on July 25, 2010, 07:34:40 AM
You have 2 options. One is to switch to real mode, do the bios int 13 call then switch back to pmode, but that is very slow.
The other is to write a driver, the ports and commands are well documented.

You might want to look at osdev.org or the OS construction forum at board.flatassembler.net
Title: Re: Reading from and writing to disk sectors in protected mode
Post by: sinsi on July 25, 2010, 07:36:29 AM
I have the atapi6 pdf somewhere, I can upload it here when I dig it out if anyone wants.
Title: Re: Reading from and writing to disk sectors in protected mode
Post by: Geryon on July 25, 2010, 10:07:08 AM
Take a look
http://www.pjrc.com/tech/8051/ide/wesley.html