summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/Kconfig2
-rw-r--r--common/autoboot.c11
-rw-r--r--common/bloblist.c67
-rw-r--r--common/board_f.c11
-rw-r--r--common/board_r.c6
-rw-r--r--common/cli.c4
-rw-r--r--common/console.c12
-rw-r--r--common/memsize.c75
-rw-r--r--common/spl/Kconfig5
-rw-r--r--common/update.c6
10 files changed, 177 insertions, 22 deletions
diff --git a/common/Kconfig b/common/Kconfig
index 2a167ec3ad3..8e8c733aa29 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -425,7 +425,7 @@ config LOGF_FUNC_PAD
config LOG_SYSLOG
bool "Log output to syslog server"
- depends on NET || NET_LWIP
+ depends on NET
help
Enables a log driver which broadcasts log records via UDP port 514
to syslog servers.
diff --git a/common/autoboot.c b/common/autoboot.c
index 1783ef92c94..4b80ddb5b28 100644
--- a/common/autoboot.c
+++ b/common/autoboot.c
@@ -316,15 +316,6 @@ static int passwd_abort_key(uint64_t etime)
}
/**
- * flush_stdin() - drops all pending characters from stdin
- */
-static void flush_stdin(void)
-{
- while (tstc())
- (void)getchar();
-}
-
-/**
* fallback_to_sha256() - check whether we should fall back to sha256
* password checking
*
@@ -354,7 +345,7 @@ static int abortboot_key_sequence(int bootdelay)
uint64_t etime = endtick(bootdelay);
if (IS_ENABLED(CONFIG_AUTOBOOT_FLUSH_STDIN))
- flush_stdin();
+ console_flush_stdin();
# ifdef CONFIG_AUTOBOOT_PROMPT
/*
* CONFIG_AUTOBOOT_PROMPT includes the %d for all boards.
diff --git a/common/bloblist.c b/common/bloblist.c
index d5fa62249a9..d084be89958 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -43,6 +43,7 @@ static struct tag_name {
{ BLOBLISTT_ACPI_TABLES, "ACPI tables for x86" },
{ BLOBLISTT_TPM_EVLOG, "TPM event log defined by TCG EFI" },
{ BLOBLISTT_TPM_CRB_BASE, "TPM Command Response Buffer address" },
+ { BLOBLISTT_FDT_OVERLAY, "DT overlay" },
/* BLOBLISTT_AREA_FIRMWARE */
{ BLOBLISTT_TPM2_TCG_LOG, "TPM v2 log space" },
@@ -96,6 +97,19 @@ static inline uint rec_tag(struct bloblist_rec *rec)
BLOBLISTR_TAG_SHIFT;
}
+static inline void void_blob(struct bloblist_rec *rec)
+{
+ if (rec_tag(rec) == BLOBLISTT_VOID)
+ return;
+ rec->tag_and_hdr_size = BLOBLISTT_VOID |
+ sizeof(*rec) << BLOBLISTR_HDR_SIZE_SHIFT;
+}
+
+static inline struct bloblist_rec *rec_from_blob(void *blob)
+{
+ return (blob - sizeof(struct bloblist_rec));
+}
+
static ulong bloblist_blob_end_ofs(struct bloblist_hdr *hdr,
struct bloblist_rec *rec)
{
@@ -222,6 +236,19 @@ static int bloblist_ensurerec(uint tag, struct bloblist_rec **recp, int size,
return 0;
}
+static int bloblist_get_blob_data_offset(uint tag)
+{
+ switch (tag) {
+ case BLOBLISTT_FDT_OVERLAY:
+ return sizeof(struct dto_blob_hdr);
+ /*
+ * return the data offset if it is not following the blob
+ * header immediately.
+ */
+ }
+ return 0;
+}
+
void *bloblist_find(uint tag, int size)
{
void *blob = NULL;
@@ -248,6 +275,44 @@ void *bloblist_get_blob(uint tag, int *sizep)
return (void *)rec + rec_hdr_size(rec);
}
+int bloblist_apply_blobs(uint tag, int (*func)(void **data, int size))
+{
+ struct bloblist_hdr *hdr = gd->bloblist;
+ struct bloblist_rec *rec;
+
+ if (!func || !hdr)
+ return -ENOENT;
+
+ foreach_rec(rec, hdr) {
+ /* Apply all blobs with the specified tag */
+ if (rec_tag(rec) == tag) {
+ int ret;
+ int tag = rec_tag(rec);
+ void *blob = (void *)rec + rec_hdr_size(rec);
+ int dat_off = bloblist_get_blob_data_offset(tag);
+
+ blob += dat_off;
+ ret = func(&blob, rec->size - dat_off);
+ if (ret) {
+ log_err("Failed to apply blob with tag %d\n",
+ tag);
+ return ret;
+ }
+
+ rec = rec_from_blob(blob - dat_off);
+ if (!rec) {
+ log_err("Blob corrupted\n");
+ return -ENOENT;
+ }
+
+ /* Mark applied blob record as void */
+ void_blob(rec);
+ }
+ }
+
+ return 0;
+}
+
void *bloblist_add(uint tag, int size, int align_log2)
{
struct bloblist_rec *rec;
@@ -322,7 +387,7 @@ static int bloblist_resize_rec(struct bloblist_hdr *hdr,
next_ofs = bloblist_blob_end_ofs(hdr, rec);
if (next_ofs != hdr->used_size) {
memmove((void *)hdr + next_ofs + expand_by,
- (void *)hdr + next_ofs, new_alloced - next_ofs);
+ (void *)hdr + next_ofs, hdr->used_size - next_ofs);
}
hdr->used_size = new_alloced;
diff --git a/common/board_f.c b/common/board_f.c
index 11ad5779115..ce87c619e68 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -813,7 +813,16 @@ static int initf_dm(void)
return 0;
bootstage_start(BOOTSTAGE_ID_ACCUM_DM_F, "dm_f");
- ret = dm_init_and_scan(true);
+
+ /*
+ * If SKIP_EARLY_DM is set then we just create an empty device
+ * model, the serial port will still be bound later through
+ * serial_find_console_or_panic() via /chosen/stdout-path
+ */
+ if (!CONFIG_IS_ENABLED(SKIP_EARLY_DM))
+ ret = dm_init_and_scan(true);
+ else
+ ret = dm_init(false);
if (ret)
return ret;
diff --git a/common/board_r.c b/common/board_r.c
index 5d37345ca09..a397e20959d 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -495,7 +495,7 @@ static int initr_boot_led_on(void)
return 0;
}
-#if CONFIG_IS_ENABLED(NET) || CONFIG_IS_ENABLED(NET_LWIP)
+#if CONFIG_IS_ENABLED(NET)
static int initr_net(void)
{
puts("Net: ");
@@ -687,7 +687,7 @@ static void initcall_run_r(void)
INITCALL(initr_flash);
#endif
WATCHDOG_RESET();
-#if CONFIG_IS_ENABLED(PPC) || CONFIG_IS_ENABLED(M68K) || CONFIG_IS_ENABLED(X86)
+#if IS_ENABLED(CONFIG_PPC) || CONFIG_IS_ENABLED(M68K) || CONFIG_IS_ENABLED(X86)
/* initialize higher level parts of CPU like time base and timers */
INITCALL(cpu_init_r);
#endif
@@ -760,7 +760,7 @@ static void initcall_run_r(void)
#if CONFIG_IS_ENABLED(PCI_ENDPOINT)
INITCALL(pci_ep_init);
#endif
-#if CONFIG_IS_ENABLED(NET) || CONFIG_IS_ENABLED(NET_LWIP)
+#if CONFIG_IS_ENABLED(NET)
WATCHDOG_RESET();
INITCALL(initr_net);
#endif
diff --git a/common/cli.c b/common/cli.c
index 4694a35cd0e..bcc7264d51a 100644
--- a/common/cli.c
+++ b/common/cli.c
@@ -295,6 +295,10 @@ err:
void cli_loop(void)
{
bootstage_mark(BOOTSTAGE_ID_ENTER_CLI_LOOP);
+
+ if (IS_ENABLED(CONFIG_CMDLINE_FLUSH_STDIN))
+ console_flush_stdin();
+
#if CONFIG_IS_ENABLED(HUSH_PARSER)
if (gd->flags & GD_FLG_HUSH_MODERN_PARSER)
parse_and_run_file();
diff --git a/common/console.c b/common/console.c
index 22e554cf203..54d1249422d 100644
--- a/common/console.c
+++ b/common/console.c
@@ -643,6 +643,15 @@ int tstc(void)
return serial_tstc();
}
+/**
+ * console_flush_stdin() - drops all pending characters from stdin
+ */
+void console_flush_stdin(void)
+{
+ while (tstc())
+ (void)getchar();
+}
+
#define PRE_CONSOLE_FLUSHPOINT1_SERIAL 0
#define PRE_CONSOLE_FLUSHPOINT2_EVERYTHING_BUT_SERIAL 1
@@ -914,8 +923,7 @@ int confirm_yesno(void)
char str_input[5];
/* Flush input */
- while (tstc())
- getchar();
+ console_flush_stdin();
i = 0;
while (i < sizeof(str_input)) {
str_input[i] = getchar();
diff --git a/common/memsize.c b/common/memsize.c
index 1abf3fc47d7..fd22f85a164 100644
--- a/common/memsize.c
+++ b/common/memsize.c
@@ -127,6 +127,81 @@ long get_ram_size(long *base, long maxsize)
return (maxsize);
}
+/**
+ * probe_ram_size_by_alias() - Detect RAM size using known alias addresses
+ * @checks: Array of RAM alias probe descriptors, terminated by a NULL
+ * @probe_addr entry
+ *
+ * Probe RAM size by writing a test pattern to each @probe_addr and checking
+ * whether the same pattern does not appear at the corresponding @alias_addr.
+ * This is useful on systems where address wrap-around does not alias to the
+ * base of memory in a linear way, so get_ram_size() cannot be used directly.
+ * It is also useful on systems where the base of the physical memory cannot
+ * be safely accessed, so get_ram_size() cannot be used at all.
+ *
+ * Return: The size associated with the first matching entry, or 0 if no match
+ * is found.
+ */
+long probe_ram_size_by_alias(const struct ram_alias_check *checks)
+{
+ long save[2];
+ long pat;
+ int dcache_en = 0;
+ long ret = 0;
+
+ if (!CONFIG_IS_ENABLED(SYS_DCACHE_OFF))
+ dcache_en = dcache_status();
+
+ while (checks->probe_addr && !ret) {
+ volatile long *d = checks->probe_addr;
+ volatile long *s = checks->alias_addr;
+
+ save[0] = *s;
+ save[1] = *d;
+ /* Ensure s is written and not cached */
+ if (dcache_en)
+ dcache_flush_invalidate(s);
+
+ pat = ~save[0];
+ *d = pat;
+ sync();
+ if (dcache_en)
+ dcache_flush_invalidate(d);
+
+ /*
+ * Make sure the test pattern is observable at the probe
+ * address before checking whether it is also visible through
+ * the alias address.
+ */
+ if (*d != pat) {
+ *d = save[1];
+ sync();
+ if (dcache_en)
+ dcache_flush_invalidate(d);
+ checks++;
+ continue;
+ }
+
+ if (*s != pat)
+ ret = checks->size;
+
+ /* Restore content */
+ *d = save[1];
+ sync();
+ if (dcache_en)
+ dcache_flush_invalidate(d);
+
+ *s = save[0];
+ sync();
+ if (dcache_en)
+ dcache_flush_invalidate(s);
+
+ checks++;
+ }
+
+ return ret;
+}
+
phys_size_t __weak get_effective_memsize(void)
{
phys_size_t ram_size = gd->ram_size;
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index a21b71ad5d1..5fa94098e49 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -1151,7 +1151,7 @@ config SPL_DM_SPI_FLASH
config SPL_NET
bool "Support networking"
- depends on NET
+ depends on NET_LEGACY
select SPL_USE_TINY_PRINTF_POINTER_SUPPORT if SPL_USE_TINY_PRINTF
help
Enable support for network devices (such as Ethernet) in SPL.
@@ -1160,6 +1160,9 @@ config SPL_NET
the network stack uses a number of environment variables. See also
SPL_ETH.
+config SPL_NET_LEGACY
+ def_bool y if SPL_NET
+
config SPL_NET_VCI_STRING
string "BOOTP Vendor Class Identifier string sent by SPL"
depends on SPL_NET
diff --git a/common/update.c b/common/update.c
index 0bafffede9e..06e53cbd402 100644
--- a/common/update.c
+++ b/common/update.c
@@ -32,7 +32,7 @@ static uchar *saved_prot_info;
#endif
static int update_load(char *filename, ulong msec_max, int cnt_max, ulong addr)
{
- int rv;
+ int rv, ret;
ulong saved_timeout_msecs;
int saved_timeout_count;
char *saved_netretry, *saved_bootfile;
@@ -54,9 +54,9 @@ static int update_load(char *filename, ulong msec_max, int cnt_max, ulong addr)
/* download the update file */
image_load_addr = addr;
copy_filename(net_boot_file_name, filename, sizeof(net_boot_file_name));
- rv = net_loop(TFTPGET);
+ ret = net_loop(TFTPGET);
- if (rv < 0)
+ if (ret < 0)
rv = 1;
else
flush_cache(addr, net_boot_file_size);