VirtualBox

source: vbox/trunk/src/recompiler/cpu-defs.h@ 36141

最後變更 在這個檔案從36141是 36140,由 vboxsync 提交於 14 年 前

rem: Re-synced to svn://svn.savannah.nongnu.org/qemu/trunk@5495 (repo UUID c046a42c-6fe2-441c-8c8c-71466251a162).

  • 屬性 svn:eol-style 設為 native
檔案大小: 9.6 KB
 
1/*
2 * common defines for all CPUs
3 *
4 * Copyright (c) 2003 Fabrice Bellard
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21/*
22 * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
23 * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
24 * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
25 * a choice of LGPL license versions is made available with the language indicating
26 * that LGPLv2 or any later version may be used, or where a choice of which version
27 * of the LGPL is applied is otherwise unspecified.
28 */
29
30#ifndef CPU_DEFS_H
31#define CPU_DEFS_H
32
33#ifndef NEED_CPU_H
34#error cpu.h included from common code
35#endif
36
37#include "config.h"
38#include <setjmp.h>
39#include <inttypes.h>
40#include "osdep.h"
41
42#ifndef TARGET_LONG_BITS
43#error TARGET_LONG_BITS must be defined before including this header
44#endif
45
46#ifndef TARGET_PHYS_ADDR_BITS
47#if TARGET_LONG_BITS >= HOST_LONG_BITS
48#define TARGET_PHYS_ADDR_BITS TARGET_LONG_BITS
49#else
50#define TARGET_PHYS_ADDR_BITS HOST_LONG_BITS
51#endif
52#endif
53
54#define TARGET_LONG_SIZE (TARGET_LONG_BITS / 8)
55
56/* target_ulong is the type of a virtual address */
57#if TARGET_LONG_SIZE == 4
58typedef int32_t target_long;
59typedef uint32_t target_ulong;
60#define TARGET_FMT_lx "%08x"
61#define TARGET_FMT_ld "%d"
62#define TARGET_FMT_lu "%u"
63#elif TARGET_LONG_SIZE == 8
64typedef int64_t target_long;
65typedef uint64_t target_ulong;
66#define TARGET_FMT_lx "%016" PRIx64
67#define TARGET_FMT_ld "%" PRId64
68#define TARGET_FMT_lu "%" PRIu64
69#else
70#error TARGET_LONG_SIZE undefined
71#endif
72
73/* target_phys_addr_t is the type of a physical address (its size can
74 be different from 'target_ulong'). We have sizeof(target_phys_addr)
75 = max(sizeof(unsigned long),
76 sizeof(size_of_target_physical_address)) because we must pass a
77 host pointer to memory operations in some cases */
78
79#if TARGET_PHYS_ADDR_BITS == 32
80typedef uint32_t target_phys_addr_t;
81#define TARGET_FMT_plx "%08x"
82#elif TARGET_PHYS_ADDR_BITS == 64
83typedef uint64_t target_phys_addr_t;
84#define TARGET_FMT_plx "%016" PRIx64
85#else
86#error TARGET_PHYS_ADDR_BITS undefined
87#endif
88
89#define HOST_LONG_SIZE (HOST_LONG_BITS / 8)
90
91#define EXCP_INTERRUPT 0x10000 /* async interruption */
92#define EXCP_HLT 0x10001 /* hlt instruction reached */
93#define EXCP_DEBUG 0x10002 /* cpu stopped after a breakpoint or singlestep */
94#define EXCP_HALTED 0x10003 /* cpu is halted (waiting for external event) */
95#if defined(VBOX)
96#define EXCP_EXECUTE_RAW 0x11024 /* execute raw mode. */
97#define EXCP_EXECUTE_HWACC 0x11025 /* execute hardware accelerated raw mode. */
98#define EXCP_SINGLE_INSTR 0x11026 /* executed single instruction. */
99#define EXCP_RC 0x11027 /* a EM rc was raised (VMR3Reset/Suspend/PowerOff). */
100#endif /* VBOX */
101#define MAX_BREAKPOINTS 32
102#define MAX_WATCHPOINTS 32
103
104#define TB_JMP_CACHE_BITS 12
105#define TB_JMP_CACHE_SIZE (1 << TB_JMP_CACHE_BITS)
106
107/* Only the bottom TB_JMP_PAGE_BITS of the jump cache hash bits vary for
108 addresses on the same page. The top bits are the same. This allows
109 TLB invalidation to quickly clear a subset of the hash table. */
110#define TB_JMP_PAGE_BITS (TB_JMP_CACHE_BITS / 2)
111#define TB_JMP_PAGE_SIZE (1 << TB_JMP_PAGE_BITS)
112#define TB_JMP_ADDR_MASK (TB_JMP_PAGE_SIZE - 1)
113#define TB_JMP_PAGE_MASK (TB_JMP_CACHE_SIZE - TB_JMP_PAGE_SIZE)
114
115#define CPU_TLB_BITS 8
116#define CPU_TLB_SIZE (1 << CPU_TLB_BITS)
117
118#if TARGET_PHYS_ADDR_BITS == 32 && TARGET_LONG_BITS == 32
119#define CPU_TLB_ENTRY_BITS 4
120#else
121#define CPU_TLB_ENTRY_BITS 5
122#endif
123
124typedef struct CPUTLBEntry {
125 /* bit TARGET_LONG_BITS to TARGET_PAGE_BITS : virtual address
126 bit TARGET_PAGE_BITS-1..4 : Nonzero for accesses that should not
127 go directly to ram.
128 bit 3 : indicates that the entry is invalid
129 bit 2..0 : zero
130 */
131 target_ulong addr_read;
132 target_ulong addr_write;
133 target_ulong addr_code;
134 /* Addend to virtual address to get physical address. IO accesses
135 use the correcponding iotlb value. */
136#if TARGET_PHYS_ADDR_BITS == 64
137 /* on i386 Linux make sure it is aligned */
138 target_phys_addr_t addend __attribute__((aligned(8)));
139#else
140 target_phys_addr_t addend;
141#endif
142 /* padding to get a power of two size */
143 uint8_t dummy[(1 << CPU_TLB_ENTRY_BITS) -
144 (sizeof(target_ulong) * 3 +
145 ((-sizeof(target_ulong) * 3) & (sizeof(target_phys_addr_t) - 1)) +
146 sizeof(target_phys_addr_t))];
147} CPUTLBEntry;
148
149#ifdef WORDS_BIGENDIAN
150typedef struct icount_decr_u16 {
151 uint16_t high;
152 uint16_t low;
153} icount_decr_u16;
154#else
155typedef struct icount_decr_u16 {
156 uint16_t low;
157 uint16_t high;
158} icount_decr_u16;
159#endif
160
161#define CPU_TEMP_BUF_NLONGS 128
162#define CPU_COMMON \
163 struct TranslationBlock *current_tb; /* currently executing TB */ \
164 /* soft mmu support */ \
165 /* in order to avoid passing too many arguments to the MMIO \
166 helpers, we store some rarely used information in the CPU \
167 context) */ \
168 unsigned long mem_io_pc; /* host pc at which the memory was \
169 accessed */ \
170 target_ulong mem_io_vaddr; /* target virtual addr at which the \
171 memory was accessed */ \
172 uint32_t halted; /* Nonzero if the CPU is in suspend state */ \
173 uint32_t interrupt_request; \
174 /* The meaning of the MMU modes is defined in the target code. */ \
175 CPUTLBEntry tlb_table[NB_MMU_MODES][CPU_TLB_SIZE]; \
176 target_phys_addr_t iotlb[NB_MMU_MODES][CPU_TLB_SIZE]; \
177 /** addends for HVA -> GPA translations */ \
178 VBOX_ONLY(target_phys_addr_t phys_addends[NB_MMU_MODES][CPU_TLB_SIZE]); \
179 struct TranslationBlock *tb_jmp_cache[TB_JMP_CACHE_SIZE]; \
180 /* buffer for temporaries in the code generator */ \
181 long temp_buf[CPU_TEMP_BUF_NLONGS]; \
182 \
183 int64_t icount_extra; /* Instructions until next timer event. */ \
184 /* Number of cycles left, with interrupt flag in high bit. \
185 This allows a single read-compare-cbranch-write sequence to test \
186 for both decrementer underflow and exceptions. */ \
187 union { \
188 uint32_t u32; \
189 icount_decr_u16 u16; \
190 } icount_decr; \
191 uint32_t can_do_io; /* nonzero if memory mapped IO is safe. */ \
192 \
193 /* from this point: preserved by CPU reset */ \
194 /* ice debug support */ \
195 target_ulong breakpoints[MAX_BREAKPOINTS]; \
196 int nb_breakpoints; \
197 int singlestep_enabled; \
198 \
199 struct { \
200 target_ulong vaddr; \
201 int type; /* PAGE_READ/PAGE_WRITE */ \
202 } watchpoint[MAX_WATCHPOINTS]; \
203 int nb_watchpoints; \
204 int watchpoint_hit; \
205 \
206 struct GDBRegisterState *gdb_regs; \
207 \
208 /* Core interrupt code */ \
209 jmp_buf jmp_env; \
210 int exception_index; \
211 \
212 int user_mode_only; \
213 \
214 void *next_cpu; /* next CPU sharing TB cache */ \
215 int cpu_index; /* CPU index (informative) */ \
216 int running; /* Nonzero if cpu is currently running(usermode). */ \
217 /* user data */ \
218 void *opaque; \
219 \
220 const char *cpu_model_str;
221
222#endif
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette