]> git.lizzy.rs Git - plan9front.git/blob - sys/lib/acid/386
keep fpregs always in sse (FXSAVE) format, adapt libmach and acid files for new format
[plan9front.git] / sys / lib / acid / 386
1 // 386 support
2
3 defn acidinit()                 // Called after all the init modules are loaded
4 {
5         bplist = {};
6         bpfmt = 'b';
7
8         srcpath = {
9                 "./",
10                 "/sys/src/libc/port/",
11                 "/sys/src/libc/9sys/",
12                 "/sys/src/libc/386/"
13         };
14
15         srcfiles = {};                  // list of loaded files
16         srctext = {};                   // the text of the files
17 }
18
19 defn linkreg(addr)
20 {
21         return 0;
22 }
23
24 defn stk()                              // trace
25 {
26         _stk(*PC, *SP, 0, 0);
27 }
28
29 defn lstk()                             // trace with locals
30 {
31         _stk(*PC, *SP, 0, 1);
32 }
33
34 defn gpr()              // print general(hah hah!) purpose registers
35 {
36         print("AX\t", *AX, " BX\t", *BX, " CX\t", *CX, " DX\t", *DX, "\n");
37         print("DI\t", *DI, " SI\t", *SI, " BP\t", *BP, "\n");
38 }
39
40 defn spr()                              // print special processor registers
41 {
42         local pc;
43         local cause;
44
45         pc = *PC;
46         print("PC\t", pc, " ", fmt(pc, 'a'), "  ");
47         pfl(pc);
48         print("SP\t", *SP, " ECODE ", *ECODE, " EFLAG ", *EFLAGS, "\n");
49         print("CS\t", *CS, " DS\t ", *DS, " SS\t", *SS, "\n");
50         print("GS\t", *GS, " FS\t ", *FS, " ES\t", *ES, "\n");
51         
52         cause = *TRAP;
53         print("TRAP\t", cause, " ", reason(cause), "\n");
54 }
55
56 defn regs()                             // print all registers
57 {
58         spr();
59         gpr();
60 }
61
62 defn fpr()
63 {
64         print("F0\t",  *F0, "\n");
65         print("F1\t",  *F1, "\n");
66         print("F2\t",  *F2, "\n");
67         print("F3\t",  *F3, "\n");
68         print("F4\t",  *F4, "\n");
69         print("F5\t",  *F5, "\n");
70         print("F6\t",  *F6, "\n");
71         print("F7\t",  *F7, "\n");
72         print("control\t", *FCW, "\n");
73         print("status\t", *FSW, "\n");
74         print("tag\t", *FTW, "\n");
75         print("ip\t", *FIP, "\n");
76         print("cs selector\t", *FCS, "\n");
77         print("opcode\t", *FOP, "\n");
78         print("data operand\t", *FDP, "\n");
79         print("operand selector\t", *FDS, "\n");
80 }
81
82 defn pstop(pid)
83 {
84         local l;
85         local pc;
86
87         pc = *PC;
88
89         print(pid,": ", reason(*TRAP), "\t");
90         print(fmt(pc, 'a'), "\t", fmt(pc, 'i'), "\n");
91
92         if notes then {
93                 if notes[0] != "sys: breakpoint" then {
94                         print("Notes pending:\n");
95                         l = notes;
96                         while l do {
97                                 print("\t", head l, "\n");
98                                 l = tail l;
99                         }
100                 }
101         }
102 }
103
104 aggr Ureg
105 {
106         'X' 0 di;
107         'X' 4 si;
108         'X' 8 bp;
109         'X' 12 nsp;
110         'X' 16 bx;
111         'X' 20 dx;
112         'X' 24 cx;
113         'X' 28 ax;
114         'X' 32 gs;
115         'X' 36 fs;
116         'X' 40 es;
117         'X' 44 ds;
118         'X' 48 trap;
119         'X' 52 ecode;
120         'X' 56 pc;
121         'X' 60 cs;
122         'X' 64 flags;
123         {
124         'X' 68 usp;
125         'X' 68 sp;
126         };
127         'X' 72 ss;
128 };
129
130 defn
131 Ureg(addr) {
132         complex Ureg addr;
133         print(" di      ", addr.di, "\n");
134         print(" si      ", addr.si, "\n");
135         print(" bp      ", addr.bp, "\n");
136         print(" nsp     ", addr.nsp, "\n");
137         print(" bx      ", addr.bx, "\n");
138         print(" dx      ", addr.dx, "\n");
139         print(" cx      ", addr.cx, "\n");
140         print(" ax      ", addr.ax, "\n");
141         print(" gs      ", addr.gs, "\n");
142         print(" fs      ", addr.fs, "\n");
143         print(" es      ", addr.es, "\n");
144         print(" ds      ", addr.ds, "\n");
145         print(" trap    ", addr.trap, "\n");
146         print(" ecode   ", addr.ecode, "\n");
147         print(" pc      ", addr.pc, "\n");
148         print(" cs      ", addr.cs, "\n");
149         print(" flags   ", addr.flags, "\n");
150         print(" sp      ", addr.sp, "\n");
151         print(" ss      ", addr.ss, "\n");
152 };
153 sizeofUreg = 76;
154
155 print("/sys/lib/acid/386");