efi bios之handler&protocol

上传人:第*** 文档编号:31323772 上传时间:2018-02-06 格式:DOC 页数:12 大小:138KB
返回 下载 相关 举报
efi bios之handler&protocol_第1页
第1页 / 共12页
efi bios之handler&protocol_第2页
第2页 / 共12页
efi bios之handler&protocol_第3页
第3页 / 共12页
efi bios之handler&protocol_第4页
第4页 / 共12页
efi bios之handler&protocol_第5页
第5页 / 共12页
点击查看更多>>
资源描述

《efi bios之handler&protocol》由会员分享,可在线阅读,更多相关《efi bios之handler&protocol(12页珍藏版)》请在金锄头文库上搜索。

1、UEFI Spec 探讨- Handler&Protocol1. UEFI Firmware Core OverView首先再来回顾一下 UEFI 架构 : UEFI 整个系统以 UEFI firmware core(kernel)为核心,在firmware core 基础上可以编写 platform driver/application,然后通过 firmware services 加载运行.总的来看,UEFI firmware core 主要功能包括:1) Kernel Service Routines提供 EFI_SYSTEM_TABLE , 包含 kernel services. 即

2、boot services 和 runtime services2) Image Managementa.通过 Boot Services-LoadImage 可以 load 其它 driver/application 的 image,并生成ImageHandler, (关于 ImageHandle, 第一个 ImageHandle 就是 EFI firmware 本身,即EfiCoreImageHandle)b.通过 boot services-StartImage 运行 driver/application 的 EntryPoint.并传入两个参数如: 参看 SBDxe.cEFI_STAT

3、US SBDXE_Init(IN EFI_HANDLE ImageHandle,IN EFI_SYSTEM_TABLE *SystemTable)通过 SystemTable 就可以调用 Service 了。3) Driver Model/Protocol对 bus/device 提供 Driver Model/Protocol 的管理机制4) Event参看 UEFI Spec 探讨之 2 Event.doc5) Boot Management以下我们简单探讨下 Device Handler,重点学习一下 Protocol 相关的资料:2UEFI Driver Model / Device

4、HandlerDriver Model 机制1 Driver Image 的 load: 调用 firmware core 的 LoadImage()/StartImage(),同时也将生成一个 ImageHandle,而且firmware core 将为这个 ImageHandle 安装好一个 EFI_LOADED_IMAGE_PROTOCOL,并执行 DriverImage Entry. 一般 DriverImage Entry 并不 touch hardware. 只在 ImageHandle 上安装 Driver Binding Protocol 等 Protocols. 只有当调用

5、firmware core 的 ConnectController() service 连接到一个 Controller 或 Device 时才会运行 EFI_DRIVER_BINDING_PROTOCOL.Start()去管理Controller.2 Driver Binding Protocl最典型的是 PCI Driver. 例如:EFI_DRIVER_BINDING_PROTOCOL gPciBusDriverBinding = PciBusSupported, /SupportedPciBusStart, /PciBusDrvStart,PciBusStop, /PciBusDrvS

