dat.h 5.4 KB

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