MdeModulePkg: document workaround for EFI_RUNTIME_EVENT_ENTRY PI spec bug

The PI spec (v1.7) correctly specifies "EFI_RUNTIME_EVENT_ENTRY.Event" in
natural language, but the field type in the structure definition itself is
wrong -- it should be EFI_EVENT, not (EFI_EVENT*).

This spec bug is likely unfixable for compatibility reasons, and so edk2
works it around already. We should clearly document the workaround.

Functionally, this patch is a no-op.

(I've also requested a non-normative (informative) clarification for the
PI spec: <https://mantis.uefi.org/mantis/view.php?id=2017>.)

Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
This commit is contained in:
Laszlo Ersek 2019-09-07 13:17:49 +02:00
parent 0bee7dbd2b
commit d342d318e9
2 changed files with 17 additions and 1 deletions

View File

@ -485,6 +485,14 @@ CoreCreateEventInternal (
IEvent->RuntimeData.NotifyTpl = NotifyTpl; IEvent->RuntimeData.NotifyTpl = NotifyTpl;
IEvent->RuntimeData.NotifyFunction = NotifyFunction; IEvent->RuntimeData.NotifyFunction = NotifyFunction;
IEvent->RuntimeData.NotifyContext = (VOID *) NotifyContext; IEvent->RuntimeData.NotifyContext = (VOID *) NotifyContext;
//
// Work around the bug in the Platform Init specification (v1.7), reported
// as Mantis#2017: "EFI_RUNTIME_EVENT_ENTRY.Event" should have type
// EFI_EVENT, not (EFI_EVENT*). The PI spec documents the field correctly
// as "The EFI_EVENT returned by CreateEvent()", but the type of the field
// doesn't match the natural language description. Therefore we need an
// explicit cast here.
//
IEvent->RuntimeData.Event = (EFI_EVENT *) IEvent; IEvent->RuntimeData.Event = (EFI_EVENT *) IEvent;
InsertTailList (&gRuntime->EventHead, &IEvent->RuntimeData.Link); InsertTailList (&gRuntime->EventHead, &IEvent->RuntimeData.Link);
} }

View File

@ -285,8 +285,16 @@ RuntimeDriverSetVirtualAddressMap (
for (Link = mRuntime.EventHead.ForwardLink; Link != &mRuntime.EventHead; Link = Link->ForwardLink) { for (Link = mRuntime.EventHead.ForwardLink; Link != &mRuntime.EventHead; Link = Link->ForwardLink) {
RuntimeEvent = BASE_CR (Link, EFI_RUNTIME_EVENT_ENTRY, Link); RuntimeEvent = BASE_CR (Link, EFI_RUNTIME_EVENT_ENTRY, Link);
if ((RuntimeEvent->Type & EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE) == EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE) { if ((RuntimeEvent->Type & EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE) == EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE) {
//
// Work around the bug in the Platform Init specification (v1.7),
// reported as Mantis#2017: "EFI_RUNTIME_EVENT_ENTRY.Event" should have
// type EFI_EVENT, not (EFI_EVENT*). The PI spec documents the field
// correctly as "The EFI_EVENT returned by CreateEvent()", but the type
// of the field doesn't match the natural language description. Therefore
// we need an explicit cast here.
//
RuntimeEvent->NotifyFunction ( RuntimeEvent->NotifyFunction (
RuntimeEvent->Event, (EFI_EVENT) RuntimeEvent->Event,
RuntimeEvent->NotifyContext RuntimeEvent->NotifyContext
); );
} }