From 185715d83256b94ead6879f14fbbbb302025b6ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Holz?= Date: Sat, 11 Nov 2023 13:55:22 +0100 Subject: [PATCH] Kernel/riscv64: Generate Kernel.bin from kernel ELF This is necessary for being able to use the qemu `-kernel` option. The QEMU virt machine uses OpenSBI's FW_DYNAMIC feature to pass the kernel entry address, which is the virtual entry point address specified in the kernel ELF. If we instead `objcopy` the kernel into a raw binary, OpenSBI will jump to the physical kernel load address, which is what we want it to do. --- Kernel/CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Kernel/CMakeLists.txt b/Kernel/CMakeLists.txt index cb97b258f0..677081aea0 100644 --- a/Kernel/CMakeLists.txt +++ b/Kernel/CMakeLists.txt @@ -806,6 +806,13 @@ if ("${SERENITY_ARCH}" STREQUAL "aarch64") COMMAND ${CMAKE_OBJCOPY} -O binary Kernel kernel8.img BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/kernel8.img ) +elseif ("${SERENITY_ARCH}" STREQUAL "riscv64") + add_custom_command( + TARGET Kernel POST_BUILD + COMMAND ${CMAKE_OBJCOPY} -O binary Kernel Kernel.bin + BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/Kernel.bin + ) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/Kernel.bin" DESTINATION boot) endif() serenity_install_headers(Kernel)