xref: /inferno-os/utils/acid/386 (revision 74a4d8c26dd3c1e9febcb717cfd6cb6512991a7a)
1// 386 support
2
3defn 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	Labspoff = 4;		// adjustment to Label's sp
18	Labpcoff = 0;		// adjustment to Label's pc
19}
20
21defn linkreg(addr)
22{
23	return 0;
24}
25
26defn stk()				// trace
27{
28	_stk(*PC, *SP, 0, 0);
29}
30
31defn lstk()				// trace with locals
32{
33	_stk(*PC, *SP, 0, 1);
34}
35
36defn kstk()				// kernel stack
37{
38	_stk(*PC-Labpcoff, *SP-Labspoff, 0, 0);
39}
40
41defn lkstk()				// kernel stack and locals
42{
43	_stk(*PC-Labpcoff, *SP-Labspoff, 0, 1);
44}
45defn gpr()		// print general(hah hah!) purpose registers
46{
47	print("AX\t", *AX, " BX\t", *BX, " CX\t", *CX, " DX\t", *DX, "\n");
48	print("DI\t", *DI, " SI\t", *SI, " BP\t", *BP, "\n");
49}
50
51defn spr()				// print special processor registers
52{
53	local pc;
54	local cause;
55
56	pc = *PC;
57	print("PC\t", pc, " ", fmt(pc, 'a'), "  ");
58	pfl(pc);
59	print("SP\t", *SP, " ECODE ", *ECODE, " EFLAG ", *EFLAGS, "\n");
60	print("CS\t", *CS, " DS\t ", *DS, " SS\t", *SS, "\n");
61	print("GS\t", *GS, " FS\t ", *FS, " ES\t", *ES, "\n");
62
63	cause = *TRAP;
64	print("TRAP\t", cause, " ", reason(cause), "\n");
65}
66
67defn regs()				// print all registers
68{
69	spr();
70	gpr();
71}
72
73defn pstop(pid)
74{
75	local l;
76	local pc;
77
78	pc = *PC;
79
80	print(pid,": ", reason(*TRAP), "\t");
81	print(fmt(pc, 'a'), "\t", fmt(pc, 'i'), "\n");
82
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
95aggr Ureg
96{
97	'U' 0 di;
98	'U' 4 si;
99	'U' 8 bp;
100	'U' 12 nsp;
101	'U' 16 bx;
102	'U' 20 dx;
103	'U' 24 cx;
104	'U' 28 ax;
105	'U' 32 gs;
106	'U' 36 fs;
107	'U' 40 es;
108	'U' 44 ds;
109	'U' 48 trap;
110	'U' 52 ecode;
111	'U' 56 pc;
112	'U' 60 cs;
113	'U' 64 flags;
114	{
115	'U' 68 usp;
116	'U' 68 sp;
117	};
118	'U' 72 ss;
119};
120
121defn
122Ureg(addr) {
123	complex Ureg addr;
124	print("	di	", addr.di, "\n");
125	print("	si	", addr.si, "\n");
126	print("	bp	", addr.bp, "\n");
127	print("	nsp	", addr.nsp, "\n");
128	print("	bx	", addr.bx, "\n");
129	print("	dx	", addr.dx, "\n");
130	print("	cx	", addr.cx, "\n");
131	print("	ax	", addr.ax, "\n");
132	print("	gs	", addr.gs, "\n");
133	print("	fs	", addr.fs, "\n");
134	print("	es	", addr.es, "\n");
135	print("	ds	", addr.ds, "\n");
136	print("	trap	", addr.trap, "\n");
137	print("	ecode	", addr.ecode, "\n");
138	print("	pc	", addr.pc, "\n");
139	print("	cs	", addr.cs, "\n");
140	print("	flags	", addr.flags, "\n");
141	print("	sp	", addr.sp, "\n");
142	print("}\n");
143	print("	ss	", addr.ss, "\n");
144};
145
146print("/sys/lib/acid/386");
147