RDFU  1.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
EventsScanner.c File Reference

Support for the EVENT scanner which runs periodically. More...

Include dependency graph for EventsScanner.c:

Go to the source code of this file.

Macros

#define MAX_NEW_NOTIFY_FUNCTIONS   100
 

Functions

BOOLEAN IsOnNewEventNotifyFunctionList (C_PTR NotifyFunction)
 
__inline VOID AddNewEventNotifyFunction (C_PTR NotifyFunction)
 
VOID EFIAPI NotifyEventScannerTimer (EFI_EVENT EventT, VOID *Context)
 
EFI_STATUS InstallEventScanner (CALLBACK_EVENTSCANNER UserCallback)
 
EFI_STATUS UnInstallEventScanner (VOID)
 

Variables

event_entry_list * gEventList = 0
 
EFI_EVENT gEventScannerEvent = 0
 
CALLBACK_EVENTSCANNER gUserEventScannerCallback = 0
 
C_PTR NewEventNotifyFunctions [MAX_NEW_NOTIFY_FUNCTIONS] = {0}
 
UINTN NumOfNewEventNotifyFunctions = 0
 

Detailed Description

Support for the EVENT scanner which runs periodically.

Author
Piotr Bania
Date
Feb 2013 Support for the EVENT scanner which runs periodically

Definition in file EventsScanner.c.

Macro Definition Documentation

#define MAX_NEW_NOTIFY_FUNCTIONS   100

following table will hold all "new notify functions" detected by the scanner (performance optimization)

Definition at line 30 of file EventsScanner.c.

Referenced by AddNewEventNotifyFunction().

Function Documentation

__inline VOID AddNewEventNotifyFunction ( C_PTR  NotifyFunction)

Definition at line 45 of file EventsScanner.c.

References MAX_NEW_NOTIFY_FUNCTIONS, NewEventNotifyFunctions, and NumOfNewEventNotifyFunctions.

Referenced by NotifyEventScannerTimer().

46 {
48  return;
49 
51 }

Here is the caller graph for this function:

EFI_STATUS InstallEventScanner ( CALLBACK_EVENTSCANNER  UserCallback)

Function installs EFI timer which checks the events for changes

Parameters
UserCallbackOptional address to user function which will be executed when new event will be found.
Return values
EFI_SUCCESSOn success
EFI_ERROR*On error

Definition at line 125 of file EventsScanner.c.

References EFI_STATUS(), EFI_TPL_NOTIFY, GetAllEvents(), gEventScannerEvent, gUserEventScannerCallback, LogFullAscii(), MemZero(), NewEventNotifyFunctions, NotifyEventScannerTimer(), NumOfNewEventNotifyFunctions, and SAMPLE_INTERVAL.

Referenced by DrawBoxAndMenu(), and TestDumpHandles().

126 {
127  EFI_STATUS Status;
128 
129  LogFullAscii(": Installing the event scanner\r\n");
130 
131 
134 
135 
136  if (UserCallback)
137  gUserEventScannerCallback = UserCallback;
138 
139 
140 
141  // firstly get the current event list
143  if (!gEventList)
144  {
145  LogFullAscii("%a: Error unable to get event list!\r\n", __FUNCTION__);
146  return EFI_NOT_FOUND;
147  }
148 
149 
150 
151  Status = gBS->CreateEvent(EVT_NOTIFY_SIGNAL | EVT_TIMER,
154  NULL,
156  if (EFI_ERROR(Status))
157  {
158  LogFullAscii("%a: Unable to install the event scanner, status = %08x\r\n",
159  __FUNCTION__, Status);
160 
161  return Status;
162  }
163 
164  Status = gBS->SetTimer(gEventScannerEvent, TimerPeriodic, SAMPLE_INTERVAL);
165 
166  if (EFI_ERROR(Status))
167  {
168  gBS->CloseEvent(gEventScannerEvent);
169 
170  LogFullAscii("%a: Unable to install the timer for event scanner, status = %08x\r\n",
171  __FUNCTION__, Status);
172 
173  return Status;
174  }
175 
176  return EFI_SUCCESS;
177 }

Here is the call graph for this function:

Here is the caller graph for this function:

BOOLEAN IsOnNewEventNotifyFunctionList ( C_PTR  NotifyFunction)

Definition at line 35 of file EventsScanner.c.

References NewEventNotifyFunctions, and NumOfNewEventNotifyFunctions.

Referenced by NotifyEventScannerTimer().

36 {
37  UINTN i;
38 
39  for (i = 0; i < NumOfNewEventNotifyFunctions; i++)
40  if (NewEventNotifyFunctions[i] == NotifyFunction)
41  return TRUE;
42  return FALSE;
43 }

Here is the caller graph for this function:

VOID EFIAPI NotifyEventScannerTimer ( EFI_EVENT  EventT,
VOID *  Context 
)

Scanning routine (runs periodically). Function checks for new events (events that are not found in the previously gathered event list). If such routine is found it is logged to the log file. Additionally if user callback was specified it is executed as well.

Return values
NONE

Definition at line 67 of file EventsScanner.c.

References AddNewEventNotifyFunction(), EVENT_SIGNATURE, EVENT_TYPE_BUFF_SIZE, FindEventByAddr(), GetEventTypeStringAscii(), gEventSignalQueueAddr, gUserEventScannerCallback, IsOnNewEventNotifyFunctionList(), LogFileAscii(), IEVENT::NotifyFunction, NumOfNewEventNotifyFunctions, and IEVENT::Type.

Referenced by InstallEventScanner().

70 {
71  int i;
72  IEVENT *Event;
73  LIST_ENTRY *Head;
74  LIST_ENTRY *Link;
75 
76  CHAR8 EventTypeBuff[EVENT_TYPE_BUFF_SIZE];
77 
79  return;
80 
81 
82  Head = (LIST_ENTRY*)gEventSignalQueueAddr;
83  for (i = 0, Link = Head->ForwardLink; Link != Head; Link = Link->ForwardLink, i++)
84  {
85  Event = CR(Link, IEVENT, SignalLink, EVENT_SIGNATURE);
86 
87  if ((!FindEventByAddr(gEventList, (C_PTR)Event->NotifyFunction)) &&
89  {
90  // change detected, log the change
91  // also add this entry to the list and not log it again
93 
94  GetEventTypeStringAscii(EventTypeBuff, sizeof(EventTypeBuff), Event->Type);
95 
96  LogFileAscii("[%08d] NEW ENTRY: EventFunc = %016lx Type: %08x - %a\r\n",
98  (MAX_PTR)Event->NotifyFunction,
99  Event->Type,
100  EventTypeBuff);
101 
104 
105  }
106  }
107 
108 }

Here is the call graph for this function:

Here is the caller graph for this function:

EFI_STATUS UnInstallEventScanner ( VOID  )

Function uninstalls EFI timer which checks the events for changes

Return values
EFI_SUCCESSOn success
EFI_ERROR*On error

Definition at line 188 of file EventsScanner.c.

References FreeEvents(), gEventScannerEvent, and LogFullAscii().

189 {
190  LogFullAscii(": UnInstalling the event scanner\r\n");
191 
192  if (gEventScannerEvent)
193  gBS->CloseEvent(gEventScannerEvent);
194 
195 
196  if (gEventList)
197  {
199  gEventList = 0;
200  }
201 
202  return EFI_SUCCESS;
203 }

Here is the call graph for this function:

Variable Documentation

event_entry_list* gEventList = 0

Definition at line 20 of file EventsScanner.c.

EFI_EVENT gEventScannerEvent = 0

Definition at line 21 of file EventsScanner.c.

Referenced by InstallEventScanner(), and UnInstallEventScanner().

CALLBACK_EVENTSCANNER gUserEventScannerCallback = 0

Definition at line 22 of file EventsScanner.c.

Referenced by InstallEventScanner(), and NotifyEventScannerTimer().

C_PTR NewEventNotifyFunctions[MAX_NEW_NOTIFY_FUNCTIONS] = {0}
UINTN NumOfNewEventNotifyFunctions = 0