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
|
// license:BSD-3-Clause
// copyright-holders:Nigel Barnes
/**********************************************************************
Acorn AKA25 Ethernet
http://chrisacorns.computinghistory.org.uk/32bit_UpgradesA2G/Acorn_AKA25_Ethernet.html
**********************************************************************/
#include "emu.h"
#include "ether1.h"
#include "machine/i82586.h"
namespace {
class arc_ether1_aka25_device :
public device_t,
public device_archimedes_podule_interface
{
public:
// construction/destruction
arc_ether1_aka25_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock);
protected:
// device-level overrides
virtual void device_start() override;
virtual void device_reset() override;
// optional information overrides
virtual void device_add_mconfig(machine_config &config) override;
virtual const tiny_rom_entry *device_rom_region() const override;
// device_archimedes_podule_interface overrides
virtual void ioc_map(address_map &map) override;
private:
required_memory_region m_podule_rom;
required_shared_ptr<u16> m_ram;
required_device<i82586_device> m_lance;
void lan_map(address_map &map);
void checksum();
void control_w(u8 data);
u8 m_rom_page;
u8 m_ram_page;
};
void arc_ether1_aka25_device::ioc_map(address_map &map)
{
map(0x0000, 0x003f).lr8(NAME([this](offs_t offset) { return m_podule_rom->base()[offset | ((m_rom_page << 4) & 0x1f)]; })).umask32(0x000000ff);
map(0x0000, 0x0000).lw8(NAME([this](u8 data) { m_ram_page = data & 0x0f; }));
map(0x0004, 0x0004).w(FUNC(arc_ether1_aka25_device::control_w));
map(0x2000, 0x3fff).lrw8(NAME([this](offs_t offset) { return m_ram[offset | (m_ram_page << 11)]; }), NAME([this](offs_t offset, u16 data) { m_ram[offset | (m_ram_page << 11)] = data; })).umask32(0x0000ffff);
}
void arc_ether1_aka25_device::lan_map(address_map &map)
{
map(0x000000, 0x00ffff).mirror(0xff0000).ram().share("ram");
}
//-------------------------------------------------
// device_add_mconfig - add device configuration
//-------------------------------------------------
void arc_ether1_aka25_device::device_add_mconfig(machine_config &config)
{
I82586(config, m_lance, 20_MHz_XTAL / 2);
m_lance->out_irq_cb().set([this](int state) { m_rom_page = state; set_pirq(state); });
m_lance->set_addrmap(0, &arc_ether1_aka25_device::lan_map);
}
//-------------------------------------------------
// ROM( ether1_aka25 )
//-------------------------------------------------
ROM_START( ether1_aka25 )
ROM_REGION(0x20, "podule_rom", 0)
ROM_LOAD("27ls19.bin", 0x00, 0x20, CRC(e034ae68) SHA1(9a9404028d166d9cbb466513f514be5d3ea77956))
ROM_END
const tiny_rom_entry *arc_ether1_aka25_device::device_rom_region() const
{
return ROM_NAME( ether1_aka25 );
}
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
//-------------------------------------------------
// arc_ether1_aka25_device - constructor
//-------------------------------------------------
arc_ether1_aka25_device::arc_ether1_aka25_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock)
: device_t(mconfig, ARC_ETHER1_AKA25, tag, owner, clock)
, device_archimedes_podule_interface(mconfig, *this)
, m_podule_rom(*this, "podule_rom")
, m_ram(*this, "ram")
, m_lance(*this, "lance")
, m_rom_page(0)
, m_ram_page(0)
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void arc_ether1_aka25_device::device_start()
{
checksum();
save_item(NAME(m_rom_page));
save_item(NAME(m_ram_page));
}
//-------------------------------------------------
// device_reset - device-specific reset
//-------------------------------------------------
void arc_ether1_aka25_device::device_reset()
{
m_rom_page = 0x00;
m_ram_page = 0x00;
}
//**************************************************************************
// IMPLEMENTATION
//**************************************************************************
void arc_ether1_aka25_device::checksum()
{
// PROM CRC calculation (from A500/R200 Service Manual)
u32 chk = 0xffffffff;
for (int i = 0; i < 28; i++)
{
// CRC on bytes 0..28
u8 byte = m_podule_rom->base()[i];
for (int j = 0; j < 8; j++)
{
if (((byte & 1) ^ (chk >> 31)) != 0)
chk = (chk << 1) ^ (0x04c11db7);
else
chk = (chk << 1);
byte = byte >> 1;
}
}
// get CRC from PROM
u32 checksum = (m_podule_rom->base()[31] << 24) | (m_podule_rom->base()[30] << 16) | (m_podule_rom->base()[29] << 8) | (m_podule_rom->base()[28] << 0);
// test to see if the same
logerror("checksum: %08x %s\n", chk, checksum == chk ? "Pass" : "Fail");
}
void arc_ether1_aka25_device::control_w(u8 data)
{
m_lance->reset_w(BIT(data, 0)); // b0 Reset
//m_sia->lpbk(BIT(data, 1)); // b1 Loop-Back
m_lance->ca(BIT(data, 2)); // b2 Channel Attention
if (BIT(data, 3)) set_pirq(0); // b3 Clear Interrupt
}
} // anonymous namespace
//**************************************************************************
// DEVICE DEFINITIONS
//**************************************************************************
DEFINE_DEVICE_TYPE_PRIVATE(ARC_ETHER1_AKA25, device_archimedes_podule_interface, arc_ether1_aka25_device, "arc_ether1_aka25", "Acorn AKA25 Ethernet")
|