dat.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  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. uint lastkmap; /* last entry used by kmap */
  103. };
  104. /*
  105. * things saved in the Proc structure during a notify
  106. */
  107. struct Notsave
  108. {
  109. ulong svflags;
  110. ulong svcs;
  111. ulong svss;
  112. };
  113. #include "../port/portdat.h"
  114. typedef struct {
  115. ulong link; /* link (old TSS selector) */
  116. ulong esp0; /* privilege level 0 stack pointer */
  117. ulong ss0; /* privilege level 0 stack selector */
  118. ulong esp1; /* privilege level 1 stack pointer */
  119. ulong ss1; /* privilege level 1 stack selector */
  120. ulong esp2; /* privilege level 2 stack pointer */
  121. ulong ss2; /* privilege level 2 stack selector */
  122. ulong cr3; /* page directory base register */
  123. ulong eip; /* instruction pointer */
  124. ulong eflags; /* flags register */
  125. ulong eax; /* general registers */
  126. ulong ecx;
  127. ulong edx;
  128. ulong ebx;
  129. ulong esp;
  130. ulong ebp;
  131. ulong esi;
  132. ulong edi;
  133. ulong es; /* segment selectors */
  134. ulong cs;
  135. ulong ss;
  136. ulong ds;
  137. ulong fs;
  138. ulong gs;
  139. ulong ldt; /* selector for task's LDT */
  140. ulong iomap; /* I/O map base address + T-bit */
  141. } Tss;
  142. struct Segdesc
  143. {
  144. ulong d0;
  145. ulong d1;
  146. };
  147. struct Mach
  148. {
  149. int machno; /* physical id of processor (KNOWN TO ASSEMBLY) */
  150. ulong splpc; /* pc of last caller to splhi */
  151. ulong* pdb; /* page directory base for this processor (va) */
  152. Tss* tss; /* tss for this processor */
  153. Segdesc *gdt; /* gdt for this processor */
  154. Proc* proc; /* current process on this processor */
  155. Proc* externup; /* extern register Proc *up */
  156. Page* pdbpool;
  157. int pdbcnt;
  158. ulong ticks; /* of the clock since boot time */
  159. Label sched; /* scheduler wakeup */
  160. Lock alarmlock; /* access to alarm list */
  161. void* alarm; /* alarms bound to this clock */
  162. int inclockintr;
  163. Proc* readied; /* for runproc */
  164. ulong schedticks; /* next forced context switch */
  165. int tlbfault;
  166. int tlbpurge;
  167. int pfault;
  168. int cs;
  169. int syscall;
  170. int load;
  171. int intr;
  172. int flushmmu; /* make current proc flush it's mmu state */
  173. int ilockdepth;
  174. Perf perf; /* performance counters */
  175. ulong spuriousintr;
  176. int lastintr;
  177. int loopconst;
  178. Lock apictimerlock;
  179. int cpumhz;
  180. uvlong cyclefreq; /* Frequency of user readable cycle counter */
  181. uvlong cpuhz;
  182. int cpuidax;
  183. int cpuiddx;
  184. char cpuidid[16];
  185. char* cpuidtype;
  186. int havetsc;
  187. int havepge;
  188. uvlong tscticks;
  189. vlong mtrrcap;
  190. vlong mtrrdef;
  191. vlong mtrrfix[11];
  192. vlong mtrrvar[32]; /* 256 max. */
  193. int stack[1];
  194. };
  195. /*
  196. * KMap the structure doesn't exist, but the functions do.
  197. */
  198. typedef struct KMap KMap;
  199. #define VA(k) ((void*)(k))
  200. KMap* kmap(Page*);
  201. void kunmap(KMap*);
  202. struct
  203. {
  204. Lock;
  205. int machs; /* bitmap of active CPUs */
  206. int exiting; /* shutdown */
  207. int ispanic; /* shutdown in response to a panic */
  208. int thunderbirdsarego; /* lets the added processors continue to schedinit */
  209. }active;
  210. /*
  211. * routines for things outside the PC model, like power management
  212. */
  213. struct PCArch
  214. {
  215. char* id;
  216. int (*ident)(void); /* this should be in the model */
  217. void (*reset)(void); /* this should be in the model */
  218. int (*serialpower)(int); /* 1 == on, 0 == off */
  219. int (*modempower)(int); /* 1 == on, 0 == off */
  220. void (*intrinit)(void);
  221. int (*intrenable)(Vctl*);
  222. int (*intrvecno)(int);
  223. int (*intrdisable)(int);
  224. void (*introff)(void);
  225. void (*intron)(void);
  226. void (*clockenable)(void);
  227. uvlong (*fastclock)(uvlong*);
  228. void (*timerset)(uvlong);
  229. };
  230. /*
  231. * a parsed plan9.ini line
  232. */
  233. #define NISAOPT 8
  234. struct ISAConf {
  235. char *type;
  236. ulong port;
  237. int irq;
  238. ulong dma;
  239. ulong mem;
  240. ulong size;
  241. ulong freq;
  242. int nopt;
  243. char *opt[NISAOPT];
  244. };
  245. extern PCArch *arch; /* PC architecture */
  246. /*
  247. * Each processor sees its own Mach structure at address MACHADDR.
  248. * However, the Mach structures must also be available via the per-processor
  249. * MMU information array machp, mainly for disambiguation and access to
  250. * the clock which is only maintained by the bootstrap processor (0).
  251. */
  252. Mach* machp[MAXMACH];
  253. #define MACHP(n) (machp[n])
  254. extern Mach *m;
  255. #define up (((Mach*)MACHADDR)->externup)
  256. /*
  257. * hardware info about a device
  258. */
  259. typedef struct {
  260. ulong port;
  261. int size;
  262. } Devport;
  263. struct DevConf
  264. {
  265. ulong intnum; /* interrupt number */
  266. char *type; /* card type, malloced */
  267. int nports; /* Number of ports */
  268. Devport *ports; /* The ports themselves */
  269. };