2023-05-17 20:20:53 -07:00
|
|
|
add_executable(zion
|
2023-05-18 01:16:53 -07:00
|
|
|
boot/boot_info.cpp
|
2023-06-06 16:24:03 -07:00
|
|
|
capability/capability.cpp
|
2023-05-17 21:41:08 -07:00
|
|
|
common/gdt.cpp
|
|
|
|
common/load_gdt.s
|
2023-05-17 20:42:59 -07:00
|
|
|
debug/debug.cpp
|
2023-05-17 22:54:37 -07:00
|
|
|
interrupt/interrupt.cpp
|
|
|
|
interrupt/interrupt_enter.s
|
2023-05-29 21:52:01 -07:00
|
|
|
interrupt/timer.cpp
|
2023-05-29 00:32:54 -07:00
|
|
|
loader/init_loader.cpp
|
2023-05-18 09:46:41 -07:00
|
|
|
memory/kernel_heap.cpp
|
2023-05-30 21:27:20 -07:00
|
|
|
memory/kernel_stack_manager.cpp
|
2023-05-18 01:18:51 -07:00
|
|
|
memory/paging_util.cpp
|
2023-05-18 11:00:05 -07:00
|
|
|
memory/physical_memory.cpp
|
2023-05-30 22:35:57 -07:00
|
|
|
memory/user_stack_manager.cpp
|
2023-06-06 21:44:10 -07:00
|
|
|
object/address_space.cpp
|
|
|
|
object/memory_object.cpp
|
2023-06-06 20:18:53 -07:00
|
|
|
object/process.cpp
|
|
|
|
object/thread.cpp
|
2023-05-18 13:24:02 -07:00
|
|
|
scheduler/context_switch.s
|
2023-05-29 12:44:26 -07:00
|
|
|
scheduler/jump_user_space.s
|
2023-05-29 23:35:44 -07:00
|
|
|
scheduler/process_manager.cpp
|
2023-05-18 12:43:53 -07:00
|
|
|
scheduler/scheduler.cpp
|
2023-05-18 16:03:09 -07:00
|
|
|
syscall/syscall.cpp
|
|
|
|
syscall/syscall_enter.s
|
2023-05-17 20:20:53 -07:00
|
|
|
zion.cpp)
|
|
|
|
|
2023-05-17 20:42:59 -07:00
|
|
|
target_include_directories(zion
|
|
|
|
PRIVATE
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
)
|
|
|
|
|
2023-05-17 21:41:08 -07:00
|
|
|
# -c -- Don't run the linker (only necessary for the assembler)
|
|
|
|
# -ffreestanding
|
2023-05-18 11:29:44 -07:00
|
|
|
# -fno-rtti -- No runtime type information (might mess with polymorphism?)
|
|
|
|
# -fno-exceptions -- Disable exceptions.
|
2023-05-17 20:20:53 -07:00
|
|
|
# -nostdlib -- Don't include the standard library.
|
|
|
|
# -mabi=sysv -- Explicitly specify the ABI since we will rely on it.
|
|
|
|
# -mno-red-zone -- Don't put data below the stack pointer (clobbered by interrupts).
|
|
|
|
# -mcmodel=kernel -- Assume the kernel code is running in the higher half.
|
|
|
|
# -mgeneral-regs-only -- Prevent GCC from using a whole host of nonsense registers (that we have to enable).
|
2023-05-18 11:29:44 -07:00
|
|
|
set(_Z_COMPILE_FLAGS "${CMAKE_CXX_FLAGS} -c -ffreestanding -fno-rtti -fno-exceptions -nostdlib -mabi=sysv -mno-red-zone -mcmodel=kernel -mgeneral-regs-only")
|
2023-05-17 20:20:53 -07:00
|
|
|
|
|
|
|
set(_Z_LINK_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/linker.ld")
|
|
|
|
|
|
|
|
# -lgcc -- Link against gcc internals. Not sure if necessary.
|
|
|
|
# -nostdlib -- Don't try to link against the stdlib.
|
|
|
|
# -nostartfiles -- Don't try to link against crt0.s
|
|
|
|
# -static -- Prevent trying something with shared libraries (probably irrelevant).
|
|
|
|
# -z max-page-size=0x1000 -- Assume 4 KiB Pages.
|
|
|
|
set(_Z_LINK_FLAGS "-T ${_Z_LINK_SCRIPT} -lgcc -nostdlib -nostartfiles -static -z max-page-size=0x1000")
|
|
|
|
|
|
|
|
|
|
|
|
# Don't try to dynamically link.
|
|
|
|
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
|
|
|
|
|
|
|
|
set_target_properties(zion
|
|
|
|
PROPERTIES
|
|
|
|
COMPILE_FLAGS "${_Z_COMPILE_FLAGS}"
|
|
|
|
LINK_FLAGS "${_Z_LINK_FLAGS}"
|
|
|
|
)
|
2023-05-29 00:32:54 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
add_library(zion_lib STATIC
|
|
|
|
usr/crt0.s
|
|
|
|
usr/zcall.cpp)
|
|
|
|
|
|
|
|
target_include_directories(zion_lib
|
|
|
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
|
|
|
|
|
|
|
set_target_properties(zion_lib
|
|
|
|
PROPERTIES
|
|
|
|
COMPILE_FLAGS "${_Z_COMPILE_FLAGS}")
|