当前位置: 首页 > news >正文

UEFI EDK2框架学习(三)——protocol

一、Protocol协议

  • 搜索支持特定Protocol的设备,获取其Handle

gBS->LocateHandleBuffer

  • 将内存中的Driver绑定到给定的ControllerHandle

gBS->OpenProtocol

二、代码实现

Protocol.c

#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/UefiBootServicesTableLib.h>EFI_STATUS
EFIAPI
UefiMain(IN EFI_HANDLE ImageHandle,IN EFI_SYSTEM_TABLE *SystemTable
) {EFI_STATUS Status = EFI_SUCCESS;UINTN NoHandles = 0;EFI_HANDLE *Buffer = NULL;Status = gBS->LocateHandleBuffer(ByProtocol,&gEfiGraphicsOutputProtocolGuid,NULL,&NoHandles,&Buffer);Print(L"Status = %d", Status);if (EFI_ERROR(Status)) {Print(L"Failed to LocateHandleBuffer. \n");return Status;}Print(L"Hello, Protocol\n");EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop;Status = gBS->OpenProtocol(Buffer[0],&gEfiGraphicsOutputProtocolGuid,(VOID**)&Gop,ImageHandle,NULL,EFI_OPEN_PROTOCOL_GET_PROTOCOL);Print(L"Status = %d", Status);if (EFI_ERROR(Status)) {Print(L"Failed to OpenProtocol. \n");return Status;}return Status;
}

Protocol.inf

[Defines]INF_VERSION = 0x00010006BASE_NAME = ProtocolFILE_GUID = 767c2824-dbe2-4a8f-b2f5-8a10f23e7853MODULE_TYPE = UEFI_APPLICATIONVERSION_STRING = 0.1ENTRY_POINT = UefiMain[Sources]HelloWorld.c[Packages]MdePkg/MdePkg.dec[LibraryClasses]UefiApplicationEntryPointUefiLib

ProtocolPkg.dsc

[Defines]PLATFORM_NAME = ProtocolPkgPLATFORM_GUID = 767c2824-dbe2-4a8f-b2f5-8a10f23e7853PLATFORM_VERSION = 0.1DSC_SPECIFICATION = 0x00010005SUPPORTED_ARCHITECTURES = X64BUILD_TARGETS = DEBUG|RELEASEOUTPUT_DIRECTORY = ProtocolPkg/Build[LibraryClasses]UefiLib|MdePkg/Library/UefiLib/UefiLib.infUefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.infPrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.infPcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.infMemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.infDebugLib|MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.infBaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.infBaseLib|MdePkg/Library/BaseLib/BaseLib.infUefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.infDevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.infUefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.infRegisterFilterLib|MdePkg/Library/RegisterFilterLibNull/RegisterFilterLibNull.infDebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
[Components]ProtocolPkg/Protocol.inf

三、参考文献

UEFI——UEFI 基础服务_installprotocolinterface-CSDN博客

UEFI——protocol服务详解_uefi protocol-CSDN博客

http://www.lryc.cn/news/450643.html

相关文章:

  • PostgreSQL的字段存储类型了解
  • CTFshow 命令执行 web29~web36(正则匹配绕过)
  • 【顺序表使用练习】发牌游戏
  • 1.7 编码与调制
  • 004集—— txt格式坐标写入cad(CAD—C#二次开发入门)
  • CSS中的font-variation-settings:探索字体的可变性
  • 组合优化与凸优化 学习笔记5 对偶拉格朗日函数
  • 监控易监测对象及指标之:Exchange邮件服务器监测
  • 【机器学习基础】Transformer学习
  • mysql如何不使用窗口函数,去统计出入库情况
  • uni-app canvas文本自动换行
  • 【设计模式-职责链】
  • Prompt:在AI时代,提问比答案更有价值
  • whatis命令:关于命令的简短描述
  • ICM20948 DMP代码详解(54)
  • RabbitMQ的应用问题
  • C++14:通过make_index_sequence实现将tuple转换为array
  • Linux中修改MySQL密码
  • 华为OD真题机试-英文输入法(Java)
  • 【React 】入门Day01 —— 从基础概念到实战应用
  • 2024年9月总结及随笔之丢卡
  • sql语法学习 sql各种语法 sql增删改查 数据库各种操作 数据库指令
  • 鸡兔同笼,但是线性代数
  • 01---java面试八股文——springboot---10题
  • 计算机毕业设计 二手图书交易系统的设计与实现 Java实战项目 附源码+文档+视频讲解
  • 【进阶OpenCV】 (3)--SIFT特征提取
  • HarmonyOS/OpenHarmony Audio 实现音频录制及播放功能
  • css 中 ~ 符号、text-indent、ellipsis、ellipsis-2、text-overflow: ellipsis、::before的使用
  • Activiti 工作流大致了解
  • 速盾:高防 CDN,网站安全的有力保障