Kernel Configuration
This document explains the kernel configuration options available in SlayerOS. These settings control the core behavior and features of the operating system.
Feature Flags
SlayerOS uses compile-time feature flags to enable or disable specific kernel features. These flags are defined in src/include/host/flags.h.
Core Features
// Enable/disable kernel features
#define ENABLE_SMP 1 // Symmetric Multiprocessing support
#define ENABLE_ACPI 1 // Advanced Configuration and Power Interface
#define ENABLE_APIC 1 // Advanced Programmable Interrupt Controller
#define ENABLE_SERIAL_LOGGING 1 // Serial port loggingMemory Management
// Memory management configuration
#define PAGE_SIZE 4096 // Size of memory pages in bytes
#define KERNEL_HEAP_INITIAL_SIZE (4 * 1024 * 1024) // 4MB initial heap
#define MAX_PHYSICAL_MEMORY (4ULL * 1024 * 1024 * 1024) // 4GB max physical memoryDebug Options
// Debug configuration
#define ENABLE_DEBUG_SYMBOLS 0 // Include debug symbols in release build
#define STACK_PROTECTOR 1 // Enable stack protection
#define HEAP_VALIDATION 0 // Enable heap validation (performance impact)Kernel Parameters
The kernel accepts several parameters that can be passed via the bootloader:
| Parameter | Description | Default |
|---|---|---|
debug | Enable debug output | Disabled |
serial | Enable serial output | Enabled |
vga | Use VGA text mode instead of framebuffer | Disabled |
noacpi | Disable ACPI | ACPI Enabled |
nomce | Disable Machine Check Exception handling | MCE Enabled |
Memory Layout
The kernel memory layout is defined in misc/linkage.ld:
KERNEL_VIRT_BASE = 0xFFFFFFFF80000000; /* Kernel virtual base address */
KERNEL_PHYS_BASE = 0x100000; /* Kernel physical base (1MB) */This places the kernel in the higher half of the virtual address space, starting at -2GB.
Interrupt Configuration
Interrupt handling can be configured in src/kernel/arch/interrupts.cxx:
// IRQ assignments
#define PIT_IRQ 0 // Programmable Interval Timer
#define KEYBOARD_IRQ 1 // Keyboard controller
#define CASCADE_IRQ 2 // Cascade for IRQs 8-15
#define COM1_IRQ 4 // Serial port COM1
#define MOUSE_IRQ 12 // PS/2 MouseScheduler Settings
The kernel scheduler can be configured in src/kernel/sched/scheduler.cxx:
// Scheduler configuration
#define TIMESLICE_MS 10 // Default timeslice in milliseconds
#define MAX_PRIORITY 32 // Number of priority levels
#define DEFAULT_PRIORITY 16 // Default process priorityCustomizing the Kernel
To customize the kernel configuration:
- Edit the appropriate configuration file
- Rebuild the kernel with
make clean && make - Test your changes in QEMU before deploying
Configuration Examples
Minimal Configuration
For a minimal system with reduced memory footprint:
#define ENABLE_SMP 0
#define ENABLE_ACPI 0
#define KERNEL_HEAP_INITIAL_SIZE (1 * 1024 * 1024) // 1MB initial heapDebug Configuration
For a debug-friendly configuration:
#define ENABLE_DEBUG_SYMBOLS 1
#define ENABLE_SERIAL_LOGGING 1
#define STACK_PROTECTOR 1
#define HEAP_VALIDATION 1Best Practices
- Only enable features you need to minimize kernel size and attack surface
- Test thoroughly after changing configuration options
- Consider hardware compatibility when disabling features like ACPI
- Document any custom configurations you create