中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-10-31 09:43
47,815 topics / 349,930 posts / today 0 new / 48,290 members
DOS开发编程 & 发展交流 (开发室) » Ask about the data retrieved by the ATA 0xec command
Printable Version  2,428 / 7
Floor1 Joyoung Posted 2008-10-29 16:17
初级用户 Posts 18 Credits 48
The code is as follows:
unsigned int diskData; /* Disk data */
。。。
。。。
for (offset = 0; offset != 256; offset++) /* Read "sector" */
diskData = inpw(cmdInterface);//At this time, data can be successfully obtained

printf("Word:%X, Word:%X\n", diskData, diskData]);//61: 60 is the number of sectors. If the hard disk size is 80G, the data taken out is correct, but if the hard disk is 160G/250G/500G, the taken-out numbers are all FFF:FFFF. There must be something wrong, but I don't know where the problem is. Is there any expert who knows? Thank you!~~~~
Floor2 netwinxp Posted 2008-10-29 16:27
高级用户 Posts 366 Credits 741
For LBA48 hard drives (>137G), this DWORD stores 0FFF FFFFH (7 Fs are exactly LBA28). The actual number of sectors is not stored here. I don't quite remember the exact location. You can look up the ATA-ATAPI-5 standard (I think). Direct hardware programming is a very tedious task. The best way is to find as many relevant standard documents as possible.

There are many different ATA commands between LBA48 and LBA28, and the format of the LBA packet is also different. The reason why many HPA tools don't work is that the writers didn't consider the difference here.

[ Last edited by netwinxp on 2008-10-29 at 16:39 ]
Floor3 Joyoung Posted 2008-10-29 16:38
初级用户 Posts 18 Credits 48
Originally posted by netwinxp at 2008-10-29 16:27:
For hard disks with LBA48 (>137G), this DWORD stores 0FFF FFFFH (7 Fs are exactly LBA28), and the actual number of sectors is not stored here. I don't quite remember the exact location. You can look up the ATA-ATAPI-5 standard (I think). ...


I read ATA 6, but my English is not very good, and I didn't find where it could be. Can you please ask a master to take a look? Thanks a lot!
Floor4 netwinxp Posted 2008-10-29 16:40
高级用户 Posts 366 Credits 741
Looking for the IDENTIFY_DEV(0ECH) command, which will mark where to find the definition of the 256 - byte.
Floor5 Joyoung Posted 2008-10-29 17:36
初级用户 Posts 18 Credits 48
Originally posted by netwinxp at 2008-10-29 16:40:
Looking for the IDENTIFY_DEV(0ECH) command, which will mark where to find the definition of those 256 bytes.


I took a look, it seems to be Word60-Word61:Total number of user addressable sectors (LBA mode only), and another one is Word57-Word58:Current capacity in sectors; the others don't seem to be there. The ATA 6 SPEC is in the attachment, can the experts help take a look?

Attachments
HDD.rar (9.53 KiB)
Floor6 netwinxp Posted 2008-10-29 19:04
高级用户 Posts 366 Credits 741
WORD60~61 (LBA28) is invalid if it is 0FFFFFFF.
WORD100~103 (LBA48) is invalid if it is 0000FFFFFFFFFFFF. (PS: Currently there is no exceeding LBA48, so the definition after exceeding is not out yet)
See 6.2.1 in detail.
To judge whether LBA48 is supported, check WORD83 BIT10, this value is only the maximum capacity that BIOS can return (excluding HPA).
The real hard disk capacity (including HPA part) is obtained by READ_NATIVE_MAX(F8)<LBA28> or READ_NATIVE_MAX_EXT(27)<LBA48>.
LZ must not have read carefully enough, no need to download the attachment, my PATCH has been downloaded to August-September this year.

[ Last edited by netwinxp on 2008-10-29 at 19:36 ]
Floor7 Joyoung Posted 2008-10-29 20:05
初级用户 Posts 18 Credits 48
Originally posted by netwinxp at 2008-10-29 19:04:
WORD60~61 (LBA28) are invalid if they are 0FFFFFFF.
WORD100~103 (LBA48) are invalid if they are 0000FFFFFFFFFFFF. (PS: There hasn't been any LBA48 exceeding yet, so the definition beyond that hasn't been worked out yet)
See 6.2.1 in detail.
Judgment is ...


Got it, really thank you so much! Thanks!~~~
I used Word, my document is marked in red, I thought it's not used in this area now, but it turned out I misunderstood, alas...
PS: READ_NATIVE_MAX(F8) <LBA28> or READ_NATIVE_MAX_EXT(27) <LBA48> These two functions are used under Linux, not available under DOS, and the source code can't be found in BC3.1
Floor8 netwinxp Posted 2008-10-30 11:55
高级用户 Posts 366 Credits 741
Originally posted by Joyoung at 2008-10-29 20:05:
PS:READ_NATIVE_MAX(F8)<LBA28> or READ_NATIVE_MAX_EXT(27)<LBA48>
Oh no! These are two ATA commands, F8 and 27. F8 is used in the LBA28 scenario, and 27 is used in LBA48. It's similar to EC stuff
Remember to share your great work with everyone when it's done!

[ Last edited by netwinxp on 2008-10-30 at 12:50 ]
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023