Page 1 of 2
Floppy Driver
Posted: Mon May 05, 2003 1:36 pm
by slacker
To what port do i send the commands to the floppy driver?
List of Valid Commands
Data Transfer Commands
Command Name | Function
-----------------------------------------
read complete track | x2h
write sector | x5h
read sector | x6h
write deleted sector | x9h
read deleted sector | xch
format track | xdh
Control Commands
Command Name | Function
-----------------------------------------
fix drive data | x3h
check drive status | x4h
calibrate drive | x7h
check interrupt status | x8h
read sector ID | xah
seek/park head | xfh
invalid command | all invalid opcodes
Extended Commands
Command Name | Function
-----------------------------------------------
register summary | 0fh
determine controller version | x10h
verify | x16h
seek relative | 1xfh
then after i send the command where do i send/retreive the data from?
Re:Floppy Driver
Posted: Tue May 06, 2003 10:18 am
by Guest
i am also interested in what port to send those commands...does anyone know?
Re:Floppy Driver
Posted: Tue May 06, 2003 10:53 am
by Peter_Vigren
This link covers pretty much of what you ask for... ports, commands etc... It really is good!
http://www.cyberscriptorium.com/osjourn ... ile&file=9
Re:Floppy Driver
Posted: Tue May 06, 2003 1:10 pm
by slacker
peter: i already read that one. the doc tells me all the ports except what port to send the command to.
Re:Floppy Driver
Posted: Wed May 07, 2003 5:03 am
by Tim
Look under the section "Configuration of an FDC on a PC".
Re:Floppy Driver
Posted: Wed May 07, 2003 10:50 am
by slacker
maybe i never learned how to read correctly but im not picking up on the specific port to write commands to...
Configuration of an FDC on a PC
The Floppy Controller on a PC uses a standard configuration. On the XT there are 3 ports available for control and data access registers. On the AT, there are 4, and on the PS/2 there are 6.
The base port address used for the controller is dependant on whether the controller is configured as the primary or secondary controller. This base address controls the port addresses used for each of the registers on the controller. It can additionally be noted that all floppy controllers on a PC use DMA channel 2 for data transfer during a read or write, and they all issue a hardware interrupt via IRQ6 to be serviced by INT 0eh by default.
Primary Address Secondary Address Write (W) Read (R)
base address 3f0h 370h
status register A (PS/2) 3f0h 370h R
status register B (PS/2) 3f1h 371h R
digital output register DOR 3f2h 372h W
main status register 3f4h 374h R
data rate select register (DSR)(PS/2) 3f4h 374h W
data register 3f5h 375h R/W
digital input register DIR (AT) 3f7h 377h R
configuration control register (AT) 3f7h 377h W
DMA channel 2 2
IRQ 6 6
INTR 0eh 0eh
Note that the controller can be configured differently from the defaults for handling interrupts.
Re:Floppy Driver
Posted: Wed May 07, 2003 11:05 am
by Tim
1. Look at the numbers in the table
2. Ignore the ones that say "IRQ", "DMA channel" or "INTR" next to them
You're now left with a list of port numbers.
Re:Floppy Driver
Posted: Wed May 07, 2003 12:12 pm
by slacker
ok i see port numbers...the same ones i was looking at 3 weeks ago.
....so what port do i write the commands to?
Re:Floppy Driver
Posted: Wed May 07, 2003 12:14 pm
by slacker
...and btw i am refferring to the commands in my first post..
Re:Floppy Driver
Posted: Wed May 07, 2003 12:32 pm
by Tim
Read the document! It's all there!
For example: "All commands and status bytes are transferred via the data register, at port 37fh or 377h".
If the document confuses you, download the source code of one of the many open-source operating systems on the net and see how they do it.
Re:Floppy Driver
Posted: Wed May 07, 2003 12:39 pm
by Jamethiel
If you're still lost, here are a couple threads from another message board that might be of interest.
http://www.osdev.org/board.jsp?message=3075
http://www.osdev.org/board.jsp?message=2862
--Jamethiel
Re:Floppy Driver
Posted: Wed May 07, 2003 12:42 pm
by slacker
once i send the command to 0x37F (amen..i got it) ...i need to send the data for the command...but the data listed for many of the commands is 9bits long...how would i send these 9 bits..?
Re:Floppy Driver
Posted: Wed May 07, 2003 1:13 pm
by Beyond infinity lazy
nay, slacker, you are in err here.
what you think are 9 bits are in fact 9 BYTES, if I interpret this table about the layout of a command right.
the bits are to be read horizontally in these tables, where the lowest bit is at the right and the highest bit is at the left.
the bytes to write to the port are ordered vertically from the lowest order to the highest.
you write the bytes one by one with a waiting function to the controller. this should then do it.
Re:Floppy Driver
Posted: Wed May 07, 2003 1:24 pm
by slacker
ok... say i finally sent the command to write data to port 0x37f..then i send the bytes(all 9 of em)...if i were to use port i/o to send data to the floppy(yea i know i should use DMA)...would i then send the data that i want written to port 0x37f?
Re:Floppy Driver
Posted: Thu May 08, 2003 8:47 am
by Jamethiel
Yes, like the documentation says, if you aren't using DMA you would send the sector data to the same I/O port as you did the write command.
--Jamethiel