Skip to content
This repository was archived by the owner on Jan 4, 2026. It is now read-only.

Commit 80de4df

Browse files
authored
Merge pull request #173 from assembler-0/Development
Development
2 parents 6bdfaf8 + 3298096 commit 80de4df

21 files changed

Lines changed: 432 additions & 136 deletions

CMakeLists.txt

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ enable_language(ASM_NASM)
1515
# Module Path & Includes
1616
# ============================================================================
1717
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
18+
1819
include(cache)
20+
include(ccache)
1921
include(features)
2022
include(variable)
2123
include(dependencies)
@@ -38,7 +40,17 @@ else()
3840
endif()
3941

4042
if(NOT CMAKE_TOOLCHAIN_FILE)
41-
message(FATAL_ERROR "CMAKE_TOOLCHAIN_FILE is not set. Please provide a toolchain file.")
43+
message(WARNING "CMAKE_TOOLCHAIN_FILE is not set. Automatically selecting toolchain file...")
44+
if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
45+
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/cmake/toolchains/linux-x64.cmake" CACHE PATH "Toolchain file" FORCE)
46+
message(STATUS "Defaulting to Linux x86_64 toolchain file: ${CMAKE_TOOLCHAIN_FILE}")
47+
elseif (CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
48+
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/cmake/toolchains/macos-x64.cmake" CACHE PATH "Toolchain file" FORCE)
49+
message(STATUS "Defaulting to macOS x86_64 toolchain file: ${CMAKE_TOOLCHAIN_FILE}")
50+
elseif (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
51+
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/cmake/toolchains/windows-x64.cmake" CACHE PATH "Toolchain file" FORCE)
52+
message(STATUS "Defaulting to Windows x86_64 toolchain file: ${CMAKE_TOOLCHAIN_FILE}")
53+
endif()
4254
else()
4355
message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}")
4456
endif()
@@ -48,19 +60,14 @@ if(NOT CMAKE_BUILD_TYPE)
4860
message(WARNING "CMAKE_BUILD_TYPE not set. Defaulting to Release.")
4961
endif()
5062

51-
if(CMAKE_GENERATOR STREQUAL "Ninja")
52-
message(STATUS "CMake: Generator: ${CMAKE_GENERATOR}")
53-
else()
54-
message(WARNING "CMake: Non-Ninja generator detected: ${CMAKE_GENERATOR}. Ninja is recommended.")
55-
endif()
56-
5763
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64")
58-
message(STATUS "CMake: Target Architecture: ${CMAKE_SYSTEM_PROCESSOR}")
64+
message(STATUS "CMake Target Architecture: ${CMAKE_SYSTEM_PROCESSOR}")
5965
set(Rust_CARGO_TARGET "x86_64-unknown-none")
6066
else()
6167
message(FATAL_ERROR "Unsupported target architecture: ${CMAKE_SYSTEM_PROCESSOR}")
6268
endif()
6369

70+
message(STATUS "CMake Generator: ${CMAKE_GENERATOR}")
6471
message(STATUS "CMake Build Type: ${CMAKE_BUILD_TYPE}")
6572
message(STATUS "CMake Source Directory: ${CMAKE_SOURCE_DIR}")
6673
message(STATUS "CMake Binary Directory: ${CMAKE_BINARY_DIR}")
@@ -106,10 +113,6 @@ if (SILENT_BUILD)
106113
corrosion_add_target_rustflags(voidframe_spinlock "-A" "warnings" "-C" "link-arg=-s")
107114
endif()
108115

109-
# ============================================================================
110-
# Flags setup
111-
# ============================================================================
112-
113116
# ============================================================================
114117
# Kernel Linking
115118
# ============================================================================

cmake/ccache.cmake

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# ============================================================================
2+
# CCache Configuration for Faster Builds
3+
# ============================================================================
4+
5+
option(VF_ENABLE_CCACHE "Enable ccache for faster compilation" ON)
6+
7+
if(VF_ENABLE_CCACHE)
8+
find_program(CCACHE_PROGRAM ccache)
9+
if(CCACHE_PROGRAM)
10+
# Configure ccache
11+
set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_PROGRAM})
12+
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_PROGRAM})
13+
14+
# Set ccache options for kernel development
15+
set(ENV{CCACHE_SLOPPINESS} "file_macro,locale,time_macros")
16+
set(ENV{CCACHE_MAXSIZE} "2G")
17+
set(ENV{CCACHE_COMPRESS} "true")
18+
set(ENV{CCACHE_COMPRESSLEVEL} "6")
19+
20+
message(STATUS "ccache enabled: ${CCACHE_PROGRAM}")
21+
22+
# Show ccache stats
23+
execute_process(
24+
COMMAND ${CCACHE_PROGRAM} -s
25+
OUTPUT_VARIABLE CCACHE_STATS
26+
ERROR_QUIET
27+
)
28+
if(CCACHE_STATS)
29+
message(STATUS "ccache statistics:\n${CCACHE_STATS}")
30+
endif()
31+
else()
32+
message(WARNING "ccache requested but not found")
33+
endif()
34+
endif()

