efi_loader: use type bool for event states

Queued and signaled describe boolean states of events.
So let's use type bool and rename the structure members to is_queued
and is_signaled.

Update the comments for is_queued and is_signaled.

Reported-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Rob Clark <robdclark@gmail.com>
Reviewed-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
master
Heinrich Schuchardt 8 years ago committed by Alexander Graf
parent 037ee6f91b
commit e190e8972f
  1. 8
      include/efi_loader.h
  2. 32
      lib/efi_loader/efi_boottime.c
  3. 2
      lib/efi_loader/efi_console.c

@ -136,8 +136,8 @@ struct efi_object {
* @nofify_function: Function to call when the event is triggered * @nofify_function: Function to call when the event is triggered
* @notify_context: Data to be passed to the notify function * @notify_context: Data to be passed to the notify function
* @trigger_type: Type of timer, see efi_set_timer * @trigger_type: Type of timer, see efi_set_timer
* @queued: The notification functionis queued * @queued: The notification function is queued
* @signaled: The event occured * @signaled: The event occurred. The event is in the signaled state.
*/ */
struct efi_event { struct efi_event {
uint32_t type; uint32_t type;
@ -147,8 +147,8 @@ struct efi_event {
u64 trigger_next; u64 trigger_next;
u64 trigger_time; u64 trigger_time;
enum efi_timer_delay trigger_type; enum efi_timer_delay trigger_type;
int queued; bool is_queued;
int signaled; bool is_signaled;
}; };

@ -164,14 +164,14 @@ static u64 efi_div10(u64 a)
void efi_signal_event(struct efi_event *event) void efi_signal_event(struct efi_event *event)
{ {
if (event->notify_function) { if (event->notify_function) {
event->queued = 1; event->is_queued = true;
/* Check TPL */ /* Check TPL */
if (efi_tpl >= event->notify_tpl) if (efi_tpl >= event->notify_tpl)
return; return;
EFI_CALL_VOID(event->notify_function(event, EFI_CALL_VOID(event->notify_function(event,
event->notify_context)); event->notify_context));
} }
event->queued = 0; event->is_queued = false;
} }
static efi_status_t efi_unsupported(const char *funcname) static efi_status_t efi_unsupported(const char *funcname)
@ -316,8 +316,8 @@ efi_status_t efi_create_event(uint32_t type, UINTN notify_tpl,
efi_events[i].notify_context = notify_context; efi_events[i].notify_context = notify_context;
/* Disable timers on bootup */ /* Disable timers on bootup */
efi_events[i].trigger_next = -1ULL; efi_events[i].trigger_next = -1ULL;
efi_events[i].queued = 0; efi_events[i].is_queued = false;
efi_events[i].signaled = 0; efi_events[i].is_signaled = false;
*event = &efi_events[i]; *event = &efi_events[i];
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -350,7 +350,7 @@ void efi_timer_check(void)
for (i = 0; i < ARRAY_SIZE(efi_events); ++i) { for (i = 0; i < ARRAY_SIZE(efi_events); ++i) {
if (!efi_events[i].type) if (!efi_events[i].type)
continue; continue;
if (efi_events[i].queued) if (efi_events[i].is_queued)
efi_signal_event(&efi_events[i]); efi_signal_event(&efi_events[i]);
if (!(efi_events[i].type & EVT_TIMER) || if (!(efi_events[i].type & EVT_TIMER) ||
now < efi_events[i].trigger_next) now < efi_events[i].trigger_next)
@ -366,7 +366,7 @@ void efi_timer_check(void)
default: default:
continue; continue;
} }
efi_events[i].signaled = 1; efi_events[i].is_signaled = true;
efi_signal_event(&efi_events[i]); efi_signal_event(&efi_events[i]);
} }
WATCHDOG_RESET(); WATCHDOG_RESET();
@ -403,7 +403,7 @@ efi_status_t efi_set_timer(struct efi_event *event, enum efi_timer_delay type,
} }
event->trigger_type = type; event->trigger_type = type;
event->trigger_time = trigger_time; event->trigger_time = trigger_time;
event->signaled = 0; event->is_signaled = false;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
@ -440,14 +440,14 @@ static efi_status_t EFIAPI efi_wait_for_event(unsigned long num_events,
known_event: known_event:
if (!event[i]->type || event[i]->type & EVT_NOTIFY_SIGNAL) if (!event[i]->type || event[i]->type & EVT_NOTIFY_SIGNAL)
return EFI_EXIT(EFI_INVALID_PARAMETER); return EFI_EXIT(EFI_INVALID_PARAMETER);
if (!event[i]->signaled) if (!event[i]->is_signaled)
efi_signal_event(event[i]); efi_signal_event(event[i]);
} }
/* Wait for signal */ /* Wait for signal */
for (;;) { for (;;) {
for (i = 0; i < num_events; ++i) { for (i = 0; i < num_events; ++i) {
if (event[i]->signaled) if (event[i]->is_signaled)
goto out; goto out;
} }
/* Allow events to occur. */ /* Allow events to occur. */
@ -459,7 +459,7 @@ out:
* Reset the signal which is passed to the caller to allow periodic * Reset the signal which is passed to the caller to allow periodic
* events to occur. * events to occur.
*/ */
event[i]->signaled = 0; event[i]->is_signaled = false;
if (index) if (index)
*index = i; *index = i;
@ -474,9 +474,9 @@ static efi_status_t EFIAPI efi_signal_event_ext(struct efi_event *event)
for (i = 0; i < ARRAY_SIZE(efi_events); ++i) { for (i = 0; i < ARRAY_SIZE(efi_events); ++i) {
if (event != &efi_events[i]) if (event != &efi_events[i])
continue; continue;
if (event->signaled) if (event->is_signaled)
break; break;
event->signaled = 1; event->is_signaled = true;
if (event->type & EVT_NOTIFY_SIGNAL) if (event->type & EVT_NOTIFY_SIGNAL)
efi_signal_event(event); efi_signal_event(event);
break; break;
@ -493,8 +493,8 @@ static efi_status_t EFIAPI efi_close_event(struct efi_event *event)
if (event == &efi_events[i]) { if (event == &efi_events[i]) {
event->type = 0; event->type = 0;
event->trigger_next = -1ULL; event->trigger_next = -1ULL;
event->queued = 0; event->is_queued = false;
event->signaled = 0; event->is_signaled = false;
return EFI_EXIT(EFI_SUCCESS); return EFI_EXIT(EFI_SUCCESS);
} }
} }
@ -512,9 +512,9 @@ static efi_status_t EFIAPI efi_check_event(struct efi_event *event)
continue; continue;
if (!event->type || event->type & EVT_NOTIFY_SIGNAL) if (!event->type || event->type & EVT_NOTIFY_SIGNAL)
break; break;
if (!event->signaled) if (!event->is_signaled)
efi_signal_event(event); efi_signal_event(event);
if (event->signaled) if (event->is_signaled)
return EFI_EXIT(EFI_SUCCESS); return EFI_EXIT(EFI_SUCCESS);
return EFI_EXIT(EFI_NOT_READY); return EFI_EXIT(EFI_NOT_READY);
} }

@ -460,7 +460,7 @@ static void EFIAPI efi_console_timer_notify(struct efi_event *event,
{ {
EFI_ENTRY("%p, %p", event, context); EFI_ENTRY("%p, %p", event, context);
if (tstc()) { if (tstc()) {
efi_con_in.wait_for_key->signaled = 1; efi_con_in.wait_for_key->is_signaled = true;
efi_signal_event(efi_con_in.wait_for_key); efi_signal_event(efi_con_in.wait_for_key);
} }
EFI_EXIT(EFI_SUCCESS); EFI_EXIT(EFI_SUCCESS);

Loading…
Cancel
Save