summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/bloblist.c15
-rw-r--r--common/fdt_support.c9
-rw-r--r--common/malloc_simple.c2
-rw-r--r--common/spl/Kconfig24
-rw-r--r--common/spl/spl.c12
-rw-r--r--common/spl/spl_ymodem.c15
-rw-r--r--common/usb_kbd.c31
7 files changed, 91 insertions, 17 deletions
diff --git a/common/bloblist.c b/common/bloblist.c
index 056b50c2cb6..406073c8105 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -430,18 +430,23 @@ void bloblist_reloc(void *to, uint to_size, void *from, uint from_size)
int bloblist_init(void)
{
+ bool fixed = IS_ENABLED(CONFIG_BLOBLIST_FIXED);
int ret = -ENOENT;
ulong addr, size;
bool expected;
/**
- * Wed expect to find an existing bloblist in the first phase of U-Boot
- * that runs
+ * We don't expect to find an existing bloblist in the first phase of
+ * U-Boot that runs. Also we have no way to receive the address of an
+ * allocated bloblist from a previous stage, so it must be at a fixed
+ * address.
*/
- expected = !u_boot_first_phase();
+ expected = fixed && !u_boot_first_phase();
if (spl_prev_phase() == PHASE_TPL && !IS_ENABLED(CONFIG_TPL_BLOBLIST))
expected = false;
- addr = bloblist_addr();
+ if (fixed)
+ addr = IF_ENABLED_INT(CONFIG_BLOBLIST_FIXED,
+ CONFIG_BLOBLIST_ADDR);
size = CONFIG_BLOBLIST_SIZE;
if (expected) {
ret = bloblist_check(addr, size);
@@ -460,6 +465,8 @@ int bloblist_init(void)
if (!ptr)
return log_msg_ret("alloc", -ENOMEM);
addr = map_to_sysmem(ptr);
+ } else if (!fixed) {
+ return log_msg_ret("!fixed", ret);
}
log_debug("Creating new bloblist size %lx at %lx\n", size,
addr);
diff --git a/common/fdt_support.c b/common/fdt_support.c
index daa24d4c10b..ea18ea3f045 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -988,7 +988,7 @@ void fdt_fixup_mtdparts(void *blob, const struct node_info *node_info,
{
struct mtd_device *dev;
int i, idx;
- int noff;
+ int noff, parts;
bool inited = false;
for (i = 0; i < node_info_size; i++) {
@@ -1014,7 +1014,12 @@ void fdt_fixup_mtdparts(void *blob, const struct node_info *node_info,
dev = device_find(node_info[i].type, idx++);
if (dev) {
- if (fdt_node_set_part_info(blob, noff, dev))
+ parts = fdt_subnode_offset(blob, noff,
+ "partitions");
+ if (parts < 0)
+ parts = noff;
+
+ if (fdt_node_set_part_info(blob, parts, dev))
return; /* return on error */
}
}
diff --git a/common/malloc_simple.c b/common/malloc_simple.c
index 0267fb6bec8..67ee623850e 100644
--- a/common/malloc_simple.c
+++ b/common/malloc_simple.c
@@ -23,7 +23,7 @@ static void *alloc_simple(size_t bytes, int align)
addr = ALIGN(gd->malloc_base + gd->malloc_ptr, align);
new_ptr = addr + bytes - gd->malloc_base;
- log_debug("size=%zx, ptr=%lx, limit=%lx: ", bytes, new_ptr,
+ log_debug("size=%lx, ptr=%lx, limit=%lx: ", (ulong)bytes, new_ptr,
gd->malloc_limit);
if (new_ptr > gd->malloc_limit) {
log_err("alloc space exhausted\n");
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index e0d0a6f77b5..9418d37b2e2 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -101,6 +101,18 @@ config SPL_SHOW_ERRORS
This adds a small amount to SPL code size, perhaps 100 bytes.
+config SPL_BINMAN_SYMBOLS
+ bool "Declare binman symbols in SPL"
+ depends on SPL_FRAMEWORK && BINMAN
+ default y
+ help
+ This enables use of symbols in SPL which refer to U-Boot, enabling SPL
+ to obtain the location of U-Boot simply by calling spl_get_image_pos()
+ and spl_get_image_size().
+
+ For this to work, you must have a U-Boot image in the binman image, so
+ binman can update SPL with the location of it.
+
menu "PowerPC and LayerScape SPL Boot options"
config SPL_NAND_BOOT
@@ -1321,6 +1333,18 @@ config TPL_SIZE_LIMIT
Specifies the maximum length of the U-Boot TPL image.
If this value is zero, it is ignored.
+config TPL_BINMAN_SYMBOLS
+ bool "Declare binman symbols in SPL"
+ depends on SPL_FRAMEWORK && BINMAN
+ default y
+ help
+ This enables use of symbols in TPL which refer to U-Boot, enabling SPL
+ to obtain the location of U-Boot simply by calling spl_get_image_pos()
+ and spl_get_image_size().
+
+ For this to work, you must have a U-Boot image in the binman image, so
+ binman can update SPL with the location of it.
+
config TPL_FRAMEWORK
bool "Support TPL based upon the common SPL framework"
default y if SPL_FRAMEWORK
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 884102bdea4..b452d4feeb2 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -49,13 +49,15 @@ DECLARE_GLOBAL_DATA_PTR;
u32 *boot_params_ptr = NULL;
+#if CONFIG_IS_ENABLED(BINMAN_SYMBOLS)
/* See spl.h for information about this */
binman_sym_declare(ulong, u_boot_any, image_pos);
binman_sym_declare(ulong, u_boot_any, size);
+#endif
#ifdef CONFIG_TPL
-binman_sym_declare(ulong, spl, image_pos);
-binman_sym_declare(ulong, spl, size);
+binman_sym_declare(ulong, u_boot_spl, image_pos);
+binman_sym_declare(ulong, u_boot_spl, size);
#endif
/* Define board data structure */
@@ -140,19 +142,21 @@ void spl_fixup_fdt(void *fdt_blob)
#endif
}
+#if CONFIG_IS_ENABLED(BINMAN_SYMBOLS)
ulong spl_get_image_pos(void)
{
return spl_phase() == PHASE_TPL ?
- binman_sym(ulong, spl, image_pos) :
+ binman_sym(ulong, u_boot_spl, image_pos) :
binman_sym(ulong, u_boot_any, image_pos);
}
ulong spl_get_image_size(void)
{
return spl_phase() == PHASE_TPL ?
- binman_sym(ulong, spl, size) :
+ binman_sym(ulong, u_boot_spl, size) :
binman_sym(ulong, u_boot_any, size);
}
+#endif /* BINMAN_SYMBOLS */
ulong spl_get_image_text_base(void)
{
diff --git a/common/spl/spl_ymodem.c b/common/spl/spl_ymodem.c
index 047df74856b..fdd52610429 100644
--- a/common/spl/spl_ymodem.c
+++ b/common/spl/spl_ymodem.c
@@ -42,6 +42,7 @@ static ulong ymodem_read_fit(struct spl_load_info *load, ulong offset,
int res, err, buf_offset;
struct ymodem_fit_info *info = load->priv;
char *buf = info->buf;
+ ulong copy_size = size;
while (info->image_read < offset) {
res = xyzModem_stream_read(buf, BUF_SIZE, &err);
@@ -57,8 +58,14 @@ static ulong ymodem_read_fit(struct spl_load_info *load, ulong offset,
buf_offset = (info->image_read % BUF_SIZE);
else
buf_offset = BUF_SIZE;
+
+ if (res > copy_size) {
+ memcpy(addr, &buf[buf_offset - res], copy_size);
+ goto done;
+ }
memcpy(addr, &buf[buf_offset - res], res);
addr = addr + res;
+ copy_size -= res;
}
while (info->image_read < offset + size) {
@@ -66,11 +73,17 @@ static ulong ymodem_read_fit(struct spl_load_info *load, ulong offset,
if (res <= 0)
break;
- memcpy(addr, buf, res);
info->image_read += res;
+ if (res > copy_size) {
+ memcpy(addr, buf, copy_size);
+ goto done;
+ }
+ memcpy(addr, buf, res);
addr += res;
+ copy_size -= res;
}
+done:
return size;
}
diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index afad260d3dc..352d86fb2ec 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
@@ -17,6 +17,9 @@
#include <stdio_dev.h>
#include <watchdog.h>
#include <asm/byteorder.h>
+#ifdef CONFIG_SANDBOX
+#include <asm/state.h>
+#endif
#include <usb.h>
@@ -118,7 +121,7 @@ struct usb_kbd_pdata {
extern int __maybe_unused net_busy_flag;
/* The period of time between two calls of usb_kbd_testc(). */
-static unsigned long __maybe_unused kbd_testc_tms;
+static unsigned long kbd_testc_tms;
/* Puts character in the queue and sets up the in and out pointer. */
static void usb_kbd_put_queue(struct usb_kbd_pdata *data, u8 c)
@@ -394,21 +397,39 @@ static int usb_kbd_testc(struct stdio_dev *sdev)
struct usb_device *usb_kbd_dev;
struct usb_kbd_pdata *data;
+ /*
+ * Polling the keyboard for an event can take dozens of milliseconds.
+ * Add a delay between polls to avoid blocking activity which polls
+ * rapidly, like the UEFI console timer.
+ */
+ unsigned long poll_delay = CONFIG_SYS_HZ / 50;
+
#ifdef CONFIG_CMD_NET
/*
* If net_busy_flag is 1, NET transfer is running,
* then we check key-pressed every second (first check may be
* less than 1 second) to improve TFTP booting performance.
*/
- if (net_busy_flag && (get_timer(kbd_testc_tms) < CONFIG_SYS_HZ))
- return 0;
- kbd_testc_tms = get_timer(0);
+ if (net_busy_flag)
+ poll_delay = CONFIG_SYS_HZ;
+#endif
+
+#ifdef CONFIG_SANDBOX
+ /*
+ * Skip delaying polls if a test requests it.
+ */
+ if (state_get_skip_delays())
+ poll_delay = 0;
#endif
+
dev = stdio_get_by_name(sdev->name);
usb_kbd_dev = (struct usb_device *)dev->priv;
data = usb_kbd_dev->privptr;
- usb_kbd_poll_for_event(usb_kbd_dev);
+ if (get_timer(kbd_testc_tms) >= poll_delay) {
+ usb_kbd_poll_for_event(usb_kbd_dev);
+ kbd_testc_tms = get_timer(0);
+ }
return !(data->usb_in_pointer == data->usb_out_pointer);
}