X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=cpu-i386.h;h=e6318fb7f2ddcd177f4526d8afce6cfd1a4c7bfb;hb=4690764bba3a489d5180106d08970ced59113e22;hp=92178b98c0fd4cdb2af91a414d1a18fb0f5ee5c7;hpb=5a9fdfec7eff4f053705cf160be87ebf01a57833;p=qemu diff --git a/cpu-i386.h b/cpu-i386.h index 92178b9..e6318fb 100644 --- a/cpu-i386.h +++ b/cpu-i386.h @@ -50,7 +50,8 @@ /* segment descriptor fields */ #define DESC_G_MASK (1 << 23) -#define DESC_B_MASK (1 << 22) +#define DESC_B_SHIFT 22 +#define DESC_B_MASK (1 << DESC_B_SHIFT) #define DESC_AVL_MASK (1 << 20) #define DESC_P_MASK (1 << 15) #define DESC_DPL_SHIFT 13 @@ -85,6 +86,54 @@ #define VIP_MASK 0x00100000 #define ID_MASK 0x00200000 +#define CR0_PE_MASK (1 << 0) +#define CR0_TS_MASK (1 << 3) +#define CR0_WP_MASK (1 << 16) +#define CR0_AM_MASK (1 << 18) +#define CR0_PG_MASK (1 << 31) + +#define CR4_VME_MASK (1 << 0) +#define CR4_PVI_MASK (1 << 1) +#define CR4_TSD_MASK (1 << 2) +#define CR4_DE_MASK (1 << 3) +#define CR4_PSE_MASK (1 << 4) + +#define PG_PRESENT_BIT 0 +#define PG_RW_BIT 1 +#define PG_USER_BIT 2 +#define PG_PWT_BIT 3 +#define PG_PCD_BIT 4 +#define PG_ACCESSED_BIT 5 +#define PG_DIRTY_BIT 6 +#define PG_PSE_BIT 7 +#define PG_GLOBAL_BIT 8 + +#define PG_PRESENT_MASK (1 << PG_PRESENT_BIT) +#define PG_RW_MASK (1 << PG_RW_BIT) +#define PG_USER_MASK (1 << PG_USER_BIT) +#define PG_PWT_MASK (1 << PG_PWT_BIT) +#define PG_PCD_MASK (1 << PG_PCD_BIT) +#define PG_ACCESSED_MASK (1 << PG_ACCESSED_BIT) +#define PG_DIRTY_MASK (1 << PG_DIRTY_BIT) +#define PG_PSE_MASK (1 << PG_PSE_BIT) +#define PG_GLOBAL_MASK (1 << PG_GLOBAL_BIT) + +#define PG_ERROR_W_BIT 1 + +#define PG_ERROR_P_MASK 0x01 +#define PG_ERROR_W_MASK (1 << PG_ERROR_W_BIT) +#define PG_ERROR_U_MASK 0x04 +#define PG_ERROR_RSVD_MASK 0x08 + +#define MSR_IA32_APICBASE 0x1b +#define MSR_IA32_APICBASE_BSP (1<<8) +#define MSR_IA32_APICBASE_ENABLE (1<<11) +#define MSR_IA32_APICBASE_BASE (0xfffff<<12) + +#define MSR_IA32_SYSENTER_CS 0x174 +#define MSR_IA32_SYSENTER_ESP 0x175 +#define MSR_IA32_SYSENTER_EIP 0x176 + #define EXCP00_DIVZ 0 #define EXCP01_SSTP 1 #define EXCP02_NMI 2 @@ -105,6 +154,7 @@ #define EXCP12_MCHK 18 #define EXCP_INTERRUPT 256 /* async interruption */ +#define EXCP_HLT 257 /* hlt instruction reached */ enum { CC_OP_DYNAMIC, /* must use dynamic code to get cc_op */ @@ -161,19 +211,12 @@ typedef double CPU86_LDouble; #endif typedef struct SegmentCache { + uint32_t selector; uint8_t *base; - unsigned long limit; - uint8_t seg_32bit; + uint32_t limit; + uint32_t flags; } SegmentCache; -typedef struct SegmentDescriptorTable { - uint8_t *base; - unsigned long limit; - /* this is the returned base when reading the register, just to - avoid that the emulated program modifies it */ - unsigned long emu_base; -} SegmentDescriptorTable; - typedef struct CPUX86State { /* standard registers */ uint32_t regs[8]; @@ -205,19 +248,29 @@ typedef struct CPUX86State { } fp_convert; /* segments */ - uint32_t segs[6]; /* selector values */ - SegmentCache seg_cache[6]; /* info taken from LDT/GDT */ - SegmentDescriptorTable gdt; - SegmentDescriptorTable ldt; - SegmentDescriptorTable idt; + SegmentCache segs[6]; /* selector values */ + SegmentCache ldt; + SegmentCache tr; + SegmentCache gdt; /* only base and limit are used */ + SegmentCache idt; /* only base and limit are used */ + + /* sysenter registers */ + uint32_t sysenter_cs; + uint32_t sysenter_esp; + uint32_t sysenter_eip; /* exception/interrupt handling */ jmp_buf jmp_env; int exception_index; int error_code; - uint32_t cr2; - int interrupt_request; - + int exception_is_int; + int exception_next_eip; + struct TranslationBlock *current_tb; /* currently executing TB */ + uint32_t cr[5]; /* NOTE: cr1 is unused */ + uint32_t dr[8]; /* debug registers */ + int interrupt_request; + int user_mode_only; /* user mode only simulation */ + /* user data */ void *opaque; } CPUX86State; @@ -233,8 +286,8 @@ int cpu_x86_inl(CPUX86State *env, int addr); CPUX86State *cpu_x86_init(void); int cpu_x86_exec(CPUX86State *s); -void cpu_x86_interrupt(CPUX86State *s); void cpu_x86_close(CPUX86State *s); +int cpu_x86_get_pic_interrupt(CPUX86State *s); /* needed to load some predefinied segment registers */ void cpu_x86_load_seg(CPUX86State *s, int seg_reg, int selector); @@ -250,6 +303,12 @@ struct siginfo; int cpu_x86_signal_handler(int host_signum, struct siginfo *info, void *puc); +/* MMU defines */ +void cpu_x86_init_mmu(CPUX86State *env); +extern int phys_ram_size; +extern int phys_ram_fd; +extern uint8_t *phys_ram_base; + /* used to debug */ #define X86_DUMP_FPU 0x0001 /* dump FPU state too */ #define X86_DUMP_CCOP 0x0002 /* dump qemu flag cache */