Compare commits

..

No commits in common. "74b1c2c69d7f60924299d9e45204158fa293ed7a" and "7d7620405324693b7f6e9690e75ccede66b8f757" have entirely different histories.

4 changed files with 2 additions and 57 deletions

View File

@ -3,10 +3,6 @@
#include <inc/types.h>
#define MSR_IA32_SYSENTER_CS 0x174
#define MSR_IA32_SYSENTER_EIP 0x176
#define MSR_IA32_SYSENTER_ESP 0x175
static inline void
breakpoint(void)
{
@ -265,19 +261,4 @@ xchg(volatile uint32_t *addr, uint32_t newval)
return result;
}
static inline void
write_msr(uint32_t reg, uint32_t low, uint32_t high) {
asm volatile("wrmsr\n\t"
:: "c" (reg), "a" (low), "d" (high));
}
static inline void
read_msr(uint32_t reg, uint32_t* low, uint32_t* high) {
uint32_t eax, edx;
asm volatile("rdmsr\n\t"
: "=a" (eax), "=d" (edx) : "c" (reg));
*low = eax;
*high = edx;
}
#endif /* !JOS_INC_X86_H */

View File

@ -3,7 +3,6 @@
#include <inc/stdio.h>
#include <inc/string.h>
#include <inc/assert.h>
#include <inc/x86.h>
#include <kern/monitor.h>
#include <kern/console.h>
@ -12,7 +11,6 @@
#include <kern/env.h>
#include <kern/trap.h>
void sysenter_handler();
void
i386_init(void)
@ -36,10 +34,6 @@ 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,21 +43,6 @@
.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.
*/

View File

@ -2,7 +2,6 @@
#include <inc/syscall.h>
#include <inc/lib.h>
#include <inc/x86.h>
static inline int32_t
syscall(int num, int check, uint32_t a1, uint32_t a2, uint32_t a3, uint32_t a4, uint32_t a5)
@ -38,30 +37,16 @@ syscall(int num, int check, uint32_t a1, uint32_t a2, uint32_t a3, uint32_t a4,
return ret;
}
int32_t
fast_syscall(int num, uint32_t a1, uint32_t a2, uint32_t a3, uint32_t a4) {
asm volatile(
"push %%ebp\n\t"
"mov %%esp, %%ebp\n\t"
"lea syscall_ret_%=, %%esi\n\t"
"sysenter\n\t"
"syscall_ret_%=: pop %%ebp\n\t"
: "+a" (num)
: "d" (a1), "c" (a2), "b" (a3), "D" (a4)
: "esi");
return num;
}
void
sys_cputs(const char *s, size_t len)
{
fast_syscall(SYS_cputs, (uint32_t)s, len, 0, 0);
syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}
int
sys_cgetc(void)
{
return fast_syscall(SYS_cgetc, 0, 0, 0, 0);
return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}
int