2023-04-02 04:07:27 +03:00
|
|
|
set(KERNEL_SOURCES
|
|
|
|
font/prefs.psf.o
|
2024-04-04 14:14:28 +03:00
|
|
|
kernel/ACPI/ACPI.cpp
|
2024-04-07 02:54:02 +03:00
|
|
|
kernel/ACPI/AML.cpp
|
2024-04-09 01:16:07 +03:00
|
|
|
kernel/ACPI/AML/Field.cpp
|
|
|
|
kernel/ACPI/AML/NamedObject.cpp
|
|
|
|
kernel/ACPI/AML/Namespace.cpp
|
|
|
|
kernel/ACPI/AML/Node.cpp
|
2024-04-19 11:26:48 +03:00
|
|
|
kernel/ACPI/AML/Package.cpp
|
2024-04-09 01:16:07 +03:00
|
|
|
kernel/ACPI/AML/Scope.cpp
|
2023-04-02 04:07:27 +03:00
|
|
|
kernel/APIC.cpp
|
2023-11-17 18:54:59 +02:00
|
|
|
kernel/BootInfo.cpp
|
2023-04-02 04:07:27 +03:00
|
|
|
kernel/CPUID.cpp
|
2024-01-02 23:19:58 +02:00
|
|
|
kernel/Credentials.cpp
|
2023-04-02 04:07:27 +03:00
|
|
|
kernel/Debug.cpp
|
2024-02-05 01:24:09 +02:00
|
|
|
kernel/Device/DebugDevice.cpp
|
2023-07-19 23:50:57 +03:00
|
|
|
kernel/Device/Device.cpp
|
2023-11-22 20:34:00 +02:00
|
|
|
kernel/Device/FramebufferDevice.cpp
|
2023-07-20 00:06:22 +03:00
|
|
|
kernel/Device/NullDevice.cpp
|
2023-09-09 22:46:15 +03:00
|
|
|
kernel/Device/ZeroDevice.cpp
|
2023-04-11 23:25:21 +03:00
|
|
|
kernel/Errors.cpp
|
2023-07-10 23:17:14 +03:00
|
|
|
kernel/FS/DevFS/FileSystem.cpp
|
2023-09-01 15:10:23 +03:00
|
|
|
kernel/FS/Ext2/FileSystem.cpp
|
|
|
|
kernel/FS/Ext2/Inode.cpp
|
2024-06-14 01:02:28 +03:00
|
|
|
kernel/FS/FAT/FileSystem.cpp
|
|
|
|
kernel/FS/FAT/Inode.cpp
|
2024-06-11 10:50:26 +03:00
|
|
|
kernel/FS/FileSystem.cpp
|
2023-06-11 19:52:13 +03:00
|
|
|
kernel/FS/Inode.cpp
|
2023-07-06 22:16:26 +03:00
|
|
|
kernel/FS/Pipe.cpp
|
2023-09-30 21:19:36 +03:00
|
|
|
kernel/FS/ProcFS/FileSystem.cpp
|
|
|
|
kernel/FS/ProcFS/Inode.cpp
|
2023-11-04 18:13:52 +02:00
|
|
|
kernel/FS/TmpFS/FileSystem.cpp
|
|
|
|
kernel/FS/TmpFS/Inode.cpp
|
2023-04-02 04:07:27 +03:00
|
|
|
kernel/FS/VirtualFileSystem.cpp
|
2024-03-26 13:59:09 +02:00
|
|
|
kernel/GDT.cpp
|
|
|
|
kernel/IDT.cpp
|
2024-07-12 20:45:15 +03:00
|
|
|
kernel/Input/InputDevice.cpp
|
2024-01-04 11:00:10 +02:00
|
|
|
kernel/Input/PS2/Controller.cpp
|
|
|
|
kernel/Input/PS2/Device.cpp
|
|
|
|
kernel/Input/PS2/Keyboard.cpp
|
|
|
|
kernel/Input/PS2/Keymap.cpp
|
2024-01-04 12:09:49 +02:00
|
|
|
kernel/Input/PS2/Mouse.cpp
|
2024-03-06 00:46:20 +02:00
|
|
|
kernel/Interruptable.cpp
|
2023-04-02 04:07:27 +03:00
|
|
|
kernel/InterruptController.cpp
|
|
|
|
kernel/kernel.cpp
|
2023-10-08 02:56:01 +03:00
|
|
|
kernel/Memory/DMARegion.cpp
|
2023-09-29 17:23:42 +03:00
|
|
|
kernel/Memory/FileBackedRegion.cpp
|
2023-04-14 15:16:38 +03:00
|
|
|
kernel/Memory/Heap.cpp
|
2023-04-14 13:30:21 +03:00
|
|
|
kernel/Memory/kmalloc.cpp
|
2023-09-29 16:18:23 +03:00
|
|
|
kernel/Memory/MemoryBackedRegion.cpp
|
|
|
|
kernel/Memory/MemoryRegion.cpp
|
2023-05-28 16:21:45 +03:00
|
|
|
kernel/Memory/PhysicalRange.cpp
|
2024-05-29 15:58:46 +03:00
|
|
|
kernel/Memory/SharedMemoryObject.cpp
|
2023-05-28 16:21:45 +03:00
|
|
|
kernel/Memory/VirtualRange.cpp
|
2024-02-03 01:26:06 +02:00
|
|
|
kernel/Networking/ARPTable.cpp
|
2024-02-01 22:08:59 +02:00
|
|
|
kernel/Networking/E1000/E1000.cpp
|
|
|
|
kernel/Networking/E1000/E1000E.cpp
|
2024-02-06 12:30:01 +02:00
|
|
|
kernel/Networking/IPv4Layer.cpp
|
2024-02-01 22:08:59 +02:00
|
|
|
kernel/Networking/NetworkInterface.cpp
|
2024-06-18 20:32:43 +03:00
|
|
|
kernel/Networking/NetworkLayer.cpp
|
2024-02-01 23:38:06 +02:00
|
|
|
kernel/Networking/NetworkManager.cpp
|
|
|
|
kernel/Networking/NetworkSocket.cpp
|
2024-02-12 04:27:50 +02:00
|
|
|
kernel/Networking/TCPSocket.cpp
|
2024-02-01 23:38:06 +02:00
|
|
|
kernel/Networking/UDPSocket.cpp
|
2024-02-08 02:28:19 +02:00
|
|
|
kernel/Networking/UNIX/Socket.cpp
|
2023-07-07 23:11:37 +03:00
|
|
|
kernel/OpenFileDescriptorSet.cpp
|
2023-04-16 00:04:49 +03:00
|
|
|
kernel/Panic.cpp
|
2023-04-02 04:07:27 +03:00
|
|
|
kernel/PCI.cpp
|
|
|
|
kernel/PIC.cpp
|
|
|
|
kernel/Process.cpp
|
2024-03-03 22:30:06 +02:00
|
|
|
kernel/Processor.cpp
|
2024-02-12 04:25:06 +02:00
|
|
|
kernel/Random.cpp
|
2023-04-02 04:07:27 +03:00
|
|
|
kernel/Scheduler.cpp
|
2024-07-22 00:33:50 +03:00
|
|
|
kernel/ThreadBlocker.cpp
|
2023-04-02 04:07:27 +03:00
|
|
|
kernel/SSP.cpp
|
2023-10-12 21:53:48 +03:00
|
|
|
kernel/Storage/ATA/AHCI/Controller.cpp
|
|
|
|
kernel/Storage/ATA/AHCI/Device.cpp
|
2023-10-07 15:46:30 +03:00
|
|
|
kernel/Storage/ATA/ATABus.cpp
|
|
|
|
kernel/Storage/ATA/ATAController.cpp
|
|
|
|
kernel/Storage/ATA/ATADevice.cpp
|
2023-06-03 02:23:14 +03:00
|
|
|
kernel/Storage/DiskCache.cpp
|
2024-01-14 01:39:48 +02:00
|
|
|
kernel/Storage/NVMe/Controller.cpp
|
|
|
|
kernel/Storage/NVMe/Namespace.cpp
|
|
|
|
kernel/Storage/NVMe/Queue.cpp
|
2023-11-21 15:16:04 +02:00
|
|
|
kernel/Storage/Partition.cpp
|
2023-04-02 04:07:27 +03:00
|
|
|
kernel/Storage/StorageDevice.cpp
|
|
|
|
kernel/Syscall.cpp
|
2023-11-22 21:57:17 +02:00
|
|
|
kernel/Terminal/FramebufferTerminal.cpp
|
2023-09-04 19:34:18 +03:00
|
|
|
kernel/Terminal/Serial.cpp
|
2023-04-05 00:56:09 +03:00
|
|
|
kernel/Terminal/TTY.cpp
|
2023-09-04 19:34:18 +03:00
|
|
|
kernel/Terminal/VirtualTTY.cpp
|
2023-08-04 10:22:20 +03:00
|
|
|
kernel/Thread.cpp
|
2023-08-04 15:15:45 +03:00
|
|
|
kernel/Timer/HPET.cpp
|
2023-08-04 10:22:20 +03:00
|
|
|
kernel/Timer/PIT.cpp
|
2023-08-04 11:12:16 +03:00
|
|
|
kernel/Timer/RTC.cpp
|
2023-08-04 10:22:20 +03:00
|
|
|
kernel/Timer/Timer.cpp
|
2024-07-10 12:06:00 +03:00
|
|
|
kernel/USB/Device.cpp
|
2024-07-14 02:02:59 +03:00
|
|
|
kernel/USB/HID/HIDDriver.cpp
|
2024-07-14 02:09:18 +03:00
|
|
|
kernel/USB/HID/Keyboard.cpp
|
2024-07-14 02:11:32 +03:00
|
|
|
kernel/USB/HID/Mouse.cpp
|
2024-07-10 12:06:00 +03:00
|
|
|
kernel/USB/USBManager.cpp
|
|
|
|
kernel/USB/XHCI/Controller.cpp
|
|
|
|
kernel/USB/XHCI/Device.cpp
|
2023-04-02 04:07:27 +03:00
|
|
|
icxxabi.cpp
|
|
|
|
)
|
|
|
|
|
2024-06-19 04:20:23 +03:00
|
|
|
set(ENABLE_KERNEL_UBSAN False)
|
2023-04-12 00:18:06 +03:00
|
|
|
|
2023-04-02 04:07:27 +03:00
|
|
|
if(ENABLE_KERNEL_UBSAN)
|
|
|
|
set(KERNEL_SOURCES ${KERNEL_SOURCES} ubsan.cpp)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if("${BANAN_ARCH}" STREQUAL "x86_64")
|
|
|
|
set(KERNEL_SOURCES
|
|
|
|
${KERNEL_SOURCES}
|
|
|
|
arch/x86_64/boot.S
|
|
|
|
arch/x86_64/interrupts.S
|
2023-05-29 21:06:09 +03:00
|
|
|
arch/x86_64/PageTable.cpp
|
2023-07-21 15:45:02 +03:00
|
|
|
arch/x86_64/Signal.S
|
2024-03-22 12:48:54 +02:00
|
|
|
arch/x86_64/Syscall.S
|
2023-04-02 04:07:27 +03:00
|
|
|
arch/x86_64/Thread.S
|
|
|
|
)
|
2024-03-26 02:48:26 +02:00
|
|
|
elseif("${BANAN_ARCH}" STREQUAL "i686")
|
2023-04-02 04:07:27 +03:00
|
|
|
set(KERNEL_SOURCES
|
|
|
|
${KERNEL_SOURCES}
|
2024-03-26 02:48:26 +02:00
|
|
|
arch/i686/boot.S
|
2024-03-26 13:59:09 +02:00
|
|
|
arch/i686/interrupts.S
|
2024-03-26 02:48:26 +02:00
|
|
|
arch/i686/PageTable.cpp
|
|
|
|
arch/i686/Signal.S
|
|
|
|
arch/i686/Syscall.S
|
|
|
|
arch/i686/Thread.S
|
2023-04-02 04:07:27 +03:00
|
|
|
)
|
|
|
|
else()
|
2023-04-02 04:48:56 +03:00
|
|
|
message(FATAL_ERROR "unsupported architecure ${BANAN_ARCH}")
|
2023-04-02 04:07:27 +03:00
|
|
|
endif()
|
|
|
|
|
|
|
|
set(BAN_SOURCES
|
2024-03-04 11:41:54 +02:00
|
|
|
../BAN/BAN/Assert.cpp
|
2023-04-10 21:03:41 +03:00
|
|
|
../BAN/BAN/New.cpp
|
2023-04-02 04:07:27 +03:00
|
|
|
../BAN/BAN/StringView.cpp
|
|
|
|
../BAN/BAN/Time.cpp
|
|
|
|
)
|
|
|
|
|
2024-02-14 15:00:04 +02:00
|
|
|
set(KLIBC_SOURCES
|
|
|
|
klibc/ctype.cpp
|
|
|
|
klibc/string.cpp
|
2023-04-02 04:07:27 +03:00
|
|
|
)
|
|
|
|
|
2023-04-12 22:20:18 +03:00
|
|
|
set(LIBELF_SOURCES
|
2024-06-18 13:14:35 +03:00
|
|
|
../userspace/libraries/LibELF/LibELF/LoadableELF.cpp
|
2023-04-12 22:20:18 +03:00
|
|
|
)
|
|
|
|
|
2024-05-31 10:47:05 +03:00
|
|
|
set(LIBFONT_SOURCES
|
2024-06-18 13:14:35 +03:00
|
|
|
../userspace/libraries/LibFont/Font.cpp
|
|
|
|
../userspace/libraries/LibFont/PSF.cpp
|
2024-05-31 10:47:05 +03:00
|
|
|
)
|
|
|
|
|
2024-05-28 18:00:39 +03:00
|
|
|
set(LIBINPUT_SOURCE
|
2024-06-18 13:14:35 +03:00
|
|
|
../userspace/libraries/LibInput/KeyboardLayout.cpp
|
|
|
|
../userspace/libraries/LibInput/KeyEvent.cpp
|
2024-05-28 18:00:39 +03:00
|
|
|
)
|
|
|
|
|
2023-04-02 04:07:27 +03:00
|
|
|
set(KERNEL_SOURCES
|
|
|
|
${KERNEL_SOURCES}
|
|
|
|
${BAN_SOURCES}
|
2024-02-14 15:00:04 +02:00
|
|
|
${KLIBC_SOURCES}
|
2023-04-12 22:20:18 +03:00
|
|
|
${LIBELF_SOURCES}
|
2024-05-31 10:47:05 +03:00
|
|
|
${LIBFONT_SOURCES}
|
2024-05-28 18:00:39 +03:00
|
|
|
${LIBINPUT_SOURCE}
|
2023-04-02 04:07:27 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
add_executable(kernel ${KERNEL_SOURCES})
|
|
|
|
|
|
|
|
target_compile_definitions(kernel PUBLIC __is_kernel)
|
2023-04-02 04:48:56 +03:00
|
|
|
target_compile_definitions(kernel PUBLIC __arch=${BANAN_ARCH})
|
2023-04-02 04:07:27 +03:00
|
|
|
|
|
|
|
target_compile_options(kernel PUBLIC -O2 -g)
|
2023-09-18 21:48:37 +03:00
|
|
|
target_compile_options(kernel PUBLIC $<$<COMPILE_LANGUAGE:CXX>:-Wno-literal-suffix -fno-rtti -fno-exceptions>)
|
2023-04-28 14:43:19 +03:00
|
|
|
target_compile_options(kernel PUBLIC -fmacro-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}=.)
|
2024-07-10 12:06:00 +03:00
|
|
|
target_compile_options(kernel PUBLIC -fstack-protector -ffreestanding -fno-omit-frame-pointer -fstrict-volatile-bitfields -mgeneral-regs-only)
|
|
|
|
target_compile_options(kernel PUBLIC -Wall -Wextra -Werror -Wstack-usage=1024)
|
2023-04-02 04:07:27 +03:00
|
|
|
|
2023-10-30 17:51:18 +02:00
|
|
|
# This might not work with other toolchains
|
|
|
|
target_compile_options(kernel PUBLIC $<$<COMPILE_LANGUAGE:CXX>:-Wno-invalid-offsetof>)
|
|
|
|
|
2023-04-02 04:07:27 +03:00
|
|
|
if(ENABLE_KERNEL_UBSAN)
|
|
|
|
target_compile_options(kernel PUBLIC -fsanitize=undefined)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if("${BANAN_ARCH}" STREQUAL "x86_64")
|
2024-03-22 13:32:07 +02:00
|
|
|
target_compile_options(kernel PUBLIC -mcmodel=kernel -mno-red-zone)
|
2023-04-02 04:07:27 +03:00
|
|
|
target_link_options(kernel PUBLIC LINKER:-z,max-page-size=4096)
|
|
|
|
target_link_options(kernel PUBLIC LINKER:-T,${CMAKE_CURRENT_SOURCE_DIR}/arch/x86_64/linker.ld)
|
2024-03-26 02:48:26 +02:00
|
|
|
elseif("${BANAN_ARCH}" STREQUAL "i686")
|
|
|
|
target_link_options(kernel PUBLIC LINKER:-T,${CMAKE_CURRENT_SOURCE_DIR}/arch/i686/linker.ld)
|
2023-04-02 04:07:27 +03:00
|
|
|
endif()
|
|
|
|
|
2023-05-06 18:14:45 +03:00
|
|
|
target_link_options(kernel PUBLIC -ffreestanding -nostdlib)
|
2023-04-02 04:07:27 +03:00
|
|
|
|
|
|
|
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=crtbegin.o OUTPUT_VARIABLE CRTBEGIN OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=crtend.o OUTPUT_VARIABLE CRTEND OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
|
|
|
|
add_custom_command(
|
|
|
|
TARGET kernel PRE_LINK
|
|
|
|
COMMAND ${CMAKE_CXX_COMPILER} -MD -c ${CMAKE_CURRENT_SOURCE_DIR}/arch/${BANAN_ARCH}/crti.S ${COMPILE_OPTIONS}
|
|
|
|
COMMAND ${CMAKE_CXX_COMPILER} -MD -c ${CMAKE_CURRENT_SOURCE_DIR}/arch/${BANAN_ARCH}/crtn.S ${COMPILE_OPTIONS}
|
2023-10-30 11:06:13 +02:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CRTBEGIN} .
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CRTEND} .
|
2023-04-02 04:07:27 +03:00
|
|
|
)
|
|
|
|
|
2023-10-05 18:52:44 +03:00
|
|
|
#add_custom_command(
|
|
|
|
# TARGET kernel POST_BUILD
|
|
|
|
# COMMAND x86_64-banan_os-strip ${CMAKE_CURRENT_BINARY_DIR}/kernel
|
|
|
|
#)
|
2023-07-21 15:47:31 +03:00
|
|
|
|
2024-06-19 04:20:23 +03:00
|
|
|
banan_include_headers(kernel ban)
|
|
|
|
banan_include_headers(kernel libc)
|
|
|
|
banan_include_headers(kernel libfont)
|
|
|
|
banan_include_headers(kernel libelf)
|
|
|
|
banan_include_headers(kernel libinput)
|
|
|
|
|
|
|
|
banan_install_headers(kernel)
|
|
|
|
set_target_properties(kernel PROPERTIES OUTPUT_NAME banan-os.kernel)
|
2024-06-20 14:32:05 +03:00
|
|
|
install(TARGETS kernel DESTINATION ${BANAN_BOOT} OPTIONAL)
|
2024-06-19 04:20:23 +03:00
|
|
|
|
|
|
|
if("${BANAN_ARCH}" STREQUAL "x86_64")
|
|
|
|
set(ELF_FORMAT elf64-x86-64)
|
|
|
|
elseif("${BANAN_ARCH}" STREQUAL "i686")
|
|
|
|
set(ELF_FORMAT elf32-i386)
|
|
|
|
endif()
|
|
|
|
|
2023-04-02 04:48:56 +03:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT font/prefs.psf.o
|
|
|
|
COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && objcopy -O ${ELF_FORMAT} -B i386 -I binary font/prefs.psf ${CMAKE_CURRENT_BINARY_DIR}/font/prefs.psf.o
|
|
|
|
)
|
|
|
|
|
|
|
|
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_COMPILER} <CMAKE_CXX_LINK_FLAGS> <FLAGS> <LINK_FLAGS> -o <TARGET> ${CMAKE_CURRENT_BINARY_DIR}/crti.o ${CMAKE_CURRENT_BINARY_DIR}/crtbegin.o <OBJECTS> ${CMAKE_CURRENT_BINARY_DIR}/crtend.o ${CMAKE_CURRENT_BINARY_DIR}/crtn.o -lgcc ")
|