summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/autoboot.c11
-rw-r--r--common/board_f.c11
-rw-r--r--common/cli.c4
-rw-r--r--common/console.c12
-rw-r--r--common/memsize.c59
-rw-r--r--common/update.c6
6 files changed, 87 insertions, 16 deletions
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/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/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..3ecf9bac2aa 100644
--- a/common/memsize.c
+++ b/common/memsize.c
@@ -127,6 +127,65 @@ 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];
+ 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);
+
+ *d = ~save[0];
+ sync();
+ if (dcache_en)
+ dcache_flush_invalidate(d);
+
+ if (*s != ~save[0])
+ 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/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);