From b3d6090042d4de265c930358aec4d9b96bf3748a Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Wed, 18 Oct 2017 18:13:04 +0200 Subject: efi_loader: implement SetWatchdogTimer The watchdog is initialized with a 5 minute timeout period. It can be reset by SetWatchdogTimer. It is stopped by ExitBoottimeServices. Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/efi_loader.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index 1b92edbd77c..af64b11cee8 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -163,6 +163,8 @@ int efi_disk_register(void); int efi_gop_register(void); /* Called by bootefi to make the network interface available */ int efi_net_register(void); +/* Called by bootefi to make the watchdog available */ +int efi_watchdog_register(void); /* Called by bootefi to make SMBIOS tables available */ void efi_smbios_register(void); @@ -171,6 +173,8 @@ efi_fs_from_path(struct efi_device_path *fp); /* Called by networking code to memorize the dhcp ack package */ void efi_net_set_dhcp_ack(void *pkt, int len); +/* Called by efi_set_watchdog_timer to reset the timer */ +efi_status_t efi_set_watchdog(unsigned long timeout); /* Called from places to check whether a timer expired */ void efi_timer_check(void); -- cgit v1.2.3 From f58c5ecb87e0ab170dfa92cd0c1052dd18fffc2c Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Wed, 18 Oct 2017 18:13:06 +0200 Subject: efi_loader: new function utf8_to_utf16 Provide a conversion function from utf8 to utf16. Add missing #include in include/charset.h. Remove superfluous #include in lib/charset.c. Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/charset.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'include') diff --git a/include/charset.h b/include/charset.h index 37a32784998..2662c2f7c9a 100644 --- a/include/charset.h +++ b/include/charset.h @@ -9,6 +9,8 @@ #ifndef __CHARSET_H_ #define __CHARSET_H_ +#include + #define MAX_UTF8_PER_UTF16 3 /** @@ -62,4 +64,17 @@ uint16_t *utf16_strdup(const uint16_t *s); */ uint8_t *utf16_to_utf8(uint8_t *dest, const uint16_t *src, size_t size); +/** + * utf8_to_utf16() - Convert an utf8 string to utf16 + * + * Converts up to 'size' characters of the utf16 string 'src' to utf8 + * written to the 'dest' buffer. Stops at 0x00. + * + * @dest the destination buffer to write the utf8 characters + * @src the source utf16 string + * @size maximum number of utf16 characters to convert + * @return the pointer to the first unwritten byte in 'dest' + */ +uint16_t *utf8_to_utf16(uint16_t *dest, const uint8_t *src, size_t size); + #endif /* __CHARSET_H_ */ -- cgit v1.2.3 From cd9e18dee0d148a326aafcc075b0b9d247ffdaa2 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Wed, 18 Oct 2017 18:13:07 +0200 Subject: efi_loader: guard against double inclusion of efi_loader.h Use a define to detect double inclusion of efi_loader.h. Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/efi_loader.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index af64b11cee8..e506eeec617 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -6,6 +6,9 @@ * SPDX-License-Identifier: GPL-2.0+ */ +#ifndef _EFI_LOADER_H +#define _EFI_LOADER_H 1 + #include #include #include @@ -345,4 +348,6 @@ static inline void efi_set_bootdev(const char *dev, const char *devnr, const char *path) { } static inline void efi_net_set_dhcp_ack(void *pkt, int len) { } -#endif +#endif /* CONFIG_EFI_LOADER && !CONFIG_SPL_BUILD */ + +#endif /* _EFI_LOADER_H */ -- cgit v1.2.3 From d78e40d651972ef061c960e4b7da7843383c2ec9 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Wed, 18 Oct 2017 18:13:13 +0200 Subject: efi_selftest: allow to select a single test for execution Environment variable efi_selftest is passed as load options to the selftest application. It is used to select a single test to be executed. The load options are an UTF8 string. Yet I decided to keep the name propertiy of the tests as char[] to reduce code size. Special value 'list' displays a list of all available tests. Tests get an on_request property. If this property is set the tests are only executed if explicitly requested. The invocation of efi_selftest is changed to reflect that bootefi selftest with efi_selftest = 'list' will call the Exit bootservice. Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/efi_selftest.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include') diff --git a/include/efi_selftest.h b/include/efi_selftest.h index 7ec42a0406b..5cc8d4f6006 100644 --- a/include/efi_selftest.h +++ b/include/efi_selftest.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #define EFI_ST_SUCCESS 0 @@ -71,6 +72,15 @@ void efi_st_printf(const char *fmt, ...) */ int efi_st_memcmp(const void *buf1, const void *buf2, size_t length); +/* + * Compare an u16 string to a char string. + * + * @buf1: u16 string + * @buf2: char string + * @return: 0 if both buffers contain the same bytes + */ +int efi_st_strcmp_16_8(const u16 *buf1, const char *buf2); + /* * Reads an Unicode character from the input device. * @@ -88,6 +98,7 @@ u16 efi_st_get_key(void); * @setup: set up the unit test * @teardown: tear down the unit test * @execute: execute the unit test + * @on_request: test is only executed on request */ struct efi_unit_test { const char *name; @@ -96,6 +107,7 @@ struct efi_unit_test { const struct efi_system_table *systable); int (*execute)(void); int (*teardown)(void); + bool on_request; }; /* Declare a new EFI unit test */ -- cgit v1.2.3 From 9f0770ff9c04c43f71bba076203af61ac62e8f3c Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Mon, 6 Nov 2017 21:17:42 +0100 Subject: efi_loader: capitalize EFI_LOCATE_SEARCH_TYPE values Constants should be capitalized. So rename the values of enum efi_locate_search_type. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass Signed-off-by: Alexander Graf --- include/efi.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/efi.h b/include/efi.h index dc8edc8743a..2f0be9c86cb 100644 --- a/include/efi.h +++ b/include/efi.h @@ -227,9 +227,9 @@ struct efi_time_cap { }; enum efi_locate_search_type { - all_handles, - by_register_notify, - by_protocol + ALL_HANDLES, + BY_REGISTER_NOTIFY, + BY_PROTOCOL }; struct efi_open_protocol_info_entry { -- cgit v1.2.3 From 927ca890b09fd7dd5fdf2214adcb10565f3573c9 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Mon, 6 Nov 2017 21:17:43 +0100 Subject: efi_selftest: test protocol management This unit test checks the following protocol services: InstallProtocolInterface, UninstallProtocolInterface, InstallMultipleProtocolsInterfaces, UninstallMultipleProtocolsInterfaces, HandleProtocol, ProtocolsPerHandle, LocateHandle, LocateHandleBuffer. As UninstallProtocolInterface and UninstallMultipleProtocolsInterfaces are not completely implemented a TODO message will shown for their failure. Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/efi_selftest.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') diff --git a/include/efi_selftest.h b/include/efi_selftest.h index 5cc8d4f6006..be5ba4bfa91 100644 --- a/include/efi_selftest.h +++ b/include/efi_selftest.h @@ -27,6 +27,15 @@ (efi_st_printf("%s(%u):\nERROR: ", __FILE__, __LINE__), \ efi_st_printf(__VA_ARGS__)) \ +/* + * Prints a TODO message. + * + * @... format string followed by fields to print + */ +#define efi_st_todo(...) \ + (efi_st_printf("%s(%u):\nTODO: ", __FILE__, __LINE__), \ + efi_st_printf(__VA_ARGS__)) \ + /* * A test may be setup and executed at boottime, * it may be setup at boottime and executed at runtime, -- cgit v1.2.3 From 7e82449495eef28dddb6160385ab546eac212500 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Mon, 6 Nov 2017 21:17:46 +0100 Subject: efi_loader: remove unused typedef for INTN INTN is not used in the coding. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass Signed-off-by: Alexander Graf --- include/efi_api.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index fcd7483ab21..8ea44b1a7a2 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -29,7 +29,6 @@ enum efi_timer_delay { }; #define UINTN size_t -typedef long INTN; typedef uint16_t *efi_string_t; #define EVT_TIMER 0x80000000 -- cgit v1.2.3 From 152cade32643fdbdd73614db4cfb159876b58262 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Mon, 6 Nov 2017 21:17:47 +0100 Subject: efi_loader: replace UINTN by efi_uintn_t UINTN is used in the UEFI specification for unsigned integers matching the bitness of the CPU. Types in U-Boot should be lower case. The patch replaces it by efi_uintn_t. Suggested-by: Simon Glass Suggested-by: Rob Clark Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass Signed-off-by: Alexander Graf --- include/efi_api.h | 8 ++++---- include/efi_loader.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index 8ea44b1a7a2..5ab78baeea0 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -28,7 +28,7 @@ enum efi_timer_delay { EFI_TIMER_RELATIVE = 2 }; -#define UINTN size_t +#define efi_uintn_t size_t typedef uint16_t *efi_string_t; #define EVT_TIMER 0x80000000 @@ -48,8 +48,8 @@ struct efi_event; /* EFI Boot Services table */ struct efi_boot_services { struct efi_table_hdr hdr; - efi_status_t (EFIAPI *raise_tpl)(UINTN new_tpl); - void (EFIAPI *restore_tpl)(UINTN old_tpl); + efi_status_t (EFIAPI *raise_tpl)(efi_uintn_t new_tpl); + void (EFIAPI *restore_tpl)(efi_uintn_t old_tpl); efi_status_t (EFIAPI *allocate_pages)(int, int, unsigned long, efi_physical_addr_t *); @@ -61,7 +61,7 @@ struct efi_boot_services { efi_status_t (EFIAPI *free_pool)(void *); efi_status_t (EFIAPI *create_event)(uint32_t type, - UINTN notify_tpl, + efi_uintn_t notify_tpl, void (EFIAPI *notify_function) ( struct efi_event *event, void *context), diff --git a/include/efi_loader.h b/include/efi_loader.h index e506eeec617..83b27d04490 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -144,7 +144,7 @@ struct efi_object { */ struct efi_event { uint32_t type; - UINTN notify_tpl; + efi_uintn_t notify_tpl; void (EFIAPI *notify_function)(struct efi_event *event, void *context); void *notify_context; u64 trigger_next; @@ -193,7 +193,7 @@ void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map); /* Call this to set the current device name */ void efi_set_bootdev(const char *dev, const char *devnr, const char *path); /* Call this to create an event */ -efi_status_t efi_create_event(uint32_t type, UINTN notify_tpl, +efi_status_t efi_create_event(uint32_t type, efi_uintn_t notify_tpl, void (EFIAPI *notify_function) ( struct efi_event *event, void *context), -- cgit v1.2.3 From f5a2a93892ff8a8f066bc9f84eb9f0cf35ba0c67 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Mon, 6 Nov 2017 21:17:48 +0100 Subject: efi_loader: consistently use efi_uintn_t in boot services Consistenly use efi_uintn_t wherever the UEFI spec uses UINTN in boot services interfaces. Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/efi_api.h | 29 ++++++++++++++++------------- include/efi_loader.h | 12 ++++++------ 2 files changed, 22 insertions(+), 19 deletions(-) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index 5ab78baeea0..e0991b6eca5 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -51,13 +51,15 @@ struct efi_boot_services { efi_status_t (EFIAPI *raise_tpl)(efi_uintn_t new_tpl); void (EFIAPI *restore_tpl)(efi_uintn_t old_tpl); - efi_status_t (EFIAPI *allocate_pages)(int, int, unsigned long, + efi_status_t (EFIAPI *allocate_pages)(int, int, efi_uintn_t, efi_physical_addr_t *); - efi_status_t (EFIAPI *free_pages)(efi_physical_addr_t, unsigned long); - efi_status_t (EFIAPI *get_memory_map)(unsigned long *memory_map_size, - struct efi_mem_desc *desc, unsigned long *key, - unsigned long *desc_size, u32 *desc_version); - efi_status_t (EFIAPI *allocate_pool)(int, unsigned long, void **); + efi_status_t (EFIAPI *free_pages)(efi_physical_addr_t, efi_uintn_t); + efi_status_t (EFIAPI *get_memory_map)(efi_uintn_t *memory_map_size, + struct efi_mem_desc *desc, + efi_uintn_t *key, + efi_uintn_t *desc_size, + u32 *desc_version); + efi_status_t (EFIAPI *allocate_pool)(int, efi_uintn_t, void **); efi_status_t (EFIAPI *free_pool)(void *); efi_status_t (EFIAPI *create_event)(uint32_t type, @@ -69,8 +71,9 @@ struct efi_boot_services { efi_status_t (EFIAPI *set_timer)(struct efi_event *event, enum efi_timer_delay type, uint64_t trigger_time); - efi_status_t (EFIAPI *wait_for_event)(unsigned long number_of_events, - struct efi_event **event, size_t *index); + efi_status_t (EFIAPI *wait_for_event)(efi_uintn_t number_of_events, + struct efi_event **event, + efi_uintn_t *index); efi_status_t (EFIAPI *signal_event)(struct efi_event *event); efi_status_t (EFIAPI *close_event)(struct efi_event *event); efi_status_t (EFIAPI *check_event)(struct efi_event *event); @@ -93,7 +96,7 @@ struct efi_boot_services { efi_status_t (EFIAPI *locate_handle)( enum efi_locate_search_type search_type, const efi_guid_t *protocol, void *search_key, - unsigned long *buffer_size, efi_handle_t *buffer); + efi_uintn_t *buffer_size, efi_handle_t *buffer); efi_status_t (EFIAPI *locate_device_path)(const efi_guid_t *protocol, struct efi_device_path **device_path, efi_handle_t *device); @@ -140,14 +143,14 @@ struct efi_boot_services { efi_status_t(EFIAPI *open_protocol_information)(efi_handle_t handle, const efi_guid_t *protocol, struct efi_open_protocol_info_entry **entry_buffer, - unsigned long *entry_count); + efi_uintn_t *entry_count); efi_status_t (EFIAPI *protocols_per_handle)(efi_handle_t handle, efi_guid_t ***protocol_buffer, - unsigned long *protocols_buffer_count); + efi_uintn_t *protocols_buffer_count); efi_status_t (EFIAPI *locate_handle_buffer) ( enum efi_locate_search_type search_type, const efi_guid_t *protocol, void *search_key, - unsigned long *no_handles, efi_handle_t **buffer); + efi_uintn_t *no_handles, efi_handle_t **buffer); efi_status_t (EFIAPI *locate_protocol)(const efi_guid_t *protocol, void *registration, void **protocol_interface); efi_status_t (EFIAPI *install_multiple_protocol_interfaces)( @@ -248,7 +251,7 @@ struct efi_system_table { struct efi_simple_text_output_protocol *std_err; struct efi_runtime_services *runtime; struct efi_boot_services *boottime; - unsigned long nr_tables; + efi_uintn_t nr_tables; struct efi_configuration_table *tables; }; diff --git a/include/efi_loader.h b/include/efi_loader.h index 83b27d04490..e3d1c359301 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -215,20 +215,20 @@ struct efi_file_handle *efi_file_from_path(struct efi_device_path *fp); /* Generic EFI memory allocator, call this to get memory */ void *efi_alloc(uint64_t len, int memory_type); /* More specific EFI memory allocator, called by EFI payloads */ -efi_status_t efi_allocate_pages(int type, int memory_type, unsigned long pages, +efi_status_t efi_allocate_pages(int type, int memory_type, efi_uintn_t pages, uint64_t *memory); /* EFI memory free function. */ -efi_status_t efi_free_pages(uint64_t memory, unsigned long pages); +efi_status_t efi_free_pages(uint64_t memory, efi_uintn_t pages); /* EFI memory allocator for small allocations */ -efi_status_t efi_allocate_pool(int pool_type, unsigned long size, +efi_status_t efi_allocate_pool(int pool_type, efi_uintn_t size, void **buffer); /* EFI pool memory free function. */ efi_status_t efi_free_pool(void *buffer); /* Returns the EFI memory map */ -efi_status_t efi_get_memory_map(unsigned long *memory_map_size, +efi_status_t efi_get_memory_map(efi_uintn_t *memory_map_size, struct efi_mem_desc *memory_map, - unsigned long *map_key, - unsigned long *descriptor_size, + efi_uintn_t *map_key, + efi_uintn_t *descriptor_size, uint32_t *descriptor_version); /* Adds a range into the EFI memory map */ uint64_t efi_add_memory_map(uint64_t start, uint64_t pages, int memory_type, -- cgit v1.2.3 From 1b68153af1ff0af3828ad7de0d0319a456ff19f7 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Mon, 6 Nov 2017 21:17:50 +0100 Subject: efi_loader: rework efi_search_obj EFI_HANDLEs are used both in boottime and in runtime services. efi_search_obj is a function that can be used to validate handles. So let's make it accessible via efi_loader.h. We can simplify the coding using list_for_each_entry. Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/efi_loader.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index e3d1c359301..2bcca3dfd8b 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -192,6 +192,8 @@ void efi_restore_gd(void); void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map); /* Call this to set the current device name */ void efi_set_bootdev(const char *dev, const char *devnr, const char *path); +/* Call this to validate a handle and find the EFI object for it */ +struct efi_object *efi_search_obj(void *handle); /* Call this to create an event */ efi_status_t efi_create_event(uint32_t type, efi_uintn_t notify_tpl, void (EFIAPI *notify_function) ( -- cgit v1.2.3 From ff401d3f81bb8cfcec28162de07236a355aa3212 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 26 Oct 2017 19:25:48 +0200 Subject: efi_loader: efi_dp_match should have const arguments efi_dp_match does not change its arguments. So they should be marked as const. Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/efi_loader.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index 2bcca3dfd8b..5fe17b0c091 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -252,7 +252,8 @@ extern void *efi_bounce_buffer; struct efi_device_path *efi_dp_next(const struct efi_device_path *dp); -int efi_dp_match(struct efi_device_path *a, struct efi_device_path *b); +int efi_dp_match(const struct efi_device_path *a, + const struct efi_device_path *b); struct efi_object *efi_dp_find_obj(struct efi_device_path *dp, struct efi_device_path **rem); unsigned efi_dp_size(const struct efi_device_path *dp); -- cgit v1.2.3 From 2edab5e2e685a384261e6dd32676924feb33dfa8 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 26 Oct 2017 19:25:49 +0200 Subject: efi_loader: make efi_create_handle non-static Export function efi_create_handle. Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/efi_loader.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index 5fe17b0c091..f42dceaf51d 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -192,6 +192,8 @@ void efi_restore_gd(void); void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map); /* Call this to set the current device name */ void efi_set_bootdev(const char *dev, const char *devnr, const char *path); +/* Create handle */ +efi_status_t efi_create_handle(void **handle); /* Call this to validate a handle and find the EFI object for it */ struct efi_object *efi_search_obj(void *handle); /* Call this to create an event */ -- cgit v1.2.3 From 085d07cd3b8c9a12d5a02c13b56ab92436c062ba Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 26 Oct 2017 19:25:50 +0200 Subject: efi_loader: argument of efi_search_obj should be const The argument of efi_search_obj is not changed so it should be marked as const. Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/efi_loader.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index f42dceaf51d..a5aae1b87ec 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -195,7 +195,7 @@ void efi_set_bootdev(const char *dev, const char *devnr, const char *path); /* Create handle */ efi_status_t efi_create_handle(void **handle); /* Call this to validate a handle and find the EFI object for it */ -struct efi_object *efi_search_obj(void *handle); +struct efi_object *efi_search_obj(const void *handle); /* Call this to create an event */ efi_status_t efi_create_event(uint32_t type, efi_uintn_t notify_tpl, void (EFIAPI *notify_function) ( -- cgit v1.2.3 From 1c38a7741c59d1213004a07c362ae7f07a3d9357 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 26 Oct 2017 19:25:51 +0200 Subject: efi_loader: efi_gop: use correct types for parameters Use efi_uintn_t instead of unsigned long. EFI_GRAPHICS_OUTPUT_BLT_OPERATION is an enum. If we don't define an enum we have to pass it as u32. Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/efi_api.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index e0991b6eca5..584016dc302 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -585,14 +585,14 @@ struct efi_gop_mode struct efi_gop { efi_status_t (EFIAPI *query_mode)(struct efi_gop *this, u32 mode_number, - unsigned long *size_of_info, + efi_uintn_t *size_of_info, struct efi_gop_mode_info **info); efi_status_t (EFIAPI *set_mode)(struct efi_gop *this, u32 mode_number); efi_status_t (EFIAPI *blt)(struct efi_gop *this, void *buffer, - unsigned long operation, unsigned long sx, - unsigned long sy, unsigned long dx, - unsigned long dy, unsigned long width, - unsigned long height, unsigned long delta); + u32 operation, efi_uintn_t sx, + efi_uintn_t sy, efi_uintn_t dx, + efi_uintn_t dy, efi_uintn_t width, + efi_uintn_t height, efi_uintn_t delta); struct efi_gop_mode *mode; }; -- cgit v1.2.3 From 3f79a2b532d8deafd5293f9f7e492d30fc6e339d Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 26 Oct 2017 19:25:53 +0200 Subject: efi_loader: helper functions for protocol management This patch provides helper functions to manage protocols. efi_search_protocol - find a protocol on a handle efi_add_protocol - install a protocol on a handle efi_remove_protocol - remove a protocol from a handle efi_remove_all_protocols - remove all protocols from a handle Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/efi_loader.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index a5aae1b87ec..934f64dccb9 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -196,6 +196,18 @@ void efi_set_bootdev(const char *dev, const char *devnr, const char *path); efi_status_t efi_create_handle(void **handle); /* Call this to validate a handle and find the EFI object for it */ struct efi_object *efi_search_obj(const void *handle); +/* Find a protocol on a handle */ +efi_status_t efi_search_protocol(const void *handle, + const efi_guid_t *protocol_guid, + struct efi_handler **handler); +/* Install new protocol on a handle */ +efi_status_t efi_add_protocol(const void *handle, const efi_guid_t *protocol, + void *protocol_interface); +/* Delete protocol from a handle */ +efi_status_t efi_remove_protocol(const void *handle, const efi_guid_t *protocol, + void *protocol_interface); +/* Delete all protocols from a handle */ +efi_status_t efi_remove_all_protocols(const void *handle); /* Call this to create an event */ efi_status_t efi_create_event(uint32_t type, efi_uintn_t notify_tpl, void (EFIAPI *notify_function) ( -- cgit v1.2.3 From ebb4dd5bc3d39b3a2109970936c7e74556110915 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 26 Oct 2017 19:25:59 +0200 Subject: efi_loader: efi_console: use helper functions Use helper functions efi_created_handle and efi_add_protocol for creating the console handles and instaling the respective protocols. This change is needed if we want to move from an array of protocols to a linked list of protocols. Eliminate EFI_PROTOCOL_OBJECT which is not used anymore. Currently we have not defined protocol interfaces to be const. So efi_con_out and efi_console_control cannot be defined as const. Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/efi_loader.h | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index 934f64dccb9..e1f0af3496e 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -78,9 +78,9 @@ const char *__efi_nesting_dec(void); extern struct efi_runtime_services efi_runtime_services; extern struct efi_system_table systab; -extern const struct efi_simple_text_output_protocol efi_con_out; +extern struct efi_simple_text_output_protocol efi_con_out; extern struct efi_simple_input_interface efi_con_in; -extern const struct efi_console_control_protocol efi_console_control; +extern struct efi_console_control_protocol efi_console_control; extern const struct efi_device_path_to_text_protocol efi_device_path_to_text; uint16_t *efi_dp_str(struct efi_device_path *dp); @@ -121,14 +121,6 @@ struct efi_object { void *handle; }; -#define EFI_PROTOCOL_OBJECT(_guid, _protocol) (struct efi_object){ \ - .protocols = {{ \ - .guid = &(_guid), \ - .protocol_interface = (void *)(_protocol), \ - }}, \ - .handle = (void *)(_protocol), \ -} - /** * struct efi_event * -- cgit v1.2.3 From 69fb6b1afcf37d3f68c6e0614658cfc023410e09 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sun, 26 Nov 2017 14:05:17 +0100 Subject: efi_loader: manage protocols in a linked list Reviewed-by: Simon Glass Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/efi_loader.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index e1f0af3496e..a73bbc12695 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -101,6 +101,8 @@ extern unsigned int __efi_runtime_rel_start, __efi_runtime_rel_stop; * interface (usually a struct with callback functions), this struct maps the * protocol GUID to the respective protocol interface */ struct efi_handler { + /* Link to the list of protocols of a handle */ + struct list_head link; const efi_guid_t *guid; void *protocol_interface; }; @@ -115,8 +117,8 @@ struct efi_handler { struct efi_object { /* Every UEFI object is part of a global object list */ struct list_head link; - /* We support up to 16 "protocols" an object can be accessed through */ - struct efi_handler protocols[16]; + /* The list of protocols */ + struct list_head protocols; /* The object spawner can either use this for data or as identifier */ void *handle; }; -- cgit v1.2.3 From 44549d62c31dc433366b4c5d6e58e0e3091e542b Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sun, 26 Nov 2017 14:05:23 +0100 Subject: efi_loader: helper function to add EFI object to list To avoid duplicate coding provide a helper function that initializes an EFI object and adds it to the EFI object list. efi_exit() is the only place where we dereference a handle to obtain a protocol interface. Add a comment to the function. Suggested-by: Alexander Graf Reviewed-by: Simon Glass Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/efi_loader.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index a73bbc12695..c0caabddb12 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -186,6 +186,8 @@ void efi_restore_gd(void); void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map); /* Call this to set the current device name */ void efi_set_bootdev(const char *dev, const char *devnr, const char *path); +/* Add a new object to the object list. */ +void efi_add_handle(struct efi_object *obj); /* Create handle */ efi_status_t efi_create_handle(void **handle); /* Call this to validate a handle and find the EFI object for it */ -- cgit v1.2.3