Added ability to configure CPUID stepping through .bochsrc.

Next is CPUID model/extended model.
This commit is contained in:
Stanislav Shwartsman 2010-07-16 21:03:52 +00:00
parent 59ad9d8de8
commit cd6314b65c
6 changed files with 38 additions and 12 deletions

View File

@ -191,6 +191,9 @@ cpu: count=1, ips=50000000, reset_on_triple_fault=1, ignore_bad_msrs=1, msrs="ms
# Set the CPUID vendor string returned by CPUID(0x80000002 .. 0x80000004).
# This should be at most a forty-eight-character ASCII string.
#
# STEPPING:
# Set stepping information returned by CPUID. Default stepping value is 3.
#
# CPUID_LIMIT_WINNT:
# Determine whether to limit maximum CPUID function to 3. This mode is
# required to workaround WinNT installation and boot issues.

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: config.cc,v 1.207 2010-07-03 11:13:40 sshwarts Exp $
// $Id: config.cc,v 1.208 2010-07-16 21:03:52 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002-2009 The Bochs Project
@ -366,7 +366,7 @@ void bx_init_options()
cpu_param->set_options(menu->SHOW_PARENT);
// cpuid subtree
bx_list_c *cpuid_param = new bx_list_c(root_param, "cpuid", "CPUID Options", 13);
bx_list_c *cpuid_param = new bx_list_c(root_param, "cpuid", "CPUID Options", 15);
new bx_param_bool_c(cpuid_param,
"cpuid_limit_winnt", "Limit max CPUID function to 3",
@ -394,6 +394,12 @@ void bx_init_options()
#endif
BX_CPUID_BRAND_LEN+1);
new bx_param_num_c(cpuid_param,
"stepping", "Stepping ID",
"Processor 4-bits stepping ID",
0, 15,
3);
#if BX_CPU_LEVEL >= 5
new bx_param_bool_c(cpuid_param,
"mmx", "Support for MMX instruction set",
@ -2666,6 +2672,8 @@ static int parse_line_formatted(const char *context, int num_params, char *param
PARSE_ERR(("%s: cpuid directive malformed.", context));
}
SIM->get_param_string(BXPN_BRAND_STRING)->set(&params[i][13]);
} else if (!strncmp(params[i], "stepping=", 9)) {
SIM->get_param_num(BXPN_CPUID_STEPPING)->set(atol(&params[i][9]));
} 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));
@ -3893,7 +3901,17 @@ int bx_write_configuration(const char *rc, int overwrite)
fprintf(fp, ", mwait_is_nop=%d", SIM->get_param_bool(BXPN_CPUID_MWAIT_IS_NOP)->get());
#endif
#endif
fprintf(fp, ", stepping=%d", 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);
const char *brand_string = SIM->get_param_string(BXPN_BRAND_STRING)->getptr();
if (brand_string)
fprintf(fp, ", brand_string=\"%s\"", brand_string);
fprintf(fp, "\n");
fprintf(fp, "print_timestamps: enabled=%d\n", bx_dbg.print_timestamps);
bx_write_debugger_options(fp);
fprintf(fp, "port_e9_hack: enabled=%d\n", SIM->get_param_bool(BXPN_PORT_E9_HACK)->get());

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: cpuid.cc,v 1.119 2010-07-15 20:18:03 sshwarts Exp $
// $Id: cpuid.cc,v 1.120 2010-07-16 21:03:52 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2007-2010 Stanislav Shwartsman
@ -48,7 +48,9 @@
Bit32u BX_CPU_C::get_cpu_version_information(void)
{
Bit32u family = 0, model = 0, stepping = 0;
Bit32u stepping = SIM->get_param_num(BXPN_CPUID_STEPPING)->get();
Bit32u family = 0, model = 0;
Bit32u extended_model = 0;
Bit32u extended_family = 0;
@ -63,10 +65,8 @@ Bit32u BX_CPU_C::get_cpu_version_information(void)
#if BX_SUPPORT_FPU
model = 1; // 486dx
stepping = 3;
#else
model = 2; // 486sx
stepping = 3;
#endif
/* **************** */
@ -81,8 +81,6 @@ Bit32u BX_CPU_C::get_cpu_version_information(void)
else
model = 1; // Pentium 60/66
stepping = 3;
/* ****** */
/* i686 */
/* ****** */
@ -103,7 +101,6 @@ Bit32u BX_CPU_C::get_cpu_version_information(void)
*/
model = 0;
family = 0xf;
stepping = 0;
#if BX_SUPPORT_X86_64
model = 2; // Hammer returns what?
@ -113,7 +110,6 @@ Bit32u BX_CPU_C::get_cpu_version_information(void)
else { // Pentium Pro/Pentium II/Pentium III processor
family = 6;
model = 8;
stepping = 3;
}
#else

View File

@ -1,7 +1,7 @@
<!--
================================================================
doc/docbook/user/user.dbk
$Id: user.dbk,v 1.280 2010-07-03 05:34:27 vruppert Exp $
$Id: user.dbk,v 1.281 2010-07-16 21:03:52 sshwarts Exp $
This is the top level file for the Bochs Users Manual.
================================================================
@ -3108,6 +3108,10 @@ This option exists only if Bochs compiled with x86-64 support.
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>stepping</command></para>
<para>
Set stepping information returned by CPUID. Default stepping value is 3.
</para>
<para><command>vendor_string</command></para>
<para>
Set the CPUID vendor string returned by CPUID(0x0). This should be a

View File

@ -239,6 +239,10 @@ mwait_is_nop:
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.
stepping:
Set stepping information returned by CPUID. Default stepping value is 3.
vendor_string:
Set the CPUID vendor string returned by CPUID(0x0). This should be a

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: param_names.h,v 1.9 2010-07-03 05:34:27 vruppert Exp $
// $Id: param_names.h,v 1.10 2010-07-16 21:03:52 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2009 The Bochs Project
@ -42,6 +42,7 @@
#define BXPN_CONFIGURABLE_MSRS_PATH "cpu.msrs"
#define BXPN_VENDOR_STRING "cpuid.vendor_string"
#define BXPN_BRAND_STRING "cpuid.brand_string"
#define BXPN_CPUID_STEPPING "cpuid.stepping"
#define BXPN_CPUID_LIMIT_WINNT "cpuid.cpuid_limit_winnt"
#define BXPN_CPUID_MMX "cpuid.mmx"
#define BXPN_CPUID_SSE "cpuid.sse"