summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/machine/i80130.c
blob: c9175aebfd679efdb704ef0b67f73013e620bfd9 (plain) (blame)
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
// license:BSD-3-Clause
// copyright-holders:Curt Coder
/**********************************************************************

    Intel 80130 iRMX Operating System Processor emulation

    Copyright MESS Team.
    Visit http://mamedev.org for licensing and usage restrictions.

**********************************************************************/

#include "i80130.h"



//**************************************************************************
//  DEVICE DEFINITIONS
//**************************************************************************

// device type definition
const device_type I80130 = &device_creator<i80130_device>;


DEVICE_ADDRESS_MAP_START( rom_map, 16, i80130_device )
	//AM_RANGE(0x0000, 0x3fff) AM_ROM AM_REGION("rom", 0)
ADDRESS_MAP_END

DEVICE_ADDRESS_MAP_START( io_map, 16, i80130_device )
	AM_RANGE(0x00, 0x0f) AM_READWRITE(io_r, io_w)
	//AM_RANGE(0x00, 0x01) AM_MIRROR(0x2) AM_DEVREADWRITE8("pic", pic8259_device, read, write, 0x00ff)
	//AM_RANGE(0x08, 0x0f) AM_DEVREADWRITE8("pit", pit8254_device, read, write, 0x00ff)
ADDRESS_MAP_END

READ16_MEMBER( i80130_device::io_r )
{
	UINT16 data = 0;

	switch (offset)
	{
	case 0: case 1:
		if (ACCESSING_BITS_0_7)
		{
			data = m_pic->read(space, offset & 0x01);
		}
		break;

	case 4: case 5: case 6: case 7:
		if (ACCESSING_BITS_0_7)
		{
			data = m_pit->read(space, offset & 0x03);
		}
		break;
	}

	return data;
}

WRITE16_MEMBER( i80130_device::io_w )
{
	switch (offset)
	{
	case 0: case 1:
		if (ACCESSING_BITS_0_7)
		{
			m_pic->write(space, offset & 0x01, data & 0xff);
		}
		break;

	case 4: case 5: case 6: case 7:
		if (ACCESSING_BITS_0_7)
		{
			m_pit->write(space, offset & 0x03, data & 0xff);
		}
		break;
	}
}


//-------------------------------------------------
//  ROM( i80130 )
//-------------------------------------------------

ROM_START( i80130 )
	ROM_REGION16_LE( 0x4000, "rom", 0 )
	ROM_LOAD( "80130", 0x0000, 0x4000, NO_DUMP )
ROM_END


//-------------------------------------------------
//  rom_region - device-specific ROM region
//-------------------------------------------------

const rom_entry *i80130_device::device_rom_region() const
{
	return ROM_NAME( i80130 );
}


//-------------------------------------------------
//  pit8253_interface pit_intf
//-------------------------------------------------

static const struct pit8253_interface pit_intf =
{
	{
		{ 0, DEVCB_LINE_VCC, DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, i80130_device, systick_w) },
		{ 0, DEVCB_LINE_VCC, DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, i80130_device, delay_w) },
		{ 0, DEVCB_LINE_VCC, DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, i80130_device, baud_w) }
	}
};


//-------------------------------------------------
//  MACHINE_CONFIG_FRAGMENT( i80130 )
//-------------------------------------------------

static MACHINE_CONFIG_FRAGMENT( i80130 )
	MCFG_PIC8259_ADD("pic", DEVWRITELINE(DEVICE_SELF, i80130_device, irq_w), VCC, NULL)
	MCFG_PIT8254_ADD("pit", pit_intf)
MACHINE_CONFIG_END


//-------------------------------------------------
//  machine_config_additions - device-specific
//  machine configurations
//-------------------------------------------------

machine_config_constructor i80130_device::device_mconfig_additions() const
{
	return MACHINE_CONFIG_NAME( i80130 );
}



//**************************************************************************
//  LIVE DEVICE
//**************************************************************************

//-------------------------------------------------
//  i80130_device - constructor
//-------------------------------------------------

i80130_device::i80130_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
	: device_t(mconfig, I80130, "I80130", tag, owner, clock, "i80130", __FILE__),
	  m_pic(*this, "pic"),
	  m_pit(*this, "pit"),
	  m_write_irq(*this),
	  m_write_ack(*this),
	  m_write_lir(*this),
	  m_write_systick(*this),
	  m_write_delay(*this),
	  m_write_baud(*this)
{
}


//-------------------------------------------------
//  device_start - device-specific startup
//-------------------------------------------------

void i80130_device::device_start()
{
	// resolve callbacks
	m_write_irq.resolve_safe();
	m_write_ack.resolve_safe();
	m_write_lir.resolve_safe();
	m_write_systick.resolve_safe();
	m_write_delay.resolve_safe();
	m_write_baud.resolve_safe();
}


//-------------------------------------------------
//  device_reset - device-specific reset
//-------------------------------------------------

void i80130_device::device_reset()
{
	// set PIT clocks
	m_pit->set_clockin(0, clock());
	m_pit->set_clockin(1, clock());
	m_pit->set_clockin(2, clock());
}