summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/efi_loader/efi_memory.c2
-rw-r--r--lib/fdtdec.c38
-rw-r--r--lib/hashtable.c7
-rw-r--r--lib/libfdt/Makefile1
-rw-r--r--lib/libfdt/fdt_check.c2
-rw-r--r--lib/lmb.c26
-rw-r--r--lib/rsa/Kconfig8
-rw-r--r--lib/string.c51
8 files changed, 59 insertions, 76 deletions
diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index 2feb29f0a2c..c3da7c20cb2 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -871,7 +871,7 @@ static void add_u_boot_and_runtime(void)
/* Add U-Boot */
uboot_start = ((uintptr_t)map_sysmem(gd->start_addr_sp, 0) -
uboot_stack_size) & ~EFI_PAGE_MASK;
- uboot_pages = ((uintptr_t)map_sysmem(gd->ram_top - 1, 0) -
+ uboot_pages = ((uintptr_t)map_sysmem(gd->initial_relocaddr - 1, 0) -
uboot_start + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT;
efi_update_memory_map(uboot_start, uboot_pages, EFI_BOOT_SERVICES_CODE,
false, false);
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index c67b6e8c133..b91e067106d 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -35,6 +35,7 @@
#include <linux/ctype.h>
#include <linux/lzo.h>
#include <linux/ioport.h>
+#include <asm/global_data.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -1142,14 +1143,14 @@ int fdtdec_setup_memory_banksize(void)
if (ret != 0)
return -EINVAL;
- gd->bd->bi_dram[bank].start = (phys_addr_t)res.start;
- gd->bd->bi_dram[bank].size =
+ gd->dram[bank].start = (phys_addr_t)res.start;
+ gd->dram[bank].size =
(phys_size_t)(res.end - res.start + 1);
debug("%s: DRAM Bank #%d: start = %pap, size = %pap\n",
__func__, bank,
- &gd->bd->bi_dram[bank].start,
- &gd->bd->bi_dram[bank].size);
+ &gd->dram[bank].start,
+ &gd->dram[bank].size);
}
return 0;
@@ -1822,17 +1823,12 @@ int fdtdec_setup(void)
int ret = -ENOENT;
/*
- * If allowing a bloblist, check that first. There was discussion about
- * adding an OF_BLOBLIST Kconfig, but this was rejected.
- *
- * The necessary test is whether the previous phase passed a bloblist,
- * not whether this phase creates one.
+ * If allowing a bloblist, check that first. The necessary test is
+ * whether the previous phase passed a bloblist, not whether this phase
+ * creates one.
*/
- if (CONFIG_IS_ENABLED(BLOBLIST) &&
- (xpl_prev_phase() != PHASE_TPL ||
- IS_ENABLED(CONFIG_TPL_BLOBLIST))) {
- ret = bloblist_maybe_init();
- if (!ret) {
+ if (CONFIG_IS_ENABLED(BLOBLIST) && (xpl_phase() > PHASE_TPL)) {
+ if (bloblist_exists()) {
gd->fdt_blob = bloblist_find(BLOBLISTT_CONTROL_FDT, 0);
if (gd->fdt_blob) {
gd->fdt_src = FDTSRC_BLOBLIST;
@@ -1935,7 +1931,7 @@ int fdtdec_resetup(int *rescan)
int fdtdec_decode_ram_size(const void *blob, const char *area, int board_id,
phys_addr_t *basep, phys_size_t *sizep,
- struct bd_info *bd)
+ gd_t *gd_ptr)
{
int addr_cells, size_cells;
const u32 *cell, *end;
@@ -1987,8 +1983,8 @@ int fdtdec_decode_ram_size(const void *blob, const char *area, int board_id,
}
/* Note: if no matching subnode was found we use the parent node */
- if (bd) {
- memset(bd->bi_dram, '\0', sizeof(bd->bi_dram[0]) *
+ if (gd_ptr) {
+ memset(gd_ptr->dram, '\0', sizeof(gd_ptr->dram[0]) *
CONFIG_NR_DRAM_BANKS);
}
@@ -2004,8 +2000,8 @@ int fdtdec_decode_ram_size(const void *blob, const char *area, int board_id,
if (addr_cells == 2)
addr += (u64)fdt32_to_cpu(*cell++) << 32UL;
addr += fdt32_to_cpu(*cell++);
- if (bd)
- bd->bi_dram[bank].start = addr;
+ if (gd_ptr)
+ gd_ptr->dram[bank].start = addr;
if (basep && !bank)
*basep = (phys_addr_t)addr;
@@ -2027,8 +2023,8 @@ int fdtdec_decode_ram_size(const void *blob, const char *area, int board_id,
}
}
- if (bd)
- bd->bi_dram[bank].size = size;
+ if (gd_ptr)
+ gd_ptr->dram[bank].size = size;
total_size += size;
}
diff --git a/lib/hashtable.c b/lib/hashtable.c
index 75c263b5053..f96a8e686f6 100644
--- a/lib/hashtable.c
+++ b/lib/hashtable.c
@@ -821,13 +821,12 @@ int himport_r(struct hsearch_data *htab,
}
/* we allocate new space to make sure we can write to the array */
- if ((data = malloc(size + 1)) == NULL) {
- debug("himport_r: can't malloc %lu bytes\n", (ulong)size + 1);
+ data = memdup_nul(env, size);
+ if (data == NULL) {
+ debug("himport_r: can't duplicate env block\n");
__set_errno(ENOMEM);
return 0;
}
- memcpy(data, env, size);
- data[size] = '\0';
dp = data;
/* make a local copy of the list of variables */
diff --git a/lib/libfdt/Makefile b/lib/libfdt/Makefile
index c492377032b..b4113cfb478 100644
--- a/lib/libfdt/Makefile
+++ b/lib/libfdt/Makefile
@@ -5,6 +5,7 @@
obj-y += \
fdt.o \
+ fdt_check.o \
fdt_ro.o \
fdt_wip.o \
fdt_strerror.o \
diff --git a/lib/libfdt/fdt_check.c b/lib/libfdt/fdt_check.c
new file mode 100644
index 00000000000..b7fa4a7c0bb
--- /dev/null
+++ b/lib/libfdt/fdt_check.c
@@ -0,0 +1,2 @@
+#include <linux/libfdt_env.h>
+#include "../../scripts/dtc/libfdt/fdt_check.c"
diff --git a/lib/lmb.c b/lib/lmb.c
index 275d105c5aa..77440a48486 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -540,13 +540,14 @@ static void lmb_reserve_uboot_region(void)
ulong pram = 0;
rsv_start = gd->start_addr_sp - CONFIG_STACK_SIZE;
- end = gd->ram_top;
+ end = gd->initial_relocaddr;
/*
* Reserve memory from aligned address below the bottom of U-Boot stack
- * until end of RAM area to prevent LMB from overwriting that memory.
+ * until the original relocation address to prevent LMB from
+ * overwriting that memory.
*/
- debug("## Current stack ends at 0x%08lx ", (ulong)rsv_start);
+ debug("## Current stack ends at 0x%08lx\n", (ulong)rsv_start);
#ifdef CFG_PRAM
pram = env_get_ulong("pram", 10, CFG_PRAM);
@@ -554,12 +555,12 @@ static void lmb_reserve_uboot_region(void)
#endif
for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
- if (!gd->bd->bi_dram[bank].size ||
- rsv_start < gd->bd->bi_dram[bank].start)
+ if (!gd->dram[bank].size ||
+ rsv_start < gd->dram[bank].start)
continue;
/* Watch out for RAM at end of address space! */
- bank_end = gd->bd->bi_dram[bank].start +
- gd->bd->bi_dram[bank].size - 1;
+ bank_end = gd->dram[bank].start +
+ gd->dram[bank].size - 1;
if (rsv_start > bank_end)
continue;
if (bank_end > end)
@@ -614,7 +615,6 @@ static void lmb_add_memory(void)
phys_addr_t bank_end;
phys_size_t size;
u64 ram_top = gd->ram_top;
- struct bd_info *bd = gd->bd;
if (CONFIG_IS_ENABLED(LMB_ARCH_MEM_MAP))
return lmb_arch_add_memory();
@@ -624,22 +624,22 @@ static void lmb_add_memory(void)
ram_top = 0x100000000ULL;
for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
- size = bd->bi_dram[i].size;
+ size = gd->dram[i].size;
if (size) {
- lmb_add(bd->bi_dram[i].start, size);
+ lmb_add(gd->dram[i].start, size);
if (!IS_ENABLED(CONFIG_LMB_LIMIT_DMA_BELOW_RAM_TOP))
continue;
- bank_end = bd->bi_dram[i].start + size;
+ bank_end = gd->dram[i].start + size;
/*
* Reserve memory above ram_top as
* no-overwrite so that it cannot be
* allocated
*/
- if (bd->bi_dram[i].start >= ram_top)
- lmb_reserve(bd->bi_dram[i].start, size,
+ if (gd->dram[i].start >= ram_top)
+ lmb_reserve(gd->dram[i].start, size,
LMB_NOOVERWRITE);
else if (bank_end > ram_top)
lmb_reserve(ram_top, bank_end - ram_top,
diff --git a/lib/rsa/Kconfig b/lib/rsa/Kconfig
index 12a71c3df6f..deaad0bba02 100644
--- a/lib/rsa/Kconfig
+++ b/lib/rsa/Kconfig
@@ -94,14 +94,14 @@ config RSA_FREESCALE_EXP
bool "Enable RSA Modular Exponentiation with FSL crypto accelerator"
depends on DM && FSL_CAAM && !ARCH_MX7 && !ARCH_MX7ULP && !ARCH_MX6 && !ARCH_MX5
help
- Enables driver for RSA modular exponentiation using Freescale cryptographic
- accelerator - CAAM.
+ Enables driver for RSA modular exponentiation using Freescale cryptographic
+ accelerator - CAAM.
config RSA_ASPEED_EXP
bool "Enable RSA Modular Exponentiation with ASPEED crypto accelerator"
depends on DM && ASPEED_ACRY
help
- Enables driver for RSA modular exponentiation using ASPEED cryptographic
- accelerator - ACRY
+ Enables driver for RSA modular exponentiation using ASPEED cryptographic
+ accelerator - ACRY
endif
diff --git a/lib/string.c b/lib/string.c
index 302efe048b0..37ea8c29561 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -343,41 +343,29 @@ size_t strcspn(const char *s, const char *reject)
}
#endif
-#ifndef __HAVE_ARCH_STRDUP
-char * strdup(const char *s)
+void *memdup_nul(const void *src, size_t len)
{
- char *new;
+ char *dst;
- if ((s == NULL) ||
- ((new = malloc (strlen(s) + 1)) == NULL) ) {
+ if (len + 1 < len)
return NULL;
- }
- strcpy (new, s);
- return new;
-}
-
-char * strndup(const char *s, size_t n)
-{
- size_t len;
- char *new;
-
- if (s == NULL)
+ dst = malloc(len + 1);
+ if (!dst)
return NULL;
- len = strlen(s);
-
- if (n < len)
- len = n;
-
- new = malloc(len + 1);
- if (new == NULL)
- return NULL;
+ dst[len] = '\0';
+ return memcpy(dst, src, len);
+}
- strncpy(new, s, len);
- new[len] = '\0';
+char * strdup(const char *s)
+{
+ return s ? memdup_nul(s, strlen(s)) : NULL;
+}
- return new;
+char * strndup(const char *s, size_t n)
+{
+ return s ? memdup_nul(s, strnlen(s, n)) : NULL;
}
/**
@@ -410,7 +398,6 @@ void kfree_const(const void *x)
free((void *)x);
}
-#endif
#ifndef __HAVE_ARCH_STRSPN
/**
@@ -698,17 +685,15 @@ void * memscan(void * addr, int c, size_t size)
}
#endif
-char *memdup(const void *src, size_t len)
+void *memdup(const void *src, size_t len)
{
- char *p;
+ void *p;
p = malloc(len);
if (!p)
return NULL;
- memcpy(p, src, len);
-
- return p;
+ return memcpy(p, src, len);
}
#ifndef __HAVE_ARCH_STRNSTR