#ifndef CPU_H #define CPU_H #include "hos_types.h" static u32_t read_cr0() __attribute__ ((unused)); static u32_t read_cr0() { u32_t val; __asm__ __volatile__ ("movl %%cr0, %0" : "=r" (val)); return val; } static u32_t read_cr2() __attribute__ ((unused)); static u32_t read_cr2() { u32_t val; __asm__ __volatile__ ("movl %%cr2, %0" : "=r" (val)); return val; } static u32_t read_cr3() __attribute__ ((unused)); static u32_t read_cr3() { u32_t val; __asm__ __volatile__ ("movl %%cr3, %0" : "=r" (val)); return val; } #define write_cr0(val) \ __asm__ __volatile__ ("movl %0, %%cr0" : : "r" (val)); #define write_cr3(val) \ __asm__ __volatile__ ("movl %0, %%cr3" : : "r" (val)); #define write_esp(val) \ __asm__ __volatile__ ("movl %0, %%esp" : : "r" (val)); #endif