rsb.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* $Id$ */
  2. /* The Return Status Block contains, in push order:
  3. FIL, LIN, LB, PC, PI, rsbcode
  4. */
  5. #include "logging.h"
  6. #include "global.h"
  7. #include "mem.h"
  8. #include "rsb.h"
  9. #include "proctab.h"
  10. #include "linfil.h"
  11. #include "shadow.h"
  12. #include "warn.h"
  13. /* offsets to be added to a local base */
  14. int rsb_rsbcode;
  15. int rsb_PI;
  16. int rsb_PC;
  17. int rsb_LB;
  18. int rsb_LIN;
  19. int rsb_FIL;
  20. int rsbsize;
  21. init_rsb()
  22. {
  23. rsb_rsbcode = 0;
  24. rsb_PI = wsize;
  25. rsb_PC = rsb_PI + psize;
  26. rsb_LB = rsb_PC + psize;
  27. rsb_LIN = rsb_LB + psize;
  28. rsb_FIL = rsb_LIN + LINSIZE;
  29. rsbsize = rsb_FIL + psize;
  30. }
  31. pushrsb(rsbcode)
  32. int rsbcode;
  33. {
  34. /* fill Return Status Block */
  35. incSP((size)rsbsize);
  36. st_stdp(SP + rsb_FIL, getFIL());
  37. st_prot(SP + rsb_FIL, psize);
  38. st_stn(SP + rsb_LIN, (long)getLIN(), LINSIZE);
  39. st_prot(SP + rsb_LIN, LINSIZE);
  40. st_stdp(SP + rsb_LB, LB);
  41. st_prot(SP + rsb_LB, psize);
  42. st_stip(SP + rsb_PC, PC);
  43. st_prot(SP + rsb_PC, psize);
  44. st_stn(SP + rsb_PI, PI, psize);
  45. st_prot(SP + rsb_PI, psize);
  46. st_stw(SP + rsb_rsbcode, (long)rsbcode);
  47. st_prot(SP + rsb_rsbcode, wsize);
  48. newLB(SP);
  49. }
  50. /*ARGSUSED*/
  51. int poprsb(rtt)
  52. int rtt; /* set to 1 if working for RTT */
  53. {
  54. /* pops the RSB and returns the rsbcode, for further testing */
  55. register int rsbcode;
  56. #ifdef LOGGING
  57. {
  58. /* check SP */
  59. register ptr properSP = LB - proctab[PI].pr_nloc;
  60. if (SP < properSP)
  61. warning(rtt ? WRTTSTL : WRETSTL);
  62. if (SP > properSP)
  63. warning(rtt ? WRTTSTS : WRETSTS);
  64. }
  65. #endif /* LOGGING */
  66. /* discard stack up to RSB */
  67. newSP(LB);
  68. /* get RSB code and test it for applicability */
  69. rsbcode = st_lduw(SP + rsb_rsbcode);
  70. if ((rsbcode & RSBMASK) != RSBCODE) /* no RSB at all */
  71. return rsbcode;
  72. if (rsbcode != RSB_STP) {
  73. /* Restore registers PI, PC, LB, LIN and FIL
  74. from Return Status Block
  75. */
  76. PI = st_lds(SP + rsb_PI, psize);
  77. newPC(st_ldip(SP + rsb_PC));
  78. newLB(st_lddp(SP + rsb_LB));
  79. putLIN((long) st_ldu(SP + rsb_LIN, LINSIZE));
  80. putFIL(st_lddp(SP + rsb_FIL));
  81. /* remove RSB */
  82. st_dec(rsbsize);
  83. pop_frames();
  84. }
  85. return rsbcode;
  86. }