dat.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  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. typedef struct Conf Conf;
  14. typedef struct Confmem Confmem;
  15. typedef struct FPsave FPsave;
  16. typedef struct ISAConf ISAConf;
  17. typedef struct Label Label;
  18. typedef struct Lock Lock;
  19. typedef struct Memcache Memcache;
  20. typedef struct MMMU MMMU;
  21. typedef struct Mach Mach;
  22. typedef struct Notsave Notsave;
  23. typedef struct Page Page;
  24. typedef struct PhysUart PhysUart;
  25. typedef struct PMMU PMMU;
  26. typedef struct Proc Proc;
  27. typedef u32int PTE;
  28. typedef struct Uart Uart;
  29. typedef struct Ureg Ureg;
  30. typedef uvlong Tval;
  31. #pragma incomplete Ureg
  32. #define MAXSYSARG 5 /* for mount(fd, mpt, flag, arg, srv) */
  33. /*
  34. * parameters for sysproc.c
  35. */
  36. #define AOUT_MAGIC (E_MAGIC)
  37. struct Lock
  38. {
  39. ulong key;
  40. u32int sr;
  41. uintptr pc;
  42. Proc* p;
  43. Mach* m;
  44. int isilock;
  45. };
  46. struct Label
  47. {
  48. uintptr sp;
  49. uintptr pc;
  50. };
  51. enum {
  52. Maxfpregs = 32, /* could be 16 or 32, see Mach.fpnregs */
  53. Nfpctlregs = 16,
  54. };
  55. /*
  56. * emulated or vfp3 floating point
  57. */
  58. struct FPsave
  59. {
  60. ulong status;
  61. ulong control;
  62. /*
  63. * vfp3 with ieee fp regs; uvlong is sufficient for hardware but
  64. * each must be able to hold an Internal from fpi.h for sw emulation.
  65. */
  66. ulong regs[Maxfpregs][3];
  67. int fpstate;
  68. uintptr pc; /* of failed fp instr. */
  69. };
  70. /*
  71. * FPsave.fpstate
  72. */
  73. enum
  74. {
  75. FPinit,
  76. FPactive,
  77. FPinactive,
  78. FPemu,
  79. /* bits or'd with the state */
  80. FPillegal= 0x100,
  81. };
  82. struct Confmem
  83. {
  84. uintptr base;
  85. usize npage;
  86. uintptr limit;
  87. uintptr kbase;
  88. uintptr klimit;
  89. };
  90. struct Conf
  91. {
  92. ulong nmach; /* processors */
  93. ulong nproc; /* processes */
  94. Confmem mem[1]; /* physical memory */
  95. ulong npage; /* total physical pages of memory */
  96. usize upages; /* user page pool */
  97. ulong copymode; /* 0 is copy on write, 1 is copy on reference */
  98. ulong ialloc; /* max interrupt time allocation in bytes */
  99. ulong pipeqsize; /* size in bytes of pipe queues */
  100. ulong nimage; /* number of page cache image headers */
  101. ulong nswap; /* number of swap pages */
  102. int nswppo; /* max # of pageouts per segment pass */
  103. ulong hz; /* processor cycle freq */
  104. ulong mhz;
  105. int monitor; /* flag */
  106. };
  107. /*
  108. * things saved in the Proc structure during a notify
  109. */
  110. struct Notsave {
  111. int emptiness;
  112. };
  113. /*
  114. * MMU stuff in Mach.
  115. */
  116. struct MMMU
  117. {
  118. PTE* mmul1; /* l1 for this processor */
  119. int mmul1lo;
  120. int mmul1hi;
  121. int mmupid;
  122. };
  123. /*
  124. * MMU stuff in proc
  125. */
  126. #define NCOLOR 1 /* 1 level cache, don't worry about VCE's */
  127. struct PMMU
  128. {
  129. Page* mmul2;
  130. Page* mmul2cache; /* free mmu pages */
  131. };
  132. #include "../port/portdat.h"
  133. struct Mach
  134. {
  135. int machno; /* physical id of processor */
  136. uintptr splpc; /* pc of last caller to splhi */
  137. Proc* proc; /* current process */
  138. MMMU;
  139. int flushmmu; /* flush current proc mmu state */
  140. ulong ticks; /* of the clock since boot time */
  141. Label sched; /* scheduler wakeup */
  142. Lock alarmlock; /* access to alarm list */
  143. void* alarm; /* alarms bound to this clock */
  144. Proc* readied; /* for runproc */
  145. ulong schedticks; /* next forced context switch */
  146. int cputype;
  147. ulong delayloop;
  148. /* stats */
  149. int tlbfault;
  150. int tlbpurge;
  151. int pfault;
  152. int cs;
  153. int syscall;
  154. int load;
  155. int intr;
  156. uvlong fastclock; /* last sampled value */
  157. ulong spuriousintr;
  158. int lastintr;
  159. int ilockdepth;
  160. Perf perf; /* performance counters */
  161. int cpumhz;
  162. uvlong cpuhz; /* speed of cpu */
  163. uvlong cyclefreq; /* Frequency of user readable cycle counter */
  164. /* vfp2 or vfp3 fpu */
  165. int havefp;
  166. int havefpvalid;
  167. int fpon;
  168. int fpconfiged;
  169. int fpnregs;
  170. ulong fpscr; /* sw copy */
  171. int fppid; /* pid of last fault */
  172. uintptr fppc; /* addr of last fault */
  173. int fpcnt; /* how many consecutive at that addr */
  174. /* save areas for exceptions, hold R0-R4 */
  175. u32int sfiq[5];
  176. u32int sirq[5];
  177. u32int sund[5];
  178. u32int sabt[5];
  179. u32int smon[5]; /* probably not needed */
  180. u32int ssys[5];
  181. int stack[1];
  182. };
  183. /*
  184. * Fake kmap.
  185. */
  186. typedef void KMap;
  187. #define VA(k) ((uintptr)(k))
  188. #define kmap(p) (KMap*)((p)->pa|kseg0)
  189. #define kunmap(k)
  190. struct
  191. {
  192. Lock;
  193. int machs; /* bitmap of active CPUs */
  194. int exiting; /* shutdown */
  195. int ispanic; /* shutdown in response to a panic */
  196. }active;
  197. extern register Mach* m; /* R10 */
  198. extern register Proc* up; /* R9 */
  199. extern uintptr kseg0;
  200. extern Mach* machaddr[MAXMACH];
  201. extern ulong memsize;
  202. extern int normalprint;
  203. /*
  204. * a parsed plan9.ini line
  205. */
  206. #define NISAOPT 8
  207. struct ISAConf {
  208. char *type;
  209. ulong port;
  210. int irq;
  211. ulong dma;
  212. ulong mem;
  213. ulong size;
  214. ulong freq;
  215. int nopt;
  216. char *opt[NISAOPT];
  217. };
  218. #define MACHP(n) (machaddr[n])
  219. /*
  220. * Horrid. But the alternative is 'defined'.
  221. */
  222. #ifdef _DBGC_
  223. #define DBGFLG (dbgflg[_DBGC_])
  224. #else
  225. #define DBGFLG (0)
  226. #endif /* _DBGC_ */
  227. int vflag;
  228. extern char dbgflg[256];
  229. #define dbgprint print /* for now */
  230. /*
  231. * hardware info about a device
  232. */
  233. typedef struct {
  234. ulong port;
  235. int size;
  236. } Devport;
  237. struct DevConf
  238. {
  239. ulong intnum; /* interrupt number */
  240. char *type; /* card type, malloced */
  241. int nports; /* Number of ports */
  242. Devport *ports; /* The ports themselves */
  243. };