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 #if !defined(SIM_TAPE_H_)
40 # define SIM_TAPE_H_ 0
41
42
43
44 typedef uint32 t_mtrlnt;
45
46 # define MTR_TMK 0x00000000
47 # define MTR_EOM 0xFFFFFFFF
48 # define MTR_GAP 0xFFFFFFFE
49 # define MTR_RRGAP 0xFFFFFFFF
50 # define MTR_FHGAP 0xFFFEFFFF
51 # define MTR_RHGAP 0xFFFF0000
52 # define MTR_M_RHGAP (~0x000080FF)
53 # define MTR_MAXLEN 0x00FFFFFF
54 # define MTR_ERF 0x80000000
55 # define MTR_F(x) ((x) & MTR_ERF)
56 # define MTR_L(x) ((x) & ~MTR_ERF)
57
58
59
60 typedef uint16 t_tpclnt;
61
62
63
64 # define P7B_SOR 0x80
65 # define P7B_PAR 0x40
66 # define P7B_DATA 0x3F
67 # define P7B_DPAR (P7B_PAR|P7B_DATA)
68 # define P7B_EOF 0x0F
69
70 # define TPC_TMK 0x0000
71
72
73
74 # define MTUF_V_PNU (UNIT_V_UF + 0)
75 # define MTUF_V_WLK (UNIT_V_UF + 1)
76 # define MTUF_V_FMT (UNIT_V_UF + 2)
77 # define MTUF_W_FMT 3
78 # define MTUF_N_FMT (1u << MTUF_W_FMT)
79 # define MTUF_M_FMT ((1u << MTUF_W_FMT) - 1)
80 # define MTUF_F_STD 0
81 # define MTUF_F_E11 1
82 # define MTUF_F_TPC 2
83 # define MTUF_F_P7B 3
84 # define MUTF_F_TDF 4
85 # define MTUF_V_UF (MTUF_V_FMT + MTUF_W_FMT)
86 # define MTUF_PNU (1u << MTUF_V_PNU)
87 # define MTUF_WLK (1u << MTUF_V_WLK)
88 # define MTUF_FMT (MTUF_M_FMT << MTUF_V_FMT)
89 # define MTUF_WRP (MTUF_WLK | UNIT_RO)
90
91 # define MT_F_STD (MTUF_F_STD << MTUF_V_FMT)
92 # define MT_F_E11 (MTUF_F_E11 << MTUF_V_FMT)
93 # define MT_F_TPC (MTUF_F_TPC << MTUF_V_FMT)
94 # define MT_F_P7B (MTUF_F_P7B << MTUF_V_FMT)
95 # define MT_F_TDF (MTUF_F_TDF << MTUF_V_FMT)
96
97 # define MT_SET_PNU(u) (u)->flags = (u)->flags | MTUF_PNU
98 # define MT_CLR_PNU(u) (u)->flags = (u)->flags & ~MTUF_PNU
99 # define MT_TST_PNU(u) ((u)->flags & MTUF_PNU)
100 # define MT_GET_FMT(u) (((u)->flags >> MTUF_V_FMT) & MTUF_M_FMT)
101
102
103 # define MTPOS_V_REW 3
104 # define MTPOS_M_REW (1u << MTPOS_V_REW)
105 # define MTPOS_V_REV 2
106 # define MTPOS_M_REV (1u << MTPOS_V_REV)
107 # define MTPOS_V_OBJ 1
108 # define MTPOS_M_OBJ (1u << MTPOS_V_OBJ)
109 # define MTPOS_V_DLE 4
110 # define MTPOS_M_DLE (1u << MTPOS_V_DLE)
111
112
113
114 # define MT_DENS_NONE 0
115 # define MT_DENS_200 1
116 # define MT_DENS_556 2
117 # define MT_DENS_800 3
118 # define MT_DENS_1600 4
119 # define MT_DENS_6250 5
120
121 # define MTVF_DENS_MASK (((1u << UNIT_S_DF_TAPE) - 1) << UNIT_V_DF_TAPE)
122 # define MT_DENS(f) (((f) & MTVF_DENS_MASK) >> UNIT_V_DF_TAPE)
123
124 # define MT_NONE_VALID (1u << MT_DENS_NONE)
125 # define MT_200_VALID (1u << MT_DENS_200)
126 # define MT_556_VALID (1u << MT_DENS_556)
127 # define MT_800_VALID (1u << MT_DENS_800)
128 # define MT_1600_VALID (1u << MT_DENS_1600)
129 # define MT_6250_VALID (1u << MT_DENS_6250)
130
131
132
133 # define MTSE_OK 0
134 # define MTSE_TMK 1
135 # define MTSE_UNATT 2
136 # define MTSE_IOERR 3
137 # define MTSE_INVRL 4
138 # define MTSE_FMT 5
139 # define MTSE_BOT 6
140 # define MTSE_EOM 7
141 # define MTSE_RECE 8
142 # define MTSE_WRP 9
143 # define MTSE_LEOT 10
144 # define MTSE_RUNAWAY 11
145
146 typedef void (*TAPE_PCALLBACK)(UNIT *unit, t_stat status);
147
148
149
150 # define MTSE_DBG_DAT 0x0400000
151 # define MTSE_DBG_POS 0x0800000
152 # define MTSE_DBG_STR 0x1000000
153
154
155
156 t_stat sim_tape_attach_ex (UNIT *uptr, const char *cptr, uint32 dbit, int completion_delay);
157 t_stat sim_tape_attach (UNIT *uptr, CONST char *cptr);
158 t_stat sim_tape_detach (UNIT *uptr);
159 t_stat sim_tape_attach_help(FILE *st, DEVICE *dptr, const UNIT *uptr, int32 flag, const char *cptr);
160 t_stat sim_tape_rdrecf (UNIT *uptr, uint8 *buf, t_mtrlnt *bc, t_mtrlnt max);
161 t_stat sim_tape_rdrecf_a (UNIT *uptr, uint8 *buf, t_mtrlnt *bc, t_mtrlnt max, TAPE_PCALLBACK callback);
162 t_stat sim_tape_rdrecr (UNIT *uptr, uint8 *buf, t_mtrlnt *bc, t_mtrlnt max);
163 t_stat sim_tape_rdrecr_a (UNIT *uptr, uint8 *buf, t_mtrlnt *bc, t_mtrlnt max, TAPE_PCALLBACK callback);
164 t_stat sim_tape_wrrecf (UNIT *uptr, uint8 *buf, t_mtrlnt bc);
165 t_stat sim_tape_wrrecf_a (UNIT *uptr, uint8 *buf, t_mtrlnt bc, TAPE_PCALLBACK callback);
166 t_stat sim_tape_wrtmk (UNIT *uptr);
167 t_stat sim_tape_wrtmk_a (UNIT *uptr, TAPE_PCALLBACK callback);
168 t_stat sim_tape_wreom (UNIT *uptr);
169 t_stat sim_tape_wreom_a (UNIT *uptr, TAPE_PCALLBACK callback);
170 t_stat sim_tape_wreomrw (UNIT *uptr);
171 t_stat sim_tape_wreomrw_a (UNIT *uptr, TAPE_PCALLBACK callback);
172 t_stat sim_tape_wrgap (UNIT *uptr, uint32 gaplen);
173 t_stat sim_tape_wrgap_a (UNIT *uptr, uint32 gaplen, TAPE_PCALLBACK callback);
174 t_stat sim_tape_sprecf (UNIT *uptr, t_mtrlnt *bc);
175 t_stat sim_tape_sprecf_a (UNIT *uptr, t_mtrlnt *bc, TAPE_PCALLBACK callback);
176 t_stat sim_tape_sprecsf (UNIT *uptr, uint32 count, uint32 *skipped);
177 t_stat sim_tape_sprecsf_a (UNIT *uptr, uint32 count, uint32 *skipped, TAPE_PCALLBACK callback);
178 t_stat sim_tape_spfilef (UNIT *uptr, uint32 count, uint32 *skipped);
179 t_stat sim_tape_spfilef_a (UNIT *uptr, uint32 count, uint32 *skipped, TAPE_PCALLBACK callback);
180 t_stat sim_tape_spfilebyrecf \
181 (UNIT *uptr, uint32 count, uint32 *skipped, uint32 *recsskipped, t_bool check_leot);
182 t_stat sim_tape_spfilebyrecf_a \
183 (UNIT *uptr, uint32 count, uint32 *skipped, uint32 *recsskipped, t_bool check_leot, TAPE_PCALLBACK callback);
184 t_stat sim_tape_sprecr (UNIT *uptr, t_mtrlnt *bc);
185 t_stat sim_tape_sprecr_a (UNIT *uptr, t_mtrlnt *bc, TAPE_PCALLBACK callback);
186 t_stat sim_tape_sprecsr (UNIT *uptr, uint32 count, uint32 *skipped);
187 t_stat sim_tape_sprecsr_a (UNIT *uptr, uint32 count, uint32 *skipped, TAPE_PCALLBACK callback);
188 t_stat sim_tape_spfiler (UNIT *uptr, uint32 count, uint32 *skipped);
189 t_stat sim_tape_spfiler_a (UNIT *uptr, uint32 count, uint32 *skipped, TAPE_PCALLBACK callback);
190 t_stat sim_tape_spfilebyrecr (UNIT *uptr, uint32 count, uint32 *skipped, uint32 *recsskipped);
191 t_stat sim_tape_spfilebyrecr_a (UNIT *uptr, uint32 count, uint32 *skipped, uint32 *recsskipped, TAPE_PCALLBACK callback);
192 t_stat sim_tape_rewind (UNIT *uptr);
193 t_stat sim_tape_rewind_a (UNIT *uptr, TAPE_PCALLBACK callback);
194 t_stat sim_tape_position \
195 (UNIT *uptr, uint32 flags, uint32 recs, uint32 *recskipped, uint32 files,
196 uint32 *fileskipped, uint32 *objectsskipped);
197 t_stat sim_tape_position_a \
198 (UNIT *uptr, uint32 flags, uint32 recs, uint32 *recsskipped, uint32 files,
199 uint32 *filesskipped, uint32 *objectsskipped, TAPE_PCALLBACK callback);
200 t_stat sim_tape_reset (UNIT *uptr);
201 t_bool sim_tape_bot (UNIT *uptr);
202 t_bool sim_tape_wrp (UNIT *uptr);
203 t_bool sim_tape_eot (UNIT *uptr);
204 t_stat sim_tape_set_fmt (UNIT *uptr, int32 val, CONST char *cptr, void *desc);
205 t_stat sim_tape_show_fmt (FILE *st, UNIT *uptr, int32 val, CONST void *desc);
206 t_stat sim_tape_set_capac (UNIT *uptr, int32 val, CONST char *cptr, void *desc);
207 t_stat sim_tape_show_capac (FILE *st, UNIT *uptr, int32 val, CONST void *desc);
208 t_stat sim_tape_set_dens (UNIT *uptr, int32 val, CONST char *cptr, void *desc);
209 t_stat sim_tape_show_dens (FILE *st, UNIT *uptr, int32 val, CONST void *desc);
210
211 #endif