diff options
Diffstat (limited to 'include/arch/x86_64/processor.h')
-rw-r--r-- | include/arch/x86_64/processor.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/include/arch/x86_64/processor.h b/include/arch/x86_64/processor.h new file mode 100644 index 0000000..f8a93ce --- /dev/null +++ b/include/arch/x86_64/processor.h @@ -0,0 +1,66 @@ +#ifndef _JOVE_ARCH_x86_64_PROCESSOR_H +#define _JOVE_ARCH_x86_64_PROCESSOR_H 1 + +#include "memory.h" +#include "tables.h" +#include "object.h" +#include <stdint.h> + +#define MSR_FS_BASE 0xC0000100 +#define MSR_GS_BASE 0xC0000101 +#define MSR_KGS_BASE 0xC0000102 + +#define MSR_EFER 0xC0000080 +#define MSR_STAR 0xC0000081 +#define MSR_LSTAR 0xC0000082 +#define MSR_SFMASK 0xC0000084 + +typedef struct jove_TSS +{ + uint32_t resv0; + uint64_t rsp[3]; + uint32_t resv1; + uint64_t ist[8]; + uint32_t resv2[2]; + uint16_t resv3; + uint16_t iopb; +} tss_t; + +enum +{ + GDT_ENTRY_KERNEL_NULL = 0, + GDT_ENTRY_KERNEL_CODE, + GDT_ENTRY_KERNEL_DATA, + GDT_ENTRY_USER_NULL, + GDT_ENTRY_USER_DATA, + GDT_ENTRY_USER_CODE, + GDT_ENTRY_TSS_LOW, + GDT_ENTRY_TSS_HIGH, + GDT_ENTRY_COUNT +}; + +typedef struct jove_Processor +{ + physptr_t pdir; + struct jove_ObjectDirectory *odir; + + segment_descriptor_t gdt[GDT_ENTRY_COUNT]; + struct { + uint16_t length; + uint64_t base; + } __attribute__((packed)) gdtr; + struct { + uint16_t length; + uint64_t base; + } __attribute__((packed)) idtr; + + tss_t tss; + tcb_t *tcb; +} processor_t; + +void gdt_setup(processor_t *processor); + +void rdmsr(uint32_t msr, uint32_t *lo, uint32_t *hi); +void wrmsr(uint32_t msr, uint32_t lo, uint32_t hi); + +#endif |