-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeccsr.cc
71 lines (57 loc) · 1.93 KB
/
deccsr.cc
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
/* DEC 5000/200 Control/Status Register emulation.
Copyright 2003 Brian R. Gaeke.
This file is part of VMIPS.
VMIPS is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
VMIPS is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along
with VMIPS; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
/* Memory-mapped device representing the Control/Status Register
* in the DEC 5000/200 (KN02).
*/
#include "deccsrreg.h"
#include "deccsr.h"
#include <cstdio>
uint32 DECCSRDevice::update_status_reg (void)
{
return robits | rwbits | ioint;
}
#define CSR_INTERRUPT_PENDING() ((((rwbits & CSR_IOINTEN) >> 16) & (ioint)) != 0)
#define CSR_INTERRUPT_CHECK() do { if (CSR_INTERRUPT_PENDING()) { DeviceInt::assertInt(irq); } else { DeviceInt::deassertInt(irq); } } while (0)
void DECCSRDevice::update_control_reg (uint32 data)
{
rwbits = data & CSR_RW_BITS;
leds = data & CSR_LEDS;
CSR_INTERRUPT_CHECK();
}
uint32
DECCSRDevice::fetch_word (uint32 offset, int mode, DeviceExc *client)
{
uint32 status_reg = update_status_reg ();
/* fprintf (stderr, "CSR status reg read as 0x%x\n", status_reg); */
return status_reg;
}
void
DECCSRDevice::store_word (uint32 offset, uint32 data, DeviceExc *client)
{
/* fprintf (stderr, "CSR control reg written with 0x%x\n", data); */
update_control_reg (data);
}
void
DECCSRDevice::assertInt (uint8 line)
{
ioint |= line;
CSR_INTERRUPT_CHECK();
}
void
DECCSRDevice::deassertInt (uint8 line)
{
ioint &= ~line;
CSR_INTERRUPT_CHECK();
}