Annotation of cci/d/event/roprnd_evt.s, revision 1.1.1.1

1.1       root        1: #
                      2: #      reserved operand event test
                      3: #
                      4: #      includes mtpr,mfpr,&rei
                      5: #
                      6: #      R7 = which instruction is testing
                      7: #           1 - MTPR
                      8: #           2 - MFPR
                      9: #           3 - REI
                     10: #      R3 = PC that force fault
                     11: #      R0 = error code 
                     12: #           1 : expected reserved operand fault didnot happen
                     13: #           2 : error in PC pushed on stack
                     14: #                R1 = actual, R2 = expected
                     15: #           3 : error in PSL pushed on stack
                     16: #                R1 = actual, R2 = expected
                     17: #           4 : Too many parameters pushed on the stack
                     18: #           5 : REI did not catch bad PC/PSL on the stack
                     19: #
                     20: 
                     21:        .set    N_EXIST_PR,255
                     22: 
                     23:        .globl  _roprnd_evt
                     24: _roprnd_evt:
                     25:        .word   0x1fff
                     26:        mtpr    $31,$IPL
                     27:        movab   (sp),_savvec0           /* Save current SP              */
                     28:        mtpr    _savvec0,$ISP           /* Set ISP = current SP         */
                     29:        movl    _scb+ROVEC,_savvec2     /* Save vector of Resr. oprd fault */
                     30:        movab   ropflt1,_scb+ROVEC      /* Set new vector               */
                     31:        movl    $-1,-(sp)               /* Push marker on stack         */
                     32: 
                     33:        movab   _pcb0,r1                /* Partially set PCBB           */
                     34:        mtpr    r1,$PCBB                /* Set PCBB to PCB_0            */
                     35:        movab   (sp),_pcb0              /* Set PCB_KSP = current SP     */
                     36:        movab   (sp),_pcb0+4            /* Set PCB_USP = current SP     */
                     37: 
                     38:        movpsl  r1                      /* If PSL_MODE != Kernel then   */
                     39:        bitl    $0x01000000,r1          /* change to Kernel mode by     */
                     40:        beql    1f                      /* executing a privilege inst.  */
                     41:        movl    _scb+PINSTVEC,_savvec3  /* as HALT                      */
                     42:        movab   tempvec,_scb+PINSTVEC
                     43:        halt
                     44: 
                     45:        .align  2
                     46: tempvec:
                     47:        addl2   $8,sp                   /* Get rid of trash on the stack */
                     48:        movl    _savvec3,_scb+PINSTVEC  /* Restore original vector      */
                     49: #
                     50: #      We are running in Kernel mode; Interrupt stack
                     51: #      MTPR to non existent privileged register                        */
                     52: #
                     53: 1:             
                     54:        movl    $0,r11          /* Set flag to be checked in event handler */
                     55:        movab   mfprt,r6        /* R6 = return address after exception  */
                     56:        movab   mtprt,r5        /* R5 = expected PC on stack after fault */
                     57:        movl    r5,r3
                     58:        movl    $1,r7           /* R7 = 1; testing MTPR */
                     59:        movpsl  r4              /* R4 = expected PSL                    */
                     60: mtprt:
                     61:        mtpr    $0,$N_EXIST_PR  /* Should cause reserved operand fault !! */
                     62:        movl    $1,r0           /* R0 = error code; expected reserved   */
                     63:        jmp     *badrtn         /* operand fault did not happen         */
                     64: 
                     65:        .align  2               /* Event handler for reserved oprd. fault */
                     66: ropflt1:
                     67:        movl    (sp)+,r1        /* R1 = actual PC from stack            */
                     68:        movl    r5,r2           /* R5 = expected PC                     */
                     69:        cmpl    r1,r2
                     70:        beql    1f
                     71:        movl    $2,r0           /* R0 = error code; PC saved on stack   */
                     72:        jmp     *badrtn         /* not equal to expexted PC             */
                     73:                                /* R1 = actual; R2 = expected           */
                     74: 
                     75: 1:     movl    (sp)+,r1        /* R1 = actual PSL from stack           */
                     76:        movl    r4,r2           /* R2 = expected PSL                    */
                     77:        cmpl    r2,r1           /* Are they the same ?                  */
                     78:        beql    1f
                     79:        movl    $3,r0           /* Error in PSL !!                      */
                     80:        jmp     *badrtn
                     81: 1:
                     82:        cmpl    $1,r11          /* Is fault caused by REI or MTPR ?     */
                     83:        bneq    1f              /* Skip this part if come here from MTPR */
                     84:        movl    (sp)+,r10       /* REI fault : get rid off PC,PSL on the */
                     85:        movl    (sp)+,r10       /* stack then check for marker          */
                     86: 
                     87: 1:
                     88:        cmpl    $-1,(sp)        /* Is SP pointing at the marker on SP ? */
                     89:        beql    1f
                     90:        movl    $4,r0           /* If not then error : pushed too many  */
                     91:        jmp     *badrtn         /* parameters on SP after fault ..      */
                     92: 
                     93: 1:     movpsl  r1              /* Get ready to return from fault       */
                     94:        movl    r1,-(sp)        /* Push current PSL on stack            */
                     95:        movl    r6,-(sp)        /* R6 = addr to return to               */
                     96:        rei
                     97:        halt                    /* Should never come here !!!!          */
                     98: #
                     99: #
                    100: #      MFPR from non existent privileged register
                    101: #
                    102: mfprt:
                    103:        movl    $2,r7           /* R7 = 2; testing MFPR */
                    104:        movab   reit,r6         /* Set R6 = return adddress after fault */
                    105:        movab   mfprt0,r5       /* R5 = expected PC on stack            */
                    106:        movl    r5,r3
                    107:        movpsl  r4              /* R4 = expected PSL                    */
                    108: mfprt0:
                    109:        mfpr    $N_EXIST_PR,r10 /* Should cause resr. oprd. fault ..    */
                    110:        movl    $1,r0           /* Error; expected fault did not happen */
                    111:        jmp     *badrtn
                    112: #
                    113: #      REI with illegal PSL on the stack : PSL_IS on and PSL_MODE is User
                    114: #
                    115: reit:
                    116:        movl    $3,r7           /* R7 = 3; testing REI */
                    117:        movab   reit1,r6        /* R6 = return address after exception  */
                    118:        movab   reita,r5        /* R5 = expected PC on SP               */
                    119:        movl    r5,r3
                    120:        movl    $0x05000000,r1  /* Push PSL on stack; PSL_IS on and     */
                    121:        movl    r1,-(sp)        /* and PSL_MODE = User                  */
                    122:        movab   reierr,-(sp)    /* PC if REI doesn't catch bad PSL      */
                    123:        movl    $1,r11          /* Set flag to be checked in event handler */
                    124: reita: rei                     /* should cause reserved opr. fault     */
                    125:        movl    $1,r0           /* Error; expected fault did not happen */
                    126:        jmp     *badrtn         /* Should never come here ..            */
                    127: #
                    128: #      REI with illegal PSL on the stack : PSL_IS on and PSL_IPL = 0
                    129: #
                    130: reit1:
                    131:        movab   reit2,r6        /* R6 = return address after exception  */
                    132:        movab   reit1a,r5       /* R5 = expected PC on stack            */
                    133:        movl    r5,r3
                    134:        movl    $0x04000000,r1  /* Set PSL, PC on stack for REI         */
                    135:        movl    r1,-(sp)
                    136:        movab   reierr,-(sp)    /* PC if REI doesn't catch bad PSL      */
                    137: reit1a:        rei                     /* Should cause fault                   */
                    138:        movl    $1,r0           /* Error; expected fault did not happen */
                    139:        jmp     *badrtn         /* Should never come here ..            */
                    140: #
                    141: #      REI with illegal PSL on the stack : PSL_IS off,PSL_IPL > 0
                    142: #      and PSL_MODE = User
                    143: #
                    144: reit2:
                    145:        movab   reit3,r6        /* R6 = return address after exception  */
                    146:        movab   reit2a,r5       /* R5 = expected PC on stack            */
                    147:        movl    r5,r3
                    148:        movl    $0x010f0000,r1  /* Set PSL, PC on stack for REI         */
                    149:        movl    r1,-(sp)
                    150:        movab   reierr,-(sp)    /* PC if REI doesn't catch bad PSl      */
                    151: reit2a:        rei                     /* Should cause fault                   */
                    152:        movl    $1,r0           /* Error; expected fault did not happen */
                    153:        jmp     *badrtn         /* Should never come here ..            */
                    154: 
                    155: reit3:
                    156:        movpsl  r1
                    157:        bitl    $0x04000000,r1
                    158:        beql    1f              /* If IS is ON, turn it off by          */
                    159:        andl2   $0xfbffffff,r1  /* using REI                            */
                    160:        movl    r1,-(sp)
                    161:        movab   1f,-(sp)
                    162:        rei
                    163:        jmp     *badrtn
                    164: 
                    165: #
                    166: #      REI with illegal PSL on the stack : PSL_IS on; Try to switch
                    167: #      to Interrupt stack by REI
                    168: #
                    169: 1:                             /* Current PSL_IS is OFF                */
                    170:        movab   reit4,r6        /* R6 = return address after exception  */
                    171:        movab   reit3a,r5       /* R5 = expected PC on stack            */
                    172:        movl    r5,r3
                    173:        movl    $0x04000000,r1  /* Set PSL, PC on stack for REI         */
                    174:        movl    r1,-(sp)
                    175:        movab   reierr,-(sp)    /* PC if REI doesn't catch bad PSL      */
                    176:        movpsl  r4
                    177: reit3a:        rei                     /* Should cause fault                   */
                    178:        movl    $1,r0           /* Error; expected fault did not happen */
                    179:        jmp     *badrtn         /* Should never come here ..            */
                    180: #
                    181: #      REI with illegal PSL on the stack : Current PSL_IPL is smaller
                    182: #      than PSL_IPL on stack 
                    183: #
                    184: reit4:
                    185:        movab   reit5,r6        /* R6 = return address after exception  */
                    186:        movab   reit4a,r5       /* R5 = expected PC on stack            */
                    187:        movl    r5,r3
                    188:        mtpr    $0x10,$IPL      /* Set current PSL_IPL = 0x10           */
                    189:        movpsl  r4
                    190:        movl    $0x00180001,r1  /* Set PSL_IPL (on stack) to 0x18       */
                    191:        movl    r1,-(sp)
                    192:        movab   reierr,-(sp)    /* PC if REI doesn't catch bad PSL      */
                    193: reit4a:        rei                     /* Should cause fault                   */
                    194:        movl    $1,r0           /* Error; expected fault did not happen */
                    195:        jmp     *badrtn         /* Should never come here ..            */
                    196: #
                    197: #
                    198: reit5:
                    199:        movl    $0x01000000,-(sp)       /* Set up PSL, PC to use REI to */
                    200:        movab   usrmd,-(sp)             /* switch to User mode          */
                    201:        rei
                    202:        jmp     *badrtn
                    203: #
                    204: #      REI with illegal PSL on the stack : Try to switch from USER to
                    205: #      KERNEL mode by REI 
                    206: #
                    207: usrmd:                         /* We now running in User mode          */
                    208:        movab   reit6,r6        /* R6 = return address after exception  */
                    209:        movab   reit5a,r5       /* R5 = expected PC on stack            */
                    210:        movl    r5,r3
                    211:        movl    $0x00000000,r1  /* Set up PSL, PC for REI               */
                    212:        movl    r1,-(sp)
                    213:        movab   reierr,-(sp)    /* PC if REI doesn't catch bad PSL      */
                    214:        clrl    r11             /* Clear flag                           */
                    215:        movpsl  r4
                    216: reit5a:        rei                     /* Should cause fault                   */
                    217:        movl    $1,r0
                    218:        jmp     *badrtn         /* Should never come here ..            */
                    219: #
                    220: #
                    221: #
                    222: reit6:
                    223:        movl    _savvec3,_scb+PINSTVEC  /* Restore vectors              */
                    224:        movl    _savvec2,_scb+ROVEC
                    225:        pushl   $0                      /* Push dummy PSL,PC on stack   */
                    226:        pushl   $0
                    227:        svpctx                          /* Switch to ISP                */
                    228: btisp:
                    229:        mtpr    $31,$IPL                /* Reset IPL to HIGH            */
                    230:        movl    _savvec0,sp             /* Restore SP                   */
                    231:        ret
                    232: #
                    233: #
                    234: #
                    235: reierr:
                    236:        movl    $5,r0
                    237:        jmp     *badrtn         /* REI error - REI did not catch illegal PSL*/
                    238:                                /* on the stack !*/

unix.superglobalmegacorp.com

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