mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-03 18:13:01 +00:00
Move CPUID functions into their own module, m_cpuid.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3940
This commit is contained in:
parent
a0a6af2854
commit
f4871f2c72
@ -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"
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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 ---##
|
||||
##--------------------------------------------------------------------##
|
||||
@ -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 =
|
||||
|
||||
@ -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 ---##
|
||||
##--------------------------------------------------------------------##
|
||||
@ -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"
|
||||
|
||||
45
coregrind/pub_core_cpuid.h
Normal file
45
coregrind/pub_core_cpuid.h
Normal file
@ -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 ---*/
|
||||
/*--------------------------------------------------------------------*/
|
||||
@ -1,5 +0,0 @@
|
||||
Makefile.in
|
||||
Makefile
|
||||
core_arch_asm_offsets.h
|
||||
gen_offsets
|
||||
stage2.lds
|
||||
@ -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
|
||||
|
||||
@ -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 \
|
||||
|
||||
46
include/pub_tool_cpuid.h
Normal file
46
include/pub_tool_cpuid.h
Normal file
@ -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 ---*/
|
||||
/*--------------------------------------------------------------------*/
|
||||
@ -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 */
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user