Added a function to un-register a bochs timer, in case a component

wants to free up that resource.

  unsigned unregisterTimer(int timerID);

Pass in the timer index received from the register function.  A return
  of 1 means success.  NOTE: you must make sure the timer is deactivated
  first.  Call deactivate_timer() to be sure.  A return of 0 means
  failure, though a panic is really generated.

For now, this function does not really free up the slot, but will soon.
This commit is contained in:
Kevin Lawton 2002-10-06 14:55:06 +00:00
parent 261badee5a
commit 8ef1a6b8b0
2 changed files with 14 additions and 3 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: pc_system.cc,v 1.27 2002-10-04 16:26:08 kevinlawton Exp $
// $Id: pc_system.cc,v 1.28 2002-10-06 14:55:06 kevinlawton Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -228,7 +228,7 @@ bx_pc_system_c::exit(void)
{
if (bx_devices.hard_drive)
bx_devices.hard_drive->close_harddrive();
BX_INFO(("Last time is %d", bx_cmos.s.timeval));
BX_INFO(("Last time is %u", (unsigned) bx_cmos.s.timeval));
bx_gui.exit();
}
@ -497,3 +497,13 @@ bx_pc_system_c::deactivate_timer( unsigned i )
timer[i].active = 0;
}
unsigned
bx_pc_system_c::unregisterTimer(int i)
{
if (timer[i].active) {
BX_PANIC(("unregisterTimer: timer '%s' is still active!", timer[i].id));
return(0); // Fail.
}
return(1); // OK
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: pc_system.h,v 1.17 2002-10-04 16:26:09 kevinlawton Exp $
// $Id: pc_system.h,v 1.18 2002-10-06 14:55:06 kevinlawton Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -97,6 +97,7 @@ public:
void init_ips(Bit32u ips);
int register_timer( void *this_ptr, bx_timer_handler_t, Bit32u useconds,
Boolean continuous, Boolean active, const char *id);
unsigned unregisterTimer(int timerID);
void start_timers(void);
void activate_timer( unsigned timer_index, Bit32u useconds,
Boolean continuous );