From 842a8e434e48e3d4d7a862c4a1676a698aa0954d Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sun, 27 Aug 2017 00:51:04 +0200 Subject: efi_loader: support 16 protocols per efi_object 8 protocols per efi_object is insufficient for iPXE. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass Reviewed-by: Rob Clark Signed-off-by: Alexander Graf --- include/efi_loader.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index 2f081f8996..90db790001 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -112,8 +112,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 8 "protocols" an object can be accessed through */ - struct efi_handler protocols[8]; + /* We support up to 16 "protocols" an object can be accessed through */ + struct efi_handler protocols[16]; /* The object spawner can either use this for data or as identifier */ void *handle; }; -- cgit From e190e8972faf4d5b09e2a92fefc54a1832fd67da Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Wed, 4 Oct 2017 15:03:24 +0200 Subject: efi_loader: use type bool for event states Queued and signaled describe boolean states of events. So let's use type bool and rename the structure members to is_queued and is_signaled. Update the comments for is_queued and is_signaled. Reported-by: Simon Glass Signed-off-by: Heinrich Schuchardt Reviewed-by: Rob Clark Reviewed-by: Rob Clark Signed-off-by: Alexander Graf --- include/efi_loader.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index 90db790001..e1179b7dcd 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -136,8 +136,8 @@ struct efi_object { * @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 - * @queued: The notification functionis queued - * @signaled: The event occured + * @queued: The notification function is queued + * @signaled: The event occurred. The event is in the signaled state. */ struct efi_event { uint32_t type; @@ -147,8 +147,8 @@ struct efi_event { u64 trigger_next; u64 trigger_time; enum efi_timer_delay trigger_type; - int queued; - int signaled; + bool is_queued; + bool is_signaled; }; -- cgit From e67e7249c8000d72b4c4b985fdeb3e103d65aa9e Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Wed, 4 Oct 2017 15:31:26 +0200 Subject: efi_selftest: make tests easier to read Rename counter to more illustrative names. Update notification function description. Simplify notification function. Add comment for arbitrary non-zero value. Document @return. Use constants for return values of setup, execute, teardown. Reported-by: Simon Glass Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass Signed-off-by: Alexander Graf --- include/efi_selftest.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/efi_selftest.h b/include/efi_selftest.h index 76304a2b2a..beb662d4e1 100644 --- a/include/efi_selftest.h +++ b/include/efi_selftest.h @@ -14,6 +14,9 @@ #include #include +#define EFI_ST_SUCCESS 0 +#define EFI_ST_FAILURE 1 + /* * Prints an error message. * -- cgit From fc05a9590689b70fffdb9914e9867ea53fd579fa Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 5 Oct 2017 16:35:52 +0200 Subject: efi_loader: parameters of CopyMem and SetMem The UEFI spec defines the length parameters of CopyMem and SetMem as UINTN. We should size_t here. The source buffer of CopyMem should be marked as const. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass Signed-off-by: Alexander Graf --- include/efi_api.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index c3b9032a48..0b1a383e61 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -156,10 +156,9 @@ struct efi_boot_services { void *handle, ...); efi_status_t (EFIAPI *calculate_crc32)(void *data, unsigned long data_size, uint32_t *crc32); - void (EFIAPI *copy_mem)(void *destination, void *source, - unsigned long length); - void (EFIAPI *set_mem)(void *buffer, unsigned long size, - uint8_t value); + void (EFIAPI *copy_mem)(void *destination, const void *source, + size_t length); + void (EFIAPI *set_mem)(void *buffer, size_t size, uint8_t value); void *create_event_ex; }; -- cgit From 5a9682d0ddd9328eb581b18a8b263c3834943942 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 5 Oct 2017 16:35:53 +0200 Subject: efi_loader: pass GUIDs as const efi_guid_t * We need to call some boottime services internally. Our GUIDs are stored as const efi_guid_t *. The boottime services never change GUIDs. So we can define the parameters as const efi_guid_t *. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass Signed-off-by: Alexander Graf --- include/efi_api.h | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index 0b1a383e61..aa4306aac9 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -77,24 +77,25 @@ struct efi_boot_services { efi_status_t (EFIAPI *check_event)(struct efi_event *event); #define EFI_NATIVE_INTERFACE 0x00000000 efi_status_t (EFIAPI *install_protocol_interface)( - void **handle, efi_guid_t *protocol, + void **handle, const efi_guid_t *protocol, int protocol_interface_type, void *protocol_interface); efi_status_t (EFIAPI *reinstall_protocol_interface)( - void *handle, efi_guid_t *protocol, + void *handle, const efi_guid_t *protocol, void *old_interface, void *new_interface); efi_status_t (EFIAPI *uninstall_protocol_interface)(void *handle, - efi_guid_t *protocol, void *protocol_interface); - efi_status_t (EFIAPI *handle_protocol)(efi_handle_t, efi_guid_t *, - void **); + const efi_guid_t *protocol, void *protocol_interface); + efi_status_t (EFIAPI *handle_protocol)(efi_handle_t, + const efi_guid_t *protocol, + void **protocol_interface); void *reserved; efi_status_t (EFIAPI *register_protocol_notify)( - efi_guid_t *protocol, struct efi_event *event, + const efi_guid_t *protocol, struct efi_event *event, void **registration); efi_status_t (EFIAPI *locate_handle)( enum efi_locate_search_type search_type, - efi_guid_t *protocol, void *search_key, + const efi_guid_t *protocol, void *search_key, unsigned long *buffer_size, efi_handle_t *buffer); - efi_status_t (EFIAPI *locate_device_path)(efi_guid_t *protocol, + efi_status_t (EFIAPI *locate_device_path)(const efi_guid_t *protocol, struct efi_device_path **device_path, efi_handle_t *device); efi_status_t (EFIAPI *install_configuration_table)( @@ -131,14 +132,14 @@ struct efi_boot_services { #define EFI_OPEN_PROTOCOL_BY_DRIVER 0x00000010 #define EFI_OPEN_PROTOCOL_EXCLUSIVE 0x00000020 efi_status_t (EFIAPI *open_protocol)(efi_handle_t handle, - efi_guid_t *protocol, void **interface, + const efi_guid_t *protocol, void **interface, efi_handle_t agent_handle, efi_handle_t controller_handle, u32 attributes); efi_status_t (EFIAPI *close_protocol)(void *handle, - efi_guid_t *protocol, void *agent_handle, + const efi_guid_t *protocol, void *agent_handle, void *controller_handle); efi_status_t(EFIAPI *open_protocol_information)(efi_handle_t handle, - efi_guid_t *protocol, + const efi_guid_t *protocol, struct efi_open_protocol_info_entry **entry_buffer, unsigned long *entry_count); efi_status_t (EFIAPI *protocols_per_handle)(efi_handle_t handle, @@ -146,9 +147,9 @@ struct efi_boot_services { unsigned long *protocols_buffer_count); efi_status_t (EFIAPI *locate_handle_buffer) ( enum efi_locate_search_type search_type, - efi_guid_t *protocol, void *search_key, + const efi_guid_t *protocol, void *search_key, unsigned long *no_handles, efi_handle_t **buffer); - efi_status_t (EFIAPI *locate_protocol)(efi_guid_t *protocol, + efi_status_t (EFIAPI *locate_protocol)(const efi_guid_t *protocol, void *registration, void **protocol_interface); efi_status_t (EFIAPI *install_multiple_protocol_interfaces)( void **handle, ...); -- cgit From ca379e1bf16e59841f15ed34088eb1362bf2bd35 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 5 Oct 2017 16:35:54 +0200 Subject: efi_loader: wrong type in wait_for_event The UEFI spec defines parameter index of WaitForEvent as UINTN*. So we should use size_t here. I deliberately do not use UINTN because I hold a following patch that will eliminate UINTN because uppercase types to not match the U-Boot coding style. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass 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 aa4306aac9..c44dc9d0cb 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -71,7 +71,7 @@ struct efi_boot_services { 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, unsigned long *index); + struct efi_event **event, size_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); -- cgit From 84a12ce64e08257d9e8eb7b9e7c2b232a2a35ebf Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 5 Oct 2017 16:35:55 +0200 Subject: efi_loader: incorrect definition of EFI_SIMPLE_NETWORK_PROTOCOL WaitForPacket is an event and not a function pointer. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass 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 c44dc9d0cb..308baeec49 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -633,7 +633,7 @@ struct efi_simple_network ulong *header_size, ulong *buffer_size, void *buffer, struct efi_mac_address *src_addr, struct efi_mac_address *dest_addr, u16 *protocol); - void (EFIAPI *waitforpacket)(void); + struct efi_event *wait_for_packet; struct efi_simple_network_mode *mode; }; -- cgit From 2e0864a47e223d1581acfb49e4ec2f68615da3dc Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 5 Oct 2017 16:35:56 +0200 Subject: efi_loader: correct bits of receive_filters bit mask Remove extraneous commas. Add comment. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass Signed-off-by: Alexander Graf --- include/efi_api.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index 308baeec49..8c227ce703 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -593,11 +593,12 @@ struct efi_simple_network_mode { u8 media_present; }; -#define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST 0x01, -#define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST 0x02, -#define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST 0x04, -#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS 0x08, -#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10, +/* receive_filters bit mask */ +#define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST 0x01 +#define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST 0x02 +#define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST 0x04 +#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS 0x08 +#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10 struct efi_simple_network { -- cgit From bdecf974f168af49f5deb2d325e7ad8f3ad4a52e Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 5 Oct 2017 16:35:57 +0200 Subject: efi_loader: fill simple network protocol revision Provide the simple network protocol revision. This revision number could be used to identify backwards compatible enhancements of the protocol. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass Signed-off-by: Alexander Graf --- include/efi_api.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index 8c227ce703..2f31464cb3 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -600,6 +600,9 @@ struct efi_simple_network_mode { #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS 0x08 #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10 +/* revision of the simple network protocol */ +#define EFI_SIMPLE_NETWORK_PROTOCOL_REVISION 0x00010000 + struct efi_simple_network { u64 revision; -- cgit From 891b3d9051690d0ba39da4eda1d15773ebfee2b6 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 5 Oct 2017 16:36:02 +0200 Subject: efi_loader: fix efi_net_get_status The returned interrupt status was wrong. As out transmit buffer is empty we need to always set EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT. When we have received a packet we need to set EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT. Furthermore we should call efi_timer_check() to handle events. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass Signed-off-by: Alexander Graf --- include/efi_api.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index 2f31464cb3..1f349db246 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -600,6 +600,12 @@ struct efi_simple_network_mode { #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS 0x08 #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10 +/* interrupt status bit mask */ +#define EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT 0x01 +#define EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT 0x02 +#define EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT 0x04 +#define EFI_SIMPLE_NETWORK_SOFTWARE_INTERRUPT 0x08 + /* revision of the simple network protocol */ #define EFI_SIMPLE_NETWORK_PROTOCOL_REVISION 0x00010000 -- cgit From 8db174d651e3f92ddb9660f1f8b8755b902c3c11 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 5 Oct 2017 16:36:03 +0200 Subject: efi_loader: size fields in SimpleNetworkProtocol The size fields in the Simple Network Protocol are all UINTN in the UEFI spec. So use size_t. Provide a function description of the receive function. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass 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 1f349db246..a9a6494afe 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -636,11 +636,11 @@ struct efi_simple_network efi_status_t (EFIAPI *get_status)(struct efi_simple_network *this, u32 *int_status, void **txbuf); efi_status_t (EFIAPI *transmit)(struct efi_simple_network *this, - ulong header_size, ulong buffer_size, void *buffer, + size_t header_size, size_t buffer_size, void *buffer, struct efi_mac_address *src_addr, struct efi_mac_address *dest_addr, u16 *protocol); efi_status_t (EFIAPI *receive)(struct efi_simple_network *this, - ulong *header_size, ulong *buffer_size, void *buffer, + size_t *header_size, size_t *buffer_size, void *buffer, struct efi_mac_address *src_addr, struct efi_mac_address *dest_addr, u16 *protocol); struct efi_event *wait_for_packet; -- cgit From 9820c2f30c028f40d22fdc892799fd7088f23bc7 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 5 Oct 2017 16:36:05 +0200 Subject: efi_selftest: correct definition of efi_st_error Enclose definition in parantheses to allow using efi_st_error like a void function. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass Signed-off-by: Alexander Graf --- include/efi_selftest.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/efi_selftest.h b/include/efi_selftest.h index beb662d4e1..2f0992f06e 100644 --- a/include/efi_selftest.h +++ b/include/efi_selftest.h @@ -23,8 +23,8 @@ * @... format string followed by fields to print */ #define efi_st_error(...) \ - efi_st_printf("%s(%u):\nERROR: ", __FILE__, __LINE__); \ - efi_st_printf(__VA_ARGS__) \ + (efi_st_printf("%s(%u):\nERROR: ", __FILE__, __LINE__), \ + efi_st_printf(__VA_ARGS__)) \ /* * A test may be setup and executed at boottime, -- cgit From 5ca23ed5bc63832baa24a6107537fdd229c458ae Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 5 Oct 2017 16:36:07 +0200 Subject: efi_loader: supply EFI network test This patch provides an EFI application to check the correct function of the Simple Network Protocol implementation. It sends a DHCP request and analyzes the DHCP offer. Different error conditions including a 10s timeout are checked. A successful execution will look like this: => bootefi nettest Scanning disk ide.blk#0... Found 1 disks WARNING: Invalid device tree, expect boot to fail Network test DHCP Discover DHCP reply received from 192.168.76.2 (52:55:c0:a8:4c:02) as broadcast message. OK. The test was completed successfully. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass Signed-off-by: Alexander Graf --- include/efi_selftest.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include') diff --git a/include/efi_selftest.h b/include/efi_selftest.h index 2f0992f06e..7ec42a0406 100644 --- a/include/efi_selftest.h +++ b/include/efi_selftest.h @@ -60,6 +60,17 @@ void efi_st_exit_boot_services(void); void efi_st_printf(const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2))); +/* + * Compare memory. + * We cannot use lib/string.c due to different CFLAGS values. + * + * @buf1: first buffer + * @buf2: second buffer + * @length: number of bytes to compare + * @return: 0 if both buffers contain the same bytes + */ +int efi_st_memcmp(const void *buf1, const void *buf2, size_t length); + /* * Reads an Unicode character from the input device. * -- cgit From 984f251feeb932cfe551cbd62c5f7f5e073b6cc3 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Mon, 9 Oct 2017 21:09:05 +0200 Subject: efi_loader: MAX_UTF8_PER_UTF16 = 3 The constant MAX_UTF8_PER_UTF16 is used to calculate required memory when converting from UTF-16 to UTF-8. If this constant is too big we waste memory. A code point encoded by one UTF-16 symbol is converted to a maximum of three UTF-8 symbols, e.g. 0xffff could be encoded as 0xef 0xbf 0xbf. The first byte carries four bits, the second and third byte carry six bits each. A code point encoded by two UTF-16 symbols is converted to four UTF-8 symbols. So in this case we need a maximum of two UTF-8 symbols per UTF-16 symbol. As the overall maximum is three UTF-8 symobls per UTF-16 symbol we need MAX_UTF8_PER_UTF16 = 3. Fixes: 78178bb0c9d lib: add some utf16 handling helpers Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/charset.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/charset.h b/include/charset.h index 39279f746a..37a3278499 100644 --- a/include/charset.h +++ b/include/charset.h @@ -9,7 +9,7 @@ #ifndef __CHARSET_H_ #define __CHARSET_H_ -#define MAX_UTF8_PER_UTF16 4 +#define MAX_UTF8_PER_UTF16 3 /** * utf16_strlen() - Get the length of an utf16 string @@ -52,7 +52,7 @@ uint16_t *utf16_strdup(const uint16_t *s); * Converts 'size' characters of the utf16 string 'src' to utf8 * written to the 'dest' buffer. * - * NOTE that a single utf16 character can generate up to 4 utf8 + * NOTE that a single utf16 character can generate up to 3 utf8 * characters. See MAX_UTF8_PER_UTF16. * * @dest the destination buffer to write the utf8 characters -- cgit From bf19273e81eb5e23c9bc14c3881f92a120565561 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Tue, 10 Oct 2017 08:23:06 -0400 Subject: efi_loader: Add mem-mapped for fallback When we don't have a real device/image path, such as 'bootefi hello', construct a mem-mapped device-path. This fixes 'bootefi hello' after devicepath refactoring. Fixes: 95c5553ea2 ("efi_loader: refactor boot device and loaded_image handling") Signed-off-by: Rob Clark Acked-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/efi_api.h | 8 ++++++++ include/efi_loader.h | 3 +++ 2 files changed, 11 insertions(+) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index a9a6494afe..94c15b279a 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -297,8 +297,16 @@ struct efi_mac_addr { } __packed; #define DEVICE_PATH_TYPE_HARDWARE_DEVICE 0x01 +# define DEVICE_PATH_SUB_TYPE_MEMORY 0x03 # define DEVICE_PATH_SUB_TYPE_VENDOR 0x04 +struct efi_device_path_memory { + struct efi_device_path dp; + u32 memory_type; + u64 start_address; + u64 end_address; +} __packed; + struct efi_device_path_vendor { struct efi_device_path dp; efi_guid_t guid; diff --git a/include/efi_loader.h b/include/efi_loader.h index e1179b7dcd..1b92edbd77 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -259,6 +259,9 @@ struct efi_device_path *efi_dp_from_part(struct blk_desc *desc, int part); struct efi_device_path *efi_dp_from_file(struct blk_desc *desc, int part, const char *path); struct efi_device_path *efi_dp_from_eth(void); +struct efi_device_path *efi_dp_from_mem(uint32_t mem_type, + uint64_t start_address, + uint64_t end_address); void efi_dp_split_file_path(struct efi_device_path *full_path, struct efi_device_path **device_path, struct efi_device_path **file_path); -- cgit From 2d5dc2a52d412964031c9920d354ad5bdc91c654 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Tue, 10 Oct 2017 08:23:01 -0400 Subject: efi_loader: console support for color attributes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Shell.efi uses this, and supporting color attributes makes things look nicer. Map the EFI fg/bg color attributes to ANSI escape sequences. Not all colors have a perfect match, but spec just says "Devices supporting a different number of text colors are required to emulate the above colors to the best of the device’s capabilities". Signed-off-by: Rob Clark Tested-by: Heinrich Schuchardt Reviewed-by: Alexander Graf [agraf: s/unsigned/unsigned int/] Signed-off-by: Alexander Graf --- include/efi_api.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index 94c15b279a..fcd7483ab2 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -433,6 +433,39 @@ struct simple_text_output_mode { EFI_GUID(0x387477c2, 0x69c7, 0x11d2, \ 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b) +#define EFI_BLACK 0x00 +#define EFI_BLUE 0x01 +#define EFI_GREEN 0x02 +#define EFI_CYAN 0x03 +#define EFI_RED 0x04 +#define EFI_MAGENTA 0x05 +#define EFI_BROWN 0x06 +#define EFI_LIGHTGRAY 0x07 +#define EFI_BRIGHT 0x08 +#define EFI_DARKGRAY 0x08 +#define EFI_LIGHTBLUE 0x09 +#define EFI_LIGHTGREEN 0x0a +#define EFI_LIGHTCYAN 0x0b +#define EFI_LIGHTRED 0x0c +#define EFI_LIGHTMAGENTA 0x0d +#define EFI_YELLOW 0x0e +#define EFI_WHITE 0x0f +#define EFI_BACKGROUND_BLACK 0x00 +#define EFI_BACKGROUND_BLUE 0x10 +#define EFI_BACKGROUND_GREEN 0x20 +#define EFI_BACKGROUND_CYAN 0x30 +#define EFI_BACKGROUND_RED 0x40 +#define EFI_BACKGROUND_MAGENTA 0x50 +#define EFI_BACKGROUND_BROWN 0x60 +#define EFI_BACKGROUND_LIGHTGRAY 0x70 + +/* extract foreground color from EFI attribute */ +#define EFI_ATTR_FG(attr) ((attr) & 0x07) +/* treat high bit of FG as bright/bold (similar to edk2) */ +#define EFI_ATTR_BOLD(attr) (((attr) >> 3) & 0x01) +/* extract background color from EFI attribute */ +#define EFI_ATTR_BG(attr) (((attr) >> 4) & 0x7) + struct efi_simple_text_output_protocol { void *reset; efi_status_t (EFIAPI *output_string)( -- cgit