arm.h 4.0 KB

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