Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
f5df607
Squash commit of shell_fs
automas-dev Aug 12, 2025
a1cf8e0
Get pid and yield from init
automas-dev Aug 13, 2025
4f53ee8
Squashed commit of refactor
automas-dev Aug 21, 2025
8dc6e44
Move libk code into libc component
automas-dev Aug 21, 2025
0e0e328
Move screen out of device folder
automas-dev Aug 21, 2025
eedd2ad
Fix boot map docs in memory.md
automas-dev Aug 21, 2025
a455cd8
Condense drivers into kernel
automas-dev Aug 21, 2025
dba0d53
Move load and run init to loader
automas-dev Aug 21, 2025
23a2d47
Add loader notes
automas-dev Aug 21, 2025
fc3234c
Enable stderr by increasing initial size
automas-dev Aug 21, 2025
ada1968
IT CAN READ FILES!!!
automas-dev Aug 21, 2025
9234e75
Update clang format rules
automas-dev Dec 22, 2025
faed68f
Update boot stage documentation
automas-dev Dec 22, 2025
72253d4
Add acpi 3.0 extended attributes to memory documentation
automas-dev Dec 22, 2025
967ad17
Rename stuff
automas-dev Dec 22, 2025
683a15c
Back to one file
automas-dev Dec 22, 2025
f145110
Update stage 2 docs
automas-dev Dec 22, 2025
99e98d0
Remove libk from cpu component
automas-dev Dec 22, 2025
ff74680
Add kernel steps to stages docs
automas-dev Dec 22, 2025
66d4cf1
Split libk for system calls from libc
automas-dev Dec 22, 2025
a6fd425
Cleanup old code
automas-dev Dec 22, 2025
eb797a3
Sort kernel sources into subdirs
automas-dev Dec 22, 2025
56f652e
Fix print numbers of base other than 10
automas-dev Dec 23, 2025
2391e50
Order imports
automas-dev Dec 23, 2025
f84240a
Log system calls
automas-dev Dec 23, 2025
a99bbd0
More logging for process system calls
automas-dev Dec 23, 2025
66c95dc
Replace poetry with uv for docs
automas-dev Dec 23, 2025
c59daf1
Working popen
automas-dev Dec 23, 2025
3752bd8
Setup ping pong apps
automas-dev Dec 23, 2025
bf371f4
Move ram under drivers
automas-dev Dec 23, 2025
54467e7
Rename popen to proc_open
automas-dev Dec 23, 2025
7c82160
Get tests working again
automas-dev Dec 23, 2025
0d62a61
Order imports, pass vga screen as arg
automas-dev Dec 23, 2025
2ca3d43
Add import path for gtest to cpp properties
automas-dev Dec 23, 2025
8563e01
Rename init_ata to ata_init
automas-dev Dec 23, 2025
be5f152
Rename init_keyboard to keyboard_init
automas-dev Dec 23, 2025
a0148cf
Rename init_pit to pit_init
automas-dev Dec 23, 2025
455fd7a
Update ram import guard
automas-dev Dec 23, 2025
a058b11
Rename init_rtc to rtc_init
automas-dev Dec 23, 2025
b396d6d
Fix ram import guard
automas-dev Dec 23, 2025
7376a3c
Rename init_kernel_logs to kernel_log_init
automas-dev Dec 23, 2025
baa69e5
Rename init_kmalloc to kmalloc_init
automas-dev Dec 23, 2025
9c34a38
Add time_ prefix to kernel time functions
automas-dev Dec 23, 2025
d04d97e
Rename init_system_call to system_call_init
automas-dev Dec 23, 2025
3815b7c
Getting ready for shell
automas-dev Dec 23, 2025
ea31e2e
Working shell with keyboard input
automas-dev Dec 24, 2025
2174e11
Move memory alloc tests to libc
automas-dev Dec 24, 2025
3f1991d
Uniform naming of static globals
automas-dev Dec 24, 2025
961b770
Use kernel logs in ata driver
automas-dev Dec 24, 2025
da2d32c
More cleanup
automas-dev Dec 24, 2025
8183928
More cleanup and setup foreground task
automas-dev Dec 24, 2025
41207d7
idk why it's working but don't make shell the foreground task
automas-dev Dec 24, 2025
98732ac
Cleanup
automas-dev Dec 25, 2025
f010431
Add serial driver
automas-dev Dec 26, 2025
71fbeb5
Add serial device
automas-dev Dec 26, 2025
93ee6d0
Working state
automas-dev Dec 26, 2025
36bb58a
It's working so I'm not going to change it
automas-dev Dec 26, 2025
2036301
Change kernel log file name
automas-dev Dec 26, 2025
67d4a69
Strip project path prefix from log file path
automas-dev Dec 26, 2025
824a2f9
Fix io for puts and putc
automas-dev Dec 26, 2025
19fe585
Add level name to output
automas-dev Dec 26, 2025
492ce5c
Set file level service name for logging
automas-dev Dec 26, 2025
b1b8110
Update logging for ata, rename disk vars and params to drive
automas-dev Dec 26, 2025
8f650a8
Cleanup qemu flags in makefile
automas-dev Dec 27, 2025
86d38df
Add DRIVER/ prefix to ata service
automas-dev Dec 27, 2025
7f1f121
Update keyboard logging
automas-dev Dec 27, 2025
1c10cc9
Change kernel to panic header
automas-dev Dec 27, 2025
0afaa8b
Update logging in pit driver
automas-dev Dec 27, 2025
edfe081
Fix vprintf handling 64 bit
automas-dev Dec 27, 2025
cb02879
Update logging in ram, check kmemmove for error, add log mock, update…
automas-dev Dec 27, 2025
0b09872
Update logging and error handling in ramdisk driver
automas-dev Dec 27, 2025
dbd21e3
Add logs to RTC, rtc still needs a proper implementation
automas-dev Dec 28, 2025
d05b962
Add note not to log in serial driver
automas-dev Dec 28, 2025
bc8ba26
Add logging to tar driver
automas-dev Dec 28, 2025
9c8f54b
Add log to ram driver for init
automas-dev Dec 28, 2025
1a4b052
Add logging to vga driver
automas-dev Dec 28, 2025
af1f7e8
Initialize serial driver and logging before vga driver
automas-dev Dec 28, 2025
610e945
Cleanup order of driver init logging
automas-dev Dec 28, 2025
c8b5fd5
Fix loader log level and vga init log position
automas-dev Dec 28, 2025
0aa68ad
Add logging to system call handlers
automas-dev Dec 28, 2025
61ddd27
Add logging to kernel memory
automas-dev Dec 28, 2025
3867e27
Add logging to kernel time
automas-dev Dec 28, 2025
dfbe821
Add logging to system call
automas-dev Dec 28, 2025
49943e2
Fix build for test coverage
automas-dev Dec 29, 2025
9adf4a3
Temp disable ci coverage
automas-dev Dec 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
BasedOnStyle: Google
AccessModifierOffset: -4
AlignArrayOfStructures: Left
AlignConsecutiveAssignments: Consecutive
AlignConsecutiveBitFields: AcrossEmptyLines
AlignConsecutiveDeclarations: Consecutive
Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ jobs:
- name: Build
run: cmake --build ${BUILD_DIR}

