From: <ssh...@us...> - 2011-02-25 15:05:55
|
Revision: 10211 http://bochs.svn.sourceforge.net/bochs/?rev=10211&view=rev Author: sshwarts Date: 2011-02-25 15:05:48 +0000 (Fri, 25 Feb 2011) Log Message: ----------- added ability to configure CPU family and model through .bochsrc Modified Paths: -------------- trunk/bochs/.bochsrc trunk/bochs/PARAM_TREE.txt trunk/bochs/config.cc trunk/bochs/cpu/cpu.h trunk/bochs/cpu/cpuid.cc trunk/bochs/doc/docbook/user/user.dbk trunk/bochs/doc/man/bochsrc.5 trunk/bochs/param_names.h Property Changed: ---------------- trunk/bochs/PARAM_TREE.txt Modified: trunk/bochs/.bochsrc =================================================================== --- trunk/bochs/.bochsrc 2011-02-24 22:12:02 UTC (rev 10210) +++ trunk/bochs/.bochsrc 2011-02-25 15:05:48 UTC (rev 10211) @@ -199,6 +199,13 @@ # Set the CPUID vendor string returned by CPUID(0x80000002 .. 0x80000004). # This should be at most a forty-eight-character ASCII string. # +# FAMILY: +# Set model information returned by CPUID. Default family value determined +# by configure option --enable-cpu-level. +# +# MODEL: +# Set model information returned by CPUID. Default model value is 3. +# # STEPPING: # Set stepping information returned by CPUID. Default stepping value is 3. # @@ -207,7 +214,7 @@ # required to workaround WinNT installation and boot issues. #======================================================================= cpuid: mmx=1, sep=1, sse=sse4_2, xapic=1, aes=1, movbe=1, xsave=1 -cpuid: stepping=5 +cpuid: family=6, model=0x1a, stepping=5 cpuid: cpuid_limit_winnt=0 #======================================================================= Modified: trunk/bochs/PARAM_TREE.txt =================================================================== --- trunk/bochs/PARAM_TREE.txt 2011-02-24 22:12:02 UTC (rev 10210) +++ trunk/bochs/PARAM_TREE.txt 2011-02-25 15:05:48 UTC (rev 10211) @@ -1,4 +1,4 @@ -$Id: PARAM_TREE.txt,v 1.34 2011-01-16 12:46:47 vruppert Exp $ +$Id$ Starting from Bochs 2.3 the parameters are organized in a tree structure instead of a huge flat list. The parameter tree was required for implementing @@ -27,6 +27,8 @@ cpuid cpuid_limit_winnt + family + model stepping vendor_string brand_string Property changes on: trunk/bochs/PARAM_TREE.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Rev Modified: trunk/bochs/config.cc =================================================================== --- trunk/bochs/config.cc 2011-02-24 22:12:02 UTC (rev 10210) +++ trunk/bochs/config.cc 2011-02-25 15:05:48 UTC (rev 10211) @@ -321,6 +321,7 @@ cpu_param->set_options(menu->SHOW_PARENT); // cpuid subtree +#if BX_CPU_LEVEL >= 4 bx_list_c *cpuid_param = new bx_list_c(root_param, "cpuid", "CPUID Options", 16); new bx_param_bool_c(cpuid_param, @@ -355,6 +356,18 @@ 0, 15, 3); + new bx_param_num_c(cpuid_param, + "model", "Model ID", + "Processor model ID, extended model ID", + 0, 255, + 3); + + new bx_param_num_c(cpuid_param, + "family", "Family ID", + "Processor family ID, extended family ID", + BX_CPU_LEVEL, 4095, + BX_CPU_LEVEL); + #if BX_CPU_LEVEL >= 5 new bx_param_bool_c(cpuid_param, "mmx", "Support for MMX instruction set", @@ -418,6 +431,8 @@ #endif #endif +#endif // CPU_LEVEL >= 4 + cpuid_param->set_options(menu->SHOW_PARENT); // memory subtree @@ -2570,6 +2585,7 @@ PARSE_ERR(("%s: cpu directive malformed.", context)); } } +#if BX_CPU_LEVEL >= 4 } else if (!strcmp(params[0], "cpuid")) { if (num_params < 2) { PARSE_ERR(("%s: cpuid directive malformed.", context)); @@ -2587,6 +2603,10 @@ SIM->get_param_string(BXPN_BRAND_STRING)->set(¶ms[i][13]); } else if (!strncmp(params[i], "stepping=", 9)) { SIM->get_param_num(BXPN_CPUID_STEPPING)->set(atol(¶ms[i][9])); + } else if (!strncmp(params[i], "model=", 6)) { + SIM->get_param_num(BXPN_CPUID_MODEL)->set(strtoul(¶ms[i][6], NULL, 0)); + } else if (!strncmp(params[i], "family=", 7)) { + SIM->get_param_num(BXPN_CPUID_FAMILY)->set(strtoul(¶ms[i][7], NULL, 0)); } else if (!strncmp(params[i], "cpuid_limit_winnt=", 18)) { if (parse_param_bool(params[i], 18, BXPN_CPUID_LIMIT_WINNT) < 0) { PARSE_ERR(("%s: cpuid directive malformed.", context)); @@ -2650,6 +2670,7 @@ PARSE_ERR(("%s: cpuid directive malformed.", context)); } } +#endif } else if (!strcmp(params[0], "megs")) { if (num_params != 2) { PARSE_ERR(("%s: megs directive: wrong # args.", context)); @@ -3809,6 +3830,8 @@ fprintf(fp, ", msrs=\"%s\"", strptr); #endif fprintf(fp, "\n"); + +#if BX_CPU_LEVEL >= 4 fprintf(fp, "cpuid: cpuid_limit_winnt=%d", SIM->get_param_bool(BXPN_CPUID_LIMIT_WINNT)->get()); #if BX_CPU_LEVEL >= 5 fprintf(fp, ", mmx=%d", SIM->get_param_bool(BXPN_CPUID_MMX)->get()); @@ -3835,7 +3858,10 @@ #endif fprintf(fp, "\n"); - fprintf(fp, "cpuid: stepping=%d", SIM->get_param_num(BXPN_CPUID_STEPPING)->get()); + fprintf(fp, "cpuid: family=%x, model=%02x, stepping=%d", + SIM->get_param_num(BXPN_CPUID_FAMILY)->get(), + SIM->get_param_num(BXPN_CPUID_MODEL)->get(), + SIM->get_param_num(BXPN_CPUID_STEPPING)->get()); const char *vendor_string = SIM->get_param_string(BXPN_VENDOR_STRING)->getptr(); if (vendor_string) fprintf(fp, ", vendor_string=\"%s\"", vendor_string); @@ -3843,6 +3869,7 @@ if (brand_string) fprintf(fp, ", brand_string=\"%s\"", brand_string); fprintf(fp, "\n"); +#endif fprintf(fp, "print_timestamps: enabled=%d\n", bx_dbg.print_timestamps); bx_write_debugger_options(fp); Modified: trunk/bochs/cpu/cpu.h =================================================================== --- trunk/bochs/cpu/cpu.h 2011-02-24 22:12:02 UTC (rev 10210) +++ trunk/bochs/cpu/cpu.h 2011-02-25 15:05:48 UTC (rev 10211) @@ -3274,18 +3274,20 @@ BX_SMF Bit32u get_cpu_version_information(void); BX_SMF Bit32u get_extended_cpuid_features(void); - BX_SMF Bit32u get_ext2_cpuid_features(void); BX_SMF Bit32u get_std_cpuid_features(void); - BX_SMF void set_cpuid_defaults(void); BX_SMF void init_isa_features_bitmask(void); BX_SMF void init_FetchDecodeTables(void); +#if BX_CPU_LEVEL >= 4 + BX_SMF void set_cpuid_defaults(void); +#endif #if BX_SUPPORT_X2APIC BX_SMF void bx_cpuid_extended_topology_leaf(Bit32u subfunction); #endif #if BX_CPU_LEVEL >= 6 BX_SMF void bx_cpuid_xsave_leaf(Bit32u subfunction); BX_SMF void bx_cpuid_extended_cpuid_leaf(Bit32u subfunction); + BX_SMF Bit32u get_ext2_cpuid_features(void); #endif BX_SMF BX_CPP_INLINE int bx_cpuid_support_debug_extensions(void); Modified: trunk/bochs/cpu/cpuid.cc =================================================================== --- trunk/bochs/cpu/cpuid.cc 2011-02-24 22:12:02 UTC (rev 10210) +++ trunk/bochs/cpu/cpuid.cc 2011-02-25 15:05:48 UTC (rev 10211) @@ -44,85 +44,24 @@ * [7:4] Model: starts at 1 * [11:8] Family: 4=486, 5=Pentium, 6=PPro, ... * [13:12] Type: 0=OEM, 1=overdrive, 2=dual cpu, 3=reserved - * [31:14] Reserved + * [19:16] Extended Model + * [27:29] Extended Family */ Bit32u BX_CPU_C::get_cpu_version_information(void) { +#if BX_CPU_LEVEL >= 4 Bit32u stepping = SIM->get_param_num(BXPN_CPUID_STEPPING)->get(); + Bit32u model = SIM->get_param_num(BXPN_CPUID_MODEL)->get(); + Bit32u family = SIM->get_param_num(BXPN_CPUID_FAMILY)->get(); - Bit32u family = 0, model = 0; - Bit32u extended_model = 0; - Bit32u extended_family = 0; - -#if BX_CPU_LEVEL > 3 - - /* ****** */ - /* i486 */ - /* ****** */ - -#if BX_CPU_LEVEL == 4 - family = 4; - -#if BX_SUPPORT_FPU - model = 1; // 486dx + return ((family & 0xfff0) << 16) | + ((model & 0xf0) << 12) | + ((family & 0x0f) << 8) | + ((model & 0x0f) << 4) | stepping; #else - model = 2; // 486sx + return 0; /* CPUID not supported */ #endif - - /* **************** */ - /* i586 (Pentium) */ - /* **************** */ - -#elif BX_CPU_LEVEL == 5 - family = 5; - - if (BX_CPU_SUPPORT_ISA_EXTENSION(BX_CPU_MMX)) - model = 4; // Pentium MMX - else - model = 1; // Pentium 60/66 - - /* ****** */ - /* i686 */ - /* ****** */ - -#elif BX_CPU_LEVEL == 6 - - unsigned sse_enabled = SIM->get_param_enum(BXPN_CPUID_SSE)->get(); - - if (sse_enabled >= 2) { - -/* - The model, family, and processor type for the first - processor in the Intel Pentium 4 family is as follows: - * Model-0000B - * Family-1111B - * Processor Type-00B (OEM) - * Stepping-0B -*/ - model = 0; - family = 0xf; - -#if BX_SUPPORT_X86_64 - model = 2; // Hammer returns what? -#endif - - } - else { // Pentium Pro/Pentium II/Pentium III processor - family = 6; - model = 8; - } - -#else - BX_PANIC(("CPUID family ID not implemented for CPU LEVEL > 6")); -#endif - -#endif // BX_CPU_LEVEL > 3 - - return (extended_family << 20) | - (extended_model << 16) | - (family << 8) | - (model<<4) | stepping; } /* Get CPU extended feature flags. */ @@ -214,6 +153,7 @@ return features; } +#if BX_CPU_LEVEL >= 6 Bit32u BX_CPU_C::get_ext2_cpuid_features(void) { Bit32u features = 0; @@ -225,6 +165,7 @@ return features; } +#endif /* Get CPU feature flags. Returned by CPUID functions 1 and 80000001. */ Bit32u BX_CPU_C::get_std_cpuid_features(void) @@ -389,6 +330,7 @@ #endif } +#if BX_CPU_LEVEL >= 4 void BX_CPU_C::set_cpuid_defaults(void) { Bit8u *vendor_string = (Bit8u *)SIM->get_param_string(BXPN_VENDOR_STRING)->getptr(); @@ -465,7 +407,8 @@ // [7:4] Model: starts at 1 // [11:8] Family: 4=486, 5=Pentium, 6=PPro, ... // [13:12] Type: 0=OEM, 1=overdrive, 2=dual cpu, 3=reserved - // [31:14] Reserved + // [19:16] Extended Model + // [27:20] Extended Family cpuid->eax = get_cpu_version_information(); // EBX: @@ -954,6 +897,8 @@ } #endif +#endif + void BX_CPU_C::init_isa_features_bitmask(void) { Bit32u features_bitmask = 0; Modified: trunk/bochs/doc/docbook/user/user.dbk =================================================================== --- trunk/bochs/doc/docbook/user/user.dbk 2011-02-24 22:12:02 UTC (rev 10210) +++ trunk/bochs/doc/docbook/user/user.dbk 2011-02-25 15:05:48 UTC (rev 10211) @@ -3115,6 +3115,15 @@ When this option is enabled MWAIT will not put the CPU into a sleep state. This option exists only if Bochs compiled with --enable-monitor-mwait. </para> +<para><command>family</command></para> +<para> +Set family information returned by CPUID. Default family value determined +by configure option --enable-cpu-level. +</para> +<para><command>model</command></para> +<para> +Set model information returned by CPUID. Default model value is 3. +</para> <para><command>stepping</command></para> <para> Set stepping information returned by CPUID. Default stepping value is 3. Modified: trunk/bochs/doc/man/bochsrc.5 =================================================================== --- trunk/bochs/doc/man/bochsrc.5 2011-02-24 22:12:02 UTC (rev 10210) +++ trunk/bochs/doc/man/bochsrc.5 2011-02-25 15:05:48 UTC (rev 10211) @@ -244,6 +244,15 @@ When this option is enabled MWAIT will not put the CPU into a sleep state. This option exists only if Bochs compiled with --enable-monitor-mwait. +family: + +Set family information returned by CPUID. Default family value determined +by configure option --enable-cpu-level. + +model: + +Set model information returned by CPUID. Default model value is 3. + stepping: Set stepping information returned by CPUID. Default stepping value is 3. Modified: trunk/bochs/param_names.h =================================================================== --- trunk/bochs/param_names.h 2011-02-24 22:12:02 UTC (rev 10210) +++ trunk/bochs/param_names.h 2011-02-25 15:05:48 UTC (rev 10211) @@ -42,6 +42,8 @@ #define BXPN_CONFIGURABLE_MSRS_PATH "cpu.msrs" #define BXPN_VENDOR_STRING "cpuid.vendor_string" #define BXPN_BRAND_STRING "cpuid.brand_string" +#define BXPN_CPUID_FAMILY "cpuid.family" +#define BXPN_CPUID_MODEL "cpuid.model" #define BXPN_CPUID_STEPPING "cpuid.stepping" #define BXPN_CPUID_LIMIT_WINNT "cpuid.cpuid_limit_winnt" #define BXPN_CPUID_MMX "cpuid.mmx" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |