提交 bfc72462 编写于 作者: X xypron.glpk@gmx.de 提交者: Alexander Graf

efi_loader: refactor efi_set_timer

efi_set_timer is refactored to make the function callable internally.
Wrapper function efi_set_timer_ext is provided for EFI applications.
Signed-off-by: NHeinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: NAlexander Graf <agraf@suse.de>
上级 49deb455
...@@ -122,6 +122,9 @@ efi_status_t efi_create_event(enum efi_event_type type, UINTN notify_tpl, ...@@ -122,6 +122,9 @@ efi_status_t efi_create_event(enum efi_event_type type, UINTN notify_tpl,
struct efi_event *event, struct efi_event *event,
void *context), void *context),
void *notify_context, struct efi_event **event); void *notify_context, struct efi_event **event);
/* Call this to set a timer */
efi_status_t efi_set_timer(struct efi_event *event, int type,
uint64_t trigger_time);
/* Generic EFI memory allocator, call this to get memory */ /* Generic EFI memory allocator, call this to get memory */
void *efi_alloc(uint64_t len, int memory_type); void *efi_alloc(uint64_t len, int memory_type);
......
...@@ -252,16 +252,14 @@ void efi_timer_check(void) ...@@ -252,16 +252,14 @@ void efi_timer_check(void)
WATCHDOG_RESET(); WATCHDOG_RESET();
} }
static efi_status_t EFIAPI efi_set_timer(struct efi_event *event, int type, efi_status_t efi_set_timer(struct efi_event *event, int type,
uint64_t trigger_time) uint64_t trigger_time)
{ {
/* We don't have 64bit division available everywhere, so limit timer /* We don't have 64bit division available everywhere, so limit timer
* distances to 32bit bits. */ * distances to 32bit bits. */
u32 trigger32 = trigger_time; u32 trigger32 = trigger_time;
int i; int i;
EFI_ENTRY("%p, %d, %"PRIx64, event, type, trigger_time);
if (trigger32 < trigger_time) { if (trigger32 < trigger_time) {
printf("WARNING: Truncating timer from %"PRIx64" to %x\n", printf("WARNING: Truncating timer from %"PRIx64" to %x\n",
trigger_time, trigger32); trigger_time, trigger32);
...@@ -283,13 +281,20 @@ static efi_status_t EFIAPI efi_set_timer(struct efi_event *event, int type, ...@@ -283,13 +281,20 @@ static efi_status_t EFIAPI efi_set_timer(struct efi_event *event, int type,
timer_get_us() + (trigger32 / 10); timer_get_us() + (trigger32 / 10);
break; break;
default: default:
return EFI_EXIT(EFI_INVALID_PARAMETER); return EFI_INVALID_PARAMETER;
} }
event->trigger_type = type; event->trigger_type = type;
event->trigger_time = trigger_time; event->trigger_time = trigger_time;
return EFI_EXIT(EFI_SUCCESS); return EFI_SUCCESS;
} }
return EFI_EXIT(EFI_INVALID_PARAMETER); return EFI_INVALID_PARAMETER;
}
static efi_status_t EFIAPI efi_set_timer_ext(struct efi_event *event, int type,
uint64_t trigger_time)
{
EFI_ENTRY("%p, %d, %"PRIx64, event, type, trigger_time);
return EFI_EXIT(efi_set_timer(event, type, trigger_time));
} }
static efi_status_t EFIAPI efi_wait_for_event(unsigned long num_events, static efi_status_t EFIAPI efi_wait_for_event(unsigned long num_events,
...@@ -1067,7 +1072,7 @@ static const struct efi_boot_services efi_boot_services = { ...@@ -1067,7 +1072,7 @@ static const struct efi_boot_services efi_boot_services = {
.allocate_pool = efi_allocate_pool_ext, .allocate_pool = efi_allocate_pool_ext,
.free_pool = efi_free_pool_ext, .free_pool = efi_free_pool_ext,
.create_event = efi_create_event_ext, .create_event = efi_create_event_ext,
.set_timer = efi_set_timer, .set_timer = efi_set_timer_ext,
.wait_for_event = efi_wait_for_event, .wait_for_event = efi_wait_for_event,
.signal_event = efi_signal_event_ext, .signal_event = efi_signal_event_ext,
.close_event = efi_close_event, .close_event = efi_close_event,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册