1
0
mirror of https://github.com/sgmarz/osblog.git synced 2024-11-24 02:16:19 +04:00

Don't grab the table unless we really need it.

This commit is contained in:
Stephen Marz 2020-05-17 15:13:53 -04:00
parent fe023e026e
commit 43e18b498d

View File

@ -49,14 +49,14 @@ pub unsafe fn do_syscall(mepc: usize, frame: *mut TrapFrame) -> usize {
// execv // execv
//A0 = path //A0 = path
//A1 = argv //A1 = argv
let mut path_addr = (*frame).regs[Registers::A0 as usize];
// If the MMU is turned on, translate.
if (*frame).satp >> 60 != 0 {
let p = get_by_pid((*frame).pid as u16); let p = get_by_pid((*frame).pid as u16);
let table = ((*p).get_table_address() let table = ((*p).get_table_address()
as *mut Table) as *mut Table)
.as_ref() .as_ref()
.unwrap(); .unwrap();
let mut path_addr = (*frame).regs[Registers::A0 as usize];
// If the MMU is turned on, translate.
if (*frame).satp >> 60 != 0 {
path_addr = virt_to_phys(table, path_addr).unwrap(); path_addr = virt_to_phys(table, path_addr).unwrap();
} }
let path_bytes = path_addr as *const u8; let path_bytes = path_addr as *const u8;