|
|
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 P0SPACE 1 /* This test run in P0 space */
43: #define TRUE 1
44: #define V_TRAP 0
45: #define V_SYSCALL 4
46:
47: .set HIGH,0x1f /*mask for disabling all interrupts */
48: .set MCKVEC,4 /*scb offset for machinecheck vector */
49: .set NISP,2 /*no. of interrupt stack pages */
50: .set DONE,255 /*user process done code */
51: .globl MME
52: .set MME,9
53:
54: .text
55:
56: #include "pstorage.s" /* PROCESSOR STORAGE AREA */
57:
58: .globl _Entry
59: _Entry:
60: jmp start
61: .space (1024-6)
62:
63:
64:
65: /* globl dump buffer to be used for communication */
66: /* between tests & interrupt handlers, & other misc. */
67: /* purposes. */
68:
69: /*physical page 3 */
70:
71: .set NLWU,30 /*no. of longwords already used */
72: /*this must be changed when you define */
73: /*additional variables below before */
74: /*_dbuf */
75: .globl _restart
76: _restart:
77: .space 4 /*contains restart address for rastarting*/
78: /*after power is restored (loaded by */
79: /*power fail interrupt handler & used by*/
80: /*CPU 2 */
81: .globl _maxmem
82: _maxmem:
83: .space 4 /*memory size in no of bytes */
84:
85: .globl _maxpages
86: _maxpages:
87: .space 4 /*memory size in no. of physical pages */
88:
89: .globl _lastadd
90: _lastadd:
91: .space 4 /*address of the last long word */
92:
93: .globl _unused
94: _unused:
95: .space 4 /*first unused page in system space */
96:
97: .globl _ctlblk
98: _ctlblk:
99: .long 0 /* pointer to SCB */
100:
101: .globl _savvec0 /*save vectors area */
102: _savvec0:
103: .space 4
104:
105: .globl _savvec1 /*save vectors area */
106: _savvec1:
107: .space 4
108:
109: .globl _savvec2 /*save vectors area */
110: _savvec2:
111: .space 4
112:
113: .globl _savvec3 /*save vectors area */
114: _savvec3:
115: .space 4
116:
117: .globl _savvec4 /*save vectors area */
118: _savvec4:
119: .space 4
120:
121: .globl _savvec5 /*save vectors area */
122: _savvec5:
123: .space 4
124: .globl _savvec6 /*save vectors area */
125: _savvec6:
126: .space 4
127: .globl _savvec7 /*save vectors area */
128: _savvec7:
129: .space 4
130: .globl _dbuf /*dump buffer left out of 1K */
131: .globl _r_no
132: _r_no:
133: .long 0
134: .globl _pt_base
135: _pt_base:
136: .long 0
137: .globl _saved_psl
138: _saved_psl:
139: .long 0
140: .globl _saved_sp
141: _saved_sp:
142: .long 0
143: .globl _saved_fp
144: _saved_fp:
145: .long 0
146: .globl _p_ptr
147: _p_ptr:
148: .long 0
149: .globl _ret_adr
150: _ret_adr:
151: .long 0
152: .globl _exp_par0
153: _exp_par0:
154: .long 0
155: .globl _exp_par1
156: _exp_par1:
157: .long 0
158: .globl _exp_par2
159: _exp_par2:
160: .long 0
161: .globl _exp_par3
162: _exp_par3:
163: .long 0
164: .globl _act_par0
165: _act_par0:
166: .long 0
167: .globl _act_par1
168: _act_par1:
169: .long 0
170: .globl _act_par2
171: _act_par2:
172: .long 0
173: .globl _act_par3
174: _act_par3:
175: .long 0
176: .globl _test_no
177: _test_no:
178: .long 0
179: _dbuf:
180: .space NBPG - (NLWU *4)
181: edbuf:
182:
183:
184: .globl _intstack /* Interrupt stack */
185: _intstack: /* Physical pages 4 & 5 */
186: .space NISP*NBPG
187: eintstack:
188:
189:
190: .set SYSPTSIZE,512 /* No. of entries in SPT */
191:
192: /*
193: System Page Table -- physical page 6 & 7
194: */
195: .align 2
196: .globl _Sysmap
197: _Sysmap:
198: .space SYSPTSIZE*4 /* 512 max pages allowed for system */
199: eSysmap:
200: .globl _Syssize
201: .set _Syssize,(eSysmap-_Sysmap)/4 /* should be SYSPTSIZE */
202:
203: .globl _iomap /* Physical page 8 */
204: _iomap: .space 1024 /* IOMAP - unused */
205: .globl _eiomap
206: _eiomap:
207:
208: .globl _pcb0 /* Physical page 9 */
209: _pcb0: .space 128 /*process control block 0 */
210: .globl _pcb1
211: _pcb1: .space 128 /*process control block 1 */
212: .globl _pcb2
213: _pcb2: .space 128 /*process control block 2 */
214: .globl _pcb3
215: _pcb3: .space 128 /*process control block 3 */
216: .globl _pcb4
217: _pcb4: .space 128 /*process control block 4 */
218: .globl _pcb5
219: _pcb5: .space 128 /*process control block 5 */
220: .globl _pcb6
221: _pcb6: .space 128 /*process control block 6 */
222: .globl _pcb7
223: _pcb7: .space 128 /*process control block 7 */
224:
225: /*
226: *user #0 page tables -- P0PT, P1PT, P2PT
227: *physical memory -- page10, 11, & 12 respectively
228: */
229: .align 2
230: .globl _u0p0pt
231: _u0p0pt:
232: .space 1024 /*255 max pages for user #0 text */
233: .globl _u0p1pt
234: _u0p1pt:
235: .space 1024 /*255 max pages for user #0 data */
236: .globl _u0p2pt
237: _u0p2pt:
238: .space 1020 /*255 max pages for user #0 stack */
239: eu0p2pt:
240: .space 4
241:
242: /*
243: *user #1 page tables -- P0PT, P1PT, P2PT
244: *physical memory -- page13 ,14, & 15 respectively
245: */
246: .align 2
247: .globl _u1p0pt
248: _u1p0pt:
249: .space 1024 /*255 max pages for user #1 text */
250: .globl _u1p1pt
251: _u1p1pt:
252: .space 1024 /*255 max pages for user #1 data */
253: .globl _u1p2pt
254: _u1p2pt:
255: .space 1020 /*255 max pages for user #1 stack */
256: eu1p2pt:
257: .space 4
258:
259:
260: /*
261: *user #2 page tables -- P0PT, P1PT, P2PT
262: *physical memory -- page 16, 17 , & 18 respectively
263: */
264: .align 2
265: .globl _u2p0pt
266: _u2p0pt:
267: .space 1024 /*255 max pages for user #2 text */
268: .globl _u2p1pt
269: _u2p1pt:
270: .space 1024 /*255 max pages for user #2 data */
271: .globl _u2p2pt
272: _u2p2pt:
273: .space 1020 /*255 max pages for user #2 stack */
274: eu2p2pt:
275: .space 4
276:
277:
278: /*
279: *user #3 page tables -- P0PT, P1PT, P2PT
280: *physical memory -- page 19, 20 , & 21 respectively
281: */
282: .align 2
283: .globl _u3p0pt
284: _u3p0pt:
285: .space 1024 /*255 max pages for user #3 text */
286: .globl _u3p1pt
287: _u3p1pt:
288: .space 1024 /*255 max pages for user #3 data */
289: .globl _u3p2pt
290: _u3p2pt:
291: .space 1020 /*255 max pages for user #3 stack */
292: eu3p2pt:
293: .space 4
294:
295: /*
296: *user #4 thru 6 page tables
297: *physical memory -- pages 22 thru 30
298: */
299: .globl _u4p0pt
300: _u4p0pt:
301: .space (9*NBPG) - 4
302: eu6p2pt:
303: .space 4
304:
305: /*
306: *user #7 page tables -- P0PT, P1PT, P2PT
307: *physical memory -- page 31, 32 , & 33 respectively
308: */
309: .align 2
310: .globl _u7p0pt
311: _u7p0pt:
312: .space 1024 /*255 max pages for user #7 text */
313: .globl _u7p1pt
314: _u7p1pt:
315: .space 1024 /*255 max pages for user #7 data */
316: .globl _u7p2pt
317: _u7p2pt:
318: .space 1020 /*255 max pages for user #7 stack */
319: eu7p2pt:
320: .space 4
321:
322: .globl _iob0 /*io buffer 0 */
323: _iob0: .space 1024
324: .globl _iob1 /*io buffer 1 */
325: _iob1: .space 1024
326: .globl _iob2 /*io buffer 2 */
327: _iob2: .space 1024
328: .globl _iob3 /*io buffer 3 */
329: _iob3: .space 1024
330: .globl _iob4 /*io buffer 4 */
331: _iob4: .space 1024
332: .globl _iob5 /*io buffer 5 */
333: _iob5: .space 1024
334: .globl _iob6 /*io buffer 6 */
335: _iob6: .space 1024
336: esysdata:
337:
338: #include "scblock.s" /* SYSTEM CONTROL BLOCK */
339:
340:
341:
342:
343:
344:
345:
346: #include "evthandlers.s" /*event handlers */
347:
348: #define ACBL(_n1,_n2,_n3,_n4) \
349: addl2 _n2,_n3;\
350: cmpl _n3,_n1;\
351: bleq _n4;
352:
353:
354:
355: /*
356: *INITIALIZATION CODE
357: *
358: * MME off; mode = k; IPL = 31; IS = 1
359: *
360: */
361:
362: .globl start
363: start:
364: mtpr $0,$MME /* Disable MME */
365: movl r0,_tno /* R0 = Test no */
366: movl r1,_option /* R1 = Options */
367: movl r2,_Cycle
368: clrl _cycle
369:
370: andl3 _option,$0x8,_ss1 /* Bit 5 : Inhibit heading messages */
371: andl3 _option,$0x4,_Emsg /* Bit 3 : Loop on test */
372: clrl _lptest
373:
374: tstl _tno /* Set lptest if tno == XX and loop forever */
375: beql dmtest
376: cmpl $-1,_Cycle
377: bneq dmtest
378: incl _lptest
379: dmtest:
380: movab _scb,r0
381: mtpr r0,$SCBB /* Set SCBB */
382: mtpr $0x1f,$IPL
383:
384: movpsl r1
385: andl2 $0xffffff00,r1 /* Mask out flags */
386: cmpl r1,$0x041f0000 /*IS on,modes =k & IPL = 31? */
387: beql 1f
388: 2: movl $1,r0
389: movl $0x041f0000,r2
390: halt /* PSL not initialized as expected */
391: 1:
392: mtpr $_intstack+NISP*NBPG,$ISP /* init. ISP */
393: movl $_intstack+NISP*NBPG,sp /* in case we get exception */
394: movab (sp),fp /* Initialize FP */
395:
396: /*
397: Clear system data area all the way upto system code
398: this includes dump buffer,interrupt stack,spt,iomap,pcbs,user
399: page tables, & io buffer area.
400: */
401: 3:
402: movab esysdata,r7
403: movab _restart,r6
404: 1: clrl (r6)
405: ACBL(r7,$4,r6,1b)
406: /*
407: Initialize System Page Table
408: */
409: 5:
410: clrl r2
411: movab esysdata,r1 /* R1 = Last address in system data area */
412: andl2 $0x3fffffff,r1 /* Mask out bit 30,31 */
413: shar $PGSHIFT,r1,r1 /* Get page no. of last system data addr */
414: /* Map systm data area 1 to 1,kernel writable */
415: 1:
416: movl r2,r11 /* Donot want to use orl3 */
417: orl2 $PG_V|PG_KW,r11
418: orl2 r11,_Sysmap[r2]
419: aoblss r1,r2,1b
420: /*
421: Map system text area 1 to 1, Kernel read/write.
422: For this to work, the label _etext must exist at the end
423: of system code; Add in 4 more pages for data area used in C
424: */
425: movab _edata + 4*(NBPG-1),r1 /* Map text+data 1 to 1; Kernel R/W */
426: /* movab _etext + 4*(NBPG-1), r1 */
427: andl2 $0x3fffffff,r1
428: shar $PGSHIFT,r1,r1
429: 1:
430: movl r2,r11
431: orl2 $PG_V|PG_KW,r11 /* Kernel Read/Write */
432: orl2 r11,_Sysmap[r2]
433: aoblss r1,r2,1b
434: /*
435: Map from here (1st unused page) to page 512 :
436: * invalid,no access, & virtual = physical
437: */
438: movl r2,_unused /* Save first unused physical page no */
439: movl $LSP+1,r1
440: 1: movl r2,_Sysmap[r2]
441: aoblss r1,r2,1b
442:
443: /*
444: Initialize SBR, SLR
445: *Following are some useful addresses for user 0 (in case you want
446: *to start user 0:
447: *
448: * p0br = $_u0p0pt (limit = 256 max)
449: * p1br = $_u0p1pt ( same limit)
450: * p2br = $0xbfc02c00 (funny)
451: * p2lr = $0x000ffff0 (funny)
452: *
453: *for other users, add NBPG*3 to above except for p2 area
454: *
455: * u0_user_sp = 0xbffffbfc
456: * u0_k_sp = 0xbfffe3fc
457: * u0_s_sp = 0xbfffcbfc
458: * u0_e_sp = 0xbfffcbfc
459: *
460: */
461:
462: sysrdy:
463: cmpl $TRUE,$P0SPACE
464: bneq 0f
465: mtpr $_Sysmap,$SBR /* Physical mode */
466: brb 1f
467: 0: mtpr $(_Sysmap-0xc0000000),$SBR /* Virtual mode version */
468: 1: mtpr $_Syssize,$SLR
469:
470: /*
471: Double map the kernel into user addresses :
472: This will enable system to go to virtual mode the 1st time !!
473: */
474: .globl _ready
475: mtpr $_Sysmap,$P0BR
476: mtpr $_Syssize,$P0LR
477: _ready:
478: cmpl $P0SPACE,$TRUE /* Run physical ? */
479: beql pmode
480:
481: /* GO TO VIRTUAL MODE */
482: mtpr $1,$DCK /* Set data cache key */
483: mtpr $0,$TBIA /* Invalidate translation buffer */
484: mtpr $1,$DCR /* Enable data cache */
485: mtpr $1,$PADC /* Purge all data cache */
486: mtpr $1,$MME /* Turn on MME */
487: jmp *$pmode /* Go .... */
488: pmode:
489: mtpr $0,$P0LR /* Invalidate user map */
490: mtpr $_pcb0,$PCBB /* Initialize PCBB */
491: movl $0,_test_no
492: mtpr $64,$DCR /* enable fault */
493:
494: tstl _ss1
495: jeql nxt0
496: pushl $M0
497: callf $4+4,_writes /* Print heading */
498:
499: nxt0: cmpl $0,_tno
500: beql t0
501: cmpl $1,_tno
502: bneq nxt1
503: t0:
504: tstl _ss1
505: jeql 1f
506: pushl $D1
507: callf $4+4,_writes
508: 1:
509: calls $4,_dmp
510: tstl _lptest
511: bneq t0
512:
513: nxt1: cmpl $0,_tno
514: beql t1
515: cmpl $2,_tno
516: bneq nxt2
517: t1:
518: tstl _ss1
519: jeql 1f
520: pushl $D2
521: callf $4+4,_writes
522: 1:
523: calls $4,_dmp0
524: tstl _lptest
525: bneq t1
526:
527: nxt2: cmpl $0,_tno
528: beql t2
529: cmpl $3,_tno
530: bneq nxt3
531: t2:
532: tstl _ss1
533: jeql 1f
534: pushl $D3
535: callf $4+4,_writes
536: 1:
537: calls $4,_dmp1
538: tstl _lptest
539: bneq t2
540:
541: nxt3: cmpl $0,_tno
542: beql t3
543: cmpl $4,_tno
544: bneq nxt4
545: t3:
546: tstl _ss1
547: jeql 1f
548: pushl $D4
549: callf $4+4,_writes
550: 1:
551: calls $4,_dmp2
552: tstl _lptest
553: bneq t3
554:
555: nxt4: cmpl $0,_tno
556: beql t4
557: cmpl $5,_tno
558: bneq nxt5
559: t4:
560: tstl _ss1
561: jeql 1f
562: pushl $D5
563: callf $4+4,_writes
564: 1:
565: calls $4,_dmp3
566: tstl _lptest
567: bneq t4
568:
569: nxt5: cmpl $0,_tno
570: beql t5
571: cmpl $6,_tno
572: bneq nxt6
573: t5:
574: tstl _ss1
575: jeql 1f
576: pushl $D6
577: callf $4+4,_writes
578: 1:
579: calls $4,_dmp4
580: tstl _lptest
581: bneq t5
582:
583: nxt6: cmpl $0,_tno
584: beql t6
585: cmpl $7,_tno
586: bneq nxt7
587: t6:
588: tstl _ss1
589: jeql 1f
590: pushl $D7
591: callf $4+4,_writes
592: 1:
593: calls $4,_dmp5
594: tstl _lptest
595: bneq t6
596:
597: nxt7: cmpl $0,_tno
598: beql t7
599: cmpl $8,_tno
600: bneq nxt8
601: t7:
602: tstl _ss1
603: jeql 1f
604: pushl $D8
605: callf $4+4,_writes
606: 1:
607: calls $4,_dmp6
608: tstl _lptest
609: bneq t7
610:
611: nxt8:
612: cmpl $-1,_Cycle
613: jeql dmtest
614:
615: incl _cycle
616: cmpl _cycle,_Cycle
617: bgeq passed
618: jmp dmtest
619:
620: .globl passed
621: passed:
622: tstl _ss1
623: jneq 1f
624: pushl $M2
625: callf $4+4,_writes
626: pushl _Cycle
627: callf $4+4,_writeh
628: pushl $M1
629: callf $4+4,_writes
630: 1:
631: movl $0xcafebabe,r0
632: halt /* Good halt : R0 == CAFE BABE */
633:
634: .align 2
635: .globl _ss1
636: _ss1: .long 0 /* If 1 then donot print heading message */
637: .globl _tno
638: _tno: .long 0
639: .globl _cycle
640: _cycle: .long 0
641: .globl _Cycle
642: _Cycle: .long 0
643: .globl _Emsg
644: _Emsg:
645: .long 0
646: .globl _lptest
647: _lptest:
648: .globl _option
649: _option:
650: .long 0
651:
652:
653: .data 1 /* MESSAGE AREA */
654: M0: .ascii "\n\t** The Demand Paging Test **\n\0"
655: M1: .ascii "\n** Passed..\n\0"
656: M2: .ascii "\n** Cycle count : \0"
657: D1: .ascii "1 : CALLS instruction.\n\0"
658: D2: .ascii "2 : SP auto decrement.\n\0"
659: D3: .ascii "3 : SP auto increment deferred.\n\0"
660: D4: .ascii "4 : Dirrect register mode.\n\0"
661: D5: .ascii "5 : Register longword displacement deferred indexed\n\0"
662: D6: .ascii "6 : PC longword relative deferred indexed.\n\0"
663: D7: .ascii "7 : EMUL with register longword displacement deferred indexed.\n\0"
664: D8: .ascii "8 : Register longword displacement deferred indexed,fault at the indirrect address.\n\0"
665:
666:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.