Overview
This merge request extends the kernel memory management and system call infrastructure to support safe hardware memory mapping and advanced Copy-on-Write (CoW) based features.
The changes enable user programs to directly access GPU framebuffer memory via MMIO while preserving kernel memory safety, and demonstrate the performance advantage of CoW through snapshot and time-travel mechanisms.
Key Changes
1. Memory Management (MM)
- Introduced
MapType::Mmioto explicitly mark hardware-mapped memory. - Prevented accidental deallocation of MMIO pages during address space teardown.
- Added
insert_mmio_areato map fixed physical addresses into user space. - Ensured correct handling of MMIO regions during
munmapand process exit. - Implemented shared mapping strategy for MMIO regions during address space duplication (fork / checkpoint) to ensure visual continuity and prevent invalid memory allocation.
2. System Call Layer
- Fixed incorrect virtual-to-physical address usage in framebuffer-related syscalls.
- Implemented kernel virtual address → physical address translation before mapping.
- Replaced hard-coded user virtual addresses with dynamic free-region allocation.
3. Driver Interface
- Extended the GPU driver interface to expose the raw framebuffer physical address.
- Enabled the syscall layer to safely obtain MMIO information from the device driver.
4. User Library & Applications
- Refactored framebuffer APIs to avoid naming conflicts with syscalls.
- Enabled automatic resolution detection in user-space display initialization.
- Updated GUI demo programs to use the new framebuffer mapping mechanism.
- Added snapshot / save-load support for the GUI snake game based on CoW.
Demonstration & Validation
- User-level GUI programs render correctly using MMIO-mapped framebuffer memory.
- Verified that MMIO regions persist correctly across snapshots without triggering kernel panics.
- Snapshot and time-travel tests demonstrate constant-time
fork()behavior regardless of memory size, validating the effectiveness of CoW. - No hardware memory is mistakenly freed during process exit or unmapping.
Notes for Reviewers
- MMIO regions are explicitly protected and never passed to the frame allocator.
- All framebuffer mappings are created using translated physical addresses.
- The changes are backward-compatible with existing user programs.