注册协议通知

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);
    }
  }
相关推荐
laplace012317 分钟前
Claude Skills 笔记整理
人工智能·笔记·agent·rag·skills
三块可乐两块冰19 分钟前
【第二十八周】机器学习笔记二十九
笔记
血小板要健康31 分钟前
Java基础常见面试题复习合集1
java·开发语言·经验分享·笔记·面试·学习方法
童话名剑1 小时前
情感分类与词嵌入除偏(吴恩达深度学习笔记)
笔记·深度学习·分类
请注意这个女生叫小美1 小时前
C语言 斐波那契而数列
c语言
Legendary_0081 小时前
Type-C 一拖二快充线:突破单口限制的技术逻辑
c语言·开发语言
智者知已应修善业1 小时前
【查找字符最大下标以*符号分割以**结束】2024-12-24
c语言·c++·经验分享·笔记·算法
91刘仁德2 小时前
c++类和对象(下)
c语言·jvm·c++·经验分享·笔记·算法
Stream_Silver2 小时前
【Agent学习笔记3:使用Python开发简单MCP服务】
笔记·python
Stream_Silver2 小时前
【Agent学习笔记2:深入理解Function Calling技术:从原理到实践】
笔记·python