|
|
1.1 ! root 1: #include "data.h" ! 2: #include "definitions" ! 3: ! 4: /* Demand paging with auto_increment deferred mode ! 5: Virtual Page 97 is used in this test. "clrl *(sp)+"" is executed to ! 6: cause translation not valid fault. USP is set point to a location which ! 7: points to 1st location in Page 97, Page 97 is set to invalid. Program ! 8: do REI to user to execute the above instruction which should cause the ! 9: demand page fault. Exception handler will set Page to valid and restart ! 10: the instruction. ! 11: */ ! 12: ! 13: long d3pc,exp_psl, exp_pc, act_pc, exp_result, act_result, exp_sp, act_sp; ! 14: long *fault_vadr, saved_vec1, saved_vec2, saved_pte, temp_glb; ! 15: char *msg1, *msg2; ! 16: ! 17: ! 18: extern long iob1, iob2, iob3, u0p2pt, pcb0, savvec4, savvec5, savvec6, savvec7; ! 19: extern long ret_adr, saved_sp, saved_fp, *p_ptr; ! 20: ! 21: dmp1() ! 22: { ! 23: asm("mfpr $SBR,_savvec4"); ! 24: savvec4 |= (savvec4 | SADDR); /* Make it system address */ ! 25: asm("mtpr _savvec4,$P0BR"); /* Double map P0PT to SPT */ ! 26: asm("mfpr $SLR,_savvec4"); ! 27: asm("mtpr _savvec4,$P0LR"); ! 28: ! 29: asm("mtpr $6,$DCK"); ! 30: asm("mtpr $0,$TBIA"); ! 31: asm("mtpr $0,$PADC"); ! 32: asm("mtpr $1,$MME"); /* Enable MME */ ! 33: asm("jmp *$0f"); /* Go virtual */ ! 34: asm("0:"); ! 35: dpt2(); ! 36: asm("mtpr $0,$MME"); ! 37: asm("mtpr $0,$P0LR"); ! 38: } ! 39: ! 40: ! 41: dpt2() ! 42: { ! 43: long ix, hdr_adr, pc_err; ! 44: ! 45: savvec4 = (long)&pcb0; ! 46: asm("mtpr _savvec4,$PCBB"); /* Set PCBB */ ! 47: asm("movab fault_pc2,_savvec4"); ! 48: exp_pc = savvec4; ! 49: savvec4 = (savvec4 >> PGSHIFT) & 0xfffff; ! 50: fixpv_pte(P0BR,savvec4,&saved_pte,(PTE_V|PTE_UW)); ! 51: fixpv_pte(P0BR,(savvec4+1),&saved_pte,(PTE_V|PTE_UW)); ! 52: ! 53: exp_result = 0; ! 54: asm("movab op_addr,_exp_sp"); ! 55: asm("mtpr _exp_sp,$USP"); /* Set USP point to operand address */ ! 56: fault_vadr = (long *) (TEST_PG << PGSHIFT); ! 57: asm("movl _fault_vadr,op_addr"); /* Set operand address */ ! 58: *fault_vadr = 0xfffffff; /* Dummy value in test loc */ ! 59: ! 60: /* Invalidate PTE of test page */ ! 61: fixpv_pte(P0BR,TEST_PG,&saved_pte,PTE_UW); ! 62: asm("movab trans_f2,_savvec4"); /* New handler for TRANS_FAULT */ ! 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: exp_psl = PSL_USR; /* User mode */ ! 69: asm("movl fp,_saved_fp"); /* save FP to return */ ! 70: asm("pushl _exp_psl"); ! 71: asm("pushl _exp_pc"); /* Push PSL,PC for REI */ ! 72: asm("mtpr $1,$PACC"); /* Purge all code cache */ ! 73: asm("movab d3rei,_d3pc"); ! 74: asm("d3rei:"); ! 75: asm("rei"); ! 76: asm("halt"); ! 77: ! 78: asm(".align 2"); ! 79: asm("rtn_t50:"); /* Return from error */ ! 80: asm("movl _saved_fp,fp"); /* restore FP */ ! 81: return; ! 82: asm("rtn_t51:"); ! 83: asm("movl _saved_fp,fp"); /* restore FP */ ! 84: act_result = *fault_vadr; ! 85: if (act_result != exp_result) ! 86: { ! 87: msg1 = "** Incorrect result after instruction is restarted.\n"; ! 88: d3err(msg1,act_result,exp_result,exp_pc,d3pc); ! 89: } ! 90: set_handler(CHMK_VEC,&temp_glb,saved_vec2); /* Restore KCALL vector */ ! 91: } ! 92: ! 93: ! 94: TEST_AREA2() ! 95: { ! 96: asm("fault_pc2:"); ! 97: asm("clrl *(sp)+"); /* should cause translation not valid fault */ ! 98: asm("kcall $0"); /* return */ ! 99: asm(".align 2"); ! 100: asm("op_addr:"); ! 101: asm(".long 0"); /* contain address of operand */ ! 102: } ! 103: ! 104: ! 105: new_hdr2() ! 106: { ! 107: ! 108: asm(".align 2"); /* Longword align */ ! 109: asm("trans_f2:"); ! 110: ! 111: asm("mtpr $0x1f,$IPL"); ! 112: asm("movl (sp)+,r12"); /* Ignore 1st parameter */ ! 113: asm("movl (sp)+,r12"); /* Ignore 2nd parameter */ ! 114: asm("movl (sp),_act_pc"); /* PC that caused fault */ ! 115: asm("movab (sp),fp"); /* set new frame pointer */ ! 116: asm("mfpr $USP,_act_sp"); ! 117: if ( act_pc != exp_pc ) ! 118: { /* Error in PC */ ! 119: msg1="** PC pushed on the stack is not correct.\n"; ! 120: d3err(msg1,act_pc,exp_pc,exp_pc,d3pc); ! 121: asm("svpctx"); /* Back to ISP */ ! 122: asm("jmp rtn_t50"); /* return */ ! 123: } ! 124: else ! 125: { ! 126: if ( exp_sp != act_sp ) ! 127: { ! 128: msg1 = "** SP is not backed up corectly.\n"; ! 129: d3err(msg1,act_sp,exp_sp,exp_pc,d3pc); ! 130: asm("svpctx"); /* Back to ISP */ ! 131: asm("jmp rtn_t50"); /* return */ ! 132: } ! 133: else ! 134: { ! 135: /* Set V bit and restart instruction at PC */ ! 136: fixpv_pte(P0BR,TEST_PG,&saved_pte,(PTE_V|PTE_UW)); ! 137: /* New handler for KCALL */ ! 138: asm("movab kcall2,_savvec4"); ! 139: set_handler(CHMK_VEC,&saved_vec2,savvec4); ! 140: /* restore original vector of TRANSLATION fault */ ! 141: set_handler(TRANS_VEC,&temp_glb,saved_vec1); ! 142: asm("movab d31rei,_d3pc"); ! 143: asm("d31rei:"); ! 144: asm("rei"); ! 145: asm("halt"); ! 146: } ! 147: } ! 148: ! 149: asm(".align 2"); ! 150: asm("kcall2:"); ! 151: asm("mtpr $0x1f,$IPL"); ! 152: asm("svpctx"); /* Back to ISP */ ! 153: asm("jmp rtn_t51"); ! 154: } ! 155: ! 156:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.