#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 #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 rsp0; uint64_t rsp1; uint64_t rsp2; uint64_t resv1; uint64_t resv2; uint64_t ist1; uint64_t ist2; uint64_t ist3; uint64_t ist4; uint64_t ist5; uint64_t ist6; uint64_t ist7; uint64_t resv3; uint16_t resv4; uint16_t iopb; } __attribute__((packed)) 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 }; #define GDT_OFFSET_KERNEL_CODE (GDT_ENTRY_KERNEL_CODE * sizeof(segment_descriptor_t)) #define GDT_OFFSET_KERNEL_DATA (GDT_ENTRY_KERNEL_DATA * sizeof(segment_descriptor_t)) #define GDT_OFFSET_USER_DATA (GDT_ENTRY_USER_DATA * sizeof(segment_descriptor_t)) #define GDT_OFFSET_USER_CODE (GDT_ENTRY_USER_CODE * sizeof(segment_descriptor_t)) #define GDT_OFFSET_TSS (GDT_ENTRY_TSS_LOW * sizeof(segment_descriptor_t)) 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