sym$cause_hardware_faults ident

. PURPOSE:
.   This module contains the procedures for causing hardware faults.

         list    0,0,0
*copy osa$cybil_interface
*copy osa$basic_register_equates
         list    1,2,1

. Define register equates used by the Cybil interface macros.
.

amacscr  equ       15        .scratch a reg used by macros
amacscr  atrib     #regtyp,#areg

          use    code
          page
. PURPOSE:
.   This procedure causes the actual hardware fault by issuing the
.   unimplemented instructions.  If not running with the special microcode this
.   task aborts with an unimplemented instruction.
.
. DESIGN:
.   Special microcode is required that actually causes the desired hardware fault.
.   The special microcode recoginizes specific unimplemented instructions that are
.   issued and dependent on the J K fields causes a specific fault.  The J field
.   specifies the kind of hardware fault and the K field specifies an X register
.   that contains the RMA of a word in memory with a parity error.  This word in
.   memory has to be preconditioned with a parity error before IPL.
.
. PROCEDURE [XREF] syp$cause_hardware_faults
.   (    hardware_fault_kind: syt$hardware_fault_kind;
.        rma_of_parity_error: integer;
.    VAR known_fault_kind: boolean);

chf      alias   SYP$CAUSE_HARDWARE_FAULTS
chf      procedur
hfk      param   val,subrange,1        .hardware fault kind.
rmaope   param   val,integer           .RMA of parity error.
khfk     param   ref,boolean           .known hardware fault kind.

         ploadx  xe,hfk                .kind of hardware fault to cause.
         ente    xc,chfpl              .jump table length.
         ploadx  xf,rmaope             .RMA of parity error.
         shfc    xe,xe,x0,1            .(jump table index)/2.
         entp    xb,0                  .set unknown hardware fault kind.
         brrgt   xe,xc,chf5            .if unknown hardware fault kind.
         entp    xb,1                  .set known hardware fault kind.
chf5     bss     0
         pstorxp   xb,khfk             .return known hardware fault kind.
         brrgt   xb,x0,chf10           .if known hardware fault kind.
         return

chf10    bss     0
         addpxq  af,xe,chfp            .address in jump table to process
                                       . hardware fault kind.
         brdir   af,x0                 .cause specified hardware fault.


.        Define a jump table for each hardware fault kind to cause.

chfp     bss     0
         brreq   x0,x0,retry           .cause successful retry.
         brreq   x0,x0,exchange        .cause exchange fault.
         brreq   x0,x0,trap            .cause trap fault.
         brreq   x0,x0,halt            .cause halt fault.
         brreq   x0,x0,pdm_halt        .cause pdm halt fault.
         brreq   x0,x0,swerr           .software error, error stop.
chfpl    equ     $-chfp                .length of jump table.

.        Cause successful retry error.

retry    bss     0
         vfd,32  0fd0f0000(16)         .condition microcode.
         vfd,32  0fe0f0000(16)         .cause hardware fault.
         return

.        Cause exchange error.

exchange bss     0
         vfd,32  0fd1f0000(16)         .condition microcode.
         vfd,32  0fe1f0000(16)         .cause hardware fault.
         return

.        Cause trap error.

trap     bss     0
         vfd,32  0fd2f0000(16)         .condition microcode.
         vfd,32  0fe2f0000(16)         .cause hardware fault.
         return

.        Cause halt error.

halt     bss     0
         vfd,32  0fd3f0000(16)         .condition microcode.
         vfd,32  0fe3f0000(16)         .cause hardware fault.
         return

.        Cause PDM halt error.

pdm_halt bss     0
         vfd,32  0fd4f0000(16)         .condition microcode.
         vfd,32  0fe4f0000(16)         .cause hardware fault.
         return

.        Cause software error, error stop.

swerr    bss     0
         halt
         return
         end
