aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2018-08-21 13:15:21 -0400
committerTom Rini <trini@konsulko.com>2018-08-21 13:15:21 -0400
commit26699998e9f4adb8c0ac8b36a2c3089fa8f05283 (patch)
treeed77d69574a9ff67aa7a8ff6bb7de03306900005
parentb71d9e8b3805305ea4116733f515061710ad7081 (diff)
parentdbb148b22cbf242156edf53cca6d661cd320cb83 (diff)
downloadu-boot-26699998e9f4adb8c0ac8b36a2c3089fa8f05283.zip
u-boot-26699998e9f4adb8c0ac8b36a2c3089fa8f05283.tar.gz
u-boot-26699998e9f4adb8c0ac8b36a2c3089fa8f05283.tar.bz2
Merge tag 'signed-efi-2018.09' of git://github.com/agraf/u-boot
Patch queue for efi - 2018-08-21 A few fixes for 2018.09. Most noticable are: - unbreak x86 target (-fdata-section fallout) - fix undefined behavior in a few corner cases - make Jetson TX1 boot again - RTS fixes - implement reset for simple output
-rw-r--r--arch/riscv/cpu/ax25/u-boot.lds2
-rw-r--r--arch/sandbox/cpu/u-boot.lds5
-rw-r--r--arch/x86/config.mk4
-rw-r--r--arch/x86/cpu/u-boot-64.lds2
-rw-r--r--arch/x86/cpu/u-boot.lds2
-rw-r--r--arch/x86/lib/elf_ia32_efi.lds2
-rw-r--r--arch/x86/lib/elf_x86_64_efi.lds2
-rw-r--r--cmd/efi.c27
-rw-r--r--include/efi.h28
-rw-r--r--include/efi_loader.h3
-rw-r--r--lib/crc32.c26
-rw-r--r--lib/efi_loader/efi_boottime.c15
-rw-r--r--lib/efi_loader/efi_console.c22
-rw-r--r--lib/efi_loader/efi_memory.c13
-rw-r--r--lib/efi_loader/efi_runtime.c177
-rw-r--r--lib/efi_selftest/efi_selftest_block_device.c2
16 files changed, 250 insertions, 82 deletions
diff --git a/arch/riscv/cpu/ax25/u-boot.lds b/arch/riscv/cpu/ax25/u-boot.lds
index 3cc8974..c50b964 100644
--- a/arch/riscv/cpu/ax25/u-boot.lds
+++ b/arch/riscv/cpu/ax25/u-boot.lds
@@ -82,7 +82,7 @@ SECTIONS
.bss : {
__bss_start = .;
- *(.bss)
+ *(.bss*)
. = ALIGN(4);
__bss_end = .;
}
diff --git a/arch/sandbox/cpu/u-boot.lds b/arch/sandbox/cpu/u-boot.lds
index 727bcc3..40c2214 100644
--- a/arch/sandbox/cpu/u-boot.lds
+++ b/arch/sandbox/cpu/u-boot.lds
@@ -17,9 +17,7 @@ SECTIONS
_u_boot_sandbox_getopt : { *(.u_boot_sandbox_getopt) }
__u_boot_sandbox_option_end = .;
- __bss_start = .;
-
- .__efi_runtime_start : {
+ .__efi_runtime_start : {
*(.__efi_runtime_start)
}
@@ -48,6 +46,7 @@ SECTIONS
*(.__efi_runtime_rel_stop)
}
+ __bss_start = .;
}
INSERT BEFORE .data;
diff --git a/arch/x86/config.mk b/arch/x86/config.mk
index 586e11a..5b04feb 100644
--- a/arch/x86/config.mk
+++ b/arch/x86/config.mk
@@ -23,13 +23,11 @@ endif
ifeq ($(IS_32BIT),y)
PLATFORM_CPPFLAGS += -march=i386 -m32
-# TODO: These break on x86_64; need to debug further
-PLATFORM_RELFLAGS += -fdata-sections
else
PLATFORM_CPPFLAGS += $(if $(CONFIG_SPL_BUILD),,-fpic) -fno-common -m64
endif
-PLATFORM_RELFLAGS += -ffunction-sections -fvisibility=hidden
+PLATFORM_RELFLAGS += -fdata-sections -ffunction-sections -fvisibility=hidden
PLATFORM_LDFLAGS += -Bsymbolic -Bsymbolic-functions
PLATFORM_LDFLAGS += -m $(if $(IS_32BIT),elf_i386,elf_x86_64)
diff --git a/arch/x86/cpu/u-boot-64.lds b/arch/x86/cpu/u-boot-64.lds
index 862aa2d..98c7f8e 100644
--- a/arch/x86/cpu/u-boot-64.lds
+++ b/arch/x86/cpu/u-boot-64.lds
@@ -95,7 +95,7 @@ SECTIONS
.bss __rel_dyn_start (OVERLAY) : {
__bss_start = .;
- *(.bss)
+ *(.bss*)
*(COM*)
. = ALIGN(4);
__bss_end = .;
diff --git a/arch/x86/cpu/u-boot.lds b/arch/x86/cpu/u-boot.lds
index a1cc19c..a283c29 100644
--- a/arch/x86/cpu/u-boot.lds
+++ b/arch/x86/cpu/u-boot.lds
@@ -94,7 +94,7 @@ SECTIONS
.bss __rel_dyn_start (OVERLAY) : {
__bss_start = .;
- *(.bss)
+ *(.bss*)
*(COM*)
. = ALIGN(4);
__bss_end = .;
diff --git a/arch/x86/lib/elf_ia32_efi.lds b/arch/x86/lib/elf_ia32_efi.lds
index 983fabb..aad61e7 100644
--- a/arch/x86/lib/elf_ia32_efi.lds
+++ b/arch/x86/lib/elf_ia32_efi.lds
@@ -46,7 +46,7 @@ SECTIONS
*(.sbss)
*(.scommon)
*(.dynbss)
- *(.bss)
+ *(.bss*)
*(COMMON)
/* U-Boot lists and device tree */
diff --git a/arch/x86/lib/elf_x86_64_efi.lds b/arch/x86/lib/elf_x86_64_efi.lds
index 7cad70a..b436429 100644
--- a/arch/x86/lib/elf_x86_64_efi.lds
+++ b/arch/x86/lib/elf_x86_64_efi.lds
@@ -44,7 +44,7 @@ SECTIONS
*(.sbss)
*(.scommon)
*(.dynbss)
- *(.bss)
+ *(.bss*)
*(COMMON)
*(.rel.local)
diff --git a/cmd/efi.c b/cmd/efi.c
index 6c1eb88..919cb2f 100644
--- a/cmd/efi.c
+++ b/cmd/efi.c
@@ -28,18 +28,21 @@ static const char *const type_name[] = {
};
static struct attr_info {
- int shift;
+ u64 val;
const char *name;
} mem_attr[] = {
- { EFI_MEMORY_UC_SHIFT, "uncached" },
- { EFI_MEMORY_WC_SHIFT, "write-coalescing" },
- { EFI_MEMORY_WT_SHIFT, "write-through" },
- { EFI_MEMORY_WB_SHIFT, "write-back" },
- { EFI_MEMORY_UCE_SHIFT, "uncached & exported" },
- { EFI_MEMORY_WP_SHIFT, "write-protect" },
- { EFI_MEMORY_RP_SHIFT, "read-protect" },
- { EFI_MEMORY_XP_SHIFT, "execute-protect" },
- { EFI_MEMORY_RUNTIME_SHIFT, "needs runtime mapping" }
+ { EFI_MEMORY_UC, "uncached" },
+ { EFI_MEMORY_WC, "write-coalescing" },
+ { EFI_MEMORY_WT, "write-through" },
+ { EFI_MEMORY_WB, "write-back" },
+ { EFI_MEMORY_UCE, "uncached & exported" },
+ { EFI_MEMORY_WP, "write-protect" },
+ { EFI_MEMORY_RP, "read-protect" },
+ { EFI_MEMORY_XP, "execute-protect" },
+ { EFI_MEMORY_NV, "non-volatile" },
+ { EFI_MEMORY_MORE_RELIABLE, "higher reliability" },
+ { EFI_MEMORY_RO, "read-only" },
+ { EFI_MEMORY_RUNTIME, "needs runtime mapping" }
};
/* Maximum different attribute values we can track */
@@ -170,10 +173,10 @@ static void efi_print_mem_table(struct efi_entry_memmap *map,
bool first;
int j;
- printf("%c%llx: ", attr & EFI_MEMORY_RUNTIME ? 'r' : ' ',
+ printf("%c%llx: ", (attr & EFI_MEMORY_RUNTIME) ? 'r' : ' ',
attr & ~EFI_MEMORY_RUNTIME);
for (j = 0, first = true; j < ARRAY_SIZE(mem_attr); j++) {
- if (attr & (1ULL << mem_attr[j].shift)) {
+ if (attr & mem_attr[j].val) {
if (first)
first = false;
else
diff --git a/include/efi.h b/include/efi.h
index 41530a7..7e7c1ca 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -170,20 +170,20 @@ enum efi_mem_type {
};
/* Attribute values */
-enum {
- EFI_MEMORY_UC_SHIFT = 0, /* uncached */
- EFI_MEMORY_WC_SHIFT = 1, /* write-coalescing */
- EFI_MEMORY_WT_SHIFT = 2, /* write-through */
- EFI_MEMORY_WB_SHIFT = 3, /* write-back */
- EFI_MEMORY_UCE_SHIFT = 4, /* uncached, exported */
- EFI_MEMORY_WP_SHIFT = 12, /* write-protect */
- EFI_MEMORY_RP_SHIFT = 13, /* read-protect */
- EFI_MEMORY_XP_SHIFT = 14, /* execute-protect */
- EFI_MEMORY_RUNTIME_SHIFT = 63, /* range requires runtime mapping */
-
- EFI_MEMORY_RUNTIME = 1ULL << EFI_MEMORY_RUNTIME_SHIFT,
- EFI_MEM_DESC_VERSION = 1,
-};
+#define EFI_MEMORY_UC ((u64)0x0000000000000001ULL) /* uncached */
+#define EFI_MEMORY_WC ((u64)0x0000000000000002ULL) /* write-coalescing */
+#define EFI_MEMORY_WT ((u64)0x0000000000000004ULL) /* write-through */
+#define EFI_MEMORY_WB ((u64)0x0000000000000008ULL) /* write-back */
+#define EFI_MEMORY_UCE ((u64)0x0000000000000010ULL) /* uncached, exported */
+#define EFI_MEMORY_WP ((u64)0x0000000000001000ULL) /* write-protect */
+#define EFI_MEMORY_RP ((u64)0x0000000000002000ULL) /* read-protect */
+#define EFI_MEMORY_XP ((u64)0x0000000000004000ULL) /* execute-protect */
+#define EFI_MEMORY_NV ((u64)0x0000000000008000ULL) /* non-volatile */
+#define EFI_MEMORY_MORE_RELIABLE \
+ ((u64)0x0000000000010000ULL) /* higher reliability */
+#define EFI_MEMORY_RO ((u64)0x0000000000020000ULL) /* read-only */
+#define EFI_MEMORY_RUNTIME ((u64)0x8000000000000000ULL) /* range requires runtime mapping */
+#define EFI_MEM_DESC_VERSION 1
#define EFI_PAGE_SHIFT 12
#define EFI_PAGE_SIZE (1UL << EFI_PAGE_SHIFT)
diff --git a/include/efi_loader.h b/include/efi_loader.h
index 57ca550..f162adf 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -417,6 +417,9 @@ static inline int guidcmp(const efi_guid_t *g1, const efi_guid_t *g2)
#define __efi_runtime_data __attribute__ ((section (".data.efi_runtime")))
#define __efi_runtime __attribute__ ((section (".text.efi_runtime")))
+/* Update CRC32 in table header */
+void __efi_runtime efi_update_table_header_crc32(struct efi_table_hdr *table);
+
/* Call this with mmio_ptr as the _pointer_ to a pointer to an MMIO region
* to make it available at runtime */
efi_status_t efi_add_runtime_mmio(void *mmio_ptr, u64 len);
diff --git a/lib/crc32.c b/lib/crc32.c
index 7f545fd..71e27df 100644
--- a/lib/crc32.c
+++ b/lib/crc32.c
@@ -12,6 +12,7 @@
#include <arpa/inet.h>
#else
#include <common.h>
+#include <efi_loader.h>
#endif
#include <compiler.h>
#include <u-boot/crc.h>
@@ -21,16 +22,18 @@
#endif
#include "u-boot/zlib.h"
-#define local static
-#define ZEXPORT /* empty */
+#ifdef USE_HOSTCC
+#define __efi_runtime
+#define __efi_runtime_data
+#endif
#define tole(x) cpu_to_le32(x)
#ifdef CONFIG_DYNAMIC_CRC_TABLE
-local int crc_table_empty = 1;
-local uint32_t crc_table[256];
-local void make_crc_table OF((void));
+static int __efi_runtime_data crc_table_empty = 1;
+static uint32_t __efi_runtime_data crc_table[256];
+static void __efi_runtime make_crc_table OF((void));
/*
Generate a table for a byte-wise 32-bit CRC calculation on the polynomial:
@@ -56,7 +59,7 @@ local void make_crc_table OF((void));
the information needed to generate CRC's on data a byte at a time for all
combinations of CRC register values and incoming bytes.
*/
-local void make_crc_table()
+static void __efi_runtime make_crc_table(void)
{
uint32_t c;
int n, k;
@@ -83,7 +86,7 @@ local void make_crc_table()
* Table of CRC-32's of all single-byte values (made by make_crc_table)
*/
-local const uint32_t crc_table[256] = {
+static const uint32_t __efi_runtime_data crc_table[256] = {
tole(0x00000000L), tole(0x77073096L), tole(0xee0e612cL), tole(0x990951baL),
tole(0x076dc419L), tole(0x706af48fL), tole(0xe963a535L), tole(0x9e6495a3L),
tole(0x0edb8832L), tole(0x79dcb8a4L), tole(0xe0d5e91eL), tole(0x97d2d988L),
@@ -176,7 +179,7 @@ const uint32_t * ZEXPORT get_crc_table()
/* No ones complement version. JFFS2 (and other things ?)
* don't use ones compliment in their CRC calculations.
*/
-uint32_t ZEXPORT crc32_no_comp(uint32_t crc, const Bytef *buf, uInt len)
+uint32_t __efi_runtime crc32_no_comp(uint32_t crc, const Bytef *buf, uInt len)
{
const uint32_t *tab = crc_table;
const uint32_t *b =(const uint32_t *)buf;
@@ -218,7 +221,7 @@ uint32_t ZEXPORT crc32_no_comp(uint32_t crc, const Bytef *buf, uInt len)
}
#undef DO_CRC
-uint32_t ZEXPORT crc32 (uint32_t crc, const Bytef *p, uInt len)
+uint32_t __efi_runtime crc32(uint32_t crc, const Bytef *p, uInt len)
{
return crc32_no_comp(crc ^ 0xffffffffL, p, len) ^ 0xffffffffL;
}
@@ -227,9 +230,8 @@ uint32_t ZEXPORT crc32 (uint32_t crc, const Bytef *p, uInt len)
* Calculate the crc32 checksum triggering the watchdog every 'chunk_sz' bytes
* of input.
*/
-uint32_t ZEXPORT crc32_wd (uint32_t crc,
- const unsigned char *buf,
- uInt len, uInt chunk_sz)
+uint32_t crc32_wd(uint32_t crc, const unsigned char *buf, uInt len,
+ uInt chunk_sz)
{
#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
const unsigned char *end, *curr;
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index b9e54f5..3935e4f 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -154,18 +154,6 @@ const char *__efi_nesting_dec(void)
}
/**
- * efi_update_table_header_crc32() - Update CRC32 in table header
- *
- * @table: EFI table
- */
-static void efi_update_table_header_crc32(struct efi_table_hdr *table)
-{
- table->crc32 = 0;
- table->crc32 = crc32(0, (const unsigned char *)table,
- table->headersize);
-}
-
-/**
* efi_queue_event() - queue an EFI event
* @event: event to signal
* @check_tpl: check the TPL level
@@ -627,7 +615,8 @@ efi_status_t efi_create_event(uint32_t type, efi_uintn_t notify_tpl,
return EFI_INVALID_PARAMETER;
}
- if (is_valid_tpl(notify_tpl) != EFI_SUCCESS)
+ if ((type & (EVT_NOTIFY_WAIT | EVT_NOTIFY_SIGNAL)) &&
+ (is_valid_tpl(notify_tpl) != EFI_SUCCESS))
return EFI_INVALID_PARAMETER;
evt = calloc(1, sizeof(struct efi_event));
diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
index 3fd0d2f..b487288 100644
--- a/lib/efi_loader/efi_console.c
+++ b/lib/efi_loader/efi_console.c
@@ -105,14 +105,6 @@ static int term_read_reply(int *n, int num, char end_char)
return 0;
}
-static efi_status_t EFIAPI efi_cout_reset(
- struct efi_simple_text_output_protocol *this,
- char extended_verification)
-{
- EFI_ENTRY("%p, %d", this, extended_verification);
- return EFI_EXIT(EFI_UNSUPPORTED);
-}
-
static efi_status_t EFIAPI efi_cout_output_string(
struct efi_simple_text_output_protocol *this,
const efi_string_t string)
@@ -341,6 +333,20 @@ static efi_status_t EFIAPI efi_cout_clear_screen(
return EFI_EXIT(EFI_SUCCESS);
}
+static efi_status_t EFIAPI efi_cout_reset(
+ struct efi_simple_text_output_protocol *this,
+ char extended_verification)
+{
+ EFI_ENTRY("%p, %d", this, extended_verification);
+
+ /* Clear screen */
+ EFI_CALL(efi_cout_clear_screen(this));
+ /* Set default colors */
+ printf(ESC "[0;37;40m");
+
+ return EFI_EXIT(EFI_SUCCESS);
+}
+
static efi_status_t EFIAPI efi_cout_set_cursor_position(
struct efi_simple_text_output_protocol *this,
unsigned long column, unsigned long row)
diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index 967c3f7..e2b40aa 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -178,14 +178,13 @@ uint64_t efi_add_memory_map(uint64_t start, uint64_t pages, int memory_type,
switch (memory_type) {
case EFI_RUNTIME_SERVICES_CODE:
case EFI_RUNTIME_SERVICES_DATA:
- newlist->desc.attribute = (1 << EFI_MEMORY_WB_SHIFT) |
- (1ULL << EFI_MEMORY_RUNTIME_SHIFT);
+ newlist->desc.attribute = EFI_MEMORY_WB | EFI_MEMORY_RUNTIME;
break;
case EFI_MMAP_IO:
- newlist->desc.attribute = 1ULL << EFI_MEMORY_RUNTIME_SHIFT;
+ newlist->desc.attribute = EFI_MEMORY_RUNTIME;
break;
default:
- newlist->desc.attribute = 1 << EFI_MEMORY_WB_SHIFT;
+ newlist->desc.attribute = EFI_MEMORY_WB;
break;
}
@@ -305,7 +304,7 @@ efi_status_t efi_allocate_pages(int type, int memory_type,
switch (type) {
case EFI_ALLOCATE_ANY_PAGES:
/* Any page */
- addr = efi_find_free_memory(len, -1ULL);
+ addr = efi_find_free_memory(len, gd->start_addr_sp);
if (!addr) {
r = EFI_NOT_FOUND;
break;
@@ -457,11 +456,13 @@ efi_status_t efi_get_memory_map(efi_uintn_t *memory_map_size,
efi_uintn_t map_size = 0;
int map_entries = 0;
struct list_head *lhandle;
- efi_uintn_t provided_map_size = *memory_map_size;
+ efi_uintn_t provided_map_size;
if (!memory_map_size)
return EFI_INVALID_PARAMETER;
+ provided_map_size = *memory_map_size;
+
list_for_each(lhandle, &efi_mem)
map_entries++;
diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
index 06958f2..27136cb 100644
--- a/lib/efi_loader/efi_runtime.c
+++ b/lib/efi_loader/efi_runtime.c
@@ -84,6 +84,32 @@ struct elf_rela {
* handle a good number of runtime callbacks
*/
+/**
+ * efi_update_table_header_crc32() - Update crc32 in table header
+ *
+ * @table: EFI table
+ */
+void __efi_runtime efi_update_table_header_crc32(struct efi_table_hdr *table)
+{
+ table->crc32 = 0;
+ table->crc32 = crc32(0, (const unsigned char *)table,
+ table->headersize);
+}
+
+/**
+ * efi_reset_system_boottime() - reset system at boottime
+ *
+ * This function implements the ResetSystem() runtime service before
+ * SetVirtualAddressMap() is called.
+ *
+ * See the Unified Extensible Firmware Interface (UEFI) specification for
+ * details.
+ *
+ * @reset_type: type of reset to perform
+ * @reset_status: status code for the reset
+ * @data_size: size of reset_data
+ * @reset_data: information about the reset
+ */
static void EFIAPI efi_reset_system_boottime(
enum efi_reset_type reset_type,
efi_status_t reset_status,
@@ -118,15 +144,17 @@ static void EFIAPI efi_reset_system_boottime(
}
/**
- * efi_get_time_boottime - get current time
+ * efi_get_time_boottime() - get current time at boottime
+ *
+ * This function implements the GetTime runtime service before
+ * SetVirtualAddressMap() is called.
*
- * This function implements the GetTime runtime service.
* See the Unified Extensible Firmware Interface (UEFI) specification
* for details.
*
* @time: pointer to structure to receive current time
* @capabilities: pointer to structure to receive RTC properties
- * Return Value: status code
+ * Returns: status code
*/
static efi_status_t EFIAPI efi_get_time_boottime(
struct efi_time *time,
@@ -179,8 +207,22 @@ out:
#endif
}
-/* Boards may override the helpers below to implement RTS functionality */
+/**
+ * efi_reset_system() - reset system
+ *
+ * This function implements the ResetSystem() runtime service after
+ * SetVirtualAddressMap() is called. It only executes an endless loop.
+ * Boards may override the helpers below to implement reset functionality.
+ *
+ * See the Unified Extensible Firmware Interface (UEFI) specification for
+ * details.
+ *
+ * @reset_type: type of reset to perform
+ * @reset_status: status code for the reset
+ * @data_size: size of reset_data
+ * @reset_data: information about the reset
+ */
void __weak __efi_runtime EFIAPI efi_reset_system(
enum efi_reset_type reset_type,
efi_status_t reset_status,
@@ -190,11 +232,30 @@ void __weak __efi_runtime EFIAPI efi_reset_system(
while (1) { }
}
+/**
+ * efi_reset_system_init() - initialize the reset driver
+ *
+ * Boards may override this function to initialize the reset driver.
+ */
efi_status_t __weak efi_reset_system_init(void)
{
return EFI_SUCCESS;
}
+/**
+ * efi_get_time() - get current time
+ *
+ * This function implements the GetTime runtime service after
+ * SetVirtualAddressMap() is called. As the U-Boot driver are not available
+ * anymore only an error code is returned.
+ *
+ * See the Unified Extensible Firmware Interface (UEFI) specification
+ * for details.
+ *
+ * @time: pointer to structure to receive current time
+ * @capabilities: pointer to structure to receive RTC properties
+ * Returns: status code
+ */
efi_status_t __weak __efi_runtime EFIAPI efi_get_time(
struct efi_time *time,
struct efi_time_cap *capabilities)
@@ -273,6 +334,9 @@ static void efi_runtime_detach(ulong offset)
debug("%s: Setting %p to %lx\n", __func__, p, newaddr);
*p = newaddr;
}
+
+ /* Update crc32 */
+ efi_update_table_header_crc32(&efi_runtime_services.hdr);
}
/* Relocate EFI runtime to uboot_reloc_base = offset */
@@ -338,6 +402,20 @@ void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map)
invalidate_icache_all();
}
+/**
+ * efi_set_virtual_address_map() - change from physical to virtual mapping
+ *
+ * This function implements the SetVirtualAddressMap() runtime service.
+ *
+ * See the Unified Extensible Firmware Interface (UEFI) specification for
+ * details.
+ *
+ * @memory_map_size: size of the virtual map
+ * @descriptor_size: size of an entry in the map
+ * @descriptor_version: version of the map entries
+ * @virtmap: virtual address mapping information
+ * Return: status code
+ */
static efi_status_t EFIAPI efi_set_virtual_address_map(
unsigned long memory_map_size,
unsigned long descriptor_size,
@@ -360,6 +438,7 @@ static efi_status_t EFIAPI efi_set_virtual_address_map(
efi_physical_addr_t map_start = map->physical_start;
efi_physical_addr_t map_len = map->num_pages << EFI_PAGE_SHIFT;
efi_physical_addr_t map_end = map_start + map_len;
+ u64 off = map->virtual_start - map_start;
/* Adjust all mmio pointers in this region */
list_for_each(lhandle, &efi_runtime_mmio) {
@@ -370,11 +449,17 @@ static efi_status_t EFIAPI efi_set_virtual_address_map(
link);
if ((map_start <= lmmio->paddr) &&
(map_end >= lmmio->paddr)) {
- u64 off = map->virtual_start - map_start;
uintptr_t new_addr = lmmio->paddr + off;
*lmmio->ptr = (void *)new_addr;
}
}
+ if ((map_start <= (uintptr_t)systab.tables) &&
+ (map_end >= (uintptr_t)systab.tables)) {
+ char *ptr = (char *)systab.tables;
+
+ ptr += off;
+ systab.tables = (struct efi_configuration_table *)ptr;
+ }
}
/* Move the actual runtime code over */
@@ -397,6 +482,16 @@ static efi_status_t EFIAPI efi_set_virtual_address_map(
return EFI_EXIT(EFI_INVALID_PARAMETER);
}
+/**
+ * efi_add_runtime_mmio() - add memory-mapped IO region
+ *
+ * This function adds a memory-mapped IO region to the memory map to make it
+ * available at runtime.
+ *
+ * @mmio_ptr: address of the memory-mapped IO region
+ * @len: size of thememory-mapped IO region
+ * Returns: status code
+ */
efi_status_t efi_add_runtime_mmio(void *mmio_ptr, u64 len)
{
struct efi_runtime_mmio_list *newmmio;
@@ -439,21 +534,61 @@ efi_status_t efi_add_runtime_mmio(void *mmio_ptr, u64 len)
* address map calls.
*/
+/**
+ * efi_unimplemented() - replacement function, returns EFI_UNSUPPORTED
+ *
+ * This function is used after SetVirtualAddressMap() is called as replacement
+ * for services that are not available anymore due to constraints of the U-Boot
+ * implementation.
+ *
+ * Return: EFI_UNSUPPORTED
+ */
static efi_status_t __efi_runtime EFIAPI efi_unimplemented(void)
{
return EFI_UNSUPPORTED;
}
+/**
+ * efi_device_error() - replacement function, returns EFI_DEVICE_ERROR
+ *
+ * This function is used after SetVirtualAddressMap() is called as replacement
+ * for services that are not available anymore due to constraints of the U-Boot
+ * implementation.
+ *
+ * Return: EFI_DEVICE_ERROR
+ */
static efi_status_t __efi_runtime EFIAPI efi_device_error(void)
{
return EFI_DEVICE_ERROR;
}
+/**
+ * efi_invalid_parameter() - replacement function, returns EFI_INVALID_PARAMETER
+ *
+ * This function is used after SetVirtualAddressMap() is called as replacement
+ * for services that are not available anymore due to constraints of the U-Boot
+ * implementation.
+ *
+ * Return: EFI_INVALID_PARAMETER
+ */
static efi_status_t __efi_runtime EFIAPI efi_invalid_parameter(void)
{
return EFI_INVALID_PARAMETER;
}
+/**
+ * efi_update_capsule() - process information from operating system
+ *
+ * This function implements the UpdateCapsule() runtime service.
+ *
+ * See the Unified Extensible Firmware Interface (UEFI) specification for
+ * details.
+ *
+ * @capsule_header_array: pointer to array of virtual pointers
+ * @capsule_count: number of pointers in capsule_header_array
+ * @scatter_gather_list: pointer to arry of physical pointers
+ * Returns: status code
+ */
efi_status_t __efi_runtime EFIAPI efi_update_capsule(
struct efi_capsule_header **capsule_header_array,
efi_uintn_t capsule_count,
@@ -462,6 +597,20 @@ efi_status_t __efi_runtime EFIAPI efi_update_capsule(
return EFI_UNSUPPORTED;
}
+/**
+ * efi_query_capsule_caps() - check if capsule is supported
+ *
+ * This function implements the QueryCapsuleCapabilities() runtime service.
+ *
+ * See the Unified Extensible Firmware Interface (UEFI) specification for
+ * details.
+ *
+ * @capsule_header_array: pointer to array of virtual pointers
+ * @capsule_count: number of pointers in capsule_header_array
+ * @capsule_size: maximum capsule size
+ * @reset_type: type of reset needed for capsule update
+ * Returns: status code
+ */
efi_status_t __efi_runtime EFIAPI efi_query_capsule_caps(
struct efi_capsule_header **capsule_header_array,
efi_uintn_t capsule_count,
@@ -471,6 +620,24 @@ efi_status_t __efi_runtime EFIAPI efi_query_capsule_caps(
return EFI_UNSUPPORTED;
}
+/**
+ * efi_query_variable_info() - get information about EFI variables
+ *
+ * This function implements the QueryVariableInfo() runtime service.
+ *
+ * See the Unified Extensible Firmware Interface (UEFI) specification for
+ * details.
+ *
+ * @attributes: bitmask to select variables to be
+ * queried
+ * @maximum_variable_storage_size: maximum size of storage area for the
+ * selected variable types
+ * @remaining_variable_storage_size: remaining size of storage are for the
+ * selected variable types
+ * @maximum_variable_size: maximum size of a variable of the
+ * selected type
+ * Returns: status code
+ */
efi_status_t __efi_runtime EFIAPI efi_query_variable_info(
u32 attributes,
u64 *maximum_variable_storage_size,
diff --git a/lib/efi_selftest/efi_selftest_block_device.c b/lib/efi_selftest/efi_selftest_block_device.c
index b82e405..1cd1304 100644
--- a/lib/efi_selftest/efi_selftest_block_device.c
+++ b/lib/efi_selftest/efi_selftest_block_device.c
@@ -415,7 +415,7 @@ static int execute(void)
#ifdef CONFIG_FAT_WRITE
/* Write file */
- ret = root->open(root, &file, (s16 *)L"u-boot.txt",
+ ret = root->open(root, &file, (s16 *)L"u-boot.txt", EFI_FILE_MODE_READ |
EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, 0);
if (ret != EFI_SUCCESS) {
efi_st_error("Failed to open file\n");