2022-12-04 12:47:08 +01:00
|
|
|
# The Moon kernel for Luna.
|
|
|
|
|
2023-01-23 20:07:17 +01:00
|
|
|
file(GLOB_RECURSE HEADERS src/*.h)
|
|
|
|
|
2022-11-13 10:09:09 +01:00
|
|
|
set(SOURCES
|
2023-01-23 20:07:17 +01:00
|
|
|
${HEADERS}
|
2022-11-13 10:09:09 +01:00
|
|
|
src/main.cpp
|
2022-11-30 13:29:28 +01:00
|
|
|
src/Log.cpp
|
2023-08-12 21:38:25 +02:00
|
|
|
src/Pledge.cpp
|
2023-01-13 18:56:05 +01:00
|
|
|
src/cxxabi.cpp
|
2023-10-13 22:11:52 +02:00
|
|
|
src/Symbols.cpp
|
2022-11-19 17:59:39 +01:00
|
|
|
src/video/Framebuffer.cpp
|
2022-11-20 17:55:22 +01:00
|
|
|
src/video/TextConsole.cpp
|
2022-11-19 17:59:39 +01:00
|
|
|
src/memory/MemoryManager.cpp
|
2022-11-20 15:15:26 +01:00
|
|
|
src/memory/Heap.cpp
|
2022-12-05 20:36:24 +01:00
|
|
|
src/memory/KernelVM.cpp
|
2023-07-09 20:38:04 +02:00
|
|
|
src/memory/AddressSpace.cpp
|
2022-12-04 15:45:13 +01:00
|
|
|
src/memory/MemoryMap.cpp
|
2023-08-02 22:18:36 +02:00
|
|
|
src/memory/SharedMemory.cpp
|
2022-11-19 17:59:39 +01:00
|
|
|
src/boot/Init.cpp
|
2022-11-13 10:30:10 +01:00
|
|
|
src/arch/Serial.cpp
|
2023-01-23 20:07:17 +01:00
|
|
|
src/arch/PCI.cpp
|
2023-09-20 07:05:33 +02:00
|
|
|
src/lib/Mutex.cpp
|
2022-12-07 15:03:34 +01:00
|
|
|
src/thread/Thread.cpp
|
2023-03-16 22:44:58 +01:00
|
|
|
src/thread/ThreadImage.cpp
|
2022-12-07 15:03:34 +01:00
|
|
|
src/thread/Scheduler.cpp
|
2023-11-15 23:50:04 +01:00
|
|
|
src/thread/Clock.cpp
|
2023-01-05 22:39:56 +01:00
|
|
|
src/sys/Syscall.cpp
|
|
|
|
src/sys/exit.cpp
|
2023-01-07 00:21:08 +01:00
|
|
|
src/sys/clock_gettime.cpp
|
2023-03-14 20:43:15 +01:00
|
|
|
src/sys/mmap.cpp
|
2023-01-22 15:00:20 +01:00
|
|
|
src/sys/usleep.cpp
|
2023-03-11 17:45:20 +01:00
|
|
|
src/sys/open.cpp
|
2023-03-16 22:44:58 +01:00
|
|
|
src/sys/exec.cpp
|
2023-03-11 18:02:50 +01:00
|
|
|
src/sys/file.cpp
|
2023-03-11 22:19:58 +01:00
|
|
|
src/sys/id.cpp
|
2023-03-12 15:32:09 +01:00
|
|
|
src/sys/mkdir.cpp
|
2023-05-18 21:48:47 +02:00
|
|
|
src/sys/pstat.cpp
|
2023-03-23 22:42:24 +01:00
|
|
|
src/sys/waitpid.cpp
|
2023-03-28 21:28:56 +02:00
|
|
|
src/sys/getdents.cpp
|
2023-04-10 19:56:03 +02:00
|
|
|
src/sys/stat.cpp
|
2023-04-11 22:15:21 +02:00
|
|
|
src/sys/chdir.cpp
|
2023-04-12 18:11:36 +02:00
|
|
|
src/sys/link.cpp
|
2023-04-24 20:34:44 +02:00
|
|
|
src/sys/uname.cpp
|
2023-05-17 20:30:15 +02:00
|
|
|
src/sys/mount.cpp
|
2023-05-20 12:48:07 +02:00
|
|
|
src/sys/resource.cpp
|
2023-07-10 19:46:57 +02:00
|
|
|
src/sys/signal.cpp
|
2023-07-27 16:37:10 +02:00
|
|
|
src/sys/socket.cpp
|
2023-08-02 14:48:20 +02:00
|
|
|
src/sys/poll.cpp
|
2023-11-16 21:48:18 +01:00
|
|
|
src/sys/setitimer.cpp
|
2023-08-12 21:38:25 +02:00
|
|
|
src/sys/pledge.cpp
|
2023-08-17 20:15:32 +02:00
|
|
|
src/sys/memstat.cpp
|
2023-02-03 22:18:52 +01:00
|
|
|
src/fs/VFS.cpp
|
2023-05-10 22:48:31 +02:00
|
|
|
src/fs/Pipe.cpp
|
2023-05-17 19:40:37 +02:00
|
|
|
src/fs/Mount.cpp
|
2023-05-26 23:28:51 +02:00
|
|
|
src/fs/MBR.cpp
|
2023-06-17 12:03:37 +02:00
|
|
|
src/fs/GPT.cpp
|
2023-08-16 14:54:13 +02:00
|
|
|
src/fs/StorageCache.cpp
|
2023-10-23 20:13:11 +02:00
|
|
|
src/fs/OpenFileDescription.cpp
|
2023-10-23 22:47:49 +02:00
|
|
|
src/fs/FSRegistry.cpp
|
2023-07-27 16:37:10 +02:00
|
|
|
src/net/UnixSocket.cpp
|
2023-02-03 22:18:52 +01:00
|
|
|
src/fs/tmpfs/FileSystem.cpp
|
2023-06-18 11:33:40 +02:00
|
|
|
src/fs/tmpfs/Inode.cpp
|
2023-09-16 11:46:52 +02:00
|
|
|
src/fs/devpts/FileSystem.cpp
|
|
|
|
src/fs/devpts/Inode.cpp
|
2023-06-20 21:39:41 +02:00
|
|
|
src/fs/ext2/FileSystem.cpp
|
2023-06-21 21:32:28 +02:00
|
|
|
src/fs/ext2/Inode.cpp
|
2023-03-18 09:10:33 +01:00
|
|
|
src/fs/devices/DeviceRegistry.cpp
|
2023-08-16 14:54:13 +02:00
|
|
|
src/fs/devices/BlockDevice.cpp
|
2023-03-18 09:10:33 +01:00
|
|
|
src/fs/devices/NullDevice.cpp
|
2023-03-30 21:19:16 +02:00
|
|
|
src/fs/devices/ZeroDevice.cpp
|
2023-05-27 10:42:45 +02:00
|
|
|
src/fs/devices/FullDevice.cpp
|
2023-03-18 09:10:33 +01:00
|
|
|
src/fs/devices/ConsoleDevice.cpp
|
2023-04-21 18:18:15 +02:00
|
|
|
src/fs/devices/FramebufferDevice.cpp
|
2023-07-21 14:09:37 +02:00
|
|
|
src/fs/devices/UARTDevice.cpp
|
2023-08-02 11:55:45 +02:00
|
|
|
src/fs/devices/MouseDevice.cpp
|
2023-08-02 17:20:13 +02:00
|
|
|
src/fs/devices/KeyboardDevice.cpp
|
2023-09-16 11:46:52 +02:00
|
|
|
src/fs/devices/PTYMultiplexer.cpp
|
|
|
|
src/fs/devices/MasterPTY.cpp
|
|
|
|
src/fs/devices/SlavePTY.cpp
|
2023-10-14 19:00:10 +02:00
|
|
|
src/fs/devices/TTYLink.cpp
|
2023-04-28 15:55:06 +02:00
|
|
|
src/fs/InitRD.cpp
|
2023-07-30 18:25:44 +02:00
|
|
|
src/binfmt/ELF.cpp
|
|
|
|
src/binfmt/BinaryFormat.cpp
|
2023-07-30 18:46:19 +02:00
|
|
|
src/binfmt/Script.cpp
|
2022-11-13 10:30:10 +01:00
|
|
|
)
|
|
|
|
|
2023-01-21 22:44:16 +01:00
|
|
|
if("${LUNA_ARCH}" MATCHES "x86_64")
|
2022-11-19 18:00:45 +01: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
|
2023-11-15 23:50:04 +01:00
|
|
|
src/arch/x86_64/Clock.cpp
|
2022-12-07 15:03:34 +01:00
|
|
|
src/arch/x86_64/Thread.cpp
|
2023-01-23 20:07:17 +01:00
|
|
|
src/arch/x86_64/PCI.cpp
|
2023-03-19 11:17:43 +01:00
|
|
|
src/arch/x86_64/Keyboard.cpp
|
2023-05-10 19:15:47 +02:00
|
|
|
src/arch/x86_64/disk/ATA.cpp
|
2022-12-17 15:45:06 +01:00
|
|
|
src/arch/x86_64/init/GDT.cpp
|
|
|
|
src/arch/x86_64/init/IDT.cpp
|
|
|
|
src/arch/x86_64/init/PIC.cpp
|
2023-08-02 11:55:45 +02:00
|
|
|
src/arch/x86_64/PS2Mouse.cpp
|
2022-11-19 18:00:45 +01:00
|
|
|
)
|
2022-11-19 17:46:53 +01:00
|
|
|
endif()
|
2022-11-13 10:09:09 +01:00
|
|
|
|
2022-11-15 19:10:32 +01:00
|
|
|
add_executable(moon ${SOURCES})
|
2022-11-13 10:09:09 +01:00
|
|
|
|
2023-01-21 22:44:16 +01:00
|
|
|
if("${LUNA_ARCH}" MATCHES "x86_64")
|
2022-11-19 17:59:39 +01:00
|
|
|
set(ASM_SOURCES
|
|
|
|
src/arch/x86_64/CPU.asm
|
2022-11-19 18:38:32 +01:00
|
|
|
src/arch/x86_64/Entry.asm
|
2022-11-19 17:59:39 +01:00
|
|
|
)
|
|
|
|
add_library(moon-asm STATIC ${ASM_SOURCES})
|
|
|
|
target_link_libraries(moon moon-asm)
|
2022-11-19 17:46:53 +01:00
|
|
|
endif()
|
|
|
|
|
|
|
|
target_link_libraries(moon luna-freestanding)
|
2022-11-13 10:09:09 +01:00
|
|
|
|
2022-11-15 19:36:50 +01:00
|
|
|
target_compile_definitions(moon PRIVATE IN_MOON)
|
|
|
|
|
2023-04-07 12:02:49 +02:00
|
|
|
target_compile_options(moon PRIVATE ${COMMON_FLAGS})
|
2023-10-23 22:47:49 +02:00
|
|
|
target_compile_options(moon PRIVATE -nostdlib -mcmodel=kernel -ffreestanding -fno-threadsafe-statics)
|
2022-11-15 19:10:32 +01:00
|
|
|
|
2023-01-21 22:44:16 +01:00
|
|
|
if("${LUNA_ARCH}" MATCHES "x86_64")
|
2022-11-19 17:59:39 +01: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 17:46:53 +01:00
|
|
|
endif()
|
2022-11-15 19:10:32 +01:00
|
|
|
|
2023-04-07 12:07:08 +02:00
|
|
|
if(MOON_DEBUG)
|
2023-01-09 17:59:52 +01:00
|
|
|
include(debug.cmake)
|
2022-12-04 10:27:25 +01:00
|
|
|
endif()
|
|
|
|
|
2023-07-10 13:04:26 +02:00
|
|
|
if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/config.cmake)
|
|
|
|
message(STATUS "Using custom config.cmake file")
|
2023-06-18 20:18:19 +02:00
|
|
|
include(config.cmake)
|
|
|
|
endif()
|
|
|
|
|
2023-07-21 14:09:37 +02:00
|
|
|
if(BUILD_TESTS)
|
|
|
|
target_compile_definitions(moon PRIVATE MOON_ENABLE_TESTING_FEATURES)
|
|
|
|
endif()
|
|
|
|
|
2022-11-15 19:10:32 +01:00
|
|
|
target_link_options(moon PRIVATE -lgcc -Wl,--build-id=none -z max-page-size=0x1000 -mcmodel=kernel)
|
|
|
|
|
2022-11-13 11:25:15 +01:00
|
|
|
set_target_properties(moon PROPERTIES CXX_STANDARD 20)
|
|
|
|
|
2022-11-13 10:30:10 +01:00
|
|
|
target_include_directories(moon PRIVATE ${CMAKE_CURRENT_LIST_DIR}/src)
|
2023-01-07 00:21:08 +01:00
|
|
|
target_include_directories(moon PRIVATE ${LUNA_BASE}/usr/include)
|
2022-11-13 10:09:09 +01:00
|
|
|
|
2022-12-03 17:25:25 +01: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 10:09:09 +01:00
|
|
|
target_link_options(moon PRIVATE LINKER:-T ${CMAKE_CURRENT_LIST_DIR}/moon.ld -nostdlib -nodefaultlibs)
|
|
|
|
|
2023-10-13 22:11:52 +02:00
|
|
|
add_custom_command(TARGET moon POST_BUILD COMMAND ${LUNA_ROOT}/tools/generate-symbols.sh)
|
|
|
|
|
2023-01-05 22:39:56 +01:00
|
|
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/moon" DESTINATION ${LUNA_ROOT}/initrd/boot)
|