mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 10:22:45 +00:00 
			
		
		
		
	 7e94b090fe
			
		
	
	
		7e94b090fe
		
	
	
	
	
		
			
			This implements a simple bootloader that is capable of loading ELF64 kernel images. It does this by using QEMU/GRUB to load the kernel image from disk and pass it to our bootloader as a Multiboot module. The bootloader then parses the ELF image and sets it up appropriately. The kernel's entry point is a C++ function with architecture-native code. Co-authored-by: Liav A <liavalb@gmail.com>
		
			
				
	
	
		
			28 lines
		
	
	
	
		
			874 B
		
	
	
	
		
			CMake
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
	
		
			874 B
		
	
	
	
		
			CMake
		
	
	
	
	
	
| set(SOURCES
 | |
|     boot.S
 | |
|     multiboot.S
 | |
|     init.cpp
 | |
|     UBSanitizer.cpp
 | |
|     ../MiniStdLib.cpp
 | |
| )
 | |
| 
 | |
| if ("${SERENITY_ARCH}" STREQUAL "i686")
 | |
|     set(PREKERNEL_TARGET Prekernel32)
 | |
| else()
 | |
|     set(PREKERNEL_TARGET Prekernel64)
 | |
| endif()
 | |
| 
 | |
| add_executable(${PREKERNEL_TARGET} ${SOURCES})
 | |
| 
 | |
| target_link_options(${PREKERNEL_TARGET} PRIVATE LINKER:-T ${CMAKE_CURRENT_SOURCE_DIR}/linker.ld -nostdlib)
 | |
| set_target_properties(${PREKERNEL_TARGET} PROPERTIES LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/linker.ld)
 | |
| 
 | |
| target_link_libraries(${PREKERNEL_TARGET} gcc supc++)
 | |
| 
 | |
| add_custom_command(
 | |
|     TARGET ${PREKERNEL_TARGET} POST_BUILD
 | |
|     COMMAND ${TOOLCHAIN_PREFIX}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)
 |