|
|
Power 6/32 Unix version 1.2b
#include "data.h"
#include "definitions"
/* Demand paging with auto_increment deferred mode
Virtual Page 97 is used in this test. "clrl *(sp)+"" is executed to
cause translation not valid fault. USP is set point to a location which
points to 1st location in Page 97, Page 97 is set to invalid. Program
do REI to user to execute the above instruction which should cause the
demand page fault. Exception handler will set Page to valid and restart
the instruction.
*/
long d3pc,exp_psl, exp_pc, act_pc, exp_result, act_result, exp_sp, act_sp;
long *fault_vadr, saved_vec1, saved_vec2, saved_pte, temp_glb;
char *msg1, *msg2;
extern long iob1, iob2, iob3, u0p2pt, pcb0, savvec4, savvec5, savvec6, savvec7;
extern long ret_adr, saved_sp, saved_fp, *p_ptr;
dmp1()
{
asm("mfpr $SBR,_savvec4");
savvec4 |= (savvec4 | SADDR); /* Make it system address */
asm("mtpr _savvec4,$P0BR"); /* Double map P0PT to SPT */
asm("mfpr $SLR,_savvec4");
asm("mtpr _savvec4,$P0LR");
asm("mtpr $6,$DCK");
asm("mtpr $0,$TBIA");
asm("mtpr $0,$PADC");
asm("mtpr $1,$MME"); /* Enable MME */
asm("jmp *$0f"); /* Go virtual */
asm("0:");
dpt2();
asm("mtpr $0,$MME");
asm("mtpr $0,$P0LR");
}
dpt2()
{
long ix, hdr_adr, pc_err;
savvec4 = (long)&pcb0;
asm("mtpr _savvec4,$PCBB"); /* Set PCBB */
asm("movab fault_pc2,_savvec4");
exp_pc = savvec4;
savvec4 = (savvec4 >> PGSHIFT) & 0xfffff;
fixpv_pte(P0BR,savvec4,&saved_pte,(PTE_V|PTE_UW));
fixpv_pte(P0BR,(savvec4+1),&saved_pte,(PTE_V|PTE_UW));
exp_result = 0;
asm("movab op_addr,_exp_sp");
asm("mtpr _exp_sp,$USP"); /* Set USP point to operand address */
fault_vadr = (long *) (TEST_PG << PGSHIFT);
asm("movl _fault_vadr,op_addr"); /* Set operand address */
*fault_vadr = 0xfffffff; /* Dummy value in test loc */
/* Invalidate PTE of test page */
fixpv_pte(P0BR,TEST_PG,&saved_pte,PTE_UW);
asm("movab trans_f2,_savvec4"); /* New handler for TRANS_FAULT */
set_handler(TRANS_VEC,&saved_vec1,savvec4);
asm("movab (sp),_savvec4");
savvec4 -= 16; /* KSP is 4 words below ISP */
asm("mtpr _savvec4,$KSP");
exp_psl = PSL_USR; /* User mode */
asm("movl fp,_saved_fp"); /* save FP to return */
asm("pushl _exp_psl");
asm("pushl _exp_pc"); /* Push PSL,PC for REI */
asm("mtpr $1,$PACC"); /* Purge all code cache */
asm("movab d3rei,_d3pc");
asm("d3rei:");
asm("rei");
asm("halt");
asm(".align 2");
asm("rtn_t50:"); /* Return from error */
asm("movl _saved_fp,fp"); /* restore FP */
return;
asm("rtn_t51:");
asm("movl _saved_fp,fp"); /* restore FP */
act_result = *fault_vadr;
if (act_result != exp_result)
{
msg1 = "** Incorrect result after instruction is restarted.\n";
d3err(msg1,act_result,exp_result,exp_pc,d3pc);
}
set_handler(CHMK_VEC,&temp_glb,saved_vec2); /* Restore KCALL vector */
}
TEST_AREA2()
{
asm("fault_pc2:");
asm("clrl *(sp)+"); /* should cause translation not valid fault */
asm("kcall $0"); /* return */
asm(".align 2");
asm("op_addr:");
asm(".long 0"); /* contain address of operand */
}
new_hdr2()
{
asm(".align 2"); /* Longword align */
asm("trans_f2:");
asm("mtpr $0x1f,$IPL");
asm("movl (sp)+,r12"); /* Ignore 1st parameter */
asm("movl (sp)+,r12"); /* Ignore 2nd parameter */
asm("movl (sp),_act_pc"); /* PC that caused fault */
asm("movab (sp),fp"); /* set new frame pointer */
asm("mfpr $USP,_act_sp");
if ( act_pc != exp_pc )
{ /* Error in PC */
msg1="** PC pushed on the stack is not correct.\n";
d3err(msg1,act_pc,exp_pc,exp_pc,d3pc);
asm("svpctx"); /* Back to ISP */
asm("jmp rtn_t50"); /* return */
}
else
{
if ( exp_sp != act_sp )
{
msg1 = "** SP is not backed up corectly.\n";
d3err(msg1,act_sp,exp_sp,exp_pc,d3pc);
asm("svpctx"); /* Back to ISP */
asm("jmp rtn_t50"); /* return */
}
else
{
/* Set V bit and restart instruction at PC */
fixpv_pte(P0BR,TEST_PG,&saved_pte,(PTE_V|PTE_UW));
/* New handler for KCALL */
asm("movab kcall2,_savvec4");
set_handler(CHMK_VEC,&saved_vec2,savvec4);
/* restore original vector of TRANSLATION fault */
set_handler(TRANS_VEC,&temp_glb,saved_vec1);
asm("movab d31rei,_d3pc");
asm("d31rei:");
asm("rei");
asm("halt");
}
}
asm(".align 2");
asm("kcall2:");
asm("mtpr $0x1f,$IPL");
asm("svpctx"); /* Back to ISP */
asm("jmp rtn_t51");
}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.