|
@@ -18,6 +18,7 @@
|
|
*/
|
|
*/
|
|
|
|
|
|
#include "qemu/osdep.h"
|
|
#include "qemu/osdep.h"
|
|
|
|
+#include "qemu-common.h"
|
|
#include "qemu/units.h"
|
|
#include "qemu/units.h"
|
|
#include "qemu/error-report.h"
|
|
#include "qemu/error-report.h"
|
|
#include "exec/cpu-defs.h"
|
|
#include "exec/cpu-defs.h"
|
|
@@ -32,6 +33,59 @@
|
|
# define KERNEL_BOOT_ADDRESS 0x80200000
|
|
# define KERNEL_BOOT_ADDRESS 0x80200000
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
+void riscv_find_and_load_firmware(MachineState *machine,
|
|
|
|
+ const char *default_machine_firmware,
|
|
|
|
+ hwaddr firmware_load_addr)
|
|
|
|
+{
|
|
|
|
+ char *firmware_filename;
|
|
|
|
+
|
|
|
|
+ if (!machine->firmware) {
|
|
|
|
+ /*
|
|
|
|
+ * The user didn't specify -bios.
|
|
|
|
+ * At the moment we default to loading nothing when this hapens.
|
|
|
|
+ * In the future this defaul will change to loading the prebuilt
|
|
|
|
+ * OpenSBI firmware. Let's warn the user and then continue.
|
|
|
|
+ */
|
|
|
|
+ warn_report("No -bios option specified. Not loading a firmware.");
|
|
|
|
+ warn_report("This default will change in QEMU 4.3. Please use the " \
|
|
|
|
+ "-bios option to aviod breakages when this happens.");
|
|
|
|
+ warn_report("See QEMU's deprecation documentation for details");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!strcmp(machine->firmware, "default")) {
|
|
|
|
+ /*
|
|
|
|
+ * The user has specified "-bios default". That means we are going to
|
|
|
|
+ * load the OpenSBI binary included in the QEMU source.
|
|
|
|
+ *
|
|
|
|
+ * We can't load the binary by default as it will break existing users
|
|
|
|
+ * as users are already loading their own firmware.
|
|
|
|
+ *
|
|
|
|
+ * Let's try to get everyone to specify the -bios option at all times,
|
|
|
|
+ * so then in the future we can make "-bios default" the default option
|
|
|
|
+ * if no -bios option is set without breaking anything.
|
|
|
|
+ */
|
|
|
|
+ firmware_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS,
|
|
|
|
+ default_machine_firmware);
|
|
|
|
+ if (firmware_filename == NULL) {
|
|
|
|
+ error_report("Unable to load the default RISC-V firmware \"%s\"",
|
|
|
|
+ default_machine_firmware);
|
|
|
|
+ exit(1);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ firmware_filename = machine->firmware;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (strcmp(firmware_filename, "none")) {
|
|
|
|
+ /* If not "none" load the firmware */
|
|
|
|
+ riscv_load_firmware(firmware_filename, firmware_load_addr);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!strcmp(machine->firmware, "default")) {
|
|
|
|
+ g_free(firmware_filename);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
target_ulong riscv_load_firmware(const char *firmware_filename,
|
|
target_ulong riscv_load_firmware(const char *firmware_filename,
|
|
hwaddr firmware_load_addr)
|
|
hwaddr firmware_load_addr)
|
|
{
|
|
{
|