From b60d7d31541e8be66f521bcef13868b324d7502f Mon Sep 17 00:00:00 2001 From: Stanislav Shwartsman Date: Wed, 11 Feb 2015 21:31:17 +0000 Subject: [PATCH] Cleanup of CPUDB modules, moved common functionality into bx_cpuid_t base class Added Pentium (P54C) AKA Pentium with no MMX to CPUDB --- bochs/cpu/cpudb/Makefile.in | 11 ++- bochs/cpu/cpudb/amd_k6_2_chomper.cc | 51 ++---------- bochs/cpu/cpudb/amd_k6_2_chomper.h | 2 - bochs/cpu/cpudb/amd_k6_2_chomper.txt | 82 ++++++-------------- bochs/cpu/cpudb/athlon64_clawhammer.cc | 62 ++------------- bochs/cpu/cpudb/athlon64_clawhammer.h | 4 +- bochs/cpu/cpudb/athlon64_venice.cc | 62 ++------------- bochs/cpu/cpudb/athlon64_venice.h | 4 +- bochs/cpu/cpudb/atom_n270.cc | 22 ++---- bochs/cpu/cpudb/core2_penryn_t9600.cc | 22 ++---- bochs/cpu/cpudb/core_duo_t2400_yonah.cc | 22 ++---- bochs/cpu/cpudb/corei5_arrandale_m520.cc | 22 ++---- bochs/cpu/cpudb/corei5_lynnfield_750.cc | 22 ++---- bochs/cpu/cpudb/corei7_haswell_4770.cc | 28 ++----- bochs/cpu/cpudb/corei7_ivy_bridge_3770K.cc | 22 ++---- bochs/cpu/cpudb/corei7_sandy_bridge_2600K.cc | 22 ++---- bochs/cpu/cpudb/p2_klamath.cc | 20 +---- bochs/cpu/cpudb/p3_katmai.cc | 20 +---- bochs/cpu/cpudb/p4_prescott_celeron_336.cc | 25 +----- bochs/cpu/cpudb/p4_willamette.cc | 25 +----- bochs/cpu/cpudb/pentium_mmx.cc | 20 +---- bochs/cpu/cpudb/pentium_mmx.h | 2 +- bochs/cpu/cpudb/phenomx3_8650_toliman.cc | 41 ++-------- bochs/cpu/cpudb/trinity_apu.cc | 37 ++------- bochs/cpu/cpudb/turion64_tyler.cc | 36 +-------- bochs/cpu/cpudb/zambezi.cc | 37 ++------- bochs/cpu/cpuid.cc | 61 ++++++++++++--- bochs/cpu/cpuid.h | 11 ++- bochs/cpu/generic_cpuid.cc | 50 +++--------- bochs/cpu/generic_cpuid.h | 2 +- bochs/cpudb.h | 3 +- 31 files changed, 205 insertions(+), 645 deletions(-) diff --git a/bochs/cpu/cpudb/Makefile.in b/bochs/cpu/cpudb/Makefile.in index dd9f8fe20..3cc6e3c3d 100644 --- a/bochs/cpu/cpudb/Makefile.in +++ b/bochs/cpu/cpudb/Makefile.in @@ -35,7 +35,8 @@ RANLIB = @RANLIB@ BX_INCDIRS = -I.. -I../.. -I$(srcdir)/.. -I$(srcdir)/../.. -I../../@INSTRUMENT_DIR@ -I$(srcdir)/../../@INSTRUMENT_DIR@ -CPUDB_OBJS = pentium_mmx.o \ +CPUDB_OBJS = pentium.o \ + pentium_mmx.o \ amd_k6_2_chomper.o \ p2_klamath.o \ p3_katmai.o \ @@ -213,6 +214,14 @@ p4_willamette.o: p4_willamette.@CPP_SUFFIX@ ../../bochs.h ../../config.h \ ../descriptor.h ../instr.h ../ia_opcodes.h ../lazy_flags.h ../icache.h \ ../apic.h ../i387.h ../fpu/softfloat.h ../fpu/tag_w.h ../fpu/status_w.h \ ../fpu/control_w.h ../xmm.h p4_willamette.h ../../cpu/cpuid.h +pentium.o: pentium.@CPP_SUFFIX@ ../../bochs.h ../../config.h ../../osdep.h \ + ../../bx_debug/debug.h ../../config.h ../../osdep.h \ + ../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \ + ../../memory/memory.h ../../pc_system.h ../../gui/gui.h \ + ../../instrument/stubs/instrument.h ../cpu.h ../access.h ../cpuid.h ../crregs.h \ + ../descriptor.h ../instr.h ../ia_opcodes.h ../lazy_flags.h ../icache.h \ + ../apic.h ../i387.h ../fpu/softfloat.h ../fpu/tag_w.h ../fpu/status_w.h \ + ../fpu/control_w.h ../xmm.h pentium.h pentium_mmx.o: pentium_mmx.@CPP_SUFFIX@ ../../bochs.h ../../config.h ../../osdep.h \ ../../bx_debug/debug.h ../../config.h ../../osdep.h \ ../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \ diff --git a/bochs/cpu/cpudb/amd_k6_2_chomper.cc b/bochs/cpu/cpudb/amd_k6_2_chomper.cc index c9ca3b5a2..af21d4a83 100644 --- a/bochs/cpu/cpudb/amd_k6_2_chomper.cc +++ b/bochs/cpu/cpudb/amd_k6_2_chomper.cc @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2011-2014 Stanislav Shwartsman +// Copyright (c) 2011-2015 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or @@ -58,10 +58,11 @@ amd_k6_2_chomper_t::amd_k6_2_chomper_t(BX_CPU_C *cpu): bx_cpuid_t(cpu) void amd_k6_2_chomper_t::get_cpuid_leaf(Bit32u function, Bit32u subfunction, cpuid_function_t *leaf) const { static const char* brand_string = "AMD-K6(tm) 3D processor\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; + static const char* magic_string = "NexGenerationAMD"; switch(function) { case 0x8FFFFFFF: - get_cpuid_hidden_level(leaf); + get_cpuid_hidden_level(leaf, magic_string); return; case 0x80000000: get_ext_cpuid_leaf_0(leaf); @@ -92,23 +93,7 @@ void amd_k6_2_chomper_t::get_cpuid_leaf(Bit32u function, Bit32u subfunction, cpu // leaf 0x00000000 // void amd_k6_2_chomper_t::get_std_cpuid_leaf_0(cpuid_function_t *leaf) const { - static const char* vendor_string = "AuthenticAMD"; - - // EAX: highest std function understood by CPUID - // EBX: vendor ID string - // EDX: vendor ID string - // ECX: vendor ID string - leaf->eax = 0x1; - - // CPUID vendor string (e.g. GenuineIntel, AuthenticAMD, CentaurHauls, ...) - memcpy(&(leaf->ebx), vendor_string, 4); - memcpy(&(leaf->edx), vendor_string + 4, 4); - memcpy(&(leaf->ecx), vendor_string + 8, 4); -#ifdef BX_BIG_ENDIAN - leaf->ebx = bx_bswap32(leaf->ebx); - leaf->ecx = bx_bswap32(leaf->ecx); - leaf->edx = bx_bswap32(leaf->edx); -#endif + get_leaf_0(0x1, "AuthenticAMD", leaf); } // leaf 0x00000001 // @@ -187,10 +172,7 @@ void amd_k6_2_chomper_t::get_ext_cpuid_leaf_0(cpuid_function_t *leaf) const // EBX: reserved // EDX: reserved // ECX: reserved - leaf->eax = 0x80000005; - leaf->ebx = 0; - leaf->ecx = 0; - leaf->edx = 0; + get_leaf_0(0x80000005, NULL, leaf); } // leaf 0x80000001 // @@ -269,31 +251,10 @@ void amd_k6_2_chomper_t::get_ext_cpuid_leaf_5(cpuid_function_t *leaf) const leaf->edx = 0x20020220; } -// leaf 0x8FFFFFFF // -void amd_k6_2_chomper_t::get_cpuid_hidden_level(cpuid_function_t *leaf) const -{ - static const char* magic_string = "NexGenerationAMD"; - - memcpy(&(leaf->eax), magic_string , 4); - memcpy(&(leaf->ebx), magic_string + 4, 4); - memcpy(&(leaf->ecx), magic_string + 8, 4); - memcpy(&(leaf->edx), magic_string + 12, 4); - -#ifdef BX_BIG_ENDIAN - leaf->eax = bx_bswap32(leaf->eax); - leaf->ebx = bx_bswap32(leaf->ebx); - leaf->ecx = bx_bswap32(leaf->ecx); - leaf->edx = bx_bswap32(leaf->edx); -#endif -} - void amd_k6_2_chomper_t::dump_cpuid(void) const { bx_cpuid_t::dump_cpuid(0x1, 0x5); - - struct cpuid_function_t leaf; - get_cpuid_leaf(0x8fffffff, 0x00000000, &leaf); - BX_INFO(("CPUID[0x8fffffff]: %08x %08x %08x %08x", leaf.eax, leaf.ebx, leaf.ecx, leaf.edx)); + dump_cpuid_leaf(0x8fffffff); } bx_cpuid_t *create_amd_k6_2_chomper_cpuid(BX_CPU_C *cpu) { return new amd_k6_2_chomper_t(cpu); } diff --git a/bochs/cpu/cpudb/amd_k6_2_chomper.h b/bochs/cpu/cpudb/amd_k6_2_chomper.h index e34bb3439..a7e8d8052 100644 --- a/bochs/cpu/cpudb/amd_k6_2_chomper.h +++ b/bochs/cpu/cpudb/amd_k6_2_chomper.h @@ -47,8 +47,6 @@ private: void get_ext_cpuid_leaf_0(cpuid_function_t *leaf) const; void get_ext_cpuid_leaf_1(cpuid_function_t *leaf) const; void get_ext_cpuid_leaf_5(cpuid_function_t *leaf) const; - - void get_cpuid_hidden_level(cpuid_function_t *leaf) const; }; extern bx_cpuid_t *create_amd_k6_2_chomper_cpuid(BX_CPU_C *cpu); diff --git a/bochs/cpu/cpudb/amd_k6_2_chomper.txt b/bochs/cpu/cpudb/amd_k6_2_chomper.txt index c1dd19083..628261f63 100644 --- a/bochs/cpu/cpudb/amd_k6_2_chomper.txt +++ b/bochs/cpu/cpudb/amd_k6_2_chomper.txt @@ -1,64 +1,32 @@ -CPU-Z TXT Report -------------------------------------------------------------------------- +------[ Versions ]------ -Binaries -------------------------------------------------------------------------- +Program Version : EVEREST v4.60.1629 Beta +BenchDLL Version: 2.4.257.0 -CPU-Z version 1.53.1 +------[ CPU Info ]------ -Processors -------------------------------------------------------------------------- +CPU Type : AMD K6-2, 333 MHz +CPU Alias : Chomper, K6 3D, 6k86 3D +CPU Platform : Socket 7 +CPU Stepping : A +Instruction Set : x86, MMX, 3DNow! +CPUID Manufacturer : AuthenticAMD +CPUID CPU Name : AMD-K6(tm) 3D processor +CPUID Revision : 00000580h +Platform ID : CBh (Socket 7) -Number of processors 1 -Number of threads 1 +------[ Logical CPU #0 ]------ -APICs -------------------------------------------------------------------------- +allcpu: Valid -Processor 0 - -- Core 0 - -- Thread 0 0 +CPUID 00000000: 00000001-68747541-444D4163-69746E65 +CPUID 00000001: 00000580-00000000-00000000-008001BF +CPUID 80000000: 80000005-00000000-00000000-00000000 +CPUID 80000001: 00000680-00000000-00000000-808009BF +CPUID 80000002: 2D444D41-7428364B-3320296D-72702044 +CPUID 80000003: 7365636F-00726F73-00000000-00000000 +CPUID 80000004: 00000000-00000000-00000000-00000000 +CPUID 80000005: 00000000-02800140-20020220-20020220 +CPUID 8FFFFFFF: 4778654E-72656E65-6F697461-444D416E -Processors Information -------------------------------------------------------------------------- - -Processor 1 ID = 0 - Number of cores 1 (max 1) - Number of threads 1 (max 1) - Name AMD K6-2 - Codename Chomper - Specification AMD-K6(tm) 3D processor - Package Socket 7 (321) - CPUID 5.8.0 - Extended CPUID 6.8 - Core Stepping - Technology 0.25 um - Core Speed 267.3 MHz - Instructions sets MMX, 3DNow! - L1 Data cache 32 KBytes, 2-way set associative, 32-byte line size - L1 Instruction cache 32 KBytes, 2-way set associative, 32-byte line size - FID/VID Control no - - - -Thread dumps -------------------------------------------------------------------------- - -CPU Thread 0 - APIC ID 0 - Topology Processor ID 0, Core ID 0, Thread ID 0 - Type 02000802h - Max CPUID level 00000001h - Max CPUID ext. level 80000005h - Cache descriptor Level 1, I, 32 KB, 1 thread(s) - Cache descriptor Level 1, D, 32 KB, 1 thread(s) - - CPUID - 0x00000000 0x00000001 0x68747541 0x444D4163 0x69746E65 - 0x00000001 0x00000580 0x00000000 0x00000000 0x008001BF - 0x80000000 0x80000005 0x00000000 0x00000000 0x00000000 - 0x80000001 0x00000680 0x00000000 0x00000000 0x808009BF - 0x80000002 0x2D444D41 0x7428364B 0x3320296D 0x72702044 - 0x80000003 0x7365636F 0x00726F73 0x00000000 0x00000000 - 0x80000004 0x00000000 0x00000000 0x00000000 0x00000000 - 0x80000005 0x00000000 0x02800140 0x20020220 0x20020220 +------[ MSR Registers ]------ diff --git a/bochs/cpu/cpudb/athlon64_clawhammer.cc b/bochs/cpu/cpudb/athlon64_clawhammer.cc index 42302dae6..cf0c1a0f7 100644 --- a/bochs/cpu/cpudb/athlon64_clawhammer.cc +++ b/bochs/cpu/cpudb/athlon64_clawhammer.cc @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2011-2014 Stanislav Shwartsman +// Copyright (c) 2011-2015 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or @@ -71,10 +71,11 @@ athlon64_clawhammer_t::athlon64_clawhammer_t(BX_CPU_C *cpu): bx_cpuid_t(cpu) void athlon64_clawhammer_t::get_cpuid_leaf(Bit32u function, Bit32u subfunction, cpuid_function_t *leaf) const { static const char* brand_string = "AMD Athlon(tm) 64 Processor 2800+\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; + static const char* magic_string = "IT'S HAMMER TIME"; switch(function) { case 0x8FFFFFFF: - get_cpuid_hidden_level(leaf); + get_cpuid_hidden_level(leaf, magic_string); return; case 0x80000000: get_ext_cpuid_leaf_0(leaf); @@ -114,23 +115,7 @@ void athlon64_clawhammer_t::get_cpuid_leaf(Bit32u function, Bit32u subfunction, // leaf 0x00000000 // void athlon64_clawhammer_t::get_std_cpuid_leaf_0(cpuid_function_t *leaf) const { - static const char* vendor_string = "AuthenticAMD"; - - // EAX: highest std function understood by CPUID - // EBX: vendor ID string - // EDX: vendor ID string - // ECX: vendor ID string - leaf->eax = 0x1; - - // CPUID vendor string (e.g. GenuineIntel, AuthenticAMD, CentaurHauls, ...) - memcpy(&(leaf->ebx), vendor_string, 4); - memcpy(&(leaf->edx), vendor_string + 4, 4); - memcpy(&(leaf->ecx), vendor_string + 8, 4); -#ifdef BX_BIG_ENDIAN - leaf->ebx = bx_bswap32(leaf->ebx); - leaf->ecx = bx_bswap32(leaf->ecx); - leaf->edx = bx_bswap32(leaf->edx); -#endif + get_leaf_0(0x1, "AuthenticAMD", leaf); } // leaf 0x00000001 // @@ -224,21 +209,7 @@ void athlon64_clawhammer_t::get_std_cpuid_leaf_1(cpuid_function_t *leaf) const // leaf 0x80000000 // void athlon64_clawhammer_t::get_ext_cpuid_leaf_0(cpuid_function_t *leaf) const { - static const char* vendor_string = "AuthenticAMD"; - - // EAX: highest extended function understood by CPUID - // EBX: reserved - // EDX: reserved - // ECX: reserved - leaf->eax = 0x80000018; - memcpy(&(leaf->ebx), vendor_string, 4); - memcpy(&(leaf->edx), vendor_string + 4, 4); - memcpy(&(leaf->ecx), vendor_string + 8, 4); -#ifdef BX_BIG_ENDIAN - leaf->ebx = bx_bswap32(leaf->ebx); - leaf->ecx = bx_bswap32(leaf->ecx); - leaf->edx = bx_bswap32(leaf->edx); -#endif + get_leaf_0(0x80000018, "AuthenticAMD", leaf); } // leaf 0x80000001 // @@ -366,31 +337,10 @@ void athlon64_clawhammer_t::get_ext_cpuid_leaf_8(cpuid_function_t *leaf) const // leaf 0x8000000A : SVM // // leaf 0x8000000B - 0x80000018: Reserved // -// leaf 0x8FFFFFFF // -void athlon64_clawhammer_t::get_cpuid_hidden_level(cpuid_function_t *leaf) const -{ - static const char* magic_string = "IT'S HAMMER TIME"; - - memcpy(&(leaf->eax), magic_string , 4); - memcpy(&(leaf->ebx), magic_string + 4, 4); - memcpy(&(leaf->ecx), magic_string + 8, 4); - memcpy(&(leaf->edx), magic_string + 12, 4); - -#ifdef BX_BIG_ENDIAN - leaf->eax = bx_bswap32(leaf->eax); - leaf->ebx = bx_bswap32(leaf->ebx); - leaf->ecx = bx_bswap32(leaf->ecx); - leaf->edx = bx_bswap32(leaf->edx); -#endif -} - void athlon64_clawhammer_t::dump_cpuid(void) const { bx_cpuid_t::dump_cpuid(0x1, 0x18); - - struct cpuid_function_t leaf; - get_cpuid_leaf(0x8fffffff, 0x00000000, &leaf); - BX_INFO(("CPUID[0x8fffffff]: %08x %08x %08x %08x", leaf.eax, leaf.ebx, leaf.ecx, leaf.edx)); + dump_cpuid_leaf(0x8fffffff); } bx_cpuid_t *create_athlon64_clawhammer_cpuid(BX_CPU_C *cpu) { return new athlon64_clawhammer_t(cpu); } diff --git a/bochs/cpu/cpudb/athlon64_clawhammer.h b/bochs/cpu/cpudb/athlon64_clawhammer.h index beeb77a66..c5170059c 100644 --- a/bochs/cpu/cpudb/athlon64_clawhammer.h +++ b/bochs/cpu/cpudb/athlon64_clawhammer.h @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2011-2014 Stanislav Shwartsman +// Copyright (c) 2011-2015 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or @@ -50,8 +50,6 @@ private: void get_ext_cpuid_leaf_6(cpuid_function_t *leaf) const; void get_ext_cpuid_leaf_7(cpuid_function_t *leaf) const; void get_ext_cpuid_leaf_8(cpuid_function_t *leaf) const; - - void get_cpuid_hidden_level(cpuid_function_t *leaf) const; }; extern bx_cpuid_t *create_athlon64_clawhammer_cpuid(BX_CPU_C *cpu); diff --git a/bochs/cpu/cpudb/athlon64_venice.cc b/bochs/cpu/cpudb/athlon64_venice.cc index 2a5dd8a04..013c270ad 100644 --- a/bochs/cpu/cpudb/athlon64_venice.cc +++ b/bochs/cpu/cpudb/athlon64_venice.cc @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2011-2014 Stanislav Shwartsman +// Copyright (c) 2011-2015 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or @@ -73,10 +73,11 @@ athlon64_venice_t::athlon64_venice_t(BX_CPU_C *cpu): bx_cpuid_t(cpu) void athlon64_venice_t::get_cpuid_leaf(Bit32u function, Bit32u subfunction, cpuid_function_t *leaf) const { static const char* brand_string = "AMD Athlon(tm) 64 Processor 3000+\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; + static const char* magic_string = "IT'S HAMMER TIME"; switch(function) { case 0x8FFFFFFF: - get_cpuid_hidden_level(leaf); + get_cpuid_hidden_level(leaf, magic_string); return; case 0x80000000: get_ext_cpuid_leaf_0(leaf); @@ -116,23 +117,7 @@ void athlon64_venice_t::get_cpuid_leaf(Bit32u function, Bit32u subfunction, cpui // leaf 0x00000000 // void athlon64_venice_t::get_std_cpuid_leaf_0(cpuid_function_t *leaf) const { - static const char* vendor_string = "AuthenticAMD"; - - // EAX: highest std function understood by CPUID - // EBX: vendor ID string - // EDX: vendor ID string - // ECX: vendor ID string - leaf->eax = 0x1; - - // CPUID vendor string (e.g. GenuineIntel, AuthenticAMD, CentaurHauls, ...) - memcpy(&(leaf->ebx), vendor_string, 4); - memcpy(&(leaf->edx), vendor_string + 4, 4); - memcpy(&(leaf->ecx), vendor_string + 8, 4); -#ifdef BX_BIG_ENDIAN - leaf->ebx = bx_bswap32(leaf->ebx); - leaf->ecx = bx_bswap32(leaf->ecx); - leaf->edx = bx_bswap32(leaf->edx); -#endif + get_leaf_0(0x1, "AuthenticAMD", leaf); } // leaf 0x00000001 // @@ -258,21 +243,7 @@ void athlon64_venice_t::get_std_cpuid_leaf_1(cpuid_function_t *leaf) const // leaf 0x80000000 // void athlon64_venice_t::get_ext_cpuid_leaf_0(cpuid_function_t *leaf) const { - static const char* vendor_string = "AuthenticAMD"; - - // EAX: highest extended function understood by CPUID - // EBX: reserved - // EDX: reserved - // ECX: reserved - leaf->eax = 0x80000018; - memcpy(&(leaf->ebx), vendor_string, 4); - memcpy(&(leaf->edx), vendor_string + 4, 4); - memcpy(&(leaf->ecx), vendor_string + 8, 4); -#ifdef BX_BIG_ENDIAN - leaf->ebx = bx_bswap32(leaf->ebx); - leaf->ecx = bx_bswap32(leaf->ecx); - leaf->edx = bx_bswap32(leaf->edx); -#endif + get_leaf_0(0x80000018, "AuthenticAMD", leaf); } // leaf 0x80000001 // @@ -417,31 +388,10 @@ void athlon64_venice_t::get_ext_cpuid_leaf_8(cpuid_function_t *leaf) const // leaf 0x8000000A : SVM // // leaf 0x8000000B - 0x80000018: Reserved // -// leaf 0x8FFFFFFF // -void athlon64_venice_t::get_cpuid_hidden_level(cpuid_function_t *leaf) const -{ - static const char* magic_string = "IT'S HAMMER TIME"; - - memcpy(&(leaf->eax), magic_string , 4); - memcpy(&(leaf->ebx), magic_string + 4, 4); - memcpy(&(leaf->ecx), magic_string + 8, 4); - memcpy(&(leaf->edx), magic_string + 12, 4); - -#ifdef BX_BIG_ENDIAN - leaf->eax = bx_bswap32(leaf->eax); - leaf->ebx = bx_bswap32(leaf->ebx); - leaf->ecx = bx_bswap32(leaf->ecx); - leaf->edx = bx_bswap32(leaf->edx); -#endif -} - void athlon64_venice_t::dump_cpuid(void) const { bx_cpuid_t::dump_cpuid(0x1, 0x18); - - struct cpuid_function_t leaf; - get_cpuid_leaf(0x8fffffff, 0x00000000, &leaf); - BX_INFO(("CPUID[0x8fffffff]: %08x %08x %08x %08x", leaf.eax, leaf.ebx, leaf.ecx, leaf.edx)); + dump_cpuid_leaf(0x8fffffff); } bx_cpuid_t *create_athlon64_venice_cpuid(BX_CPU_C *cpu) { return new athlon64_venice_t(cpu); } diff --git a/bochs/cpu/cpudb/athlon64_venice.h b/bochs/cpu/cpudb/athlon64_venice.h index e45d52a82..3d4739e5a 100644 --- a/bochs/cpu/cpudb/athlon64_venice.h +++ b/bochs/cpu/cpudb/athlon64_venice.h @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2011-2014 Stanislav Shwartsman +// Copyright (c) 2011-2015 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or @@ -50,8 +50,6 @@ private: void get_ext_cpuid_leaf_6(cpuid_function_t *leaf) const; void get_ext_cpuid_leaf_7(cpuid_function_t *leaf) const; void get_ext_cpuid_leaf_8(cpuid_function_t *leaf) const; - - void get_cpuid_hidden_level(cpuid_function_t *leaf) const; }; extern bx_cpuid_t *create_athlon64_venice_cpuid(BX_CPU_C *cpu); diff --git a/bochs/cpu/cpudb/atom_n270.cc b/bochs/cpu/cpudb/atom_n270.cc index e2f4b6ec0..e689526b5 100644 --- a/bochs/cpu/cpudb/atom_n270.cc +++ b/bochs/cpu/cpudb/atom_n270.cc @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2011-2014 Stanislav Shwartsman +// Copyright (c) 2011-2015 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or @@ -142,21 +142,12 @@ void atom_n270_t::get_std_cpuid_leaf_0(cpuid_function_t *leaf) const // EBX: vendor ID string // EDX: vendor ID string // ECX: vendor ID string + unsigned max_leaf = 0xA; static bx_bool cpuid_limit_winnt = SIM->get_param_bool(BXPN_CPUID_LIMIT_WINNT)->get(); if (cpuid_limit_winnt) - leaf->eax = 0x2; - else - leaf->eax = 0xA; + max_leaf = 0x2; - // CPUID vendor string (e.g. GenuineIntel, AuthenticAMD, CentaurHauls, ...) - memcpy(&(leaf->ebx), vendor_string, 4); - memcpy(&(leaf->edx), vendor_string + 4, 4); - memcpy(&(leaf->ecx), vendor_string + 8, 4); -#ifdef BX_BIG_ENDIAN - leaf->ebx = bx_bswap32(leaf->ebx); - leaf->ecx = bx_bswap32(leaf->ecx); - leaf->edx = bx_bswap32(leaf->edx); -#endif + get_leaf_0(max_leaf, vendor_string, leaf); } // leaf 0x00000001 // @@ -462,10 +453,7 @@ void atom_n270_t::get_ext_cpuid_leaf_0(cpuid_function_t *leaf) const // EBX: reserved // EDX: reserved // ECX: reserved - leaf->eax = 0x80000008; - leaf->ebx = 0; - leaf->edx = 0; // Reserved for Intel - leaf->ecx = 0; + get_leaf_0(0x80000008, NULL, leaf); } // leaf 0x80000001 // diff --git a/bochs/cpu/cpudb/core2_penryn_t9600.cc b/bochs/cpu/cpudb/core2_penryn_t9600.cc index 30c104dcf..b37f4363e 100644 --- a/bochs/cpu/cpudb/core2_penryn_t9600.cc +++ b/bochs/cpu/cpudb/core2_penryn_t9600.cc @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2011-2014 Stanislav Shwartsman +// Copyright (c) 2011-2015 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or @@ -189,21 +189,12 @@ void core2_penryn_t9600_t::get_std_cpuid_leaf_0(cpuid_function_t *leaf) const // EBX: vendor ID string // EDX: vendor ID string // ECX: vendor ID string + unsigned max_leaf = 0xD; static bx_bool cpuid_limit_winnt = SIM->get_param_bool(BXPN_CPUID_LIMIT_WINNT)->get(); if (cpuid_limit_winnt) - leaf->eax = 0x2; - else - leaf->eax = 0xD; + max_leaf = 0x2; - // CPUID vendor string (e.g. GenuineIntel, AuthenticAMD, CentaurHauls, ...) - memcpy(&(leaf->ebx), vendor_string, 4); - memcpy(&(leaf->edx), vendor_string + 4, 4); - memcpy(&(leaf->ecx), vendor_string + 8, 4); -#ifdef BX_BIG_ENDIAN - leaf->ebx = bx_bswap32(leaf->ebx); - leaf->ecx = bx_bswap32(leaf->ecx); - leaf->edx = bx_bswap32(leaf->edx); -#endif + get_leaf_0(max_leaf, vendor_string, leaf); } // leaf 0x00000001 // @@ -544,10 +535,7 @@ void core2_penryn_t9600_t::get_ext_cpuid_leaf_0(cpuid_function_t *leaf) const // EBX: reserved // EDX: reserved // ECX: reserved - leaf->eax = 0x80000008; - leaf->ebx = 0; - leaf->edx = 0; // Reserved for Intel - leaf->ecx = 0; + get_leaf_0(0x80000008, NULL, leaf); } // leaf 0x80000001 // diff --git a/bochs/cpu/cpudb/core_duo_t2400_yonah.cc b/bochs/cpu/cpudb/core_duo_t2400_yonah.cc index bec591e4d..302b41377 100644 --- a/bochs/cpu/cpudb/core_duo_t2400_yonah.cc +++ b/bochs/cpu/cpudb/core_duo_t2400_yonah.cc @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2011-2014 Stanislav Shwartsman +// Copyright (c) 2011-2015 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or @@ -144,21 +144,12 @@ void core_duo_t2400_yonah_t::get_std_cpuid_leaf_0(cpuid_function_t *leaf) const // EBX: vendor ID string // EDX: vendor ID string // ECX: vendor ID string + unsigned max_leaf = 0xA; static bx_bool cpuid_limit_winnt = SIM->get_param_bool(BXPN_CPUID_LIMIT_WINNT)->get(); if (cpuid_limit_winnt) - leaf->eax = 0x2; - else - leaf->eax = 0xA; + max_leaf = 0x2; - // CPUID vendor string (e.g. GenuineIntel, AuthenticAMD, CentaurHauls, ...) - memcpy(&(leaf->ebx), vendor_string, 4); - memcpy(&(leaf->edx), vendor_string + 4, 4); - memcpy(&(leaf->ecx), vendor_string + 8, 4); -#ifdef BX_BIG_ENDIAN - leaf->ebx = bx_bswap32(leaf->ebx); - leaf->ecx = bx_bswap32(leaf->ecx); - leaf->edx = bx_bswap32(leaf->edx); -#endif + get_leaf_0(max_leaf, vendor_string, leaf); } // leaf 0x00000001 // @@ -463,10 +454,7 @@ void core_duo_t2400_yonah_t::get_ext_cpuid_leaf_0(cpuid_function_t *leaf) const // EBX: reserved // EDX: reserved // ECX: reserved - leaf->eax = 0x80000008; - leaf->ebx = 0; - leaf->edx = 0; // Reserved for Intel - leaf->ecx = 0; + get_leaf_0(0x80000008, NULL, leaf); } // leaf 0x80000001 // diff --git a/bochs/cpu/cpudb/corei5_arrandale_m520.cc b/bochs/cpu/cpudb/corei5_arrandale_m520.cc index 79252150d..f61b8ba28 100644 --- a/bochs/cpu/cpudb/corei5_arrandale_m520.cc +++ b/bochs/cpu/cpudb/corei5_arrandale_m520.cc @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2011-2014 Stanislav Shwartsman +// Copyright (c) 2011-2015 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or @@ -206,21 +206,12 @@ void corei5_arrandale_m520_t::get_std_cpuid_leaf_0(cpuid_function_t *leaf) const // EBX: vendor ID string // EDX: vendor ID string // ECX: vendor ID string + unsigned max_leaf = 0xB; static bx_bool cpuid_limit_winnt = SIM->get_param_bool(BXPN_CPUID_LIMIT_WINNT)->get(); if (cpuid_limit_winnt) - leaf->eax = 0x2; - else - leaf->eax = 0xB; + max_leaf = 0x2; - // CPUID vendor string (e.g. GenuineIntel, AuthenticAMD, CentaurHauls, ...) - memcpy(&(leaf->ebx), vendor_string, 4); - memcpy(&(leaf->edx), vendor_string + 4, 4); - memcpy(&(leaf->ecx), vendor_string + 8, 4); -#ifdef BX_BIG_ENDIAN - leaf->ebx = bx_bswap32(leaf->ebx); - leaf->ecx = bx_bswap32(leaf->ecx); - leaf->edx = bx_bswap32(leaf->edx); -#endif + get_leaf_0(max_leaf, vendor_string, leaf); } // leaf 0x00000001 // @@ -540,10 +531,7 @@ void corei5_arrandale_m520_t::get_ext_cpuid_leaf_0(cpuid_function_t *leaf) const // EBX: reserved // EDX: reserved // ECX: reserved - leaf->eax = 0x80000008; - leaf->ebx = 0; - leaf->edx = 0; // Reserved for Intel - leaf->ecx = 0; + get_leaf_0(0x80000008, NULL, leaf); } // leaf 0x80000001 // diff --git a/bochs/cpu/cpudb/corei5_lynnfield_750.cc b/bochs/cpu/cpudb/corei5_lynnfield_750.cc index a5fa1733d..f9613db1e 100644 --- a/bochs/cpu/cpudb/corei5_lynnfield_750.cc +++ b/bochs/cpu/cpudb/corei5_lynnfield_750.cc @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2011-2014 Stanislav Shwartsman +// Copyright (c) 2011-2015 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or @@ -184,21 +184,12 @@ void corei5_lynnfield_750_t::get_std_cpuid_leaf_0(cpuid_function_t *leaf) const // EBX: vendor ID string // EDX: vendor ID string // ECX: vendor ID string + unsigned max_leaf = 0xB; static bx_bool cpuid_limit_winnt = SIM->get_param_bool(BXPN_CPUID_LIMIT_WINNT)->get(); if (cpuid_limit_winnt) - leaf->eax = 0x2; - else - leaf->eax = 0xB; + max_leaf = 0x2; - // CPUID vendor string (e.g. GenuineIntel, AuthenticAMD, CentaurHauls, ...) - memcpy(&(leaf->ebx), vendor_string, 4); - memcpy(&(leaf->edx), vendor_string + 4, 4); - memcpy(&(leaf->ecx), vendor_string + 8, 4); -#ifdef BX_BIG_ENDIAN - leaf->ebx = bx_bswap32(leaf->ebx); - leaf->ecx = bx_bswap32(leaf->ecx); - leaf->edx = bx_bswap32(leaf->edx); -#endif + get_leaf_0(max_leaf, vendor_string, leaf); } // leaf 0x00000001 // @@ -515,10 +506,7 @@ void corei5_lynnfield_750_t::get_ext_cpuid_leaf_0(cpuid_function_t *leaf) const // EBX: reserved // EDX: reserved // ECX: reserved - leaf->eax = 0x80000008; - leaf->ebx = 0; - leaf->edx = 0; // Reserved for Intel - leaf->ecx = 0; + get_leaf_0(0x80000008, NULL, leaf); } // leaf 0x80000001 // diff --git a/bochs/cpu/cpudb/corei7_haswell_4770.cc b/bochs/cpu/cpudb/corei7_haswell_4770.cc index b4c6d4289..c009de474 100644 --- a/bochs/cpu/cpudb/corei7_haswell_4770.cc +++ b/bochs/cpu/cpudb/corei7_haswell_4770.cc @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2013-2014 Stanislav Shwartsman +// Copyright (c) 2013-2015 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or @@ -222,21 +222,12 @@ void corei7_haswell_4770_t::get_std_cpuid_leaf_0(cpuid_function_t *leaf) const // EBX: vendor ID string // EDX: vendor ID string // ECX: vendor ID string + unsigned max_leaf = 0xD; static bx_bool cpuid_limit_winnt = SIM->get_param_bool(BXPN_CPUID_LIMIT_WINNT)->get(); if (cpuid_limit_winnt) - leaf->eax = 0x2; - else - leaf->eax = 0xD; + max_leaf = 0x2; - // CPUID vendor string (e.g. GenuineIntel, AuthenticAMD, CentaurHauls, ...) - memcpy(&(leaf->ebx), vendor_string, 4); - memcpy(&(leaf->edx), vendor_string + 4, 4); - memcpy(&(leaf->ecx), vendor_string + 8, 4); -#ifdef BX_BIG_ENDIAN - leaf->ebx = bx_bswap32(leaf->ebx); - leaf->ecx = bx_bswap32(leaf->ecx); - leaf->edx = bx_bswap32(leaf->edx); -#endif + get_leaf_0(max_leaf, vendor_string, leaf); } // leaf 0x00000001 // @@ -524,14 +515,14 @@ void corei7_haswell_4770_t::get_std_cpuid_leaf_7(Bit32u subfunction, cpuid_funct // * [1:1] Support for IA32_TSC_ADJUST MSR // [2:2] reserved // * [3:3] BMI1: Advanced Bit Manipulation Extensions - // * [4:4] HLE: Hardware Lock Elision + // [4:4] HLE: Hardware Lock Elision // * [5:5] AVX2 // [6:6] reserved // * [7:7] SMEP: Supervisor Mode Execution Protection // * [8:8] BMI2: Advanced Bit Manipulation Extensions // * [9:9] Support for Enhanced REP MOVSB/STOSB // * [10:10] Support for INVPCID instruction - // * [11:11] RTM: Restricted Transactional Memory + // [11:11] RTM: Restricted Transactional Memory // [12:12] Supports Quality of Service (QoS) capability // * [13:13] Deprecates FPU CS and FPU DS values // [17:14] reserved @@ -542,13 +533,11 @@ void corei7_haswell_4770_t::get_std_cpuid_leaf_7(Bit32u subfunction, cpuid_funct leaf->ebx = BX_CPUID_EXT3_FSGSBASE | /* BX_CPUID_EXT3_TSC_ADJUST | */ // not implemented yet BX_CPUID_EXT3_BMI1 | - /* BX_CPUID_EXT3_HLE | */ // not implemented yet BX_CPUID_EXT3_AVX2 | BX_CPUID_EXT3_SMEP | BX_CPUID_EXT3_BMI2 | BX_CPUID_EXT3_ENCHANCED_REP_STRINGS | BX_CPUID_EXT3_INVPCID | - /* BX_CPUID_EXT3_RTM | */ // not implemented yet BX_CPUID_EXT3_DEPRECATE_FCS_FDS; leaf->ecx = 0; leaf->edx = 0; @@ -657,10 +646,7 @@ void corei7_haswell_4770_t::get_ext_cpuid_leaf_0(cpuid_function_t *leaf) const // EBX: reserved // EDX: reserved // ECX: reserved - leaf->eax = 0x80000008; - leaf->ebx = 0; - leaf->edx = 0; // Reserved for Intel - leaf->ecx = 0; + get_leaf_0(0x80000008, NULL, leaf); } // leaf 0x80000001 // diff --git a/bochs/cpu/cpudb/corei7_ivy_bridge_3770K.cc b/bochs/cpu/cpudb/corei7_ivy_bridge_3770K.cc index 5033ae0a9..76f9dc552 100644 --- a/bochs/cpu/cpudb/corei7_ivy_bridge_3770K.cc +++ b/bochs/cpu/cpudb/corei7_ivy_bridge_3770K.cc @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2013-2014 Stanislav Shwartsman +// Copyright (c) 2013-2015 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or @@ -226,21 +226,12 @@ void corei7_ivy_bridge_3770k_t::get_std_cpuid_leaf_0(cpuid_function_t *leaf) con // EBX: vendor ID string // EDX: vendor ID string // ECX: vendor ID string + unsigned max_leaf = 0xD; static bx_bool cpuid_limit_winnt = SIM->get_param_bool(BXPN_CPUID_LIMIT_WINNT)->get(); if (cpuid_limit_winnt) - leaf->eax = 0x2; - else - leaf->eax = 0xD; + max_leaf = 0x2; - // CPUID vendor string (e.g. GenuineIntel, AuthenticAMD, CentaurHauls, ...) - memcpy(&(leaf->ebx), vendor_string, 4); - memcpy(&(leaf->edx), vendor_string + 4, 4); - memcpy(&(leaf->ecx), vendor_string + 8, 4); -#ifdef BX_BIG_ENDIAN - leaf->ebx = bx_bswap32(leaf->ebx); - leaf->ecx = bx_bswap32(leaf->ecx); - leaf->edx = bx_bswap32(leaf->edx); -#endif + get_leaf_0(max_leaf, vendor_string, leaf); } // leaf 0x00000001 // @@ -651,10 +642,7 @@ void corei7_ivy_bridge_3770k_t::get_ext_cpuid_leaf_0(cpuid_function_t *leaf) con // EBX: reserved // EDX: reserved // ECX: reserved - leaf->eax = 0x80000008; - leaf->ebx = 0; - leaf->edx = 0; // Reserved for Intel - leaf->ecx = 0; + get_leaf_0(0x80000008, NULL, leaf); } // leaf 0x80000001 // diff --git a/bochs/cpu/cpudb/corei7_sandy_bridge_2600K.cc b/bochs/cpu/cpudb/corei7_sandy_bridge_2600K.cc index 5d267a49d..2599c35db 100644 --- a/bochs/cpu/cpudb/corei7_sandy_bridge_2600K.cc +++ b/bochs/cpu/cpudb/corei7_sandy_bridge_2600K.cc @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2011-2014 Stanislav Shwartsman +// Copyright (c) 2011-2015 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or @@ -220,21 +220,12 @@ void corei7_sandy_bridge_2600k_t::get_std_cpuid_leaf_0(cpuid_function_t *leaf) c // EBX: vendor ID string // EDX: vendor ID string // ECX: vendor ID string + unsigned max_leaf = 0xD; static bx_bool cpuid_limit_winnt = SIM->get_param_bool(BXPN_CPUID_LIMIT_WINNT)->get(); if (cpuid_limit_winnt) - leaf->eax = 0x2; - else - leaf->eax = 0xD; + max_leaf = 0x2; - // CPUID vendor string (e.g. GenuineIntel, AuthenticAMD, CentaurHauls, ...) - memcpy(&(leaf->ebx), vendor_string, 4); - memcpy(&(leaf->edx), vendor_string + 4, 4); - memcpy(&(leaf->ecx), vendor_string + 8, 4); -#ifdef BX_BIG_ENDIAN - leaf->ebx = bx_bswap32(leaf->ebx); - leaf->ecx = bx_bswap32(leaf->ecx); - leaf->edx = bx_bswap32(leaf->edx); -#endif + get_leaf_0(max_leaf, vendor_string, leaf); } // leaf 0x00000001 // @@ -616,10 +607,7 @@ void corei7_sandy_bridge_2600k_t::get_ext_cpuid_leaf_0(cpuid_function_t *leaf) c // EBX: reserved // EDX: reserved // ECX: reserved - leaf->eax = 0x80000008; - leaf->ebx = 0; - leaf->edx = 0; // Reserved for Intel - leaf->ecx = 0; + get_leaf_0(0x80000008, NULL, leaf); } // leaf 0x80000001 // diff --git a/bochs/cpu/cpudb/p2_klamath.cc b/bochs/cpu/cpudb/p2_klamath.cc index 975cd9a49..4775aa0d9 100644 --- a/bochs/cpu/cpudb/p2_klamath.cc +++ b/bochs/cpu/cpudb/p2_klamath.cc @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2011-2014 Stanislav Shwartsman +// Copyright (c) 2011-2015 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or @@ -72,23 +72,7 @@ void p2_klamath_t::get_cpuid_leaf(Bit32u function, Bit32u subfunction, cpuid_fun // leaf 0x00000000 // void p2_klamath_t::get_std_cpuid_leaf_0(cpuid_function_t *leaf) const { - static const char* vendor_string = "GenuineIntel"; - - // EAX: highest std function understood by CPUID - // EBX: vendor ID string - // EDX: vendor ID string - // ECX: vendor ID string - leaf->eax = 0x2; - - // CPUID vendor string (e.g. GenuineIntel, AuthenticAMD, CentaurHauls, ...) - memcpy(&(leaf->ebx), vendor_string, 4); - memcpy(&(leaf->edx), vendor_string + 4, 4); - memcpy(&(leaf->ecx), vendor_string + 8, 4); -#ifdef BX_BIG_ENDIAN - leaf->ebx = bx_bswap32(leaf->ebx); - leaf->ecx = bx_bswap32(leaf->ecx); - leaf->edx = bx_bswap32(leaf->edx); -#endif + get_leaf_0(0x2, "GenuineIntel", leaf); } // leaf 0x00000001 // diff --git a/bochs/cpu/cpudb/p3_katmai.cc b/bochs/cpu/cpudb/p3_katmai.cc index 9ce24b074..caab2ddfc 100644 --- a/bochs/cpu/cpudb/p3_katmai.cc +++ b/bochs/cpu/cpudb/p3_katmai.cc @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2011-2014 Stanislav Shwartsman +// Copyright (c) 2011-2015 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or @@ -77,23 +77,7 @@ void p3_katmai_t::get_cpuid_leaf(Bit32u function, Bit32u subfunction, cpuid_func // leaf 0x00000000 // void p3_katmai_t::get_std_cpuid_leaf_0(cpuid_function_t *leaf) const { - static const char* vendor_string = "GenuineIntel"; - - // EAX: highest std function understood by CPUID - // EBX: vendor ID string - // EDX: vendor ID string - // ECX: vendor ID string - leaf->eax = 0x3; - - // CPUID vendor string (e.g. GenuineIntel, AuthenticAMD, CentaurHauls, ...) - memcpy(&(leaf->ebx), vendor_string, 4); - memcpy(&(leaf->edx), vendor_string + 4, 4); - memcpy(&(leaf->ecx), vendor_string + 8, 4); -#ifdef BX_BIG_ENDIAN - leaf->ebx = bx_bswap32(leaf->ebx); - leaf->ecx = bx_bswap32(leaf->ecx); - leaf->edx = bx_bswap32(leaf->edx); -#endif + get_leaf_0(0x3, "GenuineIntel", leaf); } // leaf 0x00000001 // diff --git a/bochs/cpu/cpudb/p4_prescott_celeron_336.cc b/bochs/cpu/cpudb/p4_prescott_celeron_336.cc index 9eb3df39d..5d98d279d 100644 --- a/bochs/cpu/cpudb/p4_prescott_celeron_336.cc +++ b/bochs/cpu/cpudb/p4_prescott_celeron_336.cc @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2011-2014 Stanislav Shwartsman +// Copyright (c) 2011-2015 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or @@ -119,23 +119,7 @@ void p4_prescott_celeron_336_t::get_cpuid_leaf(Bit32u function, Bit32u subfuncti // leaf 0x00000000 // void p4_prescott_celeron_336_t::get_std_cpuid_leaf_0(cpuid_function_t *leaf) const { - static const char* vendor_string = "GenuineIntel"; - - // EAX: highest std function understood by CPUID - // EBX: vendor ID string - // EDX: vendor ID string - // ECX: vendor ID string - leaf->eax = 0x3; - - // CPUID vendor string (e.g. GenuineIntel, AuthenticAMD, CentaurHauls, ...) - memcpy(&(leaf->ebx), vendor_string, 4); - memcpy(&(leaf->edx), vendor_string + 4, 4); - memcpy(&(leaf->ecx), vendor_string + 8, 4); -#ifdef BX_BIG_ENDIAN - leaf->ebx = bx_bswap32(leaf->ebx); - leaf->ecx = bx_bswap32(leaf->ecx); - leaf->edx = bx_bswap32(leaf->edx); -#endif + get_leaf_0(0x3, "GenuineIntel", leaf); } // leaf 0x00000001 // @@ -302,10 +286,7 @@ void p4_prescott_celeron_336_t::get_ext_cpuid_leaf_0(cpuid_function_t *leaf) con // EBX: reserved // EDX: reserved // ECX: reserved - leaf->eax = 0x80000008; - leaf->ebx = 0; - leaf->edx = 0; // Reserved for Intel - leaf->ecx = 0; + get_leaf_0(0x80000008, NULL, leaf); } // leaf 0x80000001 // diff --git a/bochs/cpu/cpudb/p4_willamette.cc b/bochs/cpu/cpudb/p4_willamette.cc index fc3a6cdaa..3864e6afb 100644 --- a/bochs/cpu/cpudb/p4_willamette.cc +++ b/bochs/cpu/cpudb/p4_willamette.cc @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2011-2014 Stanislav Shwartsman +// Copyright (c) 2011-2015 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or @@ -91,23 +91,7 @@ void p4_willamette_t::get_cpuid_leaf(Bit32u function, Bit32u subfunction, cpuid_ // leaf 0x00000000 // void p4_willamette_t::get_std_cpuid_leaf_0(cpuid_function_t *leaf) const { - static const char* vendor_string = "GenuineIntel"; - - // EAX: highest std function understood by CPUID - // EBX: vendor ID string - // EDX: vendor ID string - // ECX: vendor ID string - leaf->eax = 0x2; - - // CPUID vendor string (e.g. GenuineIntel, AuthenticAMD, CentaurHauls, ...) - memcpy(&(leaf->ebx), vendor_string, 4); - memcpy(&(leaf->edx), vendor_string + 4, 4); - memcpy(&(leaf->ecx), vendor_string + 8, 4); -#ifdef BX_BIG_ENDIAN - leaf->ebx = bx_bswap32(leaf->ebx); - leaf->ecx = bx_bswap32(leaf->ecx); - leaf->edx = bx_bswap32(leaf->edx); -#endif + get_leaf_0(0x2, "GenuineIntel", leaf); } // leaf 0x00000001 // @@ -223,10 +207,7 @@ void p4_willamette_t::get_ext_cpuid_leaf_0(cpuid_function_t *leaf) const // EBX: reserved // EDX: reserved // ECX: reserved - leaf->eax = 0x80000004; - leaf->ebx = 0; - leaf->edx = 0; // Reserved for Intel - leaf->ecx = 0; + get_leaf_0(0x80000004, NULL, leaf); } // leaf 0x80000001 // diff --git a/bochs/cpu/cpudb/pentium_mmx.cc b/bochs/cpu/cpudb/pentium_mmx.cc index 1e7f28d83..f8b11faeb 100644 --- a/bochs/cpu/cpudb/pentium_mmx.cc +++ b/bochs/cpu/cpudb/pentium_mmx.cc @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2011-2014 Stanislav Shwartsman +// Copyright (c) 2011-2015 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or @@ -67,23 +67,7 @@ void pentium_mmx_t::get_cpuid_leaf(Bit32u function, Bit32u subfunction, cpuid_fu // leaf 0x00000000 // void pentium_mmx_t::get_std_cpuid_leaf_0(cpuid_function_t *leaf) const { - static const char* vendor_string = "GenuineIntel"; - - // EAX: highest std function understood by CPUID - // EBX: vendor ID string - // EDX: vendor ID string - // ECX: vendor ID string - leaf->eax = 0x1; - - // CPUID vendor string (e.g. GenuineIntel, AuthenticAMD, CentaurHauls, ...) - memcpy(&(leaf->ebx), vendor_string, 4); - memcpy(&(leaf->edx), vendor_string + 4, 4); - memcpy(&(leaf->ecx), vendor_string + 8, 4); -#ifdef BX_BIG_ENDIAN - leaf->ebx = bx_bswap32(leaf->ebx); - leaf->ecx = bx_bswap32(leaf->ecx); - leaf->edx = bx_bswap32(leaf->edx); -#endif + get_leaf_0(0x1, "GenuineIntel", leaf); } // leaf 0x00000001 // diff --git a/bochs/cpu/cpudb/pentium_mmx.h b/bochs/cpu/cpudb/pentium_mmx.h index a0d6effc5..c26ccb630 100644 --- a/bochs/cpu/cpudb/pentium_mmx.h +++ b/bochs/cpu/cpudb/pentium_mmx.h @@ -47,6 +47,6 @@ private: extern bx_cpuid_t *create_pentium_mmx_cpuid(BX_CPU_C *cpu); -#endif // BX_CPU_LEVEL >= 5 && BX_SUPPORT_X86_64 == 0 +#endif // BX_CPU_LEVEL >= 5 #endif diff --git a/bochs/cpu/cpudb/phenomx3_8650_toliman.cc b/bochs/cpu/cpudb/phenomx3_8650_toliman.cc index 75a9bb256..857a4d2c8 100644 --- a/bochs/cpu/cpudb/phenomx3_8650_toliman.cc +++ b/bochs/cpu/cpudb/phenomx3_8650_toliman.cc @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2012-2014 Stanislav Shwartsman +// Copyright (c) 2012-2015 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or @@ -170,27 +170,12 @@ void phenom_8650_toliman_t::get_std_cpuid_leaf_0(cpuid_function_t *leaf) const // EBX: vendor ID string // EDX: vendor ID string // ECX: vendor ID string + unsigned max_leaf = BX_SUPPORT_MONITOR_MWAIT ? 0x5 : 0x1; static bx_bool cpuid_limit_winnt = SIM->get_param_bool(BXPN_CPUID_LIMIT_WINNT)->get(); - if (cpuid_limit_winnt) { - leaf->eax = 0x1; - } - else { -#if BX_SUPPORT_MONITOR_MWAIT - leaf->eax = 0x5; -#else - leaf->eax = 0x1; -#endif - } + if (cpuid_limit_winnt) + max_leaf = 0x1; - // CPUID vendor string (e.g. GenuineIntel, AuthenticAMD, CentaurHauls, ...) - memcpy(&(leaf->ebx), vendor_string, 4); - memcpy(&(leaf->edx), vendor_string + 4, 4); - memcpy(&(leaf->ecx), vendor_string + 8, 4); -#ifdef BX_BIG_ENDIAN - leaf->ebx = bx_bswap32(leaf->ebx); - leaf->ecx = bx_bswap32(leaf->ecx); - leaf->edx = bx_bswap32(leaf->edx); -#endif + get_leaf_0(max_leaf, vendor_string, leaf); } // leaf 0x00000001 // @@ -352,21 +337,7 @@ void phenom_8650_toliman_t::get_std_cpuid_leaf_5(cpuid_function_t *leaf) const // leaf 0x80000000 // void phenom_8650_toliman_t::get_ext_cpuid_leaf_0(cpuid_function_t *leaf) const { - static const char* vendor_string = "AuthenticAMD"; - - // EAX: highest extended function understood by CPUID - // EBX: reserved - // EDX: reserved - // ECX: reserved - leaf->eax = 0x8000001A; - memcpy(&(leaf->ebx), vendor_string, 4); - memcpy(&(leaf->edx), vendor_string + 4, 4); - memcpy(&(leaf->ecx), vendor_string + 8, 4); -#ifdef BX_BIG_ENDIAN - leaf->ebx = bx_bswap32(leaf->ebx); - leaf->ecx = bx_bswap32(leaf->ecx); - leaf->edx = bx_bswap32(leaf->edx); -#endif + get_leaf_0(0x8000001A, "AuthenticAMD", leaf); } // leaf 0x80000001 // diff --git a/bochs/cpu/cpudb/trinity_apu.cc b/bochs/cpu/cpudb/trinity_apu.cc index d9f23fe17..9c5e6ee21 100644 --- a/bochs/cpu/cpudb/trinity_apu.cc +++ b/bochs/cpu/cpudb/trinity_apu.cc @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2014 Stanislav Shwartsman +// Copyright (c) 2014-2015 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or @@ -209,23 +209,12 @@ void trinity_apu_t::get_std_cpuid_leaf_0(cpuid_function_t *leaf) const // EBX: vendor ID string // EDX: vendor ID string // ECX: vendor ID string + unsigned max_leaf = 0xD; static bx_bool cpuid_limit_winnt = SIM->get_param_bool(BXPN_CPUID_LIMIT_WINNT)->get(); - if (cpuid_limit_winnt) { - leaf->eax = 0x1; - } - else { - leaf->eax = 0xd; - } + if (cpuid_limit_winnt) + max_leaf = 0x1; - // CPUID vendor string (e.g. GenuineIntel, AuthenticAMD, CentaurHauls, ...) - memcpy(&(leaf->ebx), vendor_string, 4); - memcpy(&(leaf->edx), vendor_string + 4, 4); - memcpy(&(leaf->ecx), vendor_string + 8, 4); -#ifdef BX_BIG_ENDIAN - leaf->ebx = bx_bswap32(leaf->ebx); - leaf->ecx = bx_bswap32(leaf->ecx); - leaf->edx = bx_bswap32(leaf->edx); -#endif + get_leaf_0(max_leaf, vendor_string, leaf); } // leaf 0x00000001 // @@ -486,21 +475,7 @@ void trinity_apu_t::get_std_cpuid_xsave_leaf(Bit32u subfunction, cpuid_function_ // leaf 0x80000000 // void trinity_apu_t::get_ext_cpuid_leaf_0(cpuid_function_t *leaf) const { - static const char* vendor_string = "AuthenticAMD"; - - // EAX: highest extended function understood by CPUID - // EBX: reserved - // EDX: reserved - // ECX: reserved - leaf->eax = 0x8000001E; - memcpy(&(leaf->ebx), vendor_string, 4); - memcpy(&(leaf->edx), vendor_string + 4, 4); - memcpy(&(leaf->ecx), vendor_string + 8, 4); -#ifdef BX_BIG_ENDIAN - leaf->ebx = bx_bswap32(leaf->ebx); - leaf->ecx = bx_bswap32(leaf->ecx); - leaf->edx = bx_bswap32(leaf->edx); -#endif + get_leaf_0(0x8000001E, "AuthenticAMD", leaf); } // leaf 0x80000001 // diff --git a/bochs/cpu/cpudb/turion64_tyler.cc b/bochs/cpu/cpudb/turion64_tyler.cc index e6c04448f..f64e22502 100644 --- a/bochs/cpu/cpudb/turion64_tyler.cc +++ b/bochs/cpu/cpudb/turion64_tyler.cc @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2011-2014 Stanislav Shwartsman +// Copyright (c) 2011-2015 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or @@ -128,23 +128,7 @@ void turion64_tyler_t::get_cpuid_leaf(Bit32u function, Bit32u subfunction, cpuid // leaf 0x00000000 // void turion64_tyler_t::get_std_cpuid_leaf_0(cpuid_function_t *leaf) const { - static const char* vendor_string = "AuthenticAMD"; - - // EAX: highest std function understood by CPUID - // EBX: vendor ID string - // EDX: vendor ID string - // ECX: vendor ID string - leaf->eax = 0x1; - - // CPUID vendor string (e.g. GenuineIntel, AuthenticAMD, CentaurHauls, ...) - memcpy(&(leaf->ebx), vendor_string, 4); - memcpy(&(leaf->edx), vendor_string + 4, 4); - memcpy(&(leaf->ecx), vendor_string + 8, 4); -#ifdef BX_BIG_ENDIAN - leaf->ebx = bx_bswap32(leaf->ebx); - leaf->ecx = bx_bswap32(leaf->ecx); - leaf->edx = bx_bswap32(leaf->edx); -#endif + get_leaf_0(0x1, "AuthenticAMD", leaf); } // leaf 0x00000001 // @@ -273,21 +257,7 @@ void turion64_tyler_t::get_std_cpuid_leaf_1(cpuid_function_t *leaf) const // leaf 0x80000000 // void turion64_tyler_t::get_ext_cpuid_leaf_0(cpuid_function_t *leaf) const { - static const char* vendor_string = "AuthenticAMD"; - - // EAX: highest extended function understood by CPUID - // EBX: reserved - // EDX: reserved - // ECX: reserved - leaf->eax = 0x80000018; - memcpy(&(leaf->ebx), vendor_string, 4); - memcpy(&(leaf->edx), vendor_string + 4, 4); - memcpy(&(leaf->ecx), vendor_string + 8, 4); -#ifdef BX_BIG_ENDIAN - leaf->ebx = bx_bswap32(leaf->ebx); - leaf->ecx = bx_bswap32(leaf->ecx); - leaf->edx = bx_bswap32(leaf->edx); -#endif + get_leaf_0(0x80000018, "AuthenticAMD", leaf); } // leaf 0x80000001 // diff --git a/bochs/cpu/cpudb/zambezi.cc b/bochs/cpu/cpudb/zambezi.cc index 891b85f2a..f31742d45 100644 --- a/bochs/cpu/cpudb/zambezi.cc +++ b/bochs/cpu/cpudb/zambezi.cc @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2012-2014 Stanislav Shwartsman +// Copyright (c) 2012-2015 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or @@ -202,23 +202,12 @@ void zambezi_t::get_std_cpuid_leaf_0(cpuid_function_t *leaf) const // EBX: vendor ID string // EDX: vendor ID string // ECX: vendor ID string + unsigned max_leaf = 0xD; static bx_bool cpuid_limit_winnt = SIM->get_param_bool(BXPN_CPUID_LIMIT_WINNT)->get(); - if (cpuid_limit_winnt) { - leaf->eax = 0x1; - } - else { - leaf->eax = 0xd; - } + if (cpuid_limit_winnt) + max_leaf = 0x1; - // CPUID vendor string (e.g. GenuineIntel, AuthenticAMD, CentaurHauls, ...) - memcpy(&(leaf->ebx), vendor_string, 4); - memcpy(&(leaf->edx), vendor_string + 4, 4); - memcpy(&(leaf->ecx), vendor_string + 8, 4); -#ifdef BX_BIG_ENDIAN - leaf->ebx = bx_bswap32(leaf->ebx); - leaf->ecx = bx_bswap32(leaf->ecx); - leaf->edx = bx_bswap32(leaf->edx); -#endif + get_leaf_0(max_leaf, vendor_string, leaf); } // leaf 0x00000001 // @@ -439,21 +428,7 @@ void zambezi_t::get_std_cpuid_xsave_leaf(Bit32u subfunction, cpuid_function_t *l // leaf 0x80000000 // void zambezi_t::get_ext_cpuid_leaf_0(cpuid_function_t *leaf) const { - static const char* vendor_string = "AuthenticAMD"; - - // EAX: highest extended function understood by CPUID - // EBX: reserved - // EDX: reserved - // ECX: reserved - leaf->eax = 0x8000001E; - memcpy(&(leaf->ebx), vendor_string, 4); - memcpy(&(leaf->edx), vendor_string + 4, 4); - memcpy(&(leaf->ecx), vendor_string + 8, 4); -#ifdef BX_BIG_ENDIAN - leaf->ebx = bx_bswap32(leaf->ebx); - leaf->ecx = bx_bswap32(leaf->ecx); - leaf->edx = bx_bswap32(leaf->edx); -#endif + get_leaf_0(0x8000001E, "AuthenticAMD", leaf); } // leaf 0x80000001 // diff --git a/bochs/cpu/cpuid.cc b/bochs/cpu/cpuid.cc index 18191acf9..48028e54f 100644 --- a/bochs/cpu/cpuid.cc +++ b/bochs/cpu/cpuid.cc @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2014 Stanislav Shwartsman +// Copyright (c) 2014-2015 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or @@ -122,6 +122,32 @@ void bx_cpuid_t::get_std_cpuid_extended_topology_leaf(Bit32u subfunction, cpuid_ #endif +void bx_cpuid_t::get_leaf_0(unsigned max_leaf, const char *vendor_string, cpuid_function_t *leaf) const +{ + // EAX: highest function understood by CPUID + // EBX: vendor ID string + // EDX: vendor ID string + // ECX: vendor ID string + leaf->eax = max_leaf; + + if (vendor_string == NULL) { + leaf->ebx = 0; + leaf->ecx = 0; // Reserved + leaf->edx = 0; + return; + } + + // CPUID vendor string (e.g. GenuineIntel, AuthenticAMD, CentaurHauls, ...) + memcpy(&(leaf->ebx), vendor_string, 4); + memcpy(&(leaf->edx), vendor_string + 4, 4); + memcpy(&(leaf->ecx), vendor_string + 8, 4); +#ifdef BX_BIG_ENDIAN + leaf->ebx = bx_bswap32(leaf->ebx); + leaf->ecx = bx_bswap32(leaf->ecx); + leaf->edx = bx_bswap32(leaf->edx); +#endif +} + void bx_cpuid_t::get_ext_cpuid_brand_string_leaf(const char *brand_string, Bit32u function, cpuid_function_t *leaf) const { switch(function) { @@ -155,21 +181,38 @@ void bx_cpuid_t::get_ext_cpuid_brand_string_leaf(const char *brand_string, Bit32 #endif } -void bx_cpuid_t::dump_cpuid(unsigned max_std_leaf, unsigned max_ext_leaf) const +void bx_cpuid_t::get_cpuid_hidden_level(cpuid_function_t *leaf, const char *magic_string) const +{ + memcpy(&(leaf->eax), magic_string , 4); + memcpy(&(leaf->ebx), magic_string + 4, 4); + memcpy(&(leaf->ecx), magic_string + 8, 4); + memcpy(&(leaf->edx), magic_string + 12, 4); + +#ifdef BX_BIG_ENDIAN + leaf->eax = bx_bswap32(leaf->eax); + leaf->ebx = bx_bswap32(leaf->ebx); + leaf->ecx = bx_bswap32(leaf->ecx); + leaf->edx = bx_bswap32(leaf->edx); +#endif +} + +void bx_cpuid_t::dump_cpuid_leaf(unsigned function, unsigned subfunction) const { struct cpuid_function_t leaf; - unsigned n; + get_cpuid_leaf(function, subfunction, &leaf); + BX_INFO(("CPUID[0x%08x]: %08x %08x %08x %08x", function, leaf.eax, leaf.ebx, leaf.ecx, leaf.edx)); +} - for (n=0; n<=max_std_leaf; n++) { - get_cpuid_leaf(n, 0x00000000, &leaf); - BX_INFO(("CPUID[0x%08x]: %08x %08x %08x %08x", n, leaf.eax, leaf.ebx, leaf.ecx, leaf.edx)); +void bx_cpuid_t::dump_cpuid(unsigned max_std_leaf, unsigned max_ext_leaf) const +{ + for (unsigned std_leaf=0; std_leaf<=max_std_leaf; std_leaf++) { + dump_cpuid_leaf(std_leaf); } if (max_ext_leaf == 0) return; - for (n=0x80000000; n<=(0x8000000 + max_ext_leaf); n++) { - get_cpuid_leaf(n, 0x00000000, &leaf); - BX_INFO(("CPUID[0x%08x]: %08x %08x %08x %08x", n, leaf.eax, leaf.ebx, leaf.ecx, leaf.edx)); + for (unsigned ext_leaf=0x80000000; ext_leaf<=(0x8000000 + max_ext_leaf); ext_leaf++) { + dump_cpuid_leaf(ext_leaf); } } diff --git a/bochs/cpu/cpuid.h b/bochs/cpu/cpuid.h index 7cf6655a6..2396fb506 100644 --- a/bochs/cpu/cpuid.h +++ b/bochs/cpu/cpuid.h @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2010-2014 Stanislav Shwartsman +// Copyright (c) 2010-2015 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or @@ -126,7 +126,7 @@ public: virtual ~bx_cpuid_t() {} // return CPU name - virtual const char *get_name(void) const { return NULL; } + virtual const char *get_name(void) const = 0; BX_CPP_INLINE void get_cpu_extensions(Bit32u *extensions) const { for (unsigned n=0; n < BX_ISA_EXTENSIONS_ARRAY_SIZE; n++) @@ -188,12 +188,14 @@ protected: } } + void get_leaf_0(unsigned max_leaf, const char *vendor_string, cpuid_function_t *leaf) const; + void get_ext_cpuid_brand_string_leaf(const char *brand_string, Bit32u function, cpuid_function_t *leaf) const; + void get_cpuid_hidden_level(cpuid_function_t *leaf, const char *magic_string) const; + #if BX_SUPPORT_APIC void get_std_cpuid_extended_topology_leaf(Bit32u subfunction, cpuid_function_t *leaf) const; #endif - void get_ext_cpuid_brand_string_leaf(const char *brand_string, Bit32u function, cpuid_function_t *leaf) const; - BX_CPP_INLINE void get_reserved_leaf(cpuid_function_t *leaf) const { leaf->eax = 0; @@ -202,6 +204,7 @@ protected: leaf->edx = 0; } + void dump_cpuid_leaf(unsigned function, unsigned subfunction = 0) const; void dump_cpuid(unsigned max_std_leaf, unsigned max_ext_leaf) const; }; diff --git a/bochs/cpu/generic_cpuid.cc b/bochs/cpu/generic_cpuid.cc index c73cfcefd..a1c4a7299 100644 --- a/bochs/cpu/generic_cpuid.cc +++ b/bochs/cpu/generic_cpuid.cc @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2011-2014 Stanislav Shwartsman +// Copyright (c) 2011-2015 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or @@ -78,7 +78,7 @@ bx_generic_cpuid_t::bx_generic_cpuid_t(BX_CPU_C *cpu): bx_cpuid_t(cpu) void bx_generic_cpuid_t::get_cpuid_leaf(Bit32u function, Bit32u subfunction, cpuid_function_t *leaf) const { - static char *brand_string = (char *)SIM->get_param_string(BXPN_BRAND_STRING)->getptr(); + static const char *brand_string = (const char *)SIM->get_param_string(BXPN_BRAND_STRING)->getptr(); static bx_bool cpuid_limit_winnt = SIM->get_param_bool(BXPN_CPUID_LIMIT_WINNT)->get(); if (cpuid_limit_winnt) @@ -171,23 +171,18 @@ void bx_generic_cpuid_t::get_cpuid_leaf(Bit32u function, Bit32u subfunction, cpu // leaf 0x00000000 // void bx_generic_cpuid_t::get_std_cpuid_leaf_0(cpuid_function_t *leaf) const { - static Bit8u *vendor_string = (Bit8u *)SIM->get_param_string(BXPN_VENDOR_STRING)->getptr(); + static const Bit8u *vendor_string = (const Bit8u *)SIM->get_param_string(BXPN_VENDOR_STRING)->getptr(); // EAX: highest std function understood by CPUID // EBX: vendor ID string // EDX: vendor ID string // ECX: vendor ID string - leaf->eax = max_std_leaf; + unsigned max_leaf = max_std_leaf; + static bx_bool cpuid_limit_winnt = SIM->get_param_bool(BXPN_CPUID_LIMIT_WINNT)->get(); + if (cpuid_limit_winnt) + max_leaf = 0x2; - // CPUID vendor string (e.g. GenuineIntel, AuthenticAMD, CentaurHauls, ...) - memcpy(&(leaf->ebx), vendor_string, 4); - memcpy(&(leaf->edx), vendor_string + 4, 4); - memcpy(&(leaf->ecx), vendor_string + 8, 4); -#ifdef BX_BIG_ENDIAN - leaf->ebx = bx_bswap32(leaf->ebx); - leaf->ecx = bx_bswap32(leaf->ecx); - leaf->edx = bx_bswap32(leaf->edx); -#endif + get_leaf_0(max_leaf, (const char *) vendor_string, leaf); } // leaf 0x00000001 // @@ -463,28 +458,13 @@ void bx_generic_cpuid_t::get_std_cpuid_xsave_leaf(Bit32u subfunction, cpuid_func // leaf 0x80000000 // void bx_generic_cpuid_t::get_ext_cpuid_leaf_0(cpuid_function_t *leaf) const { + static const Bit8u *vendor_string = (const Bit8u *)SIM->get_param_string(BXPN_VENDOR_STRING)->getptr(); + // EAX: highest extended function understood by CPUID // EBX: vendor ID string // EDX: vendor ID string // ECX: vendor ID string - leaf->eax = max_ext_leaf; -#if BX_CPU_VENDOR_INTEL - leaf->ebx = 0; - leaf->edx = 0; // Reserved for Intel - leaf->ecx = 0; -#else - static Bit8u *vendor_string = (Bit8u *)SIM->get_param_string(BXPN_VENDOR_STRING)->getptr(); - - memcpy(&(leaf->ebx), vendor_string, 4); - memcpy(&(leaf->edx), vendor_string + 4, 4); - memcpy(&(leaf->ecx), vendor_string + 8, 4); -#endif - -#ifdef BX_BIG_ENDIAN - leaf->ebx = bx_bswap32(leaf->ebx); - leaf->ecx = bx_bswap32(leaf->ecx); - leaf->edx = bx_bswap32(leaf->edx); -#endif + get_leaf_0(max_ext_leaf, BX_CPU_VENDOR_INTEL ? NULL : (const char *) vendor_string, leaf); } // leaf 0x80000001 // @@ -1535,13 +1515,7 @@ Bit32u bx_generic_cpuid_t::get_ext3_cpuid_features(void) const void bx_generic_cpuid_t::dump_cpuid(void) const { - bx_cpuid_t::dump_cpuid(max_std_leaf, -#if BX_CPU_LEVEL <= 5 - 0 -#else - max_ext_leaf-0x80000000 -#endif - ); + bx_cpuid_t::dump_cpuid(max_std_leaf, (max_ext_leaf > 0x80000000) ? (max_ext_leaf-0x80000000) : 0); } bx_cpuid_t *create_bx_generic_cpuid(BX_CPU_C *cpu) { return new bx_generic_cpuid_t(cpu); } diff --git a/bochs/cpu/generic_cpuid.h b/bochs/cpu/generic_cpuid.h index cca5a07dd..3c0a415a4 100644 --- a/bochs/cpu/generic_cpuid.h +++ b/bochs/cpu/generic_cpuid.h @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2011-2014 Stanislav Shwartsman +// Copyright (c) 2011-2015 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or diff --git a/bochs/cpudb.h b/bochs/cpudb.h index a5e908128..17a17a929 100644 --- a/bochs/cpudb.h +++ b/bochs/cpudb.h @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2011-2014 Stanislav Shwartsman +// Copyright (c) 2011-2015 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or @@ -23,6 +23,7 @@ bx_define_cpudb(bx_generic) #if BX_CPU_LEVEL >= 5 +bx_define_cpudb(pentium) bx_define_cpudb(pentium_mmx) bx_define_cpudb(amd_k6_2_chomper) #if BX_CPU_LEVEL >= 6