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

1.1       root        1: #include "data.h"
                      2: #include "definitions"
                      3: 
                      4: 
                      5: 
                      6: /*     Demand paging with 4 operands instruction 
                      7:        EMUL *12(r3)[r4], r5, *12(r6)[r7], *12(r10)[R9]
                      8: */
                      9: 
                     10: long exp_psl, exp_result0, exp_result1, saved_vec1, saved_vec2, saved_pte;
                     11: long saved_pte2, *opa4, exp_pc, act_pc, act_result0, act_result1, temp_glb;
                     12: long d7pc, dummy, act_fvadr;
                     13: char *msg1, *msg2;
                     14: extern long iob1,iob2,iob3, u0p2pt, pcb0, savvec4, ret_adr, saved_sp, saved_fp;
                     15: extern long exp_fvadr, act_fvadr;
                     16: 
                     17: dmp5()
                     18: {
                     19:        asm("mfpr $SBR,_savvec4");
                     20:        savvec4 |= (savvec4 | SADDR);           /* Make it system address */
                     21:        asm("mtpr _savvec4,$P0BR");             /* Double map P0PT to SPT */
                     22:        asm("mfpr $SLR,_savvec4");
                     23:        asm("mtpr _savvec4,$P0LR");
                     24: 
                     25:        asm("mtpr $6,$DCK");    
                     26:        asm("mtpr $0,$TBIA");   
                     27:        asm("mtpr $0,$PADC");   
                     28:        asm("mtpr $1,$MME");                    /* Enable MME */
                     29:        asm("jmp  *$0f");                       /* Go virtual */
                     30: asm("0:");
                     31: 
                     32:        dt5();
                     33:        asm("mtpr $0,$MME");
                     34:        asm("mtpr $0,$P0LR");
                     35: }
                     36: 
                     37: 
                     38: dt5()
                     39: {      char *byte_ptr;
                     40:        long ix, byte_no, dummy;
                     41: 
                     42:        savvec4 = (long)&pcb0;
                     43:        asm("mtpr _savvec4,$PCBB");
                     44:        fixpv_pte(P0BR,(TEST_PG-1),&saved_pte,(PTE_V|PTE_UW));
                     45:        asm("movab prod,_opa4");                /* address of operand 4 */
                     46: 
                     47:        asm("movab opadr1,_savvec4");
                     48:        savvec4 = (savvec4 >> PGSHIFT) & 0xfffff;       /* Make test area */
                     49:        fixpv_pte(P0BR,savvec4,&dummy,(PTE_V|PTE_UW));  /* User read/write */
                     50:        fixpv_pte(P0BR,(savvec4+1),&dummy,(PTE_V|PTE_UW));
                     51:        
                     52: for(byte_no=1;byte_no<I5;byte_no++)
                     53:        {
                     54:        /* Move code to boundery of test page */
                     55:        exp_pc  = ((TEST_PG-1)<<PGSHIFT)|(NBPG-byte_no);
                     56:        byte_ptr = (char *)exp_pc;
                     57:        for(ix=0;ix<I5;ix++) *byte_ptr++ = EMUL[ix];
                     58:        *byte_ptr++ = KCALL[0];                 /* move KCALL instruction */
                     59:        *byte_ptr = KCALL[1];
                     60: 
                     61:        exp_fvadr = (TEST_PG<<PGSHIFT) & 0xfffffc00;
                     62:        fixpv_pte(P0BR,TEST_PG,&saved_pte,PTE_UW);      /* Set V bit off */
                     63:        asm("movab prot_f5,_savvec4");     /* Set new exception handlers  */
                     64:        set_handler(TRANS_VEC,&saved_vec1,savvec4);
                     65:        asm("movl fp,_saved_fp");               /* save FP to return  */
                     66:        asm("movab (sp),_savvec4");
                     67:        savvec4 -= 160;                         /* KSP is 40 words below ISP */
                     68:        asm("mtpr _savvec4,$KSP");
                     69: 
                     70:        exp_psl = PSL_USR;                      /* PSL : user mode */
                     71:        asm("pushl _exp_psl");                  /* Push PSL on stack */
                     72:        asm("pushl _exp_pc");                   /* Push PC on stack */
                     73: 
                     74:        opa4[0] = opa4[1] = 0xffffffff;         /* result = dummy value */
                     75:        exp_result0 = 0;
                     76:        exp_result1 = 6;                        /* prod = (2*2) + 2  */
                     77:        asm("movl  $1,r4");                     /* Set index value   */
                     78:        asm("movl  $2,r5");                     /* R5 = multiplicand */
                     79:        asm("movl  $1,r7");
                     80:        asm("movl  $1,r9");
                     81:        asm("movab opadr1,r3");         /* Set base address of operand1 */
                     82:        asm("movab opadr3,r6");         /* Set base address of operand3 */
                     83:        asm("movab opadr4,r10");        /* Set base address of operand4 */
                     84:        asm("mtpr $1,$PACC");           /* Purge all code cache */
                     85:        asm("movab d7rei,_d7pc");
                     86: asm("d7rei:");
                     87:        asm("rei");                     /* Context switch to user */
                     88:        asm("halt");
                     89: 
                     90: asm(".align 2");
                     91: asm("rtn_t50:");
                     92:        asm("movl _saved_fp,fp");       /* restore FP */
                     93:        break;                          /* return from error ; stop test */
                     94: asm("rtn_t51:");
                     95:        asm("movl _saved_fp,fp");       /* restore FP */
                     96:        act_result0 = opa4[0];
                     97:        act_result1 = opa4[1];
                     98: 
                     99:        set_handler(CHMK_VEC,&temp_glb,saved_vec2);   /* restore CMHK vector */
                    100:        if ( (act_result0!=exp_result0)||(act_result1!=exp_result1) )
                    101:                {
                    102:                msg1 = "** Incorrect result after instruction is restarted.\n";
                    103:                d2err(msg1,act_result1,exp_result1,exp_pc,d7pc,exp_fvadr);
                    104:                }
                    105:        }
                    106: }
                    107: 
                    108: prot_hdl5()
                    109: {
                    110: asm(".align 2");
                    111: asm("prot_f5:");
                    112:        asm("mtpr $0x1f,$IPL");
                    113:        asm("movl (sp)+,r12");          /* Ignore 1st parameter */
                    114:        asm("movl (sp)+,_act_fvadr");   /* Actual VA at fault */
                    115: 
                    116:        asm("movl (sp),_act_pc");       /* Actual PC that caused fault */
                    117:        asm("movab (sp),fp");           /* Set FP */
                    118:        if (act_pc != exp_pc)
                    119:                {
                    120:                msg1="** PC pushed on the stack is not correct.\n";
                    121:                d2err(msg1,act_pc,exp_pc,exp_pc,d7pc,exp_fvadr);
                    122:                asm("svpctx");                  /* Switch to ISP */
                    123:                asm("jmp rtn_t50");
                    124:                }
                    125:        act_fvadr &= 0xfffffc00;
                    126:        if (act_fvadr != exp_fvadr)
                    127:                {
                    128:                msg1="** Fault virtual address pushed on the stack is not correct.\n";
                    129:                d2err(msg1,act_fvadr,exp_fvadr,exp_pc,d7pc,exp_fvadr);
                    130:                asm("svpctx");                  /* Switch to ISP */
                    131:                asm("jmp rtn_t50");
                    132:                }
                    133:            else
                    134:                {
                    135:                asm("movab kcall5,_savvec4");   /* New handler for KCALL */
                    136:                set_handler(CHMK_VEC,&saved_vec2,savvec4);
                    137:                /* Restore TRANSLATION fault vector */
                    138:                set_handler(TRANS_VEC,&dummy,saved_vec1);
                    139:                /* Validate test page and restart instruction */
                    140:                fixpv_pte(P0BR,TEST_PG,&saved_pte2,(PTE_V|PTE_UW));
                    141:                asm("movab d71rei,_d7pc");
                    142: asm("d71rei:");
                    143:                asm("rei");
                    144:                }
                    145: 
                    146: asm(".align 2");
                    147: asm("kcall5:");
                    148:        asm("mtpr $0x1f,$IPL");
                    149:        asm("svpctx");                  /* Switch to ISP */
                    150:        asm("jmp rtn_t51");
                    151: 
                    152: }
                    153: 
                    154: 
                    155: TEST_AREA5()
                    156: {
                    157:        asm(".align 2");
                    158: asm("opadr1:");                /* r3 point to here */
                    159:        asm(".space 12");       /* 12 bytes for displacement */
                    160:        asm(".long  op1");      /* r3 point to here after add in displacement */
                    161: asm("op1:");
                    162:        asm(".long  0");        /* indexed by r4 */
                    163: asm("mulr:");
                    164:        asm(".long  2");        /* Multiplier = 2  */
                    165: 
                    166: 
                    167: asm("opadr3:");                /* r6 point to here */
                    168:        asm(".space 12");       /* 12 bytes for displacement */
                    169:        asm(".long  op3");      /* r6 point to here after add in displacement */
                    170: asm("op3:");
                    171:        asm(".long  0");        /* indexed by r7 */
                    172: asm("addop:");
                    173:        asm(".long  2");        /* addend operand = 2 */
                    174: 
                    175: 
                    176: asm("opadr4:");                /* r10 point to here */
                    177:        asm(".space 12");       /* 12 bytes for displacement */
                    178:        asm(".long  op4");      /* r8 point to here after add in displacement */
                    179: asm("op4:");
                    180:        asm(".long  0");        /* indexed by r9 : quadword */
                    181:        asm(".long  0");
                    182: asm("prod:");
                    183:        asm(".space  16");      /* Quadword for result of EMUL */
                    184: 
                    185: }
                    186: 

unix.superglobalmegacorp.com

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