48 Bit LBA
48 Bit LBA
I want to use 48 Bit LBA without using the BIOS (I'm in PMode), so I'm working with ports. This works fine if I use the READ SECTOR (0x20) command with CHS, but I've got problems when using READ SECTOR EXT (0x24) with LBA. I want to use 48 Bit Addressing, to use disk larger than 136 GB. If I read the data-port out, I got only the byte value 0xff all the time, but no real disk data. But if I read the error-register, I see no error (0x0). Do you have example code, that could help me with LBA & 48 Bit?
Thanks,
Thomas Krause
P.S. Why has the data-port only one physical byte (the next address is the error-register) but is 16 Bit width? I thought you could replace an inport(port) with an inportb(port) and an inportb(port+1)?
Thanks,
Thomas Krause
P.S. Why has the data-port only one physical byte (the next address is the error-register) but is 16 Bit width? I thought you could replace an inport(port) with an inportb(port) and an inportb(port+1)?
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:48 Bit LBA
most of intel chips allow indeed you to do OUTW x instead of OUTB x, OUTB x+1. However, here, the hardware *require* that you read *words* out of the HDD controler. period.
Iirc, the "read sector ext" is a command that allows you to read the CRC checksum and things like that along with the sector bytes. Do you really need that for 48bits LBA ?
Iirc, the "read sector ext" is a command that allows you to read the CRC checksum and things like that along with the sector bytes. Do you really need that for 48bits LBA ?
Re:48 Bit LBA
What you mean is "read sector long" afaik. The normal read sector function uses only 24 Bits, which is to less for my needs.
Thanks,
Thomas Krause
Thanks,
Thomas Krause
Re:48 Bit LBA
Reading a sector using 48 bits requires sending two commands, one which stores the first 24 (or last, anyway, half of the) bits in the controller, and then you send the actual command which reads the last (or first, the other half of the) bits and executes the command. Since a harddisk command is a short command, a very long wait and a normal reply, the command could easily be longer .aKzenT wrote: What you mean is "read sector long" afaik. The normal read sector function uses only 24 Bits, which is to less for my needs.
Thanks,
Thomas Krause
In effect, try ATA specs for ATA 6 or 7. You do NOT want read sector ext, that reads 516 byte sectors, not sectors located somewhere else.
PS: do you have a 128+ GB harddisk to test the code with?
Re:48 Bit LBA
I checked the ATA specs 6. All EXT-Commands are in the 48-Bit-Address-Feature set. I don't know if it reads 512 or 516 bytes, but I know that it seams to be the only possibility to address with 48 Bit.
I have Hard-Disks to test it, but I'm emulating in a VM without a Hard Disk that is so big.
At the moment I simply do 6 outport commands to fill every LBA-register two times, exactly how it is described in the specs. After writing all LBA and Sector register, I put one 24h command, which does not produce anything. Do I really have to send 2 commands, one after I fill the adress registers the first time and the after to actually execute it? I can't find something about this in the ATA specs.
Thank you very much for your help,
Thomas Krause
I have Hard-Disks to test it, but I'm emulating in a VM without a Hard Disk that is so big.
At the moment I simply do 6 outport commands to fill every LBA-register two times, exactly how it is described in the specs. After writing all LBA and Sector register, I put one 24h command, which does not produce anything. Do I really have to send 2 commands, one after I fill the adress registers the first time and the after to actually execute it? I can't find something about this in the ATA specs.
I don't understand this sentence (forgive me for my poor english).Since a harddisk command is a short command, a very long wait and a normal reply, the command could easily be longer
Thank you very much for your help,
Thomas Krause
Re:48 Bit LBA
HI,
"Since a harddisk command is a short command, a very long wait and a normal reply, the command could easily be longer"
That isn't the clearest sentence. If I am correct "harddisk command" should be "hard disk sector read".
Basically it takes a long time read the disk, so sending the command is a miniscule amount of time.
If you want 48bit LBA why don't you look at the Linux or FreeBSD sources? Its only 1 specific piece of functionality you want so shouldn't be hard to find.
"Since a harddisk command is a short command, a very long wait and a normal reply, the command could easily be longer"
That isn't the clearest sentence. If I am correct "harddisk command" should be "hard disk sector read".
Basically it takes a long time read the disk, so sending the command is a miniscule amount of time.
If you want 48bit LBA why don't you look at the Linux or FreeBSD sources? Its only 1 specific piece of functionality you want so shouldn't be hard to find.
Re:48 Bit LBA
Thank you for this idea. Do you know where I can find the sources without downloading the whole distribution. I have only a 56kb modem.
Thomas Krause
Thomas Krause
Re:48 Bit LBA
I searched in google for weeks and I found only the official ATA-specs that shows how you can use 48 Bit, but it simply does not work.
aKzenT
aKzenT
Re:48 Bit LBA
Hi,
I was referring to the Linux source code. That is extremely easy to find on the web. Then you can search it and find the 48 bit LBA (I presume).
I was referring to the Linux source code. That is extremely easy to find on the web. Then you can search it and find the 48 bit LBA (I presume).
Re:48 Bit LBA
Thank you!
Is the "Notify of replies" check box broken? I check it all the time, but I never get a notification. Perhaps it is filtered by my spam filter... I will check that.
Thomas Krause
Is the "Notify of replies" check box broken? I check it all the time, but I never get a notification. Perhaps it is filtered by my spam filter... I will check that.
Thomas Krause
Re:48 Bit LBA
I hope this is of help, you said that you have tried using the 28bit CHS mode... but have you tried using the 28bit LBA mode?
To do this you must set bit 7 of the drive/head specifier:
outportb (0x20, hdcbaseport+7); // Command (PIO Read)
outportb (0x01, hdcbaseport+1); // Sector Count
outportb (0x64, hdcbaseport+2); // lba 0..7
outportb (0x00, hdcbaseport+3); // lba 8..15
outportb (0x00, hdcbaseport+4); // lba 16..24
/* now comes the magic */
outportb (0xE0, hdcbaseport+5);
The lower 4 bits are LBA 25..28, bit 7 set means use LBA the above example, of course, will use the master drive and read the sector at LBA 0x64. if you change the command to 0x24 and ouput the LBA Address as detailed in the Maxtor recomendation... it should work. I cannot test the 48 bit version (my drives are all too old!!) but the one above does work.
I hope this helps... if you want some code let me know!
Ben.
To do this you must set bit 7 of the drive/head specifier:
outportb (0x20, hdcbaseport+7); // Command (PIO Read)
outportb (0x01, hdcbaseport+1); // Sector Count
outportb (0x64, hdcbaseport+2); // lba 0..7
outportb (0x00, hdcbaseport+3); // lba 8..15
outportb (0x00, hdcbaseport+4); // lba 16..24
/* now comes the magic */
outportb (0xE0, hdcbaseport+5);
The lower 4 bits are LBA 25..28, bit 7 set means use LBA the above example, of course, will use the master drive and read the sector at LBA 0x64. if you change the command to 0x24 and ouput the LBA Address as detailed in the Maxtor recomendation... it should work. I cannot test the 48 bit version (my drives are all too old!!) but the one above does work.
I hope this helps... if you want some code let me know!
Ben.
Re:48 Bit LBA
Ooops... the above code should read:
outportb (0x20, hdcbaseport+7); // Command (PIO Read)
outportb (0x01, hdcbaseport+2); // Sector Count
outportb (0x64, hdcbaseport+3); // lba 0..7
outportb (0x00, hdcbaseport+4); // lba 8..15
outportb (0x00, hdcbaseport+5); // lba 16..24
/* now comes the magic */
outportb (0xE0, hdcbaseport+6);
Sorry about that!
outportb (0x20, hdcbaseport+7); // Command (PIO Read)
outportb (0x01, hdcbaseport+2); // Sector Count
outportb (0x64, hdcbaseport+3); // lba 0..7
outportb (0x00, hdcbaseport+4); // lba 8..15
outportb (0x00, hdcbaseport+5); // lba 16..24
/* now comes the magic */
outportb (0xE0, hdcbaseport+6);
Sorry about that!
Re:48 Bit LBA
Should read "The lower 4 bits are LBA 25..28, bit 6 set means use LBA the above..." I live in the UK and it is 02:37 here now... I am tired!Ben Green wrote: The lower 4 bits are LBA 25..28, bit 7 set means use LBA the above...