feat(boot+shell): add bootable disk image, unified scheduler and interactive user-space shell

- Implement Limine v8 boot protocol requests in dedicated PT_LOAD RW segment
- Configure IOPL=3 and SSE in arch setup for Ring 3 drivers and libc
- Unify scheduler context switching via switch_to and preempt_tick
- Support dual-source keyboard/serial input in sys_key_read
- Add automated 'make image' and 'make run' targets for instant QEMU launch
- Complete interactive UNIX-like shell (osh) with built-in commands & ramdisk
This commit is contained in:
RarDog
2026-09-02 19:47:57 +03:00
parent ca3555bd09
commit eed05c1eca
17 changed files with 452 additions and 217 deletions
+11 -4
View File
@@ -29,28 +29,33 @@ impl FrameAllocator {
pub unsafe fn init(&mut self, memmap: *const LimineMemmapResponse, hhdm: u64) {
self.hhdm_offset = hhdm;
if memmap.is_null() {
kprintln!("[PFA] ERROR: memmap is null!");
return;
}
let entry_count = (*memmap).entry_count as usize;
let entries = (*memmap).entries;
let entries_ptr = (*memmap).entries;
kprintln!("[PFA] entry_count={}, entries_ptr={:#018x}", entry_count, entries_ptr as u64);
let mut max_paddr: u64 = 0;
for i in 0..entry_count {
let entry = *entries.add(i);
let entry = *entries_ptr.add(i);
let end = (*entry).base + (*entry).length;
kprintln!("[PFA] entry[{}]: base={:#x} len={:#x} type={}", i, (*entry).base, (*entry).length, (*entry).typ);
if end > max_paddr {
max_paddr = end;
}
}
kprintln!("[PFA] max_paddr={:#x}", max_paddr);
self.total_frames = (max_paddr as usize) / PAGE_SIZE;
self.bitmap_size_bytes = (self.total_frames + 7) / 8;
kprintln!("[PFA] total_frames={}, bitmap_size={} bytes", self.total_frames, self.bitmap_size_bytes);
// Find a usable region large enough to place the bitmap
let mut bitmap_paddr: u64 = 0;
for i in 0..entry_count {
let entry = *entries.add(i);
let entry = *entries_ptr.add(i);
if (*entry).typ == LimineMemoryType::Usable as u64
&& (*entry).length >= self.bitmap_size_bytes as u64
{
@@ -63,13 +68,15 @@ impl FrameAllocator {
kprintln!("[FATAL] Could not find memory for PFA bitmap!");
return;
}
kprintln!("[PFA] Bitmap at phys={:#x}, virt={:#x}", bitmap_paddr, bitmap_paddr + hhdm);
self.bitmap = (bitmap_paddr + hhdm) as *mut u8;
core::ptr::write_bytes(self.bitmap, 0xFF, self.bitmap_size_bytes);
kprintln!("[PFA] Bitmap zeroed OK");
self.free_frames = 0;
for i in 0..entry_count {
let entry = *entries.add(i);
let entry = *entries_ptr.add(i);
if (*entry).typ == LimineMemoryType::Usable as u64 {
let start_frame = ((*entry).base as usize) / PAGE_SIZE;
let count = ((*entry).length as usize) / PAGE_SIZE;