diff --git a/Kernel/Source/Arch/Exceptions.c b/Kernel/Source/Arch/Exceptions.c index 32da766..9433402 100644 --- a/Kernel/Source/Arch/Exceptions.c +++ b/Kernel/Source/Arch/Exceptions.c @@ -20,7 +20,7 @@ Address ExceptionsHandler(ExceptionsContext* frame, ExceptionsType type) { } if (class == 0x15 && syndrome == 0) { - OSPanic("Wow! We are inside EL0! Syscall caught successfully! :D"); + OSPanic("Hi from userspace!!"); } } OSPanicException(frame); diff --git a/Runtime/cmake/aarch64.cmake b/Runtime/Common/aarch64.cmake similarity index 93% rename from Runtime/cmake/aarch64.cmake rename to Runtime/Common/aarch64.cmake index 72781e5..2a5ab03 100644 --- a/Runtime/cmake/aarch64.cmake +++ b/Runtime/Common/aarch64.cmake @@ -44,7 +44,7 @@ if(APPLE) find_program(TERMOS_LD_LLD NAMES ld.lld HINTS /usr/local/bin /opt/homebrew/bin REQUIRED) set(CMAKE_C_LINK_FLAGS "") set(CMAKE_C_LINK_EXECUTABLE - "${TERMOS_LD_LLD} -o ") + "${TERMOS_LD_LLD} -o ") endif() find_program(LLVM_OBJCOPY NAMES llvm-objcopy objcopy diff --git a/Runtime/Common/linker.ld b/Runtime/Common/linker.ld new file mode 100644 index 0000000..619b2c8 --- /dev/null +++ b/Runtime/Common/linker.ld @@ -0,0 +1,23 @@ +ENTRY(_start) + +SECTIONS +{ + . = 0x400000; + + .text : ALIGN(4K) { + *(.text .text.*) + } + + .rodata : ALIGN(4K) { + *(.rodata .rodata.*) + } + + .data : ALIGN(4K) { + *(.data .data.*) + } + + .bss : ALIGN(4K) { + *(.bss .bss.*) + *(COMMON) + } +} diff --git a/Runtime/System/Init/CMakeLists.txt b/Runtime/System/Init/CMakeLists.txt index 2099edd..a610e36 100644 --- a/Runtime/System/Init/CMakeLists.txt +++ b/Runtime/System/Init/CMakeLists.txt @@ -2,7 +2,8 @@ # Copyright (c) 2026 0xKSor cmake_minimum_required(VERSION 3.20) -project(ksOS_init LANGUAGES C) +project(ksOS_init LANGUAGES C ASM) + file(GLOB_RECURSE INIT_SOURCES CMAKE_CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/Source/*.S @@ -17,21 +18,27 @@ target_include_directories(init PRIVATE ) target_compile_options(init PRIVATE - -std=c23 + $<$: + -std=c23 + -fno-stack-protector + -fno-builtin + -Wall + -Wextra + > -ffreestanding - -fno-stack-protector - -fno-builtin - -Wall -Wextra -g -mgeneral-regs-only ) -# Передаем "голые" аргументы напрямую для ld.lld target_link_options(init PRIVATE - "-Ttext=0x400000" - "-e" "_start" - "-z" "max-page-size=0x1000" - "--no-dynamic-linker" + -nostdlib + -static + -no-pie + -T "${CMAKE_CURRENT_SOURCE_DIR}/../../Common/linker.ld" + -Ttext=0x400000 + -e _start + -z max-page-size=0x1000 + --no-dynamic-linker ) set_target_properties(init PROPERTIES diff --git a/Runtime/justfile b/Runtime/justfile index 88203b3..9fdcc82 100644 --- a/Runtime/justfile +++ b/Runtime/justfile @@ -20,7 +20,7 @@ _default: echo " 🛠️ CMake build: ${TARGET_SUBPATH}" - TOOLCHAIN_FILE="{{ justfile_directory() }}/cmake/aarch64.cmake" + TOOLCHAIN_FILE="{{ justfile_directory() }}/Common/aarch64.cmake" TOOLCHAIN="" if [ -f "${TOOLCHAIN_FILE}" ]; then TOOLCHAIN="-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE}"