Implement the fast syscall challenge.

This commit is contained in:
2019-04-25 17:14:57 -07:00
parent 7d76204053
commit 3449b8c566
4 changed files with 56 additions and 1 deletions

View File

@@ -3,6 +3,7 @@
#include <inc/stdio.h>
#include <inc/string.h>
#include <inc/assert.h>
#include <inc/x86.h>
#include <kern/monitor.h>
#include <kern/console.h>
@@ -11,6 +12,7 @@
#include <kern/env.h>
#include <kern/trap.h>
void sysenter_handler();
void
i386_init(void)
@@ -34,6 +36,10 @@ i386_init(void)
"\33[34m" "r"
"\33[0m" " Works!" "\n");
write_msr(MSR_IA32_SYSENTER_EIP, (uint32_t) sysenter_handler, 0);
write_msr(MSR_IA32_SYSENTER_ESP, KSTACKTOP, 0);
write_msr(MSR_IA32_SYSENTER_CS, GD_KT, 0);
// Lab 2 memory management initialization functions
mem_init();

View File

@@ -43,6 +43,21 @@
.text
.globl sysenter_handler
sysenter_handler:
push %ebp // holds env's stack pointer
push %esi // holds the env's return addr
push %edi
push %ebx
push %ecx
push %edx
push %eax
call syscall
add $0x14, %esp
pop %edx
pop %ecx
sysexit
/*
* Lab 3: Your code here for generating entry points for the different traps.
*/