机械硬盘ATA以及ATAPI

文章详细介绍了PCIIDE控制器的地址空间分配,包括BAR0至BAR5的用途,以及ATA和ATAPI模式下的寄存器描述,如DataRegister、ErrorRegister等。还讨论了ATA模式识别过程和HDD的低级格式化,包括FormatUnit和ModeSelect指令的作用。此外,提到了USB到ATA/ATAPI桥接技术和相关芯片型号。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1 ATA HDD
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

1.4 HDD Low-level formatting
低级格式化历史:HDD一个完整扇区包括头部总计15字节的间隙(Gap)部分、同步(Sync)部分和地址标记(Address Mark)部分,总计512字节的数据(Data)部分,以及最后50字节的ECC部分,这些都是在低级格式化时所确定的。

SCSI指令Format Unit和Mode Select,可以一定程度改变HDD的工作模式,其中包括扇区尺寸。由于能够改变扇区的定义,所以这2个指令可以看着是对HDD的低级格式化操作。

ATA 50H:该命令用来格式化一个磁道,也即是低级格式化命令。

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,小型化委员会

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值