]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Move CPUID functions into their own module, m_cpuid.
authorNicholas Nethercote <njn@valgrind.org>
Sat, 18 Jun 2005 18:31:26 +0000 (18:31 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Sat, 18 Jun 2005 18:31:26 +0000 (18:31 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3940

14 files changed:
cachegrind/cg-x86.c
configure.in
coregrind/Makefile.am
coregrind/amd64/Makefile.am [deleted file]
coregrind/amd64/cpuid.S [deleted file]
coregrind/arm/Makefile.am [deleted file]
coregrind/m_cpuid.S [moved from coregrind/x86/cpuid.S with 69% similarity]
coregrind/m_translate.c
coregrind/pub_core_cpuid.h [new file with mode: 0644]
coregrind/x86/.cvsignore [deleted file]
coregrind/x86/Makefile.am [deleted file]
include/Makefile.am
include/pub_tool_cpuid.h [new file with mode: 0644]
include/tool.h

index b7bce81e42d970a00456a3df3f5867c59f16e014..d0dc588567310b3fb43f36181f5a2c4c5bc35a8d 100644 (file)
@@ -29,6 +29,7 @@
 */
 
 #include "tool.h"
+#include "pub_tool_cpuid.h"
 #include "pub_tool_libcbase.h"
 #include "pub_tool_libcassert.h"
 #include "pub_tool_libcprint.h"
index 96e698ad02ff1c155f9241e514236984b7cb0abf..d10a795b4dc636d0f7b205b36c0ea135a0d9019c 100644 (file)
@@ -430,9 +430,6 @@ AC_OUTPUT(
    coregrind/m_scheduler/Makefile 
    coregrind/m_sigframe/Makefile 
    coregrind/m_syswrap/Makefile 
-   coregrind/amd64/Makefile
-   coregrind/arm/Makefile
-   coregrind/x86/Makefile
    addrcheck/Makefile
    addrcheck/tests/Makefile
    addrcheck/docs/Makefile
index 214c2671277d788d2d808107e26594148f1e10ee..a0f87e3d96f3219c09fd4b4e8f01e06f455b9b72 100644 (file)
@@ -14,13 +14,9 @@ MODULES = \
 ## When building, we are only interested in the current arch/OS/platform.
 ## But when doing 'make dist', we are interested in every arch/OS/platform.
 ## That's what DIST_SUBDIRS specifies.
-SUBDIRS = \
-       $(VG_ARCH) \
-       $(MODULES) .
+SUBDIRS = $(MODULES) .
 
-DIST_SUBDIRS = \
-       $(VG_ARCH_ALL) \
-       $(MODULES) .
+DIST_SUBDIRS = $(MODULES) .
 
 AM_CPPFLAGS += -DVG_LIBDIR="\"$(valdir)"\" \
                -DKICKSTART_BASE=@KICKSTART_BASE@
@@ -38,6 +34,7 @@ noinst_HEADERS = \
        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_LDFLAGS=-static -g
 valgrind_LDADD=
 
 stage2_SOURCES = \
+       m_cpuid.S \
        m_debuglog.c \
        m_errormgr.c \
        m_execontext.c \
@@ -135,7 +133,6 @@ stage2_extra= \
        m_aspacemgr/libaspacemgr.a \
        m_sigframe/libsigframe.a \
        m_syswrap/libsyswrap.a \
-       ${VG_ARCH}/libarch.a \
        @VEX_DIR@/libvex.a
 
 ## These ones must be linked in with the --whole-archive flag, because they
diff --git a/coregrind/amd64/Makefile.am b/coregrind/amd64/Makefile.am
deleted file mode 100644 (file)
index 8306f65..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-include $(top_srcdir)/Makefile.all.am
-include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am
-
-noinst_LIBRARIES = libarch.a
-
-libarch_a_SOURCES = \
-       cpuid.S
-
diff --git a/coregrind/amd64/cpuid.S b/coregrind/amd64/cpuid.S
deleted file mode 100644 (file)
index 7641f5a..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-
-##--------------------------------------------------------------------##
-##--- Support for determining CPU characteristics.   amd64/cpuid.S ---##
-##--------------------------------------------------------------------##
-
-/*
-  This file is part of Valgrind, a dynamic binary instrumentation
-  framework.
-
-  Copyright (C) 2000-2005 Julian Seward 
-     jseward@acm.org
-
-  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)
-VG_(has_cpuid):
-        movq    $1, %rax
-        ret
-
-/*
-    int VG_(cpuid)(UInt eax,
-                   UInt *eax_ret, UInt *ebx_ret, UInt *ecx_ret, UInt *edx_ret)
- */
-.globl VG_(cpuid)
-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
-        
-/* Let the linker know we don't need an executable stack */
-.section .note.GNU-stack,"",@progbits
-
-##--------------------------------------------------------------------##
-##--- end                                                         ---##
-##--------------------------------------------------------------------##
diff --git a/coregrind/arm/Makefile.am b/coregrind/arm/Makefile.am
deleted file mode 100644 (file)
index da669e9..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-include $(top_srcdir)/Makefile.all.am
-include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am
-
-noinst_LIBRARIES = libarch.a
-
-libarch_a_SOURCES =
-
similarity index 69%
rename from coregrind/x86/cpuid.S
rename to coregrind/m_cpuid.S
index 6fea1b5198833cacf782250e46c62b36b34e5342..c08a151508494c763b9d770b933cd7ddc76e8a2a 100644 (file)
@@ -1,6 +1,6 @@
 
 ##--------------------------------------------------------------------##
-##--- Support for determining CPU characteristics.     x86/cpuid.S ---##
+##--- CPUID interface.                                   m_cpuid.S ---##
 ##--------------------------------------------------------------------##
 
 /*
@@ -34,7 +34,8 @@
     Bool VG_(has_cpuid)(void)
  */
 .globl VG_(has_cpuid)
-VG_(has_cpuid):
+#if defined(VGA_x86)
+    VG_(has_cpuid):
         pushl   %ebp
         movl    %esp, %ebp
         pushl   %ecx
@@ -55,13 +56,19 @@ VG_(has_cpuid):
         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 *edx_ret)
+                    UInt* eax_ret, UInt* ebx_ret, UInt* ecx_ret, UInt* edx_ret)
  */
 .globl VG_(cpuid)
-VG_(cpuid):
+#if defined(VGA_x86)
+    VG_(cpuid):
         pushl   %ebp
         movl    %esp, %ebp
         pushl   %eax
@@ -75,22 +82,22 @@ VG_(cpuid):
         testl   %esi, %esi
         jz      1f
         movl    %eax, (%esi)
-1:
+    1:
         movl    16(%ebp), %esi
         testl   %esi, %esi
         jz      2f
         movl    %ebx, (%esi)
-2:
+    2:
         movl    20(%ebp), %esi
         testl   %esi, %esi
         jz      3f
         movl    %ecx, (%esi)
-3:
+    3:
         movl    24(%ebp), %esi
         testl   %esi, %esi
         jz      4f
         movl    %edx, (%esi)
-4:
+    4:
         popl    %esi
         popl    %edx
         popl    %ecx
@@ -99,10 +106,46 @@ VG_(cpuid):
         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
         
 /* Let the linker know we don't need an executable stack */
 .section .note.GNU-stack,"",@progbits
-
+               
 ##--------------------------------------------------------------------##
-##--- end                                                         ---##
+##--- end                                                          ---##
 ##--------------------------------------------------------------------##
index 0211808ea89e70164a9e7d7175c8569967062b66..5442fa56b0f6827a064e28c2c0f651edf12706b0 100644 (file)
@@ -31,6 +31,7 @@
 
 #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"
diff --git a/coregrind/pub_core_cpuid.h b/coregrind/pub_core_cpuid.h
new file mode 100644 (file)
index 0000000..f825336
--- /dev/null
@@ -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
+      jseward@acm.org
+
+   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                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/coregrind/x86/.cvsignore b/coregrind/x86/.cvsignore
deleted file mode 100644 (file)
index 1d5e32f..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-Makefile.in
-Makefile
-core_arch_asm_offsets.h
-gen_offsets
-stage2.lds
diff --git a/coregrind/x86/Makefile.am b/coregrind/x86/Makefile.am
deleted file mode 100644 (file)
index 8306f65..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-include $(top_srcdir)/Makefile.all.am
-include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am
-
-noinst_LIBRARIES = libarch.a
-
-libarch_a_SOURCES = \
-       cpuid.S
-
index bcd95030090e5871bf362d00d9da6f1e6494ecd7..5bf9b1d48ff53681f32be26c1beb6e407d1df6fe 100644 (file)
@@ -6,6 +6,7 @@ incinc_HEADERS = \
        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            \
diff --git a/include/pub_tool_cpuid.h b/include/pub_tool_cpuid.h
new file mode 100644 (file)
index 0000000..b37d458
--- /dev/null
@@ -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
+      jseward@acm.org
+
+   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                                                          ---*/
+/*--------------------------------------------------------------------*/
index f78f40da16ef1aaaeb4191a67b9d111dc706cfa6..52a3a1df18b53d07b74551a14a86516f6ff75f4a 100644 (file)
@@ -68,18 +68,6 @@ extern ThreadId VG_(first_matching_thread_stack)
                         ( Bool (*p) ( Addr stack_min, Addr stack_max, void* d ),
                           void* d );
 
-/*====================================================================*/
-/*=== Valgrind's version of libc                                   ===*/
-/*====================================================================*/
-
-/* ------------------------------------------------------------------ */
-/* 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 */