dat.h 6.4 KB

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