aboutsummaryrefslogtreecommitdiff
path: root/hw/nios2/boot.c
diff options
context:
space:
mode:
authorSandra Loosemore <sandra@codesourcery.com>2019-04-03 13:53:04 -0600
committerPeter Maydell <peter.maydell@linaro.org>2019-04-29 16:09:51 +0100
commited960ba90549aca1735df128c6b454fe0a5dec2a (patch)
tree81e1d2d2d976da1d78cbd09fba18bdd3dbd7d57f /hw/nios2/boot.c
parente0fb2c3d89aa77057ac4aa073e01f4ca484449b0 (diff)
Add generic Nios II board.
This patch adds support for a generic MMU-less Nios II board that can be used e.g. for bare-metal compiler testing with the linker script and startup code provided by libgloss. Nios II booting is also tweaked so that bare-metal binaries start executing in RAM starting at 0x00000000, rather than an alias at 0xc0000000, which allows features such as unwinding to work when binaries are linked to start at the beginning of the address space. The generic_nommu.c parts are based on code by Andrew Jenner, which was in turn based on code by Marek Vasut. Originally by Marek Vasut and Andrew Jenner. Signed-off-by: Sandra Loosemore <sandra@codesourcery.com> Signed-off-by: Julian Brown <julian@codesourcery.com> Signed-off-by: Andrew Jenner <andrew@codesourcery.com> Signed-off-by: Marek Vasut <marex@denx.de> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-id: 1554321185-2825-2-git-send-email-sandra@codesourcery.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/nios2/boot.c')
-rw-r--r--hw/nios2/boot.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/hw/nios2/boot.c b/hw/nios2/boot.c
index 5f0ab2fbb9..276068c842 100644
--- a/hw/nios2/boot.c
+++ b/hw/nios2/boot.c
@@ -138,7 +138,6 @@ void nios2_load_kernel(Nios2CPU *cpu, hwaddr ddr_base,
if (kernel_filename) {
int kernel_size, fdt_size;
uint64_t entry, low, high;
- uint32_t base32;
int big_endian = 0;
#ifdef TARGET_WORDS_BIGENDIAN
@@ -149,17 +148,24 @@ void nios2_load_kernel(Nios2CPU *cpu, hwaddr ddr_base,
kernel_size = load_elf(kernel_filename, NULL, NULL, NULL,
&entry, &low, &high,
big_endian, EM_ALTERA_NIOS2, 0, 0);
- base32 = entry;
- if (base32 == 0xc0000000) {
+ if ((uint32_t)entry == 0xc0000000) {
+ /*
+ * The Nios II processor reference guide documents that the
+ * kernel is placed at virtual memory address 0xc0000000,
+ * and we've got something that points there. Reload it
+ * and adjust the entry to get the address in physical RAM.
+ */
kernel_size = load_elf(kernel_filename, NULL,
translate_kernel_address, NULL,
&entry, NULL, NULL,
big_endian, EM_ALTERA_NIOS2, 0, 0);
+ boot_info.bootstrap_pc = ddr_base + 0xc0000000 +
+ (entry & 0x07ffffff);
+ } else {
+ /* Use the entry point in the ELF image. */
+ boot_info.bootstrap_pc = (uint32_t)entry;
}
- /* Always boot into physical ram. */
- boot_info.bootstrap_pc = ddr_base + 0xc0000000 + (entry & 0x07ffffff);
-
/* If it wasn't an ELF image, try an u-boot image. */
if (kernel_size < 0) {
hwaddr uentry, loadaddr = LOAD_UIMAGE_LOADADDR_INVALID;