dat.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. typedef struct Conf Conf;
  2. typedef struct Confmem Confmem;
  3. typedef struct FPsave FPsave;
  4. typedef struct ISAConf ISAConf;
  5. typedef struct Label Label;
  6. typedef struct Lock Lock;
  7. typedef struct MMMU MMMU;
  8. typedef struct Mach Mach;
  9. typedef struct Notsave Notsave;
  10. typedef struct Page Page;
  11. typedef struct Pcidev Pcidev;
  12. typedef struct PhysUart PhysUart;
  13. typedef struct PFPU PFPU;
  14. typedef struct PMMU PMMU;
  15. typedef struct PNOTIFY PNOTIFY;
  16. typedef struct Proc Proc;
  17. typedef u32int PTE;
  18. typedef struct Uart Uart;
  19. typedef struct Ureg Ureg;
  20. typedef uvlong Tval;
  21. #pragma incomplete Pcidev
  22. #pragma incomplete Ureg
  23. #define MAXSYSARG 5 /* for mount(fd, mpt, flag, arg, srv) */
  24. /*
  25. * parameters for sysproc.c
  26. */
  27. #define AOUT_MAGIC (E_MAGIC)
  28. struct Lock
  29. {
  30. ulong key;
  31. u32int sr;
  32. uintptr pc;
  33. Proc* p;
  34. Mach* m;
  35. int isilock;
  36. };
  37. struct Label
  38. {
  39. uintptr sp;
  40. uintptr pc;
  41. };
  42. /*
  43. * emulated floating point
  44. */
  45. struct PFPU
  46. {
  47. ulong status;
  48. ulong control;
  49. ulong regs[8][3];
  50. int fpstate;
  51. };
  52. /*
  53. * PFPU.status
  54. */
  55. enum
  56. {
  57. FPinit,
  58. FPactive,
  59. FPinactive,
  60. };
  61. struct Confmem
  62. {
  63. uintptr base;
  64. usize npage;
  65. uintptr limit;
  66. uintptr kbase;
  67. uintptr klimit;
  68. };
  69. struct Conf
  70. {
  71. ulong nmach; /* processors */
  72. ulong nproc; /* processes */
  73. ulong monitor; /* has monitor? */
  74. Confmem mem[1]; /* physical memory */
  75. ulong npage; /* total physical pages of memory */
  76. usize upages; /* user page pool */
  77. ulong copymode; /* 0 is copy on write, 1 is copy on reference */
  78. ulong ialloc; /* max interrupt time allocation in bytes */
  79. ulong pipeqsize; /* size in bytes of pipe queues */
  80. ulong nimage; /* number of page cache image headers */
  81. ulong nswap; /* number of swap pages */
  82. int nswppo; /* max # of pageouts per segment pass */
  83. // ulong hz; /* processor cycle freq */
  84. // ulong mhz;
  85. };
  86. struct FPsave {
  87. int emptiness;
  88. };
  89. struct Notsave {
  90. int emptiness;
  91. };
  92. /*
  93. * MMU stuff in Mach.
  94. */
  95. struct MMMU
  96. {
  97. PTE* mmul1; /* l1 for this processor */
  98. int mmul1lo;
  99. int mmul1hi;
  100. int mmupid;
  101. };
  102. /*
  103. * MMU stuff in proc
  104. */
  105. #define NCOLOR 1 /* 1 level cache, don't worry about VCE's */
  106. struct PMMU
  107. {
  108. Page* mmul2;
  109. Page* mmul2cache; /* free mmu pages */
  110. PFPU; /* hack */
  111. };
  112. /*
  113. * things saved in the Proc structure during a notify
  114. */
  115. struct PNOTIFY
  116. {
  117. void emptiness;
  118. };
  119. #include "../port/portdat.h"
  120. struct Mach
  121. {
  122. int machno; /* physical id of processor */
  123. uintptr splpc; /* pc of last caller to splhi */
  124. Proc* proc; /* current process */
  125. MMMU;
  126. int flushmmu; /* flush current proc mmu state */
  127. ulong ticks; /* of the clock since boot time */
  128. Label sched; /* scheduler wakeup */
  129. Lock alarmlock; /* access to alarm list */
  130. void* alarm; /* alarms bound to this clock */
  131. int inclockintr;
  132. Proc* readied; /* for runproc */
  133. ulong schedticks; /* next forced context switch */
  134. int cputype;
  135. ulong delayloop;
  136. /* stats */
  137. int tlbfault;
  138. int tlbpurge;
  139. int pfault;
  140. int cs;
  141. int syscall;
  142. int load;
  143. int intr;
  144. vlong fastclock; /* last sampled value */
  145. uvlong inidle; /* time spent in idlehands() */
  146. ulong spuriousintr;
  147. int lastintr;
  148. int ilockdepth;
  149. Perf perf; /* performance counters */
  150. // int cpumhz;
  151. uvlong cpuhz; /* speed of cpu */
  152. uvlong cyclefreq; /* Frequency of user readable cycle counter */
  153. /* save areas for exceptions */
  154. u32int sfiq[5];
  155. u32int sirq[5];
  156. u32int sund[5];
  157. u32int sabt[5];
  158. #define fiqstack sfiq
  159. #define irqstack sirq
  160. #define abtstack sabt
  161. #define undstack sund
  162. int stack[1];
  163. };
  164. /*
  165. * Fake kmap.
  166. */
  167. typedef void KMap;
  168. #define VA(k) ((uintptr)(k))
  169. #define kmap(p) (KMap*)((p)->pa|kseg0)
  170. #define kunmap(k)
  171. struct
  172. {
  173. Lock;
  174. int machs; /* bitmap of active CPUs */
  175. int exiting; /* shutdown */
  176. int ispanic; /* shutdown in response to a panic */
  177. }active;
  178. enum {
  179. // Frequency = 1200*1000*1000/2, /* half the processor clock */
  180. Frequency = 1200*1000*1000, /* the processor clock */
  181. };
  182. extern register Mach* m; /* R10 */
  183. extern register Proc* up; /* R9 */
  184. extern uintptr kseg0;
  185. extern Mach* machaddr[MAXMACH];
  186. enum {
  187. Nvec = 8, /* # of vectors at start of lexception.s */
  188. };
  189. /*
  190. * Layout of physical 0.
  191. */
  192. typedef struct Vectorpage {
  193. void (*vectors[Nvec])(void);
  194. uint vtable[Nvec];
  195. } Vectorpage;
  196. /*
  197. * a parsed plan9.ini line
  198. */
  199. #define NISAOPT 8
  200. struct ISAConf {
  201. char *type;
  202. ulong port;
  203. int irq;
  204. ulong dma;
  205. ulong mem;
  206. ulong size;
  207. ulong freq;
  208. int nopt;
  209. char *opt[NISAOPT];
  210. };
  211. #define MACHP(n) (machaddr[n])
  212. /*
  213. * Horrid. But the alternative is 'defined'.
  214. */
  215. #ifdef _DBGC_
  216. #define DBGFLG (dbgflg[_DBGC_])
  217. #else
  218. #define DBGFLG (0)
  219. #endif /* _DBGC_ */
  220. int vflag;
  221. extern char dbgflg[256];
  222. #define dbgprint print /* for now */