|
|
1.1 root 1:
2: /* init.s */
3:
4:
5: /* This file is a diagnostic version of locore.s. */
6: /* It contains the following: */
7: /* *system data area = scb, dump buffer, interrupt stack, */
8: /* *system page table,user page tables,pcbs,iomap, & io buffers. */
9: /* */
10: /* *system code = interrupt vectors, initialization of system data,*/
11: /* *memory size calculation,initialization of SPT, zeroing of */
12: /* *unused memory, & loading of SBR & SLR. */
13: /* * */
14: /* *at the end of this code, you are ready to go to virtual mode. */
15: /* * --- GOOD LUCK! */
16:
17:
18: /* privileged registers addresses */
19: #include "prvreg.h"
20:
21: /* program status long word definition */
22: #include "psl.h"
23:
24: /* page table entry definition */
25: #include "pte.h"
26:
27: /* process control block offsets */
28: #include "pcboffset.h"
29:
30: /* fundamental constants for globl use */
31: #include "const.h"
32:
33: /* system control block offsets*/
34: #include "scboffset.h"
35: /* SPT offsets */
36: #include "sptoffset.h"
37:
38: /* trap numbers*/
39: #include "trap.h"
40:
41:
42: #define V_TRAP 0
43: #define V_SYSCALL 4
44:
45: .set HIGH,0x1f /*mask for disabling all interrupts */
46: .set MCKVEC,4 /*scb offset for machinecheck vector */
47: .set NISP,2 /*no. of interrupt stack pages */
48: .set DONE,255 /*user process done code */
49:
50: .text
51:
52: #include "pstorage.s" /* PROCESSOR STORAGE AREA */
53:
54: .globl _Entry
55: _Entry:
56: jmp start
57: .space (1024-6)
58:
59:
60:
61:
62: /* globl dump buffer to be used for communication */
63: /* between tests & interrupt handlers, & other misc. */
64: /* purposes. */
65:
66: /*physical page 3 */
67:
68: .set NLWU,41 /*no. of longwords already used */
69: /*this must be changed when you define */
70: /*additional variables below before */
71: /*_dbuf */
72: .globl _restart
73: _restart:
74: .space 4 /*contains restart address for restarting*/
75: /*after power is restored (loaded by */
76: /*power fail interrupt handler & used by*/
77: /*CPU 2 */
78: .globl _maxmem
79: _maxmem:
80: .space 4 /*memory size in no of bytes */
81:
82: .globl _maxpages
83: _maxpages:
84: .space 4 /*memory size in no. of physical pages */
85:
86: .globl _lastadd
87: _lastadd:
88: .space 4 /*address of the last long word */
89:
90: .globl _unused
91: _unused:
92: .space 4 /*first unused page in system space */
93:
94: .globl _ctlblk
95: _ctlblk:
96: .long 0 /* pointer to SCB */
97:
98: .globl _savvec0 /*save vectors area */
99: _savvec0:
100: .space 4
101:
102: .globl _savvec1 /*save vectors area */
103: _savvec1:
104: .space 4
105:
106: .globl _savvec2 /*save vectors area */
107: _savvec2:
108: .space 4
109:
110: .globl _savvec3 /*save vectors area */
111: _savvec3:
112: .space 4
113:
114: .globl _savvec4 /*save vectors area */
115: _savvec4:
116: .space 4
117:
118: .globl _savvec5 /*save vectors area */
119: _savvec5:
120: .space 4
121: .globl _savvec6 /*save vectors area */
122: _savvec6:
123: .space 4
124: .globl _savvec7 /*save vectors area */
125: _savvec7:
126: .space 4
127:
128: .globl _savvec8 /*save vectors area */
129: _savvec8:
130: .space 4
131:
132: .globl badrtn
133: badrtn:
134: .long 0
135:
136: .long 0
137:
138: .globl _dbuf /*dump buffer left out of 1K */
139: .globl _r_no
140: _r_no:
141: .long 0
142: .globl _pt_base
143: _pt_base:
144: .long 0
145: .globl _saved_psl
146: _saved_psl:
147: .long 0
148: .globl _saved_sp
149: _saved_sp:
150: .long 0
151: .globl _saved_fp
152: _saved_fp:
153: .long 0
154: .globl _p_ptr
155: _p_ptr:
156: .long 0
157: .globl _ret_adr
158: _ret_adr:
159: .long 0
160: .globl _exp_par0
161: _exp_par0:
162: .long 0
163: .globl _exp_par1
164: _exp_par1:
165: .long 0
166: .globl _exp_par2
167: _exp_par2:
168: .long 0
169: .globl _exp_par3
170: _exp_par3:
171: .long 0
172: .globl _act_par0
173: _act_par0:
174: .long 0
175: .globl _act_par1
176: _act_par1:
177: .long 0
178: .globl _act_par2
179: _act_par2:
180: .long 0
181: .globl _act_par3
182: _act_par3:
183: .long 0
184: .long 0
185: .globl _clk_cnt
186: _clk_cnt:
187: .long 0 /* Clock int. count */
188: .globl _loop_flg
189: _loop_flg:
190: .long 0
191: .globl _errcnt
192: _errcnt:
193: .long 0
194: .globl _cycle
195: _cycle:
196: .long 0
197: .globl _hlt_flg
198: _hlt_flg:
199: .long 0
200: .long 0
201: .globl _endprog
202: _endprog:
203: .long 0
204: .globl _nonstop
205: _nonstop:
206: .long 0
207: _dbuf:
208: .space NBPG - (NLWU *4)
209: edbuf:
210:
211:
212: .globl _intstack /* Interrupt stack */
213: _intstack: /* Physical pages 4 & 5 */
214: .space NISP*NBPG
215: eintstack:
216:
217:
218: .set SYSPTSIZE,512 /* No. of entries in SPT */
219:
220: /*
221: System Page Table -- physical page 6 & 7
222: */
223: .align 2
224: .globl _Sysmap
225: _Sysmap:
226: .space SYSPTSIZE*4 /* 512 max pages allowed for system */
227: eSysmap:
228: .globl _Syssize
229: .set _Syssize,(eSysmap-_Sysmap)/4 /* should be SYSPTSIZE */
230:
231: .globl _iomap /* Physical page 8 */
232: _iomap: .space 1024 /* IOMAP - unused */
233: .globl _eiomap
234: _eiomap:
235:
236: .globl _pcb0 /* Physical page 9 */
237: _pcb0: .space 128 /*process control block 0 */
238: .globl _pcb1
239: _pcb1: .space 128 /*process control block 1 */
240: .globl _pcb2
241: _pcb2: .space 128 /*process control block 2 */
242: .globl _pcb3
243: _pcb3: .space 128 /*process control block 3 */
244: .globl _pcb4
245: _pcb4: .space 128 /*process control block 4 */
246: .globl _pcb5
247: _pcb5: .space 128 /*process control block 5 */
248: .globl _pcb6
249: _pcb6: .space 128 /*process control block 6 */
250: .globl _pcb7
251: _pcb7: .space 128 /*process control block 7 */
252:
253: /*
254: *user #0 page tables -- P0PT, P1PT, P2PT
255: *physical memory -- page10, 11, & 12 respectively
256: */
257: .align 2
258: .globl _u0p0pt
259: _u0p0pt:
260: .space 1024 /*255 max pages for user #0 text */
261: .globl _u0p1pt
262: _u0p1pt:
263: .space 1024 /*255 max pages for user #0 data */
264: .globl _u0p2pt
265: _u0p2pt:
266: .space 1020 /*255 max pages for user #0 stack */
267: eu0p2pt:
268: .space 4
269:
270: /*
271: *user #1 page tables -- P0PT, P1PT, P2PT
272: *physical memory -- page13 ,14, & 15 respectively
273: */
274: .align 2
275: .globl _u1p0pt
276: _u1p0pt:
277: .space 1024 /*255 max pages for user #1 text */
278: .globl _u1p1pt
279: _u1p1pt:
280: .space 1024 /*255 max pages for user #1 data */
281: .globl _u1p2pt
282: _u1p2pt:
283: .space 1020 /*255 max pages for user #1 stack */
284: eu1p2pt:
285: .space 4
286:
287:
288: /*
289: *user #2 page tables -- P0PT, P1PT, P2PT
290: *physical memory -- page 16, 17 , & 18 respectively
291: */
292: .align 2
293: .globl _u2p0pt
294: _u2p0pt:
295: .space 1024 /*255 max pages for user #2 text */
296: .globl _u2p1pt
297: _u2p1pt:
298: .space 1024 /*255 max pages for user #2 data */
299: .globl _u2p2pt
300: _u2p2pt:
301: .space 1020 /*255 max pages for user #2 stack */
302: eu2p2pt:
303: .space 4
304:
305:
306: /*
307: *user #3 page tables -- P0PT, P1PT, P2PT
308: *physical memory -- page 19, 20 , & 21 respectively
309: */
310: .align 2
311: .globl _u3p0pt
312: _u3p0pt:
313: .space 1024 /*255 max pages for user #3 text */
314: .globl _u3p1pt
315: _u3p1pt:
316: .space 1024 /*255 max pages for user #3 data */
317: .globl _u3p2pt
318: _u3p2pt:
319: .space 1020 /*255 max pages for user #3 stack */
320: eu3p2pt:
321: .space 4
322:
323: /*
324: *user #4 thru 6 page tables
325: *physical memory -- pages 22 thru 30
326: */
327: .globl _u4p0pt
328: _u4p0pt:
329: .space (9*NBPG) - 4
330: eu6p2pt:
331: .space 4
332:
333: /*
334: *user #7 page tables -- P0PT, P1PT, P2PT
335: *physical memory -- page 31, 32 , & 33 respectively
336: */
337: .align 2
338: .globl _u7p0pt
339: _u7p0pt:
340: .space 1024 /*255 max pages for user #7 text */
341: .globl _u7p1pt
342: _u7p1pt:
343: .space 1024 /*255 max pages for user #7 data */
344: .globl _u7p2pt
345: _u7p2pt:
346: .space 1020 /*255 max pages for user #7 stack */
347: eu7p2pt:
348: .space 4
349:
350: .globl _iob0 /*io buffer 0 */
351: _iob0: .space 1024
352: .globl _iob1 /*io buffer 1 */
353: _iob1: .space 1024
354: .globl _iob2 /*io buffer 2 */
355: _iob2: .space 1024
356: .globl _iob3 /*io buffer 3 */
357: _iob3: .space 1024
358: .globl _iob4 /*io buffer 4 */
359: _iob4: .space 1024
360: .globl _iob5 /*io buffer 5 */
361: _iob5: .space 1024
362: .globl _iob6 /*io buffer 6 */
363: _iob6: .space 1024
364: esysdata:
365:
366: #include "scblock.s" /* SYSTEM CONTROL BLOCK */
367:
368: #include "evthandlers.s" /*event handlers */
369:
370: #define ACBL(_n1,_n2,_n3,_n4) \
371: addl2 _n2,_n3;\
372: cmpl _n3,_n1;\
373: bleq _n4;
374:
375: .set MEMUNIT,64*1024
376: .set MAXPHYSMEM,32*1024*1024-1
377: .set ERRCD,0x7
378: .set APE,0x1
379: .set DCE,0x3
380: .set VTO,0x4
381:
382:
383:
384: /*
385: *INITIALIZATION CODE
386: *
387: * MME off; mode = k; IPL = 31; IS = 1
388: *
389: */
390:
391: .globl start
392: start:
393: mtpr $0,$MME /* Disable MME */
394: andl3 $4,r11,_ss1 /* messages sense switch */
395: movl r0,_test_no /* save test number */
396: movl r1,_OPTIONS /* save option bits */
397: clrl _nonstop
398: movl r2,_count /* save cycle count */
399: cmpl $0xffffffff,r2 /* Is count == -1 */
400: bneq 1f
401: movl $1,_nonstop /* Yes : NONSTOP */
402: 1:
403: cmpl $0x0,r2 /* Is count == 0 */
404: bneq 1f
405: movl $1,_count /* Yes : set default count to 1 */
406: 1:
407: movab _scb,r0
408: andl2 $0x3ffffc00,r0
409: mtpr r0,$SCBB /* Set SCBB */
410: mtpr $0x1f,$IPL /* Set IPL to HIGH */
411:
412: movpsl r1
413: andl2 $0xffffff00,r1 /* Mask out flags */
414: cmpl r1,$0x041f0000 /*IS on,modes =k & IPL = 31? */
415: beql 1f
416: 2: movl $1,r0
417: movl $0x041f0000,r2
418: halt /* PSL not initialized as expected */
419: /*
420: # Mask out bit 30,31 of SCB vectors
421: # Will turm them back on when ready to go virtual in
422: # system space
423: */
424: 1:
425: clrl _clk_cnt
426: movl $7,r0 /* R0 : Vector no. of clock int. */
427: movab _Hardclk,_scb[r0] /* New vector for clock */
428:
429: movl $_intstack+NISP*NBPG,r0
430: andl2 $0x3fffffff,r0 /* Mask out bit 30,31 */
431: mtpr r0,$ISP /* init. ISP */
432: movl r0,sp /* in case we get exception */
433: movab (sp),fp /* Initialize FP */
434: /*
435: Clear system data area all the way upto system code
436: this includes dump buffer,interrupt stack,spt,iomap,pcbs,user
437: page tables, & io buffer area.
438: */
439: 3:
440: movab esysdata,r7
441: movab _restart,r6
442: 1: clrl (r6)
443: ACBL(r7,$4,r6,1b)
444: /*
445: Count memory
446: */
447: clrl r3
448: movl _scb+BEVEC,r12
449: movab 9f,_scb+BEVEC /* new interrupt handler */
450: 1: tstl (r3)
451: clrl r0 /* allow 100ns delay */
452: addl2 $MEMUNIT,r3
453: cmpl r3,$MAXPHYSMEM /* excess max memory size? */
454: bleq 1b
455: 2:
456: subl3 $4,r3,_maxmem
457: movl r12,_scb+BEVEC /* restore interrupt handler */
458: jmp _ready
459:
460: .align 2
461: 9: andl3 4(sp),$ERRCD,r0 /* Here's where we get the bus err */
462: cmpl r0,$APE /* data parity error */
463: bneq 1f
464: halt
465: 1: cmpl r0,$VTO /* versabus Error */
466: bneq 1f
467: halt
468: 1: movab 8(sp),sp
469: movab 2b,(sp)
470: mtpr $1,$TBIA /* Purge all */
471: mtpr $1,$PADC /* Purge all data cache */
472: rei
473:
474: .globl _ready
475: _ready:
476: mtpr $64,$DCR /* Enable fault */
477: andl3 $0x3ffffc00,$_end+NBPG-1,_endprog
478:
479: callf $4,_monitor
480: mtpr $2,$27 /* Disable Data cache */
481: clrl _cycle
482: clrl _errcnt
483: 2:
484: movl $1,_test_no
485: bitl $1,_tstmsk
486: beql 1f
487: callf $4,_stest1
488: 1:
489: incl _test_no
490: bitl $2,_tstmsk
491: beql 1f
492: callf $4,_stest2
493: 1:
494: incl _test_no
495: bitl $4,_tstmsk
496: beql 1f
497: callf $4,_stest3
498: 1:
499: mtpr $0x1e,$IPL /* Set IPL to a low value*/
500: callf $4,_i_ecc /* Init. memory + ECC */
501: incl _test_no
502: bitl $8,_tstmsk
503: beql 1f
504: callf $4,_subtest4
505: 1:
506: incl _test_no
507: bitl $16,_tstmsk
508: beql 1f
509: callf $4,_subtest5
510: 1:
511: incl _test_no
512: bitl $32,_tstmsk
513: beql 1f
514: callf $4,_subtest6
515: 1:
516: pushl $endmsg /* Write cycle count */
517: mtpr $0x1f,$IPL /* Set IPL to a high value*/
518: bitl $8,_OPTIONS /* print message ? */
519: beql 1f
520: callf $8,_writes
521: incl _cycle
522: pushl _cycle
523: callf $8,_writed
524: 1:
525: tstl _nonstop /* Is loop forever ? */
526: beql 4f
527: jmp 2b /* Yes : Jump back */
528: 4:
529: decl _count
530: tstl _count /* Is count == 0 ? */
531: beql 1f
532: jmp 2b /* No : Continue */
533: 1:
534: bitl $8,_OPTIONS /* suppress message ? */
535: beql 1f
536: pushl $emsg
537: callf $8,_writes
538: pushl _cycle
539: callf $8,_writed
540: pushl $ermsg
541: callf $8,_writes
542: pushl _errcnt
543: callf $8,_writed
544: pushl $ermsg1
545: callf $8,_writes
546: 1:
547: movl $0xCAFEBABE,r0
548: halt
549: #
550: #
551: # ***********************************
552: # * Routine to test an ECC location *
553: # * ecccor(addr) : Read from this *
554: # * addr. ECC correction is enable. *
555: # * Return in R0 : *
556: # * 0 = Didnot get Buser *
557: # * -1 = Got DCE *
558: # * -2 = Unexpected Buser *
559: # ***********************************
560: #
561: .align 2
562: .globl _ecccor
563: _ecccor: .word 0x1ffe
564: movl _scb+BEVEC,_savvec2 /* Save bus error vector */
565: movab 9f,_scb+BEVEC /* Set new vector */
566: movl 4(fp),r1 /* get test address */
567: movl $0x3,0xffffb000 /* Turn ON ECC detection,correction */
568: movl 0xffffb000,r0
569: movl (r1),*8(fp) /* Read data */
570: movl $2,r0 /* timeout value*/
571: 1:
572: decl r0
573: bgtr 1b
574:
575: clrl r0 /* indicate timeout */
576: movl $0x80,0xffffb000 /* Turn OFF ECC detection */
577: movl _savvec2,_scb+BEVEC
578: ret
579: #
580: #
581: # ***********************************
582: # * Routine to test an ECC location *
583: # * eccloc(addr) : Read from this *
584: # * addr. ECC detection is enable. *
585: # * Return in R0 : *
586: # * 0 = Didnot get Buser *
587: # * -1 = Got DCE *
588: # * -2 = Unexpected Buser *
589: # ***********************************
590: #
591: .align 2
592: .globl _eccloc
593: _eccloc: .word 0x1ffe
594: movl _scb+BEVEC,_savvec2 /* Save bus error vector */
595: movab 9f,_scb+BEVEC /* Set new vector */
596: movl 4(fp),r2 /* get test address */
597: movl $0x1,0xffffb000 /* Turn ON ECC detection */
598: movl 0xffffb000,r0
599: movl (r2),r1 /* Read data */
600: movl $4,r0 /* timeout value*/
601: 1: decl r0
602: bgtr 1b
603:
604: movl 0xffffb000,_ber1 /* Read MCR */
605: movl 0xffffb008,_ber3 /* Read MCBR */
606: movl r1,_ber2 /* Data read */
607:
608: clrl r0 /* indicate timeout */
609: #
610: # Return after Bus error
611: #
612: 2:
613: movl $0xc0,0xffffb000 /* Turn OFF ECC, clear error */
614: movl _savvec2,_scb+BEVEC
615: ret
616: #
617: # *********************
618: # * Bus Error handler *
619: # *********************
620: #
621: .align 2
622: 9:
623: movl $0xc0,0xffffb000 /* Turn OFF ECC detection */
624: andl3 4(sp),$ERRCD,r0 /* Here's where we get the bus err */
625: movl (sp),_tmp_mcbr /* save current MCBR */
626: movl 4(sp),_tmp_mear /* save current MEAR */
627: cmpl r0,$DCE /* Data Check error ? */
628: beql 3f
629: movl $-2,r0 /* indicate wrong Buser */
630: brw 4f
631: 3:
632: movl $-1,r0 /* Indicate got a DCE */
633: 4: movab 8(sp),sp
634: movab 2b,(sp)
635: movl _tmp_mcbr,_ber1
636: movl _tmp_mear,_ber2
637: rei
638:
639: .align 2
640: .globl _ber1
641: _ber1: .long 0 /* Bus error Parameter no. 1 */
642: .globl _ber2
643: _ber2: .long 0 /* Bus error Parameter no. 1 */
644: .globl _ber3
645: _ber3: .long 0
646: #
647: # *********************
648: #
649: .align 2
650: .globl _Hardclk
651: _Hardclk:
652: incl _clk_cnt
653: rei
654:
655: .align 2
656: .globl _tstmsk
657: _tstmsk: .long 0 /* tests to run */
658: .globl _ss1
659: _ss1: .long 0 /* If 1 then donot print heading messages */
660: .globl _prt_flg
661: _prt_flg: .long 0 /* print enable */
662:
663: .globl _OPTIONS
664: .globl _test_no
665: _test_no: .long 0
666: .globl _count
667: _count: .long 0
668: .globl _diagmode
669: _diagmode: .long 0
670: .globl _tmp_mcbr
671: _tmp_mcbr: .long 0
672: .globl _tmp_mear
673: _tmp_mear: .long 0
674: .globl err1
675: err1:
676: .ascii "\nRegisters : \0"
677: .globl err2
678: err2:
679: .ascii " \0"
680: .globl err3
681: err3:
682: .ascii "\n \0"
683: .globl err4
684: err4:
685: .ascii "\n\0"
686: .globl e_type
687: e_type:
688: .ascii "\n** Unexpected exception type : \0"
689: .globl par_0
690: par_0:
691: .ascii "** Par 0 : \0"
692: .globl par_1
693: par_1:
694: .ascii "** Par 1 : \0"
695: .globl par_pc
696: par_pc:
697: .ascii "** PC : \0"
698: .globl par_psl
699: par_psl:
700: .ascii "** PSL : \0"
701: .align 2
702: Gregs: .space 60 /* Space to save general registers */
703: .align 2
704: .globl _Errmsg
705: _Errmsg:
706: .long 0 /* Pointer to error message */
707: .data 1
708: endmsg: .ascii "\nEnd Cycle = \0"
709: emsg: .ascii "\nCycles Completed = \0"
710: ermsg: .ascii "\nError Count = \0"
711: ermsg1: .ascii "\nTest Complete \n\0"
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.