dat.h 6.5 KB

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