Code: Select all
typedef struct {
uint64_t carry : 1;
uint64_t reserved0 : 1;
uint64_t parity : 1;
uint64_t reserved1 : 1;
uint64_t auxiliary : 1;
uint64_t reserved2 : 1;
uint64_t zero : 1;
uint64_t sign : 1;
uint64_t trap : 1;
uint64_t interrupt_enable : 1;
uint64_t direction : 1;
uint64_t overflow : 1;
uint64_t io_privl_level : 2;
uint64_t nested_task : 1;
uint64_t reserved3 : 1;
uint64_t resume : 1;
uint64_t v8086_mode : 1;
uint64_t align_check_access_ctrl : 1;
uint64_t virtual_interrupt : 1;
uint64_t virtual_interrupt_pending : 1;
uint64_t id : 1;
uint64_t reserved4 : 42;
}__attribute__((packed)) flags_t;
typedef struct {
uint64_t protected_mode_entable : 1;
uint64_t monitor_coprocessor : 1;
uint64_t emulation : 1;
uint64_t task_switched : 1;
uint64_t extension_type : 1;
uint64_t numeric_error : 1;
uint64_t reserved0 : 10;
uint64_t write_protect : 1;
uint64_t reserved1 : 1;
uint64_t alignment_check : 1;
uint64_t reserved2 : 10;
uint64_t not_write_through : 1;
uint64_t cache_disable : 1;
uint64_t paging : 1;
uint64_t reserved3 : 32;
}__attribute__((packed)) cr0_t;
typedef struct {
uint64_t vme : 1;
uint64_t pvi : 1;
uint64_t tsd : 1;
uint64_t de : 1;
uint64_t pse : 1;
uint64_t pae : 1;
uint64_t mce : 1;
uint64_t pge : 1;
uint64_t pce : 1; /** Performance Monitoring Counter Enable */
uint64_t osfxsr : 1;
uint64_t osxmmexcpt : 1;
uint64_t umip : 1;
uint64_t reserved0 : 1;
uint64_t vmxe : 1;
uint64_t smxe : 1;
uint64_t reserved1 : 1;
uint64_t pcide : 1;
uint64_t osxsave : 1;
uint64_t reserved2 : 1;
uint64_t smep : 1;
uint64_t smap : 1;
uint64_t pke : 1;
uint64_t cet : 1;
uint64_t pks : 1;
uint64_t reserved3 : 39;
}__attribute__((packed)) cr4_t;
typedef struct {
uint64_t priority : 4;
uint64_t reserved : 60;
}__attribute__((packed)) cr8_t;
typedef struct {
uint64_t sce : 1;
uint64_t reserved0 : 7;
uint64_t lme : 1;
uint64_t lma : 1;
uint64_t nxe : 1;
uint64_t svme : 1;
uint64_t lmsle : 1;
uint64_t ffxsr : 1;
uint64_t tce : 1;
uint64_t reserved1 : 48;
}__attribute__((packed)) ia32_efer_t;
typedef struct {
/**
* General purpose registers (8-bit form)
*/
uint8_t ah;
uint8_t al;
uint8_t bh;
uint8_t bl;
uint8_t ch;
uint8_t cl;
uint8_t dh;
uint8_t dl;
uint8_t sil;
uint8_t dil;
uint8_t spl;
uint8_t bpl;
uint8_t r8b;
uint8_t r9b;
uint8_t r10b;
uint8_t r11b;
uint8_t r12b;
uint8_t r13b;
uint8_t r14b;
uint8_t r15b;
/**
* General purpose registers (16-bit form)
*/
uint16_t ax;
uint16_t bx;
uint16_t cx;
uint16_t dx;
uint16_t si;
uint16_t di;
uint16_t sp;
uint16_t bp;
uint16_t r8w;
uint16_t r9w;
uint16_t r10w;
uint16_t r11w;
uint16_t r12w;
uint16_t r13w;
uint16_t r14w;
uint16_t r15w;
/**
* Segment registers
*/
uint16_t cs;
uint16_t ds;
uint16_t es;
uint16_t fs;
uint16_t gs;
uint16_t ss;
/**
* Instruction pointer (16-bit form)
*/
uint16_t ip;
/**
* Instruction pointer (32-bit form)
*/
uint32_t eip;
/**
* General purpose registers (32-bit form)
*/
uint32_t eax;
uint32_t ebx;
uint32_t ecx;
uint32_t edx;
uint32_t esi;
uint32_t edi;
uint32_t esp;
uint32_t ebp;
uint32_t r8d;
uint32_t r9d;
uint32_t r10d;
uint32_t r11d;
uint32_t r12d;
uint32_t r13d;
uint32_t r14d;
uint32_t r15d;
/**
* Instruction pointer (64-bit form)
*/
uint64_t rax;
uint64_t rbx;
uint64_t rcx;
uint64_t rdx;
uint64_t rsi;
uint64_t rdi;
uint64_t rsp;
uint64_t rbp;
uint64_t r8;
uint64_t r9;
uint64_t r10;
uint64_t r11;
uint64_t r12;
uint64_t r13;
uint64_t r14;
uint64_t r15;
/**
* Control registers
*/
cr0_t cr0;
uint64_t cr2;
uint64_t cr3;
cr4_t cr4;
cr8_t cr8;
/**
* FLAGS register
*/
flags_t rflags;
/**
* IA32_EFER MSR
*/
ia32_efer_t ia32_efer;
} registers_t;