From 75a279c8f28539f560a23425073d97ffee746716 Mon Sep 17 00:00:00 2001 From: Gabor Juhos Date: Sun, 6 Jan 2013 00:54:20 +0000 Subject: [PATCH 1/9] MIPS: bootm.c: use debug macro to print debug message The '## Transferring control ...' message is printed only if DEBUG is enabled. Get rid of the 'ifdef DEBUG' statement and use the debug macro instead. Signed-off-by: Gabor Juhos --- arch/mips/lib/bootm.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c index 608c1a78d..4ac712aa4 100644 --- a/arch/mips/lib/bootm.c +++ b/arch/mips/lib/bootm.c @@ -59,10 +59,8 @@ int do_bootm_linux(int flag, int argc, char * const argv[], bootstage_mark(BOOTSTAGE_ID_RUN_OS); -#ifdef DEBUG - printf("## Transferring control to Linux (at address %08lx) ...\n", + debug("## Transferring control to Linux (at address %08lx) ...\n", (ulong) theKernel); -#endif linux_params_init(UNCACHED_SDRAM(gd->bd->bi_boot_params), commandline); From e08634c7bfdb5fcda2541a8845d44888538d6178 Mon Sep 17 00:00:00 2001 From: Gabor Juhos Date: Mon, 7 Jan 2013 02:53:40 +0000 Subject: [PATCH 2/9] MIPS: bootm.c: separate linux jump code Move the actual jump code into a separate function. This make the code reusable for bootm subcommands. Signed-off-by: Gabor Juhos Cc: Daniel Schwierzeck --- arch/mips/lib/bootm.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c index 4ac712aa4..689d17bd3 100644 --- a/arch/mips/lib/bootm.c +++ b/arch/mips/lib/bootm.c @@ -43,10 +43,27 @@ static int linux_env_idx; static void linux_params_init(ulong start, char *commandline); static void linux_env_set(char *env_name, char *env_val); +static void boot_jump_linux(bootm_headers_t *images) +{ + void (*theKernel) (int, char **, char **, int *); + + /* find kernel entry point */ + theKernel = (void (*)(int, char **, char **, int *))images->ep; + + debug("## Transferring control to Linux (at address %08lx) ...\n", + (ulong) theKernel); + + bootstage_mark(BOOTSTAGE_ID_RUN_OS); + + /* we assume that the kernel is in place */ + printf("\nStarting kernel ...\n\n"); + + theKernel(linux_argc, linux_argv, linux_env, 0); +} + int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *images) { - void (*theKernel) (int, char **, char **, int *); char *commandline = getenv("bootargs"); char env_buf[12]; char *cp; @@ -54,14 +71,6 @@ int do_bootm_linux(int flag, int argc, char * const argv[], if ((flag != 0) && (flag != BOOTM_STATE_OS_GO)) return 1; - /* find kernel entry point */ - theKernel = (void (*)(int, char **, char **, int *))images->ep; - - bootstage_mark(BOOTSTAGE_ID_RUN_OS); - - debug("## Transferring control to Linux (at address %08lx) ...\n", - (ulong) theKernel); - linux_params_init(UNCACHED_SDRAM(gd->bd->bi_boot_params), commandline); #ifdef CONFIG_MEMSIZE_IN_BYTES @@ -95,10 +104,7 @@ int do_bootm_linux(int flag, int argc, char * const argv[], if (cp) linux_env_set("eth1addr", cp); - /* we assume that the kernel is in place */ - printf("\nStarting kernel ...\n\n"); - - theKernel(linux_argc, linux_argv, linux_env, 0); + boot_jump_linux(images); /* does not return */ return 1; From 0ea7213f63f580aa679a36795831dabd35d786aa Mon Sep 17 00:00:00 2001 From: Gabor Juhos Date: Mon, 7 Jan 2013 02:53:41 +0000 Subject: [PATCH 3/9] MIPS: bootm.c: separate environment initialization Move the environment initialization code into a separate function. This make the code reusable for bootm subcommands. Signed-off-by: Gabor Juhos Cc: Daniel Schwierzeck --- arch/mips/lib/bootm.c | 50 +++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c index 689d17bd3..8c2e50824 100644 --- a/arch/mips/lib/bootm.c +++ b/arch/mips/lib/bootm.c @@ -43,34 +43,12 @@ static int linux_env_idx; static void linux_params_init(ulong start, char *commandline); static void linux_env_set(char *env_name, char *env_val); -static void boot_jump_linux(bootm_headers_t *images) -{ - void (*theKernel) (int, char **, char **, int *); - - /* find kernel entry point */ - theKernel = (void (*)(int, char **, char **, int *))images->ep; - - debug("## Transferring control to Linux (at address %08lx) ...\n", - (ulong) theKernel); - - bootstage_mark(BOOTSTAGE_ID_RUN_OS); - - /* we assume that the kernel is in place */ - printf("\nStarting kernel ...\n\n"); - - theKernel(linux_argc, linux_argv, linux_env, 0); -} - -int do_bootm_linux(int flag, int argc, char * const argv[], - bootm_headers_t *images) +static void boot_prep_linux(bootm_headers_t *images) { char *commandline = getenv("bootargs"); char env_buf[12]; char *cp; - if ((flag != 0) && (flag != BOOTM_STATE_OS_GO)) - return 1; - linux_params_init(UNCACHED_SDRAM(gd->bd->bi_boot_params), commandline); #ifdef CONFIG_MEMSIZE_IN_BYTES @@ -103,7 +81,33 @@ int do_bootm_linux(int flag, int argc, char * const argv[], cp = getenv("eth1addr"); if (cp) linux_env_set("eth1addr", cp); +} +static void boot_jump_linux(bootm_headers_t *images) +{ + void (*theKernel) (int, char **, char **, int *); + + /* find kernel entry point */ + theKernel = (void (*)(int, char **, char **, int *))images->ep; + + debug("## Transferring control to Linux (at address %08lx) ...\n", + (ulong) theKernel); + + bootstage_mark(BOOTSTAGE_ID_RUN_OS); + + /* we assume that the kernel is in place */ + printf("\nStarting kernel ...\n\n"); + + theKernel(linux_argc, linux_argv, linux_env, 0); +} + +int do_bootm_linux(int flag, int argc, char * const argv[], + bootm_headers_t *images) +{ + if ((flag != 0) && (flag != BOOTM_STATE_OS_GO)) + return 1; + + boot_prep_linux(images); boot_jump_linux(images); /* does not return */ From 9c170e2ef4ad2bd246c22c93824d754224c4929a Mon Sep 17 00:00:00 2001 From: Gabor Juhos Date: Mon, 7 Jan 2013 02:53:42 +0000 Subject: [PATCH 4/9] MIPS: bootm.c: add support for 'prep' and 'go' subcommands The bootm command supports subcommands since long time however those subcommands are not yet usable on MIPS. The patch is based on the ARM implementation, and it adds support for the 'prep' and 'go' subcommands only. Signed-off-by: Gabor Juhos Cc: Daniel Schwierzeck --- arch/mips/lib/bootm.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c index 8c2e50824..a36154a89 100644 --- a/arch/mips/lib/bootm.c +++ b/arch/mips/lib/bootm.c @@ -104,8 +104,19 @@ static void boot_jump_linux(bootm_headers_t *images) int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *images) { - if ((flag != 0) && (flag != BOOTM_STATE_OS_GO)) - return 1; + /* No need for those on MIPS */ + if (flag & BOOTM_STATE_OS_BD_T || flag & BOOTM_STATE_OS_CMDLINE) + return -1; + + if (flag & BOOTM_STATE_OS_PREP) { + boot_prep_linux(images); + return 0; + } + + if (flag & BOOTM_STATE_OS_GO) { + boot_jump_linux(images); + return 0; + } boot_prep_linux(images); boot_jump_linux(images); From 0f17f59c8ae4b9acf436485ed28a3d4706e91e7d Mon Sep 17 00:00:00 2001 From: Gabor Juhos Date: Tue, 8 Jan 2013 02:22:50 +0000 Subject: [PATCH 5/9] MIPS: qemu-mips: fix a typo in README The 'Limitations & comments' section refers to the '-m mips' switch which is not valid. The '-m' switch can be used for setting the virtual RAM size: $qemu-system-mips --help | grep '^-m ' -m megs set virtual RAM size to megs MB [default=128] $ The correct switch for specifying the machine type is '-M'. Fix the text to refer to that. Signed-off-by: Gabor Juhos Cc: Daniel Schwierzeck Cc: Vlad Lungu --- board/qemu-mips/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/qemu-mips/README b/board/qemu-mips/README index 9fd97e124..b2c2b5406 100644 --- a/board/qemu-mips/README +++ b/board/qemu-mips/README @@ -6,7 +6,7 @@ http://www.nongnu.org/qemu/ Limitations & comments ---------------------- -Supports the "-m mips" configuration of qemu: serial,NE2000,IDE. +Supports the "-M mips" configuration of qemu: serial,NE2000,IDE. Support is big endian only for now (or at least this is what I tested). Derived from au1x00 with a lot of things cut out. From 3567e4ef115dc129b4f8720b5abd65262f32f0f9 Mon Sep 17 00:00:00 2001 From: Gabor Juhos Date: Tue, 8 Jan 2013 02:22:51 +0000 Subject: [PATCH 6/9] MIPS: qemu-mips: add '-M mips' switch to the example usage command Using the example command from the README file does not work as expected. qemu shows a text similar to the one below and it hangs. $ qemu-system-mips -L . -nographic Could not open option rom 'pxe-pcnet.rom': No such file or directory qemu-system-mips: pci_add_option_rom: failed to find romfile "vgabios-cirrus.bin" qemu: terminating on signal 15 from pid 19726 This happens because qemu emulates a Malta board by default if the machine type is not defined explicitely on the command line. For a working test, the '-M mips' switch is required: $ qemu-system-mips -M mips -L . -nographic Could not open option rom 'vgabios.bin': No such file or directory U-Boot 2013.01-rc2-00132-g1e8e648-dirty (Jan 08 2013 - 09:06:42) Board: Qemu -M mips CPU: 24Kf proc_id=0x19300 DRAM: 128 MiB ## Unknown flash on Bank 1 - Size = 0x00000000 = 0 MB Flash: 0 Bytes *** Warning - bad CRC, using default environment In: serial Out: serial Err: serial Net: NE2000 Hit any key to stop autoboot: 0 qemu-mips # Signed-off-by: Gabor Juhos Cc: Daniel Schwierzeck Cc: Vlad Lungu --- board/qemu-mips/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/qemu-mips/README b/board/qemu-mips/README index b2c2b5406..ec58ce4ab 100644 --- a/board/qemu-mips/README +++ b/board/qemu-mips/README @@ -23,7 +23,7 @@ I) Example usage: # ln -s u-boot.bin mips_bios.bin start it: -qemu-system-mips -L . /dev/null -nographic +qemu-system-mips -M mips -L . /dev/null -nographic or From 2b086ce4a1e7bb35a885b1455239d1b1ee814f97 Mon Sep 17 00:00:00 2001 From: Daniel Schwierzeck Date: Tue, 8 Jan 2013 17:51:11 +0100 Subject: [PATCH 7/9] MIPS: qemu-mips: update and fix example usage in README By now U-Boot supports Qemu MIPS for little and big endian as well as 32 bit and 64 bit. Update and fix the example usage in the README to reflect this. Signed-off-by: Daniel Schwierzeck --- board/qemu-mips/README | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/board/qemu-mips/README b/board/qemu-mips/README index ec58ce4ab..1fdfbab67 100644 --- a/board/qemu-mips/README +++ b/board/qemu-mips/README @@ -7,7 +7,7 @@ http://www.nongnu.org/qemu/ Limitations & comments ---------------------- Supports the "-M mips" configuration of qemu: serial,NE2000,IDE. -Support is big endian only for now (or at least this is what I tested). +Supports little and big endian as well as 32 bit and 64 bit. Derived from au1x00 with a lot of things cut out. Supports emulated flash (patch Jean-Christophe PLAGNIOL-VILLARD) with @@ -21,19 +21,33 @@ Notes for the Qemu MIPS port I) Example usage: -# ln -s u-boot.bin mips_bios.bin -start it: -qemu-system-mips -M mips -L . /dev/null -nographic +Using u-boot.bin as ROM (replaces Qemu monitor): -or +32 bit, big endian: +# make qemu_mips +# qemu-system-mips -M mips -bios u-boot.bin -nographic + +32 bit, little endian: +# make qemu_mipsel +# qemu-system-mipsel -M mips -bios u-boot.bin -nographic + +64 bit, big endian: +# make qemu_mips64 +# qemu-system-mips64 -cpu MIPS64R2-generic -M mips -bios u-boot.bin -nographic + +64 bit, little endian: +# make qemu_mips64el +# qemu-system-mips64el -cpu MIPS64R2-generic -M mips -bios u-boot.bin -nographic + +or using u-boot.bin from emulated flash: if you use a qemu version after commit 4224 create image: # dd of=flash bs=1k count=4k if=/dev/zero # dd of=flash bs=1k conv=notrunc if=u-boot.bin -start it: -# qemu-system-mips -M mips -pflash flash -monitor null -nographic +start it (see above): +# qemu-system-mips[64][el] [-cpu MIPS64R2-generic] -M mips -pflash flash -nographic 2) Download kernel + initrd From 3ed75b6f7415332f4f6c57b1d84ca720b803aed4 Mon Sep 17 00:00:00 2001 From: Daniel Schwierzeck Date: Sat, 12 Jan 2013 18:58:54 +0100 Subject: [PATCH 8/9] README.qemu-mips: move README file from board to doc directory Signed-off-by: Daniel Schwierzeck --- board/qemu-mips/README => doc/README.qemu-mips | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename board/qemu-mips/README => doc/README.qemu-mips (100%) diff --git a/board/qemu-mips/README b/doc/README.qemu-mips similarity index 100% rename from board/qemu-mips/README rename to doc/README.qemu-mips From 54b08efcf2f4ff532ce99c53f341a59c193331a5 Mon Sep 17 00:00:00 2001 From: Daniel Schwierzeck Date: Sat, 12 Jan 2013 19:09:11 +0100 Subject: [PATCH 9/9] README.mips: update known issues and TODOs Signed-off-by: Daniel Schwierzeck --- doc/README.mips | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/doc/README.mips b/doc/README.mips index 85dea400c..f4f770b99 100644 --- a/doc/README.mips +++ b/doc/README.mips @@ -16,11 +16,6 @@ Toolchains Known Issues ------------ - * Little endian build problem - - If use non-ELDK toolchains, -EB will be set to CPPFLAGS. Therefore all - objects will be generated in big-endian format. - * Cache incoherency issue caused by do_bootelf_exec() at cmd_elf.c Cache will be disabled before entering the loaded ELF image without @@ -55,3 +50,9 @@ TODOs * Due to cache initialization issues, the DRAM on board must be initialized in board specific assembler language before the cache init code is run -- that is, initialize the DRAM in lowlevel_init(). + + * get rid of CONFIG_MANUAL_RELOC + + * centralize/share more CPU code of MIPS32, MIPS64 and XBurst + + * support Qemu Malta