Skip to content

Commit

Permalink
make lab3 challenge to work with lab4
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkYu98 committed Apr 15, 2019
1 parent a0a52dd commit 3bc4b5c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
14 changes: 14 additions & 0 deletions kern/trapentry.S
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ _alltraps:
.type name, @function
.align 2
sysenter_handler:
cli # Disable interrupts
cld # String operations increment
pushl %esi
pushl %ebp
pushl %edi
Expand All @@ -136,12 +138,24 @@ sysenter_handler:
movw $(GD_KD),%ax
movw %ax,%es
movw %ax,%ds

pushl $(kernel_lock)
call spin_lock
addl $4, %esp

call syscall

pushl %eax
pushl $(kernel_lock)
call spin_unlock
popl %eax
popl %eax

movw $(GD_UD),%bx
movw %bx,%es
movw %bx,%ds
addl $20,%esp
popl %ecx
popl %edx
sti
sysexit
29 changes: 17 additions & 12 deletions lib/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,29 +67,29 @@ syscall(int num, int check, uint32_t a1, uint32_t a2, uint32_t a3, uint32_t a4,
void
sys_cputs(const char *s, size_t len)
{
syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
// sysenter(SYS_cputs, 0, (uint32_t)s, len, 0, 0);
// syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
sysenter(SYS_cputs, 0, (uint32_t)s, len, 0, 0);
}

int
sys_cgetc(void)
{
return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
// return sysenter(SYS_cgetc, 0, 0, 0, 0, 0);
// return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
return sysenter(SYS_cgetc, 0, 0, 0, 0, 0);
}

int
sys_env_destroy(envid_t envid)
{
return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
// return sysenter(SYS_env_destroy, 1, envid, 0, 0, 0);
// return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
return sysenter(SYS_env_destroy, 1, envid, 0, 0, 0);
}

envid_t
sys_getenvid(void)
{
return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
// return sysenter(SYS_getenvid, 0, 0, 0, 0, 0);
// return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
return sysenter(SYS_getenvid, 0, 0, 0, 0, 0);
}

void
Expand All @@ -101,7 +101,8 @@ sys_yield(void)
int
sys_page_alloc(envid_t envid, void *va, int perm)
{
return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
// return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
return sysenter(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0);
}

int
Expand All @@ -113,27 +114,31 @@ sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
int
sys_page_unmap(envid_t envid, void *va)
{
return syscall(SYS_page_unmap, 1, envid, (uint32_t) va, 0, 0, 0);
// return syscall(SYS_page_unmap, 1, envid, (uint32_t) va, 0, 0, 0);
return sysenter(SYS_page_unmap, 1, envid, (uint32_t) va, 0, 0);
}

// sys_exofork is inlined in lib.h

int
sys_env_set_status(envid_t envid, int status)
{
return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
// return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
return sysenter(SYS_env_set_status, 1, envid, status, 0, 0);
}

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
// return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
return sysenter(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0);
}

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
return syscall(SYS_ipc_try_send, 0, envid, value, (uint32_t) srcva, perm, 0);
// return sysenter(SYS_ipc_try_send, 0, envid, value, (uint32_t) srcva, perm);
}

int
Expand Down

0 comments on commit 3bc4b5c

Please sign in to comment.