1 /* DEC 5000/200 Control/Status Register emulation.
2    Copyright 2003 Brian R. Gaeke.
3 
4 This file is part of VMIPS.
5 
6 VMIPS is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2 of the License, or (at your
9 option) any later version.
10 
11 VMIPS is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 for more details.
15 
16 You should have received a copy of the GNU General Public License along
17 with VMIPS; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
19 
20 /* Memory-mapped device representing the Control/Status Register
21  * in the DEC 5000/200 (KN02).
22  */
23 
24 #include "deccsrreg.h"
25 #include "deccsr.h"
26 #include <cstdio>
27 
update_status_reg(void)28 uint32 DECCSRDevice::update_status_reg (void)
29 {
30   return robits | rwbits | ioint;
31 }
32 
33 #define CSR_INTERRUPT_PENDING() ((((rwbits & CSR_IOINTEN) >> 16) & (ioint)) != 0)
34 #define CSR_INTERRUPT_CHECK() do { if (CSR_INTERRUPT_PENDING()) { DeviceInt::assertInt(irq); } else { DeviceInt::deassertInt(irq); } } while (0)
35 
update_control_reg(uint32 data)36 void DECCSRDevice::update_control_reg (uint32 data)
37 {
38   rwbits = data & CSR_RW_BITS;
39   leds = data & CSR_LEDS;
40   CSR_INTERRUPT_CHECK();
41 }
42 
43 uint32
fetch_word(uint32 offset,int mode,DeviceExc * client)44 DECCSRDevice::fetch_word (uint32 offset, int mode, DeviceExc *client)
45 {
46   uint32 status_reg = update_status_reg ();
47   /* fprintf (stderr, "CSR status reg read as 0x%x\n", status_reg); */
48   return status_reg;
49 }
50 
51 void
store_word(uint32 offset,uint32 data,DeviceExc * client)52 DECCSRDevice::store_word (uint32 offset, uint32 data, DeviceExc *client)
53 {
54   /* fprintf (stderr, "CSR control reg written with 0x%x\n", data); */
55   update_control_reg (data);
56 }
57 
58 void
assertInt(uint8 line)59 DECCSRDevice::assertInt (uint8 line)
60 {
61   ioint |= line;
62   CSR_INTERRUPT_CHECK();
63 }
64 
65 void
deassertInt(uint8 line)66 DECCSRDevice::deassertInt (uint8 line)
67 {
68   ioint &= ~line;
69   CSR_INTERRUPT_CHECK();
70 }
71 
72