VirtualBox

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

Last change on this file since 36175 was 36175, checked in by vboxsync, 14 years ago

rem: Synced up to v0.11.1 (35bfc7324e2e6946c4113ada5db30553a1a7c40b) from git://git.savannah.nongnu.org/qemu.git.

  • Property svn:eol-style set to native
File size: 9.5 KB
Line 
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, see <http://www.gnu.org/licenses/>.
18 */
19
20/*
21 * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
22 * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
23 * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
24 * a choice of LGPL license versions is made available with the language indicating
25 * that LGPLv2 or any later version may be used, or where a choice of which version
26 * of the LGPL is applied is otherwise unspecified.
27 */
28
29#ifndef CPU_DEFS_H
30#define CPU_DEFS_H
31
32#ifndef NEED_CPU_H
33#error cpu.h included from common code
34#endif
35
36#include "config.h"
37#include <setjmp.h>
38#include <inttypes.h>
39#include <signal.h>
40#include "osdep.h"
41#include "sys-queue.h"
42#include "targphys.h"
43
44#ifndef TARGET_LONG_BITS
45#error TARGET_LONG_BITS must be defined before including this header
46#endif
47
48#define TARGET_LONG_SIZE (TARGET_LONG_BITS / 8)
49
50/* target_ulong is the type of a virtual address */
51#if TARGET_LONG_SIZE == 4
52typedef int32_t target_long;
53typedef uint32_t target_ulong;
54#define TARGET_FMT_lx "%08x"
55#define TARGET_FMT_ld "%d"
56#define TARGET_FMT_lu "%u"
57#elif TARGET_LONG_SIZE == 8
58typedef int64_t target_long;
59typedef uint64_t target_ulong;
60#define TARGET_FMT_lx "%016" PRIx64
61#define TARGET_FMT_ld "%" PRId64
62#define TARGET_FMT_lu "%" PRIu64
63#else
64#error TARGET_LONG_SIZE undefined
65#endif
66
67#define HOST_LONG_SIZE (HOST_LONG_BITS / 8)
68
69#define EXCP_INTERRUPT 0x10000 /* async interruption */
70#define EXCP_HLT 0x10001 /* hlt instruction reached */
71#define EXCP_DEBUG 0x10002 /* cpu stopped after a breakpoint or singlestep */
72#define EXCP_HALTED 0x10003 /* cpu is halted (waiting for external event) */
73#ifdef VBOX
74# define EXCP_EXECUTE_RAW 0x11024 /**< execute raw mode. */
75# define EXCP_EXECUTE_HWACC 0x11025 /**< execute hardware accelerated raw mode. */
76# define EXCP_SINGLE_INSTR 0x11026 /**< executed single instruction. */
77# define EXCP_RC 0x11027 /**< a EM rc was raised (VMR3Reset/Suspend/PowerOff). */
78#endif /* VBOX */
79
80#define TB_JMP_CACHE_BITS 12
81#define TB_JMP_CACHE_SIZE (1 << TB_JMP_CACHE_BITS)
82
83/* Only the bottom TB_JMP_PAGE_BITS of the jump cache hash bits vary for
84 addresses on the same page. The top bits are the same. This allows
85 TLB invalidation to quickly clear a subset of the hash table. */
86#define TB_JMP_PAGE_BITS (TB_JMP_CACHE_BITS / 2)
87#define TB_JMP_PAGE_SIZE (1 << TB_JMP_PAGE_BITS)
88#define TB_JMP_ADDR_MASK (TB_JMP_PAGE_SIZE - 1)
89#define TB_JMP_PAGE_MASK (TB_JMP_CACHE_SIZE - TB_JMP_PAGE_SIZE)
90
91#define CPU_TLB_BITS 8
92#define CPU_TLB_SIZE (1 << CPU_TLB_BITS)
93
94#if TARGET_PHYS_ADDR_BITS == 32 && TARGET_LONG_BITS == 32
95#define CPU_TLB_ENTRY_BITS 4
96#else
97#define CPU_TLB_ENTRY_BITS 5
98#endif
99
100typedef struct CPUTLBEntry {
101 /* bit TARGET_LONG_BITS to TARGET_PAGE_BITS : virtual address
102 bit TARGET_PAGE_BITS-1..4 : Nonzero for accesses that should not
103 go directly to ram.
104 bit 3 : indicates that the entry is invalid
105 bit 2..0 : zero
106 */
107 target_ulong addr_read;
108 target_ulong addr_write;
109 target_ulong addr_code;
110 /* Addend to virtual address to get physical address. IO accesses
111 use the corresponding iotlb value. */
112#if TARGET_PHYS_ADDR_BITS == 64
113 /* on i386 Linux make sure it is aligned */
114 target_phys_addr_t addend __attribute__((aligned(8)));
115#else
116 target_phys_addr_t addend;
117#endif
118 /* padding to get a power of two size */
119 uint8_t dummy[(1 << CPU_TLB_ENTRY_BITS) -
120 (sizeof(target_ulong) * 3 +
121 ((-sizeof(target_ulong) * 3) & (sizeof(target_phys_addr_t) - 1)) +
122 sizeof(target_phys_addr_t))];
123} CPUTLBEntry;
124
125#ifdef WORDS_BIGENDIAN
126typedef struct icount_decr_u16 {
127 uint16_t high;
128 uint16_t low;
129} icount_decr_u16;
130#else
131typedef struct icount_decr_u16 {
132 uint16_t low;
133 uint16_t high;
134} icount_decr_u16;
135#endif
136
137struct kvm_run;
138struct KVMState;
139
140typedef struct CPUBreakpoint {
141 target_ulong pc;
142 int flags; /* BP_* */
143 TAILQ_ENTRY(CPUBreakpoint) entry;
144} CPUBreakpoint;
145
146typedef struct CPUWatchpoint {
147 target_ulong vaddr;
148 target_ulong len_mask;
149 int flags; /* BP_* */
150 TAILQ_ENTRY(CPUWatchpoint) entry;
151} CPUWatchpoint;
152
153#define CPU_TEMP_BUF_NLONGS 128
154#define CPU_COMMON \
155 struct TranslationBlock *current_tb; /* currently executing TB */ \
156 /* soft mmu support */ \
157 /* in order to avoid passing too many arguments to the MMIO \
158 helpers, we store some rarely used information in the CPU \
159 context) */ \
160 unsigned long mem_io_pc; /* host pc at which the memory was \
161 accessed */ \
162 target_ulong mem_io_vaddr; /* target virtual addr at which the \
163 memory was accessed */ \
164 uint32_t halted; /* Nonzero if the CPU is in suspend state */ \
165 uint32_t stop; /* Stop request */ \
166 uint32_t stopped; /* Artificially stopped */ \
167 uint32_t interrupt_request; \
168 volatile /*sig_atomic_t - vbox*/ int32_t exit_request; \
169 /* The meaning of the MMU modes is defined in the target code. */ \
170 CPUTLBEntry tlb_table[NB_MMU_MODES][CPU_TLB_SIZE]; \
171 target_phys_addr_t iotlb[NB_MMU_MODES][CPU_TLB_SIZE]; \
172 /** addends for HVA -> GPA translations */ \
173 VBOX_ONLY(target_phys_addr_t phys_addends[NB_MMU_MODES][CPU_TLB_SIZE]); \
174 struct TranslationBlock *tb_jmp_cache[TB_JMP_CACHE_SIZE]; \
175 /* buffer for temporaries in the code generator */ \
176 long temp_buf[CPU_TEMP_BUF_NLONGS]; \
177 \
178 int64_t icount_extra; /* Instructions until next timer event. */ \
179 /* Number of cycles left, with interrupt flag in high bit. \
180 This allows a single read-compare-cbranch-write sequence to test \
181 for both decrementer underflow and exceptions. */ \
182 union { \
183 uint32_t u32; \
184 icount_decr_u16 u16; \
185 } icount_decr; \
186 uint32_t can_do_io; /* nonzero if memory mapped IO is safe. */ \
187 \
188 /* from this point: preserved by CPU reset */ \
189 /* ice debug support */ \
190 TAILQ_HEAD(breakpoints_head, CPUBreakpoint) breakpoints; \
191 int singlestep_enabled; \
192 \
193 TAILQ_HEAD(watchpoints_head, CPUWatchpoint) watchpoints; \
194 CPUWatchpoint *watchpoint_hit; \
195 \
196 struct GDBRegisterState *gdb_regs; \
197 \
198 /* Core interrupt code */ \
199 jmp_buf jmp_env; \
200 int exception_index; \
201 \
202 CPUState *next_cpu; /* next CPU sharing TB cache */ \
203 int cpu_index; /* CPU index (informative) */ \
204 uint32_t host_tid; /* host thread ID */ \
205 int numa_node; /* NUMA node this cpu is belonging to */ \
206 int running; /* Nonzero if cpu is currently running(usermode). */ \
207 /* user data */ \
208 void *opaque; \
209 \
210 uint32_t created; \
211 struct QemuThread *thread; \
212 struct QemuCond *halt_cond; \
213 const char *cpu_model_str; \
214 struct KVMState *kvm_state; \
215 struct kvm_run *kvm_run; \
216 int kvm_fd;
217
218#endif
Note: See TracBrowser for help on using the repository browser.

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