uefi4.1更新的实验室在哪里(UEFI内核导读ATADriverStack)

固件C字营·版权所有

敬请关注“固件C字营”

敬请关注今日头条号:”固件C字营“

------------------------------------------------------------------------

SATA是我们最常见的硬盘接口,因为传输速度较慢现在绝大部分SATA接口只用在机械硬盘上。除了SATA之外常见的还SCSI、PCIE(NVME)接口也做为硬盘接口。为了与SATA接口硬盘进行数据传送必须使用ATA driver,它分成几个层次如下:

ATA host controller driver:

一般的SATA控制器都是挂在PCI总线下,所以ATA host controller driver一般是消费host controller handle上的PCI I/O Protocol,生产ATA Pass Thru Protocol 来访问硬盘设备,

Ext SCSI Pass Thru Protocol来访问CD/DVD。

ATA bus driver:

消费ATA Pass Thru Protocol,为控制器下挂的设备生产出child handle,并为其install Device Path Protocol,Block I/O Protocol, Block I/O 2 Protocol以及Storage Security Command Protocol.

ATA Host Controller Driver的实现:

host controller driver的实现和硬件平台息息相关的,不同的平台有不同的硬件配置,host controller数量也不一样,通常一个host controller driver需要控制多个控制器,所以我们需要确保driver的实现是可重入的,并为每一个控制器分配独立是私有的数据结构空间。实现步骤如下:

1.为每一个ATA host controller handle Install the ATA Pass Thru Protocol

2.为每一个SCSI host controller handle Install Extended SCSI Pass Thru Protocol

ATA Host Controller Driver :Supported()

和PCI driver一样先locate并open EFI_DEVICE_PATH_PROTOCOL、EFI_PCI_IO_PROTOCOL然后使用PCI IO Protocol 提供的服务去检测设备的VID、DID、Subclass Code。

ATA Host Controller Driver :Start()

初始化ATA host controller,一般有以下的步骤,他们和其他的driver基本一样:

1.Enable the PCI device.

2.Allocate resources.

3.Construct data structures for the driver to use.

4. Install the ATA Pass Thru Protocol instance on the same handle that has the PCI I/O Protocol.

5. Install the Extended SCSI Pass Thru Protocol instance on the same handle that has the PCI I/O Protocol.

ATA Host Controller Driver :Stop()

完成和start相反的动作:

1.Disable the ATA controller.

2. Release all resources that were allocated for this driver.

3. Close the protocol instances that were opened in the Start()function.

4. Uninstall the protocol interfaces that were attached on the host controller handle.

EFI_ATA_PASS_THRU_PROTOCOL 数据结构:

EFI_ATA_PASS_THRU_PROTOCOL会被用来获取挂在ATA host controller上的设备的各种信息和传递ATA数据请求包给设备,即使是这个设备不是可启动设备,这个通常可以用来作为一个诊断外设的手段。它还可以为那些需要作为启动设备device handle的block I/O driver提供底层访问的软件抽象和封装。

EFI_ATA_PASS_THRU_PROTOCOL.Mode:通常来获取和设定各种参

EFI_ATA_PASS_THRU_PROTOCOL.GetNextPort():

EFI_ATA_PASS_THRU_PROTOCOL.GetNextDevice():用来扫描所有的ATA设备。

EFI_ATA_PASS_THRU_PROTOCOL.BuildDevicePath():建立设备路径.

EFI_ATA_PASS_THRU_PROTOCOL.PassThru():这个是主角,有以下的功能,

1.Initialize the internal register for command/data transfer.

2.Put valid ATA commands into hardware-specific memory or register locations.

3.Start the transfer.

4.Optionally wait for completion of the execution.通常使用阻塞的传输模式。

uefi4.1更新的实验室在哪里(UEFI内核导读ATADriverStack)(1)

ATA bus driver的实现:

使用 ATA Pass Thru Protocol去扫描挂在ATA host controller下面的设备并且生产出 child handles,然后完成以下步骤,通常来说bus driver是通用driver我们一般不需要修改,porting到新平台的时候我们只需要修改和硬件平台相关的ATA Host Controller Driver就可以了:

1.Install Device Path Protocol to each child handle.

2.Install Block I/O Protocol on each child handle.

3.Install Block I/O 2 Protocol on each child handle.

4.If the hard drive supports the SPC-4 or ATA8-ACS command set, then install the Storage Security Command Protocol the child handle.

以上是对 ATA driver有一个简单介绍,细节可以参考相关的Spec。

敬请关注“固件C字营”

敬请关注今日头条号:”固件C字营“

,

免责声明:本文仅代表文章作者的个人观点,与本站无关。其原创性、真实性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容文字的真实性、完整性和原创性本站不作任何保证或承诺,请读者仅作参考,并自行核实相关内容。文章投诉邮箱:anhduc.ph@yahoo.com

    分享
    投诉
    首页