blob: 74f3023de99731ce3bd2963c594b84fec06de578 [file] [log] [blame]
sewardjde4a1d02002-03-22 01:27:54 +00001
2/*--------------------------------------------------------------------*/
3/*--- A header file containing constants (for assembly code). ---*/
4/*--- vg_constants.h ---*/
5/*--------------------------------------------------------------------*/
6
7/*
njnc9539842002-10-02 13:26:35 +00008 This file is part of Valgrind, an extensible x86 protected-mode
9 emulator for monitoring program execution on x86-Unixes.
sewardjde4a1d02002-03-22 01:27:54 +000010
nethercotebb1c9912004-01-04 16:43:23 +000011 Copyright (C) 2000-2004 Julian Seward
sewardjde4a1d02002-03-22 01:27:54 +000012 jseward@acm.org
sewardjde4a1d02002-03-22 01:27:54 +000013
14 This program is free software; you can redistribute it and/or
15 modify it under the terms of the GNU General Public License as
16 published by the Free Software Foundation; either version 2 of the
17 License, or (at your option) any later version.
18
19 This program is distributed in the hope that it will be useful, but
20 WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 General Public License for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
27 02111-1307, USA.
28
njn25e49d8e72002-09-23 09:36:25 +000029 The GNU General Public License is contained in the file COPYING.
sewardjde4a1d02002-03-22 01:27:54 +000030*/
31
32#ifndef __VG_CONSTANTS_H
33#define __VG_CONSTANTS_H
34
njn25e49d8e72002-09-23 09:36:25 +000035#include "vg_constants_skin.h"
sewardjde4a1d02002-03-22 01:27:54 +000036
37/* This file is included in all Valgrind source files, including
38 assembly ones. */
39
sewardj2e93c502002-04-12 11:12:52 +000040/* Magic values that %ebp might be set to when returning to the
sewardjde4a1d02002-03-22 01:27:54 +000041 dispatcher. The only other legitimate value is to point to the
sewardj2e93c502002-04-12 11:12:52 +000042 start of VG_(baseBlock). These also are return values from
sewardj54cacf02002-04-12 23:24:59 +000043 VG_(run_innerloop) to the scheduler.
sewardj2e93c502002-04-12 11:12:52 +000044
sewardj54cacf02002-04-12 23:24:59 +000045 EBP means %ebp can legitimately have this value when a basic block
46 returns to the dispatch loop. TRC means that this value is a valid
47 thread return code, which the dispatch loop may return to the
48 scheduler. */
sewardj54cacf02002-04-12 23:24:59 +000049#define VG_TRC_EBP_JMP_SYSCALL 19 /* EBP and TRC */
50#define VG_TRC_EBP_JMP_CLIENTREQ 23 /* EBP and TRC */
fitzhardingea02f8812003-12-18 09:06:09 +000051#define VG_TRC_EBP_JMP_YIELD 27 /* EBP and TRC */
sewardj54cacf02002-04-12 23:24:59 +000052
njn25e49d8e72002-09-23 09:36:25 +000053#define VG_TRC_INNER_FASTMISS 31 /* TRC only; means fast-cache miss. */
54#define VG_TRC_INNER_COUNTERZERO 29 /* TRC only; means bb ctr == 0 */
55#define VG_TRC_UNRESUMABLE_SIGNAL 37 /* TRC only; got sigsegv/sigbus */
sewardj54cacf02002-04-12 23:24:59 +000056
sewardj22854b92002-11-30 14:00:47 +000057/* size of call instruction put into generated code at jump sites */
58#define VG_PATCHME_CALLSZ 5
59
60/* size of jmp instruction which overwrites the call */
61#define VG_PATCHME_JMPSZ 5
62
63/* maximum number of normal jumps which can appear in a basic block */
64#define VG_MAX_JUMPS 2
65
66/* Offset of code in a TCEntry */
67#define VG_CODE_OFFSET (8 + VG_MAX_JUMPS * 2)
sewardjde4a1d02002-03-22 01:27:54 +000068
fitzhardinge98abfc72003-12-16 02:05:15 +000069/* Client address space segment limit descriptor entry */
70#define VG_POINTERCHECK_SEGIDX 1
71
sewardjde4a1d02002-03-22 01:27:54 +000072/* Debugging hack for assembly code ... sigh. */
73#if 0
74#define OYNK(nnn) pushal; pushl $nnn; call VG_(oynk) ; addl $4,%esp; popal
75#else
76#define OYNK(nnn)
77#endif
78
sewardj2e93c502002-04-12 11:12:52 +000079#if 0
sewardjde4a1d02002-03-22 01:27:54 +000080#define OYNNK(nnn) pushal; pushl $nnn; call VG_(oynk) ; addl $4,%esp; popal
81#else
82#define OYNNK(nnn)
83#endif
84
sewardj2e93c502002-04-12 11:12:52 +000085
sewardjde4a1d02002-03-22 01:27:54 +000086/* Constants for the fast translation lookup cache. */
87#define VG_TT_FAST_BITS 15
88#define VG_TT_FAST_SIZE (1 << VG_TT_FAST_BITS)
89#define VG_TT_FAST_MASK ((VG_TT_FAST_SIZE) - 1)
90
91/* Constants for the fast original-code-write check cache. */
92
sewardj2e93c502002-04-12 11:12:52 +000093
sewardj20917d82002-05-28 01:36:45 +000094/* Assembly code stubs make this request */
sewardj54cacf02002-04-12 23:24:59 +000095#define VG_USERREQ__SIGNAL_RETURNS 0x4001
sewardj54cacf02002-04-12 23:24:59 +000096
fitzhardinge0df2ac22004-01-25 02:38:29 +000097/* CPU features */
98#define VG_X86_FEAT_FPU (0*32 + 0)
99#define VG_X86_FEAT_VME (0*32 + 1)
100#define VG_X86_FEAT_DE (0*32 + 2)
101#define VG_X86_FEAT_PSE (0*32 + 3)
102#define VG_X86_FEAT_TSC (0*32 + 4)
103#define VG_X86_FEAT_MSR (0*32 + 5)
104#define VG_X86_FEAT_PAE (0*32 + 6)
105#define VG_X86_FEAT_MCE (0*32 + 7)
106#define VG_X86_FEAT_CX8 (0*32 + 8)
107#define VG_X86_FEAT_APIC (0*32 + 9)
108#define VG_X86_FEAT_SEP (0*32 + 11)
109#define VG_X86_FEAT_MTRR (0*32 + 12)
110#define VG_X86_FEAT_PGE (0*32 + 13)
111#define VG_X86_FEAT_MCA (0*32 + 14)
112#define VG_X86_FEAT_CMOV (0*32 + 15)
113#define VG_X86_FEAT_PAT (0*32 + 16)
114#define VG_X86_FEAT_PSE36 (0*32 + 17)
115#define VG_X86_FEAT_CLFSH (0*32 + 19)
116#define VG_X86_FEAT_DS (0*32 + 21)
117#define VG_X86_FEAT_ACPI (0*32 + 22)
118#define VG_X86_FEAT_MMX (0*32 + 23)
119#define VG_X86_FEAT_FXSR (0*32 + 24)
120#define VG_X86_FEAT_SSE (0*32 + 25)
121#define VG_X86_FEAT_SSE2 (0*32 + 26)
122#define VG_X86_FEAT_SS (0*32 + 27)
123#define VG_X86_FEAT_HT (0*32 + 28)
124#define VG_X86_FEAT_TM (0*32 + 29)
125#define VG_X86_FEAT_PBE (0*32 + 31)
126
127#define VG_X86_FEAT_EST (1*32 + 7)
128#define VG_X86_FEAT_TM2 (1*32 + 8)
129#define VG_X86_FEAT_CNXTID (1*32 + 10)
130
131/* Used internally to mark whether CPUID is even implemented */
132#define VG_X86_FEAT_CPUID (2*32 + 0)
133
134/* The set of features we're willing to support for the client */
135#define VG_SUPPORTED_FEATURES \
136 ((1 << VG_X86_FEAT_FPU) | \
137 (1 << VG_X86_FEAT_TSC) | \
138 (1 << VG_X86_FEAT_CMOV) | \
139 (1 << VG_X86_FEAT_MMX) | \
140 (1 << VG_X86_FEAT_FXSR) | \
141 (1 << VG_X86_FEAT_SSE) | \
142 (1 << VG_X86_FEAT_SSE2))
143
fitzhardinge98abfc72003-12-16 02:05:15 +0000144/* Various environment variables we pay attention to */
145
146/* The directory we look for all our auxillary files in */
147#define VALGRINDLIB "VALGRINDLIB"
148
149/* Additional command-line arguments; they are overridden by actual
150 command-line option. Each argument is separated by spaces. There
151 is no quoting mechanism.
152 */
153#define VALGRINDOPTS "VALGRIND_OPTS"
154
155/* If this variable is present in the environment, then valgrind will
156 not parse the command line for options at all; all options come
157 from this variable. Arguments are terminated by ^A (\001). There
158 is no quoting mechanism.
159
160 This variable is not expected to be set by anything other than
161 Valgrind itself, as part of its handling of execve with
162 --trace-children=yes. This variable should not be present in the
163 client environment.
164 */
165#define VALGRINDCLO "_VALGRIND_CLO"
166
njn25e49d8e72002-09-23 09:36:25 +0000167#endif /* ndef __VG_CONSTANTS_H */
sewardjde4a1d02002-03-22 01:27:54 +0000168
169/*--------------------------------------------------------------------*/
170/*--- end vg_constants.h ---*/
171/*--------------------------------------------------------------------*/