注册协议通知

1 CoreRegisterProtocolNotify

C 复制代码
  Status = CoreRegisterProtocolNotify (
             &gEdkiiPeCoffImageEmulatorProtocolGuid,
             mPeCoffEmuProtocolRegistrationEvent,
             &mPeCoffEmuProtocolNotifyRegistration
             );

1.1 参数描述

  • &gEdkiiPeCoffImageEmulatorProtocolGuid
dec 复制代码
  ## Include/Protocol/PeCoffImageEmulator.h
  gEdkiiPeCoffImageEmulatorProtocolGuid = { 0x96f46153, 0x97a7, 0x4793, { 0xac, 0xc1, 0xfa, 0x19, 0xbf, 0x78, 0xea, 0x97 } }
  • mPeCoffEmuProtocolRegistrationEvent
  • &mPeCoffEmuProtocolNotifyRegistration

2 函数内容

C 复制代码
EFI_STATUS
EFIAPI
CoreRegisterProtocolNotify (
  IN EFI_GUID   *Protocol,
  IN EFI_EVENT  Event,
  OUT  VOID     **Registration
  )
{
  PROTOCOL_ENTRY   *ProtEntry;
  PROTOCOL_NOTIFY  *ProtNotify;
  EFI_STATUS       Status;

  if ((Protocol == NULL) || (Event == NULL) || (Registration == NULL)) {
    return EFI_INVALID_PARAMETER;
  }

  CoreAcquireProtocolLock ();

  ProtNotify = NULL;

  //
  // Get the protocol entry to add the notification too
  //

  ProtEntry = CoreFindProtocolEntry (Protocol, TRUE);
  if (ProtEntry != NULL) {
    //
    // Allocate a new notification record
    //
    ProtNotify = AllocatePool (sizeof (PROTOCOL_NOTIFY));
    if (ProtNotify != NULL) {
      ((IEVENT *)Event)->ExFlag |= EVT_EXFLAG_EVENT_PROTOCOL_NOTIFICATION;
      ProtNotify->Signature      = PROTOCOL_NOTIFY_SIGNATURE;
      ProtNotify->Protocol       = ProtEntry;
      ProtNotify->Event          = Event;
      //
      // start at the begining
      //
      ProtNotify->Position = &ProtEntry->Protocols;

      InsertTailList (&ProtEntry->Notify, &ProtNotify->Link);
    }
  }

  CoreReleaseProtocolLock ();

  //
  // Done.  If we have a protocol notify entry, then return it.
  // Otherwise, we must have run out of resources trying to add one
  //

  Status = EFI_OUT_OF_RESOURCES;
  if (ProtNotify != NULL) {
    *Registration = ProtNotify;
    Status        = EFI_SUCCESS;
  }

  return Status;
}

2.1 检测前提并锁定协议

C 复制代码
  if ((Protocol == NULL) || (Event == NULL) || (Registration == NULL)) {
    return EFI_INVALID_PARAMETER;
  }

  CoreAcquireProtocolLock ();

2.2 获取要添加通知的协议条目

C 复制代码
  ProtEntry = CoreFindProtocolEntry (Protocol, TRUE);
  if (ProtEntry != NULL) {
    //
    // Allocate a new notification record
    //
    ProtNotify = AllocatePool (sizeof (PROTOCOL_NOTIFY));
    if (ProtNotify != NULL) {
      ((IEVENT *)Event)->ExFlag |= EVT_EXFLAG_EVENT_PROTOCOL_NOTIFICATION;
      ProtNotify->Signature      = PROTOCOL_NOTIFY_SIGNATURE;
      ProtNotify->Protocol       = ProtEntry;
      ProtNotify->Event          = Event;
      //
      // start at the begining
      //
      ProtNotify->Position = &ProtEntry->Protocols;

      InsertTailList (&ProtEntry->Notify, &ProtNotify->Link);
    }
  }
相关推荐
flying robot16 小时前
centos7系统配置
笔记
xie_pin_an18 小时前
深入浅出 C 语言数据结构:从线性表到二叉树的实战指南
c语言·数据结构·图论
zhdy5678919 小时前
最简单方法 设置matlab坐标轴刻度标签的字号,设置坐标轴标题和图形标题,并指定字号。画出的图片背景设置为白色,
笔记
崇山峻岭之间19 小时前
Matlab学习笔记02
笔记·学习·matlab
木木em哈哈19 小时前
C语言多线程
笔记
hssfscv21 小时前
Javaweb 学习笔记——html+css
前端·笔记·学习
总爱写点小BUG21 小时前
打印不同的三角形(C语言)
java·c语言·算法
Dream Algorithm1 天前
自古英雄多寂寥
笔记
yuhaiqun19891 天前
Typora 技能进阶:从会写 Markdown 到玩转配置 + 插件高效学习笔记
经验分享·笔记·python·学习·学习方法·ai编程·markdown
apcipot_rain1 天前
汇编语言与逆向分析 一轮复习笔记
汇编·笔记·逆向