|
|
1.1 root 1: /************************************************************************/
2: /* Revision History */
3: /* ---------- */
4: /* Rev 1.0 1 Aug 85 */
5: /* */
6: /* Initial release of the diagnostic */
7: /* */
8: /************************************************************************/
9:
10: # INIT.X for the Demand Pageing Tests
11: #
12: # This file is a diagnostic version of locore.s.
13: # It contains the following:
14: # *system data area = scb, dump buffer, interrupt stack,
15: # *system page table,user page tables,pcbs,iomap, & io buffers.
16: #
17: # *system code = interrupt vectors, initialization of system data,
18: # *memory size calculation,initialization of SPT, zeroing of
19: # *unused memory, & loading of SBR & SLR.
20: # *
21: # *at the end of this code, you are ready to go to virtual mode.
22: # * --- GOOD LUCK!
23: #
24: ##########################################################################
25: #
26: # 6-Mar-85 : changed to user mode execution
27: # 11-Mar-85 : moved mode changeing from here to RUN_CODE
28: # 17-Jul-85 : added "mtpr" test for fpp/no-fpp wcs
29: ##########################################################################
30:
31:
32: /* privileged registers addresses */
33: #include "prvreg.h"
34:
35: /* program status long word definition */
36: #include "psl.h"
37:
38: /* page table entry definition */
39: #include "pte.h"
40:
41: /* process control block offsets */
42: #include "pcboffset.h"
43:
44: /* fundamental constants for globl use */
45: #include "const.h"
46:
47: /* system control block offsets*/
48: #include "scboffset.h"
49: /* SPT offsets */
50: #include "sptoffset.h"
51:
52: /* trap numbers*/
53: #include "trap.h"
54:
55:
56: #define V_TRAP 0
57: #define V_SYSCALL 4
58:
59: .set HIGH,0x1f /*mask for disabling all interrupts */
60: .set MCKVEC,4 /*scb offset for machinecheck vector */
61: .set NISP,2 /*no. of interrupt stack pages */
62: .set DONE,255 /*user process done code */
63: .set TTRAP,0x32
64: .set PRIVS,0x2c
65:
66: .text
67:
68: /* PROCESSOR STORAGE AREA */
69: #include "pstorage.s"
70:
71: .globl _Entry
72: _Entry:
73: jmp start
74: .space (1024-6)
75:
76: /* globl dump buffer to be used for communication */
77: /* between tests & interrupt handlers, & other misc. */
78: /* purposes. */
79:
80: /* Physical page 3 : Used for global variables */
81:
82: .set NLWU,35 /*no. of longwords already used */
83: /*this must be changed when you define */
84: /*additional variables below before */
85: /*_dbuf */
86: .globl _Codek
87: _Codek: .long 0 /* Code cache key */
88:
89: .globl _restart
90: _restart:
91: .space 4 /*contains restart address for restarting*/
92: /*after power is restored (loaded by */
93: /*power fail interrupt handler & used by*/
94: /*CPU 2 */
95: .globl _maxmem
96: _maxmem:
97: .space 4 /*memory size in no of bytes */
98:
99: .globl _maxpages
100: _maxpages:
101: .space 4 /*memory size in no. of physical pages */
102:
103: .globl _lastadd
104: _lastadd:
105: .space 4 /*address of the last long word */
106:
107: .globl _unused
108: _unused:
109: .space 4 /*first unused page in system space */
110:
111: .globl _ctlblk
112: _ctlblk:
113: .long 0 /* pointer to SCB */
114:
115: .globl _savvec0 /*save vectors area */
116: _savvec0:
117: .space 4
118:
119: .globl _savvec1 /*save vectors area */
120: _savvec1:
121: .space 4
122:
123: .globl _savvec2 /*save vectors area */
124: _savvec2:
125: .space 4
126:
127: .globl _savvec3 /*save vectors area */
128: _savvec3:
129: .space 4
130:
131: .globl _savvec4 /*save vectors area */
132: _savvec4:
133: .space 4
134:
135: .globl _savvec5 /*save vectors area */
136: _savvec5:
137: .space 4
138: .globl _savvec6 /*save vectors area */
139: _savvec6:
140: .space 4
141: .globl _savvec7 /*save vectors area */
142: _savvec7:
143: .space 4
144:
145: .globl _savvec8 /*save vectors area */
146: _savvec8:
147: .space 4
148:
149: .globl _r_no
150: _r_no:
151: .long 0
152: .globl _pt_base
153: _pt_base:
154: .long 0
155: .globl _saved_psl
156: _saved_psl:
157: .long 0
158: .globl _saved_sp
159: _saved_sp:
160: .long 0
161: .globl _saved_fp
162: _saved_fp:
163: .long 0
164: .globl _ret_adr
165: _ret_adr:
166: .long 0
167: .globl _exp_par0
168: _exp_par0:
169: .long 0
170: .globl _exp_par1
171: _exp_par1:
172: .long 0
173: .globl _f_vaddr
174: _f_vaddr:
175: .long 0 /* VA that caused fault */
176:
177: .globl _f_ptr
178: _f_ptr:
179: .long 0 /* Pointer to fault parameters */
180: .globl _df_cnt
181: _df_cnt:
182: .long 0 /* Count of data fault */
183:
184: .globl _if_cnt
185: _if_cnt:
186: .long 0 /* Count of Instruction fault */
187:
188: .globl _newepc
189: _newepc:
190: .long 0
191:
192: .globl _errcnt
193: _errcnt:
194: .long 0
195:
196: .globl _clk_cnt
197: _clk_cnt:
198: .long 0
199:
200: .globl _ttcnt
201: _ttcnt:
202: .long 0 /* Count of Trap exception */
203: .globl _trcnt
204: _trcnt:
205: .long 0 /* Count of Translation fault */
206:
207: .globl _Ufpte
208: _Ufpte: .long 0
209: .globl _Ulpte
210: _Ulpte: .long 0
211:
212: .globl _dbuf /*dump buffer left out of 1K */
213: _dbuf:
214: .space NBPG - (NLWU *4)
215: edbuf:
216:
217:
218: .globl _intstack /* Interrupt stack */
219: _intstack: /* Physical pages 4 & 5 */
220: .space NISP*NBPG
221: eintstack:
222:
223:
224: .set SYSPTSIZE,512 /* No. of entries in SPT */
225:
226: /*
227: System Page Table -- physical page 6 & 7
228: */
229: .align 2
230: .globl _Sysmap
231: _Sysmap:
232: .space SYSPTSIZE*4 /* 512 max pages allowed for system */
233: eSysmap:
234: .globl _Syssize
235: .set _Syssize,(eSysmap-_Sysmap)/4 /* should be SYSPTSIZE */
236:
237: .globl _iomap /* Physical page 8 */
238: _iomap: .space 1024 /* IOMAP - unused */
239: .globl _eiomap
240: _eiomap:
241:
242: .globl _pcb0 /* Physical page 9 */
243: _pcb0: .space 128 /*process control block 0 */
244: .globl _pcb1
245: _pcb1: .space 128 /*process control block 1 */
246: .globl _pcb2
247: _pcb2: .space 128 /*process control block 2 */
248: .globl _pcb3
249: _pcb3: .space 128 /*process control block 3 */
250: .globl _pcb4
251: _pcb4: .space 128 /*process control block 4 */
252: .globl _pcb5
253: _pcb5: .space 128 /*process control block 5 */
254: .globl _pcb6
255: _pcb6: .space 128 /*process control block 6 */
256: .globl _pcb7
257: _pcb7: .space 128 /*process control block 7 */
258:
259: /*
260: *user #0 page tables -- P0PT, P1PT, P2PT
261: *physical memory -- page10, 11, & 12 respectively
262: */
263: .align 2
264: .globl _u0p0pt
265: _u0p0pt:
266: .space 1024 /*255 max pages for user #0 text */
267: .globl _u0p1pt
268: _u0p1pt:
269: .space 1024 /*255 max pages for user #0 data */
270: .globl _u0p2pt
271: _u0p2pt:
272: .space 1020 /*255 max pages for user #0 stack */
273: eu0p2pt:
274: .space 4
275:
276: /*
277: *user #1 page tables -- P0PT, P1PT, P2PT
278: *physical memory -- page13 ,14, & 15 respectively
279: */
280: .align 2
281: .globl _u1p0pt
282: _u1p0pt:
283: .space 1024 /*255 max pages for user #1 text */
284: .globl _u1p1pt
285: _u1p1pt:
286: .space 1024 /*255 max pages for user #1 data */
287: .globl _u1p2pt
288: _u1p2pt:
289: .space 1020 /*255 max pages for user #1 stack */
290: eu1p2pt:
291: .space 4
292:
293:
294: /*
295: *user #2 page tables -- P0PT, P1PT, P2PT
296: *physical memory -- page 16, 17 , & 18 respectively
297: */
298: .align 2
299: .globl _u2p0pt
300: _u2p0pt:
301: .space 1024 /*255 max pages for user #2 text */
302: .globl _u2p1pt
303: _u2p1pt:
304: .space 1024 /*255 max pages for user #2 data */
305: .globl _u2p2pt
306: _u2p2pt:
307: .space 1020 /*255 max pages for user #2 stack */
308: eu2p2pt:
309: .space 4
310:
311:
312: /*
313: *user #3 page tables -- P0PT, P1PT, P2PT
314: *physical memory -- page 19, 20 , & 21 respectively
315: */
316: .align 2
317: .globl _u3p0pt
318: _u3p0pt:
319: .space 1024 /*255 max pages for user #3 text */
320: .globl _u3p1pt
321: _u3p1pt:
322: .space 1024 /*255 max pages for user #3 data */
323: .globl _u3p2pt
324: _u3p2pt:
325: .space 1020 /*255 max pages for user #3 stack */
326: eu3p2pt:
327: .space 4
328:
329: /*
330: *user #4 thru 6 page tables
331: *physical memory -- pages 22 thru 30
332: */
333: .globl _u4p0pt
334: _u4p0pt:
335: .space (9*NBPG) - 4
336: eu6p2pt:
337: .space 4
338:
339: /*
340: Area used for Kernel stack
341: physical memory -- page 31, 32 , 33
342: */
343:
344: .align 2
345: .globl _Kstack /* Kernel stack */
346: _Kstack: /* Physical pages 31,32,33 */
347: .space 3*NBPG
348: .globl ekstack
349: ekstack:
350:
351:
352: .globl _iob0 /*io buffer 0 */
353: _iob0: .space 1024
354: .globl _iob1 /*io buffer 1 */
355: _iob1: .space 1024
356: .globl _iob2 /*io buffer 2 */
357: _iob2: .space 1024
358: .globl _iob3 /*io buffer 3 */
359: _iob3: .space 1024
360: .globl _iob4 /*io buffer 4 */
361: _iob4: .space 1024
362: .globl _iob5 /*io buffer 5 */
363: _iob5: .space 1024
364: .globl _iob6 /*io buffer 6 */
365: _iob6: .space 1024
366: esysdata:
367:
368: /* SYSTEM CONTROL BLOCK */
369: #include "scblock.s"
370:
371:
372:
373: #include "evthandlers.s"
374:
375: #define ACBL(_n1,_n2,_n3,_n4) addl2 _n2,_n3; cmpl _n3,_n1; bleq _n4;
376:
377:
378:
379: # *INITIALIZATION CODE
380: # *
381: # * MME off; mode = k; IPL = 31; IS = 1
382: # *
383:
384:
385: .globl start
386: start:
387: mtpr $0,$MME /* Disable MME */
388: movl r0,_run_list
389: movl r1,_OPTIONS
390: clrl _nonstop /* clear the continuous run flag */
391: movl r2,_count /* save the test count */
392: bneq 1f /* is count = 0 ? */
393: movl $1,_count /* yes -set cycle count = 1 */
394: 1: bgeq 1f /* is count < 0 ? */
395: movl $1,_nonstop /* yes -set NONSTOP flag */
396: 1:
397: clrl _no_fpp_wcs /* clear the NO-FPP WCS flag */
398: mtpr $0x400,$DCR /* check for FPP WCS loaded */
399: tstl r1 /* r1 = 0 if NO-FPP WCS loaded */
400: bneq 1f
401: movl $1,_no_fpp_wcs /* set the NO-FPP WCS flag */
402: 1:
403: movab _scb,r0
404: andl2 $0x3ffffc00,r0
405: mtpr r0,$SCBB /* Set SCBB */
406: mtpr $0x1f,$IPL /* Set IPL to HIGH */
407:
408: andl3 $4,r11,_ss1 /* messages sense switch */
409:
410: #
411: # clear the option flags
412: #
413: clrl _halt_flg /* clear the halt on error flag */
414: clrl _loop_on_err /* clear the loop on error flag */
415: movl $1,_prt_error /* set the print error messages flag */
416: movl $1,_prt_hdrs /* set the print header messages flag */
417: movl $1,_en_data_cache /* set the enable data cache flag */
418: movl $1,_user_mode /* set the Run In User Mode flag */
419: clrl _exp_event /* clear the fpp event expected flag */
420: clrl _event_return /* clear the fpp event return flag */
421: clrl _unexp_event_ret /*clear the unexpected event return addr */
422:
423: #
424: # set the option flags as needed
425: #
426: bitl $1,_OPTIONS /* bit(0) = HALT ON ERROR */
427: beql 1f
428: movl $1,_halt_flg /* set the HALT ON ERROR flag */
429: 1:
430: bitl $2,_OPTIONS /* bit(1) = LOOP ON ERROR */
431: beql 1f
432: movl $1,_loop_on_err /* set the LOOP ON ERROR flag */
433: 1:
434: bitl $4,_OPTIONS /* bit(2) = PRINT ERROR MESSAGES */
435: beql 1f
436: clrl _prt_error /* clear the PRINT ERROR MESSAGES flag */
437: 1:
438: bitl $8,_OPTIONS /* bit(3) = PRINT HEADER MESSAGES */
439: beql 1f
440: clrl _prt_hdrs /* clear the PRINT HEADER MESSAGES flag */
441: 1:
442: bitl $16,_OPTIONS /* bit(4) = ENABLE DATA CACHE flag */
443: beql 1f
444: clrl _en_data_cache /* clear the ENABLE DATA CACHE flag */
445: 1:
446: bitl $32,_OPTIONS /* bit(5) = DON'T RUN IN USER MODE flag */
447: beql 1f
448: clrl _user_mode /* reset the RUN IN USER MODE flag */
449: 1:
450: movpsl r1
451: andl2 $0xffffff00,r1 /* Mask out flags */
452: cmpl r1,$0x041f0000 /*IS on,modes =k & IPL = 31? */
453: beql 1f
454: 2: movl $1,r0
455: movl $0x041f0000,r2
456: halt /* PSL not initialized as expected */
457: 1:
458: movl $_intstack+NISP*NBPG,r0
459: andl2 $0x3fffffff,r0 /* Mask out bit 30,31 */
460: mtpr r0,$ISP /* init. ISP */
461: movl r0,sp /* in case we get exception */
462: movab (sp),fp /* Initialize FP */
463: #
464: # Clear system data area all the way upto system code
465: # this includes dump buffer,interrupt stack,spt,iomap,pcbs,user
466: # page tables, & io buffer area.
467: #
468: 3:
469: movab esysdata,r7
470: movab _restart,r6
471: 1: clrl (r6)
472: ACBL(r7,$4,r6,1b)
473: #
474: # Initialize System Page Table
475: #
476: 5:
477: clrl r2
478: movab esysdata,r1 /* R1 = Last address in system data area */
479: andl2 $0x3fffffff,r1 /* Mask out bit 30,31 */
480: shar $PGSHIFT,r1,r1 /* Get page no. of last system data addr */
481: /* Map systm data area 1 to 1,kernel writable */
482: 1:
483: orl3 $PG_V|PG_KW,r2,_Sysmap[r2]
484: aoblss r1,r2,1b
485:
486: #
487: # Map system text area 1 to 1, Kernel read/write.
488: # For this to work, the label _etext must exist at the end
489: # of system code; Add in 4 more pages for data area used in C
490: #
491: movab _Esys,r1 /* Map System text 1 to 1; Kernel R/W */
492: andl2 $0x3fffffff,r1
493: shar $PGSHIFT,r1,r1
494: 1:
495: orl3 $PG_V|PG_KW,r2,_Sysmap[r2]
496: aobleq r1,r2,1b
497: #
498: # Map from here to last page used by user :
499: # invalid, User access, & virtual = physical
500: #
501: movl r2,_unused /* Save first unused physical page no */
502: movl r2,_Ufpte /* First PTE of User */
503: movl $0x80000,r1 /* Allow this much memory for User */
504: shar $PGSHIFT,r1,r1
505: movl r1,_Ulpte /* Last PTE of User */
506:
507: 1:
508: orl3 $PG_V|PG_UW,r2,_Sysmap[r2] /* Valid / User Read/Write */
509: aoblss r1,r2,1b
510:
511: #
512: # Initialize SBR, SLR
513: #
514: sysrdy:
515: mtpr $_Sysmap,$SBR /* Set SYSTEM BASE REG */
516: mtpr $_Syssize,$SLR
517: mtpr $64,$DCR /* Enable fault */
518:
519: # GO TO VIRTUAL MODE
520: # Double map the kernel into user addresses :
521: # This will enable system to go to virtual mode the 1st time !!
522: #
523:
524: orl3 $0xc0000000,$_Sysmap,r0
525: mtpr r0,$P0BR /* Double map P0BR to SBR */
526: mtpr $_Syssize,$P0LR
527: mtpr $1,$PADC /* Purge all data cache */
528: mtpr $1,$TBIA /* Purge all Trans. buffer */
529:
530: mfpr $SCBB,r0
531: movab _Trans,TRANSVEC(r0) /* Set new trans. fault handler */
532: movab _Prvis,PRIVSVEC(r0) /* Set new priv. ins. fault handler */
533: moval _FPM_handler,FPMVEC(r0) /* Set now fpm trap handler */
534: mtpr $_pcb0,$0xe /* Init. PCBB to PCB_0 */
535:
536: movab _pcb0,r0
537: movab ekstack,PCB_KSP(r0) /* Init. PCB_KSP */
538: movab eustack,PCB_USP(r0) /* Init. PCB_USP */
539: mfpr $P0BR,PCB_P0BR(r0) /* " PCB_P0BR */
540: mfpr $P0LR,PCB_P0LR(r0) /* " PCB_P0LR */
541: movl $0x001f000,PCB_PSL(r0) /* Set PCB_PSL : Kernel Mode */
542: ldpctx /* load the process context */
543:
544: mtpr $1,$PACC /* purge the code cache */
545: movl $1,_Codek
546: mtpr _Codek,$CCK /* Set code cache key */
547:
548: callf $4,_monitor /* go execute the test */
549:
550:
551: #include "fault_handlers.s" /* put spectial handlers here */
552:
553:
554: # /****************************************************************************
555: # * STACK AREA
556: # ****************************************************************************/
557:
558: .globl _Esys /* end of systems only code */
559: _Esys:
560: .space NBPG
561:
562: .globl _Ustack /* basic stack space */
563: _Ustack:
564: .space (2*NBPG)-4 /* 2 pages */
565: .globl eustack
566: eustack:
567: .long 0 /* initial user stack ptr */
568:
569: .globl U_area
570: U_area:
571:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.