[U-Boot] [PATCH v2 2/7] efi_loader: implement multiple event support

Alexander Graf agraf at suse.de
Wed Jul 19 12:30:03 UTC 2017


On 07/18/2017 08:17 PM, Heinrich Schuchardt wrote:
> Up to now the boot time supported only a single event.
> This patch now allows four events.
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
> ---
> v2
> 	add TPL constants
> 	consider multiple events in efi_wait_for_event
> 	move notification to new function efi_signal_event
> ---
>   include/efi_api.h             |  13 ++-
>   include/efi_loader.h          |  24 ++++++
>   lib/efi_loader/efi_boottime.c | 195 ++++++++++++++++++++++++++++--------------
>   3 files changed, 168 insertions(+), 64 deletions(-)
>
> diff --git a/include/efi_api.h b/include/efi_api.h
> index a1f8221111..a3b8e04576 100644
> --- a/include/efi_api.h
> +++ b/include/efi_api.h
> @@ -28,8 +28,17 @@ enum efi_event_type {
>   	EFI_TIMER_RELATIVE = 2
>   };
>   
> -#define EVT_NOTIFY_WAIT		0x00000100
> -#define EVT_NOTIFY_SIGNAL	0x00000200
> +#define EVT_TIMER				0x80000000
> +#define EVT_RUNTIME				0x40000000
> +#define EVT_NOTIFY_WAIT				0x00000100
> +#define EVT_NOTIFY_SIGNAL			0x00000200
> +#define EVT_SIGNAL_EXIT_BOOT_SERVICES		0x00000201
> +#define EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE	0x60000202
> +
> +#define TPL_APPLICATION		0x04
> +#define TPL_CALLBACK		0x08
> +#define TPL_NOTIFY		0x10
> +#define TPL_HIGH_LEVEL		0x1F
>   
>   struct efi_event;
>   
> diff --git a/include/efi_loader.h b/include/efi_loader.h
> index d7847d23e5..3d18bfbd2e 100644
> --- a/include/efi_loader.h
> +++ b/include/efi_loader.h
> @@ -63,6 +63,30 @@ struct efi_object {
>   	void *handle;
>   };
>   
> +/**
> + * struct efi_event
> + *
> + * @type:		Type of event, see efi_create_event
> + * @notify_tpl:		Task priority level of notifications
> + * @trigger_time:	Period of the timer
> + * @trigger_next:	Next time to trigger the timer
> + * @nofify_function:	Function to call when the event is triggered
> + * @notify_context:	Data to be passed to the notify function
> + * @trigger_type:	Type of timer, see efi_set_timer
> + * @signaled:		The notify function was already called
> + */
> +struct efi_event {
> +	u32 type;
> +	unsigned long notify_tpl;
> +	void (EFIAPI *notify_function)(struct efi_event *event, void *context);
> +	void *notify_context;
> +	u64 trigger_next;
> +	u64 trigger_time;
> +	enum efi_event_type trigger_type;
> +	int signaled;
> +};
> +
> +
>   /* This list contains all UEFI objects we know of */
>   extern struct list_head efi_obj_list;
>   
> diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
> index 0eda465359..a49acc8693 100644
> --- a/lib/efi_loader/efi_boottime.c
> +++ b/lib/efi_loader/efi_boottime.c
> @@ -82,6 +82,18 @@ efi_status_t efi_exit_func(efi_status_t ret)
>   	return ret;
>   }
>   
> +static void efi_signal_event(struct efi_event *event)
> +{
> +	if (event->signaled)
> +		return;
> +	event->signaled = 1;
> +	if (event->type & EVT_NOTIFY_SIGNAL) {
> +		EFI_EXIT(EFI_SUCCESS);
> +		event->notify_function(event, event->notify_context);
> +		EFI_ENTRY("returning from notification function");
> +	}
> +}
> +
>   static efi_status_t efi_unsupported(const char *funcname)
>   {
>   	debug("EFI: App called into unimplemented function %s\n", funcname);
> @@ -163,22 +175,10 @@ static efi_status_t EFIAPI efi_free_pool_ext(void *buffer)
>   }
>   
>   /*
> - * Our event capabilities are very limited. Only support a single
> - * event to exist, so we don't need to maintain lists.
> + * Our event capabilities are very limited. Only a small limited
> + * number of events is allowed to coexist.
>    */
> -static struct efi_event {
> -	enum efi_event_type type;
> -	u32 trigger_type;
> -	u32 trigger_time;
> -	u64 trigger_next;
> -	unsigned long notify_tpl;
> -	void (EFIAPI *notify_function) (struct efi_event *event,
> -					void *context);
> -	void *notify_context;
> -} efi_event = {
> -	/* Disable timers on bootup */
> -	.trigger_next = -1ULL,
> -};
> +static struct efi_event efi_events[16];
>   
>   static efi_status_t EFIAPI efi_create_event(
>   			enum efi_event_type type, ulong notify_tpl,

The argument type of "type" is (incorrectly) enum efi_event_type. Can 
you send a follow-up patch that changes it to u32 (or its own enum) to 
avoid confusion?


Alex



More information about the U-Boot mailing list