summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/idpartner/bus.h
blob: 7a2272c200413a93056c96e6c3434ed7653d312d (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
// license:BSD-3-Clause
// copyright-holders:Miodrag Milanovic
/*********************************************************************

        Iskra Delta Partner BUS

**********************************************************************

    Pinout:

                      *********
        GND       1   * . | . *    1 GND
        GND       2   * . | . *    2 GND
        -12V      3   * . | . *    3 -12V
        +5V       4   * . | . *    4 +5V
        +5V       5   * . | . *    5 +5V
        +12V      6   * . | . *    6 +12V
        NC        7   * . | . *    7 NC
        NC        8   * . | . *    8 IEDB
        /BUSACKB  9   * . | . *    9 /DMARQ
        NC       10   * . | . *   10 NC
        /RESETB  11   * . | . *   11 NC
        NC       12   * . | . *   12 /M1B
        /MREQB   13   * . | . *   13 /NMI
        NC       14   * . | . *   14 /BUSRQ
        /INTB    15   * . | . *   15 /HALTB
        /WAITB   16   * . | . *   16 /RDB
        phiB     17   * . | . *   17 A0B
        /IORQB   18   * . | . *   18 A1B
        /WTB     19   * . | . *   19 A2B
        /RFSHB   20   * . | . *   20 A3B
        NC       21   * . | . *   21 A4B
        /BINB    22   * . | . *   22 A5B
        NC       23   * . | . *   23 A6B
        NC       24   * . | . *   24 A7B
        /D0B     25   * . | . *   25 NC
        /D1B     26   * . | . *   26 NC
        /D2B     27   * . | . *   27 NC
        /D3B     28   * . | . *   28 NC
        /D4B     29   * . | . *   29 NC
        /D5B     30   * . | . *   30 NC
        /D6B     31   * . | . *   31 NC
        /D7B     32   * . | . *   32 NC
                      *********

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

#ifndef MAME_BUS_IDPARTNER_BUS_H
#define MAME_BUS_IDPARTNER_BUS_H

#pragma once

namespace bus::idpartner {

class bus_device;
class device_exp_card_interface;

class bus_connector_device : public device_t, public device_single_card_slot_interface<device_exp_card_interface>
{
public:
	// construction/destruction
	template <typename T, typename U>
	bus_connector_device(const machine_config &mconfig, const char *tag, device_t *owner, T &&bus_tag, U &&opts, const char *dflt)
		: bus_connector_device(mconfig, tag, owner)
	{
		set_options(std::forward<U>(opts), dflt, false);
		m_bus.set_tag(std::forward<T>(bus_tag));
	}

	bus_connector_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock = 0);

protected:
	// device_t implementation
	virtual void device_resolve_objects() override ATTR_COLD;
	virtual void device_start() override ATTR_COLD;

	// configuration
	required_device<bus_device> m_bus;
};

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

	// inline configuration
	template <typename T> void set_io_space(T &&tag, int spacenum) { m_io.set_tag(std::forward<T>(tag), spacenum); }

	// callbacks
	auto int_handler() { return m_int_handler.bind(); }
	auto nmi_handler() { return m_nmi_handler.bind(); }
	auto drq_handler() { return m_drq_handler.bind(); }

	// called from expansion device
	void int_w(int state) { m_int_handler(state); }
	void nmi_w(int state) { m_nmi_handler(state); }
	void drq_w(int state) { m_drq_handler(state); }

	address_space &io() { return *m_io; }

private:
	// device_t implementation
	virtual void device_start() override ATTR_COLD;
	virtual void device_reset() override ATTR_COLD;

	// internal state
	required_address_space m_io;

	devcb_write_line m_int_handler;
	devcb_write_line m_nmi_handler;
	devcb_write_line m_drq_handler;
};

// ======================> device_exp_card_interface

class device_exp_card_interface : public device_interface
{
protected:
	// construction/destruction
	device_exp_card_interface(const machine_config &mconfig, device_t &device);

public:
	// inline configuration
	void set_bus(bus_device *bus) { m_bus = bus; }

protected:
	bus_device *m_bus;
};

} // namespace bus::idpartner

DECLARE_DEVICE_TYPE_NS(IDPARTNER_BUS, bus::idpartner, bus_device)
DECLARE_DEVICE_TYPE_NS(IDPARTNER_BUS_CONNECTOR, bus::idpartner, bus_connector_device)

void idpartner_exp_devices(device_slot_interface &device);

#endif // MAME_BUS_IDPARTNER_BUS_H