1 static char sccsid[] = " dosig.c 4.1 82/05/12 "; 2 3 #define FBSD 4 /* Handle signal trapping from version 6 or version 7 compatability 5 * mode programs. 6 * Art Wetzel November 1979 7 */ 8 #ifdef TRACE 9 #include <stdio.h> 10 #endif 11 #include <signal.h> 12 #include "defs.h" 13 unsigned int sigvals[NSIG+1]; 14 /* actual catch point for all signals */ 15 #ifdef FBSD 16 sigcatch(signum,faultcode,myaddr,stpc,stps) int signum; 17 #else 18 sigcatch(signum) int signum; 19 #endif 20 { 21 unsigned short *pcptr; 22 extern getregs(); 23 if(incompat) { 24 /* hurry up and get the registers before they are destroyed */ 25 getregs(); 26 } else { 27 /* we were in native mode simulating a sys call */ 28 /* set it up with the old values */ 29 dosig(signum, pc); 30 /* go back where we were doing the sys call */ 31 return(0); 32 } 33 /* figure out the pc */ 34 #ifdef FBSD 35 pcptr = (unsigned short *) &stpc; 36 #else 37 pcptr = (unsigned short *)((char *)&pcptr + 20); 38 #endif 39 pc = (unsigned short *) *pcptr; 40 /* get the psl with condition codes */ 41 /* requires UNIX-32V patch to not clear out condition codes */ 42 #ifdef FBSD 43 psl = 0x83c00000 | (stps & 017); 44 #else 45 psl = 0x83c00000 | (*(pcptr - 6) & 017); 46 #endif 47 /* actually do the thing */ 48 if(sigvals[signum] != (unsigned int)SIG_DFL && (sigvals[signum] & (unsigned int)SIG_IGN) == 0) 49 dosig(signum, pc); 50 /* go back to compatability mode and the signal routine there */ 51 incompat++; 52 compat(); 53 } 54 /* routine to set up pdp11 space for return from a signal */ 55 dosig(signum, from) { 56 unsigned short *sp; 57 #ifdef TRACE 58 fprintf(stderr,"Caught sig %d from 0%o -> 0%o\n",signum,(pc-1),*(pc-1)); 59 #endif 60 /* where is the stack */ 61 sp = (unsigned short *)regs[6]; 62 /* stack up psw condition codes so rti works */ 63 *(--sp) = psl & 017; 64 /* stack pc */ 65 *(--sp) = (unsigned short)(int)pc; 66 /* reset stack pointer */ 67 regs[6] = (unsigned short)(int)sp; 68 /* reset pc to signal catching routine */ 69 pc = (unsigned short *)sigvals[signum]; 70 } 71