- new PIT: exit method added to reset the timer id

- old PIT: exit method stub added and some code cleanup
- virtual timer: reset method added with basic init code from the constructor
This commit is contained in:
Volker Ruppert 2006-09-17 19:19:15 +00:00
parent fdefdc5b9f
commit b8c84baddb
7 changed files with 45 additions and 28 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: devices.cc,v 1.107 2006-09-16 19:30:56 vruppert Exp $
// $Id: devices.cc,v 1.108 2006-09-17 19:19:15 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -114,7 +114,7 @@ void bx_devices_c::init(BX_MEM_C *newmem)
{
unsigned i;
BX_DEBUG(("Init $Id: devices.cc,v 1.107 2006-09-16 19:30:56 vruppert Exp $"));
BX_DEBUG(("Init $Id: devices.cc,v 1.108 2006-09-17 19:19:15 vruppert Exp $"));
mem = newmem;
/* set no-default handlers, will be overwritten by the real default handler */
@ -391,6 +391,8 @@ void bx_devices_c::after_restore_state()
void bx_devices_c::exit()
{
pit->exit();
bx_virt_timer.reset();
bx_slowdown_timer.exit();
#if BX_SUPPORT_PCI

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: pit.cc,v 1.23 2006-05-29 22:33:38 sshwarts Exp $
// $Id: pit.cc,v 1.24 2006-09-17 19:19:15 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -142,25 +142,21 @@ bx_pit_c bx_pit;
#endif
bx_pit_c::bx_pit_c( void )
bx_pit_c::bx_pit_c(void)
{
put("PIT");
settype(PITLOG);
memset(&s, 0, sizeof(s));
/* 8254 PIT (Programmable Interval Timer) */
BX_PIT_THIS s.timer_handle[1] = BX_NULL_TIMER_HANDLE;
BX_PIT_THIS s.timer_handle[2] = BX_NULL_TIMER_HANDLE;
}
bx_pit_c::~bx_pit_c( void )
bx_pit_c::~bx_pit_c(void)
{
}
int
bx_pit_c::init( void )
int bx_pit_c::init(void)
{
DEV_register_irq(0, "8254 PIT");
DEV_register_ioread_handler(this, read_handler, 0x0040, "8254 PIT", 1);
@ -223,6 +219,10 @@ bx_pit_c::init( void )
return(1);
}
int bx_pit_c::exit(void)
{
}
void bx_pit_c::reset(unsigned type)
{
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: pit.h,v 1.15 2006-05-27 15:54:48 sshwarts Exp $
// $Id: pit.h,v 1.16 2006-09-17 19:19:15 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -65,6 +65,7 @@ public:
bx_pit_c();
virtual ~bx_pit_c();
BX_PIT_SMF int init(void);
BX_PIT_SMF void exit(void);
BX_PIT_SMF void reset( unsigned type);
BX_PIT_SMF bx_bool periodic( Bit32u usec_delta );
#if BX_SUPPORT_SAVE_RESTORE
@ -84,7 +85,6 @@ private:
bx_pit_t timer[3];
Bit8u speaker_data_on;
bx_bool refresh_clock_div2;
int timer_handle[3];
} s;
BX_PIT_SMF void write_count_reg( Bit8u value, unsigned timerid );

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////
// $Id: pit_wrap.cc,v 1.62 2006-05-27 15:54:48 sshwarts Exp $
// $Id: pit_wrap.cc,v 1.63 2006-09-17 19:19:15 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -124,7 +124,7 @@ int bx_pit_c::init(void)
BX_DEBUG(("pit: RESETting timer."));
bx_virt_timer.deactivate_timer(BX_PIT_THIS s.timer_handle[0]);
BX_DEBUG(("deactivated timer."));
if(BX_PIT_THIS s.timer.get_next_event_time()) {
if (BX_PIT_THIS s.timer.get_next_event_time()) {
bx_virt_timer.activate_timer(BX_PIT_THIS s.timer_handle[0],
(Bit32u)BX_MAX(1,TICKS_TO_USEC(BX_PIT_THIS s.timer.get_next_event_time())),
0);
@ -146,6 +146,12 @@ int bx_pit_c::init(void)
return(1);
}
void bx_pit_c::exit(void)
{
BX_PIT_THIS s.timer_handle[0] = BX_NULL_TIMER_HANDLE;
BX_PIT_THIS s.timer.init();
}
void bx_pit_c::reset(unsigned type)
{
BX_PIT_THIS s.timer.reset(type);

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: pit_wrap.h,v 1.24 2006-05-27 15:54:49 sshwarts Exp $
// $Id: pit_wrap.h,v 1.25 2006-09-17 19:19:15 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -50,6 +50,7 @@ public:
bx_pit_c();
virtual ~bx_pit_c() {}
BX_PIT_SMF int init(void);
BX_PIT_SMF void exit(void);
BX_PIT_SMF void reset(unsigned type);
BX_PIT_SMF bx_bool periodic(Bit32u usec_delta);
#if BX_SUPPORT_SAVE_RESTORE

View File

@ -1,5 +1,5 @@
////////////////////////////////////////////////////////////////////////
// $Id: virt_timer.cc,v 1.31 2006-05-29 22:33:38 sshwarts Exp $
// $Id: virt_timer.cc,v 1.32 2006-09-17 19:19:15 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -135,16 +135,7 @@ bx_virt_timer_c::bx_virt_timer_c()
put("VTIMER");
settype(VTIMERLOG);
numTimers = 0;
current_timers_time = 0;
timers_next_event_time = BX_MAX_VIRTUAL_TIME;
last_sequential_time = 0;
in_timer_handler = 0;
virtual_next_event_time = BX_MAX_VIRTUAL_TIME;
current_virtual_time = 0;
use_virtual_timers = BX_USE_VIRTUAL_TIMERS;
init_done = 0;
reset();
}
const Bit64u bx_virt_timer_c::NullTimerInterval = BX_MAX_VIRTUAL_TIME;
@ -384,6 +375,20 @@ void bx_virt_timer_c::next_event_time_update(void)
}
}
void bx_virt_timer_c::reset(void)
{
numTimers = 0;
current_timers_time = 0;
timers_next_event_time = BX_MAX_VIRTUAL_TIME;
last_sequential_time = 0;
in_timer_handler = 0;
virtual_next_event_time = BX_MAX_VIRTUAL_TIME;
current_virtual_time = 0;
use_virtual_timers = BX_USE_VIRTUAL_TIMERS;
init_done = 0;
}
void bx_virt_timer_c::init(void)
{
if ( (SIM->get_param_enum(BXPN_CLOCK_SYNC)->get()!=BX_CLOCK_SYNC_REALTIME)

View File

@ -1,5 +1,5 @@
////////////////////////////////////////////////////////////////////////
// $Id: virt_timer.h,v 1.11 2006-05-27 15:54:49 sshwarts Exp $
// $Id: virt_timer.h,v 1.12 2006-09-17 19:19:15 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -145,7 +145,10 @@ public:
//The real timer handler.
void timer_handler();
//Initialization
//Initialization step #1
void reset(void);
//Initialization step #2
void init(void);
#if BX_SUPPORT_SAVE_RESTORE