cmake/configuration.cmake

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,33 @@ option(AUTOMATIC_POST "Run POST automatically on boot" OFF)
66
option(DEBUG_SYMBOLS "Enable debug symbols" ON)
77
option(STACK_PROTECTION "Enable stack protection" ON)
88
option(SILENT_BUILD "Enable silent build (suppress warnings)" OFF)
9+
10+
option(VF_CONFIG_ENABLE_VMWARE_SVGA_II "Enable VMware SVGA II support" OFF)
11+
option(VF_CONFIG_ENABLE_CERBERUS_VFS_LOGGING "Enable Cerberus VFS logging" OFF)
12+
option(VF_CONFIG_CERBERUS_THREAT_REPORTING "Enable Cerberus threat reporting" OFF)
13+
option(VF_CONFIG_PANIC_OVERRIDE "Enable panic override" OFF)
14+
option(VF_CONFIG_LOAD_MB_MODULES "Enable multiboot module loading" OFF)
15+
16+
option(VF_CONFIG_ENABLE_XHCI "Enable XHCI support" ON)
17+
option(VF_CONFIG_ENABLE_VIRTIO "Enable VirtIO support" ON)
18+
option(VF_CONFIG_ENABLE_ISA "Enable ISA support" ON)
19+
option(VF_CONFIG_ENABLE_LPT "Enable LPT support" ON)
20+
option(VF_CONFIG_ENABLE_PCI "Enable PCI support" ON)
21+
option(VF_CONFIG_ENABLE_PS2 "Enable PS/2 support" ON)
22+
option(VF_CONFIG_ENABLE_IDE "Enable IDE support" ON)
23+
option(VF_CONFIG_ENABLE_VFCOMPOSITOR "Enable VFCompositor support" ON)
24+
option(VF_CONFIG_ENABLE_AHCI "Enable AHCI support" ON)
25+
option(VF_CONFIG_ENABLE_NVME "Enable NVMe support" ON)
26+
option(VF_CONFIG_ENABLE_GENERIC_SOUND "Enable Generic Sound support" ON)
27+
option(VF_CONFIG_RTC_CENTURY "Enable RTC Century support" ON)
28+
option(VF_CONFIG_ENFORCE_MEMORY_PROTECTION "Enforce memory protection" ON)
29+
option(VF_CONFIG_VM_HOST "Enable VM host optimizations" ON)
30+
option(VF_CONFIG_SNOOZE_ON_BOOT "Enable snooze on boot" ON)
31+
option(VF_CONFIG_USE_VFSHELL "Use VFShell as the default shell" ON)
32+
option(VF_CONFIG_USE_DYNAMOX "Use Dynamox" ON)
33+
option(VF_CONFIG_USE_ASTRA "Use Astra" ON)
34+
option(VF_CONFIG_USE_CERBERUS "Use Cerberus" ON)
35+
option(VF_CONFIG_CERBERUS_STACK_PROTECTION "Enable Cerberus stack protection" ON)
36+
option(VF_CONFIG_INTEL "Enable Intel-specific optimizations" ON)
37+
option(VF_CONFIG_ENABLE_OPIC "Enable OPIC support" ON)
38+
option(VF_CONFIG_VESA_FB "Enable VESA framebuffer support" ON)

