dat.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. /*
  2. * Time.
  3. *
  4. * HZ should divide 1000 evenly, ideally.
  5. * 100, 125, 200, 250 and 333 are okay.
  6. */
  7. #define HZ 100 /* clock frequency */
  8. #define MS2HZ (1000/HZ) /* millisec per clock tick */
  9. #define TK2SEC(t) ((t)/HZ) /* ticks to seconds */
  10. /*
  11. * More accurate time
  12. */
  13. #define MS2TMR(t) ((ulong)(((uvlong)(t) * m->cpuhz)/1000))
  14. #define US2TMR(t) ((ulong)(((uvlong)(t) * m->cpuhz)/1000000))
  15. /*
  16. * we ignore the first 2 uarts on the omap3530 (see uarti8250.c) and use the
  17. * third one but call it 0.
  18. */
  19. #define CONSOLE 0
  20. typedef struct Conf Conf;
  21. typedef struct Confmem Confmem;
  22. typedef struct FPsave FPsave;
  23. typedef struct ISAConf ISAConf;
  24. typedef struct Label Label;
  25. typedef struct Lock Lock;
  26. typedef struct Memcache Memcache;
  27. typedef struct MMMU MMMU;
  28. typedef struct Mach Mach;
  29. typedef u32int Mreg; /* Msr - bloody UART */
  30. typedef struct Notsave Notsave;
  31. typedef struct Page Page;
  32. typedef struct PhysUart PhysUart;
  33. typedef struct PMMU PMMU;
  34. typedef struct Proc Proc;
  35. typedef u32int PTE;
  36. typedef struct Uart Uart;
  37. typedef struct Ureg Ureg;
  38. typedef uvlong Tval;
  39. #pragma incomplete Ureg
  40. #define MAXSYSARG 5 /* for mount(fd, mpt, flag, arg, srv) */
  41. /*
  42. * parameters for sysproc.c
  43. */
  44. #define AOUT_MAGIC (E_MAGIC)
  45. struct Lock
  46. {
  47. ulong key;
  48. u32int sr;
  49. uintptr pc;
  50. Proc* p;
  51. Mach* m;
  52. int isilock;
  53. };
  54. struct Label
  55. {
  56. uintptr sp;
  57. uintptr pc;
  58. };
  59. /*
  60. * emulated floating point
  61. */
  62. struct FPsave
  63. {
  64. ulong status;
  65. ulong control;
  66. ulong regs[8][3];
  67. int fpstate;
  68. };
  69. /*
  70. * FPsave.status
  71. */
  72. enum
  73. {
  74. FPinit,
  75. FPactive,
  76. FPinactive,
  77. };
  78. struct Confmem
  79. {
  80. uintptr base;
  81. usize npage;
  82. uintptr limit;
  83. uintptr kbase;
  84. uintptr klimit;
  85. };
  86. struct Conf
  87. {
  88. ulong nmach; /* processors */
  89. ulong nproc; /* processes */
  90. Confmem mem[1]; /* physical memory */
  91. ulong npage; /* total physical pages of memory */
  92. usize upages; /* user page pool */
  93. ulong copymode; /* 0 is copy on write, 1 is copy on reference */
  94. ulong ialloc; /* max interrupt time allocation in bytes */
  95. ulong pipeqsize; /* size in bytes of pipe queues */
  96. ulong nimage; /* number of page cache image headers */
  97. ulong nswap; /* number of swap pages */
  98. int nswppo; /* max # of pageouts per segment pass */
  99. ulong hz; /* processor cycle freq */
  100. ulong mhz;
  101. int monitor; /* flag */
  102. };
  103. /*
  104. * things saved in the Proc structure during a notify
  105. */
  106. struct Notsave {
  107. int emptiness;
  108. };
  109. /*
  110. * MMU stuff in Mach.
  111. */
  112. struct MMMU
  113. {
  114. PTE* mmul1; /* l1 for this processor */
  115. int mmul1lo;
  116. int mmul1hi;
  117. int mmupid;
  118. };
  119. /*
  120. * MMU stuff in proc
  121. */
  122. #define NCOLOR 1 /* 1 level cache, don't worry about VCE's */
  123. struct PMMU
  124. {
  125. Page* mmul2;
  126. Page* mmul2cache; /* free mmu pages */
  127. };
  128. #include "../port/portdat.h"
  129. struct Mach
  130. {
  131. int machno; /* physical id of processor */
  132. uintptr splpc; /* pc of last caller to splhi */
  133. Proc* proc; /* current process */
  134. MMMU;
  135. int flushmmu; /* flush current proc mmu state */
  136. ulong ticks; /* of the clock since boot time */
  137. Label sched; /* scheduler wakeup */
  138. Lock alarmlock; /* access to alarm list */
  139. void* alarm; /* alarms bound to this clock */
  140. int inclockintr;
  141. Proc* readied; /* for runproc */
  142. ulong schedticks; /* next forced context switch */
  143. int cputype;
  144. ulong delayloop;
  145. /* stats */
  146. int tlbfault;
  147. int tlbpurge;
  148. int pfault;
  149. int cs;
  150. int syscall;
  151. int load;
  152. int intr;
  153. uvlong fastclock; /* last sampled value */
  154. uvlong inidle; /* time spent in idlehands() */
  155. ulong spuriousintr;
  156. int lastintr;
  157. int ilockdepth;
  158. Perf perf; /* performance counters */
  159. int cpumhz;
  160. uvlong cpuhz; /* speed of cpu */
  161. uvlong cyclefreq; /* Frequency of user readable cycle counter */
  162. /* save areas for exceptions, hold R0-R4 */
  163. u32int sfiq[5];
  164. u32int sirq[5];
  165. u32int sund[5];
  166. u32int sabt[5];
  167. u32int smon[5]; /* probably not needed */
  168. u32int ssys[5];
  169. int stack[1];
  170. };
  171. /*
  172. * Fake kmap.
  173. */
  174. typedef void KMap;
  175. #define VA(k) ((uintptr)(k))
  176. #define kmap(p) (KMap*)((p)->pa|kseg0)
  177. #define kunmap(k)
  178. struct
  179. {
  180. Lock;
  181. int machs; /* bitmap of active CPUs */
  182. int exiting; /* shutdown */
  183. int ispanic; /* shutdown in response to a panic */
  184. }active;
  185. extern register Mach* m; /* R10 */
  186. extern register Proc* up; /* R9 */
  187. extern uintptr kseg0;
  188. extern Mach* machaddr[MAXMACH];
  189. extern ulong memsize;
  190. extern int normalprint;
  191. /*
  192. * a parsed plan9.ini line
  193. */
  194. #define NISAOPT 8
  195. struct ISAConf {
  196. char *type;
  197. ulong port;
  198. int irq;
  199. ulong dma;
  200. ulong mem;
  201. ulong size;
  202. ulong freq;
  203. int nopt;
  204. char *opt[NISAOPT];
  205. };
  206. #define MACHP(n) (machaddr[n])
  207. /*
  208. * Horrid. But the alternative is 'defined'.
  209. */
  210. #ifdef _DBGC_
  211. #define DBGFLG (dbgflg[_DBGC_])
  212. #else
  213. #define DBGFLG (0)
  214. #endif /* _DBGC_ */
  215. int vflag;
  216. extern char dbgflg[256];
  217. #define dbgprint print /* for now */
  218. /*
  219. * hardware info about a device
  220. */
  221. typedef struct {
  222. ulong port;
  223. int size;
  224. } Devport;
  225. struct DevConf
  226. {
  227. ulong intnum; /* interrupt number */
  228. char *type; /* card type, malloced */
  229. int nports; /* Number of ports */
  230. Devport *ports; /* The ports themselves */
  231. };
  232. enum {
  233. Dcache,
  234. Icache,
  235. Unified,
  236. };
  237. /* characteristics of a given cache level */
  238. struct Memcache {
  239. uint level; /* 1 is nearest processor, 2 further away */
  240. uint l1ip; /* l1 I policy */
  241. uint nways; /* associativity */
  242. uint nsets;
  243. uint linelen; /* bytes per cache line */
  244. uint setsways;
  245. uint log2linelen;
  246. uint waysh; /* shifts for set/way register */
  247. uint setsh;
  248. };
  249. enum Dmamode {
  250. Const,
  251. Postincr,
  252. Index,
  253. Index2,
  254. };