2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2004-01-16 19:30:46 +03:00
|
|
|
// $Id: pit_wrap.h,v 1.18 2004-01-16 16:30:46 danielg4 Exp $
|
2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2001-06-11 07:09:40 +04:00
|
|
|
// Copyright (C) 2001 MandrakeSoft S.A.
|
|
|
|
//
|
|
|
|
// MandrakeSoft S.A.
|
|
|
|
// 43, rue d'Aboukir
|
|
|
|
// 75002 Paris - France
|
|
|
|
// http://www.linux-mandrake.com/
|
|
|
|
// http://www.mandrakesoft.com/
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
|
|
|
#ifndef _BX_PIT_WRAP_H
|
|
|
|
#define _BX_PIT_WRAP_H
|
|
|
|
|
2001-07-02 00:49:46 +04:00
|
|
|
#include "bochs.h"
|
|
|
|
|
2001-08-16 00:23:58 +04:00
|
|
|
#if BX_USE_NEW_PIT
|
2001-07-02 00:49:46 +04:00
|
|
|
|
|
|
|
#include "pit82c54.h"
|
2004-01-16 19:30:46 +03:00
|
|
|
#include "console.h"
|
2001-06-11 07:09:40 +04:00
|
|
|
|
|
|
|
#if BX_USE_PIT_SMF
|
|
|
|
# define BX_PIT_SMF static
|
2001-07-02 00:49:46 +04:00
|
|
|
# define BX_PIT_THIS bx_pit.
|
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
|
|
|
|
|
|
|
|
#ifdef OUT
|
|
|
|
# undef OUT
|
|
|
|
#endif
|
|
|
|
|
2001-07-02 00:49:46 +04:00
|
|
|
class bx_pit_c : public logfunctions {
|
2001-06-11 07:09:40 +04:00
|
|
|
public:
|
2001-07-02 00:49:46 +04:00
|
|
|
bx_pit_c( void );
|
|
|
|
~bx_pit_c( void );
|
2002-10-25 01:07:56 +04:00
|
|
|
BX_PIT_SMF int init( void );
|
2002-08-27 23:54:46 +04:00
|
|
|
BX_PIT_SMF void reset( unsigned type);
|
2002-10-25 15:44:41 +04:00
|
|
|
BX_PIT_SMF bx_bool periodic( Bit32u usec_delta );
|
2001-06-11 07:09:40 +04:00
|
|
|
|
|
|
|
BX_PIT_SMF int SaveState( class state_file *fd );
|
|
|
|
BX_PIT_SMF int LoadState( class state_file *fd );
|
2004-01-16 19:30:46 +03:00
|
|
|
bx_console_c *console;
|
|
|
|
Bit16u get_timer(int Timer) {
|
|
|
|
return s.timer.get_inlatch(Timer);
|
|
|
|
}
|
2001-06-11 07:09:40 +04:00
|
|
|
private:
|
|
|
|
|
|
|
|
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
|
|
|
|
Bit32u read( Bit32u addr, unsigned int len );
|
|
|
|
void write( Bit32u addr, Bit32u Value, unsigned int len );
|
|
|
|
#endif
|
|
|
|
|
2001-08-30 06:04:42 +04:00
|
|
|
struct s_type {
|
2001-06-11 07:09:40 +04:00
|
|
|
pit_82C54 timer;
|
|
|
|
Bit8u speaker_data_on;
|
2002-10-25 15:44:41 +04:00
|
|
|
bx_bool refresh_clock_div2;
|
2001-06-11 07:09:40 +04:00
|
|
|
int timer_handle[3];
|
2001-08-18 07:28:23 +04:00
|
|
|
Bit64u last_usec;
|
|
|
|
Bit32u last_next_event_time;
|
2002-01-31 19:52:00 +03:00
|
|
|
Bit64u total_ticks;
|
2002-02-08 00:22:55 +03:00
|
|
|
Bit64u usec_per_second;
|
|
|
|
Bit64u ticks_per_second;
|
|
|
|
Bit64u total_sec;
|
|
|
|
Bit64u last_time;
|
|
|
|
Bit64u last_sec_usec;
|
2002-05-21 01:53:26 +04:00
|
|
|
Bit64u max_ticks;
|
2002-09-21 03:10:55 +04:00
|
|
|
Bit64u stored_delta;
|
2002-02-08 00:22:55 +03:00
|
|
|
Bit64u total_usec;
|
2002-12-07 23:01:10 +03:00
|
|
|
Bit64u em_last_realtime;
|
|
|
|
Bit64u last_realtime_delta;
|
|
|
|
Bit64u last_realtime_ticks;
|
2001-06-11 07:09:40 +04:00
|
|
|
} s;
|
|
|
|
|
2001-08-18 07:28:23 +04:00
|
|
|
static void timer_handler(void *this_ptr);
|
|
|
|
BX_PIT_SMF void handle_timer();
|
|
|
|
|
2001-06-11 07:09:40 +04:00
|
|
|
BX_PIT_SMF void write_count_reg( Bit8u value, unsigned timerid );
|
|
|
|
BX_PIT_SMF Bit8u read_counter( unsigned timerid );
|
|
|
|
BX_PIT_SMF void latch( unsigned timerid );
|
|
|
|
BX_PIT_SMF void set_GATE(unsigned pit_id, unsigned value);
|
|
|
|
BX_PIT_SMF void start(unsigned timerid);
|
2002-02-08 00:22:55 +03:00
|
|
|
|
|
|
|
BX_PIT_SMF void second_update_data(void);
|
2001-06-11 07:09:40 +04:00
|
|
|
};
|
|
|
|
|
2001-07-02 00:49:46 +04:00
|
|
|
extern bx_pit_c bx_pit;
|
2001-06-11 07:09:40 +04:00
|
|
|
|
2001-08-16 00:23:58 +04:00
|
|
|
#endif // #if BX_USE_NEW_PIT
|
2001-06-11 07:09:40 +04:00
|
|
|
#endif // #ifndef _BX_PIT_WRAP_H
|