summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2017-10-13 13:53:58 (GMT)
committerTom Rini <trini@konsulko.com>2017-10-13 13:53:58 (GMT)
commitf855a7bc12dc3bdf83905b4c72a6d795ee8d8ee5 (patch)
tree91c1ba0f537f66cf3f5b5c50f5399541bfe1fa85 /include
parent26f9184e094541b672f83f23652e2e737d5d0729 (diff)
parentabe994633b2ad56c5eea87c9253873f41dab477d (diff)
downloadu-boot-f855a7bc12dc3bdf83905b4c72a6d795ee8d8ee5.tar.xz
Merge tag 'signed-efi-next' of git://github.com/agraf/u-boot
Patch queue for efi - 2017-10-13 This is the second batch of amazing improvements for efi_loader in 2017.11: - New self tests to verify our own code - A few bug fixes - colored text support - event and SNP improvements, should get us close to iPXE working
Diffstat (limited to 'include')
-rw-r--r--include/charset.h4
-rw-r--r--include/efi_api.h103
-rw-r--r--include/efi_loader.h15
-rw-r--r--include/efi_selftest.h18
4 files changed, 104 insertions, 36 deletions
diff --git a/include/charset.h b/include/charset.h
index 39279f7..37a3278 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
diff --git a/include/efi_api.h b/include/efi_api.h
index c3b9032..fcd7483 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -71,30 +71,31 @@ 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);
#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, ...);
@@ -156,10 +157,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;
};
@@ -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;
@@ -425,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)(
@@ -593,11 +634,21 @@ 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
+
+/* 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
struct efi_simple_network
{
@@ -626,14 +677,14 @@ 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);
- void (EFIAPI *waitforpacket)(void);
+ struct efi_event *wait_for_packet;
struct efi_simple_network_mode *mode;
};
diff --git a/include/efi_loader.h b/include/efi_loader.h
index 2f081f8..1b92edb 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;
};
@@ -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;
};
@@ -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);
diff --git a/include/efi_selftest.h b/include/efi_selftest.h
index 76304a2..7ec42a0 100644
--- a/include/efi_selftest.h
+++ b/include/efi_selftest.h
@@ -14,14 +14,17 @@
#include <efi_api.h>
#include <linker_lists.h>
+#define EFI_ST_SUCCESS 0
+#define EFI_ST_FAILURE 1
+
/*
* Prints an error message.
*
* @... 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,
@@ -58,6 +61,17 @@ 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.
*
* @return: Unicode character