|
|
Power 6/32 Unix version 1.2b
#include "data.h"
#include "definitions"
extern long savvec4, iob1, iob2, pcb0;
/* Demand paging with longword displacement deferred indexed
Boundery of virtual Page 97 and 98 are used in this test. Opcodes of
the "clrl *12(r5)[r6]" instruction is moved to last byte in page 22
and operand specifiers are moved to 1st byte in page 23. PTE of Page
23 is then set to invalid.
*/
long d5pc, exp_pc, act_pc, exp_psl, exp_fvadr, act_fvadr, exp_val, act_val;
long dummy, saved_vec1, saved_vec2, saved_pte1, saved_pte2;
char *msg1, *msg2;
dmp3()
{
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:");
tst_dmp3();
asm("mtpr $0,$MME"); /* Disable MME */
asm("mtpr $0,$P0LR");
}
tst_dmp3()
{ char *byte_ptr, *msg1, *msg2;
long dummy, ix, hdr_adr, pc_err, byte_no;
savvec4 = (long)&pcb0;
asm("mtpr _savvec4,$PCBB"); /* Initialize PCBB */
asm("movab r5_here,_savvec4"); /* Make test area user read/write */
savvec4 = (savvec4 >> PGSHIFT) & 0xfffff;
fixpv_pte(P0BR,savvec4,&dummy,(PTE_V|PTE_UW));
fixpv_pte(P0BR,(TEST_PG-1),&saved_pte1,(PTE_V|PTE_UW));
for(byte_no=1;byte_no<I3;byte_no++)
{
/* Move code to boundery of test page */
exp_pc = ((TEST_PG-1)<<PGSHIFT)|(NBPG-byte_no);
byte_ptr = (char *)exp_pc;
for(ix=0;ix<I3;ix++) *byte_ptr++ = CLRL3[ix];
*byte_ptr++ = KCALL[0]; /* move KCALL instruction */
*byte_ptr = KCALL[1];
exp_fvadr = (TEST_PG<<PGSHIFT) & 0xfffffc00;
/* Invalidate PTE of test page */
fixpv_pte(P0BR,TEST_PG,&saved_pte2,PTE_UW);
/* Set new exception handlers */
asm("movab prot_f3,_savvec4");
set_handler(TRANS_VEC,&saved_vec1,savvec4);
/* Set up to execute REI */
asm("movab (sp),_savvec4");
savvec4 -= 16; /* KSP is 4 words below ISP */
asm("mtpr _savvec4,$KSP");
asm("movl fp,_saved_fp"); /* save FP to return */
exp_psl = PSL_USR; /* PSL : user mode */
asm("again:");
asm("pushl _exp_psl"); /* Push PSL on stack */
asm("pushl _exp_pc"); /* Push PC on stack */
/* Set up for CLRL *12(r5)[r6] */
asm("movab r5_here,r5");
asm("movl $1,r6"); /* Set index value in r6 */
asm("movl $0xfffffff,operd");
exp_val = 0;
/* Use REI to switch to user mode */
asm("mtpr $1,$PACC"); /* Purge all code cache */
asm("movab d5rei,_d5pc");
asm("d5rei:");
asm("rei");
asm("halt");
asm(".align 2");
asm("rtn_t30:"); /* Return here if error */
asm("movl _saved_fp,fp"); /* restore FP */
break; /* Stop test */
asm("rtn_t31:");
asm("movl _saved_fp,fp"); /* restore FP */
asm("movl operd,_act_val");
set_handler(CHMK_VEC,&dummy,saved_vec2); /* restore handler */
if (exp_val != act_val) /* Demand paging fail !! */
{
msg1="** Incorrect result after instruction is restarted.\n";
d2err(msg1,act_val,exp_val,exp_pc,d5pc,exp_fvadr);
break;
}
}
}
t_space()
{
/* Operand of CLRL *12(r5)[r6] */
asm(".align 2");
asm("r5_here:");
asm(".long 0");
asm(".space 8"); /* (8 + 4 of r5_here)12 bytes for displacement */
asm(".long base_op");
asm(".align 2");
asm("base_op:");
asm(".long 0xffff"); /* four bytes for index by r6 */
asm("operd:");
asm(".long 0xffffffff");
/* this loc will be clear if demand paging works */
}
prot_hdlr()
{
asm(".align 2");
asm("prot_f3:");
asm("mtpr $0x1f,$IPL");
asm("movl (sp)+,r12"); /* Ignore 1st parameter */
asm("movl (sp)+,_act_fvadr"); /* Actual VA at fault */
asm("movl (sp),_act_pc"); /* Actual PC that caused fault */
asm("movab (sp),fp"); /* Set FP */
if (act_pc != exp_pc)
{
msg1="** PC pushed on the stack is not correct.\n";
d2err(msg1,act_pc,exp_pc,exp_pc,d5pc,exp_fvadr);
asm("svpctx"); /* Switch to ISP */
asm("jmp rtn_t30"); /* Error return */
}
if ((act_fvadr & 0xfffffc00) != (exp_fvadr & 0xfffffc00))
{
msg1="** Fault virtual address pushed on the stack is not correct\n";
d2err(msg1,(act_fvadr&0xfffffc00),(exp_fvadr&0xfffffc00),exp_pc,d5pc,exp_fvadr);
asm("svpctx"); /* Switch to ISP */
asm("jmp rtn_t30"); /* Error return */
}
else
{
asm("movab kcall3,_savvec4"); /* New handler for KCALL */
set_handler(CHMK_VEC,&saved_vec2,savvec4);
/* Restore original TRANS. fault vector */
set_handler(TRANS_VEC,&dummy,saved_vec1);
/* Validate test page and restart instruction */
fixpv_pte(P0BR,TEST_PG,&saved_pte2,(PTE_V|PTE_UW));
asm("movab d51rei,_d5pc");
asm("d51rei:");
asm("rei");
}
asm(".align 2");
asm("kcall3:");
asm("mtpr $0x1f,$IPL");
asm("svpctx"); /* Switch to ISP */
asm("jmp rtn_t31"); /* Return */
}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.