dat.h 6.8 KB

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