(3)分析得到的数据
DOS下运行: ahci1 F7906000 0
得到如下结果:
tablebuff SEG=1870 OFF=0000 FLAT ADDR=00018700
databuff SEG=18A4 OFF=0000 FLAT ADDR=00018A40
COMMAND HEADER in hex is:
05 00 01 00 00 00 00 00 00 87 01 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
COMMAND TABLE in hex is:
27 80 EC 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
40 8A 01 00 00 00 00 00 00 00 00 00 E7 03 00 80
HBA addr=F7906000H PORT addr=F7906100H
HBA MEM in hex is:
45 FF 30 CF 00 00 00 80 00 00 00 00 05 00 00 00
00 03 01 00 00 00 00 00 00 00 00 00 02 00 60 01
00 00 01 07 04 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
78 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
03 1E 31 00 1F 00 00 00 C0 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
分析如下:
45 FF 30 CF
1100 1111 0011 0000 1111 1111 0100 0101
支持6个口
支持32个SLOT
支持6Gbps
00 00 00 80
10000000 00000000 00000000 000000 0 0
AHCI已激活
总中断使能=0
未复位
00 00 00 00
各口没有中断产生
05 00 00 00
00000000 00000000 000000 00000101
第0、第2口有接设备
00 03 01 00 00 00 00 00 00 00 00 00 02 00 60 01
版本号1.3.0 不支持CCC功能 CCC口
00 00 01 07 04 00 00 00 00 00 00 00 00 00 00 00
不支持PM功能 扩展功能 控制权空闲
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
以下是VENDOR自己的东东:
78 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
03 1E 31 00 1F 00 00 00 C0 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
PORT MEM in hex is:
00 DC 09 00 00 00 00 00 00 E0 09 00 00 00 00 00
00 00 00 00 00 00 00 00 06 00 00 00 00 00 00 00
50 00 00 00 01 01 00 00 23 01 00 00 00 03 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
分析如下:
00 DC 09 00 00 00 00 00 00 E0 09 00 00 00 00 00
CML地址 接收FIS地址
00 00 00 00 00 00 00 00 06 00 00 00 00 00 00 00
IS无中断事件 中断使能=0 不支持POD,SUD
不是APAPI设备
command list未运行
不接收FIS!!
不处理COMMAND LIST!!
50 00 00 00 01 01 00 00 23 01 00 00 00 03 00 00
TFD,无ERR,无DRQ,无BSY 当前速度是2 不限速,不切换到其它电源状态
ERR=5 PxSSTS.DET = 3设备已连接
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
SERR无错误 用于“原生队列命令” CI未占用SLOT 用于Port Multiplier
SACT未占用SLOT
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
用于Port Multiplier 保留
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
另外,接SSD硬盘的PORT2的MEM如下:
00 DC 09 00 00 00 00 00 00 E0 09 00 00 00 00 00
CML地址 接收FIS地址 ---与PORT0是一样的地址!!!
00 00 00 00 00 00 00 00 06 00 00 00 00 00 00 00 ---与PORT0数据一样
50 00 00 00 01 01 00 00 23 01 00 00 00 03 00 00 ---与PORT0数据一样
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ---与PORT0数据一样
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
HAVE COPY COMMAND HEADER TO SLOT0
HAVE SET PxCMD.FRE
PxCMD is 00004016 --0100 0000 0001 0110 FRE设为1后,FR也变成1了
HAVE SET PxCMD.ST
PxCMD is 0000C017 --1100 0000 0001 0111 ST设为1后,CR也变成1了
data buff in hex is: 读出硬盘的512字节数据如下:
5A 04 FF 3F 37 C8 10 00 00 00 00 00 3F 00 00 00
00 00 00 00 20 20 20 20 20 20 32 4A 38 31 30 30
33 35 41 45 55 54 44 4E 03 00 00 40 04 00 45 4A
4F 44 36 41 41 30 69 48 61 74 68 63 20 69 54 48
35 53 37 34 36 35 41 34 45 39 38 33 20 34 20 20
20 20 20 20 20 20 20 20 20 20 20 20 20 20 10 80
00 40 00 2F 00 40 00 02 00 02 07 00 FF 3F 10 00
3F 00 10 FC FB 00 10 01 FF FF FF 0F 00 00 07 00
03 00 78 00 78 00 78 00 78 00 00 00 00 00 00 00
00 00 00 00 00 00 1F 00 06 17 00 00 5E 00 40 00
FC 01 28 00 6B 74 69 7D 63 61 69 74 49 BC 63 61
7F 20 51 00 52 00 80 40 FE FF 00 00 00 00 00 00
00 00 00 00 00 00 00 00 B0 82 85 4A 00 00 00 00
00 00 00 00 03 60 6C 82 00 50 A6 CC E1 3E EB 17
00 00 00 00 00 00 00 00 00 00 00 00 00 00 18 40
18 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00
29 00 0B 00 00 00 00 00 82 21 F1 1C 00 FA 00 00
00 40 00 04 08 01 00 00 00 00 04 0A 04 0A 03 0A
05 0A 00 00 00 00 00 00 00 00 00 00 00 00 00 00
33 44 36 44 00 00 04 29 00 00 AD 5D 18 25 00 80
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 3D 00 00 00
00 00 00 40 00 00 00 00 00 00 00 00 00 00 00 00
00 00 18 15 00 00 00 00 00 00 00 00 1F 10 21 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 01 00 E0 03 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 A5 4C
分析如下:每个WORD都是高字节在后 (参见ATA-7标准,EC命令)
(WORD0)5A 04
FF 3F 柱面总个数=16383
37 C8
10 00 磁头总个数=16
00 00 00 00 每磁道所含的字节数,每扇区所含的字节数
3F 00 每磁道所含的扇区总个数=63
即:16383×16×63=16514064扇区,8455200768字节,即8.4G的硬盘
与“INT 13H扩展”报告的是一样的
00 00 00 00
00 00
(WORD10)20 20 20 20 20 20 32 4A 38 31 30 30 33 35 41 45 55 54 44 4E
序列号20字节ASCII 内存中排列是2J810035AEUTDN,真实是J2180053EATUND
即每个WORD是高字节在后,但多个WORD的排列顺序是从前到后的
03 00 00 40 硬盘缓冲区容量
04 00 ECC校验码的长度
45 4A 4F 44 36 41 41 30 软体版本号8字节ASCII 内存中排列是EJOD6AA0 ,真实是JEDOA60A
69 48 61 74 68 63 20 69 54 48 35 53 37 34 36 35 41 34 45 39 38 33 20 34 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 硬盘型号40字节ASCII
(WORD47)10 80
00 40
00 2F capabilities
00 40 capabilities
00 02 00 02 obsolete
07 00
FF 3F 10 00
3F 00 10 FC FB 00
10 01
(WORD60)FF FF FF 0F Total number of user addressable sectors (扇区数,用于LBA28位寻址时用的)
The maximum value that shall be placed in this field is 0FFFFFFFh
00 00
(WORD63)07 00
03 00
78 00
78 00
78 00
78 00
00 00 00 00
(WORD71)00 00 00 00 00 00 00 00
1F 00 = 0001 1111
06 17
00 00
5E 00
40 00
(WORD80)FC 01 Major version number 0000 0001 1111 1100
28 00 Minor version number
6B 74
(WORD83 )69 7D bit 10 word 83 为1时,indicates support for 48-bit addressing
63 61 69 74 49 BC 63 61
(WORD88)7F 20 51 00 52 00 80 40 FE FF 00 00 00 00 00 00
00 00 00 00 00 00 00 00
(WORD100) B0 82 85 4A 00 00 00 00 Maximum user LBA for 48-bit Address feature set(扇区总数,用于LBA48位寻址用的)
//值比最大LBA再多1,LBA是从0开始的,故这里的值就是扇区总数,与AIDA检测一致
//= 1250263728 *512= 640GB
00 00 00 00
(WORD106)03 60 Physical sector size / Logical Sector Size
=01(有效) 1(1个物理扇区有多个逻辑扇区)0(words117-118无效,逻辑扇区是512字节) 0000 0000 0011
8 logical sector per physical sector,即1个物理扇区是8个逻辑扇区(4KB)
即产生4KB对齐的问题
6C 82 00 50 A6 CC E1 3E EB 17 World wide name
00 00 00 00 00 00 00 00 00 00
(WORD117)00 00 00 00 Logical Sector Size 这里无效
18 40
18 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00
29 00 0B 00 00 00 00 00 82 21 F1 1C 00 FA 00 00
00 40 00 04 08 01 00 00 00 00 04 0A 04 0A 03 0A
05 0A 00 00 00 00 00 00 00 00 00 00 00 00 00 00
33 44 36 44 00 00 04 29 00 00 AD 5D 18 25 00 80
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
(WORD176)00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Current media serial number
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
(WORD200)00 00 00 00 00 00 00 00 00 00 00 00 3D 00 00 00
00 00 00 40 00 00 00 00 00 00 00 00 00 00 00 00
00 00 18 15 00 00 00 00 00 00 00 00 1F 10 21 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 01 00 E0 03 00 00 00 00 00 00 00 00
(WORD240)00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
(WORD248)00 00 00 00 00 00 00 00 00 00 00 00 00 00 A5 4C
再读HBA MEM:
READing. source addr=F7906000 dest addr=00017B08
now 256 byte data in hex is:
45 FF 30 CF 00 00 00 80 00 00 00 00 05 00 00 00 ――内容都没有变化
00 03 01 00 00 00 00 00 00 00 00 00 02 00 60 01
00 00 01 07 04 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
78 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
03 1E 31 00 1F 00 00 00 C0 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
再读PORT0 MEM:
READing. source addr=F7906100 dest addr=00017B08
now 256 byte data in hex is:
00 DC 09 00 00 00 00 00 00 E0 09 00 00 00 00 00
02 00 00 00 00 00 00 00 17 C0 00 00 00 00 00 00
IS有事件 1100 0000 0001 0111
PIO Setup FIS Interrupt CR=1,FR=1,FRE=1,ST=1
即收到PIO包
50 00 00 00 01 01 00 00 23 01 00 00 00 03 00 00
TFD,无ERR,无DRQ,无BSY
0101 0000
ERR=5
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
SERR无错误 CI为0
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
再读COMMAND LIST:
READing. source addr=0009DC00 dest addr=00017B08
now 256 byte data in hex is:
05 00 01 00 00 02 00 00 00 87 01 00 00 00 00 00
显示已传输512字节
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
再读COMMAND TABLE: 原来的CFIS已经被冲掉了
READing. source addr=00018700 dest addr=00017B08
now 256 byte data in hex is:
30 20 30 30 20 30 30 20 30 30 20 0A 30 30 20 30
30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30
20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20
30 30 20 30 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
40 8A 01 00 00 00 00 00 00 00 00 00 E7 03 00 80 ――没有变化
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
一、 总结
以上程序均在TC3.0下编译成功,DOS下运行。
这个工程花了我1个月左右的空闲时间,虽然只研究出皮毛,但还好程序读取成功了。希望有所帮助。
程序主要用于直接访问AHCI控制器,进而访问SATA硬盘来获取硬盘参数。
得出的结论是:
直接IO读出的硬盘参数,与“INT13H扩展”报告的参数是一致的,所以就用“INT13H扩展”就可以了,除非要获得硬盘型号、序列号等信息。
“INT13H传统”报告的HCS有经过转换,与分区表的参数是一致的。
如果是读写SATA硬盘的扇区,直接就用BIOS的“INT13H扩展”中断就可以了。
AHCI规范实在太复杂了,很多没看懂。不深入研究了,结束。
文章评论(0条评论)
登录后参与讨论