China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-25 02:22
中国DOS联盟论坛 » DOS开发编程 & 发展交流 (开发室) » Ask about the data retrieved by the ATA 0xec command View 1,968 Replies 7
Original Poster Posted 2008-10-29 16:17 ·  IANA 局域网IP(Private-Use)
初级用户
Credits 48
Posts 18
Joined 2008-09-30 10:54
17-year member
UID 127064
Gender Male
Status Offline
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!~~~~
Floor 2 Posted 2008-10-29 16:27 ·  中国 福建 厦门 电信
高级用户
★★★
Credits 741
Posts 366
Joined 2007-07-25 19:11
18-year member
UID 94024
Gender Male
Status Offline
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 ]
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
Joyoung +2 2008-10-29 16:34
Floor 3 Posted 2008-10-29 16:38 ·  IANA 局域网IP(Private-Use)
初级用户
Credits 48
Posts 18
Joined 2008-09-30 10:54
17-year member
UID 127064
Gender Male
Status Offline
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!
Floor 4 Posted 2008-10-29 16:40 ·  中国 福建 厦门 电信
高级用户
★★★
Credits 741
Posts 366
Joined 2007-07-25 19:11
18-year member
UID 94024
Gender Male
Status Offline
Looking for the IDENTIFY_DEV(0ECH) command, which will mark where to find the definition of the 256 - byte.
Floor 5 Posted 2008-10-29 17:36 ·  IANA 局域网IP(Private-Use)
初级用户
Credits 48
Posts 18
Joined 2008-09-30 10:54
17-year member
UID 127064
Gender Male
Status Offline
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, Downloads: 28)
Floor 6 Posted 2008-10-29 19:04 ·  中国 福建 厦门 电信
高级用户
★★★
Credits 741
Posts 366
Joined 2007-07-25 19:11
18-year member
UID 94024
Gender Male
Status Offline
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 ]
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
Joyoung +2 2008-10-29 20:05
Floor 7 Posted 2008-10-29 20:05 ·  IANA 局域网IP(Private-Use)
初级用户
Credits 48
Posts 18
Joined 2008-09-30 10:54
17-year member
UID 127064
Gender Male
Status Offline
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
Floor 8 Posted 2008-10-30 11:55 ·  中国 福建 厦门 电信
高级用户
★★★
Credits 741
Posts 366
Joined 2007-07-25 19:11
18-year member
UID 94024
Gender Male
Status Offline
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 ]
Forum Jump: