VirtualBox

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

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

build fix

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

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