Skip to content
This repository was archived by the owner on Jan 4, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 6 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
cmake_minimum_required(VERSION 3.30)
set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
project(VoidFrame
VERSION 0.0.2
VERSION 0.0.2.4
LANGUAGES C CXX ASM_NASM
HOMEPAGE_URL "https://github.com/assembler-0/VoidFrame"
DESCRIPTION "A hobbyist operating system kernel written in C and Rust"
DESCRIPTION "A hobbyist operating system kernel written in C/C++ Assembly Rust"
)
enable_language(ASM_NASM)

Expand Down Expand Up @@ -52,12 +52,7 @@ if(NOT CMAKE_TOOLCHAIN_FILE)
message(STATUS "Defaulting to Windows x86_64 toolchain file: ${CMAKE_TOOLCHAIN_FILE}")
endif()
else()
message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}")
endif()

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type" FORCE)
message(WARNING "CMAKE_BUILD_TYPE not set. Defaulting to Release.")
message(STATUS "CMake: Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}")
endif()

if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64")
Expand Down Expand Up @@ -131,6 +126,9 @@ endif()
link_rust_library(voidframe.krnl voidframe-spinlock)
link_rust_library(voidframe.krnl voidframe-mm)

add_dependencies(voidframe.krnl voidframe_mm)
add_dependencies(voidframe.krnl cargo-build_voidframe_spinlock)

# Configure the linker to use ld.lld with proper arguments
set_target_properties(voidframe.krnl PROPERTIES
LINK_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/voidframe.ld"
Expand Down
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

## About

VoidFrame is a 64-bit **ring-0** kernel designed for the x86_64 architecture written in C and assembly (nasm).
VoidFrame is a 64-bit **ring-0** kernel designed for the x86_64 architecture written in C/C++, assembly (nasm) and Rust.
This kernel was intended and targeted for people who want to learn about operating systems and want to make a piece of their own.
As the designer of this kernel, I just wanted to make something that is simple, fast, secure and easy to understand.
Which obviously means that it is not a perfect kernel. And it breaks all the time.
Expand All @@ -26,12 +26,12 @@ It would be amazing if you could contribute to this project!

## Prerequisites (development)
- x64-compatible cpu (used: Intel i3-12100F)
- POSIX-compliant OS (SysV ABI) (used: Arch Linux 6.16.9-arch1-1)
- POSIX-compliant OS (SysV ABI) (used: Arch Linux 6.17.6-arch1-1)
- cmake >= 3.20 (used: cmake 4.1.2)
- ninja >= 1.11 (used: ninja 1.21.1)
- clang/++ >= 18.0.0 (used: 20.1.8)
- ninja >= 1.11 (used: ninja 1.13.1)
- clang/++ >= 18.0.0 (used: 21.1.4)
- rustup (nightly, bare metal toolchain) >= 1.89.0 (used: 1.92.0-nightly)
- nasm >= 2.16 (used: 2.16.03)
- nasm >= 2.16 (used: 3.01)
- qemu >= 7.0.0 (used: 10.1.0)
- mkfs.fat
- mkfs.ext2
Expand All @@ -45,8 +45,10 @@ git clone https://github.com/assembler-0/VoidFrame.git
cd VoidFrame
mkdir build
cd build
ccmake .. -G Ninja # 'c' -> 'e' -> 'q' -- IMPORTATNT!
cmake ..
cmake .. -G Ninja \
-DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain/linux-x64.cmake \
-DCMAKE_BUILD_TYPE=Release
cmake .. # IMPORTANT: for some reason, this command is needed for the first time
ninja -j$(nproc)
ninja run
```
Expand Down
2 changes: 0 additions & 2 deletions cmake/configuration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ option(STACK_PROTECTION "Enable stack protection" ON)
option(SILENT_BUILD "Enable silent build (suppress warnings)" OFF)

option(VF_CONFIG_ENABLE_VMWARE_SVGA_II "Enable VMware SVGA II support" OFF)
option(VF_CONFIG_ENABLE_CERBERUS_VFS_LOGGING "Enable Cerberus VFS logging" OFF)
option(VF_CONFIG_CERBERUS_THREAT_REPORTING "Enable Cerberus threat reporting" OFF)
option(VF_CONFIG_PANIC_OVERRIDE "Enable panic override" OFF)
option(VF_CONFIG_LOAD_MB_MODULES "Enable multiboot module loading" OFF)

Expand Down
8 changes: 0 additions & 8 deletions cmake/features.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,6 @@ if(VF_CONFIG_ENABLE_VMWARE_SVGA_II)
add_compile_definitions(VF_CONFIG_ENABLE_VMWARE_SVGA_II)
endif()

if(VF_CONFIG_ENABLE_CERBERUS_VFS_LOGGING)
add_compile_definitions(VF_CONFIG_ENABLE_CERBERUS_VFS_LOGGING)
endif()

if(VF_CONFIG_CERBERUS_THREAT_REPORTING)
add_compile_definitions(VF_CONFIG_CERBERUS_THREAT_REPORTING)
endif()

if(VF_CONFIG_PANIC_OVERRIDE)
add_compile_definitions(VF_CONFIG_PANIC_OVERRIDE)
endif()
Expand Down
2 changes: 1 addition & 1 deletion cmake/flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ else()
endif()

if(STACK_PROTECTION)
string(APPEND C_FLAGS " -fstack-protector-strong -D_FORTIFY_SOURCE=2")
string(APPEND C_FLAGS " -fstack-protector-all -D_FORTIFY_SOURCE=2")
endif()

if(DEBUG_SYMBOLS)
Expand Down
12 changes: 7 additions & 5 deletions docs/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,21 @@ The recommended approach is to use [WSL](https://learn.microsoft.com/en-us/windo

## 3. Building VoidFrame

After installing the dependencies, you can build the kernel using one of the supported build systems. All commands should be run from the root of the VoidFrame repository.

### Using CMake (actively maintained)
After installing the dependencies, you can build the kernel using CMake.

```bash
# 1. Create a build directory
mkdir -p build && cd build

# 2. Configure the project (example for Linux)
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain/linux-x64.cmake
cmake ..

# 3. Features configuration
ccmake .

# 3. Build the kernel
ninja
# 4. Build the all targets
ninja -j$(nproc)

# 4. Run the kernel in QEMU
ninja run
Expand Down
20 changes: 10 additions & 10 deletions kernel/atomic/rust/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ fn panic(_info: &PanicInfo) -> ! {
}

// Static storage for locks (kernel will manage allocation)
static mut SPINLOCK_STORAGE: [SpinLock; 64] = [const { SpinLock::new() }; 64];
static mut SPINLOCK_USED: [bool; 64] = [false; 64];
static mut SPINLOCK_STORAGE: [SpinLock; 256] = [const { SpinLock::new() }; 256];
static mut SPINLOCK_USED: [bool; 256] = [false; 256];

#[no_mangle]
pub extern "C" fn rust_spinlock_new() -> *mut SpinLock {
unsafe {
for i in 0..64 {
for i in 0..256 {
if !SPINLOCK_USED[i] {
SPINLOCK_USED[i] = true;
return &mut SPINLOCK_STORAGE[i] as *mut SpinLock;
Expand Down Expand Up @@ -103,7 +103,7 @@ pub extern "C" fn rust_spinlock_owner_cpu(lock: *mut SpinLock) -> u32 {
#[no_mangle]
pub extern "C" fn rust_spinlock_new_with_order(order: u32) -> *mut SpinLock {
unsafe {
for i in 0..64 {
for i in 0..256 {
if !SPINLOCK_USED[i] {
SPINLOCK_USED[i] = true;
SPINLOCK_STORAGE[i] = SpinLock::new_with_order(order);
Expand All @@ -115,15 +115,15 @@ pub extern "C" fn rust_spinlock_new_with_order(order: u32) -> *mut SpinLock {
}

// Static storage for MCS locks and nodes
static mut MCS_LOCK_STORAGE: [McsLock; 32] = [const { McsLock::new() }; 32];
static mut MCS_LOCK_USED: [bool; 32] = [false; 32];
static mut MCS_NODE_STORAGE: [McsNode; 128] = [const { McsNode::new() }; 128];
static mut MCS_NODE_USED: [bool; 128] = [false; 128];
static mut MCS_LOCK_STORAGE: [McsLock; 128] = [const { McsLock::new() }; 128];
static mut MCS_LOCK_USED: [bool; 128] = [false; 128];
static mut MCS_NODE_STORAGE: [McsNode; 512] = [const { McsNode::new() }; 512];
static mut MCS_NODE_USED: [bool; 512] = [false; 512];

#[no_mangle]
pub extern "C" fn rust_mcs_lock_new() -> *mut McsLock {
unsafe {
for i in 0..32 {
for i in 0..128 {
if !MCS_LOCK_USED[i] {
MCS_LOCK_USED[i] = true;
return &mut MCS_LOCK_STORAGE[i] as *mut McsLock;
Expand All @@ -150,7 +150,7 @@ pub extern "C" fn rust_mcs_lock_free(lock: *mut McsLock) {
#[no_mangle]
pub extern "C" fn rust_mcs_node_new() -> *mut McsNode {
unsafe {
for i in 0..128 {
for i in 0..512 {
if !MCS_NODE_USED[i] {
MCS_NODE_USED[i] = true;
return &mut MCS_NODE_STORAGE[i] as *mut McsNode;
Expand Down
2 changes: 0 additions & 2 deletions kernel/ipc/Ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ IpcResult IpcReceiveMessage(IpcMessage* msg_buffer) {

current->state = PROC_BLOCKED;
rust_spinlock_unlock(queue->lock);
Yield();
}
}

Expand Down Expand Up @@ -174,7 +173,6 @@ IpcResult IpcReceiveMessageType(IpcMessage* msg_buffer, IpcMessageType type) {
// Mark blocked while still holding the lock to avoid a wakeup‐before‐block race
current->state = PROC_BLOCKED;
rust_spinlock_unlock(queue->lock);
Yield();
}
}

Expand Down
Loading