2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2011-02-25 01:05:47 +03:00
|
|
|
// $Id$
|
2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2021-01-31 02:55:24 +03:00
|
|
|
// Copyright (C) 2001-2021 The Bochs Project
|
2001-06-11 07:09:40 +04:00
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
2009-02-08 12:05:52 +03:00
|
|
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2001-06-11 07:09:40 +04:00
|
|
|
|
2012-01-15 12:50:20 +04:00
|
|
|
#ifndef _BX_PIT_H
|
|
|
|
#define _BX_PIT_H
|
2001-06-11 07:09:40 +04:00
|
|
|
|
2001-07-02 00:49:46 +04:00
|
|
|
#include "bochs.h"
|
|
|
|
#include "pit82c54.h"
|
2001-06-11 07:09:40 +04:00
|
|
|
|
|
|
|
#if BX_USE_PIT_SMF
|
|
|
|
# define BX_PIT_SMF static
|
2009-01-11 21:46:01 +03:00
|
|
|
# define BX_PIT_THIS thePit->
|
2001-06-11 07:09:40 +04:00
|
|
|
#else
|
|
|
|
# define BX_PIT_SMF
|
2001-07-02 00:49:46 +04:00
|
|
|
# define BX_PIT_THIS this->
|
2001-06-11 07:09:40 +04:00
|
|
|
#endif
|
|
|
|
|
2017-04-15 23:31:07 +03:00
|
|
|
class bx_pit_c : public bx_pit_stub_c {
|
2001-06-11 07:09:40 +04:00
|
|
|
public:
|
2006-03-08 00:11:20 +03:00
|
|
|
bx_pit_c();
|
2012-08-19 12:16:20 +04:00
|
|
|
virtual ~bx_pit_c();
|
2009-01-11 21:46:01 +03:00
|
|
|
virtual void init(void);
|
|
|
|
virtual void reset(unsigned type);
|
|
|
|
virtual void register_state(void);
|
2014-05-10 10:50:06 +04:00
|
|
|
virtual void after_restore_state(void);
|
2021-01-31 02:55:24 +03:00
|
|
|
virtual void enable_irq(bool enabled) {
|
2017-04-15 23:31:07 +03:00
|
|
|
s.irq_enabled = enabled;
|
|
|
|
}
|
2012-05-01 19:53:28 +04:00
|
|
|
#if BX_DEBUGGER
|
|
|
|
virtual void debug_dump(int argc, char **argv);
|
|
|
|
#endif
|
2001-06-11 07:09:40 +04:00
|
|
|
|
2007-09-28 23:52:08 +04:00
|
|
|
private:
|
2001-06-11 07:09:40 +04:00
|
|
|
static Bit32u read_handler(void *this_ptr, Bit32u address, unsigned io_len);
|
|
|
|
static void write_handler(void *this_ptr, Bit32u address, Bit32u value, unsigned io_len);
|
|
|
|
#if !BX_USE_PIT_SMF
|
2006-03-08 00:11:20 +03:00
|
|
|
Bit32u read(Bit32u addr, unsigned len);
|
|
|
|
void write(Bit32u addr, Bit32u Value, unsigned len);
|
2001-06-11 07:09:40 +04:00
|
|
|
#endif
|
|
|
|
|
2001-08-30 06:04:42 +04:00
|
|
|
struct s_type {
|
2001-06-11 07:09:40 +04:00
|
|
|
pit_82C54 timer;
|
2021-01-31 02:55:24 +03:00
|
|
|
bool speaker_data_on;
|
|
|
|
bool speaker_active;
|
|
|
|
bool speaker_level;
|
2011-06-04 10:40:04 +04:00
|
|
|
Bit64u last_usec;
|
|
|
|
Bit32u last_next_event_time;
|
|
|
|
Bit64u total_ticks;
|
|
|
|
Bit64u total_usec;
|
|
|
|
int timer_handle[3];
|
2021-01-31 02:55:24 +03:00
|
|
|
bool irq_enabled;
|
2006-03-08 00:11:20 +03:00
|
|
|
} s;
|
2001-06-11 07:09:40 +04:00
|
|
|
|
2021-01-31 02:55:24 +03:00
|
|
|
bool is_realtime;
|
2014-10-19 12:54:16 +04:00
|
|
|
|
2001-08-18 07:28:23 +04:00
|
|
|
static void timer_handler(void *this_ptr);
|
|
|
|
BX_PIT_SMF void handle_timer();
|
2021-01-31 02:55:24 +03:00
|
|
|
BX_PIT_SMF bool periodic(Bit32u usec_delta);
|
2002-02-08 00:22:55 +03:00
|
|
|
|
2021-01-31 02:55:24 +03:00
|
|
|
BX_PIT_SMF void irq_handler(bool value);
|
|
|
|
BX_PIT_SMF void speaker_handler(bool value);
|
2001-06-11 07:09:40 +04:00
|
|
|
|
2009-01-11 21:46:01 +03:00
|
|
|
BX_PIT_SMF Bit16u get_timer(int Timer);
|
2013-06-14 23:08:51 +04:00
|
|
|
BX_PIT_SMF Bit16u new_timer_count(int Timer);
|
2009-01-11 21:46:01 +03:00
|
|
|
};
|
2001-06-11 07:09:40 +04:00
|
|
|
|
2012-01-15 12:50:20 +04:00
|
|
|
#endif // #ifndef _BX_PIT_H
|