Debian Codegraph @

cpu/cpudb/amd/phenomx3_8650_toliman.cc

raw symbols SCIP
1 /////////////////////////////////////////////////////////////////////////
2 // $Id$
3 /////////////////////////////////////////////////////////////////////////
4 //
5 // Copyright (c) 2012-2017 Stanislav Shwartsman
6 // Written by Stanislav Shwartsman [sshwarts at sourceforge net]
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA B 02110-1301 USA
21 //
22 /////////////////////////////////////////////////////////////////////////
23
24 #include "bochs.h"
25 #include "cpu.h"
26 #include "gui/siminterface.h"
27 #include "param_names.h"
28 #include "phenomx3_8650_toliman.h"
29
30 #define LOG_THIS cpu->
31
32 #if BX_SUPPORT_X86_64
33
34 phenom_8650_toliman_t::phenom_8650_toliman_t(BX_CPU_C *cpu): bx_cpuid_t(cpu)
35 {
36 if (! BX_SUPPORT_SVM)
37 BX_INFO(("WARNING: SVM support is not compiled in !"));
38
39 if (! BX_SUPPORT_MONITOR_MWAIT)
40 BX_INFO(("WARNING: MONITOR/MWAIT support is not compiled in !"));
41
42 enable_cpu_extension(BX_ISA_X87);
43 enable_cpu_extension(BX_ISA_486);
44 enable_cpu_extension(BX_ISA_PENTIUM);
45 enable_cpu_extension(BX_ISA_MMX);
46 #if BX_SUPPORT_3DNOW
47 enable_cpu_extension(BX_ISA_3DNOW);
48 enable_cpu_extension(BX_ISA_3DNOW_EXT);
49 #endif
50 enable_cpu_extension(BX_ISA_SYSCALL_SYSRET_LEGACY);
51 enable_cpu_extension(BX_ISA_SYSENTER_SYSEXIT);
52 enable_cpu_extension(BX_ISA_P6);
53 enable_cpu_extension(BX_ISA_SSE);
54 enable_cpu_extension(BX_ISA_SSE2);
55 enable_cpu_extension(BX_ISA_SSE3);
56 #if BX_SUPPORT_MONITOR_MWAIT
57 enable_cpu_extension(BX_ISA_MONITOR_MWAIT);
58 #endif
59 enable_cpu_extension(BX_ISA_CLFLUSH);
60 enable_cpu_extension(BX_ISA_POPCNT);
61 enable_cpu_extension(BX_ISA_LZCNT);
62 enable_cpu_extension(BX_ISA_SSE4A);
63 enable_cpu_extension(BX_ISA_DEBUG_EXTENSIONS);
64 enable_cpu_extension(BX_ISA_VME);
65 enable_cpu_extension(BX_ISA_PSE);
66 enable_cpu_extension(BX_ISA_PAE);
67 enable_cpu_extension(BX_ISA_PGE);
68 enable_cpu_extension(BX_ISA_MTRR);
69 enable_cpu_extension(BX_ISA_PAT);
70 enable_cpu_extension(BX_ISA_XAPIC);
71 enable_cpu_extension(BX_ISA_LONG_MODE);
72 enable_cpu_extension(BX_ISA_LM_LAHF_SAHF);
73 enable_cpu_extension(BX_ISA_NX);
74 enable_cpu_extension(BX_ISA_FFXSR);
75 enable_cpu_extension(BX_ISA_CMPXCHG16B);
76 enable_cpu_extension(BX_ISA_1G_PAGES);
77 enable_cpu_extension(BX_ISA_MISALIGNED_SSE);
78 enable_cpu_extension(BX_ISA_RDTSCP);
79 #if BX_SUPPORT_SVM
80 enable_cpu_extension(BX_ISA_SVM);
81 #endif
82 enable_cpu_extension(BX_ISA_ALT_MOV_CR8);
83 enable_cpu_extension(BX_ISA_XAPIC_EXT);
84 }
85
86 void phenom_8650_toliman_t::get_cpuid_leaf(Bit32u function, Bit32u subfunction, cpuid_function_t *leaf) const
87 {
88 static const char* brand_string = "AMD Phenom(tm) 8650 Triple-Core Processor\0\0\0\0\0\0\0";
89
90 static bool cpuid_limit_winnt = SIM->get_param_bool(BXPN_CPUID_LIMIT_WINNT)->get();
91 if (cpuid_limit_winnt)
92 if (function > 1 && function < 0x80000000) function = 1;
93
94 switch(function) {
95 case 0x80000000:
96 get_ext_cpuid_leaf_0(leaf);
97 return;
98 case 0x80000001:
99 get_ext_cpuid_leaf_1(leaf);
100 return;
101 case 0x80000002:
102 case 0x80000003:
103 case 0x80000004:
104 get_ext_cpuid_brand_string_leaf(brand_string, function, leaf);
105 return;
106 case 0x80000005:
107 get_ext_cpuid_leaf_5(leaf);
108 return;
109 case 0x80000006:
110 get_ext_cpuid_leaf_6(leaf);
111 return;
112 case 0x80000007:
113 get_ext_cpuid_leaf_7(leaf);
114 return;
115 case 0x80000008:
116 get_ext_cpuid_leaf_8(leaf);
117 return;
118 #if BX_SUPPORT_SVM
119 case 0x8000000A:
120 get_ext_cpuid_leaf_A(leaf);
121 return;
122 #endif
123 case 0x80000019:
124 get_ext_cpuid_leaf_19(leaf);
125 return;
126 case 0x8000001A:
127 get_ext_cpuid_leaf_1A(leaf);
128 return;
129 case 0x00000000:
130 get_std_cpuid_leaf_0(leaf);
131 return;
132 case 0x00000001:
133 get_std_cpuid_leaf_1(leaf);
134 return;
135 #if BX_SUPPORT_MONITOR_MWAIT
136 case 0x00000005:
137 get_std_cpuid_monitor_mwait_leaf(leaf, 0);
138 return;
139 #endif
140 default:
141 get_reserved_leaf(leaf);
142 return;
143 }
144 }
145
146 #if BX_SUPPORT_SVM
147 Bit32u phenom_8650_toliman_t::get_svm_extensions_bitmask(void) const
148 {
149 return BX_CPUID_SVM_NESTED_PAGING |
150 BX_CPUID_SVM_LBR_VIRTUALIZATION |
151 BX_CPUID_SVM_SVM_LOCK;
152 }
153 #endif
154
155 // leaf 0x00000000 //
156 void phenom_8650_toliman_t::get_std_cpuid_leaf_0(cpuid_function_t *leaf) const
157 {
158 static const char* vendor_string = "AuthenticAMD";
159
160 // EAX: highest std function understood by CPUID
161 // EBX: vendor ID string
162 // EDX: vendor ID string
163 // ECX: vendor ID string
164 unsigned max_leaf = BX_SUPPORT_MONITOR_MWAIT ? 0x5 : 0x1;
165 get_leaf_0(max_leaf, vendor_string, leaf, 0x1 /* max_leaf when limit_winnt is activated */);
166 }
167
168 // leaf 0x00000001 //
169 void phenom_8650_toliman_t::get_std_cpuid_leaf_1(cpuid_function_t *leaf) const
170 {
171 // EAX: CPU Version Information
172 // [3:0] Stepping ID
173 // [7:4] Model: starts at 1
174 // [11:8] Family: 4=486, 5=Pentium, 6=PPro, ...
175 // [13:12] Type: 0=OEM, 1=overdrive, 2=dual cpu, 3=reserved
176 // [19:16] Extended Model
177 // [27:20] Extended Family
178 leaf->eax = 0x00100F23;
179
180 // EBX:
181 // [7:0] Brand ID
182 // [15:8] CLFLUSH cache line size (value*8 = cache line size in bytes)
183 // [23:16] Number of logical processors in one physical processor
184 // [31:24] Local Apic ID
185
186 unsigned n_logical_processors = ncores*nthreads;
187 leaf->ebx = ((CACHE_LINE_SIZE / 8) << 8) |
188 (n_logical_processors << 16);
189 #if BX_SUPPORT_APIC
190 leaf->ebx |= ((cpu->get_apic_id() & 0xff) << 24);
191 #endif
192
193 // ECX: Extended Feature Flags
194 // * [0:0] SSE3: SSE3 Instructions
195 // [1:1] PCLMULQDQ Instruction support
196 // [2:2] DTES64: 64-bit DS area
197 // * [3:3] MONITOR/MWAIT support
198 // [4:4] DS-CPL: CPL qualified debug store
199 // [5:5] VMX: Virtual Machine Technology
200 // [6:6] SMX: Secure Virtual Machine Technology
201 // [7:7] EST: Enhanced Intel SpeedStep Technology
202 // [8:8] TM2: Thermal Monitor 2
203 // [9:9] SSSE3: SSSE3 Instructions
204 // [10:10] CNXT-ID: L1 context ID
205 // [11:11] reserved
206 // [12:12] FMA Instructions support
207 // * [13:13] CMPXCHG16B: CMPXCHG16B instruction support
208 // [14:14] xTPR update control
209 // [15:15] PDCM - Perfmon and Debug Capability MSR
210 // [16:16] reserved
211 // [17:17] PCID: Process Context Identifiers
212 // [18:18] DCA - Direct Cache Access
213 // [19:19] SSE4.1 Instructions
214 // [20:20] SSE4.2 Instructions
215 // [21:21] X2APIC
216 // [22:22] MOVBE instruction
217 // * [23:23] POPCNT instruction
218 // [24:24] TSC Deadline
219 // [25:25] AES Instructions
220 // [26:26] XSAVE extensions support
221 // [27:27] OSXSAVE support
222 // [28:28] AVX extensions support
223 // [29:29] AVX F16C - Float16 conversion support
224 // [30:30] RDRAND instruction
225 // [31:31] reserved
226 leaf->ecx = get_std_cpuid_leaf_1_ecx();
227
228 // EDX: Standard Feature Flags
229 // * [0:0] FPU on chip
230 // * [1:1] VME: Virtual-8086 Mode enhancements
231 // * [2:2] DE: Debug Extensions (I/O breakpoints)
232 // * [3:3] PSE: Page Size Extensions
233 // * [4:4] TSC: Time Stamp Counter
234 // * [5:5] MSR: RDMSR and WRMSR support
235 // * [6:6] PAE: Physical Address Extensions
236 // * [7:7] MCE: Machine Check Exception
237 // * [8:8] CXS: CMPXCHG8B instruction
238 // * [9:9] APIC: APIC on Chip
239 // [10:10] Reserved
240 // * [11:11] SYSENTER/SYSEXIT support
241 // * [12:12] MTRR: Memory Type Range Reg
242 // * [13:13] PGE/PTE Global Bit
243 // * [14:14] MCA: Machine Check Architecture
244 // * [15:15] CMOV: Cond Mov/Cmp Instructions
245 // * [16:16] PAT: Page Attribute Table
246 // * [17:17] PSE-36: Physical Address Extensions
247 // [18:18] PSN: Processor Serial Number
248 // * [19:19] CLFLUSH: CLFLUSH Instruction support
249 // [20:20] Reserved
250 // [21:21] DS: Debug Store
251 // [22:22] ACPI: Thermal Monitor and Software Controlled Clock Facilities
252 // * [23:23] MMX Technology
253 // * [24:24] FXSR: FXSAVE/FXRSTOR (also indicates CR4.OSFXSR is available)
254 // * [25:25] SSE: SSE Extensions
255 // * [26:26] SSE2: SSE2 Extensions
256 // [27:27] Self Snoop
257 // * [28:28] Hyper Threading Technology
258 // [29:29] TM: Thermal Monitor
259 // [30:30] Reserved
260 // [31:31] PBE: Pending Break Enable
261 leaf->edx = get_std_cpuid_leaf_1_edx();
262 #if BX_SUPPORT_SMP
263 leaf->edx |= BX_CPUID_STD1_EDX_HT;
264 #endif
265 }
266
267 // leaf 0x00000005 MONITOR/MWAIT Leaf //
268
269 // leaf 0x80000000 //
270 void phenom_8650_toliman_t::get_ext_cpuid_leaf_0(cpuid_function_t *leaf) const
271 {
272 get_leaf_0(0x8000001A, "AuthenticAMD", leaf);
273 }
274
275 // leaf 0x80000001 //
276 void phenom_8650_toliman_t::get_ext_cpuid_leaf_1(cpuid_function_t *leaf) const
277 {
278 // EAX: CPU Version Information (same as 0x00000001.EAX)
279 leaf->eax = 0x00100F23;
280
281 // EBX: Brand ID
282 leaf->ebx = 0x10000563;
283
284 // ECX:
285 // * [0:0] LAHF/SAHF instructions support in 64-bit mode
286 // * [1:1] CMP_Legacy: Core multi-processing legacy mode (AMD)
287 // * [2:2] SVM: Secure Virtual Machine (AMD)
288 // * [3:3] Extended APIC Space
289 // * [4:4] AltMovCR8: LOCK MOV CR0 means MOV CR8
290 // * [5:5] LZCNT: LZCNT instruction support
291 // * [6:6] SSE4A: SSE4A Instructions support
292 // * [7:7] Misaligned SSE support
293 // * [8:8] PREFETCHW: PREFETCHW instruction support
294 // * [9:9] OSVW: OS visible workarounds (AMD)
295 // * [10:10] IBS: Instruction based sampling
296 // [11:11] XOP: Extended Operations Support and XOP Prefix
297 // [12:12] SKINIT support
298 // [13:13] WDT: Watchdog timer support
299 // [14:14] Reserved
300 // [15:15] LWP: Light weight profiling
301 // [16:16] FMA4: Four-operand FMA instructions support
302 // [17:17] Reserved
303 // [18:18] Reserved
304 // [19:19] Reserved
305 // [20:20] NodeId: Indicates support for NodeId MSR (0xc001100c)
306 // [21:21] Reserved
307 // [22:22] TBM: trailing bit manipulation instructions support
308 // [23:23] Topology extensions support
309 // [31:24] Reserved
310 leaf->ecx = get_ext_cpuid_leaf_1_ecx(BX_CPUID_EXT1_ECX_CMP_LEGACY |
311 BX_CPUID_EXT1_ECX_PREFETCHW |
312 BX_CPUID_EXT1_ECX_OSVW |
313 BX_CPUID_EXT1_ECX_IBS);
314
315 // EDX:
316 // Many of the bits in EDX are the same as FN 0x00000001 for AMD
317 // * [0:0] FPU on chip
318 // * [1:1] VME: Virtual-8086 Mode enhancements
319 // * [2:2] DE: Debug Extensions (I/O breakpoints)
320 // * [3:3] PSE: Page Size Extensions
321 // * [4:4] TSC: Time Stamp Counter
322 // * [5:5] MSR: RDMSR and WRMSR support
323 // * [6:6] PAE: Physical Address Extensions
324 // * [7:7] MCE: Machine Check Exception
325 // * [8:8] CXS: CMPXCHG8B instruction
326 // * [9:9] APIC: APIC on Chip
327 // [10:10] Reserved
328 // * [11:11] SYSCALL/SYSRET support
329 // * [12:12] MTRR: Memory Type Range Reg
330 // * [13:13] PGE/PTE Global Bit
331 // * [14:14] MCA: Machine Check Architecture
332 // * [15:15] CMOV: Cond Mov/Cmp Instructions
333 // * [16:16] PAT: Page Attribute Table
334 // * [17:17] PSE-36: Physical Address Extensions
335 // [18:18] Reserved
336 // [19:19] Reserved
337 // * [20:20] No-Execute page protection
338 // [21:21] Reserved
339 // * [22:22] AMD MMX Extensions
340 // * [23:23] MMX Technology
341 // * [24:24] FXSR: FXSAVE/FXRSTOR (also indicates CR4.OSFXSR is available)
342 // * [25:25] Fast FXSAVE/FXRSTOR mode support
343 // * [26:26] 1G paging support
344 // * [27:27] Support RDTSCP Instruction
345 // [28:28] Reserved
346 // * [29:29] Long Mode
347 // * [30:30] AMD 3DNow! Extensions
348 // * [31:31] AMD 3DNow! Instructions
349 leaf->edx = get_ext_cpuid_leaf_1_edx_amd();
350 }
351
352 // leaf 0x80000002 //
353 // leaf 0x80000003 //
354 // leaf 0x80000004 //
355
356 // leaf 0x80000005 - L1 Cache and TLB Identifiers //
357 void phenom_8650_toliman_t::get_ext_cpuid_leaf_5(cpuid_function_t *leaf) const
358 {
359 leaf->eax = 0xFF30FF10;
360 leaf->ebx = 0xFF20FF20;
361 leaf->ecx = 0x40020140;
362 leaf->edx = 0x40020140;
363 }
364
365 // leaf 0x80000006 - L2 Cache and TLB Identifiers //
366 void phenom_8650_toliman_t::get_ext_cpuid_leaf_6(cpuid_function_t *leaf) const
367 {
368 leaf->eax = 0x20800000;
369 leaf->ebx = 0x42004200;
370 leaf->ecx = 0x02008140;
371 leaf->edx = 0x0010A140;
372 }
373
374 // leaf 0x80000007 - Advanced Power Management //
375 void phenom_8650_toliman_t::get_ext_cpuid_leaf_7(cpuid_function_t *leaf) const
376 {
377 // CPUID function 0x80000007 - Advanced Power Management
378 leaf->eax = 0;
379 leaf->ebx = 0;
380 leaf->ecx = 0;
381 leaf->edx = 0x000001F9;
382 }
383
384 // leaf 0x80000008 //
385 void phenom_8650_toliman_t::get_ext_cpuid_leaf_8(cpuid_function_t *leaf) const
386 {
387 bx_cpuid_t::get_ext_cpuid_leaf_8(leaf);
388
389 // ECX:
390 // [17..16] Performance time-stamp counter size.
391 // [15..12] APIC ID size, Zero value indicates that legacy methods must be
392 // used to derive the maximum number of cores.
393 // [11..8] (reserved)
394 // [7..0] Number of physical cores - 1.
395 leaf->ecx = ncores - 1;
396 }
397
398 // leaf 0x80000009 : Reserved //
399
400 #if BX_SUPPORT_SVM
401
402 // leaf 0x8000000A : SVM //
403 void phenom_8650_toliman_t::get_ext_cpuid_leaf_A(cpuid_function_t *leaf) const
404 {
405 leaf->eax = 0x01; /* SVM revision ID */
406 leaf->ebx = 0x40; /* number of ASIDs */
407 leaf->ecx = 0;
408
409 // * [0:0] NP - Nested paging support
410 // * [1:1] LBR virtualization
411 // * [2:2] SVM Lock
412 // [3:3] NRIPS - Next RIP save on VMEXIT
413 // [4:4] TscRate - MSR based TSC ratio control
414 // [5:5] VMCB Clean bits support
415 // [6:6] Flush by ASID support
416 // [7:7] Decode assists support
417 // [9:8] Reserved
418 // [10:10] Pause filter support
419 // [11:11] Reserved
420 // [12:12] Pause filter threshold support
421 // [31:13] Reserved
422
423 leaf->edx = get_svm_extensions_bitmask();
424 }
425
426 #endif
427
428 // leaf 0x8000000B - 0x80000018: Reserved //
429
430 void phenom_8650_toliman_t::get_ext_cpuid_leaf_19(cpuid_function_t *leaf) const
431 {
432 // CPUID function 0x800000019 - 1G Page TLB Identifiers
433 leaf->eax = 0xF0300000;
434 leaf->ebx = 0;
435 leaf->ecx = 0;
436 leaf->edx = 0;
437 }
438
439 void phenom_8650_toliman_t::get_ext_cpuid_leaf_1A(cpuid_function_t *leaf) const
440 {
441 // CPUID function 0x80000001A - Performance Optimization Identifiers
442 leaf->eax = 0x00000003;
443 leaf->ebx = 0;
444 leaf->ecx = 0;
445 leaf->edx = 0;
446 }
447
448 void phenom_8650_toliman_t::dump_cpuid(void) const
449 {
450 bx_cpuid_t::dump_cpuid(BX_SUPPORT_MONITOR_MWAIT ? 0x5 : 0x1, 0x8000001A);
451 }
452
453 bx_cpuid_t *create_phenom_8650_toliman_cpuid(BX_CPU_C *cpu) { return new phenom_8650_toliman_t(cpu); }
454
455 #endif