mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 17:47:36 +00:00
Kernel/x86: Bake the Prekernel and the Kernel into one image
The new baked image is a Prekernel and a Kernel baked together now, so essentially we no longer need to pass the Prekernel as -kernel and the actual kernel image as -initrd to QEMU, leaving the option to pass an actual initrd or initramfs module later on with multiboot.
This commit is contained in:
parent
2a1e58f8cc
commit
897c4e5145
10 changed files with 81 additions and 50 deletions
|
@ -8,14 +8,21 @@ set(SOURCES
|
|||
)
|
||||
|
||||
if ("${SERENITY_ARCH}" STREQUAL "x86_64")
|
||||
set(PREKERNEL_TARGET Prekernel64)
|
||||
set(PREKERNEL_TARGET kernel_x86-64)
|
||||
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")
|
||||
|
||||
add_executable(${PREKERNEL_TARGET} ${SOURCES})
|
||||
add_library(KernelObject OBJECT IMPORTED)
|
||||
|
||||
set_property(TARGET KernelObject PROPERTY
|
||||
IMPORTED_OBJECTS ${CMAKE_CURRENT_BINARY_DIR}/../Kernel.o
|
||||
)
|
||||
|
||||
add_executable(${PREKERNEL_TARGET} ${SOURCES} $<TARGET_OBJECTS:KernelObject>)
|
||||
add_dependencies(${PREKERNEL_TARGET} Kernel)
|
||||
target_compile_options(${PREKERNEL_TARGET} PRIVATE -no-pie -fno-pic -fno-threadsafe-statics)
|
||||
|
||||
target_link_options(${PREKERNEL_TARGET} PRIVATE LINKER:-T ${CMAKE_CURRENT_SOURCE_DIR}/linker.ld -nostdlib LINKER:--no-pie)
|
||||
|
@ -27,13 +34,20 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang$")
|
|||
target_link_libraries(${PREKERNEL_TARGET} PRIVATE clang_rt.builtins)
|
||||
endif()
|
||||
|
||||
if ("${SERENITY_ARCH}" STREQUAL "x86_64")
|
||||
set(ELF_OBJCOPY_TARGET "elf32-i386")
|
||||
elseif("${SERENITY_ARCH}" STREQUAL "aarch64")
|
||||
message(SEND_ERROR "Prekernel is not needed on aarch64 and should not be compiled!")
|
||||
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
|
||||
COMMAND ${CMAKE_OBJCOPY} -O ${ELF_OBJCOPY_TARGET} ${CMAKE_CURRENT_BINARY_DIR}/${PREKERNEL_TARGET} ${CMAKE_CURRENT_BINARY_DIR}/../Kernel
|
||||
BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/Prekernel
|
||||
)
|
||||
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/Prekernel" DESTINATION boot)
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/../Kernel" DESTINATION boot)
|
||||
|
||||
# Remove options which the Prekernel environment doesn't support.
|
||||
get_target_property(PREKERNEL_TARGET_OPTIONS ${PREKERNEL_TARGET} COMPILE_OPTIONS)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue