机械硬盘ATA以及ATAPI

1 ATA寄存器
1.1 PCI IDE
Primary IDE controller: 1F0h to 1F7h and 3F6h to 3F7h
Secondary IDE controller: 170h to 177h and 376h to 377h

BAR0: Base address of primary channel (I/O space), if it is 0x0 or 0x1, the port is 0x1F0.
BAR1: Base address of primary channel control port (I/O space), if it is 0x0 or 0x1, the port is 0x3F6.
BAR2: Base address of secondary channel (I/O space), if it is 0x0 or 0x1, the port is 0x170.
BAR3: Base address of secondary channel control port, if it is 0x0 or 0x1, the port is 0x376.
BAR4: Bus Master IDE; refers to the base of I/O range consisting of 16 ports. Each 8 ports controls DMA on the primary and secondary channel respectively.
BAR5:SATA AHCI Base Address

SATA AHCI模式使用的BAR5和IDE模式使用的BAR0-BAR4是互斥的,只能二选一。
Figure 1-1 PCI Header

1.2 寄存器描述
1F0 (Read and Write): Data Register
1F1 (Read): Error Register
1F1 (Write): Features Register
1F2 (Read and Write): Sector Count Register
1F3 (Read and Write): LBA Low Register
1F4 (Read and Write): LBA Mid Register
1F5 (Read and Write): LBA High Register
1F6 (Read and Write): Drive/Head Register
1F7 (Read): Status Register
1F7 (Write): Command Register
3F6 (Read): Alternate Status Register
3F6 (Write): Device Control Register

1.3 ATA模式识别
读取4个寄存器的值("Sector Count" and "LBA Low,Mid,High" registers)
ATA:0x01, 0x01, 0x00, 0x00
ATAPI:0x01, 0x01, 0x14, 0xEB

2 ATAPI SFF-8070i
1)选择master或者slave磁盘(一个PCI IDE控制器最多支持4个port,一个PCI SATA控制器最多支持32个port),写入寄存器Drive/Head(1F6)
2)写PIO或者DMA模式到feature寄存器(1F1)
3)写扇区尺寸到LBA Mid和High寄存器(1F4和1F5)
4)IDE偏移07的命令寄存器(1F7)写入0xA0(ATA_CMD_PACKET)
5)写12字节的SCSI包到数据寄存器(1F0),等待IDE中断
6)从LBA Mid和High读取本次传输的字节
7)从数据寄存器(1F0)读,或者往数据寄存器(1F0)写数据,等待中断

3 USB To ATA/ATAPI Bridge
SFF-8070i/ATAPI BOT:0x08/0x05/0x50

4 机械硬盘主控
4.1 AVAGO TTTNS44310
4.2 LSI B5502D0
4.3 马达芯片
STM SMOOTH L7232

5 URLs
AT89C51SND1C
https://m.book118.com/html/2018/0523/168173987.shtm?from=mip

ATAPI
https://wiki.osdev.org/ATAPI

PCI IDE Controller
https://wiki.osdev.org/PCI_IDE_Controller

6 Abbreviations
MMC-2:SCSI Multimedia Commands-2
SFF-8020i:Small Form Factor Committee,小型化委员会

发布了124 篇原创文章 · 获赞 51 · 访问量 32万+

猜你喜欢

转载自blog.csdn.net/zoosenpin/article/details/74944004