Initial Commit

This commit is contained in:
kaguya
2026-04-14 22:52:24 -04:00
commit 426ad76676
184 changed files with 11033 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
{
"configurations": [
{
"name": "linux-gcc-x64",
"includePath": [
"${workspaceFolder}/**"
],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu11",
"cppStandard": "${default}",
"intelliSenseMode": "linux-gcc-x64",
"compilerArgs": [
""
]
}
],
"version": 4
}
+24
View File
@@ -0,0 +1,24 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++ Runner: Debug Session",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"externalConsole": false,
"cwd": "/home/kaguya/testOS/user/programs",
"program": "/home/kaguya/testOS/user/programs/build/Debug/outDebug",
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
+59
View File
@@ -0,0 +1,59 @@
{
"C_Cpp_Runner.cCompilerPath": "gcc",
"C_Cpp_Runner.cppCompilerPath": "g++",
"C_Cpp_Runner.debuggerPath": "gdb",
"C_Cpp_Runner.cStandard": "gnu11",
"C_Cpp_Runner.cppStandard": "",
"C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/VR_NR/Community/VC/Auxiliary/Build/vcvarsall.bat",
"C_Cpp_Runner.useMsvc": false,
"C_Cpp_Runner.warnings": [
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wshadow",
"-Wformat=2",
"-Wcast-align",
"-Wconversion",
"-Wsign-conversion",
"-Wnull-dereference"
],
"C_Cpp_Runner.msvcWarnings": [
"/W4",
"/permissive-",
"/w14242",
"/w14287",
"/w14296",
"/w14311",
"/w14826",
"/w44062",
"/w44242",
"/w14905",
"/w14906",
"/w14263",
"/w44265",
"/w14928"
],
"C_Cpp_Runner.enableWarnings": true,
"C_Cpp_Runner.warningsAsError": false,
"C_Cpp_Runner.compilerArgs": [],
"C_Cpp_Runner.linkerArgs": [],
"C_Cpp_Runner.includePaths": [],
"C_Cpp_Runner.includeSearch": [
"*",
"**/*"
],
"C_Cpp_Runner.excludeSearch": [
"**/build",
"**/build/**",
"**/.*",
"**/.*/**",
"**/.vscode",
"**/.vscode/**"
],
"C_Cpp_Runner.useAddressSanitizer": false,
"C_Cpp_Runner.useUndefinedSanitizer": false,
"C_Cpp_Runner.useLeakSanitizer": false,
"C_Cpp_Runner.showCompilationTime": false,
"C_Cpp_Runner.useLinkTimeOptimization": false,
"C_Cpp_Runner.msvcSecureNoWarnings": false
}
+48
View File
@@ -0,0 +1,48 @@
CC = gcc
LD = ld
BUILD = build
CFLAGS = \
-m64 \
-O2 \
-ffreestanding \
-fno-pie \
-fno-pic \
-fno-stack-protector \
-nostdlib \
-nodefaultlibs \
-fno-builtin
LDFLAGS = \
-m elf_x86_64 \
-T linker.ld \
-nostdlib \
-z max-page-size=0x1000
SRC_C = programs/init.c
SRC_S = crt0.S
OBJ = \
$(BUILD)/init.o \
$(BUILD)/crt0.o
all: $(BUILD)/init.elf
$(BUILD):
mkdir -p $(BUILD)
$(BUILD)/init.o: programs/init.c | $(BUILD)
$(CC) $(CFLAGS) -c $< -o $@
$(BUILD)/crt0.o: crt0.S | $(BUILD)
$(CC) $(CFLAGS) -c $< -o $@
$(BUILD)/init.elf: $(OBJ)
$(LD) $(LDFLAGS) $^ -o $@
install: $(BUILD)/init.elf
cp $(BUILD)/init.elf /home/kaguya/testOS/ext2_root/init.elf
clean:
rm -rf $(BUILD)
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+12
View File
@@ -0,0 +1,12 @@
.global _start
.section .text
_start:
call main
mov $60, %rax # exit syscall (you define this later)
xor %rdi, %rdi
syscall
hang:
jmp hang
+15
View File
@@ -0,0 +1,15 @@
#pragma once
static inline long syscall(long num, long a1, long a2, long a3)
{
long ret;
asm volatile (
"syscall"
: "=a"(ret)
: "a"(num), "D"(a1), "S"(a2), "d"(a3)
:
);
return ret;
}
+23
View File
@@ -0,0 +1,23 @@
ENTRY(_start)
SECTIONS
{
. = 0x400000;
.text : {
*(.text*)
}
.rodata : {
*(.rodata*)
}
.data : {
*(.data*)
}
.bss : {
*(COMMON)
*(.bss*)
}
}
+22
View File
@@ -0,0 +1,22 @@
#include "../include/syscalls.h"
unsigned strlen(const char* str)
{
unsigned len = 0;
while (*str)
{
++len;
++str;
}
return len;
}
void main()
{
syscall(1, 'A', 0, 0);
syscall(1, 'B', 0, 0);
syscall(1, 'C', 0, 0);
while (1);
}