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