blob: 21d1f6c17f10262f3df7fb29f32a8db1e469eb91 [file] [log] [blame]
sewardjde4a1d02002-03-22 01:27:54 +00001
2/*--------------------------------------------------------------------*/
nethercote5a2664c2004-09-02 15:37:39 +00003/*--- Asm-specific core stuff. core_asm.h ---*/
sewardjde4a1d02002-03-22 01:27:54 +00004/*--------------------------------------------------------------------*/
5
6/*
njnb9c427c2004-12-01 14:14:42 +00007 This file is part of Valgrind, a dynamic binary instrumentation
8 framework.
sewardjde4a1d02002-03-22 01:27:54 +00009
njn53612422005-03-12 16:22:54 +000010 Copyright (C) 2000-2005 Julian Seward
sewardjde4a1d02002-03-22 01:27:54 +000011 jseward@acm.org
sewardjde4a1d02002-03-22 01:27:54 +000012
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation; either version 2 of the
16 License, or (at your option) any later version.
17
18 This program is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
26 02111-1307, USA.
27
njn25e49d8e72002-09-23 09:36:25 +000028 The GNU General Public License is contained in the file COPYING.
sewardjde4a1d02002-03-22 01:27:54 +000029*/
30
nethercote5a2664c2004-09-02 15:37:39 +000031#ifndef __CORE_ASM_H
32#define __CORE_ASM_H
sewardjde4a1d02002-03-22 01:27:54 +000033
nethercotec06e2132004-09-03 13:45:29 +000034#include "tool_asm.h" // tool asm stuff
35#include "core_arch_asm.h" // arch-specific asm stuff
sewardjde4a1d02002-03-22 01:27:54 +000036
37/* This file is included in all Valgrind source files, including
38 assembly ones. */
39
sewardj91f62782004-11-29 19:47:54 +000040
sewardjd79ef682004-11-26 13:25:17 +000041/* Magic values that the guest state might be set to when returning to the
sewardjde4a1d02002-03-22 01:27:54 +000042 dispatcher. The only other legitimate value is to point to the
sewardjd79ef682004-11-26 13:25:17 +000043 start of the thread's VEX guest state. These also are return values from
sewardjb5f6f512005-03-10 23:59:00 +000044 from VG_(run_innerloop) to the scheduler.
sewardj2a99cf62004-11-24 10:44:19 +000045*/
sewardj91f62782004-11-29 19:47:54 +000046/* Defines values for JMP_EMWARN, JMP_SYSCALL, JMP_CLIENTREQ and
47 JMP_YIELD */
sewardjd79ef682004-11-26 13:25:17 +000048#include "libvex_trc_values.h"
sewardj54cacf02002-04-12 23:24:59 +000049
sewardj91f62782004-11-29 19:47:54 +000050/* And some more of our own. These must not have the same values as
51 those from libvex_trc_values.h. */
sewardj5e2f0012004-12-13 14:10:34 +000052#define VG_TRC_INNER_FASTMISS 37 /* TRC only; means fast-cache miss. */
53#define VG_TRC_INNER_COUNTERZERO 41 /* TRC only; means bb ctr == 0 */
sewardjb5f6f512005-03-10 23:59:00 +000054#define VG_TRC_FAULT_SIGNAL 43 /* TRC only; got sigsegv/sigbus */
sewardj5390e662005-01-10 16:51:14 +000055#define VG_TRC_INVARIANT_FAILED 47 /* TRC only; invariant violation */
sewardj54cacf02002-04-12 23:24:59 +000056
sewardj91f62782004-11-29 19:47:54 +000057
sewardjb5f6f512005-03-10 23:59:00 +000058#define VG_MAX_TRC 128 /* Highest possible TRC value */
59
sewardjde4a1d02002-03-22 01:27:54 +000060/* Constants for the fast translation lookup cache. */
sewardjfa8ec112005-01-19 11:55:34 +000061#define VG_TT_FAST_BITS 16
sewardjde4a1d02002-03-22 01:27:54 +000062#define VG_TT_FAST_SIZE (1 << VG_TT_FAST_BITS)
63#define VG_TT_FAST_MASK ((VG_TT_FAST_SIZE) - 1)
64
nethercote463c63c2004-10-26 11:18:32 +000065// XXX: all this will go into x86/ eventually...
fitzhardinge27574172004-01-26 21:11:51 +000066/*
67 0 - standard feature flags
68 1 - Intel extended flags
69 2 - Valgrind internal flags
70 3 - AMD-specific flags
71 */
72#define VG_N_FEATURE_WORDS 4
fitzhardinge0df2ac22004-01-25 02:38:29 +000073
fitzhardinge27574172004-01-26 21:11:51 +000074#define VG_X86_FEAT 0
75#define VG_EXT_FEAT 1
76#define VG_INT_FEAT 2
77#define VG_AMD_FEAT 3
78
79/* CPU features (generic) */
80#define VG_X86_FEAT_FPU (VG_X86_FEAT*32 + 0)
81#define VG_X86_FEAT_VME (VG_X86_FEAT*32 + 1)
82#define VG_X86_FEAT_DE (VG_X86_FEAT*32 + 2)
83#define VG_X86_FEAT_PSE (VG_X86_FEAT*32 + 3)
84#define VG_X86_FEAT_TSC (VG_X86_FEAT*32 + 4)
85#define VG_X86_FEAT_MSR (VG_X86_FEAT*32 + 5)
86#define VG_X86_FEAT_PAE (VG_X86_FEAT*32 + 6)
87#define VG_X86_FEAT_MCE (VG_X86_FEAT*32 + 7)
88#define VG_X86_FEAT_CX8 (VG_X86_FEAT*32 + 8)
89#define VG_X86_FEAT_APIC (VG_X86_FEAT*32 + 9)
90#define VG_X86_FEAT_SEP (VG_X86_FEAT*32 + 11)
91#define VG_X86_FEAT_MTRR (VG_X86_FEAT*32 + 12)
92#define VG_X86_FEAT_PGE (VG_X86_FEAT*32 + 13)
93#define VG_X86_FEAT_MCA (VG_X86_FEAT*32 + 14)
94#define VG_X86_FEAT_CMOV (VG_X86_FEAT*32 + 15)
95#define VG_X86_FEAT_PAT (VG_X86_FEAT*32 + 16)
96#define VG_X86_FEAT_PSE36 (VG_X86_FEAT*32 + 17)
97#define VG_X86_FEAT_CLFSH (VG_X86_FEAT*32 + 19)
98#define VG_X86_FEAT_DS (VG_X86_FEAT*32 + 21)
99#define VG_X86_FEAT_ACPI (VG_X86_FEAT*32 + 22)
100#define VG_X86_FEAT_MMX (VG_X86_FEAT*32 + 23)
101#define VG_X86_FEAT_FXSR (VG_X86_FEAT*32 + 24)
102#define VG_X86_FEAT_SSE (VG_X86_FEAT*32 + 25)
103#define VG_X86_FEAT_SSE2 (VG_X86_FEAT*32 + 26)
104#define VG_X86_FEAT_SS (VG_X86_FEAT*32 + 27)
105#define VG_X86_FEAT_HT (VG_X86_FEAT*32 + 28)
106#define VG_X86_FEAT_TM (VG_X86_FEAT*32 + 29)
107#define VG_X86_FEAT_IA64 (VG_X86_FEAT*32 + 30)
108#define VG_X86_FEAT_PBE (VG_X86_FEAT*32 + 31)
109
110/* Intel extended feature word */
111#define VG_X86_FEAT_SSE3 (VG_EXT_FEAT*32 + 0)
112#define VG_X86_FEAT_MON (VG_EXT_FEAT*32 + 3)
113#define VG_X86_FEAT_DSCPL (VG_EXT_FEAT*32 + 4)
114#define VG_X86_FEAT_EST (VG_EXT_FEAT*32 + 7)
115#define VG_X86_FEAT_TM2 (VG_EXT_FEAT*32 + 8)
116#define VG_X86_FEAT_CNXTID (VG_EXT_FEAT*32 + 10)
fitzhardinge0df2ac22004-01-25 02:38:29 +0000117
118/* Used internally to mark whether CPUID is even implemented */
fitzhardinge27574172004-01-26 21:11:51 +0000119#define VG_X86_FEAT_CPUID (VG_INT_FEAT*32 + 0)
fitzhardinge0df2ac22004-01-25 02:38:29 +0000120
fitzhardinge27574172004-01-26 21:11:51 +0000121/* AMD special features */
122#define VG_AMD_FEAT_SYSCALL (VG_AMD_FEAT*32 + 11)
123#define VG_AMD_FEAT_NXP (VG_AMD_FEAT*32 + 20)
124#define VG_AMD_FEAT_MMXEXT (VG_AMD_FEAT*32 + 22)
125#define VG_AMD_FEAT_FFXSR (VG_AMD_FEAT*32 + 25)
126#define VG_AMD_FEAT_LONGMODE (VG_AMD_FEAT*32 + 29)
127#define VG_AMD_FEAT_3DNOWEXT (VG_AMD_FEAT*32 + 30)
128#define VG_AMD_FEAT_3DNOW (VG_AMD_FEAT*32 + 31)
129
nethercote463c63c2004-10-26 11:18:32 +0000130#endif /* __CORE_ASM_H */
sewardjde4a1d02002-03-22 01:27:54 +0000131
132/*--------------------------------------------------------------------*/
nethercote5a2664c2004-09-02 15:37:39 +0000133/*--- end ---*/
sewardjde4a1d02002-03-22 01:27:54 +0000134/*--------------------------------------------------------------------*/