Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
im trying read my ATA HDD in protected mode (32bits).
my question is how can I communciate with the hardware using ports
I read that I need use this ports:
0x1F0 Data port -- read and write PIO <b>data</b> bytes on this port
0x1F1 Features / Error info -- mostly used with ATAPI
0x1F2 Sector Count -- number of sectors to read/write (0 = special value)
0x1F3 Partial Disk Sector address (CHS / LBA28 / LBA48 specific)
0x1F4 Partial Disk Sector address
0x1F5 Partial Disk Sector address
0x1F6 Drive Select bit, Flag bits, Extra address bits
0x1F7 Command port / Regular Status port -- write commands / read status
Im using outb() for send ports.
According to http://wiki.osdev.org/ATA_PIO_Mode I need wait 400ns for send the next cmd and check the bits BSY and DRQ.
I have an ide_polling function (like this: http://wiki.osdev.org/IDE) and always this functions return 3 (DRQ is not set). Im calling this function -before- outb().
My question is how can I set DRQ or how can I check if the ports are writing good or not.
You can't set DRQ: the device has control over it and only sets it when it wants to transfer data. Which means you first have to send a command where data transfer is supposed to follow (like an identify)
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Combuster wrote:You can't set DRQ: the device has control over it and only sets it when it wants to transfer data. Which means you first have to send a command where data transfer is supposed to follow (like an identify)
Nice. Thanks.
Do you know that command for identify ? I read that f0-f7 are all of the ports availables. What is, then, the port or command to "prepare" to read data.
im using ide_initialize(), that´s not enough?
A status of 3 indicates that the error bit is set -- which may mean that you need to send a RESET command to the drive before it will work again. You send commands to the drive using outb on port 0x1f7, as you posted above. You send the byte 0xEC to that port to do an IDENTIFY.
If you need to do a reset, you need to send the proper byte (using outb) to port 0x3f6.
bewing wrote:A status of 3 indicates that the error bit is set -- which may mean that you need to send a RESET command to the drive before it will work again. You send commands to the drive using outb on port 0x1f7, as you posted above. You send the byte 0xEC to that port to do an IDENTIFY.
If you need to do a reset, you need to send the proper byte (using outb) to port 0x3f6.
whats the proper byte to reset?
where can I view the COMPLETE LIST of ports/bytes ? I didnt find it in osdev /ATA_PIO_Mode or /IDE
:S
qextreme wrote:where can I view the COMPLETE LIST of ports/bytes ? I didnt find it in osdev /ATA_PIO_Mode or /IDE:S
How about RBIL? and sure I guess you do have the official ATA manual
rbil? give me links plz, i didnt find info in this url: http://www.dosbox.com/wiki/Technical_Info
i think that the official ata manual is very large, i need only the ports/bytes lists
Dosbox is a poor emulator for OS development. And we don't do free rides, sorry: the official manual is an excellent reference and you do not need to read more than 1% of it to find the byte you are looking for.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
An example of a 28 bit LBA PIO mode read on the Primary bus:
1. Send 0xE0 for the "master" or 0xF0 for the "slave", ORed with the highest 4 bits of the LBA to port 0x1F6: outb(0x1F6, 0xE0 | (slavebit << 4) | ((LBA >> 24) & 0x0F))
2. Send a NULL byte to port 0x1F1, if you like (it is ignored and wastes lots of CPU time): outb(0x1F1, 0x00)
3. Send the sectorcount to port 0x1F2: outb(0x1F2, (unsigned char) count)
4. Send the low 8 bits of the LBA to port 0x1F3: outb(0x1F3, (unsigned char) LBA))
5. Send the next 8 bits of the LBA to port 0x1F4: outb(0x1F4, (unsigned char)(LBA >> )
6. Send the next 8 bits of the LBA to port 0x1F5: outb(0x1F5, (unsigned char)(LBA >> 16))
7. Send the "READ SECTORS" command (0x20) to port 0x1F7: outb(0x1F7, 0x20)
8. Wait for an IRQ or poll.
9. Transfer 256 words, a word at a time, into your buffer from I/O port 0x1F0. (In assembler, REP INSW works well for this.)
10. Then loop back to waiting for the next IRQ (or poll again -- see next note) for each successive sector.
My question is why when I try to execute the step 7 (outb(0x1F7, 0x20)) my virtual machines dieds (im using bochs).
If I invest the parameters (like this outb(0x20, 0x1F7)) its not dead.
I have any error or the error is in the wiki ?