1
/****************************************************************************
3
* Inline helpers for x86emu
5
* Copyright (C) 2008 Bart Trojanowski, Symbio Technologies, LLC
7
* ========================================================================
9
* Permission to use, copy, modify, distribute, and sell this software and
10
* its documentation for any purpose is hereby granted without fee,
11
* provided that the above copyright notice appear in all copies and that
12
* both that copyright notice and this permission notice appear in
13
* supporting documentation, and that the name of the authors not be used
14
* in advertising or publicity pertaining to distribution of the software
15
* without specific, written prior permission. The authors makes no
16
* representations about the suitability of this software for any purpose.
17
* It is provided "as is" without express or implied warranty.
19
* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
20
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
21
* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
22
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
23
* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
24
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
25
* PERFORMANCE OF THIS SOFTWARE.
27
* ========================================================================
30
* Environment: GCC on i386 or x86-64
31
* Developer: Bart Trojanowski
33
* Description: This file defines a few x86 macros that can be used by the
34
* emulator to execute native instructions.
36
* For PIC vs non-PIC code refer to:
37
* http://sam.zoy.org/blog/2007-04-13-shlib-with-non-pic-code-have-inline-assembly-and-pic-mix-well
39
****************************************************************************/
40
#ifndef __X86EMU_PRIM_X86_GCC_H
41
#define __X86EMU_PRIM_X86_GCC_H
43
#include "x86emu/types.h"
45
#if !defined(__GNUC__) || !(defined (__i386__) || defined(__i386) || defined(__AMD64__) || defined(__amd64__))
46
#error This file is intended to be used by gcc on i386 or x86-64 system
49
#if defined(__PIC__) && defined(__i386__)
51
#define X86EMU_HAS_HW_CPUID 1
52
static inline void hw_cpuid (u32 *a, u32 *b, u32 *c, u32 *d)
54
__asm__ __volatile__ ("pushl %%ebx \n\t"
58
: "=a" (*a), "=r" (*b),
64
#else // ! (__PIC__ && __i386__)
66
#define x86EMU_HAS_HW_CPUID 1
67
static inline void hw_cpuid (u32 *a, u32 *b, u32 *c, u32 *d)
69
__asm__ __volatile__ ("cpuid"
70
: "=a" (*a), "=b" (*b),
76
#endif // __PIC__ && __i386__
79
#endif // __X86EMU_PRIM_X86_GCC_H