1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 09:17:35 +00:00

Kernel: Move aarch64 Prekernel into Kernel

As there is no need for a Prekernel on aarch64, the Prekernel code was
moved into Kernel itself. The functionality remains the same.

SERENITY_KERNEL_AND_INITRD in run.sh specifies a kernel and an inital
ramdisk to be used by the emulator. This is needed because aarch64
does not need a Prekernel and the other ones do.
This commit is contained in:
Jakub V. Flasar 2022-03-08 18:21:40 +01:00 committed by Brian Gianforcaro
parent f94293f121
commit 6d2c298b66
37 changed files with 126 additions and 133 deletions

View file

@ -1,49 +1,19 @@
set(SOURCES
UBSanitizer.cpp
../MiniStdLib.cpp
)
if ("${SERENITY_ARCH}" STREQUAL "aarch64")
set(SOURCES
${SOURCES}
Arch/aarch64/BootPPMParser.cpp
Arch/aarch64/GPIO.cpp
Arch/aarch64/Framebuffer.cpp
Arch/aarch64/Mailbox.cpp
Arch/aarch64/MainIdRegister.cpp
Arch/aarch64/MMIO.cpp
Arch/aarch64/Timer.cpp
Arch/aarch64/UART.cpp
Arch/aarch64/Utils.cpp
# Preload specific
Arch/aarch64/init.cpp
Arch/aarch64/PrekernelMMU.cpp
Arch/aarch64/PrekernelExceptions.cpp
Arch/aarch64/PrekernelCommon.cpp
# Assembly
Arch/aarch64/boot.S
Arch/aarch64/Aarch64_asm_utils.S
Arch/aarch64/vector_table.S
boot.S
multiboot.S
init.cpp
../../Userland/Libraries/LibELF/Relocation.cpp
)
else()
set(SOURCES
${SOURCES}
Arch/x86/boot.S
Arch/x86/multiboot.S
# FIXME: Eventually, some of these should build on aarch64 too.
init.cpp
../../Userland/Libraries/LibELF/Relocation.cpp
)
endif()
if ("${SERENITY_ARCH}" STREQUAL "i686")
set(PREKERNEL_TARGET Prekernel32)
elseif ("${SERENITY_ARCH}" STREQUAL "x86_64")
set(PREKERNEL_TARGET Prekernel64)
else()
set(PREKERNEL_TARGET Prekernel)
elseif("${SERENITY_ARCH}" STREQUAL "aarch64")
message(SEND_ERROR "Prekernel is not needed on aarch64 and should not be compiled!")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
@ -51,13 +21,8 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
add_executable(${PREKERNEL_TARGET} ${SOURCES})
target_compile_options(${PREKERNEL_TARGET} PRIVATE -no-pie -fno-pic -fno-threadsafe-statics)
if ("${SERENITY_ARCH}" STREQUAL "aarch64")
set(PREKERNEL_LINKER_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/Arch/aarch64/linker.ld")
else()
set(PREKERNEL_LINKER_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/linker.ld")
endif()
target_link_options(${PREKERNEL_TARGET} PRIVATE LINKER:-T ${PREKERNEL_LINKER_SCRIPT} -nostdlib LINKER:--no-pie)
set_target_properties(${PREKERNEL_TARGET} PROPERTIES LINK_DEPENDS ${PREKERNEL_LINKER_SCRIPT})
target_link_options(${PREKERNEL_TARGET} PRIVATE LINKER:-T ${CMAKE_CURRENT_SOURCE_DIR}/linker.ld -nostdlib LINKER:--no-pie)
set_target_properties(${PREKERNEL_TARGET} PROPERTIES LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/linker.ld)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_link_libraries(${PREKERNEL_TARGET} PRIVATE gcc)
@ -65,23 +30,11 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang$")
target_link_libraries(${PREKERNEL_TARGET} PRIVATE clang_rt.builtins)
endif()
if ("${SERENITY_ARCH}" STREQUAL "i686" OR "${SERENITY_ARCH}" STREQUAL "x86_64")
add_custom_command(
TARGET ${PREKERNEL_TARGET} POST_BUILD
COMMAND ${CMAKE_OBJCOPY} -O elf32-i386 ${CMAKE_CURRENT_BINARY_DIR}/${PREKERNEL_TARGET} ${CMAKE_CURRENT_BINARY_DIR}/Prekernel
BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/Prekernel
)
endif()
if ("${SERENITY_ARCH}" STREQUAL "aarch64")
embed_resource(Prekernel serenity_boot_logo "Arch/aarch64/SerenityLogoRGB.ppm")
add_custom_command(
TARGET Prekernel POST_BUILD
COMMAND ${CMAKE_OBJCOPY} -O binary Prekernel kernel8.img
BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/kernel8.img
)
endif()
add_custom_command(
TARGET ${PREKERNEL_TARGET} POST_BUILD
COMMAND ${CMAKE_OBJCOPY} -O elf32-i386 ${CMAKE_CURRENT_BINARY_DIR}/${PREKERNEL_TARGET} ${CMAKE_CURRENT_BINARY_DIR}/Prekernel
BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/Prekernel
)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/Prekernel" DESTINATION boot)