From 8396e3fd63e8c8e17d60a6d1992ca3df10bc8d66 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 3 Mar 2018 15:41:37 +0100 Subject: efi_loader: remove deprecated ConsoleControlProtocol The console control protocol is not defined in the UEFI standard. It exists in EDK2's EdkCompatiblityPkg package. But this package is deprecated according to https://github.com/tianocore/tianocore.github.io/wiki/Differences-between-EDK-and-EDK-II Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/efi_api.h | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index 3ba650e..8559656 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -571,24 +571,6 @@ struct efi_simple_input_interface { struct efi_event *wait_for_key; }; -#define CONSOLE_CONTROL_GUID \ - EFI_GUID(0xf42f7782, 0x12e, 0x4c12, \ - 0x99, 0x56, 0x49, 0xf9, 0x43, 0x4, 0xf7, 0x21) -#define EFI_CONSOLE_MODE_TEXT 0 -#define EFI_CONSOLE_MODE_GFX 1 - -struct efi_console_control_protocol -{ - efi_status_t (EFIAPI *get_mode)( - struct efi_console_control_protocol *this, int *mode, - char *uga_exists, char *std_in_locked); - efi_status_t (EFIAPI *set_mode)( - struct efi_console_control_protocol *this, int mode); - efi_status_t (EFIAPI *lock_std_in)( - struct efi_console_control_protocol *this, - uint16_t *password); -}; - #define EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID \ EFI_GUID(0x8b843e20, 0x8132, 0x4852, \ 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c) -- cgit v1.1 From e70f8dfa2ce2f47a6eed891016a4c6f289da1cb6 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Fri, 9 Mar 2018 17:43:21 +0100 Subject: efi_loader: Initial EFI_DEVICE_PATH_UTILITIES_PROTOCOL Not complete, but enough for Shell.efi and SCT.efi. We'll implement the rest as needed or once we have SCT running properly so there is a way to validate the interface against the conformance test suite. Initial skeleton written by Leif, and then implementation by Rob. Signed-off-by: Leif Lindholm [Fill initial skeleton] Signed-off-by: Rob Clark [Rebase on v2018.03-rc1] Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/efi_api.h | 29 +++++++++++++++++++++++++++++ include/efi_loader.h | 4 ++++ 2 files changed, 33 insertions(+) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index 8559656..827a192 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -587,6 +587,35 @@ struct efi_device_path_to_text_protocol bool allow_shortcuts); }; +#define EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID \ + EFI_GUID(0x0379be4e, 0xd706, 0x437d, \ + 0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4) + +struct efi_device_path_utilities_protocol { + efi_uintn_t (EFIAPI *get_device_path_size)( + const struct efi_device_path *device_path); + struct efi_device_path *(EFIAPI *duplicate_device_path)( + const struct efi_device_path *device_path); + struct efi_device_path *(EFIAPI *append_device_path)( + const struct efi_device_path *src1, + const struct efi_device_path *src2); + struct efi_device_path *(EFIAPI *append_device_node)( + const struct efi_device_path *device_path, + const struct efi_device_path *device_node); + struct efi_device_path *(EFIAPI *append_device_path_instance)( + const struct efi_device_path *device_path, + const struct efi_device_path *device_path_instance); + struct efi_device_path *(EFIAPI *get_next_device_path_instance)( + struct efi_device_path **device_path_instance, + efi_uintn_t *device_path_instance_size); + bool (EFIAPI *is_device_path_multi_instance)( + const struct efi_device_path *device_path); + struct efi_device_path *(EFIAPI *create_device_node)( + uint8_t node_type, + uint8_t node_sub_type, + uint16_t node_length); +}; + #define EFI_GOP_GUID \ EFI_GUID(0x9042a9de, 0x23dc, 0x4a38, \ 0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a) diff --git a/include/efi_loader.h b/include/efi_loader.h index 07730c3..39d0266 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -83,6 +83,9 @@ extern struct efi_simple_text_output_protocol efi_con_out; extern struct efi_simple_input_interface efi_con_in; extern struct efi_console_control_protocol efi_console_control; extern const struct efi_device_path_to_text_protocol efi_device_path_to_text; +/* implementation of the EFI_DEVICE_PATH_UTILITIES_PROTOCOL */ +extern const struct efi_device_path_utilities_protocol + efi_device_path_utilities; uint16_t *efi_dp_str(struct efi_device_path *dp); @@ -97,6 +100,7 @@ extern const efi_guid_t efi_guid_loaded_image; extern const efi_guid_t efi_guid_device_path_to_text_protocol; extern const efi_guid_t efi_simple_file_system_protocol_guid; extern const efi_guid_t efi_file_info_guid; +extern const efi_guid_t efi_guid_device_path_utilities_protocol; extern unsigned int __efi_runtime_start, __efi_runtime_stop; extern unsigned int __efi_runtime_rel_start, __efi_runtime_rel_stop; -- cgit v1.1 From 7657152bddd131e47390c2b2d6f63d58149d79f1 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 3 Mar 2018 15:28:54 +0100 Subject: efi_loader: efi_smbios_register should have a return value Errors may occur inside efi_smbios_register(). - Return a status code. - Remove unused variables. - Use constants where applicable. Suggested-by: Simon Glass 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 39d0266..c686cd3 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -189,7 +189,7 @@ 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); +efi_status_t efi_smbios_register(void); struct efi_simple_file_system_protocol * efi_fs_from_path(struct efi_device_path *fp); -- cgit v1.1 From 80ea9b09900bc35a21468f5422bd36a345ae7eda Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 3 Mar 2018 15:28:55 +0100 Subject: efi_loader: return efi_status_t from efi_gop_register All initialization routines should return a status code instead of a boolean. Signed-off-by: Heinrich Schuchardt [agraf: Convert warnings to debug() prints] 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 c686cd3..a28a7a1 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -183,7 +183,7 @@ int efi_disk_create_partitions(efi_handle_t parent, struct blk_desc *desc, const char *if_typename, int diskid, const char *pdevname); /* Called by bootefi to make GOP (graphical) interface available */ -int efi_gop_register(void); +efi_status_t 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 */ -- cgit v1.1 From 075d425d652038e67136db61ace4606fcec89475 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 3 Mar 2018 15:28:56 +0100 Subject: efi_loader: return efi_status_t from efi_net_register Consistently return status codes form efi_net_register(). 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 a28a7a1..d2fadc5 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -185,7 +185,7 @@ int efi_disk_create_partitions(efi_handle_t parent, struct blk_desc *desc, /* Called by bootefi to make GOP (graphical) interface available */ efi_status_t efi_gop_register(void); /* Called by bootefi to make the network interface available */ -int efi_net_register(void); +efi_status_t 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 */ -- cgit v1.1 From d7b181d57d0c7080facce755c4b9ff7a22436a48 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 3 Mar 2018 15:28:57 +0100 Subject: efi_loader: consistently return efi_status_t efi_watchdog_register efi_watchdog_register() should always return a status code and not a boolean value. 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 d2fadc5..48fbe7a 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -187,7 +187,7 @@ efi_status_t efi_gop_register(void); /* Called by bootefi to make the network interface available */ efi_status_t efi_net_register(void); /* Called by bootefi to make the watchdog available */ -int efi_watchdog_register(void); +efi_status_t efi_watchdog_register(void); /* Called by bootefi to make SMBIOS tables available */ efi_status_t efi_smbios_register(void); -- cgit v1.1 From 22c793e6a26505fdf80cb5b099142dd6f8f0fff9 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 3 Mar 2018 15:28:59 +0100 Subject: efi_loader: exit status for efi_reset_system_init efi_reset_system_init provides the architecture or board specific initialization of the EFI subsystem. Errors should be caught and signalled by a return code. Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/efi_loader.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index 48fbe7a..3d36943 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -350,7 +350,7 @@ static inline int guidcmp(const efi_guid_t *g1, const efi_guid_t *g2) /* Call this with mmio_ptr as the _pointer_ to a pointer to an MMIO region * to make it available at runtime */ -void efi_add_runtime_mmio(void *mmio_ptr, u64 len); +efi_status_t efi_add_runtime_mmio(void *mmio_ptr, u64 len); /* Boards may provide the functions below to implement RTS functionality */ @@ -358,7 +358,9 @@ void __efi_runtime EFIAPI efi_reset_system( enum efi_reset_type reset_type, efi_status_t reset_status, unsigned long data_size, void *reset_data); -void efi_reset_system_init(void); + +/* Architecture specific initialization of the EFI subsystem */ +efi_status_t efi_reset_system_init(void); efi_status_t __efi_runtime EFIAPI efi_get_time( struct efi_time *time, @@ -392,7 +394,10 @@ void *efi_bootmgr_load(struct efi_device_path **device_path, /* Without CONFIG_EFI_LOADER we don't have a runtime section, stub it out */ #define __efi_runtime_data #define __efi_runtime -static inline void efi_add_runtime_mmio(void *mmio_ptr, u64 len) { } +static inline efi_status_t efi_add_runtime_mmio(void *mmio_ptr, u64 len) +{ + return EFI_SUCCESS; +} /* No loader configured, stub out EFI_ENTRY */ static inline void efi_restore_gd(void) { } -- cgit v1.1 From 14ad49d100a0ba4abafedf8ca6459b699c9d0fa1 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 3 Mar 2018 15:29:00 +0100 Subject: efi_loader: efi_get_time_init should return status code All EFI initialization functions should return a status code. 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 3d36943..b633518 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -365,7 +365,7 @@ efi_status_t efi_reset_system_init(void); efi_status_t __efi_runtime EFIAPI efi_get_time( struct efi_time *time, struct efi_time_cap *capabilities); -void efi_get_time_init(void); +efi_status_t efi_get_time_init(void); #ifdef CONFIG_CMD_BOOTEFI_SELFTEST /* -- cgit v1.1 From bc4f9133edb4baf5f68689a03137bb2c336e2026 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 3 Mar 2018 15:29:03 +0100 Subject: efi_loader: support device tree for bootefi selftest The second argument of the bootefi command should always be usable to specify a device tree. This was missing for bootefi selftest and bootefi hello. Proper error handling is added. 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 b633518..60f84dc 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -96,6 +96,8 @@ extern const efi_guid_t efi_guid_console_control; extern const efi_guid_t efi_guid_device_path; /* GUID of the EFI_DRIVER_BINDING_PROTOCOL */ extern const efi_guid_t efi_guid_driver_binding_protocol; +/* GUID of the device tree table */ +extern const efi_guid_t efi_guid_fdt; extern const efi_guid_t efi_guid_loaded_image; extern const efi_guid_t efi_guid_device_path_to_text_protocol; extern const efi_guid_t efi_simple_file_system_protocol_guid; -- cgit v1.1 From 43bce44262ca7cbb04bb236c50571ca84eb6fdd9 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sun, 18 Feb 2018 15:17:50 +0100 Subject: efi_loader: manage events in a linked list Lift the limit on the number of events by using a linked list. This also allows to have events with type == 0. This patch is based on Rob's patch efi_loader: fix events https://lists.denx.de/pipermail/u-boot/2017-October/309348.html Suggested-by: Rob Clark Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/efi_loader.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index 60f84dc..1a67058 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -150,17 +150,19 @@ struct efi_object { /** * struct efi_event * + * @link: Link to list of all events * @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_time: Period of the timer + * @trigger_next: Next time to trigger the timer * @trigger_type: Type of timer, see efi_set_timer - * @queued: The notification function is queued - * @signaled: The event occurred. The event is in the signaled state. + * @is_queued: The notification function is queued + * @is_signaled: The event occurred. The event is in the signaled state. */ struct efi_event { + struct list_head link; uint32_t type; efi_uintn_t notify_tpl; void (EFIAPI *notify_function)(struct efi_event *event, void *context); @@ -172,7 +174,6 @@ struct efi_event { bool is_signaled; }; - /* This list contains all UEFI objects we know of */ extern struct list_head efi_obj_list; -- cgit v1.1 From a3a28f5f0c39d94733d23e2bbbb53e6e4ddb46c6 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sun, 18 Feb 2018 15:17:51 +0100 Subject: efi_loader: define GUIDS for event groups Event groups are used to signal multiple events at the same time. They are identified by GUIDs. This patch provided the predefined GUIDs of UEFI specification 2.7. Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/efi_api.h | 21 +++++++++++++++++++++ include/efi_loader.h | 10 ++++++++++ 2 files changed, 31 insertions(+) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index 827a192..433594f 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -243,6 +243,27 @@ struct efi_runtime_services { u64 maximum_variable_size); }; +/* EFI event group GUID definitions */ +#define EFI_EVENT_GROUP_EXIT_BOOT_SERVICES \ + EFI_GUID(0x27abf055, 0xb1b8, 0x4c26, 0x80, 0x48, \ + 0x74, 0x8f, 0x37, 0xba, 0xa2, 0xdf) + +#define EFI_EVENT_GROUP_VIRTUAL_ADDRESS_CHANGE \ + EFI_GUID(0x13fa7698, 0xc831, 0x49c7, 0x87, 0xea, \ + 0x8f, 0x43, 0xfc, 0xc2, 0x51, 0x96) + +#define EFI_EVENT_GROUP_MEMORY_MAP_CHANGE \ + EFI_GUID(0x78bee926, 0x692f, 0x48fd, 0x9e, 0xdb, \ + 0x01, 0x42, 0x2e, 0xf0, 0xd7, 0xab) + +#define EFI_EVENT_GROUP_READY_TO_BOOT \ + EFI_GUID(0x7ce88fb3, 0x4bd7, 0x4679, 0x87, 0xa8, \ + 0xa8, 0xd8, 0xde, 0xe5, 0x0d, 0x2b) + +#define EFI_EVENT_GROUP_RESET_SYSTEM \ + EFI_GUID(0x62da6a56, 0x13fb, 0x485a, 0xa8, 0xda, \ + 0xa3, 0xdd, 0x79, 0x12, 0xcb, 0x6b) + /* EFI Configuration Table and GUID definitions */ #define NULL_GUID \ EFI_GUID(0x00000000, 0x0000, 0x0000, 0x00, 0x00, \ diff --git a/include/efi_loader.h b/include/efi_loader.h index 1a67058..8596c0e 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -96,6 +96,16 @@ extern const efi_guid_t efi_guid_console_control; extern const efi_guid_t efi_guid_device_path; /* GUID of the EFI_DRIVER_BINDING_PROTOCOL */ extern const efi_guid_t efi_guid_driver_binding_protocol; +/* event group ExitBootServices() invoked */ +extern const efi_guid_t efi_guid_event_group_exit_boot_services; +/* event group SetVirtualAddressMap() invoked */ +extern const efi_guid_t efi_guid_event_group_virtual_address_change; +/* event group memory map changed */ +extern const efi_guid_t efi_guid_event_group_memory_map_change; +/* event group boot manager about to boot */ +extern const efi_guid_t efi_guid_event_group_ready_to_boot; +/* event group ResetSystem() invoked (before ExitBootServices) */ +extern const efi_guid_t efi_guid_event_group_reset_system; /* GUID of the device tree table */ extern const efi_guid_t efi_guid_fdt; extern const efi_guid_t efi_guid_loaded_image; -- cgit v1.1 From b095f3c85fe08744d6081b98db65768f3421295e Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sun, 18 Feb 2018 15:17:52 +0100 Subject: efi_loader: implement event groups If an event of a group event is signaled all other events of the same group are signaled too. Function efi_signal_event is renamed to efi_queue_event. A new function efi_signal_event is introduced that checks if an event belongs to a group and than signals all events of the group. Event group notifciation is implemented for ExitBootServices, InstallConfigurationTable, and ResetSystem. 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 8596c0e..0df482e 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -165,6 +165,7 @@ struct efi_object { * @notify_tpl: Task priority level of notifications * @nofify_function: Function to call when the event is triggered * @notify_context: Data to be passed to the notify function + * @group: Event group * @trigger_time: Period of the timer * @trigger_next: Next time to trigger the timer * @trigger_type: Type of timer, see efi_set_timer @@ -177,6 +178,7 @@ struct efi_event { efi_uintn_t notify_tpl; void (EFIAPI *notify_function)(struct efi_event *event, void *context); void *notify_context; + const efi_guid_t *group; u64 trigger_next; u64 trigger_time; enum efi_timer_delay trigger_type; @@ -186,6 +188,8 @@ struct efi_event { /* This list contains all UEFI objects we know of */ extern struct list_head efi_obj_list; +/* List of all events */ +extern struct list_head efi_events; /* Called by bootefi to make console interface available */ int efi_console_register(void); @@ -252,7 +256,8 @@ efi_status_t efi_create_event(uint32_t type, efi_uintn_t notify_tpl, void (EFIAPI *notify_function) ( struct efi_event *event, void *context), - void *notify_context, struct efi_event **event); + void *notify_context, efi_guid_t *group, + struct efi_event **event); /* Call this to set a timer */ efi_status_t efi_set_timer(struct efi_event *event, enum efi_timer_delay type, uint64_t trigger_time); -- cgit v1.1 From 0e0a3ceb509b19af55c5064607d9057ec7d8c1c4 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Wed, 7 Feb 2018 22:14:22 +0100 Subject: efi_loader: implement missing bit blit operations in gop With the patch all block image transfer operations of the EFI_GRAPHICS_OUTPUT_PROTOCOL are supported. Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/efi_api.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index 433594f..167c44e 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -665,6 +665,13 @@ struct efi_gop_mode unsigned long fb_size; }; +struct efi_gop_pixel { + u8 blue; + u8 green; + u8 red; + u8 reserved; +}; + #define EFI_BLT_VIDEO_FILL 0 #define EFI_BLT_VIDEO_TO_BLT_BUFFER 1 #define EFI_BLT_BUFFER_TO_VIDEO 2 @@ -676,7 +683,8 @@ struct efi_gop 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, + efi_status_t (EFIAPI *blt)(struct efi_gop *this, + struct efi_gop_pixel *buffer, u32 operation, efi_uintn_t sx, efi_uintn_t sy, efi_uintn_t dx, efi_uintn_t dy, efi_uintn_t width, -- cgit v1.1 From 482fc90c0a93bdab8473bbd4c8d63732ce888bba Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Tue, 6 Feb 2018 22:00:22 +0100 Subject: efi_loader: add missing EFI_RESET_PLATFORM_SPECIFIC EFI_RESET_PLATFORM_SPECIFIC is one of the values that can be used for the EFI service ResetSystem. The missing definition is added. The value has to handled in efi_reset_system(). Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/efi_api.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index 167c44e..28de93a 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -180,7 +180,8 @@ struct efi_boot_services { enum efi_reset_type { EFI_RESET_COLD = 0, EFI_RESET_WARM = 1, - EFI_RESET_SHUTDOWN = 2 + EFI_RESET_SHUTDOWN = 2, + EFI_RESET_PLATFORM_SPECIFIC = 3, }; /* EFI Runtime Services table */ -- cgit v1.1 From e2742358661137b60eccd2e80b6835b58d8c5763 Mon Sep 17 00:00:00 2001 From: Patrick Wildt Date: Tue, 27 Mar 2018 14:23:20 +0200 Subject: efi_loader: complete efi_pxe_mode struct definition The efi_pxe_mode struct which represents the PXE_BASE_CODE_PROTOCOL Replace the placeholder paddings in the efi_pxe_mode struct with the actual fields as defined in UEFI's PXE Base Code Protocol. Since our efi_ip_address is a simple char array set a specific alignment to the efi_ip_address fields, as expected by the UEFI spec. Signed-off-by: Patrick Wildt [agraf: s/pxe_discovervalid/pxe_discover_valid] Signed-off-by: Alexander Graf --- include/efi_api.h | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index 28de93a..d956aee 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -703,7 +703,7 @@ struct efi_mac_address { struct efi_ip_address { u8 ip_addr[16]; -}; +} __attribute__((aligned(4))); enum efi_simple_network_state { EFI_NETWORK_STOPPED, @@ -797,7 +797,28 @@ struct efi_pxe_packet { struct efi_pxe_mode { - u8 unused[52]; + u8 started; + u8 ipv6_available; + u8 ipv6_supported; + u8 using_ipv6; + u8 bis_supported; + u8 bis_detected; + u8 auto_arp; + u8 send_guid; + u8 dhcp_discover_valid; + u8 dhcp_ack_received; + u8 proxy_offer_received; + u8 pxe_discover_valid; + u8 pxe_reply_received; + u8 pxe_bis_reply_received; + u8 icmp_error_received; + u8 tftp_error_received; + u8 make_callbacks; + u8 ttl; + u8 tos; + u8 pad; + struct efi_ip_address station_ip; + struct efi_ip_address subnet_mask; struct efi_pxe_packet dhcp_discover; struct efi_pxe_packet dhcp_ack; struct efi_pxe_packet proxy_offer; -- cgit v1.1 From 7fb96a10b31953cde698326a61e963ba9df1dc1f Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Tue, 3 Apr 2018 22:29:30 +0200 Subject: efi_loader: use efi_uintn_t for LoadImage We generally use efi_uintn_t where the UEFI spec uses UINTN. Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/efi_api.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index d956aee..d9a69db 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -107,7 +107,7 @@ struct efi_boot_services { efi_status_t (EFIAPI *load_image)(bool boot_policiy, efi_handle_t parent_image, struct efi_device_path *file_path, void *source_buffer, - unsigned long source_size, efi_handle_t *image); + efi_uintn_t source_size, efi_handle_t *image); efi_status_t (EFIAPI *start_image)(efi_handle_t handle, unsigned long *exitdata_size, s16 **exitdata); -- cgit v1.1 From 84b40b40ad9b95b4680766597c866b604147144c Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Tue, 3 Apr 2018 22:29:31 +0200 Subject: efi_loader: save image relocation address and size For analyzing crash output the relocation address and size are needed. Save them in the loaded image info. Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/efi_api.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index d9a69db..2be470b 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -331,6 +331,8 @@ struct efi_loaded_image { /* Below are efi loader private fields */ #ifdef CONFIG_EFI_LOADER + void *reloc_base; + aligned_u64 reloc_size; efi_status_t exit_status; struct jmp_buf_data exit_jmp; #endif -- cgit v1.1 From 43dace5d897ef1ac5eadaf906d77f671e018116f Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Tue, 3 Apr 2018 22:29:33 +0200 Subject: efi_loader: correct types for EFI_LOADED_IMAGE_PROTOCOL We should not use void * but specific types for * device_handle * file_path Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/efi_api.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index 2be470b..f5bb6ec 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -318,8 +318,8 @@ struct efi_loaded_image { u32 revision; void *parent_handle; struct efi_system_table *system_table; - void *device_handle; - void *file_path; + efi_handle_t device_handle; + struct efi_device_path *file_path; void *reserved; u32 load_options_size; void *load_options; -- cgit v1.1 From b6dd57773719bfcea6a295973c349b7842870337 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Tue, 3 Apr 2018 22:37:11 +0200 Subject: efi_loader: use correct types in EFI_FILE_PROTOCOL In the EFI_FILE_PROTOCOL buffer sizes and positions are passed as UINTN and not as u64. Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/efi_api.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index f5bb6ec..396f45e 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -858,17 +858,19 @@ struct efi_file_handle { efi_status_t (EFIAPI *close)(struct efi_file_handle *file); efi_status_t (EFIAPI *delete)(struct efi_file_handle *file); efi_status_t (EFIAPI *read)(struct efi_file_handle *file, - u64 *buffer_size, void *buffer); + efi_uintn_t *buffer_size, void *buffer); efi_status_t (EFIAPI *write)(struct efi_file_handle *file, - u64 *buffer_size, void *buffer); + efi_uintn_t *buffer_size, void *buffer); efi_status_t (EFIAPI *getpos)(struct efi_file_handle *file, - u64 *pos); + efi_uintn_t *pos); efi_status_t (EFIAPI *setpos)(struct efi_file_handle *file, - u64 pos); + efi_uintn_t pos); efi_status_t (EFIAPI *getinfo)(struct efi_file_handle *file, - efi_guid_t *info_type, u64 *buffer_size, void *buffer); + efi_guid_t *info_type, efi_uintn_t *buffer_size, + void *buffer); efi_status_t (EFIAPI *setinfo)(struct efi_file_handle *file, - efi_guid_t *info_type, u64 buffer_size, void *buffer); + efi_guid_t *info_type, efi_uintn_t buffer_size, + void *buffer); efi_status_t (EFIAPI *flush)(struct efi_file_handle *file); }; -- cgit v1.1 From 9c9021e24571505d76969d8fd37b3b5e06ad2590 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Wed, 4 Apr 2018 15:42:09 +0200 Subject: efi_loader: use const for GUIDs in the EFI_FILE_PROTOCOL Use const efi_guid_t* when passing GUIDs. Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/efi_api.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index 396f45e..8af466a 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -866,10 +866,10 @@ struct efi_file_handle { efi_status_t (EFIAPI *setpos)(struct efi_file_handle *file, efi_uintn_t pos); efi_status_t (EFIAPI *getinfo)(struct efi_file_handle *file, - efi_guid_t *info_type, efi_uintn_t *buffer_size, + const efi_guid_t *info_type, efi_uintn_t *buffer_size, void *buffer); efi_status_t (EFIAPI *setinfo)(struct efi_file_handle *file, - efi_guid_t *info_type, efi_uintn_t buffer_size, + const efi_guid_t *info_type, efi_uintn_t buffer_size, void *buffer); efi_status_t (EFIAPI *flush)(struct efi_file_handle *file); }; -- cgit v1.1 From c412166de28e7f7722b42a4c4c5e637da2d570ee Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Wed, 4 Apr 2018 15:42:10 +0200 Subject: efi_loader: ascii2unicode(): add trailing \0 When converting an ASCII string to UTF-16 don't forget to copy the trailing \0. Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/efi_loader.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index 0df482e..21e6692 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -352,6 +352,7 @@ static inline void ascii2unicode(u16 *unicode, const char *ascii) { while (*ascii) *(unicode++) = *(ascii++); + *unicode = 0; } static inline int guidcmp(const efi_guid_t *g1, const efi_guid_t *g2) -- cgit v1.1 From 9e6835e6baab3d56e1bb2d4b96ee80f98e2196e7 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Wed, 4 Apr 2018 15:42:11 +0200 Subject: efi_loader: implement EFI_FILE_SYSTEM_INFO Implement the information type EFI_FILE_SYSTEM_INFO in the service GetInfo() of the EFI_FILE_PROTOCOL. The volume label is not available in U-Boot. As a work-around use the partition name instead. Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/efi_api.h | 13 +++++++++++++ include/efi_loader.h | 2 ++ 2 files changed, 15 insertions(+) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index 8af466a..ae93061 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -889,6 +889,10 @@ struct efi_simple_file_system_protocol { EFI_GUID(0x9576e92, 0x6d3f, 0x11d2, \ 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b) +#define EFI_FILE_SYSTEM_INFO_GUID \ + EFI_GUID(0x09576e93, 0x6d3f, 0x11d2, \ + 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b) + #define EFI_FILE_MODE_READ 0x0000000000000001 #define EFI_FILE_MODE_WRITE 0x0000000000000002 #define EFI_FILE_MODE_CREATE 0x8000000000000000 @@ -912,6 +916,15 @@ struct efi_file_info { s16 file_name[0]; }; +struct efi_file_system_info { + u64 size; + u8 read_only; + u64 volume_size; + u64 free_space; + u32 block_size; + u16 volume_label[0]; +}; + #define EFI_DRIVER_BINDING_PROTOCOL_GUID \ EFI_GUID(0x18a031ab, 0xb443, 0x4d1a,\ 0xa5, 0xc0, 0x0c, 0x09, 0x26, 0x1e, 0x9f, 0x71) diff --git a/include/efi_loader.h b/include/efi_loader.h index 21e6692..f2942fb 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -112,6 +112,8 @@ extern const efi_guid_t efi_guid_loaded_image; extern const efi_guid_t efi_guid_device_path_to_text_protocol; extern const efi_guid_t efi_simple_file_system_protocol_guid; extern const efi_guid_t efi_file_info_guid; +/* GUID for file system information */ +extern const efi_guid_t efi_file_system_info_guid; extern const efi_guid_t efi_guid_device_path_utilities_protocol; extern unsigned int __efi_runtime_start, __efi_runtime_stop; -- cgit v1.1 From c9a63f44b526696a60e275087d79fe709f65f48b Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 5 Apr 2018 11:56:21 +0200 Subject: efi_loader: new functions to print loaded image information Introduce functions to print information about loaded images. If we want to analyze an exception in an EFI image we need the offset between the PC and the start of the loaded image. With efi_print_image_info() we can print the necessary information for a single image, e.g. UEFI image [0xbffe6000:0xbffe631f] pc=0x138 '/\snp.efi' efi_print_image_infos() provides output for all loaded images. Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/efi_loader.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index f2942fb..17f9d3d 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -308,6 +308,10 @@ efi_status_t efi_setup_loaded_image( struct efi_device_path *file_path); efi_status_t efi_load_image_from_path(struct efi_device_path *file_path, void **buffer); +/* Print information about a loaded image */ +efi_status_t efi_print_image_info(struct efi_loaded_image *image, void *pc); +/* Print information about all loaded images */ +void efi_print_image_infos(void *pc); #ifdef CONFIG_EFI_LOADER_BOUNCE_BUFFER extern void *efi_bounce_buffer; @@ -425,6 +429,7 @@ static inline void efi_restore_gd(void) { } 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) { } +static inline void efi_print_image_infos(void *pc) { } #endif /* CONFIG_EFI_LOADER && !CONFIG_SPL_BUILD */ -- cgit v1.1 From 61a5ced6ad9376a0755ea2a920667e3a9072990c Mon Sep 17 00:00:00 2001 From: Ivan Gorinov Date: Thu, 5 Apr 2018 18:32:06 -0700 Subject: efi_loader: Check machine type in the image header Check FileHeader.Machine to make sure the EFI executable image is built for the same architecture. For example, 32-bit U-Boot on x86 will print an error message instead of loading an x86_64 image and crashing. Signed-off-by: Ivan Gorinov Signed-off-by: Alexander Graf --- include/pe.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/pe.h b/include/pe.h index c3a19ce..e7845bb 100644 --- a/include/pe.h +++ b/include/pe.h @@ -38,11 +38,15 @@ typedef struct _IMAGE_DOS_HEADER { #define IMAGE_DOS_SIGNATURE 0x5A4D /* MZ */ #define IMAGE_NT_SIGNATURE 0x00004550 /* PE00 */ +#define IMAGE_FILE_MACHINE_I386 0x014c #define IMAGE_FILE_MACHINE_ARM 0x01c0 #define IMAGE_FILE_MACHINE_THUMB 0x01c2 #define IMAGE_FILE_MACHINE_ARMNT 0x01c4 #define IMAGE_FILE_MACHINE_AMD64 0x8664 #define IMAGE_FILE_MACHINE_ARM64 0xaa64 +#define IMAGE_FILE_MACHINE_RISCV32 0x5032 +#define IMAGE_FILE_MACHINE_RISCV64 0x5064 + #define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b #define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b #define IMAGE_SUBSYSTEM_EFI_APPLICATION 10 -- cgit v1.1