blob: 660d3ff43447eed4ac16d6df562096f11dd2634f [file] [log] [blame]
njnf536bbb2005-06-13 04:21:38 +00001
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)
njnaf839f52005-06-23 03:27:57 +000043# define VG_ELF_ENDIANNESS ELFDATA2LSB
44# define VG_ELF_MACHINE EM_386
45# define VG_ELF_CLASS ELFCLASS32
njnf536bbb2005-06-13 04:21:38 +000046#elif defined(VGA_amd64)
njnaf839f52005-06-23 03:27:57 +000047# define VG_ELF_ENDIANNESS ELFDATA2LSB
48# define VG_ELF_MACHINE EM_X86_64
49# define VG_ELF_CLASS ELFCLASS64
njnf536bbb2005-06-13 04:21:38 +000050#elif defined(VGA_arm)
njnaf839f52005-06-23 03:27:57 +000051# define VG_ELF_ENDIANNESS ELFDATA2LSB
52# define VG_ELF_MACHINE EM_ARM
53# define VG_ELF_CLASS ELFCLASS32
cerion85665ca2005-06-20 15:51:07 +000054#elif defined(VGA_ppc32)
njnaf839f52005-06-23 03:27:57 +000055# define VG_ELF_ENDIANNESS ELFDATA2MSB
56# define VG_ELF_MACHINE EM_PPC
57# define VG_ELF_CLASS ELFCLASS32
njnf536bbb2005-06-13 04:21:38 +000058#else
59# error Unknown arch
60#endif
61
62#if defined(VGA_x86)
njnaf839f52005-06-23 03:27:57 +000063# define VG_INSTR_PTR guest_EIP
64# define VG_STACK_PTR guest_ESP
65# define VG_FRAME_PTR guest_EBP
njnf536bbb2005-06-13 04:21:38 +000066#elif defined(VGA_amd64)
njnaf839f52005-06-23 03:27:57 +000067# define VG_INSTR_PTR guest_RIP
68# define VG_STACK_PTR guest_RSP
69# define VG_FRAME_PTR guest_RBP
njnf536bbb2005-06-13 04:21:38 +000070#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
njnaf839f52005-06-23 03:27:57 +000077# define VG_INSTR_PTR guest_R15
78# define VG_STACK_PTR guest_R13
79# define VG_FRAME_PTR guest_R11
cerion85665ca2005-06-20 15:51:07 +000080#elif defined(VGA_ppc32)
njnaf839f52005-06-23 03:27:57 +000081# 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
njnf536bbb2005-06-13 04:21:38 +000084#else
85# error Unknown arch
86#endif
87
88// Offsets for the Vex state
njnaf839f52005-06-23 03:27:57 +000089#define VG_O_STACK_PTR (offsetof(VexGuestArchState, VG_STACK_PTR))
njnf536bbb2005-06-13 04:21:38 +000090
sewardj10f08cf2005-06-29 10:16:14 +000091// 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)
97extern Int VG_(cache_line_size_ppc32);
98#endif
99
njnf536bbb2005-06-13 04:21:38 +0000100#endif // __PUB_CORE_MACHINE_H
101
102/*--------------------------------------------------------------------*/
103/*--- end ---*/
104/*--------------------------------------------------------------------*/