summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/Makefile1
-rw-r--r--common/board_f.c31
-rw-r--r--common/board_r.c12
-rw-r--r--common/cmd_itest.c21
-rw-r--r--common/cmd_ubi.c6
-rw-r--r--common/cmd_ubifs.c12
-rw-r--r--common/cmd_ximg.c3
-rw-r--r--common/image.c2
-rw-r--r--common/init/Makefile7
-rw-r--r--common/init/board_init.c60
10 files changed, 102 insertions, 53 deletions
diff --git a/common/Makefile b/common/Makefile
index 8c7775a..d986cde 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -7,6 +7,7 @@
# core
ifndef CONFIG_SPL_BUILD
+obj-y += init/
obj-y += main.o
obj-y += exports.o
obj-y += hash.o
diff --git a/common/board_f.c b/common/board_f.c
index 613332e..486e828 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -806,7 +806,7 @@ static init_fnc_t init_sequence_f[] = {
#if defined(CONFIG_BOARD_POSTCLK_INIT)
board_postclk_init,
#endif
-#ifdef CONFIG_FSL_ESDHC
+#ifdef CONFIG_FSL_CLK
get_clocks,
#endif
#ifdef CONFIG_M68K
@@ -1030,32 +1030,3 @@ void board_init_f_r(void)
hang();
}
#endif /* CONFIG_X86 */
-
-/* Unfortunately x86 can't compile this code as gd cannot be assigned */
-#ifndef CONFIG_X86
-__weak void arch_setup_gd(struct global_data *gd_ptr)
-{
- gd = gd_ptr;
-}
-#endif /* !CONFIG_X86 */
-
-ulong board_init_f_mem(ulong top)
-{
- struct global_data *gd_ptr;
-
- /* Leave space for the stack we are running with now */
- top -= 0x40;
-
- top -= sizeof(struct global_data);
- top = ALIGN(top, 16);
- gd_ptr = (struct global_data *)top;
- memset(gd_ptr, '\0', sizeof(*gd));
- arch_setup_gd(gd_ptr);
-
-#ifdef CONFIG_SYS_MALLOC_F_LEN
- top -= CONFIG_SYS_MALLOC_F_LEN;
- gd->malloc_base = top;
-#endif
-
- return top;
-}
diff --git a/common/board_r.c b/common/board_r.c
index 0a4dfe4..c4fd3ea 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -290,6 +290,9 @@ static int initr_dm(void)
/* Save the pre-reloc driver model and start a new one */
gd->dm_root_f = gd->dm_root;
gd->dm_root = NULL;
+#ifdef CONFIG_TIMER
+ gd->timer = NULL;
+#endif
return dm_init_and_scan(false);
}
#endif
@@ -544,11 +547,14 @@ static int initr_kgdb(void)
}
#endif
-#if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
+#if defined(CONFIG_STATUS_LED)
static int initr_status_led(void)
{
+#if defined(STATUS_LED_BOOT)
status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING);
-
+#else
+ status_led_init();
+#endif
return 0;
}
#endif
@@ -835,7 +841,7 @@ init_fnc_t init_sequence_r[] = {
|| defined(CONFIG_M68K)
timer_init, /* initialize timer */
#endif
-#if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
+#if defined(CONFIG_STATUS_LED)
initr_status_led,
#endif
/* PPC has a udelay(20) here dating from 2002. Why? */
diff --git a/common/cmd_itest.c b/common/cmd_itest.c
index 76af62b..596341c 100644
--- a/common/cmd_itest.c
+++ b/common/cmd_itest.c
@@ -15,6 +15,9 @@
#include <common.h>
#include <config.h>
#include <command.h>
+#include <mapmem.h>
+
+#include <asm/io.h>
#define EQ 0
#define NE 1
@@ -49,16 +52,24 @@ static const op_tbl_t op_table [] = {
static long evalexp(char *s, int w)
{
long l = 0;
- long *p;
+ unsigned long addr;
+ void *buf;
/* if the parameter starts with a * then assume is a pointer to the value we want */
if (s[0] == '*') {
- p = (long *)simple_strtoul(&s[1], NULL, 16);
+ addr = simple_strtoul(&s[1], NULL, 16);
+ buf = map_physmem(addr, w, MAP_WRBACK);
+ if (!buf) {
+ puts("Failed to map physical memory\n");
+ return 0;
+ }
switch (w) {
- case 1: return((long)(*(unsigned char *)p));
- case 2: return((long)(*(unsigned short *)p));
- case 4: return(*p);
+ case 1: l = (long)(*(unsigned char *)buf);
+ case 2: l = (long)(*(unsigned short *)buf);
+ case 4: l = (long)(*(unsigned long *)buf);
}
+ unmap_physmem(buf, w);
+ return l;
} else {
l = simple_strtoul(s, NULL, 16);
}
diff --git a/common/cmd_ubi.c b/common/cmd_ubi.c
index 0460b4c..753a4db 100644
--- a/common/cmd_ubi.c
+++ b/common/cmd_ubi.c
@@ -255,7 +255,7 @@ static int ubi_remove_vol(char *volume)
return 0;
out_err:
- ubi_err("cannot remove volume %s, error %d", volume, err);
+ ubi_err(ubi, "cannot remove volume %s, error %d", volume, err);
if (err < 0)
err = -err;
return err;
@@ -284,8 +284,8 @@ static int ubi_volume_continue_write(char *volume, void *buf, size_t size)
return -err;
if (err) {
- ubi_warn("volume %d on UBI device %d is corrupted",
- vol->vol_id, ubi->ubi_num);
+ ubi_warn(ubi, "volume %d on UBI device %d is corrupt",
+ vol->vol_id, ubi->ubi_num);
vol->corrupted = 1;
}
diff --git a/common/cmd_ubifs.c b/common/cmd_ubifs.c
index 8e9a4e5..5e9d357 100644
--- a/common/cmd_ubifs.c
+++ b/common/cmd_ubifs.c
@@ -15,8 +15,7 @@
#include <common.h>
#include <config.h>
#include <command.h>
-
-#include "../fs/ubifs/ubifs.h"
+#include <ubifs_uboot.h>
static int ubifs_initialized;
static int ubifs_mounted;
@@ -54,14 +53,7 @@ int ubifs_is_mounted(void)
void cmd_ubifs_umount(void)
{
-
- if (ubifs_sb) {
- printf("Unmounting UBIFS volume %s!\n",
- ((struct ubifs_info *)(ubifs_sb->s_fs_info))->vi.name);
- ubifs_umount(ubifs_sb->s_fs_info);
- }
-
- ubifs_sb = NULL;
+ uboot_ubifs_umount();
ubifs_mounted = 0;
ubifs_initialized = 0;
}
diff --git a/common/cmd_ximg.c b/common/cmd_ximg.c
index 8b8645c..d033c15 100644
--- a/common/cmd_ximg.c
+++ b/common/cmd_ximg.c
@@ -88,7 +88,8 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
image_print_contents(hdr);
#endif
- if (!image_check_type(hdr, IH_TYPE_MULTI)) {
+ if (!image_check_type(hdr, IH_TYPE_MULTI) &&
+ !image_check_type(hdr, IH_TYPE_SCRIPT)) {
printf("Wrong Image Type for %s command\n",
cmdtp->name);
return 1;
diff --git a/common/image.c b/common/image.c
index e607109..85c4f39 100644
--- a/common/image.c
+++ b/common/image.c
@@ -913,7 +913,7 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images,
* Look for an Android boot image.
*/
buf = map_sysmem(images->os.start, 0);
- if (genimg_get_format(buf) == IMAGE_FORMAT_ANDROID)
+ if (buf && genimg_get_format(buf) == IMAGE_FORMAT_ANDROID)
select = argv[0];
#endif
diff --git a/common/init/Makefile b/common/init/Makefile
new file mode 100644
index 0000000..4902635
--- /dev/null
+++ b/common/init/Makefile
@@ -0,0 +1,7 @@
+#
+# Copyright (c) 2015 Google, Inc
+#
+# SPDX-License-Identifier: GPL-2.0+
+#
+
+obj-y += board_init.o
diff --git a/common/init/board_init.c b/common/init/board_init.c
new file mode 100644
index 0000000..e74b63b
--- /dev/null
+++ b/common/init/board_init.c
@@ -0,0 +1,60 @@
+/*
+ * Code shared between SPL and U-Boot proper
+ *
+ * Copyright (c) 2015 Google, Inc
+ * Written by Simon Glass <sjg@chromium.org>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/*
+ * It isn't trivial to figure out whether memcpy() exists. The arch-specific
+ * memcpy() is not normally available in SPL due to code size.
+ */
+#if !defined(CONFIG_SPL_BUILD) || \
+ (defined(CONFIG_SPL_LIBGENERIC_SUPPORT) && \
+ !defined(CONFIG_USE_ARCH_MEMSET))
+#define _USE_MEMCPY
+#endif
+
+/* Unfortunately x86 can't compile this code as gd cannot be assigned */
+#ifndef CONFIG_X86
+__weak void arch_setup_gd(struct global_data *gd_ptr)
+{
+ gd = gd_ptr;
+}
+#endif /* !CONFIG_X86 */
+
+ulong board_init_f_mem(ulong top)
+{
+ struct global_data *gd_ptr;
+#ifndef _USE_MEMCPY
+ int *ptr;
+#endif
+
+ /* Leave space for the stack we are running with now */
+ top -= 0x40;
+
+ top -= sizeof(struct global_data);
+ top = ALIGN(top, 16);
+ gd_ptr = (struct global_data *)top;
+#ifdef _USE_MEMCPY
+ memset(gd_ptr, '\0', sizeof(*gd));
+#else
+ for (ptr = (int *)gd_ptr; ptr < (int *)(gd_ptr + 1); )
+ *ptr++ = 0;
+#endif
+ arch_setup_gd(gd_ptr);
+
+#if defined(CONFIG_SYS_MALLOC_F) && \
+ (!defined(CONFIG_SPL_BUILD) || !defined(CONFIG_SYS_SPL_MALLOC_START))
+ top -= CONFIG_SYS_MALLOC_F_LEN;
+ gd->malloc_base = top;
+#endif
+
+ return top;
+}