1 引言
20世纪90年代后期,嵌入式系统在工业控制、远程监控和数据采集等领域的应用日趋广泛,人们对嵌入式系统的存储容量也提出了较高的要求。因此研制适用于嵌入式系统的大容量、高速率、高可靠性的数据存储系统变得日益重要。本文针对一款基于ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM" title="ARM">ARM920T芯片的开发板,根据ATA硬盘接口规范,设计了IDE硬盘接口电路,实现了对IDE硬盘的读写,可以在Linux系统中对其上的文件系统自由访问,达到了高速率和高可靠性的要求。
2ARM920T与S3C2410介绍
ARM 包括一系列微处理芯片技术。ARM920T是ARM系列微处理器的一种,它采用5阶段管道化ARM9TDMI内核,同时配备了Thumb扩展、EmbeddedICE调试技术和Harvard总线。在生产工艺相同的情况下,性能可达ARM7TDMI芯片的两倍之多。ARM920T系列主要应用于机顶盒产品、掌上电脑、笔记本电脑和打印机。
S3C2410处理器是Samsung 公司基于ARM公司的ARM920T处理器核,采用0.18umSU造工艺的32位微控制器。该处理器拥有独立的16KB指令Cache和16KB数据Cache、MMU、支持TFT的LCD控制器、NAND闪存控制器、3路UART、4路DMA、4路带PWM的Timer、I/O口、RTC、8路10位ADC、TouchScreen接口、IIC-BuS接口、IIS-BuS接口、2个USB主机、1个USB设备、SD主机和MMC接口和2路SPI。S3C2410处理器最高可运行在268MHz。
3 IDE接口及其规范
IDE(Integrated Drive Electronics)是从IBM PC/AT上使用的ATA接口发展而来的。IDE/ATA磁盘驱动器与早期的ATA驱动器相比,增加了任务文件寄存器,包括数据寄存器、状态寄存器以及反映地址的驱动器号、磁头号、道号和扇区号寄存器等。ATA接口规范定义了信号电缆和电源线的电器特征、互联信号的电器和逻辑特征,还定义了存储设备中可操作的寄存器以及命令和协议。
3.1 寄存器
规范定义了两组寄存器:命令寄存器和控制寄存器。命令寄存器用来接收命令和传送数据,控制寄存器用来控制磁盘操作。常用的寄存器包括数据寄存器、命令寄存器、驱动器/磁头寄存器、柱面号寄存器、扇区号寄存器、扇区数寄存器和状态寄存器。
3.2 数据传输方式
ATA接口规范定义了两种数据传输方式:可编程I/O(PIO)方式和DMA方式。PIO传送方式下,CPU对控制器的访问都是通过PIO进行的,包括从控制器读取状态信息和错误信息,以及向控制器发送命令和参数。在一次PIO数据传输过程中,CPU先选址,然后使读/写信号有效,CPU或控制器放数据到数据总线,控制器或CPU读取数据,操作完成后,释放总线,这样一次数据传输完成。DMA方式,即直接内存访问,CPU把缓冲区的地址与需要读写的长度告诉外设,外设在准备好后向CPU发出一个DMA请求,要求CPU暂停使用内存,获得同意后就直接在内存和外设之间传输数据,完成后再把对内存的访问权归还给CPU。
4 硬件实现
如图1所示,S3C2410与硬盘之间接口电路分为3个部分:片选信号、数据信号和控制信号。硬盘上寄存器分为两组,分别由IDE_CS0和IDE_CS1选中,DA0~DA2则用于组内寄存器寻址;数据线DD0~DD15因存在输入/输出方向问题,故用nOE(读信号)接buffer(74LVTH162245)的DIR引脚来控制缓冲器方向;控制信号部分因该CPU与硬盘之间DMA时序不一致,故采用一块EPM7032AETC44-7芯片用于调整其时序。PIO模式下,不需要DMARQ和nDMACK信号,DMA模式下,这两个信号才起作用。
5 软件实现
硬盘驱动程序实现分为初始化、打开设备、设备I/O操作和释放设备等几部分。
5.1 硬盘初始化
与X86不同,在ARM 体系结构中,对内存和外设的访问使用统一的指令,所以要对外设地址进行内存映射。也就是说,通过一张表将I/O地址映射到内存空间中来,这部分工作是在系统初始化期间完成的。
在IDE子系统初始化期间,Linux系统一旦发现一个IDE控制器,就设置它的ide_hwif_t结构来反映这个控制器和与之相连的磁盘;向Linux的VFS登记每一个控制器,并分别把它加到blk_dev和blkdevs向量表中;请求控制适当的IRQ中断(主IDE控制器是14,次IDE控制器是15)和I/O空间(主控制器0x1f0,次控制器0x170):为每一个找到的IDE控制器在gendisk列表中增加一个条目。
IDE硬盘的初始化工作由idedisk_init完成:
(1)在数组ide_hwifs中找出已登记得各IDE控制器控制的所有IDE硬盘(一个控制器最多控制两个硬盘),每个IDE硬盘对应一个ide_drive_t结构。
(2)对找到的每个IDE硬盘,调用函数ide_register_subdriver填写各IDE硬盘结构中的相关信息域,主要是填写其驱动程序结构ide_driver_t。硬盘驱动中的函数do_rw_disk通过向磁盘控制寄存器写参数启动磁盘操作,完成真正的数据读写。
(3)对找到的每个IDE硬盘,调用函数idedisk_setup进一步设置其ide_drive_t结构,包括设置该结构的settings域、doorlocking域、cyl、head、sect域、id域等。
5.2 打开设备
打开块设备的操作与打开普通文件的操作基本相同。
(1)在当前进程的文件描述符表中为打开文件找一个空位,申请一块内存,用于建立新文件的打开文件对象,即结构file。
(2)解析设备特殊文件名,获得其VFSinode和dentry结构,根据dentry结构填写file结构,尤其是将file结构的f_op域设为其VFSinode中的缺省文件操作。
(3)执行该文件操作集中的open操作,即blkdev_open,它根据设备特殊文件的主次设备号从blkdevs向量表中取出已经注册的文件操作集(file_operations)fops,用该结构代替file结构中的f_op域。
(4)执行中新文件操作集中的open操作,即bl带头kdev_open,它根据VFS
inode中的i_rdev域查找数组ide_hwifsp[],从中找出该IDE硬盘所对应的ide_drive_t结构;如果ide_drive_t结构中注册有驱动程序,执行驱动程序集中的open操作。
(5)将打开文件对象插入到当前进程的文件描述符表中,返回文件描述符,即打开文件对象在进程文件描述符表中的索引。
5.3 设备I/O操作
读写块设备时要用到块缓冲区(bufer),对bufer的管理采用BuferCache机制。它管理bufer的创建、撤销、回收、查找、更新等,同时还要与系统中的其它部分(如文件系统、内存管理等)交互。Linux将Buffer
Cache从块设备驱动程序中独立出来,作为对块设备读写的通用机制,所以对块设备的读、写、同步等操作采用的都是由操作系统提供的公共函数,一般为block_read()和block_write()。
为了减少对块设备操作的次数,读写块设备时采用延迟操作,尽量将多个读写操作合并,所以操作请求不是马上递交给物理设备,而是提供了一种手段记录每次的请求(request),并为每类块设备提供一个请求队列用来排队、合并、重组对该块设备的请求。
当需要从硬盘读时,block_read()函数首先查找Buffer Cache
如果在其中能找到需要的buffer,则立刻返回:否则,生成一个读请求,并将其加入相应的请求队列排队。
当需要向硬盘写时,block_write()为此次写操作生成一个buffer,而后生成一个写请求,并将其加入相应的请求队列排队。
块设备驱动程序提供了一个请求处理函数,对硬盘而言是函数do_rw_disk。在适当的时候,硬盘的请求处理函数启动,do_rw_disk处理在请求队列上排队的请求,通过向硬盘发出读、写命令完成对设备的真正操作。其伪代码如下:
DO_RW_DISK(COMMAND)
{
Set_Registers();
if(COMMAND=READ){
Set read_intr as interrupt process function
Send WIN_READ or WIN_MULTREAD
command to Command register
}
if(COMMAND=WRITE){
Send WIN_WRITE or
WIN_MULTWRITE command to Command register
Get the status of Status register
and set DRQ bit
Set write intr as interrupt process function
Senddatato buferin thedisk
}
}
5.4 释放设备
由设备驱动程序中的release操作完成,一般完成与打开设备相反的动作:释放打开设备特殊文件时在file结构上所创建的私有结构;如果是最后一个设备的释放,则从硬件上关闭设备。
6 结束语
通过上述方法对IDE硬盘接口的设计与实现,我们可以在S3C2410开发板上安全自由地对硬盘上的各种文件系统进行访问,由于采用DMA方式,可以满足用户对速率的要求。