6、top,(PCI_BUS_MAJOR_VERInstallProtocolInterface (&Handle, &gCsmPlatformProtocolGuid,EFI_NATIVE_INTERFACE, &CsmPlatformProtocol);注: 特别要注意的是, 当一个 Protocol Interface 被 Install 时,将 notify 所有已经注册的callback function.即通过 RegisterProtocolNotify()传入 ProtocolInterface GUID 注册的 callback event. 后面会讲到具体这个 Notify.R

7、egisterProtocolNotify()Register 一个 Event, 以便当一个 ProtocolInterface 被 Install 时运行该 Event.typedef EFI_STATUS RegisterProtocolNotify(IN EFI_GUID *Protocol,IN EFI_EVENT Event,OUT VOID *Registration);参数说明:*Protocol: Protocol GUID, 向该 Protocol Register 一个 Event,当该 Protocol 被 Install时,将触发 Event 的运行.Event: 要

8、 Register 的 Event. 一般可通过 CreateEvent()创建.*Registration: 返回 Registeration Value.实例:参看 CRBDXE_InitStatus = pBS-LocateProtocol(&gAmiNbProtocolGuid,NULL,if (EFI_ERROR(Status)Status = pBS-CreateEvent(EVT_NOTIFY_SIGNAL,TPL_NOTIFY,CRBNbCallback, /;Create EventNULL,if (!EFI_ERROR(Status)Status = pBS-Registe

9、rProtocolNotify(&gAmiNbProtocolGuid, Event, ASSERT_EFI_ERROR(Status);这样当 gAmiNbProtocolGuid 被 Installed 的时候,将 signal 这个 CRBNbCallback 这个 Event Function.UninstallProtocolInterface()从一个 device handle 上 uninstall 一个 protocol.UEFI Spec 建议用 UninstallMultipleProtocolInterfaces()取代typedef EFI_STATUS Uninst

10、allProtocolInterface(IN EFI_HANDLE Handel,IN EFI_GUID *Protocol,IN VOID *Interface);参数说明:Handle: handle*Protocol: 要 uninstall 的 Protocol GUID*Interface: 要 uninstall 的 Protocol Interface.实例:OemDxe.cVOID SignalProtocolEvent(IN EFI_GUID *ProtocolGuid, IN VOID *Interface)EFI_HANDLE Handle = NULL;pBS-Ins

11、tallProtocolInterface (&Handle, ProtocolGuid, EFI_NATIVE_INTERFACE, Interface);pBS-UninstallProtocolInterface (Handle, ProtocolGuid, Interface);注:1. Caller 自己负责其它 driver 不再需要调用该 Uninstall 的 Protocol,否则可能出现问题。2. (EFI 1.10 extension) 可能遇到要 Uninstall 的 Protocol 正在被其他 driver 使用的情形.ReinstallProtocolInter

12、face()在一个 device handle 上用新的 protocol 替换掉旧的 protocol.typedef EFI_STATUS ReinstallProtocolInterface(IN EFI_HANDLE Handle,IN EFI_GUID *Protocol,IN VOID *OldInterface,IN VOID *NewInterface);参数说明:注:1. ReinstallProtocolInterface()实际上会先调用 UninstallProtocolInterface()旧的 Protocol, 然后再调用 InstallProtocolInter

13、face(),最后将调用 ConnectController().2. (EFI 1.10 extension) 可能遇到要 Reinstall 的 Protocol 正在被其他 driver 使用的情形.HandleProtocol()查询某个 Handle 是否支持某个 Protocol, 如果支持,返回 Protocol Interface.typedef EFI_STATUS HandleProtocol(IN EFI_HANDLE Handle,IN EFI_GUID *Protocol,OUT VOID *Interface);参数说明:Handle:*Protocol: Prot

14、ocol GUID*Interface: 如果成功,返回 Protocol Interface注:(EFI 1.10 Extension) 在新的 EFI 中, 使用 OpenProtocol()代替,定义为:EFI_STATUS HandleProtocol(IN EFI_HANDLE Handle,IN EFI_GUID *Protocol,OUT VOID *Interface)return OpenProtocol(Handle,Protocol,Interface,EfiCoreImageHandle,NULL,EFI_OPEN_PROTOCOL_BY_HANDLE_SUPPORT)

15、;.LocateHandle()查找支持某 Protocol 的 handles list. 返回指向 handles list buffer 的指针typedef EFI_STATUS LocateHandle(IN EFI_LOCATE_SEARCH_TYPE SearchType;IN EFI_GUID *Protocol OPTIONAL,IN VOID *SearchKey OPTIONAL,IN OUT UINTN *BufferSize,OUT EFI_HANDLE *Buffer);参数说明:SearchType: AllHandles/ByRegisterNotify/ByProtocol*Protocol OPTIONAL:*SearchKey OPTIONAL:-SearchType *Protocol OPTIONAL *SearchKey OPTIONAL-AllHandles null nullByRegisterNotify null 根据 SearchKey(即 RegisterProtocolNotify()返回的Registration 查找 )ByProtocol 根据 Protocol 指定的 GUID 来找 null.LocateProtocol()根据 ProtocolGUI

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 其它办公文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号