Improving AMD64 header

This commit is contained in:
Ali Mashtizadeh 2014-07-10 14:43:52 -07:00
parent a1c44dca93
commit 330a454af3
3 changed files with 49 additions and 35 deletions

View File

@ -150,22 +150,21 @@ typedef struct PACKED TaskStateSegment64 {
#define RFLAGS_CF 0x00000001 /* Carry Flag */
#define RFLAGS_PF 0x00000004 /* Parity Flag */
#define RFLAGS_AF
#define RFLAGS_ZF
#define RFLAGS_SF
#define RFLAGS_TF
#define RFLAGS_IF
#define RFLAGS_DF
#define RFLAGS_OF
// IOPL
#define RFLAGS_NT
#define RFLAGS_RF 0x00010000
#define RFLAGS_VM 0x00020000
#define RFLAGS_AC 0x00040000
#define RFLAGS_VIF 0x00080000
#define RFLAGS_VIP
#define RFLAGS_ID
#define RFLAGS_AF 0x00000010 /* Adjust Flag */
#define RFLAGS_ZF 0x00000040 /* Zero Flag */
#define RFLAGS_SF 0x00000080 /* Sign Flag */
#define RFLAGS_TF 0x00000100 /* Trap Flag */
#define RFLAGS_IF 0x00000200 /* Interrupt Enable Flag */
#define RFLAGS_DF 0x00000400 /* Direction Flag */
#define RFLAGS_OF 0x00000800 /* Overflow Flag */
// IOPL (bits 12-13)
#define RFLAGS_NT 0x00004000 /* Nested Task Flag */
#define RFLAGS_RF 0x00010000 /* Resume Flag */
#define RFLAGS_VM 0x00020000 /* Virtual 8086 Mode */
#define RFLAGS_AC 0x00040000 /* Alignment Check */
#define RFLAGS_VIF 0x00080000 /* Virtual Interrupt Flag */
#define RFLAGS_VIP 0x00100000 /* Virtual Interrupt Pending */
#define RFLAGS_ID 0x00200000 /* CPUID Supported */
/*
* Debug Registers
@ -186,6 +185,12 @@ typedef struct PACKED TaskStateSegment64 {
#define EFER_FFXSR 0x4000 /* Fast FXSAVE/FXRSTOR (AMD) */
#define EFER_TCE 0x8000 /* Translation Cache Extension (AMD) */
// SYSCALL/SYSRET
#define MSR_STAR 0xC0000081
#define MSR_LSTAR 0xC0000082
#define MSR_CSTAR 0xC0000083
#define MSR_SFMASK 0xC0000084
#include "amd64op.h"
#endif /* __AMD64_H__ */

View File

@ -76,6 +76,11 @@ void Machine_SyscallInit()
{
kprintf("Initializing Syscall... ");
wrmsr(MSR_STAR, SEL_KCS << 32 | SEL_UCS << 48);
wrmsr(MSR_LSTAR, 0);
wrmsr(MSR_CSTAR, 0);
wrmsr(MSR_SFMASK, 0);
kprintf("Done!\n");
}

View File

@ -2,25 +2,25 @@
#ifndef __TRAP_H__
#define __TRAP_H__
#define T_DE 0
#define T_DB 1
#define T_NMI 2
#define T_BP 3
#define T_OF 4
#define T_BR 5
#define T_UD 6
#define T_NM 7
#define T_DF 8
#define T_TS 10
#define T_NP 11
#define T_SS 12
#define T_GP 13
#define T_PF 14
#define T_MF 16
#define T_AC 17
#define T_MC 18
#define T_XF 19
#define T_VE 20
#define T_DE 0 /* Divide Error Exception */
#define T_DB 1 /* Debug Exception */
#define T_NMI 2 /* NMI Interrupt */
#define T_BP 3 /* Breakpoint Exception */
#define T_OF 4 /* Overflow Exception */
#define T_BR 5 /* BOUND Range Exceeded Exception */
#define T_UD 6 /* Invalid Opcode Exception */
#define T_NM 7 /* Device Not Available Exception */
#define T_DF 8 /* Double Fault Exception */
#define T_TS 10 /* Invalid TSS Exception */
#define T_NP 11 /* Segment Not Present */
#define T_SS 12 /* Stack Fault Exception */
#define T_GP 13 /* General Protection Exception */
#define T_PF 14 /* Page-Fault Exception */
#define T_MF 16 /* x87 FPU Floating-Point Error */
#define T_AC 17 /* Alignment Check Exception */
#define T_MC 18 /* Machine-Check Exception */
#define T_XF 19 /* SIMB Floating-Point Exception */
#define T_VE 20 /* Virtualization Exception */
#define T_CPU_LAST T_VE
@ -32,10 +32,14 @@
#define T_IRQ_KBD (T_IRQ_BASE + 1)
#define T_IRQ_COM1 (T_IRQ_BASE + 4)
#define T_IRQ_MOUSE (T_IRQ_BASE + 12)
// LAPIC Special Vectors
#define T_IRQ_SPURIOUS (T_IRQ_BASE + 24)
#define T_IRQ_ERROR (T_IRQ_BASE + 25)
#define T_IRQ_THERMAL (T_IRQ_BASE + 26)
#define T_SYSCALL 60
#define T_MAX 64
typedef struct TrapFrame