Re: [edk2] Interrupt hooking mechanism in EFI

Subject: Re: [edk2] Interrupt hooking mechanism in EFI

From: Sergey Isakov <isakov-sl@bk.ru>

To: edk2-devel@lists.sourceforge.net

Date: 2012-01-24 19:54:55

Hi Suraj and Andrew,
Sorry for disturbing your conversation. I found a good sample in BiosKeyboardDxe sources
---------
  //
  // Setup a periodic timer, used for reading keystrokes at a fixed interval
  //
  Status = gBS->CreateEvent (
                  EVT_TIMER | EVT_NOTIFY_SIGNAL,
                  TPL_NOTIFY,
                  BiosKeyboardTimerHandler,
                  BiosKeyboardPrivate,
                  &BiosKeyboardPrivate->TimerEvent
                  );
  if (EFI_ERROR (Status)) {
    Status      = EFI_OUT_OF_RESOURCES;
    StatusCode  = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;
    goto Done;
  }

  Status = gBS->SetTimer (
                  BiosKeyboardPrivate->TimerEvent,
                  TimerPeriodic,
                  KEYBOARD_TIMER_INTERVAL
                  );
  if (EFI_ERROR (Status)) {
    Status      = EFI_OUT_OF_RESOURCES;
    StatusCode  = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;
    goto Done;
  }

---------
Strange about EVT_TIMER instead of EFI_EVENT_TIMER.

Sergey.


On 24.01.2012, at 9:13, Suraj Joshi wrote:

Hi Andrew,
 
Thanks for your reply!
 
I am trying to implement a polling function in my module. So I used CreateEvent and SetTimer function. In SetTimer, I used TimerPeriodic type.
 
My event handler function is not called. Please help me out whether I missed out something.
 
Following is my code snippet,
 
Status = BS->CreateEvent (EFI_EVENT_TIMER | EFI_EVENT_NOTIFY_SIGNAL,
                                                                                                                                EFI_TPL_CALLBACK,
                                                                                                                                TimerHandler,
                                                                                                                                NULL,
                                                                                                                                &TimerEvent);
Print(L"Status = %r \n",Status);
 
Status = BS->SetTimer (TimerEvent,TimerPeriodic,5000000000);                                // Every 5 sec
Print(L"Status after SetTimer() = %r \n",Status);
 
VOID TimerHandler (IN EFI_EVENT Event,IN VOID *Context)
{
                Print(L"Timer event is fired.\n"); 
}
 
I got Status = Success everytime but my TimerHandler function is not called.
 
Please help me.
 
Regards,
Suraj Joshi
 
 
From: Andrew Fish [mailto:afish@apple.com] 
Sent: Tuesday, January 24, 2012 12:28 AM
To: edk2-devel@lists.sourceforge.net
Subject: Re: [edk2] Interrupt hooking mechanism in EFI
 
The CloseEvent() stops the timer. The event must exist for the TimerHandler() to be called. 
 
So for example if you were an application or a driver that returns an error you must call CostEvent() prior to exiting as the code that contains TimerHandler(), in your specific case, will be freed back to the system and other code code or data may get loaded to that address. This will cause a really nasty crash that is hard to debug.  
 
Andrew Fish
 
 


 
On Jan 23, 2012, at 2:22 AM, Suraj Joshi wrote:


Hi Andrew,
 
I tried out Timer event in following way,
 
Call CreatEvent()              - this function will call my TimerHandler() function which is having one debug messages to be print on screen
Call SetTimer()
Call CloseEvent()
 
 
Thanks,
Suraj Joshi
 
From: Suraj Joshi [mailto:suraj.joshi@zensar.in] 
Sent: Monday, January 23, 2012 11:39 AM
To: 'edk2-devel@lists.sourceforge.net'
Subject: RE: [edk2] Interrupt hooking mechanism in EFI
 
Hi Andrew,
 
Do you have sample code to achieve Timer interrupt in EFI (EDK 1.06)? If yes, then please share the same.
 
Thanks,
Suraj Joshi
 
From: Andrew Fish [mailto:afish@apple.com] 
Sent: Monday, January 16, 2012 11:59 PM
To: edk2-devel@lists.sourceforge.net
Subject: Re: [edk2] Interrupt hooking mechanism in EFI
 
There are no hardware interrupts in EFI. All that exists is a timer. 
 
Basically you use the CreateEvent() boot service to make a timer event, and then you do a SetTime() boot service call to program the period and type of the event. You can pass a Notify function and context pointer that will be passed to your Notify function when you do the CreateEvent(). 
 
Andrew Fish
 
 

 

 
On Jan 16, 2012, at 4:54 AM, Suraj Joshi wrote:

 

Hello experts,
 
How interrupt hooking mechanism is done in EFI? Which protocols are supported for handling interrupts (either hardware or software)?
 
I am using EDK1.05 source code as base version.
 
 
Please guide me.
 
Thanks,
Suraj Joshi
------------------------------------------------------------------------------
RSA(R) Conference 2012
Mar 27 - Feb 2
Save $400 by Jan. 27
Register now!
http://p.sf.net/sfu/rsa-sfdev2dev2_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel
 
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel
 
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel