Skip to content
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
11 changes: 6 additions & 5 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ jobs:
run: |
mkdir cmake-build
cd cmake-build
cmake .. -G Ninja
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain/linux-x64.cmake
cd ..
ninja -C cmake-build
ninja -C cmake-build -j $(nproc)

- name: Artifact Analysis
run: |
timeout 30s ninja -C cmake-build runmin || true

cd cmake-build
timeout 30s ninja runmin || true
cd ..
grep -q "1KCSWF23Z456789" cmake-build/bootstrap.log
! grep -i "panic\|fault\|crash\|oops\|error\|failed" cmake-build/serial.log

Expand Down Expand Up @@ -71,4 +72,4 @@ jobs:
path: |
cmake-build/voidframe.krnl
cmake-build/VoidFrame.iso
retention-days: 30
retention-days: 10
23 changes: 21 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,26 @@ else()
message(FATAL_ERROR "Unsupported host system: ${CMAKE_HOST_SYSTEM_NAME}")
endif()

if(NOT CMAKE_TOOLCHAIN_FILE)
message(FATAL_ERROR "CMAKE_TOOLCHAIN_FILE is not set. Please provide a toolchain file.")
else()
message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}")
endif()

if(CMAKE_GENERATOR STREQUAL "Ninja")
message(STATUS "CMake: Generator: ${CMAKE_GENERATOR}")
else()
message(WARNING "CMake: Non-Ninja generator detected: ${CMAKE_GENERATOR}. Ninja is recommended.")
endif()

message(STATUS "CMake Build Type: ${CMAKE_BUILD_TYPE}")
message(STATUS "CMake Source Directory: ${CMAKE_SOURCE_DIR}")
message(STATUS "CMake Binary Directory: ${CMAKE_BINARY_DIR}")
message(STATUS "CMake Current Source Directory: ${CMAKE_CURRENT_SOURCE_DIR}")
message(STATUS "CMake Current Binary Directory: ${CMAKE_CURRENT_BINARY_DIR}")
message(STATUS "CMake Host System Name: ${CMAKE_HOST_SYSTEM_NAME}")
message(STATUS "CMake Host System Processor: ${CMAKE_HOST_SYSTEM_PROCESSOR}")

# ============================================================================
# Standard Configuration
# ============================================================================
Expand All @@ -30,13 +50,12 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Module Path & Includes
# ============================================================================
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(run)
include(features)
include(variable)
include(dependencies)
include(flags)
include(configuration)
include(run)
include(clang-x64)

# ============================================================================
# Source Files Organization
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ git clone https://github.com/assembler-0/VoidFrame.git
cd VoidFrame
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -G Ninja
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain/<linux/windows/macos>-x64.cmake -G Ninja
ninja -j$(nproc)
ninja img
ninja extra-img
Expand Down
3 changes: 2 additions & 1 deletion arch/x86_64/features/x64.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ void CpuInit(void) {
// If this is not set, the OS is not allowed to set XCR0 to enable AVX.
cpu_features.osxsave = (ecx >> 27) & 1;
if (!cpu_features.osxsave) {
PrintKernelWarning("System: CPU: OSXSAVE not supported. AVX will be disabled.\n");
PrintKernelWarning("System: CPU: OSXSAVE not supported. AVX/2/512F will be disabled.\n");
cpu_features.avx = false;
cpu_features.avx2 = false;
cpu_features.avx512f = false;
CPUFeatureValidation();
return;
}
Expand Down
12 changes: 12 additions & 0 deletions arch/x86_64/features/x64.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ typedef struct {
bool osxsave;
bool avx;
bool avx2;
bool avx512f;
} CpuFeatures;

// DO NOT TOUCH THIS STRUCTURE - must match interrupt ASM stack layout
Expand Down Expand Up @@ -61,6 +62,17 @@ static inline uint64_t __attribute__((always_inline)) rdtsc(void) {
return ((uint64_t)hi << 32) | lo;
}

static inline void __attribute__((always_inline)) __full_mem_prot_init(void) {
__sync_synchronize();
__asm__ volatile("mfence; sfence; lfence" ::: "memory");
}

static inline void __attribute__((always_inline)) __full_mem_prot_end(void) {
__asm__ volatile("mfence; sfence; lfence" ::: "memory");
__sync_synchronize();
__builtin_ia32_serialize();
}

void DumpRegisters(RegistersDumpT* dump);
void PrintRegisters(const RegistersDumpT* dump);

Expand Down
64 changes: 32 additions & 32 deletions cmake/run.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,42 @@
# ============================================================================
add_custom_target(run
COMMAND ${QEMU_SYSTEM_X86_64}
-cpu max
-vga vmware
-enable-kvm
-cdrom ${CMAKE_CURRENT_BINARY_DIR}/VoidFrame.iso
-debugcon file:bootstrap.log
-serial stdio
-no-reboot -no-shutdown
-m 4G
-drive file=VoidFrameDisk.img,if=ide
-drive file=SataDisk.img,if=none,id=sata0
-device ahci,id=ahci
-device ide-hd,drive=sata0,bus=ahci.0
-boot d
-device rtl8139
-device e1000
-device nec-usb-xhci,id=xhci
-device ich9-intel-hda
-usb -device usb-tablet
-audio pa,id=myaudio
-device sb16,iobase=0x220,irq=5,dma=1,dma16=5
-parallel file:printer.out
-drive file=VirtioDisk.img,format=raw,id=virtio_disk,if=none
-device virtio-blk-pci,drive=virtio_disk,disable-legacy=on
DEPENDS iso
-cpu max
-vga vmware
-enable-kvm
-cdrom ${CMAKE_CURRENT_BINARY_DIR}/VoidFrame.iso
-debugcon file:bootstrap.log
-serial stdio
-no-reboot -no-shutdown
-m 4G
-drive file=VoidFrameDisk.img,if=ide
-drive file=SataDisk.img,if=none,id=sata0
-device ahci,id=ahci
-device ide-hd,drive=sata0,bus=ahci.0
-boot d
-device rtl8139
-device e1000
-device nec-usb-xhci,id=xhci
-device ich9-intel-hda
-usb -device usb-tablet
-audio pa,id=myaudio
-device sb16,iobase=0x220,irq=5,dma=1,dma16=5
-parallel file:printer.out
-drive file=VirtioDisk.img,format=raw,id=virtio_disk,if=none
-device virtio-blk-pci,drive=virtio_disk,disable-legacy=on
DEPENDS iso img extra-img
)

add_custom_target(runmin
COMMAND ${QEMU_SYSTEM_X86_64}
-cdrom ${CMAKE_CURRENT_BINARY_DIR}/VoidFrame.iso
-nographic
-debugcon file:bootstrap.log
-serial file:serial.log
-no-reboot -no-shutdown
-m 4G
-boot d
DEPENDS iso img extra-img
-cdrom ${CMAKE_CURRENT_BINARY_DIR}/VoidFrame.iso
-nographic
-debugcon file:bootstrap.log
-serial file:serial.log
-no-reboot -no-shutdown
-m 1G
-boot d
DEPENDS iso
)

add_custom_target(img
Expand Down
7 changes: 2 additions & 5 deletions cmake/clang-x64.cmake → cmake/toolchain/linux-x64.cmake
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# ============================================================================
# Toolchain file for building with Clang targeting x86_64 architecture
# VoidFrame Toolchain for Linux x64 Host
# ============================================================================
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR x86_64)

set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)
set(CMAKE_ASM_NASM_COMPILER nasm)

set(CMAKE_EXE_LINKER_FLAGS_INIT "-fuse-ld=lld")
set(CMAKE_SHARED_LINKER_FLAGS_INIT "-fuse-ld=lld")
set(CMAKE_ASM_NASM_COMPILER nasm)
9 changes: 9 additions & 0 deletions cmake/toolchain/macos-x64.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# ============================================================================
# VoidFrame Toolchain for OSX (Darwin/macOS) x64 Host
# ============================================================================
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR x86_64)

set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)
set(CMAKE_ASM_NASM_COMPILER nasm)
9 changes: 9 additions & 0 deletions cmake/toolchain/windows-x64.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# ============================================================================
# VoidFrame Toolchain for Windows x64 Host
# ============================================================================
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR x86_64)

set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)
set(CMAKE_ASM_NASM_COMPILER nasm)
2 changes: 2 additions & 0 deletions cmake/variable.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ add_compile_definitions(
VIRT_ADDR_SPACE_HIGH_START=0xFFFF800000000000ULL
VIRT_ADDR_SPACE_HIGH_END=0xFFFFFDFFFFFFFFFFULL
KERNEL_SPACE_END=0xFFFFFFFFFFFFFFFFULL
PREFETCH_DISTANCE=256
NT_STORE_THRESHOLD=4*1024*1024
)
7 changes: 0 additions & 7 deletions docs/CMAKE.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@ This is the main entry point for the build system. It performs the following tas

The `/cmake` directory contains several `.cmake` files that handle specific parts of the build configuration.

### `clang-x64.cmake`

This file configures the build to use the Clang toolchain for cross-compilation to an x86_64 target.
- Sets the C and CXX compilers to `clang` and `clang++`.
- Sets the assembler to `nasm`.
- Configures the linker to use `lld`.

### `configuration.cmake`

This file defines several build options that can be configured when running CMake.
Expand Down
Loading
Loading