12 #include <mach/clock.h>
13 #include <mach/mach.h>
67 time_t TimeRes = time (NULL);
73 TimeNow = (UINT64)TimeRes;
74 TimeNow = TimeNow*1000000000;
76 #elif defined (__MACH__)
80 host_get_clock_service (mach_host_self (), SYSTEM_CLOCK, &Cclock);
81 clock_get_time (Cclock, &Now);
82 mach_port_deallocate (mach_task_self (), Cclock);
84 TimeNow = (UINT64)Now.tv_sec*1000000000 + Now.tv_nsec;
89 clock_gettime (CLOCK_MONOTONIC, &Now);
90 TimeNow = (UINT64)Now.tv_sec*1000000000 + Now.tv_nsec;
109 if (
mEvents[Index].IsClosed == TRUE) {
133 if (
mEvents[Index].IsClosed == TRUE) {
143 if (((
mEvents[Index].Type & EVT_TIMER) != 0) && (
mEvents[Index].TimerEmit != 0)) {
144 if (TimeNow >=
mEvents[Index].TimerEmit) {
153 if (
mEvents[Index].TimerDelta != 0) {
167 if ((
mEvents[Index].Signaled == TRUE) && ((
mEvents[Index].Type & EVT_NOTIFY_SIGNAL) != 0)) {
250 IN EFI_TPL NotifyTpl,
251 IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL,
252 IN CONST VOID *NotifyContext OPTIONAL,
253 IN CONST EFI_GUID *EventGroup OPTIONAL,
265 return EFI_INVALID_PARAMETER;
268 if (((Type & EVT_NOTIFY_SIGNAL) != 0) && ((Type & EVT_NOTIFY_WAIT) != 0)) {
272 return EFI_INVALID_PARAMETER;
275 if ((Type & (EVT_NOTIFY_SIGNAL | EVT_NOTIFY_WAIT)) != 0) {
279 if (NotifyFunction == NULL) {
283 return EFI_INVALID_PARAMETER;
290 return EFI_INVALID_PARAMETER;
300 return EFI_OUT_OF_RESOURCES;
310 *Event = (EFI_EVENT)Ev;
339 IN EFI_TPL NotifyTpl,
340 IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL,
341 IN VOID *NotifyContext OPTIONAL,
439 if ((Ev->
Type & EVT_NOTIFY_SIGNAL) != 0) {
443 return EFI_INVALID_PARAMETER;
450 Status = EFI_SUCCESS;
460 Status = EFI_NOT_READY;
482 IN UINTN NumberOfEvents,
483 IN EFI_EVENT *Events,
493 if (
mCurTPL != TPL_APPLICATION) {
494 return EFI_UNSUPPORTED;
502 if (NumberOfEvents == 0) {
503 return EFI_INVALID_PARAMETER;
513 for (Jndex = 0; Jndex < NumberOfEvents; Jndex++) {
524 if ((Ev->
Type & EVT_NOTIFY_SIGNAL) != 0) {
526 return EFI_INVALID_PARAMETER;
558 IN EFI_TIMER_DELAY Type,
559 IN UINT64 TriggerTime
572 if ((Ev->
Type & EVT_TIMER) == 0) {
573 return EFI_INVALID_PARAMETER;
584 Ev->
TimerEmit = TimeNow + TriggerTime * 100;
589 Ev->
TimerEmit = TimeNow + TriggerTime * 100;
594 return EFI_INVALID_PARAMETER;
671 if (
mEvents[Index].IsClosed == TRUE) {
676 if (((
mEvents[Index].Type & EVT_TIMER) != 0) && (
mEvents[Index].TimerEmit != 0)) {
677 if (TimeNow >=
mEvents[Index].TimerEmit) {
679 if (
mEvents[Index].TimerDelta != 0) {
687 if ((
mEvents[Index].Signaled == TRUE) && ((
mEvents[Index].Type & EVT_NOTIFY_SIGNAL) != 0)) {
EFI_STATUS EFIAPI UserWaitForEvent(IN UINTN NumberOfEvents, IN EFI_EVENT *Events, OUT UINTN *Index)
STATIC VOID UserEventInitializer(VOID)
STATIC USER_EVENT mEvents[USER_EVENT_MAXNUM]
STATIC VOID UserEventInit(VOID)
BOOLEAN UserEventDispatchNow(VOID)
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)
STATIC UINT64 UserEventGetTimeNow(VOID)
EFI_STATUS EFIAPI UserCheckEvent(IN EFI_EVENT Event)
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 UserSignalEvent(IN EFI_EVENT Event)
EFI_STATUS EFIAPI UserCloseEvent(IN EFI_EVENT Event)
EFI_STATUS EFIAPI UserSetTimer(IN EFI_EVENT Event, IN EFI_TIMER_DELAY Type, IN UINT64 TriggerTime)
STATIC VOID UserEventDispatch(VOID)
VOID EFIAPI UserRestoreTPL(IN EFI_TPL OldTpl)
STATIC USER_EVENT * UserEventAlloc(VOID)
STATIC BOOLEAN mEventNeedInit
EFI_TPL EFIAPI UserRaiseTPL(IN EFI_TPL NewTpl)
#define USER_EVENT_MAXNUM
#define USER_EVENT_MAXTPL
EFI_EVENT_NOTIFY NotifyFn