aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBobby <[email protected]>2026-02-20 17:15:22 +0530
committerBobby <[email protected]>2026-02-20 17:15:22 +0530
commit11529f20f7710771bd517648a71bc044ee37e825 (patch)
treea63180da5342c17ed8ce340b172e2f15e027847a
parent3f68f9d0d1f833811eb60a577327e41404eba2b5 (diff)
downloadakiba-11529f20f7710771bd517648a71bc044ee37e825.tar.xz
akiba-11529f20f7710771bd517648a71bc044ee37e825.zip
feat: Remove deprecated system constants and limits modules
-rw-r--r--mirai/system/constants.zig274
-rw-r--r--mirai/system/limits.zig101
-rw-r--r--mirai/system/system.zig26
3 files changed, 0 insertions, 401 deletions
diff --git a/mirai/system/constants.zig b/mirai/system/constants.zig
deleted file mode 100644
index ed23c58..0000000
--- a/mirai/system/constants.zig
+++ /dev/null
@@ -1,274 +0,0 @@
-//! System Constants - Memory layout, addresses, and architectural constants
-//! This is the single source of truth for all memory-related and system-wide constants
-
-// ============================================================================
-// Page and Memory Block Sizes
-// ============================================================================
-
-/// Standard page size (4KB on x86-64)
-pub const PAGE_SIZE: u64 = 4096;
-
-/// Page offset mask (bits 0-11)
-pub const PAGE_OFFSET_MASK: u64 = 0xFFF;
-
-/// Page frame mask (clears offset bits)
-pub const PAGE_FRAME_MASK: u64 = ~PAGE_OFFSET_MASK;
-
-// ============================================================================
-// Memory Address Space Layout
-// ============================================================================
-
-/// Higher-half kernel space start (canonical address boundary)
-pub const HIGHER_HALF_START: u64 = 0xFFFF800000000000;
-
-/// Kernel physical start address (loaded at 1MB)
-pub const KERNEL_PHYSICAL_START: u64 = 0x100000;
-
-/// Kernel physical end address
-pub const KERNEL_PHYSICAL_END: u64 = 0x500000;
-
-/// Virtual address where kernel is mapped
-pub const KERNEL_VIRTUAL_START: u64 = HIGHER_HALF_START + KERNEL_PHYSICAL_START;
-
-/// External linker symbol marking the end of the kernel binary
-extern const _kernel_end: u8;
-
-/// Dynamically calculate the physical address where kernel binary ends
-/// The linker places _kernel_end at the end of .bss section
-/// This symbol's address is in the linker's address space (starts at 0x100000)
-pub fn KERNEL_END() u64 {
- // Get the link-time address of the symbol
- const link_addr = @intFromPtr(&_kernel_end);
- // The linker script starts at 0x100000, so this is already a physical address
- // but we need to handle if it's in higher-half or identity mapping
- if (link_addr >= HIGHER_HALF_START) {
- // Symbol accessed through higher-half mapping, convert to physical
- return link_addr - HIGHER_HALF_START;
- } else {
- // Symbol accessed through identity mapping or direct physical address
- return link_addr;
- }
-}
-
-// ============================================================================
-// User Address Space Layout
-// ============================================================================
-
-/// Userspace virtual address start (first valid page after null page)
-pub const USER_SPACE_START: u64 = 0x1000;
-
-/// Userspace virtual address maximum (canonical address boundary)
-pub const USER_SPACE_END: u64 = 0x0000800000000000;
-
-// ============================================================================
-// Stack Configuration
-// ============================================================================
-
-/// User stack top address (grows downward)
-pub const USER_STACK_TOP: u64 = 0x00007FFFFFF00000;
-
-/// Number of pages allocated for user stack
-pub const USER_STACK_PAGES: u64 = 64; // 256KB
-
-/// Total user stack size in bytes
-pub const USER_STACK_SIZE: u64 = USER_STACK_PAGES * PAGE_SIZE;
-
-/// Kernel stack size per process (one page)
-pub const KERNEL_STACK_SIZE: u64 = PAGE_SIZE;
-
-// ============================================================================
-// Page Table Entry Flags
-// ============================================================================
-
-/// Page is present in memory
-pub const PTE_PRESENT: u64 = 1 << 0;
-
-/// Page is writable
-pub const PTE_WRITABLE: u64 = 1 << 1;
-
-/// Page is accessible from user mode
-pub const PTE_USER: u64 = 1 << 2;
-
-/// Page has write-through caching
-pub const PTE_WRITE_THROUGH: u64 = 1 << 3;
-
-/// Page caching is disabled
-pub const PTE_CACHE_DISABLE: u64 = 1 << 4;
-
-/// Page has been accessed
-pub const PTE_ACCESSED: u64 = 1 << 5;
-
-/// Page has been written to
-pub const PTE_DIRTY: u64 = 1 << 6;
-
-/// Page is a huge page (2MB or 1GB)
-pub const PTE_HUGE_PAGE: u64 = 1 << 7;
-
-/// Page is global (not flushed on CR3 reload)
-pub const PTE_GLOBAL: u64 = 1 << 8;
-
-/// Execute disable bit
-pub const PTE_NO_EXECUTE: u64 = 1 << 63;
-
-// ============================================================================
-// Page Table Structure
-// ============================================================================
-
-/// Number of entries in each page table level
-pub const PAGE_TABLE_ENTRIES: usize = 512;
-
-/// Shift for PML4 index (bits 39-47)
-pub const PML4_SHIFT: u6 = 39;
-
-/// Shift for PDPT index (bits 30-38)
-pub const PDPT_SHIFT: u6 = 30;
-
-/// Shift for PD index (bits 21-29)
-pub const PD_SHIFT: u6 = 21;
-
-/// Shift for PT index (bits 12-20)
-pub const PT_SHIFT: u6 = 12;
-
-/// Mask for table indices (9 bits = 512 entries)
-pub const TABLE_INDEX_MASK: u64 = 0x1FF;
-
-// ============================================================================
-// Interrupt and Exception Vectors
-// ============================================================================
-
-/// Divide by zero exception
-pub const EXCEPTION_DIVIDE_ERROR: u8 = 0;
-
-/// Debug exception
-pub const EXCEPTION_DEBUG: u8 = 1;
-
-/// Non-maskable interrupt
-pub const EXCEPTION_NMI: u8 = 2;
-
-/// Breakpoint exception
-pub const EXCEPTION_BREAKPOINT: u8 = 3;
-
-/// Overflow exception
-pub const EXCEPTION_OVERFLOW: u8 = 4;
-
-/// Bound range exceeded
-pub const EXCEPTION_BOUND_RANGE: u8 = 5;
-
-/// Invalid opcode
-pub const EXCEPTION_INVALID_OPCODE: u8 = 6;
-
-/// Device not available
-pub const EXCEPTION_DEVICE_NOT_AVAILABLE: u8 = 7;
-
-/// Double fault
-pub const EXCEPTION_DOUBLE_FAULT: u8 = 8;
-
-/// Invalid TSS
-pub const EXCEPTION_INVALID_TSS: u8 = 10;
-
-/// Segment not present
-pub const EXCEPTION_SEGMENT_NOT_PRESENT: u8 = 11;
-
-/// Stack-segment fault
-pub const EXCEPTION_STACK_FAULT: u8 = 12;
-
-/// General protection fault
-pub const EXCEPTION_GENERAL_PROTECTION: u8 = 13;
-
-/// Page fault
-pub const EXCEPTION_PAGE_FAULT: u8 = 14;
-
-/// x87 FPU error
-pub const EXCEPTION_FPU_ERROR: u8 = 16;
-
-/// Alignment check
-pub const EXCEPTION_ALIGNMENT_CHECK: u8 = 17;
-
-/// Machine check
-pub const EXCEPTION_MACHINE_CHECK: u8 = 18;
-
-/// SIMD floating-point exception
-pub const EXCEPTION_SIMD_EXCEPTION: u8 = 19;
-
-/// Timer interrupt vector (IRQ 0)
-pub const IRQ_TIMER: u8 = 32;
-
-/// Keyboard interrupt vector (IRQ 1)
-pub const IRQ_KEYBOARD: u8 = 33;
-
-/// Syscall interrupt vector
-pub const INTERRUPT_SYSCALL: u8 = 0x80;
-
-// ============================================================================
-// Timing Constants
-// ============================================================================
-
-/// Timer tick frequency (nanoseconds per tick)
-pub const TIMER_TICK_NS: u64 = 1_000_000; // 1ms
-
-/// Scheduler time slice (in timer ticks)
-pub const SCHEDULER_TIME_SLICE: u64 = 10; // 10ms
-
-// ============================================================================
-// Sector and Block Sizes
-// ============================================================================
-
-/// Standard disk sector size
-pub const SECTOR_SIZE: usize = 512;
-
-/// Standard cluster size for filesystem
-pub const CLUSTER_SIZE: usize = 4096;
-
-// ============================================================================
-// Helper Functions
-// ============================================================================
-
-/// Align address down to page boundary
-pub inline fn align_down(addr: u64) u64 {
- return addr & PAGE_FRAME_MASK;
-}
-
-/// Align address up to page boundary
-pub inline fn align_up(addr: u64) u64 {
- return (addr + PAGE_SIZE - 1) & PAGE_FRAME_MASK;
-}
-
-/// Calculate number of pages needed for given size
-pub inline fn pages_for_size(size: u64) u64 {
- return (size + PAGE_SIZE - 1) / PAGE_SIZE;
-}
-
-/// Check if address is page-aligned
-pub inline fn is_page_aligned(addr: u64) bool {
- return (addr & PAGE_OFFSET_MASK) == 0;
-}
-
-/// Extract PML4 index from virtual address
-pub inline fn pml4_index(vaddr: u64) u64 {
- return (vaddr >> PML4_SHIFT) & TABLE_INDEX_MASK;
-}
-
-/// Extract PDPT index from virtual address
-pub inline fn pdpt_index(vaddr: u64) u64 {
- return (vaddr >> PDPT_SHIFT) & TABLE_INDEX_MASK;
-}
-
-/// Extract PD index from virtual address
-pub inline fn pd_index(vaddr: u64) u64 {
- return (vaddr >> PD_SHIFT) & TABLE_INDEX_MASK;
-}
-
-/// Extract PT index from virtual address
-pub inline fn pt_index(vaddr: u64) u64 {
- return (vaddr >> PT_SHIFT) & TABLE_INDEX_MASK;
-}
-
-/// Get physical address from higher-half virtual address
-pub inline fn virt_to_phys(vaddr: u64) u64 {
- return vaddr - HIGHER_HALF_START;
-}
-
-/// Get higher-half virtual address from physical address
-pub inline fn phys_to_virt(paddr: u64) u64 {
- return paddr + HIGHER_HALF_START;
-}
diff --git a/mirai/system/limits.zig b/mirai/system/limits.zig
deleted file mode 100644
index 916cab1..0000000
--- a/mirai/system/limits.zig
+++ /dev/null
@@ -1,101 +0,0 @@
-//! System-wide limits and constants for Akiba OS
-//! Centralizes all magic numbers and hardcoded values in one place
-
-const constants = @import("constants.zig");
-
-// ============================================================================
-// Memory Address Space Layout
-// ============================================================================
-
-/// Userspace virtual address maximum (below higher-half)
-pub const USER_SPACE_MAX: u64 = constants.USER_SPACE_END;
-
-/// First valid userspace page (page 0 is always invalid for null pointer detection)
-pub const USER_SPACE_MIN: u64 = constants.USER_SPACE_START;
-
-/// Higher-half kernel space start
-pub const KERNEL_SPACE_START: u64 = constants.HIGHER_HALF_START;
-
-// ============================================================================
-// File System Limits
-// ============================================================================
-
-/// Maximum file size that can be loaded into memory (1MB)
-pub const MAX_FILE_SIZE: u64 = 1024 * 1024;
-
-/// Maximum path length for files
-pub const MAX_PATH_LENGTH: usize = 255;
-
-/// Maximum filename component length
-pub const MAX_FILENAME_LENGTH: usize = 255;
-
-// ============================================================================
-// I/O Limits
-// ============================================================================
-
-/// Maximum size for a single write operation (1MB)
-pub const MAX_WRITE_SIZE: u64 = 1024 * 1024;
-
-/// Maximum size for a single read operation (1MB)
-pub const MAX_READ_SIZE: u64 = 1024 * 1024;
-
-/// Kernel buffer size for copying userspace data
-pub const KERNEL_COPY_BUFFER_SIZE: usize = 256;
-
-// ============================================================================
-// Process Limits
-// ============================================================================
-
-/// Maximum number of concurrent processes (katas)
-pub const MAX_PROCESSES: usize = 256;
-
-/// Maximum number of open file descriptors per process
-pub const MAX_FILE_DESCRIPTORS: usize = 16;
-
-/// Maximum command line arguments
-pub const MAX_ARGS: usize = 32;
-
-/// Maximum environment variables
-pub const MAX_ENV_VARS: usize = 64;
-
-// ============================================================================
-// String and Buffer Limits
-// ============================================================================
-
-/// Maximum string length for syscall string parameters
-pub const MAX_STRING_LENGTH: usize = 4096;
-
-/// Maximum working directory path length
-pub const MAX_CWD_LENGTH: usize = 256;
-
-// Maximum postman letter length
-pub const MAX_LETTER_LENGTH: usize = 256;
-
-// ============================================================================
-// Validation Helpers
-// ============================================================================
-
-/// Check if a pointer is in valid userspace range
-pub inline fn is_valid_user_pointer(ptr: u64) bool {
- return ptr >= USER_SPACE_MIN and ptr < USER_SPACE_MAX;
-}
-
-/// Check if a virtual address is in userspace
-pub inline fn is_userspace_address(addr: u64) bool {
- return addr < USER_SPACE_MAX;
-}
-
-/// Check if a virtual address is in kernel space
-pub inline fn is_kernel_address(addr: u64) bool {
- return addr >= KERNEL_SPACE_START;
-}
-
-/// Check if a memory range is entirely within userspace
-pub inline fn is_userspace_range(start: u64, size: u64) bool {
- if (start >= USER_SPACE_MAX) return false;
- if (size == 0) return true;
- // Check for overflow
- const end = start +% size;
- if (end < start) return false; // Overflow occurred
- return end <= USER_SPACE_MAX;
-}
diff --git a/mirai/system/system.zig b/mirai/system/system.zig
deleted file mode 100644
index 5882d49..0000000
--- a/mirai/system/system.zig
+++ /dev/null
@@ -1,26 +0,0 @@
-//! Akiba OS System Module
-//! Central import point for all system-wide constants, limits, and utilities
-
-// System constants (memory layout, addresses, architectural constants)
-pub const constants = @import("constants.zig");
-
-// System limits (process limits, buffer sizes, validation)
-pub const limits = @import("limits.zig");
-
-// Re-export commonly used constants for convenience
-pub const PAGE_SIZE = constants.PAGE_SIZE;
-pub const HIGHER_HALF_START = constants.HIGHER_HALF_START;
-pub const USER_SPACE_MAX = limits.USER_SPACE_MAX;
-pub const USER_SPACE_MIN = limits.USER_SPACE_MIN;
-
-// Re-export validation helpers
-pub const is_valid_user_pointer = limits.is_valid_user_pointer;
-pub const is_userspace_address = limits.is_userspace_address;
-pub const is_kernel_address = limits.is_kernel_address;
-pub const is_userspace_range = limits.is_userspace_range;
-
-// Re-export memory helpers
-pub const align_down = constants.align_down;
-pub const align_up = constants.align_up;
-pub const pages_for_size = constants.pages_for_size;
-pub const is_page_aligned = constants.is_page_aligned;