sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1 | |
| 2 | /*--------------------------------------------------------------------*/ |
| 3 | /*--- A header file containing constants (for assembly code). ---*/ |
| 4 | /*--- vg_constants.h ---*/ |
| 5 | /*--------------------------------------------------------------------*/ |
| 6 | |
| 7 | /* |
njn | c953984 | 2002-10-02 13:26:35 +0000 | [diff] [blame] | 8 | This file is part of Valgrind, an extensible x86 protected-mode |
| 9 | emulator for monitoring program execution on x86-Unixes. |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 10 | |
nethercote | bb1c991 | 2004-01-04 16:43:23 +0000 | [diff] [blame] | 11 | Copyright (C) 2000-2004 Julian Seward |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 12 | jseward@acm.org |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 13 | |
| 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 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 29 | The GNU General Public License is contained in the file COPYING. |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 30 | */ |
| 31 | |
| 32 | #ifndef __VG_CONSTANTS_H |
| 33 | #define __VG_CONSTANTS_H |
| 34 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 35 | #include "vg_constants_skin.h" |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 36 | |
| 37 | /* This file is included in all Valgrind source files, including |
| 38 | assembly ones. */ |
| 39 | |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 40 | /* Magic values that %ebp might be set to when returning to the |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 41 | dispatcher. The only other legitimate value is to point to the |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 42 | start of VG_(baseBlock). These also are return values from |
sewardj | 54cacf0 | 2002-04-12 23:24:59 +0000 | [diff] [blame] | 43 | VG_(run_innerloop) to the scheduler. |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 44 | |
sewardj | 54cacf0 | 2002-04-12 23:24:59 +0000 | [diff] [blame] | 45 | 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. */ |
sewardj | 54cacf0 | 2002-04-12 23:24:59 +0000 | [diff] [blame] | 49 | #define VG_TRC_EBP_JMP_SYSCALL 19 /* EBP and TRC */ |
| 50 | #define VG_TRC_EBP_JMP_CLIENTREQ 23 /* EBP and TRC */ |
fitzhardinge | a02f881 | 2003-12-18 09:06:09 +0000 | [diff] [blame] | 51 | #define VG_TRC_EBP_JMP_YIELD 27 /* EBP and TRC */ |
sewardj | 54cacf0 | 2002-04-12 23:24:59 +0000 | [diff] [blame] | 52 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 53 | #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 */ |
sewardj | 54cacf0 | 2002-04-12 23:24:59 +0000 | [diff] [blame] | 56 | |
sewardj | 22854b9 | 2002-11-30 14:00:47 +0000 | [diff] [blame] | 57 | /* 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) |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 68 | |
fitzhardinge | 98abfc7 | 2003-12-16 02:05:15 +0000 | [diff] [blame] | 69 | /* Client address space segment limit descriptor entry */ |
| 70 | #define VG_POINTERCHECK_SEGIDX 1 |
| 71 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 72 | /* 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 | |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 79 | #if 0 |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 80 | #define OYNNK(nnn) pushal; pushl $nnn; call VG_(oynk) ; addl $4,%esp; popal |
| 81 | #else |
| 82 | #define OYNNK(nnn) |
| 83 | #endif |
| 84 | |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 85 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 86 | /* 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 | |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 93 | |
sewardj | 20917d8 | 2002-05-28 01:36:45 +0000 | [diff] [blame] | 94 | /* Assembly code stubs make this request */ |
sewardj | 54cacf0 | 2002-04-12 23:24:59 +0000 | [diff] [blame] | 95 | #define VG_USERREQ__SIGNAL_RETURNS 0x4001 |
sewardj | 54cacf0 | 2002-04-12 23:24:59 +0000 | [diff] [blame] | 96 | |
fitzhardinge | 2757417 | 2004-01-26 21:11:51 +0000 | [diff] [blame^] | 97 | /* |
| 98 | 0 - standard feature flags |
| 99 | 1 - Intel extended flags |
| 100 | 2 - Valgrind internal flags |
| 101 | 3 - AMD-specific flags |
| 102 | */ |
| 103 | #define VG_N_FEATURE_WORDS 4 |
fitzhardinge | 0df2ac2 | 2004-01-25 02:38:29 +0000 | [diff] [blame] | 104 | |
fitzhardinge | 2757417 | 2004-01-26 21:11:51 +0000 | [diff] [blame^] | 105 | #define VG_X86_FEAT 0 |
| 106 | #define VG_EXT_FEAT 1 |
| 107 | #define VG_INT_FEAT 2 |
| 108 | #define VG_AMD_FEAT 3 |
| 109 | |
| 110 | /* CPU features (generic) */ |
| 111 | #define VG_X86_FEAT_FPU (VG_X86_FEAT*32 + 0) |
| 112 | #define VG_X86_FEAT_VME (VG_X86_FEAT*32 + 1) |
| 113 | #define VG_X86_FEAT_DE (VG_X86_FEAT*32 + 2) |
| 114 | #define VG_X86_FEAT_PSE (VG_X86_FEAT*32 + 3) |
| 115 | #define VG_X86_FEAT_TSC (VG_X86_FEAT*32 + 4) |
| 116 | #define VG_X86_FEAT_MSR (VG_X86_FEAT*32 + 5) |
| 117 | #define VG_X86_FEAT_PAE (VG_X86_FEAT*32 + 6) |
| 118 | #define VG_X86_FEAT_MCE (VG_X86_FEAT*32 + 7) |
| 119 | #define VG_X86_FEAT_CX8 (VG_X86_FEAT*32 + 8) |
| 120 | #define VG_X86_FEAT_APIC (VG_X86_FEAT*32 + 9) |
| 121 | #define VG_X86_FEAT_SEP (VG_X86_FEAT*32 + 11) |
| 122 | #define VG_X86_FEAT_MTRR (VG_X86_FEAT*32 + 12) |
| 123 | #define VG_X86_FEAT_PGE (VG_X86_FEAT*32 + 13) |
| 124 | #define VG_X86_FEAT_MCA (VG_X86_FEAT*32 + 14) |
| 125 | #define VG_X86_FEAT_CMOV (VG_X86_FEAT*32 + 15) |
| 126 | #define VG_X86_FEAT_PAT (VG_X86_FEAT*32 + 16) |
| 127 | #define VG_X86_FEAT_PSE36 (VG_X86_FEAT*32 + 17) |
| 128 | #define VG_X86_FEAT_CLFSH (VG_X86_FEAT*32 + 19) |
| 129 | #define VG_X86_FEAT_DS (VG_X86_FEAT*32 + 21) |
| 130 | #define VG_X86_FEAT_ACPI (VG_X86_FEAT*32 + 22) |
| 131 | #define VG_X86_FEAT_MMX (VG_X86_FEAT*32 + 23) |
| 132 | #define VG_X86_FEAT_FXSR (VG_X86_FEAT*32 + 24) |
| 133 | #define VG_X86_FEAT_SSE (VG_X86_FEAT*32 + 25) |
| 134 | #define VG_X86_FEAT_SSE2 (VG_X86_FEAT*32 + 26) |
| 135 | #define VG_X86_FEAT_SS (VG_X86_FEAT*32 + 27) |
| 136 | #define VG_X86_FEAT_HT (VG_X86_FEAT*32 + 28) |
| 137 | #define VG_X86_FEAT_TM (VG_X86_FEAT*32 + 29) |
| 138 | #define VG_X86_FEAT_IA64 (VG_X86_FEAT*32 + 30) |
| 139 | #define VG_X86_FEAT_PBE (VG_X86_FEAT*32 + 31) |
| 140 | |
| 141 | /* Intel extended feature word */ |
| 142 | #define VG_X86_FEAT_SSE3 (VG_EXT_FEAT*32 + 0) |
| 143 | #define VG_X86_FEAT_MON (VG_EXT_FEAT*32 + 3) |
| 144 | #define VG_X86_FEAT_DSCPL (VG_EXT_FEAT*32 + 4) |
| 145 | #define VG_X86_FEAT_EST (VG_EXT_FEAT*32 + 7) |
| 146 | #define VG_X86_FEAT_TM2 (VG_EXT_FEAT*32 + 8) |
| 147 | #define VG_X86_FEAT_CNXTID (VG_EXT_FEAT*32 + 10) |
fitzhardinge | 0df2ac2 | 2004-01-25 02:38:29 +0000 | [diff] [blame] | 148 | |
| 149 | /* Used internally to mark whether CPUID is even implemented */ |
fitzhardinge | 2757417 | 2004-01-26 21:11:51 +0000 | [diff] [blame^] | 150 | #define VG_X86_FEAT_CPUID (VG_INT_FEAT*32 + 0) |
fitzhardinge | 0df2ac2 | 2004-01-25 02:38:29 +0000 | [diff] [blame] | 151 | |
fitzhardinge | 2757417 | 2004-01-26 21:11:51 +0000 | [diff] [blame^] | 152 | /* AMD special features */ |
| 153 | #define VG_AMD_FEAT_SYSCALL (VG_AMD_FEAT*32 + 11) |
| 154 | #define VG_AMD_FEAT_NXP (VG_AMD_FEAT*32 + 20) |
| 155 | #define VG_AMD_FEAT_MMXEXT (VG_AMD_FEAT*32 + 22) |
| 156 | #define VG_AMD_FEAT_FFXSR (VG_AMD_FEAT*32 + 25) |
| 157 | #define VG_AMD_FEAT_LONGMODE (VG_AMD_FEAT*32 + 29) |
| 158 | #define VG_AMD_FEAT_3DNOWEXT (VG_AMD_FEAT*32 + 30) |
| 159 | #define VG_AMD_FEAT_3DNOW (VG_AMD_FEAT*32 + 31) |
| 160 | |
fitzhardinge | 98abfc7 | 2003-12-16 02:05:15 +0000 | [diff] [blame] | 161 | /* Various environment variables we pay attention to */ |
| 162 | |
| 163 | /* The directory we look for all our auxillary files in */ |
| 164 | #define VALGRINDLIB "VALGRINDLIB" |
| 165 | |
| 166 | /* Additional command-line arguments; they are overridden by actual |
| 167 | command-line option. Each argument is separated by spaces. There |
| 168 | is no quoting mechanism. |
| 169 | */ |
| 170 | #define VALGRINDOPTS "VALGRIND_OPTS" |
| 171 | |
| 172 | /* If this variable is present in the environment, then valgrind will |
| 173 | not parse the command line for options at all; all options come |
| 174 | from this variable. Arguments are terminated by ^A (\001). There |
| 175 | is no quoting mechanism. |
| 176 | |
| 177 | This variable is not expected to be set by anything other than |
| 178 | Valgrind itself, as part of its handling of execve with |
| 179 | --trace-children=yes. This variable should not be present in the |
| 180 | client environment. |
| 181 | */ |
| 182 | #define VALGRINDCLO "_VALGRIND_CLO" |
| 183 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 184 | #endif /* ndef __VG_CONSTANTS_H */ |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 185 | |
| 186 | /*--------------------------------------------------------------------*/ |
| 187 | /*--- end vg_constants.h ---*/ |
| 188 | /*--------------------------------------------------------------------*/ |