OpenCore  1.0.6
OpenCore Bootloader
Loading...
Searching...
No Matches
UserEvent.c File Reference
#include <UserEvent.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>

Go to the source code of this file.

Data Structures

struct  USER_EVENT
 

Functions

STATIC UINT64 UserEventGetTimeNow (VOID)
 
STATIC USER_EVENTUserEventAlloc (VOID)
 
STATIC VOID UserEventDispatch (VOID)
 
STATIC VOID UserEventInitializer (VOID)
 
STATIC VOID UserEventInit (VOID)
 
EFI_STATUS EFIAPI UserCreateEventEx (IN UINT32 Type, IN EFI_TPL NotifyTpl, IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL, IN CONST VOID *NotifyContext OPTIONAL, IN CONST EFI_GUID *EventGroup OPTIONAL, OUT EFI_EVENT *Event)
 
EFI_STATUS EFIAPI UserCreateEvent (IN UINT32 Type, IN EFI_TPL NotifyTpl, IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL, IN VOID *NotifyContext OPTIONAL, OUT EFI_EVENT *Event)
 
EFI_STATUS EFIAPI UserCloseEvent (IN EFI_EVENT Event)
 
EFI_STATUS EFIAPI UserSignalEvent (IN EFI_EVENT Event)
 
EFI_STATUS EFIAPI UserCheckEvent (IN EFI_EVENT Event)
 
EFI_STATUS EFIAPI UserWaitForEvent (IN UINTN NumberOfEvents, IN EFI_EVENT *Events, OUT UINTN *Index)
 
EFI_STATUS EFIAPI UserSetTimer (IN EFI_EVENT Event, IN EFI_TIMER_DELAY Type, IN UINT64 TriggerTime)
 
EFI_TPL EFIAPI UserRaiseTPL (IN EFI_TPL NewTpl)
 
VOID EFIAPI UserRestoreTPL (IN EFI_TPL OldTpl)
 
BOOLEAN UserEventDispatchNow (VOID)
 

Variables

STATIC BOOLEAN mEventNeedInit = TRUE
 
STATIC EFI_TPL mCurTPL = 0
 
STATIC USER_EVENT mEvents [USER_EVENT_MAXNUM]
 

Detailed Description

Copyright (c) 2025, Pavel Naberezhnev. All rights reserved. SPDX-License-Identifier: BSD-3-Clause

Definition in file UserEvent.c.

Function Documentation

◆ UserCheckEvent()

EFI_STATUS EFIAPI UserCheckEvent ( IN EFI_EVENT Event)

Checks whether an event is in the signaled state.

Parameters
[in]EventThe event to check.
Return values
EFI_SUCCESSThe event is in the signaled state.
EFI_NOT_READYThe event is not in the signaled state.
EFI_INVALID_PARAMETEREvent is of type EVT_NOTIFY_SIGNAL.

Definition at line 425 of file UserEvent.c.

◆ UserCloseEvent()

EFI_STATUS EFIAPI UserCloseEvent ( IN EFI_EVENT Event)

Closes an event.

Parameters
[in]EventThe event to close.
Return values
EFI_SUCCESSThe event has been closed.

Definition at line 364 of file UserEvent.c.

◆ UserCreateEvent()

EFI_STATUS EFIAPI UserCreateEvent ( IN UINT32 Type,
IN EFI_TPL NotifyTpl,
IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL,
IN VOID *NotifyContext OPTIONAL,
OUT EFI_EVENT * Event )

Creates an event.

Parameters
[in]TypeThe type of event to create and its mode and attributes.
[in]NotifyTplThe task priority level of event notifications, if needed.
[in]NotifyFunctionPointer to the event's notification function, if any.
[in]NotifyContextPointer to the notification function's context; corresponds to parameter Context in the notification function.
[out]EventPointer to the newly created event if the call succeeds.
Return values
EFI_SUCCESSThe event structure was created.
EFI_INVALID_PARAMETEROne of the parameters has an invalid value.
EFI_INVALID_PARAMETEREvent is NULL.
EFI_INVALID_PARAMETERType has an unsupported bit set.
EFI_INVALID_PARAMETERType has both EVT_NOTIFY_SINGAL and EVT_NOTIFY_WAIT set.
EFI_INVALID_PARAMETERType has either EVT_NOTIFY_SIGNAL or EVT_NOTIFY_WAIT set and NotifyFunction is NULL.
EFI_INVALID_PARAMETERType has either EVT_NOTIFY_SIGNAL or EVT_NOTIFY_WAIT set and NotifyTpl is not a supported TPL level.
EFI_OUT_OF_RESOURCESThe event could not be allocated.

Definition at line 337 of file UserEvent.c.

◆ UserCreateEventEx()

EFI_STATUS EFIAPI UserCreateEventEx ( IN UINT32 Type,
IN EFI_TPL NotifyTpl,
IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL,
IN CONST VOID *NotifyContext OPTIONAL,
IN CONST EFI_GUID *EventGroup OPTIONAL,
OUT EFI_EVENT * Event )

Creates an event in a group.

