|
|
1.1 root 1: #include "data.h"
2: #include "definitions"
3:
4: /* Demand paging with auto_decrement mode
5: Boundery of virtual Page _iob0 and _iob1 are used in this test. USP is set to
6: 1st byte of page _iob1, PTE of Page _iob0 is then set to invalid. Program do
7: a REI to user code which will execute the "clrl -(sp)" instruction . At
8: this point translation not valid fault should occur and the exception
9: handler will set page _iob0 to valid and do a REI to restart the instruction.
10: */
11:
12: long exp_psl, exp_pc, act_pc, exp_result, act_result, exp_sp, act_sp;
13: long d1rei, *fault_vadr, saved_vec1, saved_vec2, saved_pte, temp_glb;
14: char *msg1, *msg2;
15:
16: extern long iob1, iob2, iob3, u0p2pt, pcb0, savvec4, savvec5, savvec6, savvec7;
17: extern long ret_adr, saved_sp, saved_fp, *p_ptr;
18:
19: dmp0()
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: dpt1();
34: asm("mtpr $0,$MME");
35: asm("mtpr $0,$P0LR");
36: }
37:
38:
39: dpt1()
40: {
41: long ix;
42:
43: savvec4 = (long)&pcb0;
44: asm("mtpr _savvec4,$PCBB"); /* Set PCBB */
45: asm("movab fault_pc1,_savvec4");
46: savvec4 = (savvec4 >> PGSHIFT) & 0xfffff;
47: fixpv_pte(P0BR,savvec4,&saved_pte,(PTE_V|PTE_UW));
48: fixpv_pte(P0BR,(savvec4+1),&saved_pte,(PTE_V|PTE_UW));
49:
50: asm("movab fault_pc1,_exp_pc");
51: exp_sp = TEST_PG << PGSHIFT;
52: fault_vadr = (long *) (exp_sp-4);
53: *fault_vadr = 0xfffffff; /* set some value in test location */
54: exp_result = 0;
55:
56: /* Set page _iob1 to valid */
57: fixpv_pte(P0BR,TEST_PG,&saved_pte,(PTE_V|PTE_UW));
58: /* Set page _iob0 to invalid */
59: fixpv_pte(P0BR,(TEST_PG-1),&saved_pte,PTE_UW);
60:
61: /* Set new exception handlers */
62: asm("movab trans_f1,_savvec4");
63: set_handler(TRANS_VEC,&saved_vec1,savvec4);
64:
65: asm("movab (sp),_savvec4");
66: savvec4 -= 16; /* KSP is 4 words below ISP */
67: asm("mtpr _savvec4,$KSP");
68:
69: exp_psl = PSL_USR; /* User mode */
70: asm("mtpr _exp_sp,$USP"); /* Set USP to valid page */
71: asm("movl fp,_saved_fp"); /* save FP to return */
72: asm("pushl _exp_psl");
73: asm("pushl _exp_pc"); /* Push PSL,PC for REI */
74: asm("mtpr $1,$PACC"); /* Purge all code cache */
75: asm("movab d2pc,_d1rei");
76: asm("d2pc:");
77: asm("rei");
78: asm("halt");
79:
80: asm(".align 2");
81: asm("rtn_t10:");
82: asm("movl _saved_fp,fp"); /* restore FP */
83: if (1) return; /* Avoid warning from compiler */
84: asm(".align 2");
85: asm("rtn_t11:");
86: asm("movl _saved_fp,fp"); /* restore FP */
87: act_result = *fault_vadr;
88: if (act_result != exp_result)
89: {
90: msg1 = "** incorrect result after instruction is restarted.\n";
91: d3err(msg1,act_result,exp_result,exp_pc,d1rei);
92: }
93: set_handler(CHMK_VEC,&temp_glb,saved_vec2); /* Restore KCALL vector */
94: }
95:
96: TEST_AREA()
97: {
98: asm("fault_pc1:");
99: asm("clrl -(sp)"); /* should cause translation not valid fault */
100: asm("kcall $0"); /* return */
101: }
102:
103: new_hdr1()
104: {
105: asm(".align 2"); /* Longword align */
106: asm("trans_f1:");
107:
108: asm("mtpr $0x1f,$IPL");
109: asm("movl (sp)+,r12"); /* Ignore 1st parameter */
110: asm("movl (sp)+,r12"); /* Ignore 2nd parameter */
111: asm("movl (sp),_act_pc"); /* PC that caused fault */
112: asm("movab (sp),fp"); /* set new frame pointer */
113: asm("mfpr $USP,_act_sp");
114: if ( act_pc != exp_pc )
115: { /* Error in PC */
116: msg1="\nPC pushed on the stack is not correct.";
117: d3err(msg1,act_pc,exp_pc,exp_pc,d1rei);
118: asm("svpctx"); /* Back to ISP */
119: asm("jmp rtn_t10"); /* return */
120: }
121: else
122: {
123: if ( exp_sp != act_sp )
124: {
125: msg1 = "\nSP is not backed up correctly.";
126: d3err(msg1,act_sp,exp_sp,exp_pc,d1rei);
127: asm("svpctx"); /* Back to ISP */
128: asm("jmp rtn_t10"); /* return */
129: }
130: else
131: {
132: /* Set V bit and restart instruction at PC */
133: fixpv_pte(P0BR,(TEST_PG-1),&saved_pte,(PTE_V|PTE_UW));
134: /* New handler for KCALL */
135: asm("movab kcall1,_savvec4");
136: set_handler(CHMK_VEC,&saved_vec2,savvec4);
137: /* restore original vector of TRANSLATION fault */
138: set_handler(TRANS_VEC,&temp_glb,saved_vec1);
139: asm("movab d21pc,_d1rei");
140: asm("d21pc:");
141: asm("rei");
142: asm("halt");
143: }
144: }
145:
146: asm(".align 2");
147: asm("kcall1:");
148: asm("mtpr $0x1f,$IPL");
149: asm("svpctx"); /* Back to ISP */
150: asm("jmp rtn_t11");
151: }
152:
153: d3err(msg1,act,exp,pc,reipc)
154: char *msg1;
155: long act, exp, pc, reipc;
156: {
157: writes(msg1);
158: writes("\n** Actual : "); writeh(act);
159: writes("\n** Expect : "); writeh(exp);
160: writes("\n** PC : "); writeh(pc);
161: writes("\n** PC (REI instruction) : "); writeh(reipc);
162: writec('\n');
163: asm("halt");
164: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.