boot.c (d67a6e054b92e5e1cbb7b0bd5782a670cc7f0df7) | boot.c (55c136599f512a86e3fec9f77b6b5a30a6b34cca) |
---|---|
1/* 2 * QEMU RISC-V Boot Helper 3 * 4 * Copyright (c) 2017 SiFive, Inc. 5 * Copyright (c) 2019 Alistair Francis <alistair.francis@wdc.com> 6 * 7 * This program is free software; you can redistribute it and/or modify it 8 * under the terms and conditions of the GNU General Public License, --- 114 unchanged lines hidden (view full) --- 123 filename = riscv_find_bios(firmware_filename); 124 } 125 126 return filename; 127} 128 129target_ulong riscv_find_and_load_firmware(MachineState *machine, 130 const char *default_machine_firmware, | 1/* 2 * QEMU RISC-V Boot Helper 3 * 4 * Copyright (c) 2017 SiFive, Inc. 5 * Copyright (c) 2019 Alistair Francis <alistair.francis@wdc.com> 6 * 7 * This program is free software; you can redistribute it and/or modify it 8 * under the terms and conditions of the GNU General Public License, --- 114 unchanged lines hidden (view full) --- 123 filename = riscv_find_bios(firmware_filename); 124 } 125 126 return filename; 127} 128 129target_ulong riscv_find_and_load_firmware(MachineState *machine, 130 const char *default_machine_firmware, |
131 hwaddr firmware_load_addr, | 131 hwaddr *firmware_load_addr, |
132 symbol_fn_t sym_cb) 133{ 134 char *firmware_filename; | 132 symbol_fn_t sym_cb) 133{ 134 char *firmware_filename; |
135 target_ulong firmware_end_addr = firmware_load_addr; | 135 target_ulong firmware_end_addr = *firmware_load_addr; |
136 137 firmware_filename = riscv_find_firmware(machine->firmware, 138 default_machine_firmware); 139 140 if (firmware_filename) { 141 /* If not "none" load the firmware */ 142 firmware_end_addr = riscv_load_firmware(firmware_filename, 143 firmware_load_addr, sym_cb); 144 g_free(firmware_filename); 145 } 146 147 return firmware_end_addr; 148} 149 150target_ulong riscv_load_firmware(const char *firmware_filename, | 136 137 firmware_filename = riscv_find_firmware(machine->firmware, 138 default_machine_firmware); 139 140 if (firmware_filename) { 141 /* If not "none" load the firmware */ 142 firmware_end_addr = riscv_load_firmware(firmware_filename, 143 firmware_load_addr, sym_cb); 144 g_free(firmware_filename); 145 } 146 147 return firmware_end_addr; 148} 149 150target_ulong riscv_load_firmware(const char *firmware_filename, |
151 hwaddr firmware_load_addr, | 151 hwaddr *firmware_load_addr, |
152 symbol_fn_t sym_cb) 153{ 154 uint64_t firmware_entry, firmware_end; 155 ssize_t firmware_size; 156 157 g_assert(firmware_filename != NULL); 158 159 if (load_elf_ram_sym(firmware_filename, NULL, NULL, NULL, 160 &firmware_entry, NULL, &firmware_end, NULL, 161 0, EM_RISCV, 1, 0, NULL, true, sym_cb) > 0) { | 152 symbol_fn_t sym_cb) 153{ 154 uint64_t firmware_entry, firmware_end; 155 ssize_t firmware_size; 156 157 g_assert(firmware_filename != NULL); 158 159 if (load_elf_ram_sym(firmware_filename, NULL, NULL, NULL, 160 &firmware_entry, NULL, &firmware_end, NULL, 161 0, EM_RISCV, 1, 0, NULL, true, sym_cb) > 0) { |
162 *firmware_load_addr = firmware_entry; |
|
162 return firmware_end; 163 } 164 165 firmware_size = load_image_targphys_as(firmware_filename, | 163 return firmware_end; 164 } 165 166 firmware_size = load_image_targphys_as(firmware_filename, |
166 firmware_load_addr, | 167 *firmware_load_addr, |
167 current_machine->ram_size, NULL); 168 169 if (firmware_size > 0) { | 168 current_machine->ram_size, NULL); 169 170 if (firmware_size > 0) { |
170 return firmware_load_addr + firmware_size; | 171 return *firmware_load_addr + firmware_size; |
171 } 172 173 error_report("could not load firmware '%s'", firmware_filename); 174 exit(1); 175} 176 177static void riscv_load_initrd(MachineState *machine, uint64_t kernel_entry) 178{ --- 297 unchanged lines hidden --- | 172 } 173 174 error_report("could not load firmware '%s'", firmware_filename); 175 exit(1); 176} 177 178static void riscv_load_initrd(MachineState *machine, uint64_t kernel_entry) 179{ --- 297 unchanged lines hidden --- |