cmake/features.cmake

Lines changed: 87 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,93 @@
11
# ============================================================================
22
# VoidFrame Feature Configuration Flags
33
# ============================================================================
4-
add_compile_definitions(
5-
VF_CONFIG_ENABLE_XHCI
6-
VF_CONFIG_ENABLE_VIRTIO
7-
VF_CONFIG_ENABLE_ISA
8-
VF_CONFIG_ENABLE_LPT
9-
VF_CONFIG_ENABLE_PCI
10-
VF_CONFIG_ENABLE_PS2
11-
VF_CONFIG_ENABLE_IDE
12-
VF_CONFIG_ENABLE_VFCOMPOSITOR
13-
VF_CONFIG_ENABLE_AHCI
14-
VF_CONFIG_ENABLE_NVME
15-
VF_CONFIG_ENABLE_GENERIC_SOUND
16-
VF_CONFIG_RTC_CENTURY
17-
VF_CONFIG_ENFORCE_MEMORY_PROTECTION
18-
VF_CONFIG_VM_HOST
19-
VF_CONFIG_SNOOZE_ON_BOOT
20-
VF_CONFIG_PROCINFO_CREATE_DEFAULT
21-
VF_CONFIG_USE_VFSHELL
22-
VF_CONFIG_USE_DYNAMOX
23-
VF_CONFIG_USE_ASTRA
24-
VF_CONFIG_USE_CERBERUS
25-
VF_CONFIG_CERBERUS_STACK_PROTECTION
26-
VF_CONFIG_INTEL
27-
VF_CONFIG_ENABLE_OPIC
28-
)
29-
30-
add_compile_definitions(
31-
# VF_CONFIG_ENABLE_VMWARE_SVGA_II
32-
# VF_CONFIG_ENABLE_CERBERUS_VFS_LOGGING
33-
# VF_CONFIG_CERBERUS_THREAT_REPORTING
34-
# VF_CONFIG_PROCINFO_AUTO_CLEANUP
35-
# VF_CONFIG_PANIC_OVERRIDE
36-
# VF_CONFIG_LOAD_MB_MODULES
37-
)
4+
5+
if(VF_CONFIG_ENABLE_XHCI)
6+
add_compile_definitions(VF_CONFIG_ENABLE_XHCI)
7+
endif()
8+
if(VF_CONFIG_ENABLE_VIRTIO)
9+
add_compile_definitions(VF_CONFIG_ENABLE_VIRTIO)
10+
endif()
11+
if(VF_CONFIG_ENABLE_ISA)
12+
add_compile_definitions(VF_CONFIG_ENABLE_ISA)
13+
endif()
14+
if(VF_CONFIG_ENABLE_LPT)
15+
add_compile_definitions(VF_CONFIG_ENABLE_LPT)
16+
endif()
17+
if(VF_CONFIG_ENABLE_PCI)
18+
add_compile_definitions(VF_CONFIG_ENABLE_PCI)
19+
endif()
20+
if(VF_CONFIG_ENABLE_PS2)
21+
add_compile_definitions(VF_CONFIG_ENABLE_PS2)
22+
endif()
23+
if(VF_CONFIG_ENABLE_IDE)
24+
add_compile_definitions(VF_CONFIG_ENABLE_IDE)
25+
endif()
26+
if(VF_CONFIG_ENABLE_VFCOMPOSITOR)
27+
add_compile_definitions(VF_CONFIG_ENABLE_VFCOMPOSITOR)
28+
endif()
29+
if(VF_CONFIG_ENABLE_AHCI)
30+
add_compile_definitions(VF_CONFIG_ENABLE_AHCI)
31+
endif()
32+
if(VF_CONFIG_ENABLE_NVME)
33+
add_compile_definitions(VF_CONFIG_ENABLE_NVME)
34+
endif()
35+
if(VF_CONFIG_ENABLE_GENERIC_SOUND)
36+
add_compile_definitions(VF_CONFIG_ENABLE_GENERIC_SOUND)
37+
endif()
38+
if(VF_CONFIG_RTC_CENTURY)
39+
add_compile_definitions(VF_CONFIG_RTC_CENTURY)
40+
endif()
41+
if(VF_CONFIG_ENFORCE_MEMORY_PROTECTION)
42+
add_compile_definitions(VF_CONFIG_ENFORCE_MEMORY_PROTECTION)
43+
endif()
44+
if(VF_CONFIG_VM_HOST)
45+
add_compile_definitions(VF_CONFIG_VM_HOST)
46+
endif()
47+
if(VF_CONFIG_SNOOZE_ON_BOOT)
48+
add_compile_definitions(VF_CONFIG_SNOOZE_ON_BOOT)
49+
endif()
50+
if(VF_CONFIG_USE_VFSHELL)
51+
add_compile_definitions(VF_CONFIG_USE_VFSHELL)
52+
endif()
53+
if(VF_CONFIG_USE_DYNAMOX)
54+
add_compile_definitions(VF_CONFIG_USE_DYNAMOX)
55+
endif()
56+
if(VF_CONFIG_USE_ASTRA)
57+
add_compile_definitions(VF_CONFIG_USE_ASTRA)
58+
endif()
59+
if(VF_CONFIG_USE_CERBERUS)
60+
add_compile_definitions(VF_CONFIG_USE_CERBERUS)
61+
endif()
62+
if(VF_CONFIG_CERBERUS_STACK_PROTECTION)
63+
add_compile_definitions(VF_CONFIG_CERBERUS_STACK_PROTECTION)
64+
endif()
65+
if(VF_CONFIG_INTEL)
66+
add_compile_definitions(VF_CONFIG_INTEL)
67+
endif()
68+
if(VF_CONFIG_ENABLE_OPIC)
69+
add_compile_definitions(VF_CONFIG_ENABLE_OPIC)
70+
endif()
71+
72+
if(VF_CONFIG_ENABLE_VMWARE_SVGA_II)
73+
add_compile_definitions(VF_CONFIG_ENABLE_VMWARE_SVGA_II)
74+
endif()
75+
76+
if(VF_CONFIG_ENABLE_CERBERUS_VFS_LOGGING)
77+
add_compile_definitions(VF_CONFIG_ENABLE_CERBERUS_VFS_LOGGING)
78+
endif()
79+
80+
if(VF_CONFIG_CERBERUS_THREAT_REPORTING)
81+
add_compile_definitions(VF_CONFIG_CERBERUS_THREAT_REPORTING)
82+
endif()
83+
84+
if(VF_CONFIG_PANIC_OVERRIDE)
85+
add_compile_definitions(VF_CONFIG_PANIC_OVERRIDE)
86+
endif()
87+
88+
if(VF_CONFIG_LOAD_MB_MODULES)
89+
add_compile_definitions(VF_CONFIG_LOAD_MB_MODULES)
90+
endif()
3891

3992
if(EXCLUDE_EXTRA_OBJECTS)
4093
add_compile_definitions(VF_CONFIG_EXCLUDE_EXTRA_OBJECTS)

cmake/flags.cmake

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,9 @@ endif()
2222

2323
set(CMAKE_C_FLAGS "${C_FLAGS}")
2424
set(CMAKE_CXX_FLAGS "${C_FLAGS} -fno-exceptions -fno-rtti -fno-threadsafe-statics")
25-
set(CMAKE_ASM_NASM_FLAGS "-f elf64 -DVF_CONFIG_VESA_FB")
25+
26+
set(ASM_NASM_FLAGS "-f elf64")
27+
if(VF_CONFIG_VESA_FB)
28+
string(APPEND ASM_NASM_FLAGS " -DVF_CONFIG_VESA_FB")
29+
endif()
30+
set(CMAKE_ASM_NASM_FLAGS "${ASM_NASM_FLAGS}")

fs/DriveNaming.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ void GenerateDriveNameInto(BlockDeviceType type, char* out_name) {
1313
else rust_spinlock_lock(dn_lock);
1414
switch (type) {
1515
case DEVICE_TYPE_IDE:
16-
FormatA(out_name, 16, "hd%c", 'a' + ide_count++);
16+
snprintf(out_name, 16, "hd%c", 'a' + ide_count++);
1717
break;
1818
case DEVICE_TYPE_AHCI:
19-
FormatA(out_name, 16, "sd%c", 'a' + ahci_count++);
19+
snprintf(out_name, 16, "sd%c", 'a' + ahci_count++);
2020
break;
2121
case DEVICE_TYPE_NVME:
22-
FormatA(out_name, 16, "nvme%d", nvme_count++);
22+
snprintf(out_name, 16, "nvme%d", nvme_count++);
2323
break;
2424
case DEVICE_TYPE_VIRTIO:
25-
FormatA(out_name, 16, "vd%c", 'a' + virtio_count++);
25+
snprintf(out_name, 16, "vd%c", 'a' + virtio_count++);
2626
break;
2727
default:
28-
FormatA(out_name, 16, "unk%d", 0);
28+
snprintf(out_name, 16, "unk%d", 0);
2929
break;
3030
}
3131
rust_spinlock_unlock(dn_lock);

fs/FileSystem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void FileSystemAutoMount() {
7878
PrintKernel("\n");
7979
// Simple mount point naming for now
8080
char mount_point[64];
81-
FormatA(mount_point, sizeof(mount_point), "%s/%s", RuntimeMounts, dev->name);
81+
snprintf(mount_point, sizeof(mount_point), "%s/%s", RuntimeMounts, dev->name);
8282
PrintKernel("FS: Mounting at ");
8383
PrintKernel(mount_point);
8484
PrintKernel("\n");

fs/Iso9660.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,8 @@ int Iso9660Copy(const char* iso_path, const char* vfs_path) {
491491
char vfs_filepath[256];
492492
char iso_filepath[256];
493493

494-
FormatA(vfs_filepath, sizeof(vfs_filepath), "%s/%s", vfs_path, filename);
495-
FormatA(iso_filepath, sizeof(iso_filepath), "%s/%s", iso_path, filename);
494+
snprintf(vfs_filepath, sizeof(vfs_filepath), "%s/%s", vfs_path, filename);
495+
snprintf(iso_filepath, sizeof(iso_filepath), "%s/%s", iso_path, filename);
496496

497497
if (entries[i]->file_flags & 2) { // Directory
498498
Iso9660Copy(iso_filepath, vfs_filepath);

fs/MBR.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void ParseMBR(BlockDevice* device) {
7272

7373
if (p->type != 0 && p->num_sectors > 0) {
7474
char part_name[32];
75-
FormatA(part_name, sizeof(part_name), "%s-p%d", device->name, i + 1);
75+
snprintf(part_name, sizeof(part_name), "%s-p%d", device->name, i + 1);
7676

7777
PrintKernel("MBR: Registering partition ");
7878
PrintKernel(part_name);

fs/procfs/ProcFS.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ int ProcfsReadFile(const char* path, void* buffer, uint32_t max_size) {
7575
char local_buffer[1024];
7676

7777
if (FastStrCmp(filename, "info") == 0) {
78-
int len = FormatA(local_buffer, sizeof(local_buffer),
78+
int len = snprintf(local_buffer, sizeof(local_buffer),
7979
"Name: %s\n"
8080
"PID: %u\n"
8181
"State: %d\n"

0 commit comments

Comments
 (0)