First Commit of my working state
[simh.git] / PDP8 / pdp8_tsc.c
1 /* pdp8_tsc.c: PDP-8 ETOS timesharing option board (TSC8-75)
2
3 Copyright (c) 2003-2005, Robert M Supnik
4
5 Permission is hereby granted, free of charge, to any person obtaining a
6 copy of this software and associated documentation files (the "Software"),
7 to deal in the Software without restriction, including without limitation
8 the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 and/or sell copies of the Software, and to permit persons to whom the
10 Software is furnished to do so, subject to the following conditions:
11
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
14
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 ROBERT M SUPNIK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22 Except as contained in this notice, the name of Robert M Supnik shall not be
23 used in advertising or otherwise to promote the sale, use or other dealings
24 in this Software without prior written authorization from Robert M Supnik.
25
26 This module is based on Bernhard Baehr's PDP-8/E simulator
27
28 PDP-8/E Simulator Source Code
29
30 Copyright ) 2001-2003 Bernhard Baehr
31
32 TSC8iots.c - IOTs for the TSC8-75 Board plugin
33
34 This program is free software; you can redistribute it and/or modify
35 it under the terms of the GNU General Public License as published by
36 the Free Software Foundation; either version 2 of the License, or
37 (at your option) any later version.
38
39 This program is distributed in the hope that it will be useful,
40 but WITHOUT ANY WARRANTY; without even the implied warranty of
41 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
42 GNU General Public License for more details.
43
44 You should have received a copy of the GNU General Public License
45 along with this program; if not, write to the Free Software
46 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
47
48 tsc TSC8-75 option board
49 */
50
51 #include "pdp8_defs.h"
52
53 extern int32 int_req;
54 extern int32 SF;
55 extern int32 tsc_ir; /* "ERIOT" */
56 extern int32 tsc_pc; /* "ERTB" */
57 extern int32 tsc_cdf; /* "ECDF" */
58 extern int32 tsc_enb; /* enable */
59
60 #define UNIT_V_SN699 (UNIT_V_UF + 0) /* SN 699 or above */
61 #define UNIT_SN699 (1 << UNIT_V_SN699)
62
63 DEVICE tsc_dev;
64 int32 tsc (int32 IR, int32 AC);
65 t_stat tsc_reset (DEVICE *dptr);
66
67 /* TSC data structures
68
69 tsc_dev TSC device descriptor
70 tsc_unit TSC unit descriptor
71 tsc_reg TSC register list
72 */
73
74 DIB tsc_dib = { DEV_TSC, 1, { &tsc } };
75
76 UNIT tsc_unit = { UDATA (NULL, UNIT_SN699, 0) };
77
78 REG tsc_reg[] = {
79 { ORDATA (IR, tsc_ir, 12) },
80 { ORDATA (PC, tsc_pc, 12) },
81 { FLDATA (CDF, tsc_cdf, 0) },
82 { FLDATA (ENB, tsc_enb, 0) },
83 { FLDATA (INT, int_req, INT_V_TSC) },
84 { NULL }
85 };
86
87 MTAB tsc_mod[] = {
88 { UNIT_SN699, UNIT_SN699, "ESME", "ESME", NULL },
89 { UNIT_SN699, 0, "no ESME", "NOESME", NULL },
90 { 0 }
91 };
92
93 DEVICE tsc_dev = {
94 "TSC", &tsc_unit, tsc_reg, tsc_mod,
95 1, 10, 31, 1, 8, 8,
96 NULL, NULL, &tsc_reset,
97 NULL, NULL, NULL,
98 &tsc_dib, DEV_DISABLE | DEV_DIS
99 };
100
101 /* IOT routine */
102
103 int32 tsc (int32 IR, int32 AC)
104 {
105 switch (IR & 07) { /* decode IR<9:11> */
106
107 case 0: /* ETDS */
108 tsc_enb = 0; /* disable int req */
109 int_req = int_req & ~INT_TSC; /* clear flag */
110 break;
111
112 case 1: /* ESKP */
113 return (int_req & INT_TSC)? IOT_SKP + AC: AC; /* skip on int req */
114
115 case 2: /* ECTF */
116 int_req = int_req & ~INT_TSC; /* clear int req */
117 break;
118
119 case 3: /* ECDF */
120 AC = AC | ((tsc_ir >> 3) & 07); /* read "ERIOT"<6:8> */
121 if (tsc_cdf) AC = AC | IOT_SKP; /* if cdf, skip */
122 tsc_cdf = 0;
123 break;
124
125 case 4: /* ERTB */
126 return tsc_pc;
127
128 case 5: /* ESME */
129 if (tsc_unit.flags & UNIT_SN699) { /* enabled? */
130 if (tsc_cdf && ((tsc_ir & 070) >> 3) == (SF & 07)) {
131 AC = AC | IOT_SKP;
132 tsc_cdf = 0;
133 }
134 }
135 break;
136
137 case 6: /* ERIOT */
138 return tsc_ir;
139
140 case 7: /* ETEN */
141 tsc_enb = 1;
142 break;
143 } /* end switch */
144
145 return AC;
146 }
147
148 /* Reset routine */
149
150 t_stat tsc_reset (DEVICE *dptr)
151 {
152 tsc_ir = 0;
153 tsc_pc = 0;
154 tsc_cdf = 0;
155 tsc_enb = 0;
156 int_req = int_req & ~INT_TSC;
157 return SCPE_OK;
158 }