aboutsummaryrefslogtreecommitdiff
path: root/hw/nios2/boot.c
diff options
context:
space:
mode:
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;