summaryrefslogtreecommitdiff
path: root/lib_mips
diff options
context:
space:
mode:
Diffstat (limited to 'lib_mips')
-rw-r--r--lib_mips/Makefile4
-rw-r--r--lib_mips/board.c68
-rw-r--r--lib_mips/bootm.c5
-rw-r--r--lib_mips/bootm_qemu_mips.c76
-rw-r--r--lib_mips/time.c6
5 files changed, 129 insertions, 30 deletions
diff --git a/lib_mips/Makefile b/lib_mips/Makefile
index 8176437..7967e58 100644
--- a/lib_mips/Makefile
+++ b/lib_mips/Makefile
@@ -28,7 +28,11 @@ LIB = $(obj)lib$(ARCH).a
SOBJS-y +=
COBJS-y += board.o
+ifeq ($(CONFIG_QEMU_MIPS),y)
+COBJS-y += bootm_qemu_mips.o
+else
COBJS-y += bootm.o
+endif
COBJS-y += time.o
SRCS := $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
diff --git a/lib_mips/board.c b/lib_mips/board.c
index 09b8b3b..dfe6831 100644
--- a/lib_mips/board.c
+++ b/lib_mips/board.c
@@ -25,20 +25,22 @@
#include <command.h>
#include <malloc.h>
#include <devices.h>
+#include <timestamp.h>
#include <version.h>
#include <net.h>
#include <environment.h>
#include <nand.h>
+#include <onenand_uboot.h>
#include <spi.h>
DECLARE_GLOBAL_DATA_PTR;
-#if ( ((CFG_ENV_ADDR+CFG_ENV_SIZE) < CFG_MONITOR_BASE) || \
- (CFG_ENV_ADDR >= (CFG_MONITOR_BASE + CFG_MONITOR_LEN)) ) || \
- defined(CFG_ENV_IS_IN_NVRAM)
-#define TOTAL_MALLOC_LEN (CFG_MALLOC_LEN + CFG_ENV_SIZE)
+#if ( ((CONFIG_ENV_ADDR+CONFIG_ENV_SIZE) < CONFIG_SYS_MONITOR_BASE) || \
+ (CONFIG_ENV_ADDR >= (CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN)) ) || \
+ defined(CONFIG_ENV_IS_IN_NVRAM)
+#define TOTAL_MALLOC_LEN (CONFIG_SYS_MALLOC_LEN + CONFIG_ENV_SIZE)
#else
-#define TOTAL_MALLOC_LEN CFG_MALLOC_LEN
+#define TOTAL_MALLOC_LEN CONFIG_SYS_MALLOC_LEN
#endif
#undef DEBUG
@@ -53,7 +55,7 @@ extern ulong uboot_end;
ulong monitor_flash_len;
const char version_string[] =
- U_BOOT_VERSION" (" __DATE__ " - " __TIME__ ")";
+ U_BOOT_VERSION" (" U_BOOT_DATE " - " U_BOOT_TIME ")";
static char *failed = "*** failed ***\n";
@@ -70,12 +72,21 @@ static ulong mem_malloc_brk;
*/
unsigned long mips_io_port_base = -1;
+int __board_early_init_f(void)
+{
+ /*
+ * Nothing to do in this dummy implementation
+ */
+ return 0;
+}
+int board_early_init_f(void) __attribute__((weak, alias("__board_early_init_f")));
+
/*
* The Malloc area is immediately below the monitor copy in DRAM
*/
static void mem_malloc_init (void)
{
- ulong dest_addr = CFG_MONITOR_BASE + gd->reloc_off;
+ ulong dest_addr = CONFIG_SYS_MONITOR_BASE + gd->reloc_off;
mem_malloc_end = dest_addr;
mem_malloc_start = dest_addr - TOTAL_MALLOC_LEN;
@@ -123,7 +134,7 @@ static int display_banner(void)
return (0);
}
-#ifndef CFG_NO_FLASH
+#ifndef CONFIG_SYS_NO_FLASH
static void display_flash_config(ulong size)
{
puts ("Flash: ");
@@ -167,6 +178,7 @@ static int init_baudrate (void)
typedef int (init_fnc_t) (void);
init_fnc_t *init_sequence[] = {
+ board_early_init_f,
timer_init,
env_init, /* initialize environment */
#ifdef CONFIG_INCA_IP
@@ -187,7 +199,7 @@ void board_init_f(ulong bootflag)
gd_t gd_data, *id;
bd_t *bd;
init_fnc_t **init_fnc_ptr;
- ulong addr, addr_sp, len = (ulong)&uboot_end - CFG_MONITOR_BASE;
+ ulong addr, addr_sp, len = (ulong)&uboot_end - CONFIG_SYS_MONITOR_BASE;
ulong *s;
#ifdef CONFIG_PURPLE
void copy_code (ulong);
@@ -211,7 +223,7 @@ void board_init_f(ulong bootflag)
* Now that we have DRAM mapped and working, we can
* relocate the code and continue running from DRAM.
*/
- addr = CFG_SDRAM_BASE + gd->ram_size;
+ addr = CONFIG_SYS_SDRAM_BASE + gd->ram_size;
/* We can reserve some RAM "on top" here.
*/
@@ -252,10 +264,10 @@ void board_init_f(ulong bootflag)
/* Reserve memory for boot params.
*/
- addr_sp -= CFG_BOOTPARAMS_LEN;
+ addr_sp -= CONFIG_SYS_BOOTPARAMS_LEN;
bd->bi_boot_params = addr_sp;
debug ("Reserving %dk for boot params() at: %08lx\n",
- CFG_BOOTPARAMS_LEN >> 10, addr_sp);
+ CONFIG_SYS_BOOTPARAMS_LEN >> 10, addr_sp);
/*
* Finally, we set up a new (bigger) stack.
@@ -274,7 +286,7 @@ void board_init_f(ulong bootflag)
/*
* Save local variables to board info struct
*/
- bd->bi_memstart = CFG_SDRAM_BASE; /* start of DRAM memory */
+ bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; /* start of DRAM memory */
bd->bi_memsize = gd->ram_size; /* size of DRAM memory in bytes */
bd->bi_baudrate = gd->baudrate; /* Console Baudrate */
@@ -304,11 +316,11 @@ void board_init_f(ulong bootflag)
void board_init_r (gd_t *id, ulong dest_addr)
{
cmd_tbl_t *cmdtp;
-#ifndef CFG_NO_FLASH
+#ifndef CONFIG_SYS_NO_FLASH
ulong size;
#endif
extern void malloc_bin_reloc (void);
-#ifndef CFG_ENV_IS_NOWHERE
+#ifndef CONFIG_ENV_IS_NOWHERE
extern char * env_name_spec;
#endif
char *s, *e;
@@ -320,7 +332,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
debug ("Now running in RAM - U-Boot at: %08lx\n", dest_addr);
- gd->reloc_off = dest_addr - CFG_MONITOR_BASE;
+ gd->reloc_off = dest_addr - CONFIG_SYS_MONITOR_BASE;
monitor_flash_len = (ulong)&uboot_end_data - dest_addr;
@@ -345,7 +357,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
addr = (ulong)(cmdtp->usage) + gd->reloc_off;
cmdtp->usage = (char *)addr;
}
-#ifdef CFG_LONGHELP
+#ifdef CONFIG_SYS_LONGHELP
if (cmdtp->help) {
addr = (ulong)(cmdtp->help) + gd->reloc_off;
cmdtp->help = (char *)addr;
@@ -353,21 +365,21 @@ void board_init_r (gd_t *id, ulong dest_addr)
#endif
}
/* there are some other pointer constants we must deal with */
-#ifndef CFG_ENV_IS_NOWHERE
+#ifndef CONFIG_ENV_IS_NOWHERE
env_name_spec += gd->reloc_off;
#endif
bd = gd->bd;
-#ifndef CFG_NO_FLASH
+#ifndef CONFIG_SYS_NO_FLASH
/* configure available FLASH banks */
size = flash_init();
display_flash_config (size);
bd->bi_flashsize = size;
#endif
- bd->bi_flashstart = CFG_FLASH_BASE;
-#if CFG_MONITOR_BASE == CFG_FLASH_BASE
+ bd->bi_flashstart = CONFIG_SYS_FLASH_BASE;
+#if CONFIG_SYS_MONITOR_BASE == CONFIG_SYS_FLASH_BASE
bd->bi_flashoffset = monitor_flash_len; /* reserved area for U-Boot */
#else
bd->bi_flashoffset = 0;
@@ -377,6 +389,15 @@ void board_init_r (gd_t *id, ulong dest_addr)
mem_malloc_init();
malloc_bin_reloc();
+#ifdef CONFIG_CMD_NAND
+ puts ("NAND: ");
+ nand_init (); /* go init the NAND */
+#endif
+
+#if defined(CONFIG_CMD_ONENAND)
+ onenand_init();
+#endif
+
/* relocate environment function pointers etc. */
env_relocate();
@@ -418,11 +439,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
}
#endif
-#ifdef CONFIG_CMD_NAND
- puts ("NAND: ");
- nand_init (); /* go init the NAND */
-#endif
-
#ifdef CONFIG_CMD_SPI
puts ("SPI: ");
spi_init (); /* go init the SPI */
diff --git a/lib_mips/bootm.c b/lib_mips/bootm.c
index c1bf21e..3db22ea 100644
--- a/lib_mips/bootm.c
+++ b/lib_mips/bootm.c
@@ -50,6 +50,9 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
char env_buf[12];
char *cp;
+ if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
+ return 1;
+
/* find kernel entry point */
theKernel = (void (*)(int, char **, char **, int *))images->ep;
@@ -73,7 +76,7 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
linux_env_set ("memsize", env_buf);
sprintf (env_buf, "0x%08X", (uint) UNCACHED_SDRAM (images->rd_start));
- linux_env_set ("images->rd_start", env_buf);
+ linux_env_set ("initrd_start", env_buf);
sprintf (env_buf, "0x%X", (uint) (images->rd_end - images->rd_start));
linux_env_set ("initrd_size", env_buf);
diff --git a/lib_mips/bootm_qemu_mips.c b/lib_mips/bootm_qemu_mips.c
new file mode 100644
index 0000000..cc70fa9
--- /dev/null
+++ b/lib_mips/bootm_qemu_mips.c
@@ -0,0 +1,76 @@
+/*
+ * (C) Copyright 2008
+ * Jean-Christophe PLAGNIOL-VILLARD <jcplagniol@jcrosoft.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <common.h>
+#include <command.h>
+#include <image.h>
+#include <asm/byteorder.h>
+#include <asm/addrspace.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
+{
+ void (*theKernel) (int, char **, char **, int *);
+ char *bootargs = getenv ("bootargs");
+ char *start;
+ uint len;
+
+ /* find kernel entry point */
+ theKernel = (void (*)(int, char **, char **, int *))images->ep;
+
+ show_boot_progress (15);
+
+ debug ("## Transferring control to Linux (at address %08lx) ...\n",
+ (ulong) theKernel);
+
+ gd->bd->bi_boot_params = gd->bd->bi_memstart + (16 << 20) - 256;
+ debug ("%-12s= 0x%08lX\n", "boot_params", (ulong)gd->bd->bi_boot_params);
+
+ /* set Magic */
+ *(int32_t *)(gd->bd->bi_boot_params - 4) = 0x12345678;
+ /* set ram_size */
+ *(int32_t *)(gd->bd->bi_boot_params - 8) = gd->ram_size;
+
+ start = (char*)gd->bd->bi_boot_params;
+
+ len = strlen(bootargs);
+
+ strncpy(start, bootargs, len + 1);
+
+ start += len;
+
+ len = images->rd_end - images->rd_start;
+ if (len > 0) {
+ start += sprintf(start," rd_start=0x%08X rd_size=0x%0X",
+ (uint) UNCACHED_SDRAM (images->rd_start),
+ (uint) len);
+ }
+
+ /* we assume that the kernel is in place */
+ printf ("\nStarting kernel ...\n\n");
+
+ theKernel (0, NULL, NULL, 0);
+ /* does not return */
+ return 1;
+}
diff --git a/lib_mips/time.c b/lib_mips/time.c
index 1e92789..07e356d 100644
--- a/lib_mips/time.c
+++ b/lib_mips/time.c
@@ -27,7 +27,7 @@
static unsigned long timestamp;
/* how many counter cycles in a jiffy */
-#define CYCLES_PER_JIFFY (CFG_MIPS_TIMER_FREQ + CFG_HZ / 2) / CFG_HZ
+#define CYCLES_PER_JIFFY (CONFIG_SYS_MIPS_TIMER_FREQ + CONFIG_SYS_HZ / 2) / CONFIG_SYS_HZ
/*
* timer without interrupts
@@ -74,7 +74,7 @@ void udelay(unsigned long usec)
{
unsigned int tmo;
- tmo = read_c0_count() + (usec * (CFG_MIPS_TIMER_FREQ / 1000000));
+ tmo = read_c0_count() + (usec * (CONFIG_SYS_MIPS_TIMER_FREQ / 1000000));
while ((tmo - read_c0_count()) < 0x7fffffff)
/*NOP*/;
}
@@ -94,5 +94,5 @@ unsigned long long get_ticks(void)
*/
ulong get_tbclk(void)
{
- return CFG_HZ;
+ return CONFIG_SYS_HZ;
}