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