1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
/*********************************************************************
mc146818.h
Implementation of the MC146818 chip
Real time clock chip with batteru buffered ram
Used in IBM PC/AT, several PC clones, Amstrad NC200
Peter Trauner (peter.trauner@jk.uni-linz.ac.at)
*********************************************************************/
#ifndef __MC146818_H__
#define __MC146818_H__
//**************************************************************************
// INTERFACE CONFIGURATION MACROS
//**************************************************************************
#define MCFG_MC146818_ADD(_tag, _type) \
MCFG_DEVICE_ADD(_tag, MC146818, 0) \
mc146818_device_config::static_set_type(device, mc146818_device_config::_type); \
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
class mc146818_device;
// ======================> mc146818_device_config
class mc146818_device_config : public device_config,
public device_config_rtc_interface,
public device_config_nvram_interface
{
friend class mc146818_device;
// construction/destruction
mc146818_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
public:
// values
enum mc146818_type
{
MC146818_STANDARD,
MC146818_IGNORE_CENTURY, // century is NOT set, for systems having other usage of this byte
MC146818_ENHANCED,
MC146818_UTC
};
// allocators
static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
virtual device_t *alloc_device(running_machine &machine) const;
// inline configuration helpers
static void static_set_type(device_config *device, mc146818_type type);
protected:
// internal state
mc146818_type m_type;
};
// ======================> mc146818_device
class mc146818_device : public device_t,
public device_rtc_interface,
public device_nvram_interface
{
friend class mc146818_device_config;
// construction/destruction
mc146818_device(running_machine &_machine, const mc146818_device_config &config);
public:
// read/write access
DECLARE_READ8_MEMBER( read );
DECLARE_WRITE8_MEMBER( write );
protected:
// device-level overrides
virtual void device_start();
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
// device_rtc_interface overrides
virtual void rtc_set_time(int year, int month, int day, int day_of_week, int hour, int minute, int second);
virtual bool rtc_is_year_2000_compliant() { return false; }
// device_nvram_interface overrides
virtual void nvram_default();
virtual void nvram_read(emu_file &file);
virtual void nvram_write(emu_file &file);
// internal helpers
int dec_2_local(int a);
void set_base_datetime();
// internal state
static const int MC146818_DATA_SIZE = 0x80;
const mc146818_device_config & m_config;
UINT8 m_index;
UINT8 m_data[MC146818_DATA_SIZE];
UINT16 m_eindex;
UINT8 m_edata[0x2000];
bool m_updated; /* update ended interrupt flag */
attotime m_last_refresh;
};
// device type definition
extern const device_type MC146818;
#endif /* __MC146818_H__ */
|