2019-12-25 12:11:15 +00:00
|
|
|
use crate::definitions::{XousError, XousPid, MemoryAddress};
|
|
|
|
use crate::mem::MemoryManager;
|
|
|
|
use crate::filled_array;
|
|
|
|
|
|
|
|
const MAX_PROCESS_COUNT: usize = 256;
|
|
|
|
|
|
|
|
struct Process {
|
|
|
|
satp: Option<MemoryAddress>,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct ProcessTable {
|
|
|
|
processes: [Process; MAX_PROCESS_COUNT],
|
|
|
|
}
|
|
|
|
|
|
|
|
impl ProcessTable {
|
|
|
|
pub fn new(mm: &mut MemoryManager) -> Self {
|
|
|
|
let mut pt = ProcessTable {
|
|
|
|
processes: filled_array![Process { satp: None }; 256],
|
|
|
|
};
|
|
|
|
|
|
|
|
// Allocate a root page table for PID 1
|
|
|
|
pt.processes[1].satp = Some(mm.alloc_page(1).unwrap());
|
2020-01-09 03:03:55 +00:00
|
|
|
mm.create_identity(pt.processes[1].satp.unwrap(), 1).expect("Unable to create identity mapping");
|
2019-12-25 12:11:15 +00:00
|
|
|
pt
|
|
|
|
}
|
|
|
|
}
|