1 typedef struct Conf Conf; 2 typedef struct Confmem Confmem; 3 typedef struct ISAConf ISAConf; 4 typedef struct Label Label; 5 typedef struct Lock Lock; 6 typedef struct Mach Mach; 7 typedef u32int Mreg; /* Msr - bloody UART */ 8 typedef struct Page Page; 9 typedef struct FPsave FPsave; 10 typedef struct PMMU PMMU; 11 typedef struct Proc Proc; 12 typedef struct Softtlb Softtlb; 13 typedef struct Sys Sys; 14 typedef uvlong Tval; 15 typedef struct Ureg Ureg; 16 17 #pragma incomplete Ureg 18 19 #define MAXSYSARG 5 /* for mount(fd, mpt, flag, arg, srv) */ 20 21 /* 22 * parameters for sysproc.c 23 */ 24 #define AOUT_MAGIC Q_MAGIC 25 26 /* 27 * intc bits, as of 18 aug 2009. 28 * specific to rae's virtex5 design 29 */ 30 enum { 31 Bitllfifo, 32 Bittemac, 33 Bitdma, 34 Bitdma2, 35 Bituart, 36 Bitmiiphy, 37 Bitqtmmacfail, /* qtm only */ 38 Bitqtmdraminit, /* qtm only */ 39 40 Intllfifo=1<<Bitllfifo, /* local-link FIFO */ 41 Inttemac= 1<<Bittemac, 42 Intdma = 1<<Bitdma, 43 Intdma2 = 1<<Bitdma2, 44 Intuart = 1<<Bituart, 45 Intmiiphy = 1<<Bitmiiphy, 46 Intqtmmacfail= 1<<Bitqtmmacfail, 47 Intqtmdraminit= 1<<Bitqtmdraminit, 48 49 /* led bits */ 50 Ledtrap = 1<<0, /* states: processing a trap */ 51 Ledkern = 1<<0, /* running a kernel proc */ 52 Leduser = 1<<1, /* running a user proc */ 53 Ledidle = 1<<2, /* idling */ 54 Ledpulse = 1<<3, /* flags: still alive */ 55 /* off-led bits */ 56 Ledpanic = 1<<7, /* panicing */ 57 Ledethinwait = 1<<7, /* ethernet i/o waits */ 58 Ledethoutwait = 1<<7, 59 }; 60 61 /* 62 * machine dependent definitions used by ../port/dat.h 63 */ 64 65 struct Lock 66 { 67 ulong key; 68 ulong sr; 69 ulong pc; 70 Proc *p; 71 Mach *m; 72 ushort isilock; 73 ulong magic; 74 }; 75 76 struct Label 77 { 78 ulong sp; 79 ulong pc; 80 }; 81 82 /* 83 * emulated floating point 84 */ 85 struct FPsave 86 { 87 union { 88 double fpscrd; 89 struct { 90 ulong pad; 91 ulong fpscr; 92 }; 93 }; 94 int fpistate; 95 ulong emreg[32][3]; 96 }; 97 98 /* 99 * FPsave.status 100 */ 101 enum 102 { 103 FPinit, 104 FPactive, 105 FPinactive, 106 107 /* bit or'd with the state */ 108 FPillegal= 0x100, 109 }; 110 111 struct Confmem 112 { 113 ulong base; 114 ulong npage; 115 ulong kbase; 116 ulong klimit; 117 }; 118 119 struct Conf 120 { 121 ulong nmach; /* processors */ 122 ulong nproc; /* processes */ 123 Confmem mem[4]; 124 ulong npage; /* total physical pages of memory */ 125 ulong upages; /* user page pool */ 126 ulong nimage; /* number of page cache image headers */ 127 ulong nswap; /* number of swap pages */ 128 int nswppo; /* max # of pageouts per segment pass */ 129 ulong copymode; /* 0 is copy on write, 1 is copy on reference */ 130 int monitor; /* has display? */ 131 ulong ialloc; /* bytes available for interrupt time allocation */ 132 ulong pipeqsize; /* size in bytes of pipe queues */ 133 }; 134 135 /* 136 * mmu goo in the Proc structure 137 */ 138 #define NCOLOR 1 139 struct PMMU 140 { 141 int mmupid; 142 }; 143 144 /* debugging */ 145 #define TRIGGER() *(int *)(PHYSSRAM + 0xf0) = 0 146 147 #include "../port/portdat.h" 148 149 /* 150 * machine dependent definitions not used by ../port/dat.h 151 */ 152 /* 153 * Fake kmap 154 */ 155 typedef void KMap; 156 #define VA(k) PTR2UINT(k) 157 #define kmap(p) (KMap*)((p)->pa|KZERO) 158 #define kmapinval() 159 #define kunmap(k) 160 161 struct Mach 162 { 163 /* OFFSETS OF THE FOLLOWING KNOWN BY l.s */ 164 int machno; /* physical id of processor [0*4] */ 165 ulong splpc; /* pc that called splhi() [1*4] */ 166 Proc *proc; /* current process on this processor [2*4] */ 167 Softtlb* stlb; /* software tlb cache [3*4] */ 168 int utlbhi; /* lowest tlb index in use by kernel [4*4] */ 169 int utlbnext; /* next tlb entry to use for user (round robin) [5*4] */ 170 int tlbfault; /* number of tlb i/d misses [6*4] */ 171 172 /* ordering from here on irrelevant */ 173 174 ulong ticks; /* of the clock since boot time */ 175 Label sched; /* scheduler wakeup */ 176 Lock alarmlock; /* access to alarm list */ 177 void *alarm; /* alarms bound to this clock */ 178 int inclockintr; 179 180 Proc* readied; /* for runproc */ 181 ulong schedticks; /* next forced context switch */ 182 183 Mach *me; /* debugging: should be my own address */ 184 185 long oscclk; /* oscillator frequency (MHz) */ 186 long cpuhz; /* general system clock (cycles) */ 187 long clockgen; /* clock generator frequency (cycles) */ 188 long vcohz; 189 long pllhz; 190 long plbhz; 191 long opbhz; 192 long epbhz; 193 long pcihz; 194 int cputype; 195 ulong delayloop; 196 uvlong cyclefreq; /* frequency of user readable cycle clock */ 197 198 Mach *me2; /* debugging: should be my own address */ 199 200 uvlong fastclock; 201 Perf perf; /* performance counters */ 202 203 int tlbpurge; /* ... */ 204 int pfault; 205 int cs; 206 int syscall; 207 int load; 208 int intr; 209 int flushmmu; /* make current proc flush its mmu state */ 210 int ilockdepth; 211 212 int lastpid; /* last TLB pid allocated on this machine */ 213 QLock stlblock; /* prevent context switch during tlb update */ 214 Proc* pidproc[NTLBPID]; /* which proc owns a given pid */ 215 216 ulong spuriousintr; 217 int lastintr; 218 219 ulong magic; /* debugging; also check for stack overflow */ 220 221 /* MUST BE LAST */ 222 int stack[1]; 223 }; 224 225 struct Softtlb { 226 u32int hi; /* tlb hi, except that low order 10 bits have (pid[8]<<2) */ 227 u32int mid; 228 u32int lo; 229 }; 230 231 struct 232 { 233 Lock; 234 short machs; 235 short exiting; 236 short ispanic; 237 int thunderbirdsarego; /* lets the added processors continue to schedinit */ 238 }active; 239 240 /* 241 * a parsed plan9.ini line 242 */ 243 #define NISAOPT 8 244 245 struct ISAConf { 246 char *type; 247 ulong port; 248 int irq; 249 ulong dma; 250 ulong mem; 251 ulong size; 252 ulong freq; 253 254 int nopt; 255 char *opt[NISAOPT]; 256 }; 257 258 #define MACHP(n) ((Mach *)((int)&mach0 + (n)*MACHSIZE)) 259 extern Mach mach0; 260 261 extern register Mach *m; 262 extern register Proc *up; 263 264 /* 265 * Horrid. But the alternative is 'defined'. 266 */ 267 #ifdef _DBGC_ 268 #define DBGFLG (dbgflg[_DBGC_]) 269 #else 270 #define DBGFLG (0) 271 #endif /* _DBGC_ */ 272 273 // #define DBG(...) if(DBGFLG) dbgprint(__VA_ARGS__) 274 275 typedef struct { 276 ulong lasttm; /* last mutation start in seconds */ 277 ulong startticks; 278 ulong lastticks; 279 ulong count; 280 ulong totticks; 281 282 ulong period; /* in seconds */ 283 } Mutstats; 284 extern Mutstats mutstats; 285 286 char dbgflg[256]; 287 ulong intrs1sec; /* count interrupts in this second */ 288 uintptr memsz; 289 int okprint; 290 int securemem; 291 int vflag; 292 293 #define dbgprint print /* for now */ 294