njn | f536bbb | 2005-06-13 04:21:38 +0000 | [diff] [blame] | 1 | |
| 2 | /*--------------------------------------------------------------------*/ |
| 3 | /*--- Machine-related things. pub_core_machine.h ---*/ |
| 4 | /*--------------------------------------------------------------------*/ |
| 5 | |
| 6 | /* |
| 7 | This file is part of Valgrind, a dynamic binary instrumentation |
| 8 | framework. |
| 9 | |
| 10 | Copyright (C) 2000-2005 Julian Seward |
| 11 | jseward@acm.org |
| 12 | |
| 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 | |
| 28 | The GNU General Public License is contained in the file COPYING. |
| 29 | */ |
| 30 | |
| 31 | #ifndef __PUB_CORE_MACHINE_H |
| 32 | #define __PUB_CORE_MACHINE_H |
| 33 | |
| 34 | //-------------------------------------------------------------------- |
| 35 | // PURPOSE: This module contains code related to the particular |
| 36 | // architecture, things like accessing guest state, endianness, word size, |
| 37 | // etc. |
| 38 | //-------------------------------------------------------------------- |
| 39 | |
| 40 | #include "pub_tool_machine.h" |
| 41 | |
| 42 | #if defined(VGA_x86) |
njn | af839f5 | 2005-06-23 03:27:57 +0000 | [diff] [blame] | 43 | # define VG_ELF_ENDIANNESS ELFDATA2LSB |
| 44 | # define VG_ELF_MACHINE EM_386 |
| 45 | # define VG_ELF_CLASS ELFCLASS32 |
njn | f536bbb | 2005-06-13 04:21:38 +0000 | [diff] [blame] | 46 | #elif defined(VGA_amd64) |
njn | af839f5 | 2005-06-23 03:27:57 +0000 | [diff] [blame] | 47 | # define VG_ELF_ENDIANNESS ELFDATA2LSB |
| 48 | # define VG_ELF_MACHINE EM_X86_64 |
| 49 | # define VG_ELF_CLASS ELFCLASS64 |
njn | f536bbb | 2005-06-13 04:21:38 +0000 | [diff] [blame] | 50 | #elif defined(VGA_arm) |
njn | af839f5 | 2005-06-23 03:27:57 +0000 | [diff] [blame] | 51 | # define VG_ELF_ENDIANNESS ELFDATA2LSB |
| 52 | # define VG_ELF_MACHINE EM_ARM |
| 53 | # define VG_ELF_CLASS ELFCLASS32 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 54 | #elif defined(VGA_ppc32) |
njn | af839f5 | 2005-06-23 03:27:57 +0000 | [diff] [blame] | 55 | # define VG_ELF_ENDIANNESS ELFDATA2MSB |
| 56 | # define VG_ELF_MACHINE EM_PPC |
| 57 | # define VG_ELF_CLASS ELFCLASS32 |
njn | f536bbb | 2005-06-13 04:21:38 +0000 | [diff] [blame] | 58 | #else |
| 59 | # error Unknown arch |
| 60 | #endif |
| 61 | |
| 62 | #if defined(VGA_x86) |
njn | af839f5 | 2005-06-23 03:27:57 +0000 | [diff] [blame] | 63 | # define VG_INSTR_PTR guest_EIP |
| 64 | # define VG_STACK_PTR guest_ESP |
| 65 | # define VG_FRAME_PTR guest_EBP |
njn | f536bbb | 2005-06-13 04:21:38 +0000 | [diff] [blame] | 66 | #elif defined(VGA_amd64) |
njn | af839f5 | 2005-06-23 03:27:57 +0000 | [diff] [blame] | 67 | # define VG_INSTR_PTR guest_RIP |
| 68 | # define VG_STACK_PTR guest_RSP |
| 69 | # define VG_FRAME_PTR guest_RBP |
njn | f536bbb | 2005-06-13 04:21:38 +0000 | [diff] [blame] | 70 | #elif defined(VGA_arm) |
| 71 | // XXX: Not sure, but I think: |
| 72 | // r11 = frame pointer |
| 73 | // r12 = "implicit parameter" (neither caller-save, nor callee-save) |
| 74 | // r13 = stack pointer |
| 75 | // r14 = link register |
| 76 | // r15 = program counter |
njn | af839f5 | 2005-06-23 03:27:57 +0000 | [diff] [blame] | 77 | # define VG_INSTR_PTR guest_R15 |
| 78 | # define VG_STACK_PTR guest_R13 |
| 79 | # define VG_FRAME_PTR guest_R11 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 80 | #elif defined(VGA_ppc32) |
njn | af839f5 | 2005-06-23 03:27:57 +0000 | [diff] [blame] | 81 | # define VG_INSTR_PTR guest_CIA |
| 82 | # define VG_STACK_PTR guest_GPR1 |
| 83 | # define VG_FRAME_PTR guest_GPR1 // No frame ptr for PPC |
njn | f536bbb | 2005-06-13 04:21:38 +0000 | [diff] [blame] | 84 | #else |
| 85 | # error Unknown arch |
| 86 | #endif |
| 87 | |
| 88 | // Offsets for the Vex state |
njn | af839f5 | 2005-06-23 03:27:57 +0000 | [diff] [blame] | 89 | #define VG_O_STACK_PTR (offsetof(VexGuestArchState, VG_STACK_PTR)) |
njn | f536bbb | 2005-06-13 04:21:38 +0000 | [diff] [blame] | 90 | |
sewardj | 10f08cf | 2005-06-29 10:16:14 +0000 | [diff] [blame^] | 91 | // Architecture specifics |
| 92 | |
| 93 | // PPC: what is the cache line size (for dcbz etc) ? |
| 94 | // This info is harvested on Linux at startup from the AT_SYSINFO |
| 95 | // entries. |
| 96 | #if defined(VGA_ppc32) |
| 97 | extern Int VG_(cache_line_size_ppc32); |
| 98 | #endif |
| 99 | |
njn | f536bbb | 2005-06-13 04:21:38 +0000 | [diff] [blame] | 100 | #endif // __PUB_CORE_MACHINE_H |
| 101 | |
| 102 | /*--------------------------------------------------------------------*/ |
| 103 | /*--- end ---*/ |
| 104 | /*--------------------------------------------------------------------*/ |