/[pcsx2_0.9.7]/trunk/common/include/x86emitter/tools.h
ViewVC logotype

Contents of /trunk/common/include/x86emitter/tools.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 280 - (show annotations) (download)
Thu Dec 23 12:02:12 2010 UTC (9 years, 2 months ago) by william
File MIME type: text/plain
File size: 5544 byte(s)
re-commit (had local access denied errors when committing)
1 /* PCSX2 - PS2 Emulator for PCs
2 * Copyright (C) 2002-2010 PCSX2 Dev Team
3 *
4 * PCSX2 is free software: you can redistribute it and/or modify it under the terms
5 * of the GNU Lesser General Public License as published by the Free Software Found-
6 * ation, either version 3 of the License, or (at your option) any later version.
7 *
8 * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10 * PURPOSE. See the GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License along with PCSX2.
13 * If not, see <http://www.gnu.org/licenses/>.
14 */
15
16 #pragma once
17
18 #include "x86emitter.h"
19
20 enum x86VendorType
21 {
22 x86Vendor_Intel=0,
23 x86Vendor_AMD,
24 x86Vendor_Unknown,
25 };
26
27 // --------------------------------------------------------------------------------------
28 // x86capabilities
29 // --------------------------------------------------------------------------------------
30 class x86capabilities
31 {
32 public:
33 bool isIdentified;
34
35 public:
36 x86VendorType VendorID;
37
38 uint FamilyID; // Processor Family
39 uint Model; // Processor Model
40 uint TypeID; // Processor Type
41 uint StepID; // Stepping ID
42
43 u32 Flags; // Feature Flags
44 u32 Flags2; // More Feature Flags
45 u32 EFlags; // Extended Feature Flags
46 u32 EFlags2; // Extended Feature Flags pg2
47
48 char VendorName[16]; // Vendor/Creator ID
49 char FamilyName[50]; // the original cpu name
50
51 // ----------------------------------------------------------------------------
52 // x86 CPU Capabilities Section (all boolean flags!)
53 // ----------------------------------------------------------------------------
54
55 u32 hasFloatingPointUnit :1;
56 u32 hasVirtual8086ModeEnhancements :1;
57 u32 hasDebuggingExtensions :1;
58 u32 hasPageSizeExtensions :1;
59 u32 hasTimeStampCounter :1;
60 u32 hasModelSpecificRegisters :1;
61 u32 hasPhysicalAddressExtension :1;
62 u32 hasCOMPXCHG8BInstruction :1;
63 u32 hasAdvancedProgrammableInterruptController :1;
64 u32 hasSEPFastSystemCall :1;
65 u32 hasMemoryTypeRangeRegisters :1;
66 u32 hasPTEGlobalFlag :1;
67 u32 hasMachineCheckArchitecture :1;
68 u32 hasConditionalMoveAndCompareInstructions :1;
69 u32 hasFGPageAttributeTable :1;
70 u32 has36bitPageSizeExtension :1;
71 u32 hasProcessorSerialNumber :1;
72 u32 hasCFLUSHInstruction :1;
73 u32 hasDebugStore :1;
74 u32 hasACPIThermalMonitorAndClockControl :1;
75 u32 hasMultimediaExtensions :1;
76 u32 hasFastStreamingSIMDExtensionsSaveRestore :1;
77 u32 hasStreamingSIMDExtensions :1;
78 u32 hasStreamingSIMD2Extensions :1;
79 u32 hasSelfSnoop :1;
80
81 // is TRUE for both multi-core and Hyperthreaded CPUs.
82 u32 hasMultiThreading :1;
83
84 u32 hasThermalMonitor :1;
85 u32 hasIntel64BitArchitecture :1;
86 u32 hasStreamingSIMD3Extensions :1;
87 u32 hasSupplementalStreamingSIMD3Extensions :1;
88 u32 hasStreamingSIMD4Extensions :1;
89 u32 hasStreamingSIMD4Extensions2 :1;
90
91 // AMD-specific CPU Features
92 u32 hasMultimediaExtensionsExt :1;
93 u32 hasAMD64BitArchitecture :1;
94 u32 has3DNOWInstructionExtensionsExt :1;
95 u32 has3DNOWInstructionExtensions :1;
96 u32 hasStreamingSIMD4ExtensionsA :1;
97
98 // Core Counts!
99 u32 PhysicalCores;
100 u32 LogicalCores;
101
102 public:
103 x86capabilities()
104 {
105 isIdentified = false;
106 VendorID = x86Vendor_Unknown;
107 }
108
109 void Identify();
110 void CountCores();
111 wxString GetTypeName() const;
112
113 u32 CalculateMHz() const;
114
115 void SIMD_ExceptionTest();
116 void SIMD_EstablishMXCSRmask();
117
118 protected:
119 s64 _CPUSpeedHz( u64 time ) const;
120 void CountLogicalCores();
121 };
122
123 enum SSE_RoundMode
124 {
125 SSE_RoundMode_FIRST = 0,
126 SSEround_Nearest = 0,
127 SSEround_NegInf,
128 SSEround_PosInf,
129 SSEround_Chop,
130 SSE_RoundMode_COUNT
131 };
132
133 ImplementEnumOperators( SSE_RoundMode );
134
135 // --------------------------------------------------------------------------------------
136 // SSE_MXCSR - Control/Status Register (bitfield)
137 // --------------------------------------------------------------------------------------
138 // Bits 0-5 are exception flags; used only if SSE exceptions have been enabled.
139 // Bits in this field are "sticky" and, once an exception has occured, must be manually
140 // cleared using LDMXCSR or FXRSTOR.
141 //
142 // Bits 7-12 are the masks for disabling the exceptions in bits 0-5. Cleared bits allow
143 // exceptions, set bits mask exceptions from being raised.
144 //
145 union SSE_MXCSR
146 {
147 u32 bitmask;
148 struct
149 {
150 u32
151 InvalidOpFlag :1,
152 DenormalFlag :1,
153 DivideByZeroFlag :1,
154 OverflowFlag :1,
155 UnderflowFlag :1,
156 PrecisionFlag :1,
157
158 // This bit is supported only on SSE2 or better CPUs. Setting it to 1 on
159 // SSE1 cpus will result in an invalid instruction exception when executing
160 // LDMXSCR.
161 DenormalsAreZero :1,
162
163 InvalidOpMask :1,
164 DenormalMask :1,
165 DivideByZeroMask :1,
166 OverflowMask :1,
167 UnderflowMask :1,
168 PrecisionMask :1,
169
170 RoundingControl :2,
171 FlushToZero :1;
172 };
173
174 SSE_RoundMode GetRoundMode() const;
175 SSE_MXCSR& SetRoundMode( SSE_RoundMode mode );
176 SSE_MXCSR& ClearExceptionFlags();
177 SSE_MXCSR& EnableExceptions();
178 SSE_MXCSR& DisableExceptions();
179
180 SSE_MXCSR& ApplyReserveMask();
181
182 bool operator ==( const SSE_MXCSR& right ) const
183 {
184 return bitmask == right.bitmask;
185 }
186
187 bool operator !=( const SSE_MXCSR& right ) const
188 {
189 return bitmask != right.bitmask;
190 }
191
192 operator x86Emitter::xIndirect32() const;
193 };
194
195 extern SSE_MXCSR MXCSR_Mask;
196
197
198 extern __aligned16 x86capabilities x86caps;
199

  ViewVC Help
Powered by ViewVC 1.1.22