1
/* nova_tt.c: NOVA console terminal simulator
3
Copyright (c) 1993-2004, Robert M. Supnik
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:
12
The above copyright notice and this permission notice shall be included in
13
all copies or substantial portions of the Software.
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.
22
Except as contained in this notice, the name of Robert M Supnik shall not
23
be 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.
29
29-Dec-03 RMS Added console backpressure support
30
25-Apr-03 RMS Revised for extended file support
31
05-Jan-02 RMS Fixed calling sequence for setmod
32
03-Oct-02 RMS Added DIBs
33
30-May-02 RMS Widened POS to 32b
34
30-Nov-01 RMS Added extended SET/SHOW support
35
17-Sep-01 RMS Removed multiconsole support
36
07-Sep-01 RMS Moved function prototypes
37
31-May-01 RMS Added multiconsole support
40
#include "nova_defs.h"
42
#define UNIT_V_DASHER (UNIT_V_UF + 0) /* Dasher mode */
43
#define UNIT_DASHER (1 << UNIT_V_DASHER)
44
extern int32 int_req, dev_busy, dev_done, dev_disable;
46
int32 tti (int32 pulse, int32 code, int32 AC);
47
int32 tto (int32 pulse, int32 code, int32 AC);
48
t_stat tti_svc (UNIT *uptr);
49
t_stat tto_svc (UNIT *uptr);
50
t_stat tti_reset (DEVICE *dptr);
51
t_stat tto_reset (DEVICE *dptr);
52
t_stat ttx_setmod (UNIT *uptr, int32 val, char *cptr, void *desc);
54
/* TTI data structures
56
tti_dev TTI device descriptor
57
tti_unit TTI unit descriptor
58
tti_reg TTI register list
59
ttx_mod TTI/TTO modifiers list
62
DIB tti_dib = { DEV_TTI, INT_TTI, PI_TTI, &tti };
64
UNIT tti_unit = { UDATA (&tti_svc, 0, 0), KBD_POLL_WAIT };
67
{ ORDATA (BUF, tti_unit.buf, 8) },
68
{ FLDATA (BUSY, dev_busy, INT_V_TTI) },
69
{ FLDATA (DONE, dev_done, INT_V_TTI) },
70
{ FLDATA (DISABLE, dev_disable, INT_V_TTI) },
71
{ FLDATA (INT, int_req, INT_V_TTI) },
72
{ DRDATA (POS, tti_unit.pos, T_ADDR_W), PV_LEFT },
73
{ DRDATA (TIME, tti_unit.wait, 24), REG_NZ + PV_LEFT },
77
{ UNIT_DASHER, 0, "ANSI", "ANSI", &ttx_setmod },
78
{ UNIT_DASHER, UNIT_DASHER, "Dasher", "DASHER", &ttx_setmod },
82
"TTI", &tti_unit, tti_reg, ttx_mod,
84
NULL, NULL, &tti_reset,
88
/* TTO data structures
90
tto_dev TTO device descriptor
91
tto_unit TTO unit descriptor
92
tto_reg TTO register list
95
DIB tto_dib = { DEV_TTO, INT_TTO, PI_TTO, &tto };
97
UNIT tto_unit = { UDATA (&tto_svc, 0, 0), SERIAL_OUT_WAIT };
100
{ ORDATA (BUF, tto_unit.buf, 8) },
101
{ FLDATA (BUSY, dev_busy, INT_V_TTO) },
102
{ FLDATA (DONE, dev_done, INT_V_TTO) },
103
{ FLDATA (DISABLE, dev_disable, INT_V_TTO) },
104
{ FLDATA (INT, int_req, INT_V_TTO) },
105
{ DRDATA (POS, tto_unit.pos, T_ADDR_W), PV_LEFT },
106
{ DRDATA (TIME, tto_unit.wait, 24), PV_LEFT },
110
"TTO", &tto_unit, tto_reg, ttx_mod,
112
NULL, NULL, &tto_reset,
116
/* Terminal input: IOT routine */
118
int32 tti (int32 pulse, int32 code, int32 AC)
122
iodata = (code == ioDIA)? tti_unit.buf & 0377: 0;
123
switch (pulse) { /* decode IR<8:9> */
124
case iopS: /* start */
125
dev_busy = dev_busy | INT_TTI; /* set busy */
126
dev_done = dev_done & ~INT_TTI; /* clear done, int */
127
int_req = int_req & ~INT_TTI;
129
case iopC: /* clear */
130
dev_busy = dev_busy & ~INT_TTI; /* clear busy */
131
dev_done = dev_done & ~INT_TTI; /* clear done, int */
132
int_req = int_req & ~INT_TTI;
133
break; } /* end switch */
139
t_stat tti_svc (UNIT *uptr)
143
sim_activate (&tti_unit, tti_unit.wait); /* continue poll */
144
if ((temp = sim_poll_kbd ()) < SCPE_KFLAG) return temp; /* no char or error? */
145
tti_unit.buf = temp & 0177;
146
if ((tti_unit.flags & UNIT_DASHER) && (tti_unit.buf == '\r'))
147
tti_unit.buf = '\n'; /* Dasher: cr -> nl */
148
dev_busy = dev_busy & ~INT_TTI; /* clear busy */
149
dev_done = dev_done | INT_TTI; /* set done */
150
int_req = (int_req & ~INT_DEV) | (dev_done & ~dev_disable);
151
tti_unit.pos = tti_unit.pos + 1;
157
t_stat tti_reset (DEVICE *dptr)
160
dev_busy = dev_busy & ~INT_TTI; /* clear busy */
161
dev_done = dev_done & ~INT_TTI; /* clear done, int */
162
int_req = int_req & ~INT_TTI;
163
sim_activate (&tti_unit, tti_unit.wait); /* activate unit */
167
/* Terminal output: IOT routine */
169
int32 tto (int32 pulse, int32 code, int32 AC)
171
if (code == ioDOA) tto_unit.buf = AC & 0377;
172
switch (pulse) { /* decode IR<8:9> */
173
case iopS: /* start */
174
dev_busy = dev_busy | INT_TTO; /* set busy */
175
dev_done = dev_done & ~INT_TTO; /* clear done, int */
176
int_req = int_req & ~INT_TTO;
177
sim_activate (&tto_unit, tto_unit.wait); /* activate unit */
179
case iopC: /* clear */
180
dev_busy = dev_busy & ~INT_TTO; /* clear busy */
181
dev_done = dev_done & ~INT_TTO; /* clear done, int */
182
int_req = int_req & ~INT_TTO;
183
sim_cancel (&tto_unit); /* deactivate unit */
184
break; } /* end switch */
190
t_stat tto_svc (UNIT *uptr)
195
c = tto_unit.buf & 0177;
196
if ((tto_unit.flags & UNIT_DASHER) && (c == 031)) c = '\b';
197
if ((r = sim_putchar_s (c)) != SCPE_OK) { /* output; error? */
198
sim_activate (uptr, uptr->wait); /* try again */
199
return ((r == SCPE_STALL)? SCPE_OK: r); } /* !stall? report */
200
dev_busy = dev_busy & ~INT_TTO; /* clear busy */
201
dev_done = dev_done | INT_TTO; /* set done */
202
int_req = (int_req & ~INT_DEV) | (dev_done & ~dev_disable);
203
tto_unit.pos = tto_unit.pos + 1;
209
t_stat tto_reset (DEVICE *dptr)
212
dev_busy = dev_busy & ~INT_TTO; /* clear busy */
213
dev_done = dev_done & ~INT_TTO; /* clear done, int */
214
int_req = int_req & ~INT_TTO;
215
sim_cancel (&tto_unit); /* deactivate unit */
219
t_stat ttx_setmod (UNIT *uptr, int32 val, char *cptr, void *desc)
221
tti_unit.flags = (tti_unit.flags & ~UNIT_DASHER) | val;
222
tto_unit.flags = (tto_unit.flags & ~UNIT_DASHER) | val;