- added new parameter 'rtc_sync' for the 'clock' option. If this option is

enabled together with the realtime synchronization, the RTC runs at realtime speed.
This commit is contained in:
Volker Ruppert 2012-05-15 17:03:45 +00:00
parent 4e95f44873
commit 27fdc3cd45
5 changed files with 42 additions and 6 deletions

View File

@ -527,6 +527,10 @@ boot: disk
# preserve performance and host-time correlation.
# It is possible to enable both synchronization methods.
#
# RTC_SYNC:
# If this option is enabled together with the realtime synchronization,
# the RTC runs at realtime speed. This feature is disabled by default.
#
# TIME0:
# Specifies the start (boot) time of the virtual machine. Use a time
# value as returned by the time(2) system call. If no time0 value is

View File

@ -732,6 +732,15 @@ void bx_init_options()
"Initial time for Bochs CMOS clock, used if you really want two runs to be identical",
0, BX_MAX_BIT32U,
BX_CLOCK_TIME0_LOCAL);
bx_param_bool_c *rtc_sync = new bx_param_bool_c(clock_cmos,
"rtc_sync", "Sync RTC speed with realtime",
"If enabled, the RTC runs at realtime speed",
0);
deplist = new bx_list_c(NULL);
deplist->add(rtc_sync);
clock_sync->set_dependent_list(deplist, 0);
clock_sync->set_dependent_bitmap(BX_CLOCK_SYNC_REALTIME, 1);
clock_sync->set_dependent_bitmap(BX_CLOCK_SYNC_BOTH, 1);
bx_list_c *cmosimage = new bx_list_c(clock_cmos, "cmosimage", "CMOS Image Options");
bx_param_bool_c *use_cmosimage = new bx_param_bool_c(cmosimage,
@ -2883,6 +2892,9 @@ static int parse_line_formatted(const char *context, int num_params, char *param
if (!strncmp(params[i], "sync=", 5)) {
SIM->get_param_enum(BXPN_CLOCK_SYNC)->set_by_name(&params[i][5]);
}
else if (!strncmp(params[i], "rtc_sync=", 9)) {
SIM->get_param_bool(BXPN_CLOCK_RTC_SYNC)->set(atol(&params[i][9]));
}
else if (!strcmp(params[i], "time0=local")) {
SIM->get_param_num(BXPN_CLOCK_TIME0)->set(BX_CLOCK_TIME0_LOCAL);
}
@ -3311,7 +3323,7 @@ int bx_write_clock_cmos_options(FILE *fp)
fprintf(fp, ", time0=%u", SIM->get_param_num(BXPN_CLOCK_TIME0)->get());
}
fprintf(fp, "\n");
fprintf(fp, ", rtc_sync=%d\n", SIM->get_param_bool(BXPN_CLOCK_RTC_SYNC)->get());
if (strlen(SIM->get_param_string(BXPN_CMOSIMAGE_PATH)->getptr()) > 0) {
fprintf(fp, "cmosimage: file=%s, ", SIM->get_param_string(BXPN_CMOSIMAGE_PATH)->getptr());

View File

@ -26,6 +26,7 @@
#include "iodev.h"
#include "cmos.h"
#include "virt_timer.h"
#define LOG_THIS theCmosDevice->
@ -150,15 +151,27 @@ void bx_cmos_c::init(void)
DEV_register_iowrite_handler(this, write_handler, 0x0070, "CMOS RAM", 1);
DEV_register_iowrite_handler(this, write_handler, 0x0071, "CMOS RAM", 1);
DEV_register_irq(8, "CMOS RTC");
int clock_sync = SIM->get_param_enum(BXPN_CLOCK_SYNC)->get();
BX_CMOS_THIS s.rtc_sync = ((clock_sync == BX_CLOCK_SYNC_REALTIME) ||
(clock_sync == BX_CLOCK_SYNC_BOTH)) &&
SIM->get_param_bool(BXPN_CLOCK_RTC_SYNC)->get();
if (BX_CMOS_THIS s.periodic_timer_index == BX_NULL_TIMER_HANDLE) {
BX_CMOS_THIS s.periodic_timer_index =
DEV_register_timer(this, periodic_timer_handler,
1000000, 1,0, "cmos"); // continuous, not-active
}
if (BX_CMOS_THIS s.one_second_timer_index == BX_NULL_TIMER_HANDLE) {
BX_CMOS_THIS s.one_second_timer_index =
DEV_register_timer(this, one_second_timer_handler,
1000000, 1,0, "cmos"); // continuous, not-active
if (BX_CMOS_THIS s.rtc_sync) {
BX_CMOS_THIS s.one_second_timer_index =
bx_virt_timer.register_timer(this, one_second_timer_handler,
1000000, 1, 0, "cmos"); // continuous, not-active
} else {
BX_CMOS_THIS s.one_second_timer_index =
DEV_register_timer(this, one_second_timer_handler,
1000000, 1,0, "cmos"); // continuous, not-active
}
}
if (BX_CMOS_THIS s.uip_timer_index == BX_NULL_TIMER_HANDLE) {
BX_CMOS_THIS s.uip_timer_index =
@ -277,8 +290,13 @@ void bx_cmos_c::reset(unsigned type)
BX_CMOS_THIS s.reg[REG_STAT_C] = 0;
// One second timer for updating clock & alarm functions
bx_pc_system.activate_timer(BX_CMOS_THIS s.one_second_timer_index,
1000000, 1);
if (BX_CMOS_THIS s.rtc_sync) {
bx_virt_timer.activate_timer(BX_CMOS_THIS s.one_second_timer_index,
1000000, 1);
} else {
bx_pc_system.activate_timer(BX_CMOS_THIS s.one_second_timer_index,
1000000, 1);
}
// handle periodic interrupt rate select
BX_CMOS_THIS CRA_change();

View File

@ -66,6 +66,7 @@ public:
bx_bool timeval_change;
bx_bool rtc_mode_12hour;
bx_bool rtc_mode_binary;
bx_bool rtc_sync;
Bit8u reg[128];
} s; // state information

View File

@ -96,6 +96,7 @@
#define BXPN_OPTRAM4_ADDRESS "memory.optram.4.addr"
#define BXPN_CLOCK_SYNC "clock_cmos.clock_sync"
#define BXPN_CLOCK_TIME0 "clock_cmos.time0"
#define BXPN_CLOCK_RTC_SYNC "clock_cmos.rtc_sync"
#define BXPN_CMOSIMAGE_ENABLED "clock_cmos.cmosimage.enabled"
#define BXPN_CMOSIMAGE_PATH "clock_cmos.cmosimage.path"
#define BXPN_CMOSIMAGE_RTC_INIT "clock_cmos.cmosimage.rtc_init"