"git@gitlab.caltech.edu:cs24-19fa/git_rec_nano.git" did not exist on "cfa297622b1205d9a20649397f5881cbe51ea231"
Commit fa58ae1e authored by An N Tran's avatar An N Tran :speech_balloon:
Browse files

Task 4

parent 97fe004e
No related merge requests found
Pipeline #73456 passed with stage
in 14 seconds
Showing with 2 additions and 1 deletion
+2 -1
...@@ -173,7 +173,7 @@ void process_setup(pid_t pid, const char* program_name) { ...@@ -173,7 +173,7 @@ void process_setup(pid_t pid, const char* program_name) {
ptable[pid].regs.reg_rip = pgm.entry(); ptable[pid].regs.reg_rip = pgm.entry();
// allocate and map stack segment // allocate and map stack segment
uintptr_t stack_addr = PROC_START_ADDR + PROC_SIZE * pid - PAGESIZE; uintptr_t stack_addr = MEMSIZE_VIRTUAL - PAGESIZE;
uintptr_t pa = (uintptr_t) kalloc(PAGESIZE); uintptr_t pa = (uintptr_t) kalloc(PAGESIZE);
memory_map(process_pagetable, stack_addr, pa, PTE_PWU); memory_map(process_pagetable, stack_addr, pa, PTE_PWU);
ptable[pid].regs.reg_rsp = stack_addr + PAGESIZE; ptable[pid].regs.reg_rsp = stack_addr + PAGESIZE;
...@@ -325,6 +325,7 @@ uintptr_t syscall(regstate* regs) { ...@@ -325,6 +325,7 @@ uintptr_t syscall(regstate* regs) {
int syscall_page_alloc(uintptr_t addr) { int syscall_page_alloc(uintptr_t addr) {
uintptr_t pa = (uintptr_t) kalloc(PAGESIZE); uintptr_t pa = (uintptr_t) kalloc(PAGESIZE);
if (pa == 0) return -1;
memory_map(current->pagetable, addr, pa, PTE_PWU); memory_map(current->pagetable, addr, pa, PTE_PWU);
memset(memory_virtual_to_physical(current->pagetable, addr), 0, PAGESIZE); memset(memory_virtual_to_physical(current->pagetable, addr), 0, PAGESIZE);
return 0; return 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment