[comp.lang.modula3] signal handling on the DS3100 for the SRC implementation

nr@elan.Princeton.EDU (Norman Ramsey) (02/15/91)

The interface Usignal doesn't work correctly on the DS3100 (MIPS R2000
architecture) running Ultrix 4.0.  Here's an interface that does work.


INTERFACE MipsSignal;
IMPORT Formatter;
FROM Ctypes IMPORT int;


CONST
  BRK_USERBP = 0;

TYPE
  struct_sigcontext = RECORD
        sc_onstack : int;               (* sigstack state to restore *)
        sc_mask    : int;               (* signal mask to restore *)
        sc_pc      : int;               (* pc at time of signal *)
        (*
         * General purpose registers
         *)
        sc_regs : ARRAY [0..31] OF int; (* processor regs 0 to 31 *)
        sc_mdlo : int;  (* mul/div low *)
        sc_mdhi : int;  (* mul/div high *)
        (*
         * Floating point coprocessor state
         *)
        sc_ownedfp : int;       (* fp has been used *)
        sc_fpregs  : ARRAY [0..31] OF int;      (* fp regs 0 to 31 *)
        sc_fpc_csr : int;       (* floating point control and status reg *)
        sc_fpc_eir : int;       (* floating point exception instruction reg *)
        (*
         * END OF REGION THAT MUST AGREE WITH setjmp.h
         * END OF jmp_buf REGION
         *)
        (*
         * System coprocessor registers at time of signal
         *)
        sc_cause : int; (* cp0 cause register *)
        sc_badvaddr : int;      (* cp0 bad virtual address *)
        sc_badpaddr : int;      (* cpu bd bad physical address *)
  END;
  struct_sigvec = RECORD
    sv_handler : SignalHandler;
    sv_mask : int;
    sv_flags : int;
  END;
  SignalHandler = PROCEDURE (sig, code: int;
                             scp: UNTRACED REF struct_sigcontext);

<*EXTERNAL*>
PROCEDURE sigvec (sig: int; VAR vec, ovec: struct_sigvec): int;

TYPE
  jmp_buf = RECORD
        jb_onstack : int;               (* sigstack state to restore *)
        jb_mask    : int;               (* signal mask to restore *)
        jb_pc      : int;               (* pc at time of signal *)
        (*
         * General purpose registers
         *)
        jb_regs : ARRAY [0..31] OF int; (* processor regs 0 to 31 *)
        jb_mdlo : int;  (* mul/div low *)
        jb_mdhi : int;  (* mul/div high *)
        (*
         * Floating point coprocessor state
         *)
        jb_ownedfp : int;       (* fp has been used *)
        jb_fpregs  : ARRAY [0..31] OF int;      (* fp regs 0 to 31 *)
        jb_fpc_csr : int;       (* floating point control and status reg *)
        jb_fpc_eir : int;       (* floating point exception instruction reg *)
        jb_padding : ARRAY [0..10] OF int;
     END;
<*EXTERNAL "_setjmp" *> 
  PROCEDURE WildSetjmp (VAR env: jmp_buf): int;
<*EXTERNAL "_longjmp"*>
  PROCEDURE WildLongjmp (VAR env: jmp_buf; val: int);

<*EXTERNAL "setjmp"*>
  PROCEDURE Setjmp (VAR env: jmp_buf): int;
<*EXTERNAL "longjmp"*>
  PROCEDURE Longjmp (VAR env: jmp_buf; val: int);

CONST
  SigDescriptions = ARRAY OF TEXT {
        "signal 0",
        "hangup",
        "interrupt",
        "quit",
        "illegal instruction",
        "trap",
        "IOT instruction",
        "EMT instruction",
        "floating point exception",
        "kill",
        "bus error",
        "segmentation violation",
        "bad argument to system call",
        "write on a pipe with no one to read it",
        "alarm clock",
        "software termination signal from kill",
        "urgent condition on IO channel",
        "sendable stop signal not from tty",
        "stop signal from tty",
        "continue a stopped process",
        "to parent on child stop or exit",
        "to readers pgrp upon background tty read",
        "like TTIN for output if (tp->t_local&LTOSTOP)",
        "input/output possible signal",
        "exceeded CPU time limit",
        "exceeded file size limit",
        "virtual time alarm",
        "profiling time alarm",
        "window size changes",
        "Sys-V rec lock: notify user upon server crash",
        "User signal 1 (from SysV)",
        "User signal 2 (from SysV)" };
        

  FpeDescriptions = ARRAY OF TEXT {
        "fpe 0",
        "integer overflow",
        "integer divide by zero",
        "floating overflow",
        "floating/decimal divide by zero",
        "floating underflow",
        "decimal overflow",
        "subscript out of range",
        "divide by zero floating fault",
        "floating underflow fault"
   };

TYPE
   BRK = { USERBP, KERNELBP, ABORT, BD_TAKEN, BD_NOTTAKEN, SSTEPBP,
           OVERFLOW, DIVZERO, RANGE, STACKOVERFLOW };

CONST
   BRKDescriptions = ARRAY BRK OF TEXT {
        "user bp (used by debuggers)",
        "kernel bp (used by prom)",
        "no longer used",
        "for taken bd emulation",
        "for not taken bd emulation",
        "user bp (used by debuggers)",
        "overflow check",
        "divide by zero check",
        "range error check",
        "used by Ada" };


END MipsSignal.
--
Norman Ramsey
nr@princeton.edu

muller@src.dec.com (Eric Muller) (02/15/91)

In article <6935@rossignol.Princeton.EDU>, nr@elan.Princeton.EDU (Norman Ramsey) writes:
> 
> The interface Usignal doesn't work correctly on the DS3100 (MIPS R2000
> architecture) running Ultrix 4.0.  Here's an interface that does work.

I knew this would happen sooner or later. Let's face it, there is no
such thing as Ultrix 4.0; there is Ultrix 4.0/VAX and there is Ultrix
4.0/MIPS. 

I guess the proper solution is be to have two binding libraries. I'll
work on that. Any suggestions for the names ?

-- 
Eric.