386 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. // 386 support
  2. defn acidinit() // Called after all the init modules are loaded
  3. {
  4. bplist = {};
  5. bpfmt = 'b';
  6. srcpath = {
  7. "./",
  8. "/sys/src/libc/port/",
  9. "/sys/src/libc/9sys/",
  10. "/sys/src/libc/386/"
  11. };
  12. srcfiles = {}; // list of loaded files
  13. srctext = {}; // the text of the files
  14. }
  15. defn linkreg(addr)
  16. {
  17. return 0;
  18. }
  19. defn stk() // trace
  20. {
  21. _stk(*PC, *SP, 0, 0);
  22. }
  23. defn lstk() // trace with locals
  24. {
  25. _stk(*PC, *SP, 0, 1);
  26. }
  27. defn gpr() // print general(hah hah!) purpose registers
  28. {
  29. print("AX\t", *AX, " BX\t", *BX, " CX\t", *CX, " DX\t", *DX, "\n");
  30. print("DI\t", *DI, " SI\t", *SI, " BP\t", *BP, "\n");
  31. }
  32. defn spr() // print special processor registers
  33. {
  34. local pc;
  35. local cause;
  36. pc = *PC;
  37. print("PC\t", pc, " ", fmt(pc, 'a'), " ");
  38. pfl(pc);
  39. print("SP\t", *SP, " ECODE ", *ECODE, " EFLAG ", *EFLAGS, "\n");
  40. print("CS\t", *CS, " DS\t ", *DS, " SS\t", *SS, "\n");
  41. print("GS\t", *GS, " FS\t ", *FS, " ES\t", *ES, "\n");
  42. cause = *TRAP;
  43. print("TRAP\t", cause, " ", reason(cause), "\n");
  44. }
  45. defn regs() // print all registers
  46. {
  47. spr();
  48. gpr();
  49. }
  50. defn mmregs()
  51. {
  52. print("MM0\t", *MM0, " MM1\t", *MM1, "\n");
  53. print("MM2\t", *MM2, " MM3\t", *MM3, "\n");
  54. print("MM4\t", *MM4, " MM5\t", *MM5, "\n");
  55. print("MM6\t", *MM6, " MM7\t", *MM7, "\n");
  56. }
  57. defn pstop(pid)
  58. {
  59. local l;
  60. local pc;
  61. pc = *PC;
  62. print(pid,": ", reason(*TRAP), "\t");
  63. print(fmt(pc, 'a'), "\t", fmt(pc, 'i'), "\n");
  64. if notes then {
  65. if notes[0] != "sys: breakpoint" then {
  66. print("Notes pending:\n");
  67. l = notes;
  68. while l do {
  69. print("\t", head l, "\n");
  70. l = tail l;
  71. }
  72. }
  73. }
  74. }
  75. aggr Ureg
  76. {
  77. 'U' 0 di;
  78. 'U' 4 si;
  79. 'U' 8 bp;
  80. 'U' 12 nsp;
  81. 'U' 16 bx;
  82. 'U' 20 dx;
  83. 'U' 24 cx;
  84. 'U' 28 ax;
  85. 'U' 32 gs;
  86. 'U' 36 fs;
  87. 'U' 40 es;
  88. 'U' 44 ds;
  89. 'U' 48 trap;
  90. 'U' 52 ecode;
  91. 'U' 56 pc;
  92. 'U' 60 cs;
  93. 'U' 64 flags;
  94. {
  95. 'U' 68 usp;
  96. 'U' 68 sp;
  97. };
  98. 'U' 72 ss;
  99. };
  100. defn
  101. Ureg(addr) {
  102. complex Ureg addr;
  103. print(" di ", addr.di, "\n");
  104. print(" si ", addr.si, "\n");
  105. print(" bp ", addr.bp, "\n");
  106. print(" nsp ", addr.nsp, "\n");
  107. print(" bx ", addr.bx, "\n");
  108. print(" dx ", addr.dx, "\n");
  109. print(" cx ", addr.cx, "\n");
  110. print(" ax ", addr.ax, "\n");
  111. print(" gs ", addr.gs, "\n");
  112. print(" fs ", addr.fs, "\n");
  113. print(" es ", addr.es, "\n");
  114. print(" ds ", addr.ds, "\n");
  115. print(" trap ", addr.trap, "\n");
  116. print(" ecode ", addr.ecode, "\n");
  117. print(" pc ", addr.pc, "\n");
  118. print(" cs ", addr.cs, "\n");
  119. print(" flags ", addr.flags, "\n");
  120. print(" sp ", addr.sp, "\n");
  121. print("}\n");
  122. print(" ss ", addr.ss, "\n");
  123. };
  124. sizeofUreg = 76;
  125. print("/sys/lib/acid/386");