|
From: <sv...@va...> - 2005-06-18 18:32:09
|
Author: njn
Date: 2005-06-18 19:31:26 +0100 (Sat, 18 Jun 2005)
New Revision: 3940
Log:
Move CPUID functions into their own module, m_cpuid.
Added:
trunk/coregrind/m_cpuid.S
trunk/coregrind/pub_core_cpuid.h
trunk/include/pub_tool_cpuid.h
Removed:
trunk/coregrind/amd64/
trunk/coregrind/arm/
trunk/coregrind/x86/
Modified:
trunk/cachegrind/cg-x86.c
trunk/configure.in
trunk/coregrind/
trunk/coregrind/Makefile.am
trunk/coregrind/m_translate.c
trunk/include/Makefile.am
trunk/include/tool.h
Modified: trunk/cachegrind/cg-x86.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/cachegrind/cg-x86.c 2005-06-18 16:41:30 UTC (rev 3939)
+++ trunk/cachegrind/cg-x86.c 2005-06-18 18:31:26 UTC (rev 3940)
@@ -29,6 +29,7 @@
*/
=20
#include "tool.h"
+#include "pub_tool_cpuid.h"
#include "pub_tool_libcbase.h"
#include "pub_tool_libcassert.h"
#include "pub_tool_libcprint.h"
Modified: trunk/configure.in
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/configure.in 2005-06-18 16:41:30 UTC (rev 3939)
+++ trunk/configure.in 2005-06-18 18:31:26 UTC (rev 3940)
@@ -430,9 +430,6 @@
coregrind/m_scheduler/Makefile=20
coregrind/m_sigframe/Makefile=20
coregrind/m_syswrap/Makefile=20
- coregrind/amd64/Makefile
- coregrind/arm/Makefile
- coregrind/x86/Makefile
addrcheck/Makefile
addrcheck/tests/Makefile
addrcheck/docs/Makefile
Property changes on: trunk/coregrind
___________________________________________________________________
Name: svn:ignore
- .deps
Makefile
Makefile.in
*.so
stage2
valgrind
vg_intercept.c
vg_replace_malloc.c
vg_toolint.c
vg_toolint.h
+ .deps
Makefile
Makefile.in
*.so
stage2
stage2.lds
valgrind
vg_intercept.c
vg_replace_malloc.c
vg_toolint.c
vg_toolint.h
Modified: trunk/coregrind/Makefile.am
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/Makefile.am 2005-06-18 16:41:30 UTC (rev 3939)
+++ trunk/coregrind/Makefile.am 2005-06-18 18:31:26 UTC (rev 3940)
@@ -14,13 +14,9 @@
## When building, we are only interested in the current arch/OS/platform=
.
## But when doing 'make dist', we are interested in every arch/OS/platfo=
rm.
## That's what DIST_SUBDIRS specifies.
-SUBDIRS =3D \
- $(VG_ARCH) \
- $(MODULES) .
+SUBDIRS =3D $(MODULES) .
=20
-DIST_SUBDIRS =3D \
- $(VG_ARCH_ALL) \
- $(MODULES) .
+DIST_SUBDIRS =3D $(MODULES) .
=20
AM_CPPFLAGS +=3D -DVG_LIBDIR=3D"\"$(valdir)"\" \
-DKICKSTART_BASE=3D@KICKSTART_BASE@
@@ -38,6 +34,7 @@
core.h \
coregrind.h \
pub_core_aspacemgr.h \
+ pub_core_cpuid.h \
pub_core_debuginfo.h \
pub_core_debuglog.h \
pub_core_demangle.h \
@@ -96,6 +93,7 @@
valgrind_LDADD=3D
=20
stage2_SOURCES =3D \
+ m_cpuid.S \
m_debuglog.c \
m_errormgr.c \
m_execontext.c \
@@ -135,7 +133,6 @@
m_aspacemgr/libaspacemgr.a \
m_sigframe/libsigframe.a \
m_syswrap/libsyswrap.a \
- ${VG_ARCH}/libarch.a \
@VEX_DIR@/libvex.a
=20
## These ones must be linked in with the --whole-archive flag, because t=
hey
Added: trunk/coregrind/m_cpuid.S
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_cpuid.S 2005-06-18 16:41:30 UTC (rev 3939)
+++ trunk/coregrind/m_cpuid.S 2005-06-18 18:31:26 UTC (rev 3940)
@@ -0,0 +1,151 @@
+
+##--------------------------------------------------------------------##
+##--- CPUID interface. m_cpuid.S ---##
+##--------------------------------------------------------------------##
+
+/*
+ This file is part of Valgrind, a dynamic binary instrumentation
+ framework.
+
+ Copyright (C) 2000-2005 Julian Seward=20
+ js...@ac...
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The GNU General Public License is contained in the file COPYING.
+*/
+
+#include "pub_basics_asm.h"
+
+/*
+ Bool VG_(has_cpuid)(void)
+ */
+.globl VG_(has_cpuid)
+#if defined(VGA_x86)
+ VG_(has_cpuid):
+ pushl %ebp
+ movl %esp, %ebp
+ pushl %ecx
+ pushfl
+ pushfl
+ popl %eax
+ movl %eax, %ecx
+ xorl $0x200000, %eax
+ pushl %eax
+ popfl
+ pushfl
+ popl %eax
+ popfl
+ xorl %ecx, %eax
+ andl $0x200000, %eax
+ shrl $21, %eax
+ popl %ecx
+ movl %ebp, %esp
+ popl %ebp
+ ret
+#elif defined(VGA_amd64)
+ VG_(has_cpuid):
+ movq $1, %rax
+ ret
+#endif
+
+/*
+ void VG_(cpuid)(UInt eax,
+ UInt* eax_ret, UInt* ebx_ret, UInt* ecx_ret, UInt* e=
dx_ret)
+ */
+.globl VG_(cpuid)
+#if defined(VGA_x86)
+ VG_(cpuid):
+ pushl %ebp
+ movl %esp, %ebp
+ pushl %eax
+ pushl %ebx
+ pushl %ecx
+ pushl %edx
+ pushl %esi
+ movl 8(%ebp), %eax
+ cpuid
+ movl 12(%ebp), %esi
+ testl %esi, %esi
+ jz 1f
+ movl %eax, (%esi)
+ 1:
+ movl 16(%ebp), %esi
+ testl %esi, %esi
+ jz 2f
+ movl %ebx, (%esi)
+ 2:
+ movl 20(%ebp), %esi
+ testl %esi, %esi
+ jz 3f
+ movl %ecx, (%esi)
+ 3:
+ movl 24(%ebp), %esi
+ testl %esi, %esi
+ jz 4f
+ movl %edx, (%esi)
+ 4:
+ popl %esi
+ popl %edx
+ popl %ecx
+ popl %ebx
+ popl %eax
+ movl %ebp, %esp
+ popl %ebp
+ ret
+#elif defined(VGA_amd64)
+ VG_(cpuid):
+ pushq %rbp
+ movq %rsp, %rbp
+ pushq %rbx
+ movl %edi, %eax
+ movq %rdx, %rdi
+ movq %rcx, %r9
+ /*
+ eax_ret now in %rsi
+ ebx_ret now in %rdi
+ ecx_ret now in %r9
+ edx_ret now in %r8
+ */
+ cpuid
+ testq %rsi, %rsi
+ jz 1f
+ movl %eax, (%rsi)
+ 1:
+ testq %rdi, %rdi
+ jz 2f
+ movl %ebx, (%rdi)
+ 2:
+ testq %r9, %r9
+ jz 3f
+ movl %ecx, (%r9)
+ 3:
+ testq %r8, %r8
+ jz 4f
+ movl %edx, (%r8)
+ 4:
+ popq %rbx
+ movq %rbp, %rsp
+ popq %rbp
+ ret
+#endif
+ =20
+/* Let the linker know we don't need an executable stack */
+.section .note.GNU-stack,"",@progbits
+ =09
+##--------------------------------------------------------------------##
+##--- end ---##
+##--------------------------------------------------------------------##
Modified: trunk/coregrind/m_translate.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_translate.c 2005-06-18 16:41:30 UTC (rev 3939)
+++ trunk/coregrind/m_translate.c 2005-06-18 18:31:26 UTC (rev 3940)
@@ -31,6 +31,7 @@
=20
#include "core.h"
#include "pub_core_aspacemgr.h"
+#include "pub_core_cpuid.h"
#include "pub_core_libcbase.h"
#include "pub_core_libcassert.h"
#include "pub_core_libcprint.h"
Added: trunk/coregrind/pub_core_cpuid.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/pub_core_cpuid.h 2005-06-18 16:41:30 UTC (rev 3939)
+++ trunk/coregrind/pub_core_cpuid.h 2005-06-18 18:31:26 UTC (rev 3940)
@@ -0,0 +1,45 @@
+
+/*--------------------------------------------------------------------*/
+/*--- Interface to CPUID. pub_core_cpuid.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+ This file is part of Valgrind, a dynamic binary instrumentation
+ framework.
+
+ Copyright (C) 2000-2005 Julian Seward
+ js...@ac...
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The GNU General Public License is contained in the file COPYING.
+*/
+
+#ifndef __PUB_CORE_CPUID_H
+#define __PUB_CORE_CPUID_H
+
+//--------------------------------------------------------------------
+// PURPOSE: This module provides Valgrind's interface to the x86/amd64
+// CPUID instruction.
+//--------------------------------------------------------------------
+
+#include "pub_tool_cpuid.h"
+
+#endif // __PUB_CORE_CPUID_H
+
+/*--------------------------------------------------------------------*/
+/*--- end ---*/
+/*--------------------------------------------------------------------*/
Modified: trunk/include/Makefile.am
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/include/Makefile.am 2005-06-18 16:41:30 UTC (rev 3939)
+++ trunk/include/Makefile.am 2005-06-18 18:31:26 UTC (rev 3940)
@@ -6,6 +6,7 @@
tool.h \
pub_basics_asm.h \
pub_tool_aspacemgr.h \
+ pub_tool_cpuid.h \
pub_tool_errormgr.h \
pub_tool_execontext.h \
pub_tool_hashtable.h \
Added: trunk/include/pub_tool_cpuid.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/include/pub_tool_cpuid.h 2005-06-18 16:41:30 UTC (rev 3939)
+++ trunk/include/pub_tool_cpuid.h 2005-06-18 18:31:26 UTC (rev 3940)
@@ -0,0 +1,46 @@
+
+/*--------------------------------------------------------------------*/
+/*--- Interface to CPUID. pub_tool_cpuid.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+ This file is part of Valgrind, a dynamic binary instrumentation
+ framework.
+
+ Copyright (C) 2000-2005 Julian Seward
+ js...@ac...
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The GNU General Public License is contained in the file COPYING.
+*/
+
+#ifndef __PUB_TOOL_CPUID_H
+#define __PUB_TOOL_CPUID_H
+
+#if defined(VGA_x86) || defined(VGA_amd64)
+extern Bool VG_(has_cpuid) ( void );
+
+extern void VG_(cpuid) ( UInt eax,
+ UInt* eax_ret, UInt* ebx_ret,
+ UInt* ecx_ret, UInt* edx_ret );
+#endif
+
+#endif // __PUB_TOOL_CPUID_H
+
+/*--------------------------------------------------------------------*/
+/*--- end ---*/
+/*--------------------------------------------------------------------*/
Modified: trunk/include/tool.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/include/tool.h 2005-06-18 16:41:30 UTC (rev 3939)
+++ trunk/include/tool.h 2005-06-18 18:31:26 UTC (rev 3940)
@@ -68,18 +68,6 @@
( Bool (*p) ( Addr stack_min, Addr stack_max, vo=
id* d ),
void* d );
=20
-/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
-/*=3D=3D=3D Valgrind's version of libc =
=3D=3D=3D*/
-/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
-
-/* ------------------------------------------------------------------ */
-/* other, randomly useful functions */
-extern Bool VG_(has_cpuid) ( void );
-
-extern void VG_(cpuid) ( UInt eax,
- UInt *eax_ret, UInt *ebx_ret,
- UInt *ecx_ret, UInt *edx_ret );
-
#endif /* __TOOL_H */
=20
=20
|