blob: ed448814dab8176b930a4e282a001470a8b37c75 [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)
sewardj6e340c72005-07-10 00:53:42 +000043# define VG_ELF_DATA2XXX ELFDATA2LSB
njnaf839f52005-06-23 03:27:57 +000044# define VG_ELF_MACHINE EM_386
45# define VG_ELF_CLASS ELFCLASS32
njnf536bbb2005-06-13 04:21:38 +000046#elif defined(VGA_amd64)
sewardj6e340c72005-07-10 00:53:42 +000047# define VG_ELF_DATA2XXX ELFDATA2LSB
njnaf839f52005-06-23 03:27:57 +000048# define VG_ELF_MACHINE EM_X86_64
49# define VG_ELF_CLASS ELFCLASS64
cerion85665ca2005-06-20 15:51:07 +000050#elif defined(VGA_ppc32)
sewardj6e340c72005-07-10 00:53:42 +000051# define VG_ELF_DATA2XXX ELFDATA2MSB
njnaf839f52005-06-23 03:27:57 +000052# define VG_ELF_MACHINE EM_PPC
53# define VG_ELF_CLASS ELFCLASS32
njnf536bbb2005-06-13 04:21:38 +000054#else
55# error Unknown arch
56#endif
57
58#if defined(VGA_x86)
njnaf839f52005-06-23 03:27:57 +000059# define VG_INSTR_PTR guest_EIP
60# define VG_STACK_PTR guest_ESP
61# define VG_FRAME_PTR guest_EBP
njnf536bbb2005-06-13 04:21:38 +000062#elif defined(VGA_amd64)
njnaf839f52005-06-23 03:27:57 +000063# define VG_INSTR_PTR guest_RIP
64# define VG_STACK_PTR guest_RSP
65# define VG_FRAME_PTR guest_RBP
cerion85665ca2005-06-20 15:51:07 +000066#elif defined(VGA_ppc32)
njnaf839f52005-06-23 03:27:57 +000067# define VG_INSTR_PTR guest_CIA
68# define VG_STACK_PTR guest_GPR1
69# define VG_FRAME_PTR guest_GPR1 // No frame ptr for PPC
njnf536bbb2005-06-13 04:21:38 +000070#else
71# error Unknown arch
72#endif
73
sewardj7821e2e2005-08-08 00:35:46 +000074
njnf536bbb2005-06-13 04:21:38 +000075// Offsets for the Vex state
njnaf839f52005-06-23 03:27:57 +000076#define VG_O_STACK_PTR (offsetof(VexGuestArchState, VG_STACK_PTR))
njnf536bbb2005-06-13 04:21:38 +000077
sewardj7821e2e2005-08-08 00:35:46 +000078
sewardj10f08cf2005-06-29 10:16:14 +000079// Architecture specifics
80
81// PPC: what is the cache line size (for dcbz etc) ?
82// This info is harvested on Linux at startup from the AT_SYSINFO
83// entries.
84#if defined(VGA_ppc32)
85extern Int VG_(cache_line_size_ppc32);
86#endif
87
sewardj7821e2e2005-08-08 00:35:46 +000088// X86: set to 1 if the host is able to do {ld,st}mxcsr (load/store
89// the SSE control/status register.
90#if defined(VGA_x86)
91extern Int VG_(have_mxcsr_x86);
92#endif
93
94
njnf536bbb2005-06-13 04:21:38 +000095#endif // __PUB_CORE_MACHINE_H
96
97/*--------------------------------------------------------------------*/
98/*--- end ---*/
99/*--------------------------------------------------------------------*/