How rcore-os/rcore-tutorial-v3 works
Main Components
• Bootloader: Represented by the “bootloader” directory and its associated binary. This component is responsible for the early initialization and transitioning control to the kernel.
• OS Kernel: The “os” directory contains the core of the operating system. Divide this into submodules including:
– Initialization and Bootstrapping (e.g., “entry.asm”, “main.rs”, “build.rs”)
– Memory Management (modules under “os/src/mm”, including frame allocator, heap allocator, page table management)
– Process and Task Management (subdirectories like “os/src/task” handling scheduling, task switching, context management)
– System Calls and Trap Handling (modules under “os/src/syscall” and “os/src/trap”)
– Device Drivers (organized in “os/src/drivers”: block devices, char devices, bus, GPU, input, network, and PLIC)
– Filesystem Support (components under “os/src/fs”) and integration with the easy-fs and easy-fs-fuse crates
– Synchronization primitives (found in “os/src/sync”) and logging components (“os/src/logging.rs”)
• User Space: The “user” directory contains user-level applications (shell, various demo binaries) that interact with the OS via system calls.
• File System Libraries: “easy-fs” and “easy-fs-fuse” provide filesystem functionality and likely interact with both the kernel and user-level processes.
• External Tools & Environment: Tools such as Qemu (for simulation) and possibly hardware (K210 boards) are targets for deployment. Also, there is a RustSBI (Supervisor Binary Interface) component used in bootloading.
Relationships and Interactions
• The Bootloader loads the OS Kernel into memory.
• The Kernel initializes its subsystems: memory management, device drivers, task management, file system, and system call interfaces.
• User applications (from the “user” directory) run on top of the Kernel and communicate via system calls.
• Filesystem libraries (easy-fs & easy-fs-fuse) interface with both kernel-level file system support and user-space applications.
• Device drivers facilitate I/O between the kernel and external hardware (or simulators such as Qemu).
• The system design should also indicate that debugging, logging, and testing are implemented (e.g., support for debug output through “os/src/logging.rs” and test workflows in .github/workflows).
Architectural Patterns
• Layered (or modular) design: clearly separated bootloader, kernel core (with subsystems), and user space
• Microkernel-style isolation may be implied by distinguishing kernel-level services (system calls, scheduling, memory management) from user-space applications
• Dependency injection and modular abstractions: showcases how device drivers and file systems are separate yet interrelated services