1 /* id16_dboot.c: Interdata 16b simulator disk bootstrap
2 
3    Copyright (c) 2000-2008, 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    17-Jul-06    RMS     Fixed transcription error
27 */
28 
29 #include "id_defs.h"
30 
31 #define DBOOT_BEG       0x1000
32 #define DBOOT_START     0x100e
33 #define DBOOT_LEN       (sizeof (dboot_rom) / sizeof (uint8))
34 
35 /* Boot ROM: transcription of OS/16 MT2 ALO Direct Access Loader */
36 
37 static uint8 dboot_rom[] = {
38  0xca, 0xf0, 0x00, 0x30,
39  0xc5, 0xf0, 0x00, 0x3a,
40  0x02, 0x8e,
41  0x26, 0xf7,
42  0x03, 0x0e,
43  0xd1, 0xc0, 0x00, 0x78,
44  0xd0, 0xc0, 0x13, 0xf6,
45  0x07, 0xdd,
46  0xc8, 0x10, 0x10, 0x00,
47  0xd3, 0xf0, 0x00, 0x7e,
48  0xc4, 0xf0, 0x00, 0x0f,
49  0x01, 0xe1,
50  0xd2, 0xf0, 0x12, 0xe2,
51  0xd3, 0xf0, 0x00, 0x7f,
52  0x90, 0xf4,
53  0x01, 0xe1,
54  0xd2, 0xf0, 0x12, 0xe3,
55  0xd3, 0xf0, 0x00, 0x7f,
56  0xc4, 0xf0, 0x00, 0x0f,
57  0x01, 0xe1,
58  0xd2, 0xf0, 0x12, 0xe4,
59  0xd3, 0x20, 0x00, 0x7d,
60  0xd3, 0x30, 0x00, 0x7c,
61  0xd3, 0x40, 0x00, 0x7a,
62  0xd3, 0x50, 0x00, 0x7b,
63  0xc8, 0x70, 0x12, 0xf6,
64  0xc8, 0x80, 0x13, 0xf5,
65  0x07, 0xaa,
66  0x07, 0xcc,
67  0x41, 0xe0, 0x11, 0x88,
68  0x48, 0xa0, 0x12, 0xfe,
69  0x48, 0xc0, 0x13, 0x00,
70  0x43, 0x00, 0x10, 0x98,
71  0xc8, 0x70, 0x12, 0xf6,
72  0x41, 0xe0, 0x11, 0x88,
73  0xc8, 0xe0, 0x12, 0xfa,
74  0x24, 0x15,
75  0xd3, 0x0e, 0x00, 0x24,
76  0xc3, 0x00, 0x00, 0x10,
77  0x21, 0x3f,
78  0xca, 0xe0, 0x00, 0x30,
79  0x27, 0x11,
80  0x20, 0x38,
81  0x48, 0xa0, 0x12, 0xf6,
82  0x48, 0xc0, 0x12, 0xf8,
83  0x42, 0x30, 0x10, 0x70,
84  0x08, 0xaa,
85  0x20, 0x33,
86  0x43, 0x00, 0x12, 0xb2,
87  0x90, 0x05,
88  0x42, 0x30, 0x10, 0x88,
89  0xc8, 0x60, 0x4f, 0x53,
90  0x45, 0x63, 0x00, 0x00,
91  0x20, 0x36,
92  0xc8, 0x60, 0x31, 0x36,
93  0x45, 0x6e, 0x00, 0x02,
94  0x20, 0x3b,
95  0x48, 0x6e, 0x00, 0x08,
96  0x45, 0x60, 0x12, 0xe2,
97  0x20, 0x35,
98  0xd3, 0x6e, 0x00, 0x0a,
99  0xd4, 0x60, 0x12, 0xe4,
100  0x20, 0x3a,
101  0x08, 0x0e,
102  0x07, 0x66,
103  0xca, 0x60, 0x20, 0x00,
104  0x23, 0x36,
105  0x40, 0x06, 0x00, 0x00,
106  0x45, 0x06, 0x00, 0x00,
107  0x22, 0x37,
108  0x48, 0xae, 0x00, 0x0c,
109  0x48, 0xce, 0x00, 0x0e,
110  0x48, 0x0e, 0x00, 0x10,
111  0x48, 0x1e, 0x00, 0x12,
112  0x0b, 0x1c,
113  0x0f, 0x0a,
114  0x07, 0xff,
115  0x26, 0x11,
116  0x0e, 0x0f,
117  0xed, 0x00, 0x00, 0x08,
118  0xcb, 0x60, 0x02, 0xbe,
119  0x08, 0x00,
120  0x23, 0x34,
121  0x08, 0x86,
122  0x08, 0x16,
123  0x23, 0x04,
124  0x05, 0x16,
125  0x22, 0x84,
126  0x08, 0x81,
127  0x07, 0x77,
128  0x27, 0x81,
129  0xc8, 0xd1, 0xee, 0xc0,
130  0xc8, 0xf0, 0x11, 0x40,
131  0x48, 0x0f, 0x00, 0x00,
132  0x40, 0x01, 0x00, 0x00,
133  0x26, 0xf2,
134  0x26, 0x12,
135  0xc5, 0xf0, 0x13, 0xfe,
136  0x20, 0x88,
137  0x0a, 0xed,
138  0x40, 0xed, 0x12, 0xf4,
139  0x43, 0x0d, 0x11, 0x40,
140  0x41, 0xed, 0x11, 0x88,
141  0xd1, 0xed, 0x13, 0xf6,
142  0xd0, 0xe0, 0x00, 0x78,
143  0xd1, 0xed, 0x13, 0xfa,
144  0xd0, 0xe0, 0x00, 0x7c,
145  0x48, 0x10, 0x00, 0x62,
146  0x48, 0x6d, 0x12, 0xf4,
147  0xd1, 0xa6, 0x00, 0x00,
148  0xd0, 0xa1, 0x00, 0x30,
149  0xd1, 0xe6, 0x00, 0x0c,
150  0xd0, 0xe1, 0x00, 0x28,
151  0x43, 0x00, 0x00, 0x60,
152  0x07, 0x00,
153  0x07, 0xbb,
154  0x0b, 0xcf,
155  0x0f, 0xab,
156  0x21, 0x13,
157  0x26, 0x01,
158  0x22, 0x04,
159  0x0a, 0xcf,
160  0x0e, 0xab,
161  0x08, 0xac,
162  0x08, 0xc0,
163  0x03, 0x0e,
164  0xde, 0x2d, 0x12, 0x1e,
165  0xc5, 0x50, 0x00, 0x33,
166  0x42, 0x2d, 0x11, 0xec,
167  0xde, 0x3d, 0x12, 0x1e,
168  0x9d, 0x3f,
169  0x22, 0x21,
170  0x9d, 0x4f,
171  0x42, 0x1d, 0x12, 0xb8,
172  0xc3, 0xf0, 0x00, 0x10,
173  0x20, 0x35,
174  0xd0, 0xad, 0x13, 0xea,
175  0xc8, 0xf0, 0x00, 0x30,
176  0x41, 0xed, 0x11, 0x70,
177  0x08, 0x9c,
178  0x08, 0xba,
179  0x48, 0xad, 0x13, 0xea,
180  0x48, 0xcd, 0x13, 0xee,
181  0xd1, 0xed, 0x13, 0xf2,
182  0xc5, 0xb0, 0x00, 0x18,
183  0x21, 0x82,
184  0x26, 0xb8,
185  0x98, 0x49,
186  0xde, 0x4d, 0x12, 0xe7,
187  0x9d, 0x3f,
188  0x22, 0x21,
189  0x9d, 0x4f,
190  0x42, 0x7d, 0x12, 0xb8,
191  0x20, 0x83,
192  0x98, 0x27,
193  0x98, 0x28,
194  0x98, 0x49,
195  0x9a, 0x3b,
196  0x41, 0x6d, 0x12, 0x7a,
197  0x22, 0x0f,
198  0x9d, 0x4f,
199  0xc3, 0xf0, 0x00, 0x19,
200  0x42, 0x3d, 0x12, 0xb8,
201  0xd0, 0xad, 0x13, 0xea,
202  0xc8, 0xf5, 0xff, 0xcc,
203  0x0a, 0xff,
204  0x48, 0xff, 0x12, 0xec,
205  0x41, 0xed, 0x11, 0x70,
206  0x08, 0x9c,
207  0x08, 0xca,
208  0x07, 0xaa,
209  0xc8, 0xf5, 0xff, 0xcc,
210  0xd3, 0xff, 0x12, 0xe8,
211  0x41, 0xed, 0x11, 0x70,
212  0x40, 0xcd, 0x12, 0xf2,
213  0x08, 0xba,
214  0x48, 0xad, 0x13, 0xea,
215  0x48, 0xcd, 0x13, 0xee,
216  0xd1, 0xed, 0x13, 0xf2,
217  0xde, 0x4d, 0x12, 0x6e,
218  0x9d, 0x3f,
219  0x22, 0x21,
220  0x98, 0x49,
221  0xde, 0x4d, 0x12, 0xd0,
222  0x9d, 0x3f,
223  0x22, 0x21,
224  0xde, 0x4d, 0x12, 0xa2,
225  0x9d, 0x3f,
226  0x22, 0x21,
227  0xd8, 0x4d, 0x12, 0xf2,
228  0xde, 0x4d, 0x12, 0xd1,
229  0x9d, 0x3f,
230  0x22, 0x21,
231  0xde, 0x4d, 0x12, 0xe7,
232  0x9d, 0x3f,
233  0x22, 0x21,
234  0x9d, 0x4f,
235  0x20, 0x81,
236  0xc3, 0xf0, 0x00, 0x53,
237  0x42, 0x3d, 0x12, 0xb8,
238  0x48, 0xfd, 0x12, 0xf2,
239  0x91, 0xfa,
240  0x06, 0xf9,
241  0xc8, 0x6d, 0x12, 0x2c,
242  0x98, 0x27,
243  0x98, 0x28,
244  0x9a, 0x3b,
245  0x98, 0x3f,
246  0xde, 0x3d, 0x12, 0xe6,
247  0xde, 0x2d, 0x11, 0xaf,
248  0x9d, 0x2f,
249  0x20, 0x81,
250  0xde, 0x2d, 0x12, 0x1e,
251  0x99, 0x20,
252  0xde, 0x2d, 0x12, 0x1e,
253  0x9d, 0x3f,
254  0x22, 0x21,
255  0x42, 0x1d, 0x12, 0xbc,
256  0xc3, 0xf0, 0x00, 0x10,
257  0x03, 0x3e,
258  0x0b, 0x07,
259  0x26, 0x02,
260  0xc4, 0x00, 0xff, 0x00,
261  0x0a, 0x70,
262  0x26, 0x91,
263  0x07, 0xbb,
264  0x40, 0xbd, 0x12, 0xf2,
265  0x03, 0x06,
266  0x24, 0xf1,
267  0x24, 0x10,
268  0x23, 0x04,
269  0x08, 0x14,
270  0x23, 0x02,
271  0x08, 0x13,
272  0x24, 0x01,
273  0xde, 0x0d, 0x10, 0xdc,
274  0x9a, 0x0f,
275  0x9a, 0x01,
276  0xde, 0x0d, 0x12, 0xe5,
277  0xd1, 0xed, 0x13, 0xf6,
278  0xd0, 0xe0, 0x00, 0x78,
279  0xd1, 0xed, 0x13, 0xfa,
280  0xd0, 0xe0, 0x00, 0x7c,
281  0x91, 0x0f,
282  0x95, 0x10,
283  0x22, 0x01,
284  0x00, 0x00, 0x00,
285  0x80,
286  0xc1,
287  0xc2,
288  0x14, 0x40, 0x40, 0x00,
289  0x01, 0x90,
290  0x01, 0x40,
291  0x04, 0xc0,
292  0x00, 0x00,
293  0x00, 0x00
294  };
295 
296 /* Lower memory setup
297 
298         78      =       binary input device address
299         79      =       binary device input command
300         7A      =       disk device number
301         7B      =       device code
302         7C      =       disk controller address
303         7D      =       selector channel address
304         7E:7F   =       operating system extension (user specified)
305 */
306 
307 struct dboot_id {
308     char        *name;
309     uint32      sw;
310     uint32      cap;
311     uint32      dtype;
312     uint32      offset;
313     uint32      adder;
314     };
315 
316 static struct dboot_id dboot_tab[] = {
317     { "DP", 0,            2, 0x31, o_DP0, 0 },
318     { "DP", SWMASK ('F'), 9, 0x32, o_DP0, o_DPF },
319     { "DP", 0,            9, 0x33, o_DP0, 0 },
320     { "DM", 0,           64, 0x35, o_ID0, 0 },
321     { "DM", 0,          244, 0x36, o_ID0, 0 },
322     { NULL }
323     };
324 
id_dboot(int32 u,DEVICE * dptr)325 t_stat id_dboot (int32 u, DEVICE *dptr)
326 {
327 extern DIB pt_dib, sch_dib;
328 extern uint32 PC;
329 uint32 i, typ, ctlno, off, add, cap, sch_dev;
330 UNIT *uptr;
331 
332 DIB *ddib = (DIB *) dptr->ctxt;                         /* get disk DIB */
333 ctlno = ddib->dno;                                      /* get ctrl devno */
334 sch_dev = sch_dib.dno + ddib->sch;                      /* sch dev # */
335 uptr = dptr->units + u;                                 /* get capacity */
336 cap = uptr->capac >> 20;
337 for (i = typ = 0; dboot_tab[i].name != NULL; i++) {
338     if ((strcmp (dboot_tab[i].name, dptr->name) == 0) &&
339         (dboot_tab[i].cap == cap)) {
340         typ = dboot_tab[i].dtype;
341         off = dboot_tab[i].offset;
342         add = dboot_tab[i].adder;
343         break;
344         }
345     }
346 if (typ == 0)
347     return SCPE_NOFNC;
348 
349 IOWriteBlk (DBOOT_BEG, DBOOT_LEN, dboot_rom);           /* copy boot */
350 IOWriteB (AL_DEV, pt_dib.dno);                          /* bin input dev */
351 IOWriteB (AL_IOC, 0x99);
352 IOWriteB (AL_DSKU, ctlno + ((u + 1) * off) + add);      /* disk param */
353 IOWriteB (AL_DSKT, typ);
354 IOWriteB (AL_DSKC, ctlno);
355 IOWriteB (AL_SCH, sch_dev);
356 PC = DBOOT_START;
357 return SCPE_OK;
358 }
359