4 * The integer instruction side of this emulator is portable if sizeof(long) >= 4
5 * Floating point emulation however is not. Assumptions made are:
6 * sizeof(ulong) == sizeof(float)
7 * sizeof(ulong)*2 == sizeof(double)
8 * bits of floating point in memory may be reversed lsw/msw
9 * unions of double & 2*float & 2*long have no padding
11 #include "/sparc/include/ureg.h"
12 #define USERADDR 0xC0000000
13 #define UREGADDR (USERADDR+BY2PG-4-0xA0)
14 #define USER_REG(x) (UREGADDR+(ulong)(x))
15 #define REGOFF(x) (USER_REG(&((struct Ureg *) 0)->x))
17 typedef struct Registers Registers;
18 typedef struct Segment Segment;
19 typedef struct Memory Memory;
20 typedef struct Mul Mul;
21 typedef struct Mulu Mulu;
22 typedef struct Inst Inst;
23 typedef struct Icache Icache;
24 typedef struct Breakpoint Breakpoint;
37 int type; /* Instruction/Read/Access/Write/Equal */
38 ulong addr; /* Place at address */
39 int count; /* To execute count times or value */
40 int done; /* How many times passed through */
41 Breakpoint *next; /* Link to next one */
58 int on; /* Turned on */
59 int linesize; /* Line size in bytes */
60 int stall; /* Cache stalls */
61 int *lines; /* Tag array */
62 int* (*hash)(ulong); /* Hash function */
63 char *hashtext; /* What the function looks like */
136 void fatal(int, char*, ...);
142 void* emalloc(ulong);
143 void* erealloc(void*, ulong, ulong);
145 void itrace(char *, ...);
148 char* memio(char*, ulong, int, int);
149 ulong getmem_w(ulong);
151 ushort getmem_h(ulong);
152 void putmem_w(ulong, ulong);
153 uchar getmem_b(ulong);
154 void putmem_b(ulong, uchar);
155 ulong getmem_4(ulong);
156 ulong getmem_2(ulong);
157 void putmem_h(ulong, short);
159 Mulu mulu(ulong, ulong);
161 void initicache(void);
162 void updateicache(ulong addr);
164 void randseed(long, long);
166 void brkchk(ulong, int);
168 void breakpoint(char*, char*);
171 void initstk(int, char**);
177 void printsource(long);
178 void printparams(Symbol *, ulong);
179 void printlocals(Symbol *, ulong);
185 Extern Registers reg;
186 Extern Memory memory;
191 Extern Icache icache;
193 Extern jmp_buf errjmp;
194 Extern Breakpoint *bplist;
201 Extern Biobuf *bioout;
205 Extern ulong loadlock;
206 Extern ulong anulled;
211 /* Plan9 Kernel constants */
214 #define UTZERO 0x1000
216 #define TSTACKTOP 0x10000000
217 #define STACKTOP (TSTACKTOP-TSTKSIZ*BY2PG)
218 #define STACKSIZE (4*1024*1024)
222 #define NOP 0x80300000
223 #define SIGNBIT 0x80000000
224 #define IMMBIT (1<<13)
225 #define getrop23(i) rd = (i>>25)&0x1f; rs1 = (i>>14)&0x1f; rs2 = i&0x1f;
226 #define ximm(xx, ii) xx = ii&0x1FFF; if(xx&0x1000) xx |= ~0x1FFF
228 #define PSR_n (1<<23)
229 #define PSR_z (1<<22)
230 #define PSR_v (1<<21)
231 #define PSR_c (1<<20)