Annotation of cci/d/demand/dmp2.c, revision 1.1.1.1

1.1       root        1: 
                      2: #include "definitions"
                      3: #include "data.h"
                      4: 
                      5: 
                      6: extern long iob0, iob1, ret_adr, savvec4, savvec5, savvec6, savvec7;
                      7: extern long *p_ptr, saved_sp, saved_fp, pcb0;
                      8: long reipc, exp_pc, act_pc, exp_sp, act_sp, exp_psl, act_psl, act_fvadr;
                      9: 
                     10: 
                     11: /*             Demand paging with register mode
                     12:    This test run virtual in P0 space,Kernel Privilege on Interrupt stack.
                     13:    Boundery of virtual Page IOB0 and IOB1 are used in this test. Opcode of
                     14:    the "clrl r5" instruction is moved to last byte in page IOB0 and operand
                     15:    specifier is moved to 1st byte in page IOB1. PTE of Page IOB1 is then set 
                     16:    to invalid.
                     17: */
                     18: 
                     19: dmp2()
                     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:        clrlr5();
                     34:        asm("mtpr $0,$MME");                    /* Back to physical */
                     35:        asm("mtpr $0,$P0LR");
                     36: }
                     37: 
                     38: 
                     39: clrlr5()
                     40: {      char *byte_ptr, *msg1, *msg2;
                     41:        long ix, hdr_adr, pc_err, saved_pte, saved_vec1, saved_vec2;
                     42:        long dummy, exp_fvadr;
                     43: 
                     44:        savvec4 = (long)&pcb0;
                     45:        asm("mtpr _savvec4,$PCBB");
                     46: 
                     47:        /* Move code to boundery of test page */
                     48:        exp_pc  = ((TEST_PG-1)<<PGSHIFT)|(NBPG-1);
                     49:        exp_fvadr = exp_pc + 1;                 /* fault at next byte */
                     50:        byte_ptr = (char *)exp_pc;
                     51:        for(ix=0;ix<I0;ix++) *byte_ptr++ = CLRL0[ix];
                     52:        *byte_ptr++ = KCALL[0];                 /* move KCALL instruction */
                     53:        *byte_ptr = KCALL[1];
                     54: 
                     55:        fixpv_pte(P0BR,(TEST_PG-1),&saved_pte,(PTE_V|PTE_UW));
                     56:        fixpv_pte(P0BR,TEST_PG,&saved_pte,PTE_UW);    /* Invalid test page */
                     57:        asm("movab trans_f0,_savvec4");         /* new exception handlers  */
                     58:        set_handler(TRANS_VEC,&saved_vec1,savvec4);
                     59: 
                     60:        asm("movab (sp),_savvec4");
                     61:        savvec4 -= 16;                          /* KSP is 4 words below ISP */
                     62:        asm("mtpr _savvec4,$KSP");
                     63:        /* Set up to execute REI      */
                     64:        exp_psl = PSL_USR;                      /* PSL : user mode */
                     65:        asm("pushl _exp_psl");                  /* Push PSL on stack */
                     66:        asm("pushl _exp_pc");                   /* Push PC on stack */
                     67: 
                     68:        /* Use REI to switch to user mode */
                     69:        asm("mtpr $1,$PACC");                   /* Purge all code cache */
                     70: asm("d0rei:");
                     71:        asm("rei");
                     72:        asm("halt");
                     73: asm(".align 2");
                     74: asm("rtn_t0:");
                     75:        asm("movab d0rei,_reipc");
                     76:        if (act_pc != exp_pc)           /* check if PC is backed up */
                     77:                {
                     78:                msg1 = "** PC pushed on the stack is not correct.\n";
                     79:                d2err(msg1,act_pc,exp_pc,exp_pc,reipc,exp_fvadr);
                     80:                }
                     81:        if (act_fvadr != exp_fvadr)     /* check VA at fault */
                     82:                {
                     83:                msg1 = "** Fault virtual address pushed on the stack is not correct.\n";
                     84:                d2err(msg1,act_fvadr,exp_fvadr,exp_pc,reipc,exp_fvadr);
                     85:                }
                     86:        set_handler(TRANS_VEC,&dummy,saved_vec1);
                     87:        fixpv_pte(P0BR,TEST_PG,&saved_pte,(PTE_V|PTE_UW));
                     88:        asm("movab kcall_f0,_savvec4");
                     89:        set_handler(CHMK_VEC,&saved_vec2,savvec4);
                     90:        asm("pushl _exp_psl");                  /* Push PSL on stack */
                     91:        asm("pushl _exp_pc");                   /* Push PC on stack */
                     92:        asm("movl $0xffffffff,r5");
                     93: asm("d0rei1:");
                     94:        asm("rei");
                     95:        asm("halt");
                     96: asm(".align 2");
                     97: asm("rtn_t01:");
                     98:        asm("movl r5,_savvec4");
                     99:        asm("movab d0rei1,_reipc");
                    100:        if (savvec4 != 0)               /* Error !! */
                    101:                {
                    102:                msg1 = "\n** Incorrect result in R5 after instruction is restarted.\n";
                    103:                d2err(msg1,savvec4,0,exp_pc,reipc,exp_fvadr);
                    104:                }
                    105:        set_handler(CHMK_VEC,&dummy,saved_vec2);        /* Restore handler */
                    106: }
                    107: 
                    108: new_hdr0()
                    109: {
                    110: asm(".align    2");                    /* Longword align */
                    111: asm("trans_f0:");                      /* Handler of translation fault */
                    112:        asm("mtpr $0x1f,$IPL");
                    113:        asm("movl (sp)+,r12");          /* Pop 1st two parameter */
                    114:        asm("movl (sp)+,_act_fvadr");   /* Actual virtual addr at fault */
                    115:        asm("movl (sp)+,_act_pc");      /* Actual PC */
                    116:        asm("movl (sp)+,_act_psl");     /* Actual PSL */
                    117:        asm("svpctx");                  /* Switch back to ISP */
                    118:        asm("jmp rtn_t0");              /* Return */
                    119: 
                    120: 
                    121: asm(".align    2");                    /* Longword align */
                    122: asm("kcall_f0:");                      /* Handler of KCALL */
                    123:        asm("mtpr $0x1f,$IPL");
                    124:        asm("svpctx");                  /* Switch back to ISP */
                    125:        asm("jmp rtn_t01");             /* Return */
                    126: }
                    127: 
                    128: d2err(msg1,act,exp,pc,reipc,fva)
                    129: char *msg1;
                    130: long act, exp, pc, reipc, fva;
                    131: {
                    132:        writes(msg1);
                    133:        writes("\n** Actual    : "); writeh(act); 
                    134:        writes("\n** Expect    : "); writeh(exp);
                    135:        writes("\n** PC        : "); writeh(pc);
                    136:        writes("\n** PC of REI : "); writeh(reipc);
                    137:        writes("\n** VA that should cause fault : "); writeh(fva);
                    138:        writec('\n');
                    139:        asm("halt");
                    140: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.