blob: 9d470d4636dc7affee46d355d7b7161f92a96dc8 [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/*
njnc9539842002-10-02 13:26:35 +00007 This file is part of Valgrind, an extensible x86 protected-mode
8 emulator for monitoring program execution on x86-Unixes.
sewardjde4a1d02002-03-22 01:27:54 +00009
nethercotebb1c9912004-01-04 16:43:23 +000010 Copyright (C) 2000-2004 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
nethercote5a2664c2004-09-02 15:37:39 +000034#include "tool_asm.h"
sewardjde4a1d02002-03-22 01:27:54 +000035
36/* This file is included in all Valgrind source files, including
37 assembly ones. */
38
sewardj2e93c502002-04-12 11:12:52 +000039/* Magic values that %ebp might be set to when returning to the
sewardjde4a1d02002-03-22 01:27:54 +000040 dispatcher. The only other legitimate value is to point to the
sewardj2e93c502002-04-12 11:12:52 +000041 start of VG_(baseBlock). These also are return values from
sewardj54cacf02002-04-12 23:24:59 +000042 VG_(run_innerloop) to the scheduler.
sewardj2e93c502002-04-12 11:12:52 +000043
sewardj54cacf02002-04-12 23:24:59 +000044 EBP means %ebp can legitimately have this value when a basic block
45 returns to the dispatch loop. TRC means that this value is a valid
46 thread return code, which the dispatch loop may return to the
47 scheduler. */
sewardj54cacf02002-04-12 23:24:59 +000048#define VG_TRC_EBP_JMP_SYSCALL 19 /* EBP and TRC */
49#define VG_TRC_EBP_JMP_CLIENTREQ 23 /* EBP and TRC */
fitzhardingea02f8812003-12-18 09:06:09 +000050#define VG_TRC_EBP_JMP_YIELD 27 /* EBP and TRC */
sewardj54cacf02002-04-12 23:24:59 +000051
njn25e49d8e72002-09-23 09:36:25 +000052#define VG_TRC_INNER_FASTMISS 31 /* TRC only; means fast-cache miss. */
53#define VG_TRC_INNER_COUNTERZERO 29 /* TRC only; means bb ctr == 0 */
54#define VG_TRC_UNRESUMABLE_SIGNAL 37 /* TRC only; got sigsegv/sigbus */
sewardj54cacf02002-04-12 23:24:59 +000055
sewardj22854b92002-11-30 14:00:47 +000056/* size of call instruction put into generated code at jump sites */
57#define VG_PATCHME_CALLSZ 5
58
59/* size of jmp instruction which overwrites the call */
60#define VG_PATCHME_JMPSZ 5
61
62/* maximum number of normal jumps which can appear in a basic block */
63#define VG_MAX_JUMPS 2
64
65/* Offset of code in a TCEntry */
66#define VG_CODE_OFFSET (8 + VG_MAX_JUMPS * 2)
sewardjde4a1d02002-03-22 01:27:54 +000067
fitzhardinge98abfc72003-12-16 02:05:15 +000068/* Client address space segment limit descriptor entry */
69#define VG_POINTERCHECK_SEGIDX 1
70
sewardjde4a1d02002-03-22 01:27:54 +000071/* Debugging hack for assembly code ... sigh. */
72#if 0
73#define OYNK(nnn) pushal; pushl $nnn; call VG_(oynk) ; addl $4,%esp; popal
74#else
75#define OYNK(nnn)
76#endif
77
sewardj2e93c502002-04-12 11:12:52 +000078#if 0
sewardjde4a1d02002-03-22 01:27:54 +000079#define OYNNK(nnn) pushal; pushl $nnn; call VG_(oynk) ; addl $4,%esp; popal
80#else
81#define OYNNK(nnn)
82#endif
83
sewardj2e93c502002-04-12 11:12:52 +000084
sewardjde4a1d02002-03-22 01:27:54 +000085/* Constants for the fast translation lookup cache. */
86#define VG_TT_FAST_BITS 15
87#define VG_TT_FAST_SIZE (1 << VG_TT_FAST_BITS)
88#define VG_TT_FAST_MASK ((VG_TT_FAST_SIZE) - 1)
89
90/* Constants for the fast original-code-write check cache. */
91
sewardj2e93c502002-04-12 11:12:52 +000092
sewardj20917d82002-05-28 01:36:45 +000093/* Assembly code stubs make this request */
sewardj54cacf02002-04-12 23:24:59 +000094#define VG_USERREQ__SIGNAL_RETURNS 0x4001
sewardj54cacf02002-04-12 23:24:59 +000095
fitzhardinge27574172004-01-26 21:11:51 +000096/*
97 0 - standard feature flags
98 1 - Intel extended flags
99 2 - Valgrind internal flags
100 3 - AMD-specific flags
101 */
102#define VG_N_FEATURE_WORDS 4
fitzhardinge0df2ac22004-01-25 02:38:29 +0000103
fitzhardinge27574172004-01-26 21:11:51 +0000104#define VG_X86_FEAT 0
105#define VG_EXT_FEAT 1
106#define VG_INT_FEAT 2
107#define VG_AMD_FEAT 3
108
109/* CPU features (generic) */
110#define VG_X86_FEAT_FPU (VG_X86_FEAT*32 + 0)
111#define VG_X86_FEAT_VME (VG_X86_FEAT*32 + 1)
112#define VG_X86_FEAT_DE (VG_X86_FEAT*32 + 2)
113#define VG_X86_FEAT_PSE (VG_X86_FEAT*32 + 3)
114#define VG_X86_FEAT_TSC (VG_X86_FEAT*32 + 4)
115#define VG_X86_FEAT_MSR (VG_X86_FEAT*32 + 5)
116#define VG_X86_FEAT_PAE (VG_X86_FEAT*32 + 6)
117#define VG_X86_FEAT_MCE (VG_X86_FEAT*32 + 7)
118#define VG_X86_FEAT_CX8 (VG_X86_FEAT*32 + 8)
119#define VG_X86_FEAT_APIC (VG_X86_FEAT*32 + 9)
120#define VG_X86_FEAT_SEP (VG_X86_FEAT*32 + 11)
121#define VG_X86_FEAT_MTRR (VG_X86_FEAT*32 + 12)
122#define VG_X86_FEAT_PGE (VG_X86_FEAT*32 + 13)
123#define VG_X86_FEAT_MCA (VG_X86_FEAT*32 + 14)
124#define VG_X86_FEAT_CMOV (VG_X86_FEAT*32 + 15)
125#define VG_X86_FEAT_PAT (VG_X86_FEAT*32 + 16)
126#define VG_X86_FEAT_PSE36 (VG_X86_FEAT*32 + 17)
127#define VG_X86_FEAT_CLFSH (VG_X86_FEAT*32 + 19)
128#define VG_X86_FEAT_DS (VG_X86_FEAT*32 + 21)
129#define VG_X86_FEAT_ACPI (VG_X86_FEAT*32 + 22)
130#define VG_X86_FEAT_MMX (VG_X86_FEAT*32 + 23)
131#define VG_X86_FEAT_FXSR (VG_X86_FEAT*32 + 24)
132#define VG_X86_FEAT_SSE (VG_X86_FEAT*32 + 25)
133#define VG_X86_FEAT_SSE2 (VG_X86_FEAT*32 + 26)
134#define VG_X86_FEAT_SS (VG_X86_FEAT*32 + 27)
135#define VG_X86_FEAT_HT (VG_X86_FEAT*32 + 28)
136#define VG_X86_FEAT_TM (VG_X86_FEAT*32 + 29)
137#define VG_X86_FEAT_IA64 (VG_X86_FEAT*32 + 30)
138#define VG_X86_FEAT_PBE (VG_X86_FEAT*32 + 31)
139
140/* Intel extended feature word */
141#define VG_X86_FEAT_SSE3 (VG_EXT_FEAT*32 + 0)
142#define VG_X86_FEAT_MON (VG_EXT_FEAT*32 + 3)
143#define VG_X86_FEAT_DSCPL (VG_EXT_FEAT*32 + 4)
144#define VG_X86_FEAT_EST (VG_EXT_FEAT*32 + 7)
145#define VG_X86_FEAT_TM2 (VG_EXT_FEAT*32 + 8)
146#define VG_X86_FEAT_CNXTID (VG_EXT_FEAT*32 + 10)
fitzhardinge0df2ac22004-01-25 02:38:29 +0000147
148/* Used internally to mark whether CPUID is even implemented */
fitzhardinge27574172004-01-26 21:11:51 +0000149#define VG_X86_FEAT_CPUID (VG_INT_FEAT*32 + 0)
fitzhardinge0df2ac22004-01-25 02:38:29 +0000150
fitzhardinge27574172004-01-26 21:11:51 +0000151/* AMD special features */
152#define VG_AMD_FEAT_SYSCALL (VG_AMD_FEAT*32 + 11)
153#define VG_AMD_FEAT_NXP (VG_AMD_FEAT*32 + 20)
154#define VG_AMD_FEAT_MMXEXT (VG_AMD_FEAT*32 + 22)
155#define VG_AMD_FEAT_FFXSR (VG_AMD_FEAT*32 + 25)
156#define VG_AMD_FEAT_LONGMODE (VG_AMD_FEAT*32 + 29)
157#define VG_AMD_FEAT_3DNOWEXT (VG_AMD_FEAT*32 + 30)
158#define VG_AMD_FEAT_3DNOW (VG_AMD_FEAT*32 + 31)
159
fitzhardinge98abfc72003-12-16 02:05:15 +0000160/* Various environment variables we pay attention to */
161
162/* The directory we look for all our auxillary files in */
163#define VALGRINDLIB "VALGRINDLIB"
164
165/* Additional command-line arguments; they are overridden by actual
166 command-line option. Each argument is separated by spaces. There
167 is no quoting mechanism.
168 */
169#define VALGRINDOPTS "VALGRIND_OPTS"
170
171/* If this variable is present in the environment, then valgrind will
172 not parse the command line for options at all; all options come
173 from this variable. Arguments are terminated by ^A (\001). There
174 is no quoting mechanism.
175
176 This variable is not expected to be set by anything other than
177 Valgrind itself, as part of its handling of execve with
178 --trace-children=yes. This variable should not be present in the
179 client environment.
180 */
181#define VALGRINDCLO "_VALGRIND_CLO"
182
nethercote5a2664c2004-09-02 15:37:39 +0000183#endif /* ndef __CORE_ASM_H */
sewardjde4a1d02002-03-22 01:27:54 +0000184
185/*--------------------------------------------------------------------*/
nethercote5a2664c2004-09-02 15:37:39 +0000186/*--- end ---*/
sewardjde4a1d02002-03-22 01:27:54 +0000187/*--------------------------------------------------------------------*/