Parameters
[in]TypeThe type of event to create and its mode and attributes.
[in]NotifyTplThe task priority level of event notifiactions, if needed.
[in]NotifyFunctionPointer to the event's notification function, if any.
[in]NotifyContextPointer to the notification function's context; corresponds to to parameter Context in the notificatuin function.
[in]EventGroupPointer to the unique identifier of the group to which this event belongs. Maybe NULL.
[out]EventPointer to the newly created event if the call succeeds.
Return values
EFI_SUCCESSThe event structure was created.
EFI_INVALID_PARAMETEROne of the parameters has an invalid value.
EFI_INVALID_PARAMETEREvent is NULL.
EFI_INVALID_PARAMETERType has an unsupported bit set.
EFI_INVALID_PARAMETERType has both EVT_NOTIFY_SIGNAL and EVT_NOTIFY_WAIT set.
EFI_INVALID_PARAMETERType has either EVT_NOTIFY_SIGNAL or EVT_NOTIFY_WAIT set and NotifyFunction is NULL.
EFI_INVALID_PARAMETERType has either EVT_NOTIFY_SIGNAL or EVT_NOTIFY_WAIT set and NotifyTpl is not a supported TPL level.
EFI_OUT_OF_RESOURCESThe event could not be allocated.

Definition at line 248 of file UserEvent.c.

◆ UserEventAlloc()

STATIC USER_EVENT * UserEventAlloc ( VOID )

Allocates an Event descriptor

Definition at line 102 of file UserEvent.c.

◆ UserEventDispatch()

STATIC VOID UserEventDispatch ( VOID )

Dispatches signaled events and triggers active timers

Definition at line 123 of file UserEvent.c.

◆ UserEventDispatchNow()

BOOLEAN UserEventDispatchNow ( VOID )

Immediately triggers event dispatch.

Returns
True if at least one event is detected in the signaled state, else false.

Definition at line 657 of file UserEvent.c.

◆ UserEventGetTimeNow()

STATIC UINT64 UserEventGetTimeNow ( VOID )

Returns current time in nanoseconds

Definition at line 57 of file UserEvent.c.

◆ UserEventInit()

STATIC VOID UserEventInit ( VOID )

Calls UserEventInitializer() if needed

Definition at line 213 of file UserEvent.c.

◆ UserEventInitializer()

STATIC VOID UserEventInitializer ( VOID )

Inits the Event subsystem

Definition at line 190 of file UserEvent.c.

◆ UserRaiseTPL()

EFI_TPL EFIAPI UserRaiseTPL ( IN EFI_TPL NewTpl)

Raises a task's priority level and returns its previous level.

Parameters
[in]NewTplThe new task priority level. It must be greather than or equal to the current TPL.
Returns
The previous TPL value.

Definition at line 611 of file UserEvent.c.

◆ UserRestoreTPL()

VOID EFIAPI UserRestoreTPL ( IN EFI_TPL OldTpl)

Restores a task's priority level to its previous value.

Parameters
[in]OldTplThe previous task priority level to restore.

Definition at line 636 of file UserEvent.c.

◆ UserSetTimer()

EFI_STATUS EFIAPI UserSetTimer ( IN EFI_EVENT Event,
IN EFI_TIMER_DELAY Type,
IN UINT64 TriggerTime )

Sets the type of timer and the trigger time for a timer event.

Parameters
[in]EventThe timer event that is to be signaled at the specified time.
[in]TypeThe type of time is specified in TriggerTime.
[in]TriggerTimeThe number if 100ns units untill the timer expires.
Return values
EFI_SUCCESSThe event has been set to be signaled at the requested time.
EFI_INVALID_PARAMETEREvent or Type is not valid.

Definition at line 556 of file UserEvent.c.

◆ UserSignalEvent()

EFI_STATUS EFIAPI UserSignalEvent ( IN EFI_EVENT Event)

Signals an event.

Parameters
[in]EventThe event to signal.
Return values
EFI_SUCCESSThe event was signaled.

Definition at line 392 of file UserEvent.c.

◆ UserWaitForEvent()

EFI_STATUS EFIAPI UserWaitForEvent ( IN UINTN NumberOfEvents,
IN EFI_EVENT * Events,
OUT UINTN * Index )

Stops execution untill an event is signaled.

Parameters
[in]NumberOfEventsThe number of events in the Events array.
[in]EventsAn array of EFI_EVENT.
[out]IndexPointer to the index of the event which satisfied the wait condition.
Return values
EFI_SUCCESSThe event indicated by Index was signaled.
EFI_INVALID_PARAMETERNumberOfEvents is 0.
EFI_INVALID_PARAMETERThe event indicated by Index is of type EVT_NOTIFY_SIGNAL.
EFI_UNSUPPORTEDThe current TPL is not TPL_APPLICATION.

Definition at line 481 of file UserEvent.c.

Variable Documentation

◆ mCurTPL

STATIC EFI_TPL mCurTPL = 0

Definition at line 49 of file UserEvent.c.

◆ mEventNeedInit

STATIC BOOLEAN mEventNeedInit = TRUE

Local variables

mEventNeedInit Do we need to initialize the event subsystem? mCurTPL The current TPL value mEvents The static array of Event descriptor

Definition at line 48 of file UserEvent.c.

◆ mEvents

STATIC USER_EVENT mEvents[USER_EVENT_MAXNUM]

Definition at line 50 of file UserEvent.c.