[edk2-devel] [PATCH V2 4/4] MdeModulePkg/DxeMain: Implement common event protocol
From: Sean Brogan REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1400 If an interrupt happens between CheckEvent and gIdleLoopEvent, there would be a event pending during cpu sleep. So it is required to check the gEventPending with the interrupt disabled. Implement a protocol gEdkiiCommonEventProtocolGuid to support all TPL event for PI drivers that use HW interrput. It has two interface, one is to create event and the other one is to wait for event. Add 'volatile' specifier for gEfiCurrentTpl and gEventPending because they may be changed out of the context (interrupt context). Cc: Jian J Wang Cc: Hao A Wu Cc: Ray Ni Cc: Star Zeng Cc: Liming gao Cc: Sean Brogan Cc: Michael Turner Cc: Bret Barkelew Signed-off-by: Zhichao Gao --- MdeModulePkg/Core/Dxe/DxeMain.h | 64 ++- MdeModulePkg/Core/Dxe/DxeMain.inf | 2 + MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c | 22 .../Core/Dxe/DxeMain/DxeProtocolNotify.c | 1 + MdeModulePkg/Core/Dxe/Event/Event.c | 102 -- MdeModulePkg/Core/Dxe/Event/Event.h | 2 +- MdeModulePkg/Include/Protocol/Cpu2.h | 2 +- 7 files changed, 181 insertions(+), 14 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeMain.h index 6a64852730..38907bfe8d 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.h +++ b/MdeModulePkg/Core/Dxe/DxeMain.h @@ -38,6 +38,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include #include #include #include @@ -47,6 +48,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include #include #include #include @@ -274,10 +276,11 @@ extern EFI_METRONOME_ARCH_PROTOCOL *gMetronome; extern EFI_TIMER_ARCH_PROTOCOL *gTimer; extern EFI_SECURITY_ARCH_PROTOCOL *gSecurity; extern EFI_SECURITY2_ARCH_PROTOCOL *gSecurity2; +extern EDKII_CPU2_PROTOCOL *gCpu2; extern EFI_BDS_ARCH_PROTOCOL*gBds; extern EFI_SMM_BASE2_PROTOCOL *gSmmBase2; -extern EFI_TPL gEfiCurrentTpl; +extern volatile EFI_TPL gEfiCurrentTpl; extern EFI_GUID *gDxeCoreFileName; extern EFI_LOADED_IMAGE_PROTOCOL*gDxeCoreLoadedImage; @@ -1714,6 +1717,65 @@ CoreCheckEvent ( ); +/** + Stops execution until an event is signaled. + + Support all TPL. + + @param NumberOfEvents The number of events in the UserEvents array + @param UserEvents An array of EFI_EVENT + @param UserIndex Pointer to the index of the event which + satisfied the wait condition + + @retval EFI_SUCCESSThe event indicated by Index was signaled. + @retval EFI_INVALID_PARAMETER The event indicated by Index has a notification + function or Event was not a valid type + @retval EFI_UNSUPPORTEDThe current TPL is not TPL_APPLICATION + +**/ +EFI_STATUS +EFIAPI +CommonWaitForEvent ( + IN UINTNNumberOfEvents, + IN EFI_EVENT*UserEvents, + OUT UINTN *UserIndex + ); + + +/** + Creates an event in a group. + + Support all TPL. + + @param Type The type of event to create and its mode and + attributes + @param NotifyTpl The task priority level of event notifications + @param NotifyFunction Pointer to the events notification function + @param NotifyContext Pointer to the notification functions context; + corresponds to parameter "Context" in the + notification function + @param EventGroup GUID for EventGroup if NULL act the same as + gBS->CreateEvent(). + @param Event Pointer to the newly created event if the call + succeeds; undefined otherwise + + @retval EFI_SUCCESSThe event structure was created + @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value + @retval EFI_OUT_OF_RESOURCES The event could not be allocated + +**/ +EFI_STATUS +EFIAPI +CommonCreateEventEx ( + IN UINT32 Type, + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL + IN CONST VOID *NotifyContext, OPTIONAL + IN CONST EFI_GUID *EventGroup,OPTIONAL + OUT EFI_EVENT *Event + ); + + /** Adds reserved memory, system memory, or memory-mapped I/O resources to the global coherency domain of the processor. diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf b/MdeModulePkg/Core/Dxe/DxeMain.inf index 61161bee28..44f90bcf4b 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.inf +++ b/MdeModulePkg/Core/Dxe/DxeMain.inf @@ -17
Re: [edk2-devel] [PATCH V2 4/4] MdeModulePkg/DxeMain: Implement common event protocol
> -Original Message- > From: Wang, Jian J > Sent: Wednesday, July 10, 2019 4:47 PM > To: Gao, Zhichao ; devel@edk2.groups.io > Cc: Sean Brogan ; Wu, Hao A > ; Ni, Ray ; Zeng, Star > ; Gao, Liming ; Michael Turner > ; Bret Barkelew > > Subject: RE: [PATCH V2 4/4] MdeModulePkg/DxeMain: Implement common > event protocol > > Zhichao, > > > -Original Message- > > From: Gao, Zhichao > > Sent: Wednesday, July 10, 2019 8:24 AM > > To: Wang, Jian J ; devel@edk2.groups.io > > Cc: Sean Brogan ; Wu, Hao A > > ; Ni, Ray ; Zeng, Star > > ; Gao, Liming ; Michael > > Turner ; Bret Barkelew > > > > Subject: RE: [PATCH V2 4/4] MdeModulePkg/DxeMain: Implement > common > > event protocol > > > > > > > > > -Original Message- > > > From: Wang, Jian J > > > Sent: Tuesday, July 9, 2019 5:24 PM > > > To: Gao, Zhichao ; devel@edk2.groups.io > > > Cc: Sean Brogan ; Wu, Hao A > > > ; Ni, Ray ; Zeng, Star > > > ; Gao, Liming ; Michael > > Turner > > > ; Bret Barkelew > > > > > > Subject: RE: [PATCH V2 4/4] MdeModulePkg/DxeMain: Implement > > common > > > event protocol > > > > > > Hi Zhichao, > > > > > > One common comment: please update copy right year. > > > > I got the copyright remind before. Refer to > > https://edk2.groups.io/g/devel/topic/31828852#41576. > > This patch is almost provided from MU project and contributed by > > Microsoft developers, 'From:...' is the author. And they didn't add > > their copyright. So I think it is fine to keep the copyright. > > > > I mean the *year* in Intel copyright not the whole copyright. https://edk2.groups.io/g/devel/message/41599 https://edk2.groups.io/g/devel/message/41753 See above message. Maybe updating the year means you are making a legal claim to the intellectual property provided by the patch on behalf of the company. Thanks, Zhichao > > Regards, > Jian > > > > > > > See another comment at the almost the end of the email. > > > > > > > -Original Message- > > > > From: Gao, Zhichao > > > > Sent: Tuesday, July 09, 2019 4:40 PM > > > > To: devel@edk2.groups.io > > > > Cc: Sean Brogan ; Wang, Jian J > > > > ; Wu, Hao A ; Ni, Ray > > > > ; Zeng, Star ; Gao, Liming > > > > ; Michael Turner > > > ; > > > > Bret Barkelew > > > > Subject: [PATCH V2 4/4] MdeModulePkg/DxeMain: Implement > common > > > event > > > > protocol > > > > > > > > From: Sean Brogan > > > > > > > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1400 > > > > > > > > If an interrupt happens between CheckEvent and gIdleLoopEvent, > > > > there would be a event pending during cpu sleep. So it is required > > > > to check the gEventPending with the interrupt disabled. > > > > > > > > Implement a protocol gEdkiiCommonEventProtocolGuid to support all > > TPL > > > > event for PI drivers that use HW interrput. It has two interface, > > > > one is to create event and the other one is to wait for event. > > > > > > > > Add 'volatile' specifier for gEfiCurrentTpl and gEventPending > > > > because they may be changed out of the context (interrupt context). > > > > > > > > Cc: Jian J Wang > > > > Cc: Hao A Wu > > > > Cc: Ray Ni > > > > Cc: Star Zeng > > > > Cc: Liming gao > > > > Cc: Sean Brogan > > > > Cc: Michael Turner > > > > Cc: Bret Barkelew > > > > Signed-off-by: Zhichao Gao > > > > --- > > > > MdeModulePkg/Core/Dxe/DxeMain.h | 64 ++- > > > > MdeModulePkg/Core/Dxe/DxeMain.inf | 2 + > > > > MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c | 22 > > > > .../Core/Dxe/DxeMain/DxeProtocolNotify.c | 1 + > > > > MdeModulePkg/Core/Dxe/Event/Event.c | 102 > > - > > > > - > > > > MdeModulePkg/Core/Dxe/Event/Event.h | 2 +- > > > > MdeModulePkg/Include/Protocol/Cpu2.h | 2 +- > > > > 7 files changed, 181 insertions(+), 14 deletions(-) > > > > > > > > diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h > > > > b/MdeModulePkg/Core/Dxe/DxeMain.h index > > 6a64852730..38907bfe8d > > > 100644 > > > > --- a/MdeModulePkg/Core/Dxe/DxeMain.h > > > > +++ b/MdeModulePkg/Core/Dxe/DxeMain.h > > > > @@ -38,6 +38,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > > > > #include #include > > > > #include > > > > +#include > > > > #include > > > > #include #include > > > > @@ -47,6 +48,7 @@ SPDX-License-Identifier: > > > > BSD-2-Clause-Patent #include > > > > #include #include > > > > > > > > +#include > > > > #include #include > > > > #include > > > > > @@ > > > > -274,10 +276,11 @@ extern EFI_METRONOME_ARCH_PROTOCOL > > > *gMetronome; > > > > extern EFI_TIMER_ARCH_PROTOCOL *gTimer; > > > > extern EFI_SECURITY_ARCH_PROTOCOL *gSecurity; > > > > extern EFI_SECURITY2_ARCH_PROTOCOL *gSecurity2; > > > > +extern EDKII_CPU2_PROTOCOL *gCpu2; > > > > extern EFI_BDS_ARCH_PROTOCOL*gBds; > > > > extern EFI_SMM_BASE2_PROTOCOL *gSmmBase2; > > > > > > > > -extern EFI_TPL
Re: [edk2-devel] [PATCH V2 4/4] MdeModulePkg/DxeMain: Implement common event protocol
Zhichao, Understood now. Thanks for the information. Regards, Jian > -Original Message- > From: Gao, Zhichao > Sent: Thursday, July 11, 2019 8:21 AM > To: Wang, Jian J ; devel@edk2.groups.io > Cc: Sean Brogan ; Wu, Hao A > ; Ni, Ray ; Zeng, Star > ; Gao, Liming ; Michael > Turner ; Bret Barkelew > > Subject: RE: [PATCH V2 4/4] MdeModulePkg/DxeMain: Implement common > event protocol > > > > > -Original Message- > > From: Wang, Jian J > > Sent: Wednesday, July 10, 2019 4:47 PM > > To: Gao, Zhichao ; devel@edk2.groups.io > > Cc: Sean Brogan ; Wu, Hao A > > ; Ni, Ray ; Zeng, Star > > ; Gao, Liming ; Michael > Turner > > ; Bret Barkelew > > > > Subject: RE: [PATCH V2 4/4] MdeModulePkg/DxeMain: Implement > common > > event protocol > > > > Zhichao, > > > > > -Original Message- > > > From: Gao, Zhichao > > > Sent: Wednesday, July 10, 2019 8:24 AM > > > To: Wang, Jian J ; devel@edk2.groups.io > > > Cc: Sean Brogan ; Wu, Hao A > > > ; Ni, Ray ; Zeng, Star > > > ; Gao, Liming ; Michael > > > Turner ; Bret Barkelew > > > > > > Subject: RE: [PATCH V2 4/4] MdeModulePkg/DxeMain: Implement > > common > > > event protocol > > > > > > > > > > > > > -Original Message- > > > > From: Wang, Jian J > > > > Sent: Tuesday, July 9, 2019 5:24 PM > > > > To: Gao, Zhichao ; devel@edk2.groups.io > > > > Cc: Sean Brogan ; Wu, Hao A > > > > ; Ni, Ray ; Zeng, Star > > > > ; Gao, Liming ; Michael > > > Turner > > > > ; Bret Barkelew > > > > > > > > Subject: RE: [PATCH V2 4/4] MdeModulePkg/DxeMain: Implement > > > common > > > > event protocol > > > > > > > > Hi Zhichao, > > > > > > > > One common comment: please update copy right year. > > > > > > I got the copyright remind before. Refer to > > > https://edk2.groups.io/g/devel/topic/31828852#41576. > > > This patch is almost provided from MU project and contributed by > > > Microsoft developers, 'From:...' is the author. And they didn't add > > > their copyright. So I think it is fine to keep the copyright. > > > > > > > I mean the *year* in Intel copyright not the whole copyright. > > https://edk2.groups.io/g/devel/message/41599 > https://edk2.groups.io/g/devel/message/41753 > See above message. Maybe updating the year means you are making a legal > claim to the intellectual > property provided by the patch on behalf of the company. > > Thanks, > Zhichao > > > > > Regards, > > Jian > > > > > > > > > > See another comment at the almost the end of the email. > > > > > > > > > -Original Message- > > > > > From: Gao, Zhichao > > > > > Sent: Tuesday, July 09, 2019 4:40 PM > > > > > To: devel@edk2.groups.io > > > > > Cc: Sean Brogan ; Wang, Jian J > > > > > ; Wu, Hao A ; Ni, Ray > > > > > ; Zeng, Star ; Gao, Liming > > > > > ; Michael Turner > > > > ; > > > > > Bret Barkelew > > > > > Subject: [PATCH V2 4/4] MdeModulePkg/DxeMain: Implement > > common > > > > event > > > > > protocol > > > > > > > > > > From: Sean Brogan > > > > > > > > > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1400 > > > > > > > > > > If an interrupt happens between CheckEvent and gIdleLoopEvent, > > > > > there would be a event pending during cpu sleep. So it is required > > > > > to check the gEventPending with the interrupt disabled. > > > > > > > > > > Implement a protocol gEdkiiCommonEventProtocolGuid to support > all > > > TPL > > > > > event for PI drivers that use HW interrput. It has two interface, > > > > > one is to create event and the other one is to wait for event. > > > > > > > > > > Add 'volatile' specifier for gEfiCurrentTpl and gEventPending > > > > > because they may be changed out of the context (interrupt context). > > > > > > > > > > Cc: Jian J Wang > > > > > Cc: Hao A Wu > > > > > Cc: Ray Ni > > > > > Cc: Star Zeng > > > > > Cc: Liming gao > > > > > Cc: Sean Brogan > > > > > Cc: Michael Turner > > > > > Cc: Bret Barkelew > > > > > Signed-off-by: Zhichao Gao > > > > > --- > > > > > MdeModulePkg/Core/Dxe/DxeMain.h | 64 ++- > > > > > MdeModulePkg/Core/Dxe/DxeMain.inf | 2 + > > > > > MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c | 22 > > > > > .../Core/Dxe/DxeMain/DxeProtocolNotify.c | 1 + > > > > > MdeModulePkg/Core/Dxe/Event/Event.c | 102 > > > - > > > > > - > > > > > MdeModulePkg/Core/Dxe/Event/Event.h | 2 +- > > > > > MdeModulePkg/Include/Protocol/Cpu2.h | 2 +- > > > > > 7 files changed, 181 insertions(+), 14 deletions(-) > > > > > > > > > > diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h > > > > > b/MdeModulePkg/Core/Dxe/DxeMain.h index > > > 6a64852730..38907bfe8d > > > > 100644 > > > > > --- a/MdeModulePkg/Core/Dxe/DxeMain.h > > > > > +++ b/MdeModulePkg/Core/Dxe/DxeMain.h > > > > > @@ -38,6 +38,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > #include #include > > > > > #include > > > > > +#include > > > > > #include > > > > > #include #include > > > > > @@ -47,6 +48,7 @@ SPDX-License-Identifier: > >
Re: [edk2-devel] [PATCH V2 4/4] MdeModulePkg/DxeMain: Implement common event protocol
Hi Zhichao, One common comment: please update copy right year. See another comment at the almost the end of the email. > -Original Message- > From: Gao, Zhichao > Sent: Tuesday, July 09, 2019 4:40 PM > To: devel@edk2.groups.io > Cc: Sean Brogan ; Wang, Jian J > ; Wu, Hao A ; Ni, Ray > ; Zeng, Star ; Gao, Liming > ; Michael Turner ; > Bret Barkelew > Subject: [PATCH V2 4/4] MdeModulePkg/DxeMain: Implement common > event protocol > > From: Sean Brogan > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1400 > > If an interrupt happens between CheckEvent and gIdleLoopEvent, > there would be a event pending during cpu sleep. So it is > required to check the gEventPending with the interrupt disabled. > > Implement a protocol gEdkiiCommonEventProtocolGuid to support > all TPL event for PI drivers that use HW interrput. It has two > interface, one is to create event and the other one is to wait for > event. > > Add 'volatile' specifier for gEfiCurrentTpl and gEventPending > because they may be changed out of the context (interrupt context). > > Cc: Jian J Wang > Cc: Hao A Wu > Cc: Ray Ni > Cc: Star Zeng > Cc: Liming gao > Cc: Sean Brogan > Cc: Michael Turner > Cc: Bret Barkelew > Signed-off-by: Zhichao Gao > --- > MdeModulePkg/Core/Dxe/DxeMain.h | 64 ++- > MdeModulePkg/Core/Dxe/DxeMain.inf | 2 + > MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c | 22 > .../Core/Dxe/DxeMain/DxeProtocolNotify.c | 1 + > MdeModulePkg/Core/Dxe/Event/Event.c | 102 - > - > MdeModulePkg/Core/Dxe/Event/Event.h | 2 +- > MdeModulePkg/Include/Protocol/Cpu2.h | 2 +- > 7 files changed, 181 insertions(+), 14 deletions(-) > > diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h > b/MdeModulePkg/Core/Dxe/DxeMain.h > index 6a64852730..38907bfe8d 100644 > --- a/MdeModulePkg/Core/Dxe/DxeMain.h > +++ b/MdeModulePkg/Core/Dxe/DxeMain.h > @@ -38,6 +38,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > #include > #include > #include > +#include > #include > #include > #include > @@ -47,6 +48,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > #include > #include > #include > +#include > #include > #include > #include > @@ -274,10 +276,11 @@ extern EFI_METRONOME_ARCH_PROTOCOL > *gMetronome; > extern EFI_TIMER_ARCH_PROTOCOL *gTimer; > extern EFI_SECURITY_ARCH_PROTOCOL *gSecurity; > extern EFI_SECURITY2_ARCH_PROTOCOL *gSecurity2; > +extern EDKII_CPU2_PROTOCOL *gCpu2; > extern EFI_BDS_ARCH_PROTOCOL*gBds; > extern EFI_SMM_BASE2_PROTOCOL *gSmmBase2; > > -extern EFI_TPL gEfiCurrentTpl; > +extern volatile EFI_TPL gEfiCurrentTpl; > > extern EFI_GUID *gDxeCoreFileName; > extern EFI_LOADED_IMAGE_PROTOCOL*gDxeCoreLoadedImage; > @@ -1714,6 +1717,65 @@ CoreCheckEvent ( >); > > > +/** > + Stops execution until an event is signaled. > + > + Support all TPL. > + > + @param NumberOfEvents The number of events in the UserEvents > array > + @param UserEvents An array of EFI_EVENT > + @param UserIndex Pointer to the index of the event which > + satisfied the wait condition > + > + @retval EFI_SUCCESSThe event indicated by Index was signaled. > + @retval EFI_INVALID_PARAMETER The event indicated by Index has a > notification > + function or Event was not a valid type > + @retval EFI_UNSUPPORTEDThe current TPL is not TPL_APPLICATION > + > +**/ > +EFI_STATUS > +EFIAPI > +CommonWaitForEvent ( > + IN UINTNNumberOfEvents, > + IN EFI_EVENT*UserEvents, > + OUT UINTN *UserIndex > + ); > + > + > +/** > + Creates an event in a group. > + > + Support all TPL. > + > + @param Type The type of event to create and its mode and > + attributes > + @param NotifyTpl The task priority level of event > notifications > + @param NotifyFunction Pointer to the events notification function > + @param NotifyContext Pointer to the notification functions > context; > + corresponds to parameter "Context" in the > + notification function > + @param EventGroup GUID for EventGroup if NULL act the same > as > + gBS->CreateEvent(). > + @param Event Pointer to the newly created event if the > call > + succeeds; undefined otherwise > + > + @retval EFI_SUCCESSThe event structure was created > + @retval EFI_INVALID_PARAMETER One of the parameters has an invalid > value > + @retval EFI_OUT_OF_RESOURCES The event could not be all
Re: [edk2-devel] [PATCH V2 4/4] MdeModulePkg/DxeMain: Implement common event protocol
> -Original Message- > From: Wang, Jian J > Sent: Tuesday, July 9, 2019 5:24 PM > To: Gao, Zhichao ; devel@edk2.groups.io > Cc: Sean Brogan ; Wu, Hao A > ; Ni, Ray ; Zeng, Star > ; Gao, Liming ; Michael Turner > ; Bret Barkelew > > Subject: RE: [PATCH V2 4/4] MdeModulePkg/DxeMain: Implement common > event protocol > > Hi Zhichao, > > One common comment: please update copy right year. I got the copyright remind before. Refer to https://edk2.groups.io/g/devel/topic/31828852#41576. This patch is almost provided from MU project and contributed by Microsoft developers, 'From:...' is the author. And they didn't add their copyright. So I think it is fine to keep the copyright. > > See another comment at the almost the end of the email. > > > -Original Message- > > From: Gao, Zhichao > > Sent: Tuesday, July 09, 2019 4:40 PM > > To: devel@edk2.groups.io > > Cc: Sean Brogan ; Wang, Jian J > > ; Wu, Hao A ; Ni, Ray > > ; Zeng, Star ; Gao, Liming > > ; Michael Turner > ; > > Bret Barkelew > > Subject: [PATCH V2 4/4] MdeModulePkg/DxeMain: Implement common > event > > protocol > > > > From: Sean Brogan > > > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1400 > > > > If an interrupt happens between CheckEvent and gIdleLoopEvent, there > > would be a event pending during cpu sleep. So it is required to check > > the gEventPending with the interrupt disabled. > > > > Implement a protocol gEdkiiCommonEventProtocolGuid to support all TPL > > event for PI drivers that use HW interrput. It has two interface, one > > is to create event and the other one is to wait for event. > > > > Add 'volatile' specifier for gEfiCurrentTpl and gEventPending because > > they may be changed out of the context (interrupt context). > > > > Cc: Jian J Wang > > Cc: Hao A Wu > > Cc: Ray Ni > > Cc: Star Zeng > > Cc: Liming gao > > Cc: Sean Brogan > > Cc: Michael Turner > > Cc: Bret Barkelew > > Signed-off-by: Zhichao Gao > > --- > > MdeModulePkg/Core/Dxe/DxeMain.h | 64 ++- > > MdeModulePkg/Core/Dxe/DxeMain.inf | 2 + > > MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c | 22 > > .../Core/Dxe/DxeMain/DxeProtocolNotify.c | 1 + > > MdeModulePkg/Core/Dxe/Event/Event.c | 102 - > > - > > MdeModulePkg/Core/Dxe/Event/Event.h | 2 +- > > MdeModulePkg/Include/Protocol/Cpu2.h | 2 +- > > 7 files changed, 181 insertions(+), 14 deletions(-) > > > > diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h > > b/MdeModulePkg/Core/Dxe/DxeMain.h index 6a64852730..38907bfe8d > 100644 > > --- a/MdeModulePkg/Core/Dxe/DxeMain.h > > +++ b/MdeModulePkg/Core/Dxe/DxeMain.h > > @@ -38,6 +38,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > > #include #include #include > > > > +#include > > #include > > #include #include > > @@ -47,6 +48,7 @@ SPDX-License-Identifier: > > BSD-2-Clause-Patent #include #include > > #include > > +#include > > #include #include > > #include > @@ > > -274,10 +276,11 @@ extern EFI_METRONOME_ARCH_PROTOCOL > *gMetronome; > > extern EFI_TIMER_ARCH_PROTOCOL *gTimer; > > extern EFI_SECURITY_ARCH_PROTOCOL *gSecurity; > > extern EFI_SECURITY2_ARCH_PROTOCOL *gSecurity2; > > +extern EDKII_CPU2_PROTOCOL *gCpu2; > > extern EFI_BDS_ARCH_PROTOCOL*gBds; > > extern EFI_SMM_BASE2_PROTOCOL *gSmmBase2; > > > > -extern EFI_TPL gEfiCurrentTpl; > > +extern volatile EFI_TPL gEfiCurrentTpl; > > > > extern EFI_GUID *gDxeCoreFileName; > > extern EFI_LOADED_IMAGE_PROTOCOL*gDxeCoreLoadedImage; > > @@ -1714,6 +1717,65 @@ CoreCheckEvent ( > >); > > > > > > +/** > > + Stops execution until an event is signaled. > > + > > + Support all TPL. > > + > > + @param NumberOfEvents The number of events in the UserEvents > > array > > + @param UserEvents An array of EFI_EVENT > > + @param UserIndex Pointer to the index of the event which > > + satisfied the wait condition > > + > > + @retval EFI_SUCCESSThe event indicated by Index was signaled. > > + @retval EFI_INVALID_PARAMETER The event indicated by Index has a > > notification > > + function or Event was not a valid type > > + @retval EFI_UNSUPPORTEDThe current TPL is not TPL_APPLICATION > > + > > +**/ > > +EFI_STATUS > > +EFIAPI > > +CommonWaitForEvent ( > > + IN UINTNNumberOfEvents, > > + IN EFI_EVENT*UserEvents, > > + OUT UINTN *UserIndex > > + ); > > + > > + > > +/** > > + Creates an event in a group. > > + > > + Support all TPL. > > + > > + @param Type The type of event to create and its mode > > and > > + attributes > > + @param NotifyTpl
Re: [edk2-devel] [PATCH V2 4/4] MdeModulePkg/DxeMain: Implement common event protocol
Zhichao, > -Original Message- > From: Gao, Zhichao > Sent: Wednesday, July 10, 2019 8:24 AM > To: Wang, Jian J ; devel@edk2.groups.io > Cc: Sean Brogan ; Wu, Hao A > ; Ni, Ray ; Zeng, Star > ; Gao, Liming ; Michael > Turner ; Bret Barkelew > > Subject: RE: [PATCH V2 4/4] MdeModulePkg/DxeMain: Implement common > event protocol > > > > > -Original Message- > > From: Wang, Jian J > > Sent: Tuesday, July 9, 2019 5:24 PM > > To: Gao, Zhichao ; devel@edk2.groups.io > > Cc: Sean Brogan ; Wu, Hao A > > ; Ni, Ray ; Zeng, Star > > ; Gao, Liming ; Michael > Turner > > ; Bret Barkelew > > > > Subject: RE: [PATCH V2 4/4] MdeModulePkg/DxeMain: Implement > common > > event protocol > > > > Hi Zhichao, > > > > One common comment: please update copy right year. > > I got the copyright remind before. Refer to > https://edk2.groups.io/g/devel/topic/31828852#41576. > This patch is almost provided from MU project and contributed by > Microsoft developers, 'From:...' is the author. And they didn't add their > copyright. So I think it is fine to keep the copyright. > I mean the *year* in Intel copyright not the whole copyright. Regards, Jian > > > > See another comment at the almost the end of the email. > > > > > -Original Message- > > > From: Gao, Zhichao > > > Sent: Tuesday, July 09, 2019 4:40 PM > > > To: devel@edk2.groups.io > > > Cc: Sean Brogan ; Wang, Jian J > > > ; Wu, Hao A ; Ni, Ray > > > ; Zeng, Star ; Gao, Liming > > > ; Michael Turner > > ; > > > Bret Barkelew > > > Subject: [PATCH V2 4/4] MdeModulePkg/DxeMain: Implement common > > event > > > protocol > > > > > > From: Sean Brogan > > > > > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1400 > > > > > > If an interrupt happens between CheckEvent and gIdleLoopEvent, there > > > would be a event pending during cpu sleep. So it is required to check > > > the gEventPending with the interrupt disabled. > > > > > > Implement a protocol gEdkiiCommonEventProtocolGuid to support all > TPL > > > event for PI drivers that use HW interrput. It has two interface, one > > > is to create event and the other one is to wait for event. > > > > > > Add 'volatile' specifier for gEfiCurrentTpl and gEventPending because > > > they may be changed out of the context (interrupt context). > > > > > > Cc: Jian J Wang > > > Cc: Hao A Wu > > > Cc: Ray Ni > > > Cc: Star Zeng > > > Cc: Liming gao > > > Cc: Sean Brogan > > > Cc: Michael Turner > > > Cc: Bret Barkelew > > > Signed-off-by: Zhichao Gao > > > --- > > > MdeModulePkg/Core/Dxe/DxeMain.h | 64 ++- > > > MdeModulePkg/Core/Dxe/DxeMain.inf | 2 + > > > MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c | 22 > > > .../Core/Dxe/DxeMain/DxeProtocolNotify.c | 1 + > > > MdeModulePkg/Core/Dxe/Event/Event.c | 102 > - > > > - > > > MdeModulePkg/Core/Dxe/Event/Event.h | 2 +- > > > MdeModulePkg/Include/Protocol/Cpu2.h | 2 +- > > > 7 files changed, 181 insertions(+), 14 deletions(-) > > > > > > diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h > > > b/MdeModulePkg/Core/Dxe/DxeMain.h index > 6a64852730..38907bfe8d > > 100644 > > > --- a/MdeModulePkg/Core/Dxe/DxeMain.h > > > +++ b/MdeModulePkg/Core/Dxe/DxeMain.h > > > @@ -38,6 +38,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > > > #include #include #include > > > > > > +#include > > > #include > > > #include #include > > > @@ -47,6 +48,7 @@ SPDX-License-Identifier: > > > BSD-2-Clause-Patent #include #include > > > #include > > > +#include > > > #include #include > > > #include > > > @@ > > > -274,10 +276,11 @@ extern EFI_METRONOME_ARCH_PROTOCOL > > *gMetronome; > > > extern EFI_TIMER_ARCH_PROTOCOL *gTimer; > > > extern EFI_SECURITY_ARCH_PROTOCOL *gSecurity; > > > extern EFI_SECURITY2_ARCH_PROTOCOL *gSecurity2; > > > +extern EDKII_CPU2_PROTOCOL *gCpu2; > > > extern EFI_BDS_ARCH_PROTOCOL*gBds; > > > extern EFI_SMM_BASE2_PROTOCOL *gSmmBase2; > > > > > > -extern EFI_TPL gEfiCurrentTpl; > > > +extern volatile EFI_TPL gEfiCurrentTpl; > > > > > > extern EFI_GUID *gDxeCoreFileName; > > > extern EFI_LOADED_IMAGE_PROTOCOL > *gDxeCoreLoadedImage; > > > @@ -1714,6 +1717,65 @@ CoreCheckEvent ( > > >); > > > > > > > > > +/** > > > + Stops execution until an event is signaled. > > > + > > > + Support all TPL. > > > + > > > + @param NumberOfEvents The number of events in the > UserEvents > > > array > > > + @param UserEvents An array of EFI_EVENT > > > + @param UserIndex Pointer to the index of the event which > > > + satisfied the wait condition > > > + > > > + @retval EFI_SUCCESSThe event indicated by Index was > signaled. > > > + @retval EFI_INVALID_PARAME