diff options
author | Tom Rini <trini@konsulko.com> | 2017-12-05 17:52:16 -0500 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2017-12-05 17:52:16 -0500 |
commit | 9188c4315cbf670417adf196fa1c6a386e885ef1 (patch) | |
tree | bdef16af1e11d8df66211f88bdbdf509660df41e /include | |
parent | 9da7fb4a39149c3061cb148bfbaa76b4b52b9008 (diff) | |
parent | bb0bb91cf0aa2c13528fe39be2006f32f7b9c437 (diff) | |
download | u-boot-9188c4315cbf670417adf196fa1c6a386e885ef1.tar.gz |
Merge tag 'signed-efi-next' of git://github.com/agraf/u-boot
Patch queue for efi - 2017-12-05
Highlights for this release:
- Dynamic EFI object creation (lists instead of static arrays)
- EFI selftest improvements
- Minor fixes
Diffstat (limited to 'include')
-rw-r--r-- | include/charset.h | 15 | ||||
-rw-r--r-- | include/efi.h | 6 | ||||
-rw-r--r-- | include/efi_api.h | 48 | ||||
-rw-r--r-- | include/efi_loader.h | 66 | ||||
-rw-r--r-- | include/efi_selftest.h | 21 |
5 files changed, 108 insertions, 48 deletions
diff --git a/include/charset.h b/include/charset.h index 37a3278499..2662c2f7c9 100644 --- a/include/charset.h +++ b/include/charset.h @@ -9,6 +9,8 @@ #ifndef __CHARSET_H_ #define __CHARSET_H_ +#include <linux/types.h> + #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_ */ diff --git a/include/efi.h b/include/efi.h index dc8edc8743..2f0be9c86c 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 { diff --git a/include/efi_api.h b/include/efi_api.h index fcd7483ab2..584016dc30 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -28,8 +28,7 @@ enum efi_timer_delay { EFI_TIMER_RELATIVE = 2 }; -#define UINTN size_t -typedef long INTN; +#define efi_uintn_t size_t typedef uint16_t *efi_string_t; #define EVT_TIMER 0x80000000 @@ -49,20 +48,22 @@ 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_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, - UINTN notify_tpl, + efi_uintn_t notify_tpl, void (EFIAPI *notify_function) ( struct efi_event *event, void *context), @@ -70,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); @@ -94,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); @@ -141,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)( @@ -249,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; }; @@ -583,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; }; diff --git a/include/efi_loader.h b/include/efi_loader.h index 1b92edbd77..c0caabddb1 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 <common.h> #include <part_efi.h> #include <efi_api.h> @@ -75,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); @@ -98,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; }; @@ -112,20 +117,12 @@ 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; }; -#define EFI_PROTOCOL_OBJECT(_guid, _protocol) (struct efi_object){ \ - .protocols = {{ \ - .guid = &(_guid), \ - .protocol_interface = (void *)(_protocol), \ - }}, \ - .handle = (void *)(_protocol), \ -} - /** * struct efi_event * @@ -141,7 +138,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; @@ -163,6 +160,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 +170,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); @@ -185,8 +186,26 @@ 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 */ +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, 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), @@ -208,20 +227,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, @@ -243,7 +262,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); @@ -341,4 +361,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 */ diff --git a/include/efi_selftest.h b/include/efi_selftest.h index 7ec42a0406..be5ba4bfa9 100644 --- a/include/efi_selftest.h +++ b/include/efi_selftest.h @@ -12,6 +12,7 @@ #include <common.h> #include <efi.h> #include <efi_api.h> +#include <efi_loader.h> #include <linker_lists.h> #define EFI_ST_SUCCESS 0 @@ -27,6 +28,15 @@ 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, * or it may be setup and executed at runtime. @@ -72,6 +82,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. * * @return: Unicode character @@ -88,6 +107,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 +116,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 */ |