feat(shell): implement full interactive UNIX shell (osh), CMOS RTC, dual serial+PS2 keyboard input, and power management
This commit is contained in:
+5
-10
@@ -7,11 +7,11 @@ use crate::kprintln;
|
||||
pub const PAGE_SIZE: usize = 4096;
|
||||
|
||||
pub struct FrameAllocator {
|
||||
bitmap: *mut u8,
|
||||
bitmap_size_bytes: usize,
|
||||
total_frames: usize,
|
||||
free_frames: usize,
|
||||
hhdm_offset: u64,
|
||||
pub bitmap: *mut u8,
|
||||
pub bitmap_size_bytes: usize,
|
||||
pub total_frames: usize,
|
||||
pub free_frames: usize,
|
||||
pub hhdm_offset: u64,
|
||||
}
|
||||
|
||||
unsafe impl Send for FrameAllocator {}
|
||||
@@ -65,10 +65,8 @@ impl FrameAllocator {
|
||||
}
|
||||
|
||||
self.bitmap = (bitmap_paddr + hhdm) as *mut u8;
|
||||
// Initially mark all frames as used (1)
|
||||
core::ptr::write_bytes(self.bitmap, 0xFF, self.bitmap_size_bytes);
|
||||
|
||||
// Mark only truly usable RAM regions as free (0)
|
||||
self.free_frames = 0;
|
||||
for i in 0..entry_count {
|
||||
let entry = *entries.add(i);
|
||||
@@ -82,7 +80,6 @@ impl FrameAllocator {
|
||||
}
|
||||
}
|
||||
|
||||
// Mark the bitmap memory itself as allocated
|
||||
let bitmap_start_frame = (bitmap_paddr as usize) / PAGE_SIZE;
|
||||
let bitmap_frame_count = (self.bitmap_size_bytes + PAGE_SIZE - 1) / PAGE_SIZE;
|
||||
for f in bitmap_start_frame..(bitmap_start_frame + bitmap_frame_count) {
|
||||
@@ -92,7 +89,6 @@ impl FrameAllocator {
|
||||
}
|
||||
}
|
||||
|
||||
// Also protect low 1MiB
|
||||
let low_1mb_frames = 0x100000 / PAGE_SIZE;
|
||||
for f in 0..low_1mb_frames {
|
||||
if !self.test_bit(f) {
|
||||
@@ -146,7 +142,6 @@ impl FrameAllocator {
|
||||
self.set_bit(frame);
|
||||
self.free_frames -= 1;
|
||||
let paddr = (frame * PAGE_SIZE) as u64;
|
||||
// Zero out the frame
|
||||
unsafe {
|
||||
let vaddr = (paddr + self.hhdm_offset) as *mut u8;
|
||||
core::ptr::write_bytes(vaddr, 0, PAGE_SIZE);
|
||||
|
||||
Reference in New Issue
Block a user