|
|
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: /* globl dump buffer to be used for communication */
62: /* between tests & interrupt handlers, & other misc. */
63: /* purposes. */
64:
65: /*physical page 3 */
66:
67: .set NLWU,34 /*no. of longwords already used */
68: /*this must be changed when you define */
69: /*additional variables below before */
70: /*_dbuf */
71: .globl _restart
72: _restart:
73: .space 4 /*contains restart address for restarting*/
74: /*after power is restored (loaded by */
75: /*power fail interrupt handler & used by*/
76: /*CPU 2 */
77: .globl _maxmem
78: _maxmem:
79: .space 4 /*memory size in no of bytes */
80:
81: .globl _maxpages
82: _maxpages:
83: .space 4 /*memory size in no. of physical pages */
84:
85: .globl _lastadd
86: _lastadd:
87: .space 4 /*address of the last long word */
88:
89: .globl _unused
90: _unused:
91: .space 4 /*first unused page in system space */
92:
93: .globl _ctlblk
94: _ctlblk:
95: .long 0 /* pointer to SCB */
96:
97: .globl _savvec0 /*save vectors area */
98: _savvec0:
99: .space 4
100:
101: .globl _savvec1 /*save vectors area */
102: _savvec1:
103: .space 4
104:
105: .globl _savvec2 /*save vectors area */
106: _savvec2:
107: .space 4
108:
109: .globl _savvec3 /*save vectors area */
110: _savvec3:
111: .space 4
112:
113: .globl _savvec4 /*save vectors area */
114: _savvec4:
115: .space 4
116:
117: .globl _savvec5 /*save vectors area */
118: _savvec5:
119: .space 4
120: .globl _savvec6 /*save vectors area */
121: _savvec6:
122: .space 4
123: .globl _savvec7 /*save vectors area */
124: _savvec7:
125: .space 4
126:
127: .globl _savvec8 /*save vectors area */
128: _savvec8:
129: .space 4
130:
131: .globl badrtn
132: badrtn:
133: .long tfail
134:
135: testno: .long 0
136:
137: .globl _dbuf /*dump buffer left out of 1K */
138: .globl _r_no
139: _r_no:
140: .long 0
141: .globl _pt_base
142: _pt_base:
143: .long 0
144: .globl _saved_psl
145: _saved_psl:
146: .long 0
147: .globl _saved_sp
148: _saved_sp:
149: .long 0
150: .globl _saved_fp
151: _saved_fp:
152: .long 0
153: .globl _p_ptr
154: _p_ptr:
155: .long 0
156: .globl _ret_adr
157: _ret_adr:
158: .long 0
159: .globl _exp_par0
160: _exp_par0:
161: .long 0
162: .globl _exp_par1
163: _exp_par1:
164: .long 0
165: .globl _exp_par2
166: _exp_par2:
167: .long 0
168: .globl _exp_par3
169: _exp_par3:
170: .long 0
171: .globl _act_par0
172: _act_par0:
173: .long 0
174: .globl _act_par1
175: _act_par1:
176: .long 0
177: .globl _act_par2
178: _act_par2:
179: .long 0
180: .globl _act_par3
181: _act_par3:
182: .long 0
183: .globl _test_no
184: _test_no:
185: .long 0
186: .globl _clk_cnt
187: _clk_cnt:
188: .long 0 /* Clock int. count */
189: _dbuf:
190: .space NBPG - (NLWU *4)
191: edbuf:
192:
193:
194: .globl _intstack /* Interrupt stack */
195: _intstack: /* Physical pages 4 & 5 */
196: .space NISP*NBPG
197: eintstack:
198:
199:
200: .set SYSPTSIZE,512 /* No. of entries in SPT */
201:
202: /*
203: System Page Table -- physical page 6 & 7
204: */
205: .align 2
206: .globl _Sysmap
207: _Sysmap:
208: .space SYSPTSIZE*4 /* 512 max pages allowed for system */
209: eSysmap:
210: .globl _Syssize
211: .set _Syssize,(eSysmap-_Sysmap)/4 /* should be SYSPTSIZE */
212:
213: .globl _iomap /* Physical page 8 */
214: _iomap: .space 1024 /* IOMAP - unused */
215: .globl _eiomap
216: _eiomap:
217:
218: .globl _pcb0 /* Physical page 9 */
219: _pcb0: .space 128 /*process control block 0 */
220: .globl _pcb1
221: _pcb1: .space 128 /*process control block 1 */
222: .globl _pcb2
223: _pcb2: .space 128 /*process control block 2 */
224: .globl _pcb3
225: _pcb3: .space 128 /*process control block 3 */
226: .globl _pcb4
227: _pcb4: .space 128 /*process control block 4 */
228: .globl _pcb5
229: _pcb5: .space 128 /*process control block 5 */
230: .globl _pcb6
231: _pcb6: .space 128 /*process control block 6 */
232: .globl _pcb7
233: _pcb7: .space 128 /*process control block 7 */
234:
235: /*
236: *user #0 page tables -- P0PT, P1PT, P2PT
237: *physical memory -- page10, 11, & 12 respectively
238: */
239: .align 2
240: .globl _u0p0pt
241: _u0p0pt:
242: .space 1024 /*255 max pages for user #0 text */
243: .globl _u0p1pt
244: _u0p1pt:
245: .space 1024 /*255 max pages for user #0 data */
246: .globl _u0p2pt
247: _u0p2pt:
248: .space 1020 /*255 max pages for user #0 stack */
249: eu0p2pt:
250: .space 4
251:
252: /*
253: *user #1 page tables -- P0PT, P1PT, P2PT
254: *physical memory -- page13 ,14, & 15 respectively
255: */
256: .align 2
257: .globl _u1p0pt
258: _u1p0pt:
259: .space 1024 /*255 max pages for user #1 text */
260: .globl _u1p1pt
261: _u1p1pt:
262: .space 1024 /*255 max pages for user #1 data */
263: .globl _u1p2pt
264: _u1p2pt:
265: .space 1020 /*255 max pages for user #1 stack */
266: eu1p2pt:
267: .space 4
268:
269:
270: /*
271: *user #2 page tables -- P0PT, P1PT, P2PT
272: *physical memory -- page 16, 17 , & 18 respectively
273: */
274: .align 2
275: .globl _u2p0pt
276: _u2p0pt:
277: .space 1024 /*255 max pages for user #2 text */
278: .globl _u2p1pt
279: _u2p1pt:
280: .space 1024 /*255 max pages for user #2 data */
281: .globl _u2p2pt
282: _u2p2pt:
283: .space 1020 /*255 max pages for user #2 stack */
284: eu2p2pt:
285: .space 4
286:
287:
288: /*
289: *user #3 page tables -- P0PT, P1PT, P2PT
290: *physical memory -- page 19, 20 , & 21 respectively
291: */
292: .align 2
293: .globl _u3p0pt
294: _u3p0pt:
295: .space 1024 /*255 max pages for user #3 text */
296: .globl _u3p1pt
297: _u3p1pt:
298: .space 1024 /*255 max pages for user #3 data */
299: .globl _u3p2pt
300: _u3p2pt:
301: .space 1020 /*255 max pages for user #3 stack */
302: eu3p2pt:
303: .space 4
304:
305: /*
306: *user #4 thru 6 page tables
307: *physical memory -- pages 22 thru 30
308: */
309: .globl _u4p0pt
310: _u4p0pt:
311: .space (9*NBPG) - 4
312: eu6p2pt:
313: .space 4
314:
315: /*
316: *user #7 page tables -- P0PT, P1PT, P2PT
317: *physical memory -- page 31, 32 , & 33 respectively
318: */
319: .align 2
320: .globl _u7p0pt
321: _u7p0pt:
322: .space 1024 /*255 max pages for user #7 text */
323: .globl _u7p1pt
324: _u7p1pt:
325: .space 1024 /*255 max pages for user #7 data */
326: .globl _u7p2pt
327: _u7p2pt:
328: .space 1020 /*255 max pages for user #7 stack */
329: eu7p2pt:
330: .space 4
331:
332: .globl _iob0 /*io buffer 0 */
333: _iob0: .space 1024
334: .globl _iob1 /*io buffer 1 */
335: _iob1: .space 1024
336: .globl _iob2 /*io buffer 2 */
337: _iob2: .space 1024
338: .globl _iob3 /*io buffer 3 */
339: _iob3: .space 1024
340: .globl _iob4 /*io buffer 4 */
341: _iob4: .space 1024
342: .globl _iob5 /*io buffer 5 */
343: _iob5: .space 1024
344: .globl _iob6 /*io buffer 6 */
345: _iob6: .space 1024
346: esysdata:
347:
348: #include "scblock.s" /* SYSTEM CONTROL BLOCK */
349:
350:
351: #include "evthandlers.s" /*event handlers */
352:
353: #define ACBL(_n1,_n2,_n3,_n4) \
354: addl2 _n2,_n3;\
355: cmpl _n3,_n1;\
356: bleq _n4;
357:
358:
359:
360: /*
361: *INITIALIZATION CODE
362: *
363: * MME off; mode = k; IPL = 31; IS = 1
364: *
365: */
366:
367: .globl start
368: start:
369: mtpr $0,$MME /* Disable MME */
370: andl3 $0x3ffffc00,$_scb,r0
371: mtpr r0,$SCBB /* Set SCBB */
372: mtpr $0x1f,$IPL /* Set IPL to HIGH */
373:
374: movpsl r1
375: andl2 $0xffffff00,r1 /* Mask out flags */
376: cmpl r1,$0x041f0000 /*IS on,modes =k & IPL = 31? */
377: beql 1f
378: 2: movl $1,r0
379: movl $0x041f0000,r2
380: halt /* PSL not initialized as expected */
381: /*
382: # Mask out bit 30,31 of SCB vectors
383: # Will turm them back on when ready to go virtual in
384: # system space
385: */
386: 1:
387: clrl _clk_cnt
388: clrl _bell
389: movl $7,r0 /* R0 : Vector no. of clock int. */
390: movab _Hardclk,_scb[r0] /* New vector for clock */
391: movl $NBPG/4,r1 /* One page for SCB */
392: movab _scb,r0
393: andl2 $0x3ffffc00,r0
394: 1: andl2 $0x3fffffff,(r0)
395: addl2 $4,r0
396: decl r1 /* Last one yet ? */
397: bneq 1b
398:
399: movl $_intstack+NISP*NBPG,r0
400: andl2 $0x3fffffff,r0 /* Mask out bit 30,31 */
401: mtpr r0,$ISP /* init. ISP */
402: movl r0,sp /* in case we get exception */
403: movab (sp),fp /* Initialize FP */
404: /*
405: Clear system data area all the way upto system code
406: this includes dump buffer,interrupt stack,spt,iomap,pcbs,user
407: page tables, & io buffer area.
408: */
409: 3:
410: movab esysdata,r7
411: movab _restart,r6
412: 1: clrl (r6)
413: ACBL(r7,$4,r6,1b)
414: /*
415: Initialize System Page Table
416: */
417: 5:
418: clrl r2
419: movab esysdata,r1 /* R1 = Last address in system data area */
420: andl2 $0x3fffffff,r1 /* Mask out bit 30,31 */
421: shar $PGSHIFT,r1,r1 /* Get page no. of last system data addr */
422: /* Map systm data area 1 to 1,kernel writable */
423: 1:
424: movl r2,r11 /* Donot want to use orl3 */
425: orl2 $PG_V|PG_KW,r11
426: orl2 r11,_Sysmap[r2]
427: aoblss r1,r2,1b
428: /*
429: Map system text area 1 to 1, Kernel read/write.
430: For this to work, the label _etext must exist at the end
431: of system code;
432: */
433: movab _end,r1 /* Map text+data 1 to 1; Kernel R/W */
434: addl2 $66*(NBPG),r1 /* Some memory for power fail test */
435: andl2 $0x3fffffff,r1
436: shar $PGSHIFT,r1,r1
437: 1:
438: movl r2,r11
439: orl2 $PG_V|PG_KW,r11 /* Kernel Read/Write */
440: orl2 r11,_Sysmap[r2]
441: aoblss r1,r2,1b
442: /*
443: Map from here (1st unused page) to page 512 :
444: * invalid,no access, & virtual = physical
445: */
446: movl r2,_unused /* Save first unused physical page no */
447: movl $LSP+1,r1
448: 1: movl r2,_Sysmap[r2]
449: aoblss r1,r2,1b
450:
451: /*
452: Initialize SBR, SLR
453: *Following are some useful addresses for user 0 (in case you want
454: *to start user 0:
455: *
456: * p0br = $_u0p0pt (limit = 256 max)
457: * p1br = $_u0p1pt ( same limit)
458: * p2br = $0xbfc02c00 (funny)
459: * p2lr = $0x000ffff0 (funny)
460: *
461: *for other users, add NBPG*3 to above except for p2 area
462: *
463: * u0_user_sp = 0xbffffbfc
464: * u0_k_sp = 0xbfffe3fc
465: * u0_s_sp = 0xbfffcbfc
466: * u0_e_sp = 0xbfffcbfc
467: *
468: */
469:
470: sysrdy:
471: mtpr $_Sysmap,$SBR /* Set SYSTEM BASE REG */
472: mtpr $_Syssize,$SLR
473:
474: .globl _ready
475: _ready:
476: mtpr $64,$DCR /* Enable fault */
477:
478: /* GO TO VIRTUAL MODE
479: Double map the kernel into user addresses :
480: This will enable system to go to virtual mode the 1st time !!
481: */
482:
483: mtpr $_Sysmap,$SBR /* Set SYSTEM BASE REG */
484: mtpr $_Syssize,$SLR
485: mtpr $_Sysmap,$P0BR
486: mtpr $_Syssize,$P0LR
487: mtpr $1,$TBIA
488: mtpr $1,$PADC
489: mtpr $1,$MME
490: jmp *$vmode
491: vmode:
492: movl $_intstack+NISP*NBPG,r0
493: mtpr r0,$ISP /* init. ISP,sp to virtual address */
494: movl r0,sp
495:
496: andl3 $_pcb0,$0x3fffffff,r0
497: mtpr r0,$0xe /* Set PCBB */
498:
499: #
500: # Set up vectors for power fail/restart
501: #
502: movl $PFVEC,r0 /* R0 : Vector no. of p_fail int. */
503: movab _Pwfail,_scb[r0]
504: movl $PRVEC,r0 /* R0 : Vector no. of p_restart int. */
505: movab _Pwrest,_scb[r0]
506:
507: pushl $cmsg0
508: callf $8,_writes /* Print test heading */
509: #
510: # Set up before power fails
511: #
512: movl $0xcafebabe,_memflg /* Set memory flag */
513: clrl _pfint /* Clear power fail interrupt flag */
514: mfpr $SBR,_sbr
515: mfpr $SLR,_slr
516: mfpr $P0BR,_p0br
517: mfpr $P0LR,_p0lr
518: mtpr $TP1BR,$P1BR
519: mfpr $P1BR,_p1br
520: mtpr $TP2LR,$P2LR
521: mfpr $P2LR,_p2lr
522: mfpr $IPL,_ipl
523: mfpr $MME,_mme
524: mfpr $0xe,_Pcbb
525: mfpr $ISP,_Isp
526:
527: mtpr $7,$0x10 /* Request soft int. 7 */
528: mfpr $SISR,_Sisr
529: mfpr $SCBB,_scbb
530: mtpr $TKSP,$KSP
531: mfpr $KSP,_ksp
532: #
533: # write pattern to memory
534: # To be checked when power restored
535: #
536: movab _end,r0
537: addl2 $NBPG,r0 /* 1 page beyond end of program */
538: andl2 $0xfffffc00,r0 /* Begin address of this page */
539: movl r0,_baddr /* save this address */
540: pushl r0
541: callf $8,_pfsetup
542: #
543: # Write message to turn off power
544: #
545: pushl $cmsg1
546: callf $8,_writes
547: mtpr $10,$IPL /* allow clock interrupt */
548:
549: 1: jmp 2f /* Waiting for power to go down */
550: 2: jmp 1b
551:
552: .globl passed
553: passed:
554: halt
555: tfail: /* enter here when test fail */
556: movl $0xffffffff,r13
557: halt
558: #
559: # *****************
560: # Powerfail handler
561: # *****************
562: #
563: .align 2
564: .globl _Pwfail
565: _Pwfail:
566: incl _pfint
567: svpctx
568: 1: incl _pfcnt /* See how long TAHOE can count before stop */
569: jmp 1b
570: halt
571: #
572: # *********************
573: # Power restart handler
574: # *********************
575: #
576: .align 2
577: .globl _Pwrest
578: _Pwrest:
579: pushl _baddr
580: callf $8,_prest
581: halt
582: #
583: # *****************
584: # Hardclock handler
585: # *****************
586: #
587: .align 2
588: .globl _Hardclk
589: _Hardclk:
590: incl _clk_cnt
591: incl _bell
592: cmpl _bell,$0x50 /* Ring bell every 10 sec. */
593: jneq 1f
594: pushl $0x7
595: callf $8,_writec /* Ring bell */
596: clrl _bell
597: 1:
598: rei
599: #
600: # Message area
601: #
602: .data 1
603: cmsg0:
604: .ascii "\n\tThis is the Power fail/restart interrupt test.\12\0"
605: cmsg1:
606: .ascii "** Unplug power !!!!\12\0"
607: cmsg2:
608: .ascii "\n** Power restarted...\12\0"
609:
610: .align 2
611: _bell: .long 0
612: #
613: #
614: #
615: .globl _memflg
616: _memflg:
617: .long 0
618:
619: .globl _pfint
620: _pfint: .long 0
621:
622: .globl _pfcnt
623: _pfcnt: .long 0
624:
625: .globl _baddr
626: _baddr: .long 0
627: #
628: # Area to save the privilege registers
629: #
630: .globl _sbr
631: _sbr: .long 0
632: .globl _slr
633: _slr: .long 0
634:
635: .set TP0BR,0x100
636: .set TP0LR,0x200
637: .set TP1BR,0x300
638: .set TP1LR,0x400
639: .set TP2BR,0x500
640: .set TP2LR,0x600
641: .set TKSP,0x700
642:
643: .globl _p0br
644: _p0br: .long 0
645: .globl _p0lr
646: _p0lr: .long 0
647:
648: .globl _p1br
649: _p1br: .long 0
650: .globl _p1lr
651: _p1lr: .long 0
652:
653: .globl _p2br
654: _p2br: .long 0
655: .globl _p2lr
656: _p2lr: .long 0
657:
658: .globl _ipl
659: _ipl: .long 0
660:
661: .globl _mme
662: _mme: .long 0xf
663:
664: .globl _Pcbb
665: _Pcbb: .long 0
666:
667: .globl _Isp
668: _Isp: .long 0
669:
670: .globl _Sisr
671: _Sisr: .long 0
672:
673: .globl _scbb
674: _scbb: .long 0
675:
676: .globl _ksp
677: _ksp: .long 0
678:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.