forked from virtualagc/virtualagc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathINT.cpp
103 lines (103 loc) · 2.3 KB
/
INT.cpp
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
/****************************************************************************
* INT - PRIORITY INTERRUPT subsystem
*
* AUTHOR: John Pultorak
* DATE: 9/22/01
* FILE: INT.cpp
*
* NOTES: see header file.
*
*****************************************************************************
*/
#include "INT.h"
#include "SEQ.h"
#include "BUS.h"
regRPCELL INT::register_RPCELL; // latches the selected priority interrupt vector (1-5)
regINHINT1 INT::register_INHINT1; // inhibits interrupts for 1 instruction (on WOVI)
regINHINT INT::register_INHINT; // inhibits interrupts on INHINT, reenables on RELINT
// NOTE: the priority cells (rupt[]) are indexed 0-4, but stored in the
// RPCELL register as 1-5; (0 in RPCELL means no interrupt)
unsigned INT::rupt[5];
bool
INT::IRQ()
{
if ( INT::getPriorityRupt() // if interrupt requested
&& INT::register_RPCELL.read() == 0// and interrupt not currently being serviced
&& INT::register_INHINT1.read() == 0// and interrupt not inhibited for 1 instruction
&& INT::register_INHINT.read() == 0)// and interrupts enabled (RELINT)
{
return true;
}
return false;
}
void
INT::resetAllRupt()
{
for (int i = 0; i < 5; i++)
{
rupt[i] = 0;
}
}
// interrupt vector; outputs 1-5 (decimal) == vector; 0 == no interrupt
unsigned
INT::getPriorityRupt()
{
for (int i = 0; i < 5; i++)
{
if (rupt[i])
return i + 1;
}
return 0;
}
void
INT::execRP_RRPA()
{
BUS::glbl_READ_BUS = 02000 + (register_RPCELL.read() << 2);
}
// latches the selected priority interrupt vector (1-5)
// also inhibits additional interrupts while an interrupt is being processed
void
INT::execWP_GENRST()
{
register_RPCELL.write(0);
register_INHINT.write(1);
resetAllRupt();
}
void
INT::execWP_RPT()
{
register_RPCELL.write(INT::getPriorityRupt());
}
void
INT::execWP_KRPT()
{
INT::rupt[register_RPCELL.read() - 1] = 0;
}
void
INT::execWP_CLRP()
{
register_RPCELL.write(0);
}
// INHINT1: inhibits interrupts for 1 instruction (on WOVI)
void
INT::execWP_WOVI()
{
if (BUS::testOverflow(BUS::glbl_WRITE_BUS) != NO_OVF)
register_INHINT1.write(1);
}
void
INT::execWP_CLINH1()
{
register_INHINT1.write(0);
}
// INHINT: inhibits interrupts on INHINT, reenables on RELINT
void
INT::execWP_INH()
{
register_INHINT.write(1);
}
void
INT::execWP_CLINH()
{
register_INHINT.write(0);
}