Outlookに他人の予定表を表示させる方法を追加
SATA
http://www.dgway.com/products/IP/SATA-IP/dg_sataahciip_refdesign_jp.pdf
SATA host - cable - SATA device
SATA host/device の protocol stack
コマンド層
トランスポート層 コマンドから FIS 生成
リンク上位層 FIS から DWORD 生成
リンク下位層 DWORD を 8b/10b エンコードして 10bit化
物理層(PHY)デジタル OOB 生成
物理層(PHY)アナログ SerDes によるシリアル化
上は送信の場合。受信の場合はこの逆
FIS (Frame Information Structure)
SOF, Payloard, CRC, EOF から構成される
FIS type 8 種類 (SOF で続く 10bit でtypeを指定)
OOB (Out-of-Band) インターフェイスのリセット、初期化や通信の確立、
スピードネゴシエーションをつかさどる仕組み
COMRESET/COMINIT と COMWAKE
OOB は SATA 規格の中で最も遅い 1.5 Gbps でリンク確立を行う。
確立後、ネゴシエーションにより 3/6 Gbps と上げながら可能な限り高速な
伝送速度に設定して通信が始まる。
FISの種類
- RegH2D (Register Host to Device)
- RegD2H
- PIOSU (PIO setup Device to Host)
- DMAACT (DMA Active Device to Host)
- DataFIS (Data Host to Device/Data Device to Host)
- SetDB (Set Device Bit Device to Host)
- DMASU (DMA Set up Host to Device/Device to Host)
- BIST
TaskFileRegister (ATAレジスタ)
Host では Shadow task Register と呼ぶ
- DevceHead
- CylinderHigh
- CylinderLow
- SectorNumber
LBA(Logical Block Address)を指す
コマンドの種類
- Device Identity
- Device Confugraton, Set Features
- Read Sectors
- Write Sectors
- Read DMA
- Write DMA
- Read DMA Ext
- Write DMA Ext
- ...
コマンドプロトコル
- 電源ON, PHY初期化
ホスト -> OOB -> デバイス -> resp -> ホスト (デバイス PHY 初期化完)
デバイス -> RegD2H -> ホスト
- リセット系
最後は デバイス -> RegD2H -> ホスト
- コマンド系
- No Data Protocol
- PIO data-in command Protocol
- PIO data-out command Protocol
- DMA data-in command Protocol
- DMA data-out command Protocol
- Packet Protocol
----------------------------------------------------------------------
SATA standard
SATA AHCI (Advanced Host Controller Interface) 1.3.1
HBA (Host Bus Adapters = AHCI host devices) == controller
HBA register + Descriptor in Memory
ABAR (config reg) : points Memory regs header address (in HBA)
Memory reg.
100h Port0 ** Twe descriptors per port.
P0CLB : Points Command List (Port 0) (in Mem)
P0FB : Points Received FIS Structure (Port 0) (in Mem) <= written from Device
Command list (for each Port)
(PxCLBU,PxCLB) +-----------------------------------------------+
Command slot 0 | DW0 : PRDTL[31:16], PMP, C/B/R/P/W/A, CFL |
| DW1 : PRDBC (PRD Byte Count) |
| DW2 : CTBA0[31:8] (Command Table Base Add) |
| DW3 : CTBA_U0 (Command Table Base Add, Upper) |
| DW4-DW7 : Reserved |
+-----------------------------------------------+
Command slot 1 | pointer to Command Table |
+-----------------------------------------------+
+-----------------------------------------------+
+-----------------------------------------------+
Command slot 31 | pointer to Command Table |
+-----------------------------------------------+
[31:16] PRDTL: Physical Region Descriptor Table Length (0 - 0xffff)
PMP: Port Multiplier Port
C:Clear, B:BIST, R:Reset P:Prefetchable,
[06] W:Write 1=>Device write, 0=>Device read
[05] A:ATAPI
[4:0] CFL: Command FIS Length up to 0x10(16d)
Command Table (for each slot)
(CTBA_U0,CTBA0)
0x00+-----------------------------------------------+
| CFIS(Command FIS) up to 64 bytes (16 DW) | See SATA spec 2.6
0x40+-----------------------------------------------+
| ACMD(ATAPI Command) 12 or 16 bytes |
0x50+-----------------------------------------------+
0x80+-----------------------------------------------+
| PRDT(Physical Region Descriptor Table) |
| --------------------------------
| entry 0 DW0 DBA (Data Base Address)
| DW1 DBAU
| DW2 (reserved)
| DW3 I(Intr), DBC(Byte Count), 1
| --------------------------------
| entry 1
| |
| entry up to 65,353 |
+-----------------------------------------------+
RECIEVED FIS
Received FIS (for each Port) from the device
(PxFUB,PxFB)
0x00 +-----------------------------------------------+
| DSFIS (DMA Setup FIS)
0x20 +-----------------------------------------------+
| PSFIS (PIO Setup FIS)
0x40 +-----------------------------------------------+
| RFIS (D2H Register FIS)
0x58 +-----------------------------------------------+
| SDBFIS (Set Device Bits FIS)
0x60 +-----------------------------------------------+
| UFIS (Unknown FIS) up to 64 bytes
0xA0 +-----------------------------------------------+
0xFF +-----------------------------------------------+
SATA 3.2
Transport layer FIS
* Register H2D FIS
DW0:
.. LBA,..
DW4:
* Register D2H FIS
* DMA set FIS (bidirection)
DW0:
DW1: DMA buffer ID (low)
DW2: DMA buffer ID (high)
DW3: reserved
DW4: DMA buffer offset
DW5: DMA transfer count
DW6: reserved
* PIO setup
* DATA (bidirection)
==============================================================
System memory structure
serial-ata-ahci-spec-rev1_3.pdf (AHCI)
Ch.4, Fig.5
Received FIS
Pointed by PxFB register
0x00 DMA Setup FIS (DSFIS)
0x20 PIO Setup FIS (PSFIS)
0x40 D2H Register FIS (RFIS)
0x58 Set Device Bits FIS (SDBFIS)
0x60 Unknown FIS (UFIS) up to 64kB
0xA0 (Reserved)
0xFF
Command List
Pointed by PxCLB
0x000 Command Header 0
0x020 Command Header 1
...
0x3E0 Command Header 31
0x3FF
In Command Header
DW0.[10]C 1にするとDeviceがR_OKを出すとBSY解除。転送を待つなら0にしておく
DW0.[4:0]CFL 0,1は不正値
DW2.[31:7]CTBA Command Table の base addr. [6:0]は切り捨て(128-byte align)
Command Table (for each port, up to 32 commands)
Pointed by {CTBAU,CTBA} in Command Header
0x000 CFIS ----------------> (other doc)
0x040 ATAPI Command (ACMD)
0x050 (Reserved)
0x080 PRDT (size of one PRDT is 0x10)
...
up to 65,535(0xFFFF) PRDT entries
PRDT
DW0.[31:1] DBA base addr of the data block. [0]切り捨て(2-byte(word) align)
DW3.[31]I Hostが転送後割り込みを出す(メモリやデバイスの受信は完了前)
PxIS.DPSがセットされ、enableなら割り込みを出す
DW3.[21:0] data block の長さ 実際の長さ-1 をセットする
---------------------------------------------------------------------
FIS
SerialATA_Revision_3_3_Gold.pdf (SATA 3.3)
Ch.10.5 (Transport layer)
FIS Type
27h Reigser Host to Device FIS
46h Data Host to Device or Device to Host
H2D FIS
DW0 Feature(7:0),Command(7:0),C,R,R,R,PM(4),FIS_Type(4)
DW1 Device(7:0),LBA(23:0)
DW2 Features(15:8),LBA(48:24)
DW3 Control(7:0),ICC(7:0),Count(15:0)
DW4 Auxiliary(31:0)
Reigser Host to Device FIS
C 1(転送がcommand regによりなされるとき)
CFIS.C = 1 は command の意味
= 0 は request software reset などに使う
FIS Type 27h
---------------------------------------------------------------------
Command
D1699r4a-ATA8-ACS.pdf ACS(ATA Command Set)
READ DMA C8h
Device (6) shall be set to 1
READ DMA EXT 25h 48bit
Device (6) shall be set to 1
READ FPDMA QUEUED 60h
mandatroy for NCQ
Device (6) shall be set to 1
Device (4) shall be set to 0
READ SECTOR(S) 20h PIO data-in
Device (6) shall be set to 1
WRITE BUFFER E8h PIO data-out
write 512byte block data to device's buffer
WRITE DMA CAh
Device (6) shall be set to 1
WRITE DMA EXT 35h (48bit)
Device (6) shall be set to 1
WRITE FPDMA QUEUED 61h
Device (6) shall be set to 1
Device (4) shall be set to 0
WRITE SECTOR(S) 30h PIO data-out
Device (6) shall be set to 1
READ LOG EXT 2Fh, PIO data-in
READ LOG DMA EXT 47h, DMA
READ LOG DMA EXT => subcommand of NCQ ???
---------------------------------------------------------------------
状態遷移
serial-ata-ahci-spec-rev1_3.pdf (AHCI)
Ch.5
SerialATA_Revision_3_3_Gold.pdf (SATA 3.3)
Ch.10.6 (Transport layer)
Command Processing Overview
SerialATA_Revision_3_3_Gold.pdf (SATA 3.3)
Appendix B
DI0(Idle)だとコマンド終了して待ち状態
---------------------------------------------------------------------
NCQ
SATA II で採用
First Party DMA(FPDMA)
WRITE FPDMA QUEUED 61h
READ FPDMA QUEUED 60h
http://pc.watch.impress.co.jp/docs/2003/1208/it012.htm
SATC reg set
READ LOG DMA EXT subcommand (01h)
---------------------------------------------------------------------
PIO
ATA 互換
Host - RegHD -> Device (PIO Data Out)
WRITE SECTOR(S) 30h PIO data-out
READ SECTOR(S) 20h PIO data-in
WRITE MULTIPLE C5h
SET MULTIPLE MODE C6h を先にする?
http://verif-systemverilog.seesaa.net/article/235218037.html?seesaa_related=related_article
---------------------------------------------------------------------
READ LOG EXT 2Fh, PIO Data-In
READ LOG DMA EXT 47h, DMA
Log を Host に返す
Inputs
Feature: Log Specific
Count : num of blocks of data to be read from the specified log
LBA[47:0]
[39:32] Page #(15:8) first log page to be read
[15:8] Page #(7:0)
[7:0] Log Address
Device[7:0]
[4] Transport Dependent
Command : 2Fh
Outpus
Annex A Log Definitions
Log structure example
"Log directory" 00h Page #0
"Log 0" 80h Page #0 (first 512-byte log page)
Page #1 (second ...)
...
Page #15
............................................
"Log last" 9Fh ............
log の page は 512bytes
Table A.1 Log address 00h to FFh (7:0) 1 LBA has 512bytes=1page
GPL(General Purpose Log)
SCT (SMART Command Transport)
Table A.2 Log address definition
00h: Log directory N/A (Feature Set), RO, GPL/SL
04h: Device Statistics, N/A, RO, GPL/SL
10h: NCQ Command Error, NCQ, RO, GPL
80h-9Fh: Host Vendor Specific, SMART, R/W, GPL/SL
A0h-DFh: Device Vendor Specific, SMART, Vendor Specific, GPL/SL
A.2 General Purpose Log Directory (00h)
512bytes, 256words
specifies version and num of pages of each log address
A.6 Device Vendor Specific Logs (A0h-DFh)
optional 何書いてもよい
A.10 Host Vendor Specific Logs (80h-9Fh)
mandatory 16 pages.
SMART WRITE LOG -> READ LOG EXT で同じものが返ってくる
host が何も書かなければ 0 が返ってくる
A.12 NCQ Command Error (10h)
1 page (512byte) see table A.27
D.2 Command process
==============================================================
https://www.slideshare.net/gene7299/sata-introduction
https://github.com/osdev-jp/osdev-jp.github.io/wiki/AHCI-Memo