在windows下可以透過
DeviceIoControl
對Device下ata cmd
可以使用win32提供的一組struct
ATA_PASS_THROUGH_DIRECT
直接傳遞指令格式
在這邊我介紹28bits的格式
此結構有許多設定其中28bits一定要設這組結構中的陣列,將ata cmd放進去:CurrentTaskFile
ATARegs_DirectRead.CurrentTaskFile[0] = cmd[0]; // feature reg
ATARegs_DirectRead.CurrentTaskFile[1] = cmd[1]; // sector cuont reg
ATARegs_DirectRead.CurrentTaskFile[2] = cmd[2]; // sector number reg
ATARegs_DirectRead.CurrentTaskFile[3] = cmd[3]; // cylinder low reg
ATARegs_DirectRead.CurrentTaskFile[4] = cmd[4]; // cylinder high reg
ATARegs_DirectRead.CurrentTaskFile[5] = cmd[5]; // Disk Head reg
ATARegs_DirectRead.CurrentTaskFile[6] = cmd[6]; // Cmd reg.
e.g
cmd[2] = 0x00; //LBA 0
cmd[2] = 0x01; //START FROM LBA 1
cmd[1] sector count reg:
512 bytes/1 sector
, 1 count = 1 sector = 512 bytes
. 如果資料長度為1024 bytes, 則count = 2
(實際要看Device端要怎麼接收這項參數)
Ata cmd文件說明針對此項的定義:
The number of logical sectors to be transferred. A value of 00h indicates that 256 logical sectors are to be transferred. Bits 15:8 shall be cleared to zero.