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/board_r.c6
-rw-r--r--common/cli.c4
-rw-r--r--common/console.c12
-rw-r--r--common/event.c3
-rw-r--r--common/main.c4
-rw-r--r--common/memsize.c59
-rw-r--r--common/spl/Kconfig11
-rw-r--r--common/spl/spl.c17
10 files changed, 97 insertions, 41 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/board_r.c b/common/board_r.c
index 8cf0e14679c..5d37345ca09 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -569,11 +569,15 @@ static int dm_announce(void)
static int run_main_loop(void)
{
+ int ret;
+
#ifdef CONFIG_SANDBOX
sandbox_main_loop_init();
#endif
- event_notify_null(EVT_MAIN_LOOP);
+ ret = event_notify_null(EVT_MAIN_LOOP);
+ if (ret)
+ return ret;
/* main_loop() can return to retry autoboot, if so just run it again */
for (;;)
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/event.c b/common/event.c
index 8d7513eb10b..398e713d2f8 100644
--- a/common/event.c
+++ b/common/event.c
@@ -49,6 +49,9 @@ const char *const type_name[] = {
/* main loop events */
"main_loop",
+ /* post preboot events */
+ "post_preboot",
+
/* livetree has been built */
"of_live_init",
};
diff --git a/common/main.c b/common/main.c
index b0b6e74f5d3..4b4504557f6 100644
--- a/common/main.c
+++ b/common/main.c
@@ -19,6 +19,7 @@
#include <net.h>
#include <version_string.h>
#include <efi_loader.h>
+#include <event.h>
static void run_preboot_environment_command(void)
{
@@ -53,6 +54,9 @@ void main_loop(void)
if (IS_ENABLED(CONFIG_USE_PREBOOT))
run_preboot_environment_command();
+ if (event_notify_null(EVT_POST_PREBOOT))
+ return;
+
if (IS_ENABLED(CONFIG_UPDATE_TFTP))
update_tftp(0UL, NULL, NULL);
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/spl/Kconfig b/common/spl/Kconfig
index d1a85f50209..a21b71ad5d1 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -27,15 +27,6 @@ config SPL_FRAMEWORK
supports MMC, NAND and YMODEM and other methods loading of U-Boot
and the Linux Kernel. If unsure, say Y.
-config SPL_FRAMEWORK_BOARD_INIT_F
- bool "Define a generic function board_init_f"
- depends on SPL_FRAMEWORK
- help
- Define a generic function board_init_f that:
- - initialize the spl (spl_early_init)
- - initialize the serial (preloader_console_init)
- Unless you want to provide your own board_init_f, you should say Y.
-
config SPL_SIZE_LIMIT
hex "Maximum size of SPL image"
default 0x11000 if ARCH_MX6 && !MX6_OCRAM_256KB
@@ -729,7 +720,7 @@ config SPL_ENV_SUPPORT
config SPL_SAVEENV
bool "Support save environment"
depends on SPL_ENV_SUPPORT
- select SPL_MMC_WRITE if ENV_IS_IN_MMC
+ select SPL_MMC_WRITE if SPL_ENV_IS_IN_MMC
help
Enable save environment support in SPL after setenv. By default
the saveenv option is not provided in SPL, but some boards need
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 8256fa97862..722b18c98ed 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -669,23 +669,6 @@ static int boot_from_devices(struct spl_image_info *spl_image,
return ret;
}
-#if defined(CONFIG_SPL_FRAMEWORK_BOARD_INIT_F)
-void board_init_f(ulong dummy)
-{
- if (CONFIG_IS_ENABLED(OF_CONTROL)) {
- int ret;
-
- ret = spl_early_init();
- if (ret) {
- debug("spl_early_init() failed: %d\n", ret);
- hang();
- }
- }
-
- preloader_console_init();
-}
-#endif
-
void board_init_r(gd_t *dummy1, ulong dummy2)
{
u32 spl_boot_list[] = {