summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/cbus/pc9801_cbus.cpp
blob: aabc8d8a7d6db373347d6c70130ef1a5aca8fa0c (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
// license:BSD-3-Clause
// copyright-holders:Angelo Salese
/**************************************************************************************************

    C-bus slot interface for PC-98xx family

    a.k.a. NEC version of the ISA bus.
    C-bus -> Card Bus

    TODO:
    - stub interface, checkout what actually belongs here.
      Speculation is that C-bus has ROM / RAM slots always in the 0xc0000-0xdffff region,
      and some opacity can be added if true.
    - move pc9801_cbus_devices declaration from pc9801 driver in here;
    - 8-bit I/O smearing should be handled here;
    - INT# should be handled here too;
    - Best way to inform user when it tries to install incompatible boards?
    - Support for PCI bridging on later machines (cfr. pc9801cx3);

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

#include "emu.h"
#include "pc9801_cbus.h"



//**************************************************************************
//  GLOBAL VARIABLES
//**************************************************************************

DEFINE_DEVICE_TYPE(PC9801CBUS_SLOT, pc9801_slot_device, "pc9801_slot", "PC-9801 C-bus slot")



//**************************************************************************
//  DEVICE PC9801 CARD INTERFACE
//**************************************************************************

#if 0
//-------------------------------------------------
//  device_pc9801cbus_card_interface - constructor
//-------------------------------------------------

device_pc9801cbus_card_interface::device_pc9801cbus_card_interface(const machine_config &mconfig, device_t &device)
	: device_slot_card_interface(mconfig, device)
{
}


//-------------------------------------------------
//  ~device_pc9801cbus_card_interface - destructor
//-------------------------------------------------

device_pc9801cbus_card_interface::~device_pc9801cbus_card_interface()
{
}
#endif


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

//-------------------------------------------------
//  pc9801_slot_device - constructor
//-------------------------------------------------

pc9801_slot_device::pc9801_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock) :
	device_t(mconfig, PC9801CBUS_SLOT, tag, owner, clock),
	device_slot_interface(mconfig, *this),
	m_memspace(*this, finder_base::DUMMY_TAG, -1),
	m_iospace(*this, finder_base::DUMMY_TAG, -1),
	m_int_callback(*this)
{
}


//-------------------------------------------------
//  device_config_complete - perform any
//  operations now that the configuration is
//  complete
//-------------------------------------------------

void pc9801_slot_device::device_config_complete()
{
	// ...
}


//-------------------------------------------------
//  device_resolve_objects - resolve objects that
//  may be needed for other devices to set
//  initial conditions at start time
//-------------------------------------------------

void pc9801_slot_device::device_resolve_objects()
{
	m_int_callback.resolve_all_safe();
}


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

void pc9801_slot_device::device_start()
{
//  m_card = dynamic_cast<device_pc9801_slot_card_interface *>(get_card_device());
}

template<typename R, typename W> void pc9801_slot_device::install_io(offs_t start, offs_t end, R rhandler, W whandler)
{
	int buswidth = m_iospace->data_width();
	switch(buswidth)
	{
		case 8:
			m_iospace->install_readwrite_handler(start, end, rhandler, whandler, 0);
			break;
		case 16:
			m_iospace->install_readwrite_handler(start, end, rhandler, whandler, 0xffff);
			break;
		case 32:
			m_iospace->install_readwrite_handler(start, end, rhandler, whandler, 0xffffffff);
			break;
		default:
			fatalerror("PC-9801 C-bus: Bus width %d not supported\n", buswidth);
	}
}

template void pc9801_slot_device::install_io<read8_delegate,    write8_delegate   >(offs_t start, offs_t end, read8_delegate rhandler,    write8_delegate whandler);
template void pc9801_slot_device::install_io<read8s_delegate,   write8s_delegate  >(offs_t start, offs_t end, read8s_delegate rhandler,   write8s_delegate whandler);
template void pc9801_slot_device::install_io<read8sm_delegate,  write8sm_delegate >(offs_t start, offs_t end, read8sm_delegate rhandler,  write8sm_delegate whandler);
template void pc9801_slot_device::install_io<read8smo_delegate, write8smo_delegate>(offs_t start, offs_t end, read8smo_delegate rhandler, write8smo_delegate whandler);

// boilerplate code for boards that has configurable I/O with either Jumpers or Dip-Switches
// NB: client must have a mechanism to remember what port has been used before and after calling this,
// in order to avoid "last instantiated wins" issues with overlapping board full configs.
void pc9801_slot_device::flush_install_io(const char *client_tag, u16 old_io, u16 new_io, u16 size, read8sm_delegate rhandler, write8sm_delegate whandler)
{
	// initialize if client have this unmapped (such as first boot)
	// device_start fns cannot read input ports ...
	if (old_io == 0)
		old_io = new_io;

	logerror("%s: %s uninstall I/O at %04x-%04x\n",
		this->tag(),
		client_tag,
		old_io,
		old_io + size
	);
	this->io_space().unmap_readwrite(old_io, old_io + size);

	logerror("%s: %s install I/O at %04x-%04x\n",
		this->tag(),
		client_tag,
		new_io,
		new_io + size
	);
	this->install_io(
		new_io,
		new_io + size,
		rhandler,
		whandler
	);
}