kernel: hide hw specific details in process init

This commit is contained in:
eupn 2023-03-14 18:35:12 +04:00
parent 3451d106f9
commit 0953812dfc
No known key found for this signature in database
GPG key ID: 0BBE77FB42014014

View file

@ -357,9 +357,7 @@ impl SystemServices {
let mut arg_iter = args.iter().peekable(); let mut arg_iter = args.iter().peekable();
loop { loop {
if let Some(arg) = arg_iter.peek() { if let Some(arg) = arg_iter.peek() {
println!("loop");
if arg.name == u32::from_le_bytes(*b"IniE") || arg.name == u32::from_le_bytes(*b"IniF") { if arg.name == u32::from_le_bytes(*b"IniE") || arg.name == u32::from_le_bytes(*b"IniF") {
println!("found!");
break; break;
} }
} else { } else {
@ -373,19 +371,16 @@ impl SystemServices {
// value from the bootloader. For each process, translate it from a raw // value from the bootloader. For each process, translate it from a raw
// KernelArguments value to a SystemServices Process value. // KernelArguments value to a SystemServices Process value.
for init in init_offsets.iter() { for init in init_offsets.iter() {
let pid = (init.satp >> 22) & ((1 << 9) - 1); let pid = init.pid().get();
let process = &mut self.processes[(pid - 1) as usize]; let proc_idx = pid - 1;
let process = &mut self.processes[proc_idx as usize];
// println!( // println!(
// "Process: SATP: {:08x} PID: {} Memory: {:08x} PC: {:08x} SP: {:08x} Index: {}", // "Process[{}]: {:?}",
// init.satp, // pid - 1,
// pid, // init,
// init.satp << 10,
// init.entrypoint,
// init.sp,
// pid - 1
// ); // );
unsafe { unsafe {
process.mapping.from_raw(init.satp); process.mapping.from_init_process(*init);
process.ppid = PID::new_unchecked(1); process.ppid = PID::new_unchecked(1);
process.pid = PID::new(pid as _).unwrap(); process.pid = PID::new(pid as _).unwrap();
}; };