1994-06-24 11:31:16 +00:00
|
|
|
/* $Id$ */
|
1988-06-22 16:57:09 +00:00
|
|
|
|
|
|
|
/* The Return Status Block contains, in push order:
|
|
|
|
FIL, LIN, LB, PC, PI, rsbcode
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "logging.h"
|
|
|
|
#include "global.h"
|
|
|
|
#include "mem.h"
|
|
|
|
#include "rsb.h"
|
|
|
|
#include "proctab.h"
|
|
|
|
#include "linfil.h"
|
|
|
|
#include "shadow.h"
|
2019-03-17 14:42:00 +00:00
|
|
|
#include "segment.h"
|
|
|
|
#include "text.h"
|
1988-06-22 16:57:09 +00:00
|
|
|
#include "warn.h"
|
|
|
|
|
|
|
|
/* offsets to be added to a local base */
|
|
|
|
int rsb_rsbcode;
|
|
|
|
int rsb_PI;
|
|
|
|
int rsb_PC;
|
|
|
|
int rsb_LB;
|
|
|
|
int rsb_LIN;
|
|
|
|
int rsb_FIL;
|
|
|
|
int rsbsize;
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
void init_rsb(void)
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
rsb_rsbcode = 0;
|
|
|
|
rsb_PI = wsize;
|
|
|
|
rsb_PC = rsb_PI + psize;
|
|
|
|
rsb_LB = rsb_PC + psize;
|
|
|
|
rsb_LIN = rsb_LB + psize;
|
|
|
|
rsb_FIL = rsb_LIN + LINSIZE;
|
|
|
|
rsbsize = rsb_FIL + psize;
|
|
|
|
}
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
void pushrsb(int rsbcode)
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
/* fill Return Status Block */
|
1989-11-22 13:38:37 +00:00
|
|
|
incSP((size)rsbsize);
|
1988-06-22 16:57:09 +00:00
|
|
|
|
|
|
|
st_stdp(SP + rsb_FIL, getFIL());
|
|
|
|
st_prot(SP + rsb_FIL, psize);
|
|
|
|
|
|
|
|
st_stn(SP + rsb_LIN, (long)getLIN(), LINSIZE);
|
|
|
|
st_prot(SP + rsb_LIN, LINSIZE);
|
|
|
|
|
|
|
|
st_stdp(SP + rsb_LB, LB);
|
|
|
|
st_prot(SP + rsb_LB, psize);
|
|
|
|
|
|
|
|
st_stip(SP + rsb_PC, PC);
|
|
|
|
st_prot(SP + rsb_PC, psize);
|
|
|
|
|
|
|
|
st_stn(SP + rsb_PI, PI, psize);
|
|
|
|
st_prot(SP + rsb_PI, psize);
|
|
|
|
|
1989-11-22 13:38:37 +00:00
|
|
|
st_stw(SP + rsb_rsbcode, (long)rsbcode);
|
1988-06-22 16:57:09 +00:00
|
|
|
st_prot(SP + rsb_rsbcode, wsize);
|
|
|
|
|
|
|
|
newLB(SP);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
2019-03-17 14:42:00 +00:00
|
|
|
int poprsb(int rtt) /* set to 1 if working for RTT */
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
/* pops the RSB and returns the rsbcode, for further testing */
|
|
|
|
register int rsbcode;
|
|
|
|
|
|
|
|
#ifdef LOGGING
|
|
|
|
{
|
|
|
|
/* check SP */
|
|
|
|
register ptr properSP = LB - proctab[PI].pr_nloc;
|
|
|
|
|
|
|
|
if (SP < properSP)
|
|
|
|
warning(rtt ? WRTTSTL : WRETSTL);
|
|
|
|
if (SP > properSP)
|
|
|
|
warning(rtt ? WRTTSTS : WRETSTS);
|
|
|
|
}
|
1991-12-17 15:28:58 +00:00
|
|
|
#endif /* LOGGING */
|
1988-06-22 16:57:09 +00:00
|
|
|
|
|
|
|
/* discard stack up to RSB */
|
|
|
|
newSP(LB);
|
|
|
|
|
|
|
|
/* get RSB code and test it for applicability */
|
1989-11-22 13:38:37 +00:00
|
|
|
rsbcode = st_lduw(SP + rsb_rsbcode);
|
1988-06-22 16:57:09 +00:00
|
|
|
if ((rsbcode & RSBMASK) != RSBCODE) /* no RSB at all */
|
|
|
|
return rsbcode;
|
|
|
|
|
|
|
|
if (rsbcode != RSB_STP) {
|
|
|
|
/* Restore registers PI, PC, LB, LIN and FIL
|
|
|
|
from Return Status Block
|
|
|
|
*/
|
|
|
|
PI = st_lds(SP + rsb_PI, psize);
|
|
|
|
newPC(st_ldip(SP + rsb_PC));
|
|
|
|
newLB(st_lddp(SP + rsb_LB));
|
|
|
|
putLIN((long) st_ldu(SP + rsb_LIN, LINSIZE));
|
|
|
|
putFIL(st_lddp(SP + rsb_FIL));
|
|
|
|
|
|
|
|
/* remove RSB */
|
|
|
|
st_dec(rsbsize);
|
|
|
|
|
|
|
|
pop_frames();
|
|
|
|
}
|
|
|
|
|
|
|
|
return rsbcode;
|
|
|
|
}
|
|
|
|
|