WIP: modules

This commit is contained in:
karina
2026-05-03 15:49:40 +04:00
parent 2c7396353c
commit 08248e3f3c
13 changed files with 539 additions and 62 deletions
+40
View File
@@ -0,0 +1,40 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright (c) 2026 0xKSor
cmake_minimum_required(VERSION 3.20)
project(ksOS_init LANGUAGES C)
file(GLOB_RECURSE INIT_SOURCES CMAKE_CONFIGURE_DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/Source/*.S
${CMAKE_CURRENT_SOURCE_DIR}/Source/*.c
)
add_executable(init ${INIT_SOURCES})
target_include_directories(init PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/Source
${CMAKE_CURRENT_SOURCE_DIR}/../../Common
)
target_compile_options(init PRIVATE
-std=c23
-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"
)
set_target_properties(init PROPERTIES
OUTPUT_NAME "Init"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
+21
View File
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2026 0xKSor
.section .text.entry, "ax"
.global _start
_start:
// Set up stack pointer (8KB stack)
adrp x0, stack_top
add sp, x0, :lo12:stack_top
// Jump to C main
bl main
// If main returns, loop forever
b .
.section .bss, "aw", @nobits
.align 12 // 4KB alignment
stack_bottom:
.space 8192 // 8KB stack
stack_top:
+9
View File
@@ -0,0 +1,9 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2026 0xKSor
void main(void) {
__asm__ volatile(
"svc #0\n"
"b .\n"
);
}