Merge branch 'lab3' into lab4

This commit is contained in:
2019-04-25 20:01:26 -07:00
19 changed files with 636 additions and 48 deletions

View File

@@ -3,6 +3,10 @@
#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)
{
@@ -261,4 +265,19 @@ 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 */