# - name: Test
# working-directory: build
# run: ctest -V

- name: Test with Coverage
- name: Test
working-directory: build
run: cmake --build ${BUILD_DIR} --target os_test_coverage
run: ctest -V

# TODO re-enable this once coverage is complete
# - name: Test with Coverage
# working-directory: build
# run: cmake --build ${BUILD_DIR} --target os_test_coverage

lint:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
*.bin
*.o
*.elf
*.log

build/
drive/
drive.img
drive.tar
qemu_log.txt
3 changes: 2 additions & 1 deletion .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"includePath": [
"${workspaceFolder}/src/**",
"${workspaceFolder}/tests/src/**",
"${workspaceFolder}/tests/build/_deps/fff-src"
"${workspaceFolder}/tests/build/_deps/fff-src",
"${workspaceFolder}/tests/build/_deps/googletest-src/googletest/include"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
Expand Down
4 changes: 3 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
"remote": true,
"cwd": "${workspaceRoot}",
"debugger_args": [
"-nx"
"-nx",
"-ex",
"add-symbol-file ${workspaceFolder}/build/src/apps/shell/shell.elf 0x400000"
],
"valuesFormatting": "parseText",
"preLaunchTask": "Run QEMU",
Expand Down
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@ if(CMAKE_ASM_NASM_COMPILER_LOADED)
endif()

# Create config.h with project version numbers
configure_File(cmake/config.h.in include/config.h)
string(LENGTH "${PROJECT_SOURCE_DIR}/src/" FILE_PREFIX_LENGTH)
configure_file(cmake/config.h.in include/config.h)
include_directories(PRIVATE ${CMAKE_BINARY_DIR}/include)

include(cmake/targets.cmake)

# set KERNEL macro for build time
add_compile_options(-DKERNEL)

add_subdirectory(src)

# ------------------------------------------------------------------------------
Expand Down
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,22 @@ QEMU = qemu-system-i386 -boot order=a

# QEMUFLAGS = -m 4G -drive format=qcow2,file=drive.img -d int,cpu_reset -D qemu_log.txt -no-reboot
# QEMUFLAGS = -m 1G -drive format=raw,file=drive.tar -d int,mmu -D qemu_log.txt -no-reboot -no-shutdown
QEMUFLAGS = -m 1G -drive format=raw,file=build/os-image.bin,index=0,if=floppy -drive format=raw,file=build/apps.tar -d int,mmu -D qemu_log.txt -no-reboot -no-shutdown
QEMUFLAGS = -m 1G \
-drive format=raw,file=build/os-image.bin,index=0,if=floppy \
-drive format=raw,file=build/apps.tar \
-d int,mmu \
-D qemu_log.txt \
-no-reboot -no-shutdown \
-chardev stdio,id=char0,logfile=kernel.log,signal=off -serial chardev:char0

# ===============
# LAUNCH & UTIL
# ===============
setup:
cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
cmake -S . -B build -GNinja -DCMAKE_BUILD_TYPE=Debug

build:
cmake --build build
cmake --build build -j

run:
$(QEMU) $(QEMUFLAGS)
Expand All @@ -32,7 +38,7 @@ run-debug:

debug:
$(QEMU) -s -S $(QEMUFLAGS) &
$(GDB) -ex "target remote localhost:1234" -ex "symbol-file build/src/kernel/kernel.elf" -ex "b kernel_main" -ex "b isr_handler"
$(GDB) -ex "target remote localhost:1234" -ex "symbol-file build/src/kernel/kernel.elf" -ex "add-symbol-file build/src/apps/foo/foo.elf" -ex "b kernel_main" -ex "b isr_handler"

boot-debug:
$(QEMU) -s -S $(QEMUFLAGS) &
Expand Down
50 changes: 11 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ Active and planned work is tracked in [notes.md](notes.md)

For current specs see

- [memory.md](design/memory.md)
- [boot.md](design/boot.md)
- [system_call.md](design/system_call.md)
- ~~[filesystem.md](design/filesystem.md)~~
- [memory.md](design/memory.md)
- [process.md](design/process.md)
- [system_call.md](design/system_call.md)

## Goals

Expand Down Expand Up @@ -55,7 +56,7 @@ achieve these goals.
- [x] Kernel Service Calls
- [ ] Date and Time
- [ ] Optional don't disable interrupts during interrupt (nested interrupts)
- [ ] Better key event buffer (with mods) (maybe in addition to char buffer)
- [x] Better key event buffer (with mods) (maybe in addition to char buffer)
- [x] Change stdlib names with k prefix for namespace during testing
- [ ] Optimize disk read to check if area already in buffer

Expand Down Expand Up @@ -85,8 +86,14 @@ there is enough support for their development.

## Setup

You will need to install the gcc i386 elf cross compiler. This project expects
this to be under `~/.local/opt/cross` but this can be changed by editing the
root `CMakeLists.txt`. For instructions of how to build the i386 elf compiler
from source, follow the instructions on the OS-Dev Wiki
[GCC_Cross-Compiler](https://wiki.osdev.org/GCC_Cross-Compiler)

```sh
git clone git@github.com:twh2898/os.git
git clone git@github.com:automas-dev/os.git
cd os
make setup
```
Expand Down Expand Up @@ -119,38 +126,3 @@ make test_cov DARK_MODE=ON
make lint
make format
```

### Format drive.img

After creating the drive image with `make drive.img` you can format and mount it
using the following.

Setup file as drive

```sh
modprobe nbd max_part=63
qemu-nbd -c /dev/nbd0 drive.img
```

Format drive

```sh
fdisk /dev/nbd0
mkfs.fat -F32 /dev/nbd0p1
```

Fdisk commands should be `onp1 w`

Mount the drive

```sh
mount /dev/nbd0p1 drive
```

Unmount the drive

```sh
umount drive
qemu-nbd -d /dev/nbd0
rmmod nbd
```
2 changes: 2 additions & 0 deletions archlinux/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*/*
!*/PKGBUILD
49 changes: 49 additions & 0 deletions archlinux/i386-elf-binutils/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Maintainer: c0repwn3r <core@coredoes.dev>
pkgname=i386-elf-binutils-local
pkgver=2.40
pkgrel=1
epoch=
pkgdesc="GNU binutils for the i386- toolchain"
arch=(x86_64)
url="https://www.gnu.org/software/binutils"
license=('GPL')
groups=(i386-elf-toolchain)
makedepends=(gcc)
depends=(xz)
source=("http://ftpmirror.gnu.org/binutils/binutils-$pkgver.tar.xz")
sha256sums=(0f8a4c272d7f17f369ded10a4aca28b8e304828e95526da482b0ccc4dfc9d8e1)

build() {
PREFIX="$HOME/.local/opt/cross"
# Create temporary build dir
mkdir -p "i386-binutils-$pkgver-build"
cd "i386-binutils-$pkgver-build"

# Configure, we are building in seperate directory to cleanly seperate the binaries from the source
../binutils-$pkgver/configure \
--prefix="$PREFIX" \
--target=i386-elf \
--with-sysroot \
--disable-nls \
--disable-werror \
--disable-multilib \
--enable-interwork

# Build
make
}

check() {
cd "i386-binutils-$pkgver-build"
make --keep-going check
}

package() {
PREFIX="$HOME/.local/opt/cross"
cd "i386-binutils-$pkgver-build"
#make install DESTDIR=$pkgdir
make install
# Remove conflicting files
rm -rf $pkgdir/usr/share/info
rm -rf $pkgdir/usr/lib/bfd-plugins
}
55 changes: 55 additions & 0 deletions archlinux/i386-elf-gcc/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Maintainer: c0repwn3r <core@coredoes.dev>
pkgname=i386-elf-gcc-local
pkgver=12.2.0
pkgrel=1
epoch=
pkgdesc="GNU gcc for the i386- toolchain"
arch=(x86_64)
url="https://www.gnu.org/software/gcc"
license=('GPL')
groups=(i386-elf-toolchain)
makedepends=(gmp mpfr gcc)
depends=(xz libmpc i386-elf-binutils-local)
source=(
"http://ftpmirror.gnu.org/gcc/gcc-$pkgver/gcc-$pkgver.tar.xz"
)
sha256sums=(
e549cf9cf3594a00e27b6589d4322d70e0720cdd213f39beb4181e06926230ff
)

build() {
PREFIX="$HOME/.local/opt/cross"
# GCC build fails with format-security.
CFLAGS=${CFLAGS/-Werror=format-security/}
CXXFLAGS=${CXXFLAGS/-Werror=format-security/}
# Create temporary build dir
mkdir -p "i386-gcc-$pkgver-build"
cd "i386-gcc-$pkgver-build"
# Configure, we are building in seperate directory to cleanly seperate the binaries from the source
../gcc-$pkgver/configure \
--prefix="$PREFIX" \
--target=i386-elf \
--disable-nls \
--disable-werror \
--disable-multilib \
--without-headers \
--enable-languages=c,c++

# Build
make all-gcc
make all-target-libgcc
}

package() {
PREFIX="$HOME/.local/opt/cross"
cd "i386-gcc-$pkgver-build"
#make install-gcc DESTDIR=$pkgdir
#make install-target-libgcc DESTDIR=$pkgdir
#make install-gcc DESTDIR="$PREFIX"
#make install-target-libgcc DESTDIR="$PREFIX"
make install-gcc
make install-target-libgcc
# Remove conflicting files
rm -rf "$PREFIX/usr/share/info"
rm -rf "$PREFIX/usr/share/man/man7"
}
41 changes: 41 additions & 0 deletions archlinux/i386-elf-gdb/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Maintainer: c0repwn3r <core@coredoes.dev>
pkgname=i386-elf-gdb-local
pkgver=11.1
pkgrel=4
epoch=
pkgdesc="GNU debugger crosscompiled for i386 development"
arch=(x86_64)
url="https://www.gnu.org/software/gdb"
license=('GPL')
groups=(i386-elf-toolchain)
makedepends=(gmp mpfr)
depends=(xz libmpc i386-elf-gcc gdb) # GDB is included to prevent conflicts with it - otherwise this package won't function
source=(
"http://ftpmirror.gnu.org/gdb/gdb-$pkgver.tar.xz"
)
sha256sums=(
cccfcc407b20d343fb320d4a9a2110776dd3165118ffd41f4b1b162340333f94
)
OPTIONS=(!strip)

build() {
PREFIX="$HOME/.local/opt/cross"
mkdir -p "i386-gdb-$pkgver-build"
cd "i386-gdb-$pkgver-build"
# Configure, we are building in seperate directory to cleanly seperate the binaries from the source
../gdb-$pkgver/configure --target=i386-elf --prefix="$PREFIX" --program-prefix=i386-elf-

# Build
make
}

package() {
cd "i386-gdb-$pkgver-build"
#make install DESTDIR=$pkgdir
make install
# Remove conflicting files
rm -rf $pkgdir/usr/share/locale/
rm -rf $pkgdir/usr/share/gdb
rm -rf $pkgdir/usr/include/gdb
rm -rf $pkgdir/usr/share/info/dir
}
2 changes: 2 additions & 0 deletions cmake/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
#define PROJECT_VERSION_MAJOR "@PROJECT_VERSION_MAJOR@"
#define PROJECT_VERSION_MINOR "@PROJECT_VERSION_MINOR@"
#define PROJECT_VERSION_PATCH "@PROJECT_VERSION_PATCH@"
#define SOME_ARBITRARY_VAR "@SOME_ARBITRARY_VAR@"
#define FILE_PREFIX_LENGTH @FILE_PREFIX_LENGTH@
4 changes: 2 additions & 2 deletions cmake/targets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ function(cross_target_binary target)
"-T${CMAKE_CURRENT_SOURCE_DIR}/link.ld"
--oformat binary
-o "${CMAKE_CURRENT_BINARY_DIR}/${target}.bin"
$<TARGET_FILE:${target}>
--start-group
$<TARGET_FILE:${target}>
${TARGET_LINK_FILES}
--end-group
-nostdlib
Expand All @@ -39,8 +39,8 @@ function(cross_target_binary target)
COMMAND ${CMAKE_LINKER}
"-T${CMAKE_CURRENT_SOURCE_DIR}/link.ld"
-o "${CMAKE_CURRENT_BINARY_DIR}/${target}.elf"
$<TARGET_FILE:${target}>
--start-group
$<TARGET_FILE:${target}>
${TARGET_LINK_FILES}
--end-group
-nostdlib
Expand Down
Loading