xref: /plan9/sys/src/cmd/5i/arm.h (revision 514807136a8518a9c368e175000825c6e1429f43)
1 /*
2  * arm.h
3  */
4 #ifndef	EXTERN
5 #define	EXTERN	extern
6 #endif
7 
8 typedef	struct	Registers	Registers;
9 typedef	struct	Segment		Segment;
10 typedef	struct	Memory		Memory;
11 typedef	struct	Mul		Mul;
12 typedef	struct	Mulu		Mulu;
13 typedef	struct	Inst		Inst;
14 typedef	struct	Icache		Icache;
15 typedef	struct	Tlb		Tlb;
16 typedef	struct	Breakpoint	Breakpoint;
17 
18 enum
19 {
20 	Instruction	= 1,
21 	Read		= 2,
22 	Write		= 4,
23 	Access		= 2|4,
24 	Equal		= 4|8,
25 };
26 
27 struct Breakpoint
28 {
29 	int		type;		/* Instruction/Read/Access/Write/Equal */
30 	ulong		addr;		/* Place at address */
31 	int		count;		/* To execute count times or value */
32 	int		done;		/* How many times passed through */
33 	Breakpoint*	next;		/* Link to next one */
34 };
35 
36 enum
37 {
38 	Imem,
39 	Iarith,
40 	Ibranch,
41 	Isyscall,
42 };
43 
44 enum
45 {
46 	Nmaxtlb = 64,
47 	REGARG	= 0,
48 	REGRET	= 0,
49 	REGPC	= 15,
50 	REGLINK	= 14,
51 	REGSP	= 13,
52 };
53 
54 struct Tlb
55 {
56 	int	on;			/* Being updated */
57 	int	tlbsize;		/* Number of entries */
58 	ulong	tlbent[Nmaxtlb];	/* Virtual address tags */
59 	int	hit;			/* Number of successful tag matches */
60 	int	miss;			/* Number of failed tag matches */
61 };
62 
63 struct Icache
64 {
65 	int	on;			/* Turned on */
66 	int	linesize;		/* Line size in bytes */
67 	int	stall;			/* Cache stalls */
68 	int*	lines;			/* Tag array */
69 	int*	(*hash)(ulong);		/* Hash function */
70 	char*	hashtext;		/* What the function looks like */
71 };
72 
73 struct Inst
74 {
75 	void 	(*func)(ulong);
76 	char*	name;
77 	int	type;
78 	int	count;
79 	int	taken;
80 	int	useddelay;
81 };
82 
83 struct Registers
84 {
85 	ulong	ar;
86 	ulong	ir;
87 	Inst*	ip;
88 	long	r[16];
89 	long	cc1;
90 	long	cc2;
91 	int	class;
92 	int	cond;
93 	int	compare_op;
94 	int	cbit;
95 	int	cout;
96 };
97 
98 enum
99 {
100 	FPd	= 0,
101 	FPs,
102 	FPmemory,
103 };
104 
105 enum
106 {
107 	MemRead,
108 	MemReadstring,
109 	MemWrite,
110 };
111 
112 enum
113 {
114 	CCcmp,
115 	CCtst,
116 	CCteq,
117 };
118 
119 enum
120 {
121 	Stack,
122 	Text,
123 	Data,
124 	Bss,
125 	Nseg,
126 };
127 
128 struct Segment
129 {
130 	short	type;
131 	ulong	base;
132 	ulong	end;
133 	ulong	fileoff;
134 	ulong	fileend;
135 	int	rss;
136 	int	refs;
137 	uchar**	table;
138 };
139 
140 struct Memory
141 {
142 	Segment	seg[Nseg];
143 };
144 
145 void		Ssyscall(ulong);
146 int		armclass(long);
147 void		breakpoint(char*, char*);
148 void		brkchk(ulong, int);
149 void		cmd(void);
150 void		delbpt(char*);
151 void		dobplist(void);
152 void		dumpdreg(void);
153 void		dumpfreg(void);
154 void		dumpreg(void);
155 void*		emalloc(ulong);
156 void*		erealloc(void*, ulong, ulong);
157 ulong		expr(char*);
158 void		fatal(int, char*, ...);
159 ulong		getmem_2(ulong);
160 ulong		getmem_4(ulong);
161 uchar		getmem_b(ulong);
162 ushort		getmem_h(ulong);
163 uvlong		getmem_v(ulong);
164 ulong		getmem_w(ulong);
165 ulong		ifetch(ulong);
166 void		inithdr(int);
167 void		initicache(void);
168 void		initmap(void);
169 void		initstk(int, char**);
170 void		iprofile(void);
171 void		isum(void);
172 void		itrace(char*, ...);
173 long		lnrand(long);
174 char*		memio(char*, ulong, int, int);
175 int		_mipscoinst(Map*, ulong, char*, int);
176 Mul		mul(long, long);
177 Mulu		mulu(ulong, ulong);
178 char*		nextc(char*);
179 void		printlocals(Symbol*, ulong);
180 void		printparams(Symbol*, ulong);
181 void		printsource(long);
182 void		procinit(int);
183 void		putmem_b(ulong, uchar);
184 void		putmem_h(ulong, ushort);
185 void		putmem_v(ulong, uvlong);
186 void		putmem_w(ulong, ulong);
187 void		reset(void);
188 void		run(void);
189 void		segsum(void);
190 void		stktrace(int);
191 void		tlbsum(void);
192 void		undef(ulong);
193 void		updateicache(ulong addr);
194 void*		vaddr(ulong);
195 
196 /* Globals */
197 EXTERN	Registers	reg;
198 EXTERN	Memory		memory;
199 EXTERN	int		text;
200 EXTERN	int		trace;
201 EXTERN	int		sysdbg;
202 EXTERN	int		calltree;
203 EXTERN	Inst		itab[];
204 EXTERN	Inst		ispec[];
205 EXTERN	Icache		icache;
206 EXTERN	Tlb		tlb;
207 EXTERN	int		count;
208 EXTERN	jmp_buf		errjmp;
209 EXTERN	Breakpoint*	bplist;
210 EXTERN	int		atbpt;
211 EXTERN	int		membpt;
212 EXTERN	int		cmdcount;
213 EXTERN	int		nopcount;
214 EXTERN	ulong		dot;
215 EXTERN	char*		file;
216 EXTERN	Biobuf*		bioout;
217 EXTERN	Biobuf*		bin;
218 EXTERN	ulong*		iprof;
219 EXTERN	int		datasize;
220 EXTERN	Map*		symmap;
221 
222 /* Plan9 Kernel constants */
223 enum
224 {
225 	BY2PG		= 4096,
226 	BY2WD		= 4,
227 	UTZERO		= 0x1000,
228 	STACKTOP	= 0x80000000,
229 	STACKSIZE	= 0x10000,
230 
231 	PROFGRAN	= 4,
232 	Sbit		= 1<<20,
233 	SIGNBIT		= 0x80000000,
234 
235 	FP_U		= 3,
236 	FP_L		= 1,
237 	FP_G		= 2,
238 	FP_E		= 0,
239 	FP_CBIT		= 1<<23,
240 };
241