dat.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. typedef struct Conf Conf;
  2. typedef struct FPsave FPsave;
  3. typedef struct ISAConf ISAConf;
  4. typedef struct Label Label;
  5. typedef struct Lock Lock;
  6. typedef struct MMU MMU;
  7. typedef struct Mach Mach;
  8. typedef struct Notsave Notsave;
  9. typedef struct PCArch PCArch;
  10. typedef struct Pcidev Pcidev;
  11. typedef struct PCMmap PCMmap;
  12. typedef struct PCMslot PCMslot;
  13. typedef struct Page Page;
  14. typedef struct PMMU PMMU;
  15. typedef struct Proc Proc;
  16. typedef struct Segdesc Segdesc;
  17. typedef struct Ureg Ureg;
  18. typedef struct Vctl Vctl;
  19. #define MAXSYSARG 5 /* for mount(fd, afd, mpt, flag, arg) */
  20. /*
  21. * parameters for sysproc.c
  22. */
  23. #define AOUT_MAGIC (I_MAGIC)
  24. struct Lock
  25. {
  26. ulong key;
  27. ulong sr;
  28. ulong pc;
  29. Proc *p;
  30. ushort isilock;
  31. };
  32. struct Label
  33. {
  34. ulong sp;
  35. ulong pc;
  36. };
  37. /*
  38. * FPsave.status
  39. */
  40. enum
  41. {
  42. /* this is a state */
  43. FPinit= 0,
  44. FPactive= 1,
  45. FPinactive= 2,
  46. /* the following is a bit that can be or'd into the state */
  47. FPillegal= 0x100,
  48. };
  49. struct FPsave
  50. {
  51. ushort control;
  52. ushort r1;
  53. ushort status;
  54. ushort r2;
  55. ushort tag;
  56. ushort r3;
  57. ulong pc;
  58. ushort selector;
  59. ushort r4;
  60. ulong operand;
  61. ushort oselector;
  62. ushort r5;
  63. uchar regs[80]; /* floating point registers */
  64. };
  65. struct Conf
  66. {
  67. ulong nmach; /* processors */
  68. ulong nproc; /* processes */
  69. ulong monitor; /* has monitor? */
  70. ulong npage0; /* total physical pages of memory */
  71. ulong npage1; /* total physical pages of memory */
  72. ulong npage; /* total physical pages of memory */
  73. ulong upages; /* user page pool */
  74. ulong nimage; /* number of page cache image headers */
  75. ulong nswap; /* number of swap pages */
  76. int nswppo; /* max # of pageouts per segment pass */
  77. ulong base0; /* base of bank 0 */
  78. ulong base1; /* base of bank 1 */
  79. ulong copymode; /* 0 is copy on write, 1 is copy on reference */
  80. ulong ialloc; /* max interrupt time allocation in bytes */
  81. ulong pipeqsize; /* size in bytes of pipe queues */
  82. int nuart; /* number of uart devices */
  83. };
  84. /*
  85. * MMU stuff in proc
  86. */
  87. #define NCOLOR 1
  88. struct PMMU
  89. {
  90. Page* mmupdb; /* page directory base */
  91. Page* mmufree; /* unused page table pages */
  92. Page* mmuused; /* used page table pages */
  93. };
  94. /*
  95. * things saved in the Proc structure during a notify
  96. */
  97. struct Notsave
  98. {
  99. ulong svflags;
  100. ulong svcs;
  101. ulong svss;
  102. };
  103. #include "../port/portdat.h"
  104. typedef struct {
  105. ulong link; /* link (old TSS selector) */
  106. ulong esp0; /* privilege level 0 stack pointer */
  107. ulong ss0; /* privilege level 0 stack selector */
  108. ulong esp1; /* privilege level 1 stack pointer */
  109. ulong ss1; /* privilege level 1 stack selector */
  110. ulong esp2; /* privilege level 2 stack pointer */
  111. ulong ss2; /* privilege level 2 stack selector */
  112. ulong cr3; /* page directory base register */
  113. ulong eip; /* instruction pointer */
  114. ulong eflags; /* flags register */
  115. ulong eax; /* general registers */
  116. ulong ecx;
  117. ulong edx;
  118. ulong ebx;
  119. ulong esp;
  120. ulong ebp;
  121. ulong esi;
  122. ulong edi;
  123. ulong es; /* segment selectors */
  124. ulong cs;
  125. ulong ss;
  126. ulong ds;
  127. ulong fs;
  128. ulong gs;
  129. ulong ldt; /* selector for task's LDT */
  130. ulong iomap; /* I/O map base address + T-bit */
  131. } Tss;
  132. struct Segdesc
  133. {
  134. ulong d0;
  135. ulong d1;
  136. };
  137. struct Mach
  138. {
  139. int machno; /* physical id of processor (KNOWN TO ASSEMBLY) */
  140. ulong splpc; /* pc of last caller to splhi */
  141. ulong* pdb; /* page directory base for this processor (va) */
  142. Tss* tss; /* tss for this processor */
  143. Segdesc *gdt; /* gdt for this processor */
  144. Proc* proc; /* current process on this processor */
  145. Proc* externup; /* extern register Proc *up */
  146. Page* pdbpool;
  147. int pdbcnt;
  148. ulong ticks; /* of the clock since boot time */
  149. Label sched; /* scheduler wakeup */
  150. Lock alarmlock; /* access to alarm list */
  151. void* alarm; /* alarms bound to this clock */
  152. int inclockintr;
  153. ulong fairness; /* for runproc */
  154. int tlbfault;
  155. int tlbpurge;
  156. int pfault;
  157. int cs;
  158. int syscall;
  159. int load;
  160. int intr;
  161. int flushmmu; /* make current proc flush it's mmu state */
  162. int ilockdepth;
  163. Perf perf; /* performance counters */
  164. ulong spuriousintr;
  165. int lastintr;
  166. int loopconst;
  167. Lock apictimerlock;
  168. int cpumhz;
  169. uvlong cyclefreq; /* Frequency of user readable cycle counter */
  170. uvlong cpuhz;
  171. int cpuidax;
  172. int cpuiddx;
  173. char cpuidid[16];
  174. char* cpuidtype;
  175. int havetsc;
  176. int havepge;
  177. uvlong tscticks;
  178. vlong mtrrcap;
  179. vlong mtrrdef;
  180. vlong mtrrfix[11];
  181. vlong mtrrvar[32]; /* 256 max. */
  182. int stack[1];
  183. };
  184. /*
  185. * Fake kmap
  186. */
  187. typedef void KMap;
  188. #define VA(k) ((ulong)(k))
  189. #define kmap(p) (KMap*)((p)->pa|KZERO)
  190. #define kunmap(k)
  191. struct
  192. {
  193. Lock;
  194. int machs; /* bitmap of active CPUs */
  195. int exiting; /* shutdown */
  196. int ispanic; /* shutdown in response to a panic */
  197. }active;
  198. /*
  199. * routines for things outside the PC model, like power management
  200. */
  201. struct PCArch
  202. {
  203. char* id;
  204. int (*ident)(void); /* this should be in the model */
  205. void (*reset)(void); /* this should be in the model */
  206. int (*serialpower)(int); /* 1 == on, 0 == off */
  207. int (*modempower)(int); /* 1 == on, 0 == off */
  208. void (*intrinit)(void);
  209. int (*intrenable)(Vctl*);
  210. int (*intrvecno)(int);
  211. int (*intrdisable)(int);
  212. void (*clockenable)(void);
  213. uvlong (*fastclock)(uvlong*);
  214. void (*timerset)(uvlong);
  215. };
  216. /*
  217. * a parsed plan9.ini line
  218. */
  219. #define NISAOPT 8
  220. struct ISAConf {
  221. char *type;
  222. ulong port;
  223. int irq;
  224. ulong dma;
  225. ulong mem;
  226. ulong size;
  227. ulong freq;
  228. int nopt;
  229. char *opt[NISAOPT];
  230. };
  231. extern PCArch *arch; /* PC architecture */
  232. /*
  233. * Each processor sees its own Mach structure at address MACHADDR.
  234. * However, the Mach structures must also be available via the per-processor
  235. * MMU information array machp, mainly for disambiguation and access to
  236. * the clock which is only maintained by the bootstrap processor (0).
  237. */
  238. Mach* machp[MAXMACH];
  239. #define MACHP(n) (machp[n])
  240. extern Mach *m;
  241. #define up (((Mach*)MACHADDR)->externup)
  242. /*
  243. * hardware info about a device
  244. */
  245. typedef struct {
  246. ulong port;
  247. int size;
  248. } port_t;
  249. struct DevConf
  250. {
  251. ulong intnum; /* interrupt number */
  252. char *type; /* card type, malloced */
  253. int nports; /* Number of ports */
  254. port_t *ports; /* The ports themselves */
  255. };