summaryrefslogtreecommitdiffstatshomepage
path: root/src/mess/machine/nubus.h
blob: 532532d35ad8e60b1a172e342cf4cb3cee7fcd6f (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
/***************************************************************************

  nubus.h - NuBus bus and card emulation

  by R. Belmont, based heavily on Miodrag Milanovic's ISA8/16 implementation

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

#pragma once

#ifndef __NUBUS_H__
#define __NUBUS_H__

#include "emu.h"


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

#define MCFG_NUBUS_BUS_ADD(_tag, _cputag, _config) \
    MCFG_DEVICE_ADD(_tag, NUBUS, 0) \
    MCFG_DEVICE_CONFIG(_config) \
    nubus_device::static_set_cputag(*device, _cputag); \

#define MCFG_NUBUS_SLOT_ADD(_nbtag, _tag, _slot_intf, _def_slot, _def_inp) \
    MCFG_DEVICE_ADD(_tag, NUBUS_SLOT, 0) \
	MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, _def_inp, false) \
	nubus_slot_device::static_set_nubus_slot(*device, _nbtag, _tag); \

#define MCFG_NUBUS_SLOT_REMOVE(_tag)    \
    MCFG_DEVICE_REMOVE(_tag)

#define MCFG_NUBUS_ONBOARD_ADD(_nbtag, _tag, _dev_type, _def_inp) \
    MCFG_DEVICE_ADD(_tag, _dev_type, 0) \
	MCFG_DEVICE_INPUT_DEFAULTS(_def_inp) \
	device_nubus_card_interface::static_set_nubus_tag(*device, _nbtag, _tag);

#define MCFG_NUBUS_BUS_REMOVE(_tag) \
    MCFG_DEVICE_REMOVE(_tag)

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

class nubus_device;

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

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

    // inline configuration
    static void static_set_nubus_slot(device_t &device, const char *tag, const char *slottag);
protected:
	// configuration
	const char *m_nubus_tag, *m_nubus_slottag;
};

// device type definition
extern const device_type NUBUS_SLOT;

// ======================> nbbus_interface

struct nbbus_interface
{
    devcb_write_line	m_out_irq9_cb;
    devcb_write_line	m_out_irqa_cb;
    devcb_write_line	m_out_irqb_cb;
    devcb_write_line	m_out_irqc_cb;
    devcb_write_line	m_out_irqd_cb;
    devcb_write_line	m_out_irqe_cb;
};

class device_nubus_card_interface;
// ======================> nubus_device
class nubus_device : public device_t,
                    public nbbus_interface
{
public:
	// construction/destruction
	nubus_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
	nubus_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock);
	// inline configuration
	static void static_set_cputag(device_t &device, const char *tag);

	void add_nubus_card(device_nubus_card_interface *card);
    void install_device(offs_t start, offs_t end, read8_delegate rhandler, write8_delegate whandler, UINT32 mask=0xffffffff);
    void install_device(offs_t start, offs_t end, read16_delegate rhandler, write16_delegate whandler, UINT32 mask=0xffffffff);
    void install_device(offs_t start, offs_t end, read32_delegate rhandler, write32_delegate whandler, UINT32 mask=0xffffffff);
    void install_readonly_device(offs_t start, offs_t end, read32_delegate rhandler, UINT32 mask=0xffffffff);
    void install_writeonly_device(offs_t start, offs_t end, write32_delegate whandler, UINT32 mask=0xffffffff);
	void install_bank(offs_t start, offs_t end, offs_t mask, offs_t mirror, const char *tag, UINT8 *data);
    void set_irq_line(int slot, int state);

	DECLARE_WRITE_LINE_MEMBER( irq9_w );
	DECLARE_WRITE_LINE_MEMBER( irqa_w );
	DECLARE_WRITE_LINE_MEMBER( irqb_w );
	DECLARE_WRITE_LINE_MEMBER( irqc_w );
	DECLARE_WRITE_LINE_MEMBER( irqd_w );
	DECLARE_WRITE_LINE_MEMBER( irqe_w );

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

	// internal state
	device_t   *m_maincpu;

	devcb_resolved_write_line	m_out_irq9_func;
	devcb_resolved_write_line	m_out_irqa_func;
	devcb_resolved_write_line	m_out_irqb_func;
	devcb_resolved_write_line	m_out_irqc_func;
	devcb_resolved_write_line	m_out_irqd_func;
	devcb_resolved_write_line	m_out_irqe_func;

	simple_list<device_nubus_card_interface> m_device_list;
	const char *m_cputag;
};


// device type definition
extern const device_type NUBUS;

// ======================> device_nubus_card_interface

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

	device_nubus_card_interface *next() const { return m_next; }

	void set_nubus_device();

    // helper functions for card devices
    void install_declaration_rom(device_t *dev, const char *romregion, bool mirror_all_mb = false, bool reverse_rom = false);
    void install_bank(offs_t start, offs_t end, offs_t mask, offs_t mirror, const char *tag, UINT8 *data);

    UINT32 get_slotspace() { return 0xf0000000 | (m_slot<<24); }
    UINT32 get_super_slotspace() { return m_slot<<28; }

    void raise_slot_irq() { m_nubus->set_irq_line(m_slot, ASSERT_LINE); }
    void lower_slot_irq() { m_nubus->set_irq_line(m_slot, CLEAR_LINE); }

    // inline configuration
    static void static_set_nubus_tag(device_t &device, const char *tag, const char *slottag);
public:
	nubus_device  *m_nubus;
    const char *m_nubus_tag, *m_nubus_slottag;
    int m_slot;
	device_nubus_card_interface *m_next;
};

#endif  /* __NUBUS_H__ */