View | Details | Raw Unified | Return to bug 15300
Collapse All | Expand All

(-)a/hw/xfree86/x86emu/ops2.c (-1 / +15 lines)
Lines 328-333 static void x86emuOp2_pop_FS(u8 X86EMU_UNUSED(op2)) Link Here
328
}
328
}
329
329
330
/****************************************************************************
330
/****************************************************************************
331
REMARKS: CPUID takes EAX/ECX as inputs, writes EAX/EBX/ECX/EDX as output
332
Handles opcode 0x0f,0xa2
333
****************************************************************************/
334
static void x86emuOp2_cpuid(u8 X86EMU_UNUSED(op2))
335
{
336
    START_OF_INSTR();
337
    DECODE_PRINTF("CPUID\n");
338
    TRACE_AND_STEP();
339
    cpuid();
340
    DECODE_CLEAR_SEGOVR();
341
    END_OF_INSTR();
342
}
343
344
/****************************************************************************
331
REMARKS:
345
REMARKS:
332
Handles opcode 0x0f,0xa3
346
Handles opcode 0x0f,0xa3
333
****************************************************************************/
347
****************************************************************************/
Lines 2734-2740 void (*x86emu_optab2[256])(u8) = Link Here
2734
2748
2735
/*  0xa0 */ x86emuOp2_push_FS,
2749
/*  0xa0 */ x86emuOp2_push_FS,
2736
/*  0xa1 */ x86emuOp2_pop_FS,
2750
/*  0xa1 */ x86emuOp2_pop_FS,
2737
/*  0xa2 */ x86emuOp2_illegal_op,
2751
/*  0xa2 */ x86emuOp2_cpuid,
2738
/*  0xa3 */ x86emuOp2_bt_R,
2752
/*  0xa3 */ x86emuOp2_bt_R,
2739
/*  0xa4 */ x86emuOp2_shld_IMM,
2753
/*  0xa4 */ x86emuOp2_shld_IMM,
2740
/*  0xa5 */ x86emuOp2_shld_CL,
2754
/*  0xa5 */ x86emuOp2_shld_CL,
(-)a/hw/xfree86/x86emu/prim_ops.c (+59 lines)
Lines 102-107 Link Here
102
#define	PRIM_OPS_NO_REDEFINE_ASM
102
#define	PRIM_OPS_NO_REDEFINE_ASM
103
#include "x86emu/x86emui.h"
103
#include "x86emu/x86emui.h"
104
104
105
#if defined(__GNUC__)
106
# if defined (__i386__) || defined(__i386) || defined(__AMD64__) || defined(__x86_64__) || defined(__amd64__)
107
#  include "x86emu/prim_x86_gcc.h"
108
# endif
109
#endif
110
105
/*------------------------- Global Variables ------------------------------*/
111
/*------------------------- Global Variables ------------------------------*/
106
112
107
static u32 x86emu_parity_tab[8] =
113
static u32 x86emu_parity_tab[8] =
Lines 2654-2656 DB( if (CHECK_SP_ACCESS()) Link Here
2654
    return res;
2660
    return res;
2655
}
2661
}
2656
2662
2663
/****************************************************************************
2664
REMARKS:
2665
CPUID takes EAX/ECX as inputs, writes EAX/EBX/ECX/EDX as output
2666
****************************************************************************/
2667
void cpuid (void)
2668
{
2669
    u32 feature = M.x86.R_EAX;
2670
#ifdef X86EMU_HAS_HW_CPUID
2671
        // If the platform allows it, we will base our values on the real
2672
        // results from the CPUID instruction.  We limit support to the 
2673
        // first two features, and the results of those are sanitized.
2674
        if (feature <= 1)
2675
            hw_cpuid(&M.x86.R_EAX, &M.x86.R_EBX, &M.x86.R_ECX, &M.x86.R_EDX);
2676
#endif
2677
    switch (feature) {
2678
    case 0:
2679
        // Regardless if we have real data from the hardware, the emulator
2680
        // will only support upto feature 1, which we set in register EAX.
2681
        // Registers EBX:EDX:ECX contain a string identifying the CPU.
2682
        M.x86.R_EAX = 1;
2683
#ifndef X86EMU_HAS_HW_CPUID
2684
        // EBX:EDX:ECX = "GenuineIntel"
2685
        M.x86.R_EBX = 0x756e6547;
2686
        M.x86.R_EDX = 0x49656e69;
2687
        M.x86.R_ECX = 0x6c65746e;
2688
#endif
2689
        break;
2690
    case 1:
2691
#ifndef X86EMU_HAS_HW_CPUID
2692
        // If we don't have x86 compatible hardware, we return values from an
2693
        // Intel 486dx4; which was one of the first processors to have CPUID.
2694
        M.x86.R_EAX = 0x00000480;
2695
        M.x86.R_EBX = 0x00000000;
2696
        M.x86.R_ECX = 0x00000000;
2697
        M.x86.R_EDX = 0x00000002;	// VME
2698
#else
2699
        // In the case that we have hardware CPUID instruction, we make sure
2700
        // that the features reported are limited to TSC and VME.
2701
        M.x86.R_EDX &= 0x00000012;
2702
#endif
2703
        break;
2704
    default:
2705
        // Finally, we don't support any additional features.  Most CPUs
2706
        // return all zeros when queried for invalid or unsupported feature
2707
        // numbers.
2708
        M.x86.R_EAX = 0;
2709
        M.x86.R_EBX = 0;
2710
        M.x86.R_ECX = 0;
2711
        M.x86.R_EDX = 0;
2712
        break;
2713
    }
2714
}
2715
(-)a/hw/xfree86/x86emu/x86emu/prim_ops.h (+1 lines)
Lines 133-138 void push_word (u16 w); Link Here
133
void    push_long (u32 w);
133
void    push_long (u32 w);
134
u16     pop_word (void);
134
u16     pop_word (void);
135
u32		pop_long (void);
135
u32		pop_long (void);
136
void    cpuid (void);
136
137
137
#ifdef  __cplusplus
138
#ifdef  __cplusplus
138
}                       			/* End of "C" linkage for C++   	*/
139
}                       			/* End of "C" linkage for C++   	*/
(-)a/hw/xfree86/x86emu/x86emu/prim_x86_gcc.h (-1 / +79 lines)
Line 0 Link Here
0
- 
1
/****************************************************************************
2
*
3
* Inline helpers for x86emu
4
*
5
* Copyright (C) 2008 Bart Trojanowski, Symbio Technologies, LLC
6
*
7
*  ========================================================================
8
*
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.
18
*
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.
26
*
27
*  ========================================================================
28
*
29
* Language:     GNU C
30
* Environment:  GCC on i386 or x86-64
31
* Developer:    Bart Trojanowski
32
*
33
* Description:  This file defines a few x86 macros that can be used by the
34
*               emulator to execute native instructions.
35
*
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
38
*
39
****************************************************************************/
40
#ifndef __X86EMU_PRIM_X86_GCC_H
41
#define __X86EMU_PRIM_X86_GCC_H
42
43
#include "x86emu/types.h"
44
45
#if !defined(__GNUC__) || !(defined (__i386__) || defined(__i386) || defined(__AMD64__) || defined(__x86_64__) || defined(__amd64__))
46
#error This file is intended to be used by gcc on i386 or x86-64 system
47
#endif
48
49
#if defined(__PIC__) && defined(__i386__)
50
51
#define X86EMU_HAS_HW_CPUID 1
52
static inline void hw_cpuid (u32 *a, u32 *b, u32 *c, u32 *d)
53
{
54
    __asm__ __volatile__ ("pushl %%ebx      \n\t"
55
                          "cpuid            \n\t"
56
                          "movl %%ebx, %1   \n\t"
57
                          "popl %%ebx       \n\t"
58
                          : "=a" (*a), "=r" (*b),
59
                            "=c" (*c), "=d" (*d)
60
                          : "a" (*a), "c" (*c)
61
                          : "cc");
62
}
63
64
#else // ! (__PIC__ && __i386__)
65
66
#define X86EMU_HAS_HW_CPUID 1
67
static inline void hw_cpuid (u32 *a, u32 *b, u32 *c, u32 *d)
68
{
69
    __asm__ __volatile__ ("cpuid"
70
                          : "=a" (*a), "=b" (*b),
71
                            "=c" (*c), "=d" (*d)
72
                          : "a" (*a), "c" (*c)
73
                          : "cc");
74
}
75
76
#endif // __PIC__ && __i386__
77
78
79
#endif // __X86EMU_PRIM_X86_GCC_H

Return to bug 15300