2022-12-04 11:47:08 +00:00
|
|
|
# The Moon kernel for Luna.
|
|
|
|
|
2023-01-23 19:07:17 +00:00
|
|
|
file(GLOB_RECURSE HEADERS src/*.h)
|
|
|
|
|
2022-11-13 09:09:09 +00:00
|
|
|
set(SOURCES
|
2023-01-23 19:07:17 +00:00
|
|
|
${HEADERS}
|
2022-11-13 09:09:09 +00:00
|
|
|
src/main.cpp
|
2022-11-30 12:29:28 +00:00
|
|
|
src/Log.cpp
|
2023-01-13 17:56:05 +00:00
|
|
|
src/cxxabi.cpp
|
2022-11-19 16:59:39 +00:00
|
|
|
src/video/Framebuffer.cpp
|
2022-11-20 16:55:22 +00:00
|
|
|
src/video/TextConsole.cpp
|
2022-11-19 16:59:39 +00:00
|
|
|
src/memory/MemoryManager.cpp
|
2022-11-20 14:15:26 +00:00
|
|
|
src/memory/Heap.cpp
|
2022-12-05 19:36:24 +00:00
|
|
|
src/memory/KernelVM.cpp
|
2023-01-13 18:05:20 +00:00
|
|
|
src/memory/UserVM.cpp
|
2022-12-04 14:45:13 +00:00
|
|
|
src/memory/MemoryMap.cpp
|
2022-11-19 16:59:39 +00:00
|
|
|
src/boot/Init.cpp
|
2022-11-13 09:30:10 +00:00
|
|
|
src/arch/Serial.cpp
|
2022-11-19 19:01:01 +00:00
|
|
|
src/arch/Timer.cpp
|
2023-01-23 19:07:17 +00:00
|
|
|
src/arch/PCI.cpp
|
2022-12-07 14:03:34 +00:00
|
|
|
src/thread/Thread.cpp
|
|
|
|
src/thread/Scheduler.cpp
|
2023-01-05 21:39:56 +00:00
|
|
|
src/sys/Syscall.cpp
|
|
|
|
src/sys/exit.cpp
|
2023-01-07 00:49:26 +00:00
|
|
|
src/sys/console_write.cpp
|
2023-01-06 23:21:08 +00:00
|
|
|
src/sys/clock_gettime.cpp
|
2023-01-11 22:01:47 +00:00
|
|
|
src/sys/allocate_memory.cpp
|
2023-01-22 14:00:20 +00:00
|
|
|
src/sys/usleep.cpp
|
2023-03-11 16:45:20 +00:00
|
|
|
src/sys/open.cpp
|
2023-03-11 17:02:50 +00:00
|
|
|
src/sys/file.cpp
|
2023-03-11 21:19:58 +00:00
|
|
|
src/sys/id.cpp
|
2023-02-03 21:18:52 +00:00
|
|
|
src/fs/VFS.cpp
|
|
|
|
src/fs/tmpfs/FileSystem.cpp
|
2022-12-23 10:33:23 +00:00
|
|
|
src/InitRD.cpp
|
2022-12-23 12:09:21 +00:00
|
|
|
src/ELF.cpp
|
2022-11-13 09:30:10 +00:00
|
|
|
)
|
|
|
|
|
2023-01-21 21:44:16 +00:00
|
|
|
if("${LUNA_ARCH}" MATCHES "x86_64")
|
2022-11-19 17:00:45 +00:00
|
|
|
set(SOURCES
|
|
|
|
${SOURCES}
|
|
|
|
src/arch/x86_64/IO.cpp
|
|
|
|
src/arch/x86_64/Serial.cpp
|
|
|
|
src/arch/x86_64/MMU.cpp
|
|
|
|
src/arch/x86_64/CPU.cpp
|
2022-11-19 19:01:01 +00:00
|
|
|
src/arch/x86_64/Timer.cpp
|
2022-12-07 14:03:34 +00:00
|
|
|
src/arch/x86_64/Thread.cpp
|
2023-01-23 19:07:17 +00:00
|
|
|
src/arch/x86_64/PCI.cpp
|
2022-12-17 14:45:06 +00:00
|
|
|
src/arch/x86_64/init/GDT.cpp
|
|
|
|
src/arch/x86_64/init/IDT.cpp
|
|
|
|
src/arch/x86_64/init/PIC.cpp
|
2022-11-19 17:00:45 +00:00
|
|
|
)
|
2022-11-19 16:46:53 +00:00
|
|
|
endif()
|
2022-11-13 09:09:09 +00:00
|
|
|
|
2022-11-15 18:10:32 +00:00
|
|
|
add_executable(moon ${SOURCES})
|
2022-11-13 09:09:09 +00:00
|
|
|
|
2023-01-21 21:44:16 +00:00
|
|
|
if("${LUNA_ARCH}" MATCHES "x86_64")
|
2022-11-19 16:59:39 +00:00
|
|
|
set(ASM_SOURCES
|
|
|
|
src/arch/x86_64/CPU.asm
|
2022-11-19 17:38:32 +00:00
|
|
|
src/arch/x86_64/Entry.asm
|
2022-11-19 16:59:39 +00:00
|
|
|
)
|
|
|
|
add_library(moon-asm STATIC ${ASM_SOURCES})
|
|
|
|
target_link_libraries(moon moon-asm)
|
2022-11-19 16:46:53 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
target_link_libraries(moon luna-freestanding)
|
2022-11-13 09:09:09 +00:00
|
|
|
|
2022-11-15 18:36:50 +00:00
|
|
|
target_compile_definitions(moon PRIVATE IN_MOON)
|
|
|
|
|
2022-11-15 18:10:32 +00:00
|
|
|
target_compile_options(moon PRIVATE -Os)
|
2022-11-13 09:09:09 +00:00
|
|
|
|
2022-12-08 14:09:32 +00:00
|
|
|
target_compile_options(moon PRIVATE -Wall -Wextra -Werror -Wvla -Wsign-conversion)
|
2022-11-15 18:10:32 +00:00
|
|
|
target_compile_options(moon PRIVATE -Wdisabled-optimization -Wformat=2 -Winit-self)
|
|
|
|
target_compile_options(moon PRIVATE -Wmissing-include-dirs -Wswitch-default -Wcast-qual -Wundef)
|
|
|
|
target_compile_options(moon PRIVATE -Wcast-align -Wwrite-strings -Wlogical-op -Wredundant-decls -Wshadow -Wconversion)
|
|
|
|
target_compile_options(moon PRIVATE -fno-rtti -ffreestanding -fno-exceptions)
|
|
|
|
target_compile_options(moon PRIVATE -fno-asynchronous-unwind-tables -fno-omit-frame-pointer)
|
|
|
|
target_compile_options(moon PRIVATE -nostdlib -mcmodel=kernel)
|
|
|
|
|
2023-01-21 21:44:16 +00:00
|
|
|
if("${LUNA_ARCH}" MATCHES "x86_64")
|
2022-11-19 16:59:39 +00:00
|
|
|
target_compile_options(moon PRIVATE -mno-red-zone)
|
|
|
|
target_compile_options(moon PRIVATE -mno-80387 -mno-mmx -mno-sse -mno-sse2)
|
|
|
|
target_link_options(moon PRIVATE -mno-red-zone)
|
2022-11-19 16:46:53 +00:00
|
|
|
endif()
|
2022-11-15 18:10:32 +00:00
|
|
|
|
2022-12-04 09:27:25 +00:00
|
|
|
if(MOON_DEBUG_SYMBOLS)
|
|
|
|
message(STATUS "Building Moon with debug symbols")
|
|
|
|
target_compile_options(moon PRIVATE -ggdb)
|
2023-01-09 16:59:52 +00:00
|
|
|
include(debug.cmake)
|
2022-12-04 09:27:25 +00:00
|
|
|
endif()
|
|
|
|
|
2022-11-15 18:10:32 +00:00
|
|
|
target_link_options(moon PRIVATE -lgcc -Wl,--build-id=none -z max-page-size=0x1000 -mcmodel=kernel)
|
|
|
|
|
2022-11-13 10:25:15 +00:00
|
|
|
set_target_properties(moon PROPERTIES CXX_STANDARD 20)
|
|
|
|
|
2022-11-13 09:30:10 +00:00
|
|
|
target_include_directories(moon PRIVATE ${CMAKE_CURRENT_LIST_DIR}/src)
|
2023-01-06 23:21:08 +00:00
|
|
|
target_include_directories(moon PRIVATE ${LUNA_BASE}/usr/include)
|
2022-11-13 09:09:09 +00:00
|
|
|
|
2022-12-03 16:25:25 +00:00
|
|
|
configure_file(src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/gen/config.h @ONLY)
|
|
|
|
|
|
|
|
target_include_directories(moon PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/gen)
|
|
|
|
|
2022-11-13 09:09:09 +00:00
|
|
|
target_link_options(moon PRIVATE LINKER:-T ${CMAKE_CURRENT_LIST_DIR}/moon.ld -nostdlib -nodefaultlibs)
|
|
|
|
|
2023-01-05 21:39:56 +00:00
|
|
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/moon" DESTINATION ${LUNA_ROOT}/initrd/boot)
|