~ubuntu-branches/ubuntu/utopic/simh/utopic

« back to all changes in this revision

Viewing changes to NOVA/nova_tt.c

  • Committer: Bazaar Package Importer
  • Author(s): Vince Mulhollon
  • Date: 2004-04-20 20:01:26 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040420200126-ehsuleda8xcgi51h
Tags: 3.2.0-1
New upstream 3.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* nova_tt.c: NOVA console terminal simulator
 
2
 
 
3
   Copyright (c) 1993-2004, 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
 
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.
 
25
 
 
26
   tti          terminal input
 
27
   tto          terminal output
 
28
 
 
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
 
38
*/
 
39
 
 
40
#include "nova_defs.h"
 
41
 
 
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;
 
45
 
 
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);
 
53
 
 
54
/* TTI data structures
 
55
 
 
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
 
60
*/
 
61
 
 
62
DIB tti_dib = { DEV_TTI, INT_TTI, PI_TTI, &tti };
 
63
 
 
64
UNIT tti_unit = { UDATA (&tti_svc, 0, 0), KBD_POLL_WAIT };
 
65
 
 
66
REG tti_reg[] = {
 
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 },
 
74
        { NULL }  };
 
75
 
 
76
MTAB ttx_mod[] = {
 
77
        { UNIT_DASHER, 0, "ANSI", "ANSI", &ttx_setmod },
 
78
        { UNIT_DASHER, UNIT_DASHER, "Dasher", "DASHER", &ttx_setmod },
 
79
        { 0 }  };
 
80
 
 
81
DEVICE tti_dev = {
 
82
        "TTI", &tti_unit, tti_reg, ttx_mod,
 
83
        1, 10, 31, 1, 8, 8,
 
84
        NULL, NULL, &tti_reset,
 
85
        NULL, NULL, NULL,
 
86
        &tti_dib, 0 };
 
87
 
 
88
/* TTO data structures
 
89
 
 
90
   tto_dev      TTO device descriptor
 
91
   tto_unit     TTO unit descriptor
 
92
   tto_reg      TTO register list
 
93
*/
 
94
 
 
95
DIB tto_dib = { DEV_TTO, INT_TTO, PI_TTO, &tto };
 
96
 
 
97
UNIT tto_unit = { UDATA (&tto_svc, 0, 0), SERIAL_OUT_WAIT };
 
98
 
 
99
REG tto_reg[] = {
 
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 },
 
107
        { NULL }  };
 
108
 
 
109
DEVICE tto_dev = {
 
110
        "TTO", &tto_unit, tto_reg, ttx_mod,
 
111
        1, 10, 31, 1, 8, 8,
 
112
        NULL, NULL, &tto_reset,
 
113
        NULL, NULL, NULL,
 
114
        &tto_dib, 0 };
 
115
 
 
116
/* Terminal input: IOT routine */
 
117
 
 
118
int32 tti (int32 pulse, int32 code, int32 AC)
 
119
{
 
120
int32 iodata;
 
121
 
 
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;
 
128
        break;
 
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 */
 
134
return iodata;
 
135
}
 
136
 
 
137
/* Unit service */
 
138
 
 
139
t_stat tti_svc (UNIT *uptr)
 
140
{
 
141
int32 temp;
 
142
 
 
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;
 
152
return SCPE_OK;
 
153
}
 
154
 
 
155
/* Reset routine */
 
156
 
 
157
t_stat tti_reset (DEVICE *dptr)
 
158
{
 
159
tti_unit.buf = 0;
 
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 */
 
164
return SCPE_OK;
 
165
}
 
166
 
 
167
/* Terminal output: IOT routine */
 
168
 
 
169
int32 tto (int32 pulse, int32 code, int32 AC)
 
170
{
 
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 */
 
178
        break;
 
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 */
 
185
return 0;
 
186
}
 
187
 
 
188
/* Unit service */
 
189
 
 
190
t_stat tto_svc (UNIT *uptr)
 
191
{
 
192
int32 c;
 
193
t_stat r;
 
194
 
 
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;
 
204
return SCPE_OK;
 
205
}
 
206
 
 
207
/* Reset routine */
 
208
 
 
209
t_stat tto_reset (DEVICE *dptr)
 
210
{
 
211
tto_unit.buf = 0;
 
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 */
 
216
return SCPE_OK;
 
217
}
 
218
 
 
219
t_stat ttx_setmod (UNIT *uptr, int32 val, char *cptr, void *desc)
 
220
{
 
221
tti_unit.flags = (tti_unit.flags & ~UNIT_DASHER) | val;
 
222
tto_unit.flags = (tto_unit.flags & ~UNIT_DASHER) | val;
 
223
return SCPE_OK;
 
224
}