arm.h 3.8 KB

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