Andrew,
Perfect, this is what I needed to know! I will use WaitForEvent(). Also,
thank you for taking the time to answer so many questions in this mailing
list. I read them all and learn a lot.
Thomas
On Sun, Apr 20, 2014 at 12:32 PM, Andrew Fish <[email protected]> wrote:
> Thomas,
>
> WaitForEvent() is the efficient way to wait. The DXE Core will notify the
> gIdleLoopEventGuid event, when it knows there is no work to do until the
> next timer tick. The platform (CPU) specific code is responsible for
> providing this event. If the event exists you don’t burn much power when
> when you sit at the shell prompt, or any other place where where you are
> waiting for events.
>
> Definition:
> https://svn.code.sf.net/p/edk2/code/trunk/edk2/MdeModulePkg/Include/Guid/IdleLoopEvent.hso
> search the code for gIdleLoopEventGuid.
>
> If this event is not registered you will just burn power in the for loop
> in WaitForEvent(). Even if the idle event just does a CpuSleep() (X86 halt)
> there is a drastic savings in power when doing a WaitForEvent().
>
>
> https://svn.code.sf.net/p/edk2/code/trunk/edk2/MdeModulePkg/Core/Dxe/Event/Event.c
>
> /**
> Stops execution until an event is signaled.
>
> @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_SUCCESS The 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_UNSUPPORTED The current TPL is not TPL_APPLICATION
>
> **/
> EFI_STATUS
> EFIAPI
> CoreWaitForEvent (
> IN UINTN NumberOfEvents,
> IN EFI_EVENT *UserEvents,
> OUT UINTN *UserIndex
> )
> {
> EFI_STATUS Status;
> UINTN Index;
>
> //
> // Can only WaitForEvent at TPL_APPLICATION
> //
> if (gEfiCurrentTpl != TPL_APPLICATION) {
> return EFI_UNSUPPORTED;
> }
>
> for(;;) {
>
> for(Index = 0; Index < NumberOfEvents; Index++) {
>
> Status = CoreCheckEvent (UserEvents[Index]);
>
> //
> // provide index of event that caused problem
> //
> if (Status != EFI_NOT_READY) {
> *UserIndex = Index;
> return Status;
> }
> }
>
> //
> // Signal the Idle event
> //
> CoreSignalEvent (gIdleLoopEvent);
> }
> }
>
>
> Thanks,
>
> Andrew Fish
>
>
>
> On Apr 19, 2014, at 11:42 PM, Thomas Rognon <[email protected]> wrote:
>
> Here is what I would like to do:
>
> Foo () {
> // do some stuff
> // wait for a signal from a condition in code that's on a periodic timer
> // do some stuff
> }
>
> From what I see in edk2, WaitForEvent is a busy loop around CheckEvent. Is
> there a way to do this so that the execution completely stops until code in
> the periodic timer tells it to resume? Thank you for any help!
>
> Thomas
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/NeoTech_______________________________________________
> edk2-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>
>
>
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/NeoTech
> _______________________________________________
> edk2-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>
>
------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel