summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/autoboot.c1
-rw-r--r--common/board_f.c57
-rw-r--r--common/board_r.c34
-rw-r--r--common/bootm_os.c3
-rw-r--r--common/cmd_bdinfo.c3
-rw-r--r--common/cmd_cache.c4
-rw-r--r--common/cmd_eeprom.c6
-rw-r--r--common/cmd_ext2.c10
-rw-r--r--common/cmd_fat.c2
-rw-r--r--common/cmd_fs.c10
-rw-r--r--common/cmd_i2c.c6
-rw-r--r--common/cmd_ide.c135
-rw-r--r--common/cmd_log.c11
-rw-r--r--common/cmd_mii.c8
-rw-r--r--common/cmd_nvedit.c19
-rw-r--r--common/cmd_part.c6
-rw-r--r--common/cmd_pxe.c4
-rw-r--r--common/cmd_source.c3
-rw-r--r--common/cmd_ubi.c2
-rw-r--r--common/cmd_ubifs.c12
-rw-r--r--common/console.c24
-rw-r--r--common/dlmalloc.c85
-rw-r--r--common/env_common.c10
-rw-r--r--common/image-fdt.c9
-rw-r--r--common/lcd.c14
-rw-r--r--common/main.c3
-rw-r--r--common/spl/spl_nand.c6
-rw-r--r--common/splash.c6
-rw-r--r--common/stdio.c66
-rw-r--r--common/usb_kbd.c6
30 files changed, 279 insertions, 286 deletions
diff --git a/common/autoboot.c b/common/autoboot.c
index 30102a4..c27cc2c 100644
--- a/common/autoboot.c
+++ b/common/autoboot.c
@@ -6,6 +6,7 @@
*/
#include <common.h>
+#include <autoboot.h>
#include <bootretry.h>
#include <cli.h>
#include <fdtdec.h>
diff --git a/common/board_f.c b/common/board_f.c
index 4ea4cb2..6203d85 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -14,6 +14,7 @@
#include <linux/compiler.h>
#include <version.h>
#include <environment.h>
+#include <dm.h>
#include <fdtdec.h>
#include <fs.h>
#if defined(CONFIG_CMD_IDE)
@@ -37,6 +38,7 @@
#include <os.h>
#include <post.h>
#include <spi.h>
+#include <status_led.h>
#include <trace.h>
#include <watchdog.h>
#include <asm/errno.h>
@@ -52,6 +54,7 @@
#ifdef CONFIG_SANDBOX
#include <asm/state.h>
#endif
+#include <dm/root.h>
#include <linux/compiler.h>
/*
@@ -78,25 +81,15 @@ DECLARE_GLOBAL_DATA_PTR;
************************************************************************
* May be supplied by boards if desired
*/
-inline void __coloured_LED_init(void) {}
-void coloured_LED_init(void)
- __attribute__((weak, alias("__coloured_LED_init")));
-inline void __red_led_on(void) {}
-void red_led_on(void) __attribute__((weak, alias("__red_led_on")));
-inline void __red_led_off(void) {}
-void red_led_off(void) __attribute__((weak, alias("__red_led_off")));
-inline void __green_led_on(void) {}
-void green_led_on(void) __attribute__((weak, alias("__green_led_on")));
-inline void __green_led_off(void) {}
-void green_led_off(void) __attribute__((weak, alias("__green_led_off")));
-inline void __yellow_led_on(void) {}
-void yellow_led_on(void) __attribute__((weak, alias("__yellow_led_on")));
-inline void __yellow_led_off(void) {}
-void yellow_led_off(void) __attribute__((weak, alias("__yellow_led_off")));
-inline void __blue_led_on(void) {}
-void blue_led_on(void) __attribute__((weak, alias("__blue_led_on")));
-inline void __blue_led_off(void) {}
-void blue_led_off(void) __attribute__((weak, alias("__blue_led_off")));
+__weak void coloured_LED_init(void) {}
+__weak void red_led_on(void) {}
+__weak void red_led_off(void) {}
+__weak void green_led_on(void) {}
+__weak void green_led_off(void) {}
+__weak void yellow_led_on(void) {}
+__weak void yellow_led_off(void) {}
+__weak void blue_led_on(void) {}
+__weak void blue_led_off(void) {}
/*
* Why is gd allocated a register? Prior to reloc it might be better to
@@ -776,6 +769,30 @@ static int mark_bootstage(void)
return 0;
}
+static int initf_malloc(void)
+{
+#ifdef CONFIG_SYS_MALLOC_F_LEN
+ assert(gd->malloc_base); /* Set up by crt0.S */
+ gd->malloc_limit = gd->malloc_base + CONFIG_SYS_MALLOC_F_LEN;
+ gd->malloc_ptr = 0;
+#endif
+
+ return 0;
+}
+
+static int initf_dm(void)
+{
+#if defined(CONFIG_DM) && defined(CONFIG_SYS_MALLOC_F_LEN)
+ int ret;
+
+ ret = dm_init_and_scan(true);
+ if (ret)
+ return ret;
+#endif
+
+ return 0;
+}
+
static init_fnc_t init_sequence_f[] = {
#ifdef CONFIG_SANDBOX
setup_ram_buf,
@@ -833,6 +850,8 @@ static init_fnc_t init_sequence_f[] = {
sdram_adjust_866,
init_timebase,
#endif
+ initf_malloc,
+ initf_dm,
init_baud_rate, /* initialze baudrate settings */
serial_init, /* serial communications setup */
console_init_f, /* stage 1 init of console */
diff --git a/common/board_r.c b/common/board_r.c
index 602a239..8e7a3ac 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -259,6 +259,10 @@ static int initr_malloc(void)
{
ulong malloc_start;
+#ifdef CONFIG_SYS_MALLOC_F_LEN
+ debug("Pre-reloc malloc() used %#lx bytes (%ld KB)\n", gd->malloc_ptr,
+ gd->malloc_ptr / 1024);
+#endif
/* The malloc area is immediately below the monitor copy in DRAM */
malloc_start = gd->relocaddr - TOTAL_MALLOC_LEN;
mem_malloc_init((ulong)map_sysmem(malloc_start, TOTAL_MALLOC_LEN),
@@ -269,27 +273,10 @@ static int initr_malloc(void)
#ifdef CONFIG_DM
static int initr_dm(void)
{
- int ret;
-
- ret = dm_init();
- if (ret) {
- debug("dm_init() failed: %d\n", ret);
- return ret;
- }
- ret = dm_scan_platdata();
- if (ret) {
- debug("dm_scan_platdata() failed: %d\n", ret);
- return ret;
- }
-#ifdef CONFIG_OF_CONTROL
- ret = dm_scan_fdt(gd->fdt_blob);
- if (ret) {
- debug("dm_scan_fdt() failed: %d\n", ret);
- return ret;
- }
-#endif
-
- return 0;
+ /* Save the pre-reloc driver model and start a new one */
+ gd->dm_root_f = gd->dm_root;
+ gd->dm_root = NULL;
+ return dm_init_and_scan(false);
}
#endif
@@ -588,15 +575,12 @@ static int initr_status_led(void)
#if defined(CONFIG_CMD_SCSI)
static int initr_scsi(void)
{
- /* Not supported properly on ARM yet */
-#ifndef CONFIG_ARM
puts("SCSI: ");
scsi_init();
-#endif
return 0;
}
-#endif /* CONFIG_CMD_NET */
+#endif
#if defined(CONFIG_CMD_DOC)
static int initr_doc(void)
diff --git a/common/bootm_os.c b/common/bootm_os.c
index f7769ac..5be4467 100644
--- a/common/bootm_os.c
+++ b/common/bootm_os.c
@@ -437,11 +437,10 @@ static boot_os_fn *boot_os[] = {
};
/* Allow for arch specific config before we boot */
-static void __arch_preboot_os(void)
+__weak void arch_preboot_os(void)
{
/* please define platform specific arch_preboot_os() */
}
-void arch_preboot_os(void) __attribute__((weak, alias("__arch_preboot_os")));
int boot_selected_os(int argc, char * const argv[], int state,
bootm_headers_t *images, boot_os_fn *boot_fn)
diff --git a/common/cmd_bdinfo.c b/common/cmd_bdinfo.c
index f283a16..3d37a86 100644
--- a/common/cmd_bdinfo.c
+++ b/common/cmd_bdinfo.c
@@ -351,7 +351,8 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
#elif defined(CONFIG_ARM)
-int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
{
int i;
bd_t *bd = gd->bd;
diff --git a/common/cmd_cache.c b/common/cmd_cache.c
index 602feca..37ab345 100644
--- a/common/cmd_cache.c
+++ b/common/cmd_cache.c
@@ -20,7 +20,7 @@ void __weak invalidate_icache_all(void)
puts("No arch specific invalidate_icache_all available!\n");
}
-int do_icache(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_icache(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
switch (argc) {
case 2: /* on / off */
@@ -52,7 +52,7 @@ void __weak flush_dcache_all(void)
/* please define arch specific flush_dcache_all */
}
-int do_dcache(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_dcache(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
switch (argc) {
case 2: /* on / off */
diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
index fad462f..a02f0cb 100644
--- a/common/cmd_eeprom.c
+++ b/common/cmd_eeprom.c
@@ -43,7 +43,7 @@ extern int eeprom_write_enable (unsigned dev_addr, int state);
/* ------------------------------------------------------------------------- */
#if defined(CONFIG_CMD_EEPROM)
-int do_eeprom ( cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
+static int do_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
const char *const fmt =
"\nEEPROM @0x%lX %s: addr %08lx off %04lx count %ld ... ";
@@ -413,7 +413,7 @@ U_BOOT_CMD(
"read devaddr addr off cnt\n"
"eeprom write devaddr addr off cnt\n"
" - read/write `cnt' bytes from `devaddr` EEPROM at offset `off'"
-);
+)
#else /* One EEPROM */
U_BOOT_CMD(
eeprom, 5, 1, do_eeprom,
@@ -421,7 +421,7 @@ U_BOOT_CMD(
"read addr off cnt\n"
"eeprom write addr off cnt\n"
" - read/write `cnt' bytes at EEPROM offset `off'"
-);
+)
#endif /* CONFIG_SYS_I2C_MULTI_EEPROMS */
#endif
diff --git a/common/cmd_ext2.c b/common/cmd_ext2.c
index 5a4bcc1..6657ef5 100644
--- a/common/cmd_ext2.c
+++ b/common/cmd_ext2.c
@@ -22,7 +22,7 @@
*/
#include <fs.h>
-int do_ext2ls (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_ext2ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
return do_ls(cmdtp, flag, argc, argv, FS_TYPE_EXT);
}
@@ -30,7 +30,7 @@ int do_ext2ls (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
/******************************************************************************
* Ext2fs boot command intepreter. Derived from diskboot
*/
-int do_ext2load (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+int do_ext2load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
return do_load(cmdtp, flag, argc, argv, FS_TYPE_EXT);
}
@@ -40,12 +40,12 @@ U_BOOT_CMD(
"list files in a directory (default /)",
"<interface> <dev[:part]> [directory]\n"
" - list files from 'dev' on 'interface' in a 'directory'"
-);
+)
U_BOOT_CMD(
ext2load, 6, 0, do_ext2load,
"load binary file from a Ext2 filesystem",
- "<interface> <dev[:part]> [addr] [filename] [bytes]\n"
+ "<interface> [<dev[:part]> [addr [filename [bytes [pos]]]]]\n"
" - load binary file 'filename' from 'dev' on 'interface'\n"
" to address 'addr' from ext2 filesystem."
-);
+)
diff --git a/common/cmd_fat.c b/common/cmd_fat.c
index fbe3346..a478017 100644
--- a/common/cmd_fat.c
+++ b/common/cmd_fat.c
@@ -27,7 +27,7 @@ int do_fat_fsload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
U_BOOT_CMD(
fatload, 7, 0, do_fat_fsload,
"load binary file from a dos filesystem",
- "<interface> [<dev[:part]>] <addr> <filename> [bytes [pos]]\n"
+ "<interface> [<dev[:part]> [<addr> [<filename> [bytes [pos]]]]]\n"
" - Load binary file 'filename' from 'dev' on 'interface'\n"
" to address 'addr' from dos filesystem.\n"
" 'pos' gives the file position to start loading from.\n"
diff --git a/common/cmd_fs.c b/common/cmd_fs.c
index 91a205a..78590d2 100644
--- a/common/cmd_fs.c
+++ b/common/cmd_fs.c
@@ -20,7 +20,8 @@
#include <command.h>
#include <fs.h>
-int do_load_wrapper(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_load_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
{
return do_load(cmdtp, flag, argc, argv, FS_TYPE_ANY);
}
@@ -35,9 +36,10 @@ U_BOOT_CMD(
" If 'bytes' is 0 or omitted, the file is read until the end.\n"
" 'pos' gives the file byte position to start reading from.\n"
" If 'pos' is 0 or omitted, the file is read from the start."
-);
+)
-int do_ls_wrapper(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_ls_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
{
return do_ls(cmdtp, flag, argc, argv, FS_TYPE_ANY);
}
@@ -48,4 +50,4 @@ U_BOOT_CMD(
"<interface> [<dev[:part]> [directory]]\n"
" - List files in directory 'directory' of partition 'part' on\n"
" device type 'interface' instance 'dev'."
-);
+)
diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c
index d714658..3a75f94 100644
--- a/common/cmd_i2c.c
+++ b/common/cmd_i2c.c
@@ -1366,7 +1366,8 @@ int do_edid(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
* Returns zero always.
*/
#if defined(CONFIG_SYS_I2C)
-int do_i2c_show_bus(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_i2c_show_bus(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
{
int i;
#ifndef CONFIG_SYS_I2C_DIRECT_BUS
@@ -1425,7 +1426,8 @@ int do_i2c_show_bus(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
* on error.
*/
#if defined(CONFIG_SYS_I2C) || defined(CONFIG_I2C_MULTI_BUS)
-int do_i2c_bus_num(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_i2c_bus_num(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
{
int ret = 0;
unsigned int bus_no;
diff --git a/common/cmd_ide.c b/common/cmd_ide.c
index c375ef2..04a6d9b 100644
--- a/common/cmd_ide.c
+++ b/common/cmd_ide.c
@@ -253,7 +253,7 @@ int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
/* ------------------------------------------------------------------------- */
-void __ide_led(uchar led, uchar status)
+__weak void ide_led(uchar led, uchar status)
{
#if defined(CONFIG_IDE_LED) && defined(PER8_BASE) /* required by LED_PORT */
static uchar led_buffer; /* Buffer for current LED status */
@@ -269,9 +269,6 @@ void __ide_led(uchar led, uchar status)
#endif
}
-void ide_led(uchar led, uchar status)
- __attribute__ ((weak, alias("__ide_led")));
-
#ifndef CONFIG_IDE_LED /* define LED macros, they are not used anyways */
# define DEVICE_LED(x) 0
# define LED_IDE1 1
@@ -280,7 +277,7 @@ void ide_led(uchar led, uchar status)
/* ------------------------------------------------------------------------- */
-inline void __ide_outb(int dev, int port, unsigned char val)
+__weak void ide_outb(int dev, int port, unsigned char val)
{
debug("ide_outb (dev= %d, port= 0x%x, val= 0x%02x) : @ 0x%08lx\n",
dev, port, val,
@@ -299,10 +296,7 @@ inline void __ide_outb(int dev, int port, unsigned char val)
#endif
}
-void ide_outb(int dev, int port, unsigned char val)
- __attribute__ ((weak, alias("__ide_outb")));
-
-inline unsigned char __ide_inb(int dev, int port)
+__weak unsigned char ide_inb(int dev, int port)
{
uchar val;
@@ -318,19 +312,6 @@ inline unsigned char __ide_inb(int dev, int port)
return val;
}
-unsigned char ide_inb(int dev, int port)
- __attribute__ ((weak, alias("__ide_inb")));
-
-#ifdef CONFIG_TUNE_PIO
-inline int __ide_set_piomode(int pio_mode)
-{
- return 0;
-}
-
-inline int ide_set_piomode(int pio_mode)
- __attribute__ ((weak, alias("__ide_set_piomode")));
-#endif
-
void ide_init(void)
{
unsigned char c;
@@ -471,23 +452,14 @@ block_dev_desc_t *ide_get_dev(int dev)
/* ------------------------------------------------------------------------- */
-void ide_input_swap_data(int dev, ulong *sect_buf, int words)
- __attribute__ ((weak, alias("__ide_input_swap_data")));
-
-void ide_input_data(int dev, ulong *sect_buf, int words)
- __attribute__ ((weak, alias("__ide_input_data")));
-
-void ide_output_data(int dev, const ulong *sect_buf, int words)
- __attribute__ ((weak, alias("__ide_output_data")));
-
/* We only need to swap data if we are running on a big endian cpu. */
#if defined(__LITTLE_ENDIAN)
-void __ide_input_swap_data(int dev, ulong *sect_buf, int words)
+__weak void ide_input_swap_data(int dev, ulong *sect_buf, int words)
{
ide_input_data(dev, sect_buf, words);
}
#else
-void __ide_input_swap_data(int dev, ulong *sect_buf, int words)
+__weak void ide_input_swap_data(int dev, ulong *sect_buf, int words)
{
volatile ushort *pbuf =
(ushort *) (ATA_CURR_BASE(dev) + ATA_DATA_REG);
@@ -510,7 +482,7 @@ void __ide_input_swap_data(int dev, ulong *sect_buf, int words)
#if defined(CONFIG_IDE_SWAP_IO)
-void __ide_output_data(int dev, const ulong *sect_buf, int words)
+__weak void ide_output_data(int dev, const ulong *sect_buf, int words)
{
ushort *dbuf;
volatile ushort *pbuf;
@@ -525,7 +497,7 @@ void __ide_output_data(int dev, const ulong *sect_buf, int words)
}
}
#else /* ! CONFIG_IDE_SWAP_IO */
-void __ide_output_data(int dev, const ulong *sect_buf, int words)
+__weak void ide_output_data(int dev, const ulong *sect_buf, int words)
{
#if defined(CONFIG_IDE_AHB)
ide_write_data(dev, sect_buf, words);
@@ -536,7 +508,7 @@ void __ide_output_data(int dev, const ulong *sect_buf, int words)
#endif /* CONFIG_IDE_SWAP_IO */
#if defined(CONFIG_IDE_SWAP_IO)
-void __ide_input_data(int dev, ulong *sect_buf, int words)
+__weak void ide_input_data(int dev, ulong *sect_buf, int words)
{
ushort *dbuf;
volatile ushort *pbuf;
@@ -554,7 +526,7 @@ void __ide_input_data(int dev, ulong *sect_buf, int words)
}
}
#else /* ! CONFIG_IDE_SWAP_IO */
-void __ide_input_data(int dev, ulong *sect_buf, int words)
+__weak void ide_input_data(int dev, ulong *sect_buf, int words)
{
#if defined(CONFIG_IDE_AHB)
ide_read_data(dev, sect_buf, words);
@@ -575,14 +547,6 @@ static void ide_ident(block_dev_desc_t *dev_desc)
#ifdef CONFIG_ATAPI
int retries = 0;
#endif
-
-#ifdef CONFIG_TUNE_PIO
- int pio_mode;
-#endif
-
-#if 0
- int mode, cycle_time;
-#endif
int device;
device = dev_desc->dev;
@@ -691,72 +655,6 @@ static void ide_ident(block_dev_desc_t *dev_desc)
else
dev_desc->removable = 0;
-#ifdef CONFIG_TUNE_PIO
- /* Mode 0 - 2 only, are directly determined by word 51. */
- pio_mode = iop.tPIO;
- if (pio_mode > 2) {
- printf("WARNING: Invalid PIO (word 51 = %d).\n", pio_mode);
- /* Force it to dead slow, and hope for the best... */
- pio_mode = 0;
- }
-
- /* Any CompactFlash Storage Card that supports PIO mode 3 or above
- * shall set bit 1 of word 53 to one and support the fields contained
- * in words 64 through 70.
- */
- if (iop.field_valid & 0x02) {
- /*
- * Mode 3 and above are possible. Check in order from slow
- * to fast, so we wind up with the highest mode allowed.
- */
- if (iop.eide_pio_modes & 0x01)
- pio_mode = 3;
- if (iop.eide_pio_modes & 0x02)
- pio_mode = 4;
- if (ata_id_is_cfa((u16 *)&iop)) {
- if ((iop.cf_advanced_caps & 0x07) == 0x01)
- pio_mode = 5;
- if ((iop.cf_advanced_caps & 0x07) == 0x02)
- pio_mode = 6;
- }
- }
-
- /* System-specific, depends on bus speeds, etc. */
- ide_set_piomode(pio_mode);
-#endif /* CONFIG_TUNE_PIO */
-
-#if 0
- /*
- * Drive PIO mode autoselection
- */
- mode = iop.tPIO;
-
- printf("tPIO = 0x%02x = %d\n", mode, mode);
- if (mode > 2) { /* 2 is maximum allowed tPIO value */
- mode = 2;
- debug("Override tPIO -> 2\n");
- }
- if (iop.field_valid & 2) { /* drive implements ATA2? */
- debug("Drive implements ATA2\n");
- if (iop.capability & 8) { /* drive supports use_iordy? */
- cycle_time = iop.eide_pio_iordy;
- } else {
- cycle_time = iop.eide_pio;
- }
- debug("cycle time = %d\n", cycle_time);
- mode = 4;
- if (cycle_time > 120)
- mode = 3; /* 120 ns for PIO mode 4 */
- if (cycle_time > 180)
- mode = 2; /* 180 ns for PIO mode 3 */
- if (cycle_time > 240)
- mode = 1; /* 240 ns for PIO mode 4 */
- if (cycle_time > 383)
- mode = 0; /* 383 ns for PIO mode 4 */
- }
- printf("PIO mode to use: PIO %d\n", mode);
-#endif /* 0 */
-
#ifdef CONFIG_ATAPI
if (dev_desc->if_type == IF_TYPE_ATAPI) {
atapi_inquiry(dev_desc);
@@ -1122,17 +1020,10 @@ int ide_device_present(int dev)
* ATAPI Support
*/
-void ide_input_data_shorts(int dev, ushort *sect_buf, int shorts)
- __attribute__ ((weak, alias("__ide_input_data_shorts")));
-
-void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts)
- __attribute__ ((weak, alias("__ide_output_data_shorts")));
-
-
#if defined(CONFIG_IDE_SWAP_IO)
/* since ATAPI may use commands with not 4 bytes alligned length
* we have our own transfer functions, 2 bytes alligned */
-void __ide_output_data_shorts(int dev, ushort *sect_buf, int shorts)
+__weak void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts)
{
ushort *dbuf;
volatile ushort *pbuf;
@@ -1149,7 +1040,7 @@ void __ide_output_data_shorts(int dev, ushort *sect_buf, int shorts)
}
}
-void __ide_input_data_shorts(int dev, ushort *sect_buf, int shorts)
+__weak void ide_input_data_shorts(int dev, ushort *sect_buf, int shorts)
{
ushort *dbuf;
volatile ushort *pbuf;
@@ -1167,12 +1058,12 @@ void __ide_input_data_shorts(int dev, ushort *sect_buf, int shorts)
}
#else /* ! CONFIG_IDE_SWAP_IO */
-void __ide_output_data_shorts(int dev, ushort *sect_buf, int shorts)
+__weak void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts)
{
outsw(ATA_CURR_BASE(dev) + ATA_DATA_REG, sect_buf, shorts);
}
-void __ide_input_data_shorts(int dev, ushort *sect_buf, int shorts)
+__weak void ide_input_data_shorts(int dev, ushort *sect_buf, int shorts)
{
insw(ATA_CURR_BASE(dev) + ATA_DATA_REG, sect_buf, shorts);
}
diff --git a/common/cmd_log.c b/common/cmd_log.c
index 38d0f5e..873ee40 100644
--- a/common/cmd_log.c
+++ b/common/cmd_log.c
@@ -33,8 +33,8 @@
DECLARE_GLOBAL_DATA_PTR;
/* Local prototypes */
-static void logbuff_putc(const char c);
-static void logbuff_puts(const char *s);
+static void logbuff_putc(struct stdio_dev *dev, const char c);
+static void logbuff_puts(struct stdio_dev *dev, const char *s);
static int logbuff_printk(const char *line);
static char buf[1024];
@@ -143,7 +143,7 @@ int drv_logbuff_init(void)
return (rc == 0) ? 1 : rc;
}
-static void logbuff_putc(const char c)
+static void logbuff_putc(struct stdio_dev *dev, const char c)
{
char buf[2];
buf[0] = c;
@@ -151,7 +151,7 @@ static void logbuff_putc(const char c)
logbuff_printk(buf);
}
-static void logbuff_puts(const char *s)
+static void logbuff_puts(struct stdio_dev *dev, const char *s)
{
logbuff_printk (s);
}
@@ -181,6 +181,7 @@ void logbuff_log(char *msg)
*/
int do_log(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
+ struct stdio_dev *sdev = NULL;
char *s;
unsigned long i, start, size;
@@ -188,7 +189,7 @@ int do_log(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
/* Log concatenation of all arguments separated by spaces */
for (i = 2; i < argc; i++) {
logbuff_printk(argv[i]);
- logbuff_putc((i < argc - 1) ? ' ' : '\n');
+ logbuff_putc(sdev, (i < argc - 1) ? ' ' : '\n');
}
return 0;
}
diff --git a/common/cmd_mii.c b/common/cmd_mii.c
index b82a7ce..7c4a57a 100644
--- a/common/cmd_mii.c
+++ b/common/cmd_mii.c
@@ -160,10 +160,10 @@ static void dump_reg(
mask_in_place = pdesc->mask << pdesc->lo;
- printf(" (%04hx:%04hx) %u.",
- mask_in_place,
- regval & mask_in_place,
- prd->regno);
+ printf(" (%04hx:%04x) %u.",
+ mask_in_place,
+ regval & mask_in_place,
+ prd->regno);
if (special_field(prd->regno, pdesc, regval)) {
}
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index e6c3395..855808c 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -950,11 +950,15 @@ sep_err:
#ifdef CONFIG_CMD_IMPORTENV
/*
- * env import [-d] [-t | -b | -c] addr [size]
+ * env import [-d] [-t [-r] | -b | -c] addr [size]
* -d: delete existing environment before importing;
* otherwise overwrite / append to existion definitions
* -t: assume text format; either "size" must be given or the
* text data must be '\0' terminated
+ * -r: handle CRLF like LF, that means exported variables with
+ * a content which ends with \r won't get imported. Used
+ * to import text files created with editors which are using CRLF
+ * for line endings. Only effective in addition to -t.
* -b: assume binary format ('\0' separated, "\0\0" terminated)
* -c: assume checksum protected environment format
* addr: memory address to read from
@@ -970,6 +974,7 @@ static int do_env_import(cmd_tbl_t *cmdtp, int flag,
int chk = 0;
int fmt = 0;
int del = 0;
+ int crlf_is_lf = 0;
size_t size;
cmd = *argv;
@@ -994,6 +999,9 @@ static int do_env_import(cmd_tbl_t *cmdtp, int flag,
goto sep_err;
sep = '\n';
break;
+ case 'r': /* handle CRLF like LF */
+ crlf_is_lf = 1;
+ break;
case 'd':
del = 1;
break;
@@ -1009,6 +1017,9 @@ static int do_env_import(cmd_tbl_t *cmdtp, int flag,
if (!fmt)
printf("## Warning: defaulting to text format\n");
+ if (sep != '\n' && crlf_is_lf )
+ crlf_is_lf = 0;
+
addr = simple_strtoul(argv[0], NULL, 16);
ptr = map_sysmem(addr, 0);
@@ -1050,8 +1061,8 @@ static int do_env_import(cmd_tbl_t *cmdtp, int flag,
ptr = (char *)ep->data;
}
- if (himport_r(&env_htab, ptr, size, sep, del ? 0 : H_NOCLEAR, 0,
- NULL) == 0) {
+ if (himport_r(&env_htab, ptr, size, sep, del ? 0 : H_NOCLEAR,
+ crlf_is_lf, 0, NULL) == 0) {
error("Environment import failed: errno = %d\n", errno);
return 1;
}
@@ -1180,7 +1191,7 @@ static char env_help_text[] =
#endif
#endif
#if defined(CONFIG_CMD_IMPORTENV)
- "env import [-d] [-t | -b | -c] addr [size] - import environment\n"
+ "env import [-d] [-t [-r] | -b | -c] addr [size] - import environment\n"
#endif
"env print [-a | name ...] - print environment\n"
#if defined(CONFIG_CMD_RUN)
diff --git a/common/cmd_part.c b/common/cmd_part.c
index c84bc27..39e8666 100644
--- a/common/cmd_part.c
+++ b/common/cmd_part.c
@@ -26,7 +26,7 @@
#error CONFIG_PARTITION_UUIDS must be enabled for CONFIG_CMD_PART to be enabled
#endif
-int do_part_uuid(int argc, char * const argv[])
+static int do_part_uuid(int argc, char * const argv[])
{
int part;
block_dev_desc_t *dev_desc;
@@ -49,7 +49,7 @@ int do_part_uuid(int argc, char * const argv[])
return 0;
}
-int do_part_list(int argc, char * const argv[])
+static int do_part_list(int argc, char * const argv[])
{
int ret;
block_dev_desc_t *desc;
@@ -66,7 +66,7 @@ int do_part_list(int argc, char * const argv[])
return 0;
}
-int do_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
if (argc < 2)
return CMD_RET_USAGE;
diff --git a/common/cmd_pxe.c b/common/cmd_pxe.c
index 3483328..ba48692 100644
--- a/common/cmd_pxe.c
+++ b/common/cmd_pxe.c
@@ -1562,7 +1562,7 @@ static cmd_tbl_t cmd_pxe_sub[] = {
U_BOOT_CMD_MKENT(boot, 2, 1, do_pxe_boot, "", "")
};
-int do_pxe(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_pxe(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
cmd_tbl_t *cp;
@@ -1596,7 +1596,7 @@ U_BOOT_CMD(
*
* Returns 0 on success, 1 on error.
*/
-int do_sysboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_sysboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
unsigned long pxefile_addr_r;
struct pxe_menu *cfg;
diff --git a/common/cmd_source.c b/common/cmd_source.c
index f3e9e60..6881bc9 100644
--- a/common/cmd_source.c
+++ b/common/cmd_source.c
@@ -142,8 +142,7 @@ source (ulong addr, const char *fit_uname)
/**************************************************/
#if defined(CONFIG_CMD_SOURCE)
-int
-do_source (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_source(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
ulong addr;
int rcode;
diff --git a/common/cmd_ubi.c b/common/cmd_ubi.c
index 7c4d950..3c37c93 100644
--- a/common/cmd_ubi.c
+++ b/common/cmd_ubi.c
@@ -287,7 +287,7 @@ out_err:
return err;
}
-int ubi_volume_continue_write(char *volume, void *buf, size_t size)
+static int ubi_volume_continue_write(char *volume, void *buf, size_t size)
{
int err = 1;
struct ubi_volume *vol;
diff --git a/common/cmd_ubifs.c b/common/cmd_ubifs.c
index fdc8bfe..19c8a43 100644
--- a/common/cmd_ubifs.c
+++ b/common/cmd_ubifs.c
@@ -21,7 +21,8 @@
static int ubifs_initialized;
static int ubifs_mounted;
-int do_ubifs_mount(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_ubifs_mount(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
{
char *vol_name;
int ret;
@@ -65,7 +66,8 @@ void cmd_ubifs_umount(void)
ubifs_initialized = 0;
}
-int do_ubifs_umount(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_ubifs_umount(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
{
if (argc != 1)
return CMD_RET_USAGE;
@@ -80,7 +82,8 @@ int do_ubifs_umount(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
return 0;
}
-int do_ubifs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_ubifs_ls(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
{
char *filename = "/";
int ret;
@@ -103,7 +106,8 @@ int do_ubifs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
return ret;
}
-int do_ubifs_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_ubifs_load(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
{
char *filename;
char *endp;
diff --git a/common/console.c b/common/console.c
index 5453726..898da39 100644
--- a/common/console.c
+++ b/common/console.c
@@ -109,7 +109,7 @@ static int console_setfile(int file, struct stdio_dev * dev)
case stderr:
/* Start new device */
if (dev->start) {
- error = dev->start();
+ error = dev->start(dev);
/* If it's not started dont use it */
if (error < 0)
break;
@@ -159,7 +159,7 @@ static int console_getc(int file)
unsigned char ret;
/* This is never called with testcdev == NULL */
- ret = tstcdev->getc();
+ ret = tstcdev->getc(tstcdev);
tstcdev = NULL;
return ret;
}
@@ -173,7 +173,7 @@ static int console_tstc(int file)
for (i = 0; i < cd_count[file]; i++) {
dev = console_devices[file][i];
if (dev->tstc != NULL) {
- ret = dev->tstc();
+ ret = dev->tstc(dev);
if (ret > 0) {
tstcdev = dev;
disable_ctrlc(0);
@@ -194,7 +194,7 @@ static void console_putc(int file, const char c)
for (i = 0; i < cd_count[file]; i++) {
dev = console_devices[file][i];
if (dev->putc != NULL)
- dev->putc(c);
+ dev->putc(dev, c);
}
}
@@ -206,7 +206,7 @@ static void console_puts(int file, const char *s)
for (i = 0; i < cd_count[file]; i++) {
dev = console_devices[file][i];
if (dev->puts != NULL)
- dev->puts(s);
+ dev->puts(dev, s);
}
}
@@ -222,22 +222,22 @@ static inline void console_doenv(int file, struct stdio_dev *dev)
#else
static inline int console_getc(int file)
{
- return stdio_devices[file]->getc();
+ return stdio_devices[file]->getc(stdio_devices[file]);
}
static inline int console_tstc(int file)
{
- return stdio_devices[file]->tstc();
+ return stdio_devices[file]->tstc(stdio_devices[file]);
}
static inline void console_putc(int file, const char c)
{
- stdio_devices[file]->putc(c);
+ stdio_devices[file]->putc(stdio_devices[file], c);
}
static inline void console_puts(int file, const char *s)
{
- stdio_devices[file]->puts(s);
+ stdio_devices[file]->puts(stdio_devices[file], s);
}
static inline void console_printdevs(int file)
@@ -417,7 +417,7 @@ static inline void print_pre_console_buffer(void) {}
void putc(const char c)
{
#ifdef CONFIG_SANDBOX
- if (!gd) {
+ if (!gd || !(gd->flags & GD_FLG_SERIAL_READY)) {
os_putc(c);
return;
}
@@ -447,7 +447,7 @@ void putc(const char c)
void puts(const char *s)
{
#ifdef CONFIG_SANDBOX
- if (!gd) {
+ if (!gd || !(gd->flags & GD_FLG_SERIAL_READY)) {
os_puts(s);
return;
}
@@ -504,7 +504,7 @@ int vprintf(const char *fmt, va_list args)
uint i;
char printbuffer[CONFIG_SYS_PBSIZE];
-#ifndef CONFIG_PRE_CONSOLE_BUFFER
+#if defined(CONFIG_PRE_CONSOLE_BUFFER) && !defined(CONFIG_SANDBOX)
if (!gd->have_console)
return 0;
#endif
diff --git a/common/dlmalloc.c b/common/dlmalloc.c
index 3c70d5d..f987339 100644
--- a/common/dlmalloc.c
+++ b/common/dlmalloc.c
@@ -1,5 +1,9 @@
#include <common.h>
+#ifdef CONFIG_SANDBOX
+#define DEBUG
+#endif
+
#if 0 /* Moved to malloc.h */
/* ---------- To make a malloc.h, start cutting here ------------ */
@@ -220,7 +224,7 @@
*/
-
+
/* Preliminaries */
@@ -930,6 +934,8 @@ struct mallinfo mALLINFo();
#endif /* 0 */ /* Moved to malloc.h */
#include <malloc.h>
+#include <asm/io.h>
+
#ifdef DEBUG
#if __STD_C
static void malloc_update_mallinfo (void);
@@ -1132,7 +1138,7 @@ gAllocatedSize))
#endif
-
+
/*
Type declarations
@@ -1272,7 +1278,7 @@ nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
serviced via calls to mmap, and then later released via munmap.
*/
-
+
/* sizes, alignments */
#define SIZE_SZ (sizeof(INTERNAL_SIZE_T))
@@ -1297,7 +1303,7 @@ nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#define aligned_OK(m) (((unsigned long)((m)) & (MALLOC_ALIGN_MASK)) == 0)
-
+
/*
Physical chunk operations
@@ -1332,7 +1338,7 @@ nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#define chunk_at_offset(p, s) ((mchunkptr)(((char*)(p)) + (s)))
-
+
/*
Dealing with use bits
@@ -1371,7 +1377,7 @@ nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
(((mchunkptr)(((char*)(p)) + (s)))->size &= ~(PREV_INUSE))
-
+
/*
Dealing with size fields
@@ -1394,7 +1400,7 @@ nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#define set_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_size = (s))
-
+
/*
@@ -1566,7 +1572,7 @@ void mem_malloc_init(ulong start, ulong size)
#define is_small_request(nb) (nb < MAX_SMALLBIN_SIZE - SMALLBIN_WIDTH)
-
+
/*
To help compensate for the large number of bins, a one-level index
@@ -1590,7 +1596,7 @@ void mem_malloc_init(ulong start, ulong size)
#define clear_binblock(ii) (binblocks_w = (mbinptr)(binblocks_r & ~(idx2binblock(ii))))
-
+
/* Other static bookkeeping data */
@@ -1628,7 +1634,7 @@ static unsigned int max_n_mmaps = 0;
static unsigned long max_mmapped_mem = 0;
#endif
-
+
/*
Debugging support
@@ -1769,7 +1775,7 @@ static void do_check_malloced_chunk(p, s) mchunkptr p; INTERNAL_SIZE_T s;
#define check_malloced_chunk(P,N)
#endif
-
+
/*
Macro-based internal utilities
@@ -1841,7 +1847,7 @@ static void do_check_malloced_chunk(p, s) mchunkptr p; INTERNAL_SIZE_T s;
(last_remainder->fd = last_remainder->bk = last_remainder)
-
+
/* Routines dealing with mmap(). */
@@ -1972,7 +1978,7 @@ static mchunkptr mremap_chunk(p, new_size) mchunkptr p; size_t new_size;
#endif /* HAVE_MMAP */
-
+
/*
Extend the top-most chunk by obtaining memory from system.
@@ -2089,7 +2095,7 @@ static void malloc_extend_top(nb) INTERNAL_SIZE_T nb;
}
-
+
/* Main public routines */
@@ -2174,6 +2180,20 @@ Void_t* mALLOc(bytes) size_t bytes;
INTERNAL_SIZE_T nb;
+#ifdef CONFIG_SYS_MALLOC_F_LEN
+ if (!(gd->flags & GD_FLG_RELOC)) {
+ ulong new_ptr;
+ void *ptr;
+
+ new_ptr = gd->malloc_ptr + bytes;
+ if (new_ptr > gd->malloc_limit)
+ panic("Out of pre-reloc memory");
+ ptr = map_sysmem(gd->malloc_base + gd->malloc_ptr, bytes);
+ gd->malloc_ptr = ALIGN(new_ptr, sizeof(new_ptr));
+ return ptr;
+ }
+#endif
+
/* check if mem_malloc_init() was run */
if ((mem_malloc_start == 0) && (mem_malloc_end == 0)) {
/* not initialized yet */
@@ -2396,7 +2416,7 @@ Void_t* mALLOc(bytes) size_t bytes;
}
-
+
/*
@@ -2437,6 +2457,12 @@ void fREe(mem) Void_t* mem;
mchunkptr fwd; /* misc temp for linking */
int islr; /* track whether merging with last_remainder */
+#ifdef CONFIG_SYS_MALLOC_F_LEN
+ /* free() is a no-op - all the memory will be freed on relocation */
+ if (!(gd->flags & GD_FLG_RELOC))
+ return;
+#endif
+
if (mem == NULL) /* free(0) has no effect */
return;
@@ -2513,7 +2539,7 @@ void fREe(mem) Void_t* mem;
}
-
+
/*
@@ -2588,6 +2614,13 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
/* realloc of null is supposed to be same as malloc */
if (oldmem == NULL) return mALLOc(bytes);
+#ifdef CONFIG_SYS_MALLOC_F_LEN
+ if (!(gd->flags & GD_FLG_RELOC)) {
+ /* This is harder to support and should not be needed */
+ panic("pre-reloc realloc() is not supported");
+ }
+#endif
+
newp = oldp = mem2chunk(oldmem);
newsize = oldsize = chunksize(oldp);
@@ -2750,7 +2783,7 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
}
-
+
/*
@@ -2868,7 +2901,7 @@ Void_t* mEMALIGn(alignment, bytes) size_t alignment; size_t bytes;
}
-
+
/*
@@ -2933,6 +2966,12 @@ Void_t* cALLOc(n, elem_size) size_t n; size_t elem_size;
return NULL;
else
{
+#ifdef CONFIG_SYS_MALLOC_F_LEN
+ if (!(gd->flags & GD_FLG_RELOC)) {
+ MALLOC_ZERO(mem, sz);
+ return mem;
+ }
+#endif
p = mem2chunk(mem);
/* Two optional cases in which clearing not necessary */
@@ -2975,7 +3014,7 @@ void cfree(mem) Void_t *mem;
}
#endif
-
+
/*
@@ -3056,7 +3095,7 @@ int malloc_trim(pad) size_t pad;
}
}
-
+
/*
malloc_usable_size:
@@ -3092,7 +3131,7 @@ size_t malloc_usable_size(mem) Void_t* mem;
}
-
+
/* Utility to update current_mallinfo for malloc_stats and mallinfo() */
@@ -3136,7 +3175,7 @@ static void malloc_update_mallinfo()
}
#endif /* DEBUG */
-
+
/*
@@ -3183,7 +3222,7 @@ struct mallinfo mALLINFo()
#endif /* DEBUG */
-
+
/*
mallopt:
diff --git a/common/env_common.c b/common/env_common.c
index cd7b4cd..af59c72 100644
--- a/common/env_common.c
+++ b/common/env_common.c
@@ -27,12 +27,10 @@ struct hsearch_data env_htab = {
.change_ok = env_flags_validate,
};
-static uchar __env_get_char_spec(int index)
+__weak uchar env_get_char_spec(int index)
{
return *((uchar *)(gd->env_addr + index));
}
-uchar env_get_char_spec(int)
- __attribute__((weak, alias("__env_get_char_spec")));
static uchar env_get_char_init(int index)
{
@@ -120,7 +118,7 @@ void set_default_env(const char *s)
}
if (himport_r(&env_htab, (char *)default_environment,
- sizeof(default_environment), '\0', flags,
+ sizeof(default_environment), '\0', flags, 0,
0, NULL) == 0)
error("Environment import failed: errno = %d\n", errno);
@@ -137,7 +135,7 @@ int set_default_vars(int nvars, char * const vars[])
*/
return himport_r(&env_htab, (const char *)default_environment,
sizeof(default_environment), '\0',
- H_NOCLEAR | H_INTERACTIVE, nvars, vars);
+ H_NOCLEAR | H_INTERACTIVE, 0, nvars, vars);
}
#ifdef CONFIG_ENV_AES
@@ -214,7 +212,7 @@ int env_import(const char *buf, int check)
return ret;
}
- if (himport_r(&env_htab, (char *)ep->data, ENV_SIZE, '\0', 0,
+ if (himport_r(&env_htab, (char *)ep->data, ENV_SIZE, '\0', 0, 0,
0, NULL)) {
gd->flags |= GD_FLG_ENV_READY;
return 1;
diff --git a/common/image-fdt.c b/common/image-fdt.c
index 9fc7481..db6e395 100644
--- a/common/image-fdt.c
+++ b/common/image-fdt.c
@@ -450,7 +450,7 @@ __weak int ft_verify_fdt(void *fdt)
return 1;
}
-__weak int arch_fixup_memory_node(void *blob)
+__weak int arch_fixup_fdt(void *blob)
{
return 0;
}
@@ -467,7 +467,10 @@ int image_setup_libfdt(bootm_headers_t *images, void *blob,
puts(" - must RESET the board to recover.\n");
return -1;
}
- arch_fixup_memory_node(blob);
+ if (arch_fixup_fdt(blob) < 0) {
+ puts("ERROR: arch specific fdt fixup failed");
+ return -1;
+ }
if (IMAGE_OF_BOARD_SETUP)
ft_board_setup(blob, gd->bd);
fdt_fixup_ethernet(blob);
@@ -492,7 +495,7 @@ int image_setup_libfdt(bootm_headers_t *images, void *blob,
if (!ft_verify_fdt(blob))
return -1;
-#ifdef CONFIG_SOC_K2HK
+#if defined(CONFIG_SOC_KEYSTONE)
if (IMAGE_OF_BOARD_SETUP)
ft_board_setup_ex(blob, gd->bd);
#endif
diff --git a/common/lcd.c b/common/lcd.c
index 19b86b7..feb913a 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -214,6 +214,11 @@ static inline void console_newline(void)
/*----------------------------------------------------------------------*/
+static void lcd_stub_putc(struct stdio_dev *dev, const char c)
+{
+ lcd_putc(c);
+}
+
void lcd_putc(const char c)
{
if (!lcd_is_enabled) {
@@ -253,6 +258,11 @@ void lcd_putc(const char c)
/*----------------------------------------------------------------------*/
+static void lcd_stub_puts(struct stdio_dev *dev, const char *s)
+{
+ lcd_puts(s);
+}
+
void lcd_puts(const char *s)
{
if (!lcd_is_enabled) {
@@ -426,8 +436,8 @@ int drv_lcd_init(void)
strcpy(lcddev.name, "lcd");
lcddev.ext = 0; /* No extensions */
lcddev.flags = DEV_FLAGS_OUTPUT; /* Output only */
- lcddev.putc = lcd_putc; /* 'putc' function */
- lcddev.puts = lcd_puts; /* 'puts' function */
+ lcddev.putc = lcd_stub_putc; /* 'putc' function */
+ lcddev.puts = lcd_stub_puts; /* 'puts' function */
rc = stdio_register(&lcddev);
diff --git a/common/main.c b/common/main.c
index 32618f1..2979fbe 100644
--- a/common/main.c
+++ b/common/main.c
@@ -17,8 +17,7 @@ DECLARE_GLOBAL_DATA_PTR;
/*
* Board-specific Platform code can reimplement show_boot_progress () if needed
*/
-void inline __show_boot_progress (int val) {}
-void show_boot_progress (int val) __attribute__((weak, alias("__show_boot_progress")));
+__weak void show_boot_progress(int val) {}
static void modem_init(void)
{
diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c
index 062461b..9b200bc 100644
--- a/common/spl/spl_nand.c
+++ b/common/spl/spl_nand.c
@@ -44,7 +44,7 @@ void spl_nand_load_image(void)
/* load linux */
nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
- CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
+ sizeof(*header), (void *)header);
spl_parse_image_header(header);
if (header->ih_os == IH_OS_LINUX) {
/* happy - was a linux */
@@ -62,13 +62,13 @@ void spl_nand_load_image(void)
#endif
#ifdef CONFIG_NAND_ENV_DST
nand_spl_load_image(CONFIG_ENV_OFFSET,
- CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
+ sizeof(*header), (void *)header);
spl_parse_image_header(header);
nand_spl_load_image(CONFIG_ENV_OFFSET, spl_image.size,
(void *)spl_image.load_addr);
#ifdef CONFIG_ENV_OFFSET_REDUND
nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND,
- CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
+ sizeof(*header), (void *)header);
spl_parse_image_header(header);
nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, spl_image.size,
(void *)spl_image.load_addr);
diff --git a/common/splash.c b/common/splash.c
index 18885f1..144fb10 100644
--- a/common/splash.c
+++ b/common/splash.c
@@ -23,15 +23,11 @@
#include <common.h>
#include <splash.h>
-int __splash_screen_prepare(void)
+__weak int splash_screen_prepare(void)
{
return 0;
}
-int splash_screen_prepare(void)
- __attribute__ ((weak, alias("__splash_screen_prepare")));
-
-
#ifdef CONFIG_SPLASH_SCREEN_ALIGN
void splash_get_pos(int *x, int *y)
{
diff --git a/common/stdio.c b/common/stdio.c
index 844f98c..692ca7f 100644
--- a/common/stdio.c
+++ b/common/stdio.c
@@ -11,6 +11,7 @@
#include <config.h>
#include <common.h>
+#include <errno.h>
#include <stdarg.h>
#include <malloc.h>
#include <stdio_dev.h>
@@ -35,23 +36,43 @@ char *stdio_names[MAX_FILES] = { "stdin", "stdout", "stderr" };
#ifdef CONFIG_SYS_DEVICE_NULLDEV
-void nulldev_putc(const char c)
+void nulldev_putc(struct stdio_dev *dev, const char c)
{
/* nulldev is empty! */
}
-void nulldev_puts(const char *s)
+void nulldev_puts(struct stdio_dev *dev, const char *s)
{
/* nulldev is empty! */
}
-int nulldev_input(void)
+int nulldev_input(struct stdio_dev *dev)
{
/* nulldev is empty! */
return 0;
}
#endif
+void stdio_serial_putc(struct stdio_dev *dev, const char c)
+{
+ serial_putc(c);
+}
+
+void stdio_serial_puts(struct stdio_dev *dev, const char *s)
+{
+ serial_puts(s);
+}
+
+int stdio_serial_getc(struct stdio_dev *dev)
+{
+ return serial_getc();
+}
+
+int stdio_serial_tstc(struct stdio_dev *dev)
+{
+ return serial_tstc();
+}
+
/**************************************************************************
* SYSTEM DRIVERS
**************************************************************************
@@ -65,10 +86,10 @@ static void drv_system_init (void)
strcpy (dev.name, "serial");
dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
- dev.putc = serial_putc;
- dev.puts = serial_puts;
- dev.getc = serial_getc;
- dev.tstc = serial_tstc;
+ dev.putc = stdio_serial_putc;
+ dev.puts = stdio_serial_puts;
+ dev.getc = stdio_serial_getc;
+ dev.tstc = stdio_serial_tstc;
stdio_register (&dev);
#ifdef CONFIG_SYS_DEVICE_NULLDEV
@@ -128,32 +149,35 @@ struct stdio_dev* stdio_clone(struct stdio_dev *dev)
return _dev;
}
-int stdio_register (struct stdio_dev * dev)
+int stdio_register_dev(struct stdio_dev *dev, struct stdio_dev **devp)
{
struct stdio_dev *_dev;
_dev = stdio_clone(dev);
if(!_dev)
- return -1;
+ return -ENODEV;
list_add_tail(&(_dev->list), &(devs.list));
+ if (devp)
+ *devp = _dev;
+
return 0;
}
+int stdio_register(struct stdio_dev *dev)
+{
+ return stdio_register_dev(dev, NULL);
+}
+
/* deregister the device "devname".
* returns 0 if success, -1 if device is assigned and 1 if devname not found
*/
#ifdef CONFIG_SYS_STDIO_DEREGISTER
-int stdio_deregister(const char *devname)
+int stdio_deregister_dev(struct stdio_dev *dev)
{
int l;
struct list_head *pos;
- struct stdio_dev *dev;
char temp_names[3][16];
- dev = stdio_get_by_name(devname);
-
- if(!dev) /* device not found */
- return -1;
/* get stdio devices (ListRemoveItem changes the dev list) */
for (l=0 ; l< MAX_FILES; l++) {
if (stdio_devices[l] == dev) {
@@ -177,6 +201,18 @@ int stdio_deregister(const char *devname)
}
return 0;
}
+
+int stdio_deregister(const char *devname)
+{
+ struct stdio_dev *dev;
+
+ dev = stdio_get_by_name(devname);
+
+ if (!dev) /* device not found */
+ return -ENODEV;
+
+ return stdio_deregister_dev(dev);
+}
#endif /* CONFIG_SYS_STDIO_DEREGISTER */
int stdio_init (void)
diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index 0b77c16..c34fd5c 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
@@ -360,7 +360,7 @@ static inline void usb_kbd_poll_for_event(struct usb_device *dev)
}
/* test if a character is in the queue */
-static int usb_kbd_testc(void)
+static int usb_kbd_testc(struct stdio_dev *sdev)
{
struct stdio_dev *dev;
struct usb_device *usb_kbd_dev;
@@ -386,7 +386,7 @@ static int usb_kbd_testc(void)
}
/* gets the character from the queue */
-static int usb_kbd_getc(void)
+static int usb_kbd_getc(struct stdio_dev *sdev)
{
struct stdio_dev *dev;
struct usb_device *usb_kbd_dev;
@@ -522,8 +522,6 @@ int drv_usb_kbd_init(void)
memset(&usb_kbd_dev, 0, sizeof(struct stdio_dev));
strcpy(usb_kbd_dev.name, DEVNAME);
usb_kbd_dev.flags = DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
- usb_kbd_dev.putc = NULL;
- usb_kbd_dev.puts = NULL;
usb_kbd_dev.getc = usb_kbd_getc;
usb_kbd_dev.tstc = usb_kbd_testc;
usb_kbd_dev.priv = (void *)dev;