RDFU  1.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
EventsScanner.c
Go to the documentation of this file.
1 
11 #include "EfiScannerHeaders.h"
12 
13 
14 //
15 // globals
16 //
17 
18 
19 
21 EFI_EVENT gEventScannerEvent = 0;
23 
24 
30 #define MAX_NEW_NOTIFY_FUNCTIONS 100
33 
34 
35 BOOLEAN IsOnNewEventNotifyFunctionList(C_PTR NotifyFunction)
36 {
37  UINTN i;
38 
39  for (i = 0; i < NumOfNewEventNotifyFunctions; i++)
40  if (NewEventNotifyFunctions[i] == NotifyFunction)
41  return TRUE;
42  return FALSE;
43 }
44 
45 __inline VOID AddNewEventNotifyFunction(C_PTR NotifyFunction)
46 {
48  return;
49 
51 }
52 
53 
54 
68  EFI_EVENT EventT,
69  VOID *Context)
70 {
71  int i;
72  IEVENT *Event;
73  LIST_ENTRY *Head;
74  LIST_ENTRY *Link;
75 
76  CHAR8 EventTypeBuff[EVENT_TYPE_BUFF_SIZE];
77 
78  if (!gEventSignalQueueAddr || !gEventList)
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 
103  gUserEventScannerCallback(gEventList, (event_entry*)Event);
104 
105  }
106  }
107 
108 }
109 
110 
111 
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
142  gEventList = GetAllEvents();
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 }
178 
189 {
190  LogFullAscii(": UnInstalling the event scanner\r\n");
191 
192  if (gEventScannerEvent)
193  gBS->CloseEvent(gEventScannerEvent);
194 
195 
196  if (gEventList)
197  {
198  FreeEvents(gEventList);
199  gEventList = 0;
200  }
201 
202  return EFI_SUCCESS;
203 }