386 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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 fpr()
  51. {
  52. print("F0\t", *F0, "\n");
  53. print("F1\t", *F1, "\n");
  54. print("F2\t", *F2, "\n");
  55. print("F3\t", *F3, "\n");
  56. print("F4\t", *F4, "\n");
  57. print("F5\t", *F5, "\n");
  58. print("F6\t", *F6, "\n");
  59. print("F7\t", *F7, "\n");
  60. print("control\t", *fmt(E0, 'x'), "\n");
  61. print("status\t", *fmt(E1, 'x'), "\n");
  62. print("tag\t", *fmt(E2, 'x'), "\n");
  63. print("ip offset\t", *fmt(E3, 'X'), "\n");
  64. print("cs selector\t", *fmt(E4, 'x'), "\n");
  65. print("opcode\t", *fmt(E4>>8, 'x'), "\n");
  66. print("data operand offset\t", *fmt(E5, 'x'), "\n");
  67. print("operand selector\t", *fmt(E6, 'x'), "\n");
  68. }
  69. defn mmregs()
  70. {
  71. print("MM0\t", *MM0, " MM1\t", *MM1, "\n");
  72. print("MM2\t", *MM2, " MM3\t", *MM3, "\n");
  73. print("MM4\t", *MM4, " MM5\t", *MM5, "\n");
  74. print("MM6\t", *MM6, " MM7\t", *MM7, "\n");
  75. }
  76. defn pstop(pid)
  77. {
  78. local l;
  79. local pc;
  80. pc = *PC;
  81. print(pid,": ", reason(*TRAP), "\t");
  82. print(fmt(pc, 'a'), "\t", fmt(pc, 'i'), "\n");
  83. if notes then {
  84. if notes[0] != "sys: breakpoint" then {
  85. print("Notes pending:\n");
  86. l = notes;
  87. while l do {
  88. print("\t", head l, "\n");
  89. l = tail l;
  90. }
  91. }
  92. }
  93. }
  94. aggr Ureg
  95. {
  96. 'U' 0 di;
  97. 'U' 4 si;
  98. 'U' 8 bp;
  99. 'U' 12 nsp;
  100. 'U' 16 bx;
  101. 'U' 20 dx;
  102. 'U' 24 cx;
  103. 'U' 28 ax;
  104. 'U' 32 gs;
  105. 'U' 36 fs;
  106. 'U' 40 es;
  107. 'U' 44 ds;
  108. 'U' 48 trap;
  109. 'U' 52 ecode;
  110. 'U' 56 pc;
  111. 'U' 60 cs;
  112. 'U' 64 flags;
  113. {
  114. 'U' 68 usp;
  115. 'U' 68 sp;
  116. };
  117. 'U' 72 ss;
  118. };
  119. defn
  120. Ureg(addr) {
  121. complex Ureg addr;
  122. print(" di ", addr.di, "\n");
  123. print(" si ", addr.si, "\n");
  124. print(" bp ", addr.bp, "\n");
  125. print(" nsp ", addr.nsp, "\n");
  126. print(" bx ", addr.bx, "\n");
  127. print(" dx ", addr.dx, "\n");
  128. print(" cx ", addr.cx, "\n");
  129. print(" ax ", addr.ax, "\n");
  130. print(" gs ", addr.gs, "\n");
  131. print(" fs ", addr.fs, "\n");
  132. print(" es ", addr.es, "\n");
  133. print(" ds ", addr.ds, "\n");
  134. print(" trap ", addr.trap, "\n");
  135. print(" ecode ", addr.ecode, "\n");
  136. print(" pc ", addr.pc, "\n");
  137. print(" cs ", addr.cs, "\n");
  138. print(" flags ", addr.flags, "\n");
  139. print(" sp ", addr.sp, "\n");
  140. print("}\n");
  141. print(" ss ", addr.ss, "\n");
  142. };
  143. sizeofUreg = 76;
  144. print("/sys/lib/acid/386");