21#include <Library/BaseLib.h>
22#include <Library/DebugLib.h>
23#include <Library/MemoryAllocationLib.h>
25#include <Library/UefiBootServicesTableLib.h>
30#define APPLE_EVENT_HANDLE_PRIVATE_SIGNATURE \
31 SIGNATURE_32 ('A', 'L', 's', 't')
34#define APPLE_EVENT_HANDLE_PRIVATE_FROM_LIST_ENTRY(Handle) \
37 APPLE_EVENT_HANDLE_PRIVATE, \
39 APPLE_EVENT_HANDLE_PRIVATE_SIGNATURE \
64 IN EFI_EVENT_NOTIFY NotifyFunction,
65 IN VOID *NotifyContext,
66 IN UINT64 TriggerTime,
67 IN BOOLEAN SignalPeriodic,
74 DEBUG ((DEBUG_VERBOSE,
"EventLibCreateTimerEvent\n"));
78 if (NotifyTpl >= TPL_CALLBACK) {
79 Status =
gBS->CreateEvent (
80 ((NotifyFunction != NULL)
81 ? (EVT_TIMER | EVT_NOTIFY_SIGNAL)
89 if (!EFI_ERROR (Status)) {
90 Status =
gBS->SetTimer (
92 (SignalPeriodic ? TimerPeriodic : TimerRelative),
96 if (EFI_ERROR (Status)) {
97 gBS->CloseEvent (Event);
110 IN EFI_EVENT_NOTIFY NotifyFunction,
111 IN VOID *NotifyContext,
112 IN UINT64 TriggerTime,
113 IN BOOLEAN SignalPeriodic
116 DEBUG ((DEBUG_VERBOSE,
"EventLibCreateNotifyTimerEvent\n"));
135 DEBUG ((DEBUG_VERBOSE,
"EventLibCancelEvent\n"));
137 Status =
gBS->SetTimer (Event, TimerCancel, 0);
139 if (!EFI_ERROR (Status)) {
140 gBS->CloseEvent (Event);
150 LIST_ENTRY *EventHandleEntry;
153 DEBUG ((DEBUG_VERBOSE,
"EventSignalEvents\n"));
163 && EventHandle->
Ready
164 && ((EventInformation->EventType & EventHandle->
EventType) != 0)
173 EventHandleEntry = GetNextNode (&
mEventHandles, EventHandleEntry);
183 LIST_ENTRY *EventHandleEntry;
186 DEBUG ((DEBUG_VERBOSE,
"InternalFlagAllEventsReady\n"));
196 EventHandle->
Ready = TRUE;
198 EventHandleEntry = GetNextNode (&
mEventHandles, EventHandleEntry);
209 LIST_ENTRY *EventHandleEntry;
212 DEBUG ((DEBUG_VERBOSE,
"InternalSignalEvents\n"));
223 && (EventHandle->
EventType & Information->EventType)
232 EventHandleEntry = GetNextNode (&
mEventHandles, EventHandleEntry);
243 LIST_ENTRY *EventHandleEntry;
244 LIST_ENTRY *NextEventHandleEntry;
247 DEBUG ((DEBUG_VERBOSE,
"InternalRemoveUnregisteredEvents\n"));
253 NextEventHandleEntry = GetNextNode (&
mEventHandles, EventHandleEntry);
260 if (EventHandle->
Name != NULL) {
261 FreePool ((VOID *)EventHandle->
Name);
264 RemoveEntryList (&EventHandle->
Link);
265 FreePool ((VOID *)EventHandle);
268 EventHandleEntry = NextEventHandleEntry;
282 DEBUG ((DEBUG_VERBOSE,
"InternalCreatePollEvents\n"));
286 if (!EFI_ERROR (Status)) {
289 if (EFI_ERROR (Status)) {
303 DEBUG ((DEBUG_VERBOSE,
"InternalCancelPollEvents\n"));
316 IN VOID *NotifyContext
322 DEBUG ((DEBUG_VERBOSE,
"EventRegisterHandler\n"));
324 Status = EFI_INVALID_PARAMETER;
327 && (NotifyFunction != NULL)
334 Status = EFI_SUCCESS;
339 if (EFI_ERROR (Status)) {
344 EventHandle = AllocatePool (
sizeof (*EventHandle));
346 Status = EFI_OUT_OF_RESOURCES;
348 if (EventHandle != NULL) {
350 EventHandle->
Ready = FALSE;
355 EventHandle->
Name = NULL;
363 Status = EFI_SUCCESS;
379 LIST_ENTRY *EventHandleEntry;
382 DEBUG ((DEBUG_VERBOSE,
"EventUnregisterHandler\n"));
384 Status = EFI_INVALID_PARAMETER;
393 if ( ((UINTN)EventHandle == (UINTN)
Handle)
394 || ((UINTN)
Handle == (UINTN)-1))
399 Status = EFI_SUCCESS;
401 if ((UINTN)
Handle != (UINTN)-1) {
406 EventHandleEntry = GetNextNode (&
mEventHandles, EventHandleEntry);
430 DEBUG ((DEBUG_VERBOSE,
"EventSetCursorPosition\n"));
455 UINTN AllocationSize;
458 DEBUG ((DEBUG_VERBOSE,
"EventSetEventName\n"));
460 Status = EFI_INVALID_PARAMETER;
462 if ((
Handle != NULL) && (Name != NULL)) {
463 AllocationSize = AsciiStrSize (Name);
464 EventName = AllocateZeroPool (AllocationSize);
468 Status = EFI_OUT_OF_RESOURCES;
470 if (EventName != NULL) {
471 AsciiStrCpyS (EventName, AllocationSize, Name);
472 Status = EFI_SUCCESS;
493 IN OUT BOOLEAN *CLockOn
496 DEBUG ((DEBUG_VERBOSE,
"EventIsCapsLockOn\n"));
508 DEBUG ((DEBUG_VERBOSE,
"InternalUnregisterHandlers\n"));
538 DEBUG ((DEBUG_VERBOSE,
"AppleEventUnload\n"));
546 Status =
gBS->UninstallMultipleProtocolInterfaces (
558 IN BOOLEAN Reinstall,
559 IN BOOLEAN CustomDelays,
560 IN UINT16 KeyInitialDelay,
561 IN UINT16 KeySubsequentDelay,
562 IN BOOLEAN GraphicsInputMirroring,
563 IN UINT32 PointerPollMin,
564 IN UINT32 PointerPollMax,
565 IN UINT32 PointerPollMask,
566 IN UINT16 PointerSpeedDiv,
567 IN UINT16 PointerSpeedMul,
568 IN UINT16 PointerDwellClickTimeout,
569 IN UINT16 PointerDwellDoubleClickTimeout,
570 IN UINT16 PointerDwellRadius
576 DEBUG ((DEBUG_VERBOSE,
"OcAppleEventInstallProtocol\n"));
579 Status =
gBS->LocateProtocol (
585 if (!EFI_ERROR (Status)) {
589 "OCAE: Not using OEM revision %u, does not meet required minimum %u\n",
590 (UINT32)AppleEvent->Revision,
597 "OCAE: Using OEM revision %u, meets required minimum %u\n",
598 (UINT32)AppleEvent->Revision,
607 DEBUG ((DEBUG_INFO,
"OCAE: Letting OEM protocol connect later\n"));
612 if (EFI_ERROR (Status)) {
613 DEBUG ((DEBUG_ERROR,
"OCAE: OEM uninstall failed - %r\n", Status));
621 GraphicsInputMirroring
628 PointerDwellClickTimeout,
629 PointerDwellDoubleClickTimeout,
633 Status =
gBS->InstallMultipleProtocolInterfaces (
640 if (!EFI_ERROR (Status)) {
646 if (EFI_ERROR (Status)) {
647 DEBUG ((DEBUG_ERROR,
"OCAE: Builtin install failed\n"));
652 DEBUG ((DEBUG_INFO,
"OCAE: Builtin installed\n"));
#define APPLE_EVENT_TYPE_NONE
VOID * APPLE_EVENT_HANDLE
VOID(EFIAPI * APPLE_EVENT_NOTIFY_FUNCTION)(IN APPLE_EVENT_INFORMATION *Information, IN VOID *NotifyContext)
EFI_GUID gAppleEventProtocolGuid
#define APPLE_EVENT_PROTOCOL_REVISION_MINIMUM
#define APPLE_EVENT_PROTOCOL_REVISION
VOID InternalSetDwellClicking(IN UINT16 ClickTimeout, IN UINT16 DoubleClickTimeout, IN UINT16 Radius)
EFI_STATUS EFIAPI EventIsCapsLockOnImpl(IN OUT BOOLEAN *CLockOn)
VOID InternalSetKeyBehaviour(IN BOOLEAN CustomDelays, IN UINT16 KeyInitialDelay, IN UINT16 KeySubsequentDelay, IN BOOLEAN GraphicsInputMirroring)
EFI_STATUS EventSetCursorPositionImpl(IN DIMENSION *Position)
VOID InternalSetPointerSpeed(IN UINT16 PointerSpeedDiv, IN UINT16 PointerSpeedMul)
VOID EventCancelSimplePointerPollEvent(VOID)
EFI_STATUS EventCreateSimplePointerPollEvent(VOID)
VOID InternalInitializePointerUiScale(VOID)
VOID InternalSetPointerPolling(IN UINT32 PointerPollMin, IN UINT32 PointerPollMax, IN UINT32 PointerPollMask)
VOID EventCloseSimplePointerInstallNotifyEvent(VOID)
VOID EventSimplePointerDesctructor(VOID)
EFI_STATUS EventCreateSimplePointerInstallNotifyEvent(VOID)
VOID EventCancelKeyStrokePollEvent(VOID)
EFI_STATUS EventCreateKeyStrokePollEvent(VOID)
VOID InternalCreateQueueEvent(VOID)
VOID InternalSignalAndCloseQueueEvent(VOID)
EFI_EVENT EventLibCreateTimerEvent(IN EFI_EVENT_NOTIFY NotifyFunction, IN VOID *NotifyContext, IN UINT64 TriggerTime, IN BOOLEAN SignalPeriodic, IN EFI_TPL NotifyTpl)
VOID EventSignalEvents(IN APPLE_EVENT_INFORMATION *EventInformation)
EFI_EVENT EventLibCreateNotifyTimerEvent(IN EFI_EVENT_NOTIFY NotifyFunction, IN VOID *NotifyContext, IN UINT64 TriggerTime, IN BOOLEAN SignalPeriodic)
#define APPLE_EVENT_HANDLE_PRIVATE_FROM_LIST_ENTRY(Handle)
EFI_STATUS EFIAPI EventRegisterHandler(IN APPLE_EVENT_TYPE Type, IN APPLE_EVENT_NOTIFY_FUNCTION NotifyFunction, OUT APPLE_EVENT_HANDLE *Handle, IN VOID *NotifyContext)
STATIC APPLE_EVENT_PROTOCOL mAppleEventProtocol
APPLE_EVENT_PROTOCOL * OcAppleEventInstallProtocol(IN BOOLEAN Install, IN BOOLEAN Reinstall, IN BOOLEAN CustomDelays, IN UINT16 KeyInitialDelay, IN UINT16 KeySubsequentDelay, IN BOOLEAN GraphicsInputMirroring, IN UINT32 PointerPollMin, IN UINT32 PointerPollMax, IN UINT32 PointerPollMask, IN UINT16 PointerSpeedDiv, IN UINT16 PointerSpeedMul, IN UINT16 PointerDwellClickTimeout, IN UINT16 PointerDwellDoubleClickTimeout, IN UINT16 PointerDwellRadius)
EFI_STATUS EFIAPI AppleEventUnload(VOID)
VOID InternalFlagAllEventsReady(VOID)
#define APPLE_EVENT_HANDLE_PRIVATE_SIGNATURE
VOID InternalSignalEvents(IN APPLE_EVENT_INFORMATION *Information)
VOID EventLibCancelEvent(IN EFI_EVENT Event)
EFI_STATUS EFIAPI EventUnregisterHandler(IN APPLE_EVENT_HANDLE Handle)
STATIC EFI_STATUS InternalCreatePollEvents(VOID)
EFI_STATUS EFIAPI EventIsCapsLockOn(IN OUT BOOLEAN *CLockOn)
EFI_STATUS EFIAPI EventSetCursorPosition(IN DIMENSION *Position)
VOID InternalCancelPollEvents(VOID)
EFI_STATUS EFIAPI EventSetEventName(IN OUT APPLE_EVENT_HANDLE Handle, IN CHAR8 *Name)
STATIC LIST_ENTRY mEventHandles
VOID InternalRemoveUnregisteredEvents(VOID)
STATIC VOID InternalUnregisterHandlers(VOID)
STATIC UINTN mNumberOfEventHandles
EFI_STATUS OcUninstallAllProtocolInstances(EFI_GUID *Protocol)
APPLE_EVENT_HANDLE Handle
APPLE_EVENT_TYPE EventType
APPLE_EVENT_NOTIFY_FUNCTION NotifyFunction