Experimental RISC-V64 Kernel Written in Rust
elinOS is an experimental operating system kernel designed for research, learning, and exploring advanced memory management techniques. Built entirely in Rust for RISC-V architecture, it features dynamic hardware detection, sophisticated multi-tier memory allocators, real filesystem implementations, and a comprehensive Linux-compatible system call interface.
- Multi-Tier Architecture: Buddy allocator + Slab allocator + Fallible operations
- Dynamic Hardware Detection: Automatically detects available RAM and configures allocators
- Memory Zones: DMA, Normal, and High memory zone support with automatic detection
- Adaptive Sizing: Buffer sizes and allocator configurations scale based on detected memory
- Sophisticated Allocation: Handles everything from 8-byte objects to multi-megabyte allocations
- Multi-Filesystem: Native FAT32 and ext2 implementations with automatic detection
- Auto-Detection: Probes boot sectors and superblocks to identify filesystem type
- ext2 Features: Superblock validation, inode parsing, extent tree traversal, group descriptors
- File Operations: Create, read, write, delete files and directories
- VirtIO Block Device: Full VirtIO 1.0/1.1 support with auto-detection
- Dynamic Buffering: File buffers scale from 4KB to 1MB+ based on available memory
- RISC-V 64-bit: Native support for RV64GC with supervisor mode and interrupt handling
- Linux-Compatible System Calls: 100+ system calls across 8 categories
- Memory Safety: Zero-cost abstractions with comprehensive error handling
- SBI Integration: Full SBI (Supervisor Binary Interface) support
- Trap Handling: Complete interrupt and exception handling system
- Virtual Memory: Software MMU implementation with memory protection
- Built-in Commands: 20+ shell commands for system interaction
- File System Operations:
ls
,cat
,touch
,mkdir
,rm
,rmdir
,cd
,pwd
- System Monitoring:
memory
,devices
,config
,syscall
,version
- Real-time Diagnostics: Live system statistics and device information
- Path Resolution: Full path resolution with
.
and..
support - Modular Design: Separate shell crate for clean architecture
# Install Rust toolchain
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Add RISC-V target
rustup target add riscv64gc-unknown-none-elf
# Install QEMU (example for Ubuntu/Debian)
sudo apt install qemu-system-riscv64
# Install build tools
sudo apt install build-essential git gcc-riscv64-unknown-elf python3-pexpect
# Clone the repository
git clone https://github.com/username/elinOS.git
cd elinOS
# Build the kernel
make build
# Automated kernel functional test
make test
# Run the kernel in QEMU
make run-qemu
- Architecture: RISC-V 64-bit (RV64GC)
- Memory: 8MB minimum, 8GB+ maximum (auto-scaling)
- Storage: VirtIO block devices (legacy 1.0 and modern 1.1+)
- Platform: QEMU
virt
machine, SiFive boards, and compatible hardware
- Rust: Nightly toolchain with
riscv64gc-unknown-none-elf
target - QEMU: 5.0+ with RISC-V system emulation
- Build Tools: GNU Make, GCC toolchain
┌─────────────────────────────────────────────────────────────┐
│ User Space │
│ (Future Development) │
├─────────────────────────────────────────────────────────────┤
│ System Call Interface │
│ (Linux-compatible: 100+ syscalls) │
│ 8 Categories │
├─────────────────────────────────────────────────────────────┤
│ elinOS Kernel │
│ │
│ ┌─────────────────┐ ┌─────────────────┐ ┌───────────────┐ │
│ │ Memory Manager │ │ Filesystem │ │ Device Mgmt │ │
│ │ │ │ │ │ │ │
│ │ • Buddy Alloc │ │ • ext2 │ │ • VirtIO 1.1 │ │
│ │ • Slab Alloc │ │ • Auto-detect │ │ • Auto-detect │ │
│ │ • Fallible Ops │ │ • File CRUD │ │ • SBI Runtime │ │
│ │ • Auto-scaling │ │ • Path resolve │ │ • Trap Handle │ │
│ └─────────────────┘ └─────────────────┘ └───────────────┘ │
├─────────────────────────────────────────────────────────────┤
│ Hardware Abstraction │
│ (RISC-V + SBI + VirtIO + MMU) │
└─────────────────────────────────────────────────────────────┘
elinOS> ls [path] # List files and directories
elinOS> cat <filename> # Display file contents
elinOS> touch <filename> # Create empty file
elinOS> mkdir <dirname> # Create directory
elinOS> rm <filename> # Remove file
elinOS> rmdir <dirname> # Remove empty directory
elinOS> cd <path> # Change directory
elinOS> pwd # Show current directory
elinOS> help # Show all available commands
elinOS> version # Kernel version and features
elinOS> config # Display system configuration
elinOS> memory # Memory layout and allocator stats
elinOS> heap # Detailed heap information
elinOS> devices # List detected VirtIO devices
elinOS> syscall # Show system call information
elinOS> fscheck # Filesystem status and info
elinOS> echo <message> # Print message
elinOS> shutdown # Graceful system shutdown
elinOS> reboot # System reboot
elinOS is designed for:
- Memory Management Research: Testing advanced allocation strategies
- Filesystem Development: Real filesystem implementation learning
- OS Kernel Development: Understanding kernel architecture concepts
- RISC-V Development: Exploring RISC-V architecture features
- System Programming: Learning low-level Rust programming
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Make your changes
- Test thoroughly (
make test
) - Commit with clear messages
- Push to your branch
- Open a Pull Request
- Follow Rust best practices and idioms
- Maintain
#![no_std]
compatibility - Document public APIs thoroughly
- Include tests for new functionality
- Ensure memory safety and performance
- Dynamic memory management with buddy + slab allocators
- Hardware auto-detection and adaptive sizing
- Complete FAT32 and ext2 filesystem implementations
- 100+ Linux-compatible system calls
- Interactive shell with 20+ commands
- VirtIO block device support
- Comprehensive trap and interrupt handling
- Virtual memory management (software MMU)
- basic ELF program loading and execution
- Advanced ELF program loading and execution
- User-space process management
- Advanced memory protection (hardware MMU)
- Improved filesystem write operations
- Network stack implementation
- SMP (multi-core) support
- Advanced scheduler with priority queues
- Device driver framework
- IPC mechanisms (pipes, shared memory)
- Security hardening and capability system
- Performance optimizations
- User Space: No user processes yet (kernel-only)
- Networking: System calls defined but not implemented
- SMP: Single-core only
- Hardware: Limited to QEMU and compatible platforms
- Debugging: Basic debugging support
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.