mirror of
https://github.com/linux-sunxi/u-boot-sunxi.git
synced 2024-02-12 11:16:03 +08:00
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
This commit is contained in:
@ -82,7 +82,7 @@ SECTIONS
|
|||||||
|
|
||||||
.bss : {
|
.bss : {
|
||||||
__bss_start = .;
|
__bss_start = .;
|
||||||
*(.bss)
|
*(.bss*)
|
||||||
. = ALIGN(4);
|
. = ALIGN(4);
|
||||||
__bss_end = .;
|
__bss_end = .;
|
||||||
}
|
}
|
||||||
|
@ -17,9 +17,7 @@ SECTIONS
|
|||||||
_u_boot_sandbox_getopt : { *(.u_boot_sandbox_getopt) }
|
_u_boot_sandbox_getopt : { *(.u_boot_sandbox_getopt) }
|
||||||
__u_boot_sandbox_option_end = .;
|
__u_boot_sandbox_option_end = .;
|
||||||
|
|
||||||
__bss_start = .;
|
.__efi_runtime_start : {
|
||||||
|
|
||||||
.__efi_runtime_start : {
|
|
||||||
*(.__efi_runtime_start)
|
*(.__efi_runtime_start)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,6 +46,7 @@ SECTIONS
|
|||||||
*(.__efi_runtime_rel_stop)
|
*(.__efi_runtime_rel_stop)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__bss_start = .;
|
||||||
}
|
}
|
||||||
|
|
||||||
INSERT BEFORE .data;
|
INSERT BEFORE .data;
|
||||||
|
@ -23,13 +23,11 @@ endif
|
|||||||
|
|
||||||
ifeq ($(IS_32BIT),y)
|
ifeq ($(IS_32BIT),y)
|
||||||
PLATFORM_CPPFLAGS += -march=i386 -m32
|
PLATFORM_CPPFLAGS += -march=i386 -m32
|
||||||
# TODO: These break on x86_64; need to debug further
|
|
||||||
PLATFORM_RELFLAGS += -fdata-sections
|
|
||||||
else
|
else
|
||||||
PLATFORM_CPPFLAGS += $(if $(CONFIG_SPL_BUILD),,-fpic) -fno-common -m64
|
PLATFORM_CPPFLAGS += $(if $(CONFIG_SPL_BUILD),,-fpic) -fno-common -m64
|
||||||
endif
|
endif
|
||||||
|
|
||||||
PLATFORM_RELFLAGS += -ffunction-sections -fvisibility=hidden
|
PLATFORM_RELFLAGS += -fdata-sections -ffunction-sections -fvisibility=hidden
|
||||||
|
|
||||||
PLATFORM_LDFLAGS += -Bsymbolic -Bsymbolic-functions
|
PLATFORM_LDFLAGS += -Bsymbolic -Bsymbolic-functions
|
||||||
PLATFORM_LDFLAGS += -m $(if $(IS_32BIT),elf_i386,elf_x86_64)
|
PLATFORM_LDFLAGS += -m $(if $(IS_32BIT),elf_i386,elf_x86_64)
|
||||||
|
@ -95,7 +95,7 @@ SECTIONS
|
|||||||
|
|
||||||
.bss __rel_dyn_start (OVERLAY) : {
|
.bss __rel_dyn_start (OVERLAY) : {
|
||||||
__bss_start = .;
|
__bss_start = .;
|
||||||
*(.bss)
|
*(.bss*)
|
||||||
*(COM*)
|
*(COM*)
|
||||||
. = ALIGN(4);
|
. = ALIGN(4);
|
||||||
__bss_end = .;
|
__bss_end = .;
|
||||||
|
@ -94,7 +94,7 @@ SECTIONS
|
|||||||
|
|
||||||
.bss __rel_dyn_start (OVERLAY) : {
|
.bss __rel_dyn_start (OVERLAY) : {
|
||||||
__bss_start = .;
|
__bss_start = .;
|
||||||
*(.bss)
|
*(.bss*)
|
||||||
*(COM*)
|
*(COM*)
|
||||||
. = ALIGN(4);
|
. = ALIGN(4);
|
||||||
__bss_end = .;
|
__bss_end = .;
|
||||||
|
@ -46,7 +46,7 @@ SECTIONS
|
|||||||
*(.sbss)
|
*(.sbss)
|
||||||
*(.scommon)
|
*(.scommon)
|
||||||
*(.dynbss)
|
*(.dynbss)
|
||||||
*(.bss)
|
*(.bss*)
|
||||||
*(COMMON)
|
*(COMMON)
|
||||||
|
|
||||||
/* U-Boot lists and device tree */
|
/* U-Boot lists and device tree */
|
||||||
|
@ -44,7 +44,7 @@ SECTIONS
|
|||||||
*(.sbss)
|
*(.sbss)
|
||||||
*(.scommon)
|
*(.scommon)
|
||||||
*(.dynbss)
|
*(.dynbss)
|
||||||
*(.bss)
|
*(.bss*)
|
||||||
*(COMMON)
|
*(COMMON)
|
||||||
*(.rel.local)
|
*(.rel.local)
|
||||||
|
|
||||||
|
27
cmd/efi.c
27
cmd/efi.c
@ -28,18 +28,21 @@ static const char *const type_name[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static struct attr_info {
|
static struct attr_info {
|
||||||
int shift;
|
u64 val;
|
||||||
const char *name;
|
const char *name;
|
||||||
} mem_attr[] = {
|
} mem_attr[] = {
|
||||||
{ EFI_MEMORY_UC_SHIFT, "uncached" },
|
{ EFI_MEMORY_UC, "uncached" },
|
||||||
{ EFI_MEMORY_WC_SHIFT, "write-coalescing" },
|
{ EFI_MEMORY_WC, "write-coalescing" },
|
||||||
{ EFI_MEMORY_WT_SHIFT, "write-through" },
|
{ EFI_MEMORY_WT, "write-through" },
|
||||||
{ EFI_MEMORY_WB_SHIFT, "write-back" },
|
{ EFI_MEMORY_WB, "write-back" },
|
||||||
{ EFI_MEMORY_UCE_SHIFT, "uncached & exported" },
|
{ EFI_MEMORY_UCE, "uncached & exported" },
|
||||||
{ EFI_MEMORY_WP_SHIFT, "write-protect" },
|
{ EFI_MEMORY_WP, "write-protect" },
|
||||||
{ EFI_MEMORY_RP_SHIFT, "read-protect" },
|
{ EFI_MEMORY_RP, "read-protect" },
|
||||||
{ EFI_MEMORY_XP_SHIFT, "execute-protect" },
|
{ EFI_MEMORY_XP, "execute-protect" },
|
||||||
{ EFI_MEMORY_RUNTIME_SHIFT, "needs runtime mapping" }
|
{ 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 */
|
/* Maximum different attribute values we can track */
|
||||||
@ -170,10 +173,10 @@ static void efi_print_mem_table(struct efi_entry_memmap *map,
|
|||||||
bool first;
|
bool first;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
printf("%c%llx: ", attr & EFI_MEMORY_RUNTIME ? 'r' : ' ',
|
printf("%c%llx: ", (attr & EFI_MEMORY_RUNTIME) ? 'r' : ' ',
|
||||||
attr & ~EFI_MEMORY_RUNTIME);
|
attr & ~EFI_MEMORY_RUNTIME);
|
||||||
for (j = 0, first = true; j < ARRAY_SIZE(mem_attr); j++) {
|
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)
|
if (first)
|
||||||
first = false;
|
first = false;
|
||||||
else
|
else
|
||||||
|
@ -170,20 +170,20 @@ enum efi_mem_type {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Attribute values */
|
/* Attribute values */
|
||||||
enum {
|
#define EFI_MEMORY_UC ((u64)0x0000000000000001ULL) /* uncached */
|
||||||
EFI_MEMORY_UC_SHIFT = 0, /* uncached */
|
#define EFI_MEMORY_WC ((u64)0x0000000000000002ULL) /* write-coalescing */
|
||||||
EFI_MEMORY_WC_SHIFT = 1, /* write-coalescing */
|
#define EFI_MEMORY_WT ((u64)0x0000000000000004ULL) /* write-through */
|
||||||
EFI_MEMORY_WT_SHIFT = 2, /* write-through */
|
#define EFI_MEMORY_WB ((u64)0x0000000000000008ULL) /* write-back */
|
||||||
EFI_MEMORY_WB_SHIFT = 3, /* write-back */
|
#define EFI_MEMORY_UCE ((u64)0x0000000000000010ULL) /* uncached, exported */
|
||||||
EFI_MEMORY_UCE_SHIFT = 4, /* uncached, exported */
|
#define EFI_MEMORY_WP ((u64)0x0000000000001000ULL) /* write-protect */
|
||||||
EFI_MEMORY_WP_SHIFT = 12, /* write-protect */
|
#define EFI_MEMORY_RP ((u64)0x0000000000002000ULL) /* read-protect */
|
||||||
EFI_MEMORY_RP_SHIFT = 13, /* read-protect */
|
#define EFI_MEMORY_XP ((u64)0x0000000000004000ULL) /* execute-protect */
|
||||||
EFI_MEMORY_XP_SHIFT = 14, /* execute-protect */
|
#define EFI_MEMORY_NV ((u64)0x0000000000008000ULL) /* non-volatile */
|
||||||
EFI_MEMORY_RUNTIME_SHIFT = 63, /* range requires runtime mapping */
|
#define EFI_MEMORY_MORE_RELIABLE \
|
||||||
|
((u64)0x0000000000010000ULL) /* higher reliability */
|
||||||
EFI_MEMORY_RUNTIME = 1ULL << EFI_MEMORY_RUNTIME_SHIFT,
|
#define EFI_MEMORY_RO ((u64)0x0000000000020000ULL) /* read-only */
|
||||||
EFI_MEM_DESC_VERSION = 1,
|
#define EFI_MEMORY_RUNTIME ((u64)0x8000000000000000ULL) /* range requires runtime mapping */
|
||||||
};
|
#define EFI_MEM_DESC_VERSION 1
|
||||||
|
|
||||||
#define EFI_PAGE_SHIFT 12
|
#define EFI_PAGE_SHIFT 12
|
||||||
#define EFI_PAGE_SIZE (1UL << EFI_PAGE_SHIFT)
|
#define EFI_PAGE_SIZE (1UL << EFI_PAGE_SHIFT)
|
||||||
|
@ -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_data __attribute__ ((section (".data.efi_runtime")))
|
||||||
#define __efi_runtime __attribute__ ((section (".text.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
|
/* Call this with mmio_ptr as the _pointer_ to a pointer to an MMIO region
|
||||||
* to make it available at runtime */
|
* to make it available at runtime */
|
||||||
efi_status_t efi_add_runtime_mmio(void *mmio_ptr, u64 len);
|
efi_status_t efi_add_runtime_mmio(void *mmio_ptr, u64 len);
|
||||||
|
26
lib/crc32.c
26
lib/crc32.c
@ -12,6 +12,7 @@
|
|||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#else
|
#else
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
|
#include <efi_loader.h>
|
||||||
#endif
|
#endif
|
||||||
#include <compiler.h>
|
#include <compiler.h>
|
||||||
#include <u-boot/crc.h>
|
#include <u-boot/crc.h>
|
||||||
@ -21,16 +22,18 @@
|
|||||||
#endif
|
#endif
|
||||||
#include "u-boot/zlib.h"
|
#include "u-boot/zlib.h"
|
||||||
|
|
||||||
#define local static
|
#ifdef USE_HOSTCC
|
||||||
#define ZEXPORT /* empty */
|
#define __efi_runtime
|
||||||
|
#define __efi_runtime_data
|
||||||
|
#endif
|
||||||
|
|
||||||
#define tole(x) cpu_to_le32(x)
|
#define tole(x) cpu_to_le32(x)
|
||||||
|
|
||||||
#ifdef CONFIG_DYNAMIC_CRC_TABLE
|
#ifdef CONFIG_DYNAMIC_CRC_TABLE
|
||||||
|
|
||||||
local int crc_table_empty = 1;
|
static int __efi_runtime_data crc_table_empty = 1;
|
||||||
local uint32_t crc_table[256];
|
static uint32_t __efi_runtime_data crc_table[256];
|
||||||
local void make_crc_table OF((void));
|
static void __efi_runtime make_crc_table OF((void));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Generate a table for a byte-wise 32-bit CRC calculation on the polynomial:
|
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
|
the information needed to generate CRC's on data a byte at a time for all
|
||||||
combinations of CRC register values and incoming bytes.
|
combinations of CRC register values and incoming bytes.
|
||||||
*/
|
*/
|
||||||
local void make_crc_table()
|
static void __efi_runtime make_crc_table(void)
|
||||||
{
|
{
|
||||||
uint32_t c;
|
uint32_t c;
|
||||||
int n, k;
|
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)
|
* 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(0x00000000L), tole(0x77073096L), tole(0xee0e612cL), tole(0x990951baL),
|
||||||
tole(0x076dc419L), tole(0x706af48fL), tole(0xe963a535L), tole(0x9e6495a3L),
|
tole(0x076dc419L), tole(0x706af48fL), tole(0xe963a535L), tole(0x9e6495a3L),
|
||||||
tole(0x0edb8832L), tole(0x79dcb8a4L), tole(0xe0d5e91eL), tole(0x97d2d988L),
|
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 ?)
|
/* No ones complement version. JFFS2 (and other things ?)
|
||||||
* don't use ones compliment in their CRC calculations.
|
* 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 *tab = crc_table;
|
||||||
const uint32_t *b =(const uint32_t *)buf;
|
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
|
#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;
|
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
|
* Calculate the crc32 checksum triggering the watchdog every 'chunk_sz' bytes
|
||||||
* of input.
|
* of input.
|
||||||
*/
|
*/
|
||||||
uint32_t ZEXPORT crc32_wd (uint32_t crc,
|
uint32_t crc32_wd(uint32_t crc, const unsigned char *buf, uInt len,
|
||||||
const unsigned char *buf,
|
uInt chunk_sz)
|
||||||
uInt len, uInt chunk_sz)
|
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
|
#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
|
||||||
const unsigned char *end, *curr;
|
const unsigned char *end, *curr;
|
||||||
|
@ -153,18 +153,6 @@ const char *__efi_nesting_dec(void)
|
|||||||
return indent_string(--nesting_level);
|
return indent_string(--nesting_level);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
* efi_queue_event() - queue an EFI event
|
||||||
* @event: event to signal
|
* @event: event to signal
|
||||||
@ -627,7 +615,8 @@ efi_status_t efi_create_event(uint32_t type, efi_uintn_t notify_tpl,
|
|||||||
return EFI_INVALID_PARAMETER;
|
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;
|
return EFI_INVALID_PARAMETER;
|
||||||
|
|
||||||
evt = calloc(1, sizeof(struct efi_event));
|
evt = calloc(1, sizeof(struct efi_event));
|
||||||
|
@ -105,14 +105,6 @@ static int term_read_reply(int *n, int num, char end_char)
|
|||||||
return 0;
|
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(
|
static efi_status_t EFIAPI efi_cout_output_string(
|
||||||
struct efi_simple_text_output_protocol *this,
|
struct efi_simple_text_output_protocol *this,
|
||||||
const efi_string_t string)
|
const efi_string_t string)
|
||||||
@ -341,6 +333,20 @@ static efi_status_t EFIAPI efi_cout_clear_screen(
|
|||||||
return EFI_EXIT(EFI_SUCCESS);
|
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(
|
static efi_status_t EFIAPI efi_cout_set_cursor_position(
|
||||||
struct efi_simple_text_output_protocol *this,
|
struct efi_simple_text_output_protocol *this,
|
||||||
unsigned long column, unsigned long row)
|
unsigned long column, unsigned long row)
|
||||||
|
@ -178,14 +178,13 @@ uint64_t efi_add_memory_map(uint64_t start, uint64_t pages, int memory_type,
|
|||||||
switch (memory_type) {
|
switch (memory_type) {
|
||||||
case EFI_RUNTIME_SERVICES_CODE:
|
case EFI_RUNTIME_SERVICES_CODE:
|
||||||
case EFI_RUNTIME_SERVICES_DATA:
|
case EFI_RUNTIME_SERVICES_DATA:
|
||||||
newlist->desc.attribute = (1 << EFI_MEMORY_WB_SHIFT) |
|
newlist->desc.attribute = EFI_MEMORY_WB | EFI_MEMORY_RUNTIME;
|
||||||
(1ULL << EFI_MEMORY_RUNTIME_SHIFT);
|
|
||||||
break;
|
break;
|
||||||
case EFI_MMAP_IO:
|
case EFI_MMAP_IO:
|
||||||
newlist->desc.attribute = 1ULL << EFI_MEMORY_RUNTIME_SHIFT;
|
newlist->desc.attribute = EFI_MEMORY_RUNTIME;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
newlist->desc.attribute = 1 << EFI_MEMORY_WB_SHIFT;
|
newlist->desc.attribute = EFI_MEMORY_WB;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,7 +304,7 @@ efi_status_t efi_allocate_pages(int type, int memory_type,
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case EFI_ALLOCATE_ANY_PAGES:
|
case EFI_ALLOCATE_ANY_PAGES:
|
||||||
/* Any page */
|
/* Any page */
|
||||||
addr = efi_find_free_memory(len, -1ULL);
|
addr = efi_find_free_memory(len, gd->start_addr_sp);
|
||||||
if (!addr) {
|
if (!addr) {
|
||||||
r = EFI_NOT_FOUND;
|
r = EFI_NOT_FOUND;
|
||||||
break;
|
break;
|
||||||
@ -457,11 +456,13 @@ efi_status_t efi_get_memory_map(efi_uintn_t *memory_map_size,
|
|||||||
efi_uintn_t map_size = 0;
|
efi_uintn_t map_size = 0;
|
||||||
int map_entries = 0;
|
int map_entries = 0;
|
||||||
struct list_head *lhandle;
|
struct list_head *lhandle;
|
||||||
efi_uintn_t provided_map_size = *memory_map_size;
|
efi_uintn_t provided_map_size;
|
||||||
|
|
||||||
if (!memory_map_size)
|
if (!memory_map_size)
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
|
|
||||||
|
provided_map_size = *memory_map_size;
|
||||||
|
|
||||||
list_for_each(lhandle, &efi_mem)
|
list_for_each(lhandle, &efi_mem)
|
||||||
map_entries++;
|
map_entries++;
|
||||||
|
|
||||||
|
@ -84,6 +84,32 @@ struct elf_rela {
|
|||||||
* handle a good number of runtime callbacks
|
* 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(
|
static void EFIAPI efi_reset_system_boottime(
|
||||||
enum efi_reset_type reset_type,
|
enum efi_reset_type reset_type,
|
||||||
efi_status_t reset_status,
|
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
|
* See the Unified Extensible Firmware Interface (UEFI) specification
|
||||||
* for details.
|
* for details.
|
||||||
*
|
*
|
||||||
* @time: pointer to structure to receive current time
|
* @time: pointer to structure to receive current time
|
||||||
* @capabilities: pointer to structure to receive RTC properties
|
* @capabilities: pointer to structure to receive RTC properties
|
||||||
* Return Value: status code
|
* Returns: status code
|
||||||
*/
|
*/
|
||||||
static efi_status_t EFIAPI efi_get_time_boottime(
|
static efi_status_t EFIAPI efi_get_time_boottime(
|
||||||
struct efi_time *time,
|
struct efi_time *time,
|
||||||
@ -179,8 +207,22 @@ out:
|
|||||||
#endif
|
#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(
|
void __weak __efi_runtime EFIAPI efi_reset_system(
|
||||||
enum efi_reset_type reset_type,
|
enum efi_reset_type reset_type,
|
||||||
efi_status_t reset_status,
|
efi_status_t reset_status,
|
||||||
@ -190,11 +232,30 @@ void __weak __efi_runtime EFIAPI efi_reset_system(
|
|||||||
while (1) { }
|
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)
|
efi_status_t __weak efi_reset_system_init(void)
|
||||||
{
|
{
|
||||||
return EFI_SUCCESS;
|
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(
|
efi_status_t __weak __efi_runtime EFIAPI efi_get_time(
|
||||||
struct efi_time *time,
|
struct efi_time *time,
|
||||||
struct efi_time_cap *capabilities)
|
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);
|
debug("%s: Setting %p to %lx\n", __func__, p, newaddr);
|
||||||
*p = newaddr;
|
*p = newaddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Update crc32 */
|
||||||
|
efi_update_table_header_crc32(&efi_runtime_services.hdr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Relocate EFI runtime to uboot_reloc_base = offset */
|
/* 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();
|
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(
|
static efi_status_t EFIAPI efi_set_virtual_address_map(
|
||||||
unsigned long memory_map_size,
|
unsigned long memory_map_size,
|
||||||
unsigned long descriptor_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_start = map->physical_start;
|
||||||
efi_physical_addr_t map_len = map->num_pages << EFI_PAGE_SHIFT;
|
efi_physical_addr_t map_len = map->num_pages << EFI_PAGE_SHIFT;
|
||||||
efi_physical_addr_t map_end = map_start + map_len;
|
efi_physical_addr_t map_end = map_start + map_len;
|
||||||
|
u64 off = map->virtual_start - map_start;
|
||||||
|
|
||||||
/* Adjust all mmio pointers in this region */
|
/* Adjust all mmio pointers in this region */
|
||||||
list_for_each(lhandle, &efi_runtime_mmio) {
|
list_for_each(lhandle, &efi_runtime_mmio) {
|
||||||
@ -370,11 +449,17 @@ static efi_status_t EFIAPI efi_set_virtual_address_map(
|
|||||||
link);
|
link);
|
||||||
if ((map_start <= lmmio->paddr) &&
|
if ((map_start <= lmmio->paddr) &&
|
||||||
(map_end >= lmmio->paddr)) {
|
(map_end >= lmmio->paddr)) {
|
||||||
u64 off = map->virtual_start - map_start;
|
|
||||||
uintptr_t new_addr = lmmio->paddr + off;
|
uintptr_t new_addr = lmmio->paddr + off;
|
||||||
*lmmio->ptr = (void *)new_addr;
|
*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 */
|
/* 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);
|
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)
|
efi_status_t efi_add_runtime_mmio(void *mmio_ptr, u64 len)
|
||||||
{
|
{
|
||||||
struct efi_runtime_mmio_list *newmmio;
|
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.
|
* 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)
|
static efi_status_t __efi_runtime EFIAPI efi_unimplemented(void)
|
||||||
{
|
{
|
||||||
return EFI_UNSUPPORTED;
|
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)
|
static efi_status_t __efi_runtime EFIAPI efi_device_error(void)
|
||||||
{
|
{
|
||||||
return EFI_DEVICE_ERROR;
|
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)
|
static efi_status_t __efi_runtime EFIAPI efi_invalid_parameter(void)
|
||||||
{
|
{
|
||||||
return EFI_INVALID_PARAMETER;
|
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(
|
efi_status_t __efi_runtime EFIAPI efi_update_capsule(
|
||||||
struct efi_capsule_header **capsule_header_array,
|
struct efi_capsule_header **capsule_header_array,
|
||||||
efi_uintn_t capsule_count,
|
efi_uintn_t capsule_count,
|
||||||
@ -462,6 +597,20 @@ efi_status_t __efi_runtime EFIAPI efi_update_capsule(
|
|||||||
return EFI_UNSUPPORTED;
|
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(
|
efi_status_t __efi_runtime EFIAPI efi_query_capsule_caps(
|
||||||
struct efi_capsule_header **capsule_header_array,
|
struct efi_capsule_header **capsule_header_array,
|
||||||
efi_uintn_t capsule_count,
|
efi_uintn_t capsule_count,
|
||||||
@ -471,6 +620,24 @@ efi_status_t __efi_runtime EFIAPI efi_query_capsule_caps(
|
|||||||
return EFI_UNSUPPORTED;
|
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(
|
efi_status_t __efi_runtime EFIAPI efi_query_variable_info(
|
||||||
u32 attributes,
|
u32 attributes,
|
||||||
u64 *maximum_variable_storage_size,
|
u64 *maximum_variable_storage_size,
|
||||||
|
@ -415,7 +415,7 @@ static int execute(void)
|
|||||||
|
|
||||||
#ifdef CONFIG_FAT_WRITE
|
#ifdef CONFIG_FAT_WRITE
|
||||||
/* Write file */
|
/* 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);
|
EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, 0);
|
||||||
if (ret != EFI_SUCCESS) {
|
if (ret != EFI_SUCCESS) {
|
||||||
efi_st_error("Failed to open file\n");
|
efi_st_error("Failed to open file\n");
|
||||||
|
Reference in New Issue
Block a user