=====================================================================
固件C字营·版权所有·欢迎转载
敬请关注微信公众号:“固件C字营”
敬请关注QQ群:1052307
敬请关注优快云博客:Cstyle_0x007
=====================================================================
在UEFI系统中,UEFI driver model的driver必须要提供Driver Binding protocol的实例,它提供了以下的两个UEFI boot services服务:Connect a driver to a controller/ Disconnect a driver from a controller,并且不同的driver类型所install的protocol也不尽相同。也就是说Device drivers, Bus drivers以及 Hybrid drivers都必须要要实例化这个protocol。其他的driver比如Root bridge driver, service drivers, and initializing drivers则不需要。
一个标准的Driver Binding Protocol一般包含以下的内容:
• Adds a global variable for the EFI_DRIVER_BINDING_PROTOCOL instance in *.C file
• An implementation of the Supported() service
• An implementation of the Start() service
• An implementation of the Stop() service
• Installs all the Driver Binding Protocols in the driver entry point
• If the UEFI Driver supports the unload feature, it then uninstalls all the Driver
Binding Protocols in the Unload() function.
下图是一个示例(在*.C里面实现):
类型声明:

实例化该protocol:
其中的version版本如上图所示,UEFI form有分配好哪些机构可以用哪些值,handle一般先初始化为NULL,再driver的entrypoint的地方,driver会初始化这两个handle。protocol一般可有BS来install
如:InstallMultipleProtocolInterfaces(),如果install失败同时driver有install了unload服务,那么就需要使用unload服务来uninstall该DriverBindingProtocol.

None of the Driver Binding Protocol services are allowed to use the console I/O
protocols. A UEFI Driver may use the DEBUG() and ASSERT() macros from the EDK II
library DebugLib to send messages to the standard error console if it is active. These
macros are usually enabled during UEFI Driver development and are disabled when a
UEFI Driver is released.
如上面的note所示,DriverBingProtocol不允许使用console IO protocol,只能使用EDK中预定义的宏来输出debug信息。同时我们需要在shell下加载和卸载driver来测试DriverBindProtocol来测试其是否正常工作。
以上是个人读书笔记和总结,转载请注明出处,谢谢。
=====================================================================
固件C字营·版权所有·欢迎转载
敬请关注微信公众号:“固件C字营”
敬请关注QQ群:1052307
敬请关注优快云博客:Cstyle_0x007
=====================================================================
@微信公众号《固件C字营》不定期更新状态,关注&订阅公众号不迷路。
完整PDF版整理中,可以在优快云下载频道搜索”UEFI内核导读“下载样张......