summaryrefslogtreecommitdiffstats
path: root/src/devices/bus/isa/isa.h
blob: 2eddae32015dcf0f2a4df8e84859576868be6782 (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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
// license:BSD-3-Clause
// copyright-holders:Miodrag Milanovic
/***************************************************************************

        ISA bus device


    8 bit ISA bus connector:

    A1    O  I/O CH CHK    B1       GND
    A2   IO  D7            B2   I   RESET
    A3   IO  D6            B3       +5V
    A4   IO  D5            B4    O  IRQ2
    A5   IO  D4            B5       -5V
    A6   IO  D3            B6    O  DRQ2
    A7   IO  D2            B7       -12V
    A8   IO  D1            B8    O  /NOWS
    A9   IO  D0            B9       +12V
    A10   O  I/O CH RDY    B10      GND
    A11  I   AEN           B11  I   /SMEMW
    A12  IO  A19           B12  I   /SMEMR
    A13  IO  A18           B13  I   /IOW
    A14  IO  A17           B14  I   /IOR
    A15  IO  A16           B15  I   /DACK3
    A16  IO  A15           B16   O  DRQ3
    A17  IO  A14           B17  I   /DACK1
    A18  IO  A13           B18   O  DRQ1
    A19  IO  A12           B19  IO  /REFRESH
    A20  IO  A11           B20  I   CLOCK
    A21  IO  A10           B21   O  IRQ7
    A22  IO  A9            B22   O  IRQ6
    A23  IO  A8            B23   O  IRQ5
    A24  IO  A7            B24   O  IRQ4
    A25  IO  A6            B25   O  IRQ3
    A26  IO  A5            B26  I   /DACK2
    A27  IO  A4            B27  I   T/C
    A28  IO  A3            B28  I   ALE
    A29  IO  A2            B29      +5V
    A30  IO  A1            B30  I   OSC
    A31  IO  A0            B31      GND

    16 bit ISA bus extension

    C1   I   SBHE          D1   I   /MEM CS 16
    C2   IO  A23           D2   I   /I/O CS 16
    C3   IO  A22           D3    O  IRQ10
    C4   IO  A21           D4    O  IRQ11
    C5   IO  A20           D5    O  IRQ12
    C6   IO  A19           D6    O  IRQ15
    C7   IO  A18           D7    O  IRQ14
    C8   IO  A17           D8   I   /DACK0
    C9   I   /MEMR         D9    O  DRQ0
    C10  I   /MEMW         D10  I   /DACK5
    C11  IO  D8            D11   O  DRQ5
    C12  IO  D9            D12  I   /DACK6
    C13  IO  D10           D13   O  DRQ6
    C14  IO  D11           D14  I   /DACK7
    C15  IO  D12           D15   O  DRQ7
    C16  IO  D13           D16      +5V
    C17  IO  D14           D17  I   MASTER
    C18  IO  D15           D18      GND

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

#pragma once

#ifndef __ISA_H__
#define __ISA_H__



//**************************************************************************
//  INTERFACE CONFIGURATION MACROS
//**************************************************************************

#define MCFG_ISA8_CPU(_cputag) \
	isa8_device::static_set_cputag(*device, _cputag);
// include this in a driver to have ISA allocate it's own address spaces (e.g. non-x86)
#define MCFG_ISA8_BUS_CUSTOM_SPACES() \
	isa8_device::static_set_custom_spaces(*device);
#define MCFG_ISA8_SLOT_ADD(_isatag, _tag, _slot_intf, _def_slot, _fixed) \
	MCFG_DEVICE_ADD(_tag, ISA8_SLOT, 0) \
	MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, _fixed) \
	isa8_slot_device::static_set_isa8_slot(*device, owner, _isatag);
#define MCFG_ISA16_CPU(_cputag) \
	isa8_device::static_set_cputag(*device, _cputag);
#define MCFG_ISA16_BUS_CUSTOM_SPACES() \
	isa8_device::static_set_custom_spaces(*device);
#define MCFG_ISA16_SLOT_ADD(_isatag, _tag, _slot_intf, _def_slot, _fixed) \
	MCFG_DEVICE_ADD(_tag, ISA16_SLOT, 0) \
	MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, _fixed) \
	isa16_slot_device::static_set_isa16_slot(*device, owner, _isatag);

#define MCFG_ISA_BUS_IOCHCK(_iochck) \
	devcb = &downcast<isa8_device *>(device)->set_iochck_callback(DEVCB_##_iochck);

#define MCFG_ISA_OUT_IRQ2_CB(_devcb) \
	devcb = &isa8_device::set_out_irq2_callback(*device, DEVCB_##_devcb);

#define MCFG_ISA_OUT_IRQ3_CB(_devcb) \
	devcb = &isa8_device::set_out_irq3_callback(*device, DEVCB_##_devcb);

#define MCFG_ISA_OUT_IRQ4_CB(_devcb) \
	devcb = &isa8_device::set_out_irq4_callback(*device, DEVCB_##_devcb);

#define MCFG_ISA_OUT_IRQ5_CB(_devcb) \
	devcb = &isa8_device::set_out_irq5_callback(*device, DEVCB_##_devcb);

#define MCFG_ISA_OUT_IRQ6_CB(_devcb) \
	devcb = &isa8_device::set_out_irq6_callback(*device, DEVCB_##_devcb);

#define MCFG_ISA_OUT_IRQ7_CB(_devcb) \
	devcb = &isa8_device::set_out_irq7_callback(*device, DEVCB_##_devcb);

#define MCFG_ISA_OUT_DRQ1_CB(_devcb) \
	devcb = &isa8_device::set_out_drq1_callback(*device, DEVCB_##_devcb);

#define MCFG_ISA_OUT_DRQ2_CB(_devcb) \
	devcb = &isa8_device::set_out_drq2_callback(*device, DEVCB_##_devcb);

#define MCFG_ISA_OUT_DRQ3_CB(_devcb) \
	devcb = &isa8_device::set_out_drq3_callback(*device, DEVCB_##_devcb);


#define MCFG_ISA_OUT_IRQ10_CB(_devcb) \
	devcb = &isa16_device::set_out_irq10_callback(*device, DEVCB_##_devcb);

#define MCFG_ISA_OUT_IRQ11_CB(_devcb) \
	devcb = &isa16_device::set_out_irq11_callback(*device, DEVCB_##_devcb);

#define MCFG_ISA_OUT_IRQ12_CB(_devcb) \
	devcb = &isa16_device::set_out_irq12_callback(*device, DEVCB_##_devcb);

#define MCFG_ISA_OUT_IRQ14_CB(_devcb) \
	devcb = &isa16_device::set_out_irq14_callback(*device, DEVCB_##_devcb);

#define MCFG_ISA_OUT_IRQ15_CB(_devcb) \
	devcb = &isa16_device::set_out_irq15_callback(*device, DEVCB_##_devcb);

#define MCFG_ISA_OUT_DRQ0_CB(_devcb) \
	devcb = &isa16_device::set_out_drq0_callback(*device, DEVCB_##_devcb);

#define MCFG_ISA_OUT_DRQ5_CB(_devcb) \
	devcb = &isa16_device::set_out_drq5_callback(*device, DEVCB_##_devcb);

#define MCFG_ISA_OUT_DRQ6_CB(_devcb) \
	devcb = &isa16_device::set_out_drq6_callback(*device, DEVCB_##_devcb);

#define MCFG_ISA_OUT_DRQ7_CB(_devcb) \
	devcb = &isa16_device::set_out_drq7_callback(*device, DEVCB_##_devcb);


//**************************************************************************
//  TYPE DEFINITIONS
//**************************************************************************

class isa8_device;

class isa8_slot_device : public device_t,
							public device_slot_interface
{
public:
	// construction/destruction
	isa8_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
	isa8_slot_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, uint32_t clock, const char *shortname, const char *source);

	// device-level overrides
	virtual void device_start() override;

	// inline configuration
	static void static_set_isa8_slot(device_t &device, device_t *owner, const char *isa_tag);
protected:
	// configuration
	device_t *m_owner;
	const char *m_isa_tag;
};

// device type definition
extern const device_type ISA8_SLOT;

class device_isa8_card_interface;
// ======================> isa8_device
class isa8_device : public device_t,
					public device_memory_interface
{
public:
	// construction/destruction
	isa8_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
	isa8_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, uint32_t clock, const char *shortname, const char *source);
	// inline configuration
	static void static_set_cputag(device_t &device, const char *tag);
	static void static_set_custom_spaces(device_t &device);
	template<class _iochck> devcb_base &set_iochck_callback(_iochck iochck) { return m_write_iochck.set_callback(iochck); }
	template<class _Object> static devcb_base &set_out_irq2_callback(device_t &device, _Object object) { return downcast<isa8_device &>(device).m_out_irq2_cb.set_callback(object); }
	template<class _Object> static devcb_base &set_out_irq3_callback(device_t &device, _Object object) { return downcast<isa8_device &>(device).m_out_irq3_cb.set_callback(object); }
	template<class _Object> static devcb_base &set_out_irq4_callback(device_t &device, _Object object) { return downcast<isa8_device &>(device).m_out_irq4_cb.set_callback(object); }
	template<class _Object> static devcb_base &set_out_irq5_callback(device_t &device, _Object object) { return downcast<isa8_device &>(device).m_out_irq5_cb.set_callback(object); }
	template<class _Object> static devcb_base &set_out_irq6_callback(device_t &device, _Object object) { return downcast<isa8_device &>(device).m_out_irq6_cb.set_callback(object); }
	template<class _Object> static devcb_base &set_out_irq7_callback(device_t &device, _Object object) { return downcast<isa8_device &>(device).m_out_irq7_cb.set_callback(object); }
	template<class _Object> static devcb_base &set_out_drq1_callback(device_t &device, _Object object) { return downcast<isa8_device &>(device).m_out_drq1_cb.set_callback(object); }
	template<class _Object> static devcb_base &set_out_drq2_callback(device_t &device, _Object object) { return downcast<isa8_device &>(device).m_out_drq2_cb.set_callback(object); }
	template<class _Object> static devcb_base &set_out_drq3_callback(device_t &device, _Object object) { return downcast<isa8_device &>(device).m_out_drq3_cb.set_callback(object); }

	// for ISA8, put the 8-bit configs in the primary slots and the 16-bit configs in the secondary
	virtual const address_space_config *memory_space_config(address_spacenum spacenum) const override
	{
		switch (spacenum)
		{
			case AS_PROGRAM: return &m_program_config;
			case AS_IO:      return &m_io_config;
			case AS_DATA:    return &m_program16_config;
			case AS_3:       return &m_io16_config;
			default:         fatalerror("isa: invalid memory space!\n");
		}
	}

	void install_device(offs_t start, offs_t end, read8_delegate rhandler, write8_delegate whandler);
	template<typename T> void install_device(offs_t addrstart, offs_t addrend, T &device, void (T::*map)(class address_map &map), int bits = 8, uint64_t unitmask = 0xffffffffffffffffU)
	{
		m_iospace->install_device(addrstart, addrend, device, map, bits, unitmask);
	}
	void install_bank(offs_t start, offs_t end, const char *tag, uint8_t *data);
	void install_rom(device_t *dev, offs_t start, offs_t end, const char *tag, const char *region);
	void install_memory(offs_t start, offs_t end, read8_delegate rhandler, write8_delegate whandler);

	void unmap_bank(offs_t start, offs_t end);
	void unmap_rom(offs_t start, offs_t end);
	bool is_option_rom_space_available(offs_t start, int size);

	DECLARE_WRITE_LINE_MEMBER( irq2_w );
	DECLARE_WRITE_LINE_MEMBER( irq3_w );
	DECLARE_WRITE_LINE_MEMBER( irq4_w );
	DECLARE_WRITE_LINE_MEMBER( irq5_w );
	DECLARE_WRITE_LINE_MEMBER( irq6_w );
	DECLARE_WRITE_LINE_MEMBER( irq7_w );

	DECLARE_WRITE_LINE_MEMBER( drq1_w );
	DECLARE_WRITE_LINE_MEMBER( drq2_w );
	DECLARE_WRITE_LINE_MEMBER( drq3_w );

	// 8 bit accessors for ISA-defined address spaces
	DECLARE_READ8_MEMBER(prog_r);
	DECLARE_WRITE8_MEMBER(prog_w);
	DECLARE_READ8_MEMBER(io_r);
	DECLARE_WRITE8_MEMBER(io_w);

	uint8_t dack_r(int line);
	void dack_w(int line,uint8_t data);
	void eop_w(int channels, int state);

	void nmi();
	void set_nmi_state(bool enabled) { m_nmi_enabled = enabled; }

	virtual void set_dma_channel(uint8_t channel, device_isa8_card_interface *dev, bool do_eop);

	const address_space_config m_program_config, m_io_config, m_program16_config, m_io16_config;

protected:
	void install_space(address_spacenum spacenum, offs_t start, offs_t end, read8_delegate rhandler, write8_delegate whandler);

	// device-level overrides
	virtual void device_start() override;
	virtual void device_reset() override;

	// internal state
	cpu_device   *m_maincpu;

	// address spaces
	address_space *m_iospace, *m_prgspace;
	int m_iowidth, m_prgwidth;
	bool m_allocspaces;

	devcb_write_line    m_out_irq2_cb;
	devcb_write_line    m_out_irq3_cb;
	devcb_write_line    m_out_irq4_cb;
	devcb_write_line    m_out_irq5_cb;
	devcb_write_line    m_out_irq6_cb;
	devcb_write_line    m_out_irq7_cb;
	devcb_write_line    m_out_drq1_cb;
	devcb_write_line    m_out_drq2_cb;
	devcb_write_line    m_out_drq3_cb;

	device_isa8_card_interface *m_dma_device[8];
	bool                        m_dma_eop[8];
	const char                 *m_cputag;
	bool                        m_nmi_enabled;

private:
	devcb_write_line m_write_iochck;
};


// device type definition
extern const device_type ISA8;

// ======================> device_isa8_card_interface

// class representing interface-specific live isa8 card
class device_isa8_card_interface : public device_slot_card_interface
{
	friend class isa8_device;
public:
	// construction/destruction
	device_isa8_card_interface(const machine_config &mconfig, device_t &device);
	virtual ~device_isa8_card_interface();

	device_isa8_card_interface *next() const { return m_next; }

	void set_isa_device();
	// configuration access
	virtual uint8_t dack_r(int line);
	virtual void dack_w(int line,uint8_t data);
	virtual void eop_w(int state);

	// inline configuration
	static void static_set_isabus(device_t &device, device_t *isa_device);
public:
	isa8_device  *m_isa;
	device_t     *m_isa_dev;
	device_isa8_card_interface *m_next;
};

class isa16_device;

class isa16_slot_device : public isa8_slot_device
{
public:
	// construction/destruction
	isa16_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
		// device-level overrides
	virtual void device_start() override;

	// inline configuration
	static void static_set_isa16_slot(device_t &device, device_t *owner, const char *isa_tag);
};


// device type definition
extern const device_type ISA16_SLOT;

// ======================> isa16_device
class isa16_device : public isa8_device
{
public:
	// construction/destruction
	isa16_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

	template<class _Object> static devcb_base &set_out_irq10_callback(device_t &device, _Object object) { return downcast<isa16_device &>(device).m_out_irq10_cb.set_callback(object); }
	template<class _Object> static devcb_base &set_out_irq11_callback(device_t &device, _Object object) { return downcast<isa16_device &>(device).m_out_irq11_cb.set_callback(object); }
	template<class _Object> static devcb_base &set_out_irq12_callback(device_t &device, _Object object) { return downcast<isa16_device &>(device).m_out_irq12_cb.set_callback(object); }
	template<class _Object> static devcb_base &set_out_irq14_callback(device_t &device, _Object object) { return downcast<isa16_device &>(device).m_out_irq14_cb.set_callback(object); }
	template<class _Object> static devcb_base &set_out_irq15_callback(device_t &device, _Object object) { return downcast<isa16_device &>(device).m_out_irq15_cb.set_callback(object); }
	template<class _Object> static devcb_base &set_out_drq0_callback(device_t &device, _Object object) { return downcast<isa16_device &>(device).m_out_drq0_cb.set_callback(object); }
	template<class _Object> static devcb_base &set_out_drq5_callback(device_t &device, _Object object) { return downcast<isa16_device &>(device).m_out_drq5_cb.set_callback(object); }
	template<class _Object> static devcb_base &set_out_drq6_callback(device_t &device, _Object object) { return downcast<isa16_device &>(device).m_out_drq6_cb.set_callback(object); }
	template<class _Object> static devcb_base &set_out_drq7_callback(device_t &device, _Object object) { return downcast<isa16_device &>(device).m_out_drq7_cb.set_callback(object); }

	void install16_device(offs_t start, offs_t end, read16_delegate rhandler, write16_delegate whandler);

	// for ISA16, put the 16-bit configs in the primary slots and the 8-bit configs in the secondary
	virtual const address_space_config *memory_space_config(address_spacenum spacenum) const override
	{
		switch (spacenum)
		{
			case AS_PROGRAM: return &m_program16_config;
			case AS_IO:      return &m_io16_config;
			case AS_DATA:    return &m_program_config;
			case AS_3:       return &m_io_config;
			default:         fatalerror("isa: invalid memory space!\n");
		}
	}

	DECLARE_WRITE_LINE_MEMBER( irq10_w );
	DECLARE_WRITE_LINE_MEMBER( irq11_w );
	DECLARE_WRITE_LINE_MEMBER( irq12_w );
	DECLARE_WRITE_LINE_MEMBER( irq14_w );
	DECLARE_WRITE_LINE_MEMBER( irq15_w );

	DECLARE_WRITE_LINE_MEMBER( drq0_w );
	DECLARE_WRITE_LINE_MEMBER( drq5_w );
	DECLARE_WRITE_LINE_MEMBER( drq6_w );
	DECLARE_WRITE_LINE_MEMBER( drq7_w );

	uint16_t dack16_r(int line);
	void dack16_w(int line,uint16_t data);

	// 16 bit accessors for ISA-defined address spaces
	DECLARE_READ16_MEMBER(prog16_r);
	DECLARE_WRITE16_MEMBER(prog16_w);
	DECLARE_READ16_MEMBER(io16_r);
	DECLARE_WRITE16_MEMBER(io16_w);
	// byte-swapped versions of 16-bit accessors
	DECLARE_READ16_MEMBER(prog16_swap_r);
	DECLARE_WRITE16_MEMBER(prog16_swap_w);
	DECLARE_READ16_MEMBER(io16_swap_r);
	DECLARE_WRITE16_MEMBER(io16_swap_w);

protected:
	// device-level overrides
	virtual void device_start() override;

private:
	// internal state
	devcb_write_line    m_out_irq10_cb;
	devcb_write_line    m_out_irq11_cb;
	devcb_write_line    m_out_irq12_cb;
	devcb_write_line    m_out_irq14_cb;
	devcb_write_line    m_out_irq15_cb;
	devcb_write_line    m_out_drq0_cb;
	devcb_write_line    m_out_drq5_cb;
	devcb_write_line    m_out_drq6_cb;
	devcb_write_line    m_out_drq7_cb;
};


// device type definition
extern const device_type ISA16;

// ======================> device_isa16_card_interface

// class representing interface-specific live isa16 card
class device_isa16_card_interface : public device_isa8_card_interface
{
	friend class isa16_device;
public:
	// construction/destruction
	device_isa16_card_interface(const machine_config &mconfig, device_t &device);
	virtual ~device_isa16_card_interface();
	virtual uint16_t dack16_r(int line);
	virtual void dack16_w(int line,uint16_t data);

	void set_isa_device();
	isa16_device  *m_isa;
};

#endif  /* __ISA_H__ */