Debian Codegraph @

cpu/cpudb/intel/corei5_lynnfield_750.cc

raw symbols SCIP
1 /////////////////////////////////////////////////////////////////////////
2 // $Id$
3 /////////////////////////////////////////////////////////////////////////
4 //
5 // Copyright (c) 2011-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 "corei5_lynnfield_750.h"
29
30 #define LOG_THIS cpu->
31
32 #if BX_SUPPORT_X86_64
33
34 corei5_lynnfield_750_t::corei5_lynnfield_750_t(BX_CPU_C *cpu): bx_cpuid_t(cpu)
35 {
36 if (BX_SUPPORT_VMX == 1)
37 BX_INFO(("You must compile with --enable-vmx=2 for Intel Core i5 750 (Lynnfield) VMX configuration"));
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 enable_cpu_extension(BX_ISA_P6);
47 enable_cpu_extension(BX_ISA_SYSENTER_SYSEXIT);
48 enable_cpu_extension(BX_ISA_SSE);
49 enable_cpu_extension(BX_ISA_SSE2);
50 enable_cpu_extension(BX_ISA_SSE3);
51 enable_cpu_extension(BX_ISA_SSSE3);
52 enable_cpu_extension(BX_ISA_SSE4_1);
53 enable_cpu_extension(BX_ISA_SSE4_2);
54 enable_cpu_extension(BX_ISA_POPCNT);
55 #if BX_SUPPORT_MONITOR_MWAIT
56 enable_cpu_extension(BX_ISA_MONITOR_MWAIT);
57 #endif
58 #if BX_SUPPORT_VMX >= 2
59 enable_cpu_extension(BX_ISA_VMX);
60 #endif
61 enable_cpu_extension(BX_ISA_SMX);
62 enable_cpu_extension(BX_ISA_CLFLUSH);
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_CMPXCHG16B);
75 enable_cpu_extension(BX_ISA_RDTSCP);
76
77 max_std_leaf = 0xB;
78 max_ext_leaf = 0x80000008;
79 }
80
81 void corei5_lynnfield_750_t::get_cpuid_leaf(Bit32u function, Bit32u subfunction, cpuid_function_t *leaf) const
82 {
83 static const char* brand_string = "Intel(R) Core(TM) i5 CPU 750 @ 2.67GHz";
84
85 static bool cpuid_limit_winnt = SIM->get_param_bool(BXPN_CPUID_LIMIT_WINNT)->get();
86 if (cpuid_limit_winnt)
87 if (function > 2 && function < 0x80000000) function = 2;
88
89 switch(function) {
90 case 0x80000000:
91 get_leaf_0(max_ext_leaf, NULL, leaf); // highest extended function understood by CPUID
92 return;
93 case 0x80000001:
94 get_ext_cpuid_leaf_1(leaf);
95 return;
96 case 0x80000002:
97 case 0x80000003:
98 case 0x80000004:
99 get_ext_cpuid_brand_string_leaf(brand_string, function, leaf);
100 return;
101 case 0x80000005:
102 get_reserved_leaf(leaf);
103 return;
104 case 0x80000006: // CPUID leaf 0x80000006 - L2 Cache and TLB Identifiers
105 get_leaf(leaf, 0x00000000, 0x00000000, 0x01006040, 0x00000000);
106 return;
107 case 0x80000007: // CPUID leaf 0x80000007 - Advanced Power Management leaf
108 get_leaf(leaf, 0x00000000, 0x00000000, 0x00000000, 0x00000100); // EDX[8] - invariant TSC
109 return;
110 case 0x80000008:
111 get_ext_cpuid_leaf_8(leaf);
112 return;
113 case 0x00000000:
114 get_leaf_0(max_std_leaf, "GenuineIntel", leaf);
115 return;
116 case 0x00000001:
117 get_std_cpuid_leaf_1(leaf);
118 return;
119 case 0x00000002:
120 get_std_cpuid_leaf_2(leaf);
121 return;
122 case 0x00000003:
123 get_reserved_leaf(leaf);
124 return;
125 case 0x00000004:
126 get_std_cpuid_leaf_4(subfunction, leaf);
127 return;
128 case 0x00000005:
129 get_std_cpuid_monitor_mwait_leaf(leaf, 0x00001120);
130 return;
131 case 0x00000006: // CPUID leaf 0x00000006 - Thermal and Power Management Leaf
132 get_leaf(leaf, 0x00000003, 0x00000002, 0x00000001, 0x00000000);
133 return;
134 case 0x00000007:
135 case 0x00000008:
136 case 0x00000009:
137 get_reserved_leaf(leaf);
138 return;
139 case 0x0000000A:
140 get_std_cpuid_leaf_A(leaf);
141 return;
142 case 0x0000000B:
143 default:
144 get_std_cpuid_extended_topology_leaf(subfunction, leaf);
145 return;
146 }
147 }
148
149 #if BX_SUPPORT_VMX >= 2
150
151 Bit32u corei5_lynnfield_750_t::get_vmx_extensions_bitmask(void) const
152 {
153 return BX_VMX_TPR_SHADOW |
154 BX_VMX_VIRTUAL_NMI |
155 BX_VMX_APIC_VIRTUALIZATION |
156 BX_VMX_WBINVD_VMEXIT |
157 BX_VMX_MONITOR_TRAP_FLAG |
158 BX_VMX_VPID |
159 BX_VMX_EPT |
160 BX_VMX_SAVE_DEBUGCTL_DISABLE |
161 BX_VMX_PERF_GLOBAL_CTRL | // MSR not implemented yet
162 BX_VMX_PAT |
163 BX_VMX_EFER |
164 BX_VMX_DESCRIPTOR_TABLE_EXIT |
165 BX_VMX_X2APIC_VIRTUALIZATION |
166 BX_VMX_PREEMPTION_TIMER;
167 }
168
169 #endif
170
171 // leaf 0x00000000 //
172
173 // leaf 0x00000001 //
174 void corei5_lynnfield_750_t::get_std_cpuid_leaf_1(cpuid_function_t *leaf) const
175 {
176 // EAX: CPU Version Information
177 // [3:0] Stepping ID
178 // [7:4] Model: starts at 1
179 // [11:8] Family: 4=486, 5=Pentium, 6=PPro, ...
180 // [13:12] Type: 0=OEM, 1=overdrive, 2=dual cpu, 3=reserved
181 // [19:16] Extended Model
182 // [27:20] Extended Family
183 leaf->eax = 0x000106e5;
184
185 // EBX:
186 // [7:0] Brand ID
187 // [15:8] CLFLUSH cache line size (value*8 = cache line size in bytes)
188 // [23:16] Number of logical processors in one physical processor
189 // [31:24] Local Apic ID
190
191 unsigned n_logical_processors = ncores*nthreads;
192 leaf->ebx = ((CACHE_LINE_SIZE / 8) << 8) |
193 (n_logical_processors << 16);
194 #if BX_SUPPORT_APIC
195 leaf->ebx |= ((cpu->get_apic_id() & 0xff) << 24);
196 #endif
197
198 // ECX: Extended Feature Flags
199 // * [0:0] SSE3: SSE3 Instructions
200 // [1:1] PCLMULQDQ Instruction support
201 // * [2:2] DTES64: 64-bit DS area
202 // * [3:3] MONITOR/MWAIT support
203 // * [4:4] DS-CPL: CPL qualified debug store
204 // * [5:5] VMX: Virtual Machine Technology
205 // * [6:6] SMX: Secure Virtual Machine Technology
206 // * [7:7] EST: Enhanced Intel SpeedStep Technology
207 // * [8:8] TM2: Thermal Monitor 2
208 // * [9:9] SSSE3: SSSE3 Instructions
209 // [10:10] CNXT-ID: L1 context ID
210 // [11:11] reserved
211 // [12:12] FMA Instructions support
212 // * [13:13] CMPXCHG16B: CMPXCHG16B instruction support
213 // * [14:14] xTPR update control
214 // * [15:15] PDCM - Perfmon and Debug Capability MSR
215 // [16:16] reserved
216 // [17:17] PCID: Process Context Identifiers
217 // [18:18] DCA - Direct Cache Access
218 // * [19:19] SSE4.1 Instructions
219 // * [20:20] SSE4.2 Instructions
220 // [21:21] X2APIC
221 // [22:22] MOVBE instruction
222 // * [23:23] POPCNT instruction
223 // [24:24] TSC Deadline
224 // [25:25] AES Instructions
225 // [26:26] XSAVE extensions support
226 // [27:27] OSXSAVE support
227 // [28:28] AVX extensions support
228 // [29:29] AVX F16C - Float16 conversion support
229 // [30:30] RDRAND instruction
230 // [31:31] reserved
231 leaf->ecx = get_std_cpuid_leaf_1_ecx(BX_CPUID_STD1_ECX_DTES64 |
232 BX_CPUID_STD1_ECX_DS_CPL |
233 BX_CPUID_STD1_ECX_EST |
234 BX_CPUID_STD1_ECX_THERMAL_MONITOR2 |
235 BX_CPUID_STD1_ECX_xTPR |
236 BX_CPUID_STD1_ECX_PDCM);
237
238 // EDX: Standard Feature Flags
239 // * [0:0] FPU on chip
240 // * [1:1] VME: Virtual-8086 Mode enhancements
241 // * [2:2] DE: Debug Extensions (I/O breakpoints)
242 // * [3:3] PSE: Page Size Extensions
243 // * [4:4] TSC: Time Stamp Counter
244 // * [5:5] MSR: RDMSR and WRMSR support
245 // * [6:6] PAE: Physical Address Extensions
246 // * [7:7] MCE: Machine Check Exception
247 // * [8:8] CXS: CMPXCHG8B instruction
248 // * [9:9] APIC: APIC on Chip
249 // [10:10] Reserved
250 // * [11:11] SYSENTER/SYSEXIT support
251 // * [12:12] MTRR: Memory Type Range Reg
252 // * [13:13] PGE/PTE Global Bit
253 // * [14:14] MCA: Machine Check Architecture
254 // * [15:15] CMOV: Cond Mov/Cmp Instructions
255 // * [16:16] PAT: Page Attribute Table
256 // * [17:17] PSE-36: Physical Address Extensions
257 // [18:18] PSN: Processor Serial Number
258 // * [19:19] CLFLUSH: CLFLUSH Instruction support
259 // [20:20] Reserved
260 // * [21:21] DS: Debug Store
261 // * [22:22] ACPI: Thermal Monitor and Software Controlled Clock Facilities
262 // * [23:23] MMX Technology
263 // * [24:24] FXSR: FXSAVE/FXRSTOR (also indicates CR4.OSFXSR is available)
264 // * [25:25] SSE: SSE Extensions
265 // * [26:26] SSE2: SSE2 Extensions
266 // * [27:27] Self Snoop
267 // * [28:28] Hyper Threading Technology
268 // * [29:29] TM: Thermal Monitor
269 // [30:30] Reserved
270 // * [31:31] PBE: Pending Break Enable
271 leaf->edx = get_std_cpuid_leaf_1_edx(BX_CPUID_STD1_EDX_DEBUG_STORE |
272 BX_CPUID_STD1_EDX_ACPI |
273 BX_CPUID_STD1_EDX_SELF_SNOOP |
274 #if BX_SUPPORT_SMP
275 BX_CPUID_STD1_EDX_HT |
276 #endif
277 BX_CPUID_STD1_EDX_THERMAL_MONITOR |
278 BX_CPUID_STD1_EDX_PBE);
279 }
280
281 // leaf 0x00000002 //
282 void corei5_lynnfield_750_t::get_std_cpuid_leaf_2(cpuid_function_t *leaf) const
283 {
284 // CPUID function 0x00000002 - Cache and TLB Descriptors
285 leaf->eax = 0x55035a01;
286 leaf->ebx = 0x00f0b0e4;
287 leaf->ecx = 0x00000000;
288 leaf->edx = 0x09ca212c;
289 }
290
291 // leaf 0x00000003 - Processor Serial Number (not supported) //
292
293 // leaf 0x00000004 //
294 void corei5_lynnfield_750_t::get_std_cpuid_leaf_4(Bit32u subfunction, cpuid_function_t *leaf) const
295 {
296 // CPUID function 0x00000004 - Deterministic Cache Parameters
297
298 // EAX:
299 // [04-00] - Cache Type Field
300 // 0 = No more caches
301 // 1 = Data Cache
302 // 2 = Instruction Cache
303 // 3 = Unified Cache
304 // [07-05] - Cache Level (starts at 1)]
305 // [08] - Self Initializing cache level (doesn't need software initialization)
306 // [09] - Fully Associative cache
307 // [13-10] - Reserved
308 // [25-14] - Maximum number of addressable IDs for logical processors sharing this cache
309 // [31-26] - Maximum number of addressable IDs for processor cores in the physical package - 1
310 // EBX:
311 // [11-00] - L = System Coherency Line Size
312 // [21-12] - P = Physical Line partitions
313 // [31-22] - W = Ways of associativity
314 // ECX: Number of Sets
315 // EDX:
316 // [00] - Writeback invalidate
317 // [01] - Cache Inclusiveness
318 // [02] - Complex Cache Indexing
319 // [31-03] - Reserved
320
321 switch(subfunction) {
322 case 0:
323 leaf->eax = 0x1C004121;
324 leaf->ebx = 0x01C0003F;
325 leaf->ecx = 0x0000003F;
326 leaf->edx = 0x00000000;
327 break;
328 case 1:
329 leaf->eax = 0x1C004122;
330 leaf->ebx = 0x00C0003F;
331 leaf->ecx = 0x0000007F;
332 leaf->edx = 0x00000000;
333 break;
334 case 2:
335 leaf->eax = 0x1C004143;
336 leaf->ebx = 0x01C0003F;
337 leaf->ecx = 0x000001FF;
338 leaf->edx = 0x00000000;
339 break;
340 case 3:
341 leaf->eax = 0x1C03C163;
342 leaf->ebx = 0x03C0003F;
343 leaf->ecx = 0x00001FFF;
344 leaf->edx = 0x00000002;
345 break;
346 default:
347 leaf->eax = 0;
348 leaf->ebx = 0;
349 leaf->ecx = 0;
350 leaf->edx = 0;
351 return;
352 }
353 }
354
355 // leaf 0x00000005 MONITOR/MWAIT Leaf //
356 // leaf 0x00000006 Thermal and Power Management Leaf //
357 // leaf 0x00000007 not supported //
358 // leaf 0x00000008 reserved //
359 // leaf 0x00000009 direct cache access not supported //
360
361 // leaf 0x0000000A //
362 void corei5_lynnfield_750_t::get_std_cpuid_leaf_A(cpuid_function_t *leaf) const
363 {
364 // CPUID function 0x0000000A - Architectural Performance Monitoring Leaf
365
366 // EAX:
367 // [7:0] Version ID of architectural performance monitoring
368 // [15:8] Number of general-purpose performance monitoring counters per logical processor
369 // [23:16] Bit width of general-purpose, performance monitoring counter
370 // [31:24] Length of EBX bit vector to enumerate architectural performance
371 // monitoring events.
372
373 // EBX:
374 // [0] Core cycle event not available if 1
375 // [1] Instruction retired event not available if 1
376 // [2] Reference cycles event not available if 1
377 // [3] Last-level cache reference event not available if 1
378 // [4] Last-level cache misses event not available if 1
379 // [5] Branch instruction retired event not available if 1
380 // [6] Branch mispredict retired event not available if 1
381 // [31:7] reserved
382
383 // ECX: reserved
384
385 // EDX:
386 // [4:0] Number of fixed performance counters (if Version ID > 1)
387 // [12:5] Bit width of fixed-function performance counters (if Version ID > 1)
388 // [31:13] reserved
389
390 leaf->eax = 0x07300403;
391 leaf->ebx = 0x00000044;
392 leaf->ecx = 0x00000000;
393 leaf->edx = 0x00000603;
394
395 BX_INFO(("WARNING: Architectural Performance Monitoring is not implemented"));
396 }
397
398 // leaf 0x80000000 //
399
400 // leaf 0x80000001 //
401 void corei5_lynnfield_750_t::get_ext_cpuid_leaf_1(cpuid_function_t *leaf) const
402 {
403 // EAX: CPU Version Information (reserved for Intel)
404 leaf->eax = 0;
405
406 // EBX: Brand ID (reserved for Intel)
407 leaf->ebx = 0;
408
409 // ECX:
410 // * [0:0] LAHF/SAHF instructions support in 64-bit mode
411 // [1:1] CMP_Legacy: Core multi-processing legacy mode (AMD)
412 // [2:2] SVM: Secure Virtual Machine (AMD)
413 // [3:3] Extended APIC Space
414 // [4:4] AltMovCR8: LOCK MOV CR0 means MOV CR8
415 // [5:5] LZCNT: LZCNT instruction support
416 // [6:6] SSE4A: SSE4A Instructions support
417 // [7:7] Misaligned SSE support
418 // [8:8] PREFETCHW: PREFETCHW instruction support
419 // [9:9] OSVW: OS visible workarounds (AMD)
420 // [11:10] reserved
421 // [12:12] SKINIT support
422 // [13:13] WDT: Watchdog timer support
423 // [31:14] reserved
424 leaf->ecx = get_ext_cpuid_leaf_1_ecx();
425
426 // EDX:
427 // [10:0] Reserved for Intel
428 // * [11:11] SYSCALL/SYSRET support
429 // [19:12] Reserved for Intel
430 // * [20:20] No-Execute page protection
431 // [25:21] Reserved
432 // [26:26] 1G paging support
433 // * [27:27] Support RDTSCP Instruction
434 // [28:28] Reserved
435 // * [29:29] Long Mode
436 // [30:30] AMD 3DNow! Extensions
437 // [31:31] AMD 3DNow! Instructions
438 leaf->edx = get_ext_cpuid_leaf_1_edx_intel();
439 }
440
441 // leaf 0x80000002 //
442 // leaf 0x80000003 //
443 // leaf 0x80000004 //
444
445 // leaf 0x80000005 - L1 Cache and TLB Identifiers (reserved for Intel)
446 // leaf 0x80000006 - L2 Cache and TLB Identifiers
447 // leaf 0x80000007 - Advanced Power Management
448 // leaf 0x80000008 //
449
450 void corei5_lynnfield_750_t::dump_cpuid(void) const
451 {
452 bx_cpuid_t::dump_cpuid(max_std_leaf, max_ext_leaf);
453 }
454
455 bx_cpuid_t *create_corei5_lynnfield_750_cpuid(BX_CPU_C *cpu) { return new corei5_lynnfield_750_t(cpu); }
456
457 #endif