|
|
1.1 root 1: #include "data.h"
2: #include "definitions"
3:
4: extern long savvec4, iob1, iob2, pcb0;
5:
6: /* Demand paging with longword displacement deferred indexed
7: Boundery of virtual Page 97 and 98 are used in this test. Opcodes of
8: the "clrl *12(r5)[r6]" instruction is moved to last byte in page 22
9: and operand specifiers are moved to 1st byte in page 23. PTE of Page
10: 23 is then set to invalid.
11: */
12:
13: long d5pc, exp_pc, act_pc, exp_psl, exp_fvadr, act_fvadr, exp_val, act_val;
14: long dummy, saved_vec1, saved_vec2, saved_pte1, saved_pte2;
15: char *msg1, *msg2;
16:
17:
18: dmp3()
19: {
20:
21: asm("mfpr $SBR,_savvec4");
22: savvec4 |= (savvec4 | SADDR); /* Make it system address */
23: asm("mtpr _savvec4,$P0BR"); /* Double map P0PT to SPT */
24: asm("mfpr $SLR,_savvec4");
25: asm("mtpr _savvec4,$P0LR");
26:
27: asm("mtpr $6,$DCK");
28: asm("mtpr $0,$TBIA");
29: asm("mtpr $0,$PADC");
30: asm("mtpr $1,$MME"); /* Enable MME */
31: asm("jmp *$0f"); /* Go virtual */
32: asm("0:");
33: tst_dmp3();
34: asm("mtpr $0,$MME"); /* Disable MME */
35: asm("mtpr $0,$P0LR");
36: }
37:
38:
39: tst_dmp3()
40: { char *byte_ptr, *msg1, *msg2;
41: long dummy, ix, hdr_adr, pc_err, byte_no;
42:
43: savvec4 = (long)&pcb0;
44: asm("mtpr _savvec4,$PCBB"); /* Initialize PCBB */
45:
46: asm("movab r5_here,_savvec4"); /* Make test area user read/write */
47: savvec4 = (savvec4 >> PGSHIFT) & 0xfffff;
48: fixpv_pte(P0BR,savvec4,&dummy,(PTE_V|PTE_UW));
49:
50: fixpv_pte(P0BR,(TEST_PG-1),&saved_pte1,(PTE_V|PTE_UW));
51:
52: for(byte_no=1;byte_no<I3;byte_no++)
53: {
54: /* Move code to boundery of test page */
55: exp_pc = ((TEST_PG-1)<<PGSHIFT)|(NBPG-byte_no);
56: byte_ptr = (char *)exp_pc;
57: for(ix=0;ix<I3;ix++) *byte_ptr++ = CLRL3[ix];
58: *byte_ptr++ = KCALL[0]; /* move KCALL instruction */
59: *byte_ptr = KCALL[1];
60:
61: exp_fvadr = (TEST_PG<<PGSHIFT) & 0xfffffc00;
62: /* Invalidate PTE of test page */
63: fixpv_pte(P0BR,TEST_PG,&saved_pte2,PTE_UW);
64:
65: /* Set new exception handlers */
66: asm("movab prot_f3,_savvec4");
67: set_handler(TRANS_VEC,&saved_vec1,savvec4);
68:
69: /* Set up to execute REI */
70: asm("movab (sp),_savvec4");
71: savvec4 -= 16; /* KSP is 4 words below ISP */
72: asm("mtpr _savvec4,$KSP");
73: asm("movl fp,_saved_fp"); /* save FP to return */
74: exp_psl = PSL_USR; /* PSL : user mode */
75: asm("again:");
76: asm("pushl _exp_psl"); /* Push PSL on stack */
77: asm("pushl _exp_pc"); /* Push PC on stack */
78:
79: /* Set up for CLRL *12(r5)[r6] */
80: asm("movab r5_here,r5");
81: asm("movl $1,r6"); /* Set index value in r6 */
82: asm("movl $0xfffffff,operd");
83: exp_val = 0;
84:
85: /* Use REI to switch to user mode */
86: asm("mtpr $1,$PACC"); /* Purge all code cache */
87: asm("movab d5rei,_d5pc");
88: asm("d5rei:");
89: asm("rei");
90: asm("halt");
91: asm(".align 2");
92: asm("rtn_t30:"); /* Return here if error */
93: asm("movl _saved_fp,fp"); /* restore FP */
94: break; /* Stop test */
95: asm("rtn_t31:");
96: asm("movl _saved_fp,fp"); /* restore FP */
97: asm("movl operd,_act_val");
98: set_handler(CHMK_VEC,&dummy,saved_vec2); /* restore handler */
99: if (exp_val != act_val) /* Demand paging fail !! */
100: {
101: msg1="** Incorrect result after instruction is restarted.\n";
102: d2err(msg1,act_val,exp_val,exp_pc,d5pc,exp_fvadr);
103: break;
104: }
105: }
106: }
107:
108:
109: t_space()
110: {
111: /* Operand of CLRL *12(r5)[r6] */
112: asm(".align 2");
113: asm("r5_here:");
114: asm(".long 0");
115: asm(".space 8"); /* (8 + 4 of r5_here)12 bytes for displacement */
116: asm(".long base_op");
117:
118: asm(".align 2");
119: asm("base_op:");
120: asm(".long 0xffff"); /* four bytes for index by r6 */
121: asm("operd:");
122: asm(".long 0xffffffff");
123: /* this loc will be clear if demand paging works */
124:
125: }
126:
127: prot_hdlr()
128: {
129: asm(".align 2");
130: asm("prot_f3:");
131: asm("mtpr $0x1f,$IPL");
132: asm("movl (sp)+,r12"); /* Ignore 1st parameter */
133: asm("movl (sp)+,_act_fvadr"); /* Actual VA at fault */
134:
135: asm("movl (sp),_act_pc"); /* Actual PC that caused fault */
136: asm("movab (sp),fp"); /* Set FP */
137: if (act_pc != exp_pc)
138: {
139: msg1="** PC pushed on the stack is not correct.\n";
140: d2err(msg1,act_pc,exp_pc,exp_pc,d5pc,exp_fvadr);
141: asm("svpctx"); /* Switch to ISP */
142: asm("jmp rtn_t30"); /* Error return */
143: }
144: if ((act_fvadr & 0xfffffc00) != (exp_fvadr & 0xfffffc00))
145: {
146: msg1="** Fault virtual address pushed on the stack is not correct\n";
147: d2err(msg1,(act_fvadr&0xfffffc00),(exp_fvadr&0xfffffc00),exp_pc,d5pc,exp_fvadr);
148: asm("svpctx"); /* Switch to ISP */
149: asm("jmp rtn_t30"); /* Error return */
150: }
151: else
152: {
153: asm("movab kcall3,_savvec4"); /* New handler for KCALL */
154: set_handler(CHMK_VEC,&saved_vec2,savvec4);
155: /* Restore original TRANS. fault vector */
156: set_handler(TRANS_VEC,&dummy,saved_vec1);
157: /* Validate test page and restart instruction */
158: fixpv_pte(P0BR,TEST_PG,&saved_pte2,(PTE_V|PTE_UW));
159: asm("movab d51rei,_d5pc");
160: asm("d51rei:");
161: asm("rei");
162: }
163:
164:
165: asm(".align 2");
166: asm("kcall3:");
167: asm("mtpr $0x1f,$IPL");
168: asm("svpctx"); /* Switch to ISP */
169: asm("jmp rtn_t31"); /* Return */
170: }
171:
172:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.