4 * HZ should divide 1000 evenly, ideally.
5 * 100, 125, 200, 250 and 333 are okay.
7 #define HZ 100 /* clock frequency */
8 #define MS2HZ (1000/HZ) /* millisec per clock tick */
9 #define TK2SEC(t) ((t)/HZ) /* ticks to seconds */
13 Dogsectimeout = 4, /* must be ≤ 34 s. to fit in a ulong */
19 #define MS2TMR(t) ((ulong)(((uvlong)(t) * m->cpuhz)/1000))
20 #define US2TMR(t) ((ulong)(((uvlong)(t) * m->cpuhz)/1000000))
24 typedef struct Conf Conf;
25 typedef struct Confmem Confmem;
26 typedef struct FPsave FPsave;
27 typedef struct PFPU PFPU;
28 typedef struct ISAConf ISAConf;
29 typedef struct Isolated Isolated;
30 typedef struct Label Label;
31 typedef struct Lock Lock;
32 typedef struct Lowmemcache Lowmemcache;
33 typedef struct Memcache Memcache;
34 typedef struct MMMU MMMU;
35 typedef struct Mach Mach;
36 typedef u32int Mreg; /* Msr - bloody UART */
37 typedef struct Page Page;
38 typedef struct Pcisiz Pcisiz;
39 typedef struct Pcidev Pcidev;
40 typedef struct PhysUart PhysUart;
41 typedef struct PMMU PMMU;
42 typedef struct Proc Proc;
44 typedef struct Soc Soc;
45 typedef struct Uart Uart;
46 typedef struct Ureg Ureg;
49 #pragma incomplete Pcidev
50 #pragma incomplete Ureg
52 #define MAXSYSARG 5 /* for mount(fd, mpt, flag, arg, srv) */
55 * parameters for sysproc.c
57 #define AOUT_MAGIC (E_MAGIC)
76 * emulated or vfp3 floating point
79 Maxfpregs = 32, /* could be 16 or 32, see Mach.fpnregs */
88 * vfp3 with ieee fp regs; uvlong is sufficient for hardware but
89 * each must be able to hold an Internal from fpi.h for sw emulation.
91 ulong regs[Maxfpregs][3];
94 uintptr pc; /* of failed fp instr. */
110 /* bit or'd with the state */
125 ulong nmach; /* processors */
126 ulong nproc; /* processes */
127 Confmem mem[1]; /* physical memory */
128 ulong npage; /* total physical pages of memory */
129 usize upages; /* user page pool */
130 ulong copymode; /* 0 is copy on write, 1 is copy on reference */
131 ulong ialloc; /* max interrupt time allocation in bytes */
132 ulong pipeqsize; /* size in bytes of pipe queues */
133 ulong nimage; /* number of page cache image headers */
134 ulong nswap; /* number of swap pages */
135 int nswppo; /* max # of pageouts per segment pass */
136 ulong hz; /* processor cycle freq */
138 int monitor; /* flag */
146 PTE* mmul1; /* l1 for this processor */
155 #define NCOLOR 1 /* 1 level cache, don't worry about VCE's */
159 Page* mmul2cache; /* free mmu pages */
162 #include "../port/portdat.h"
166 /* offsets known to asm */
167 int machno; /* physical id of processor */
168 uintptr splpc; /* pc of last caller to splhi */
170 Proc* proc; /* current process */
173 /* end of offsets known to asm */
174 int flushmmu; /* flush current proc mmu state */
176 ulong ticks; /* of the clock since boot time */
177 Label sched; /* scheduler wakeup */
178 Lock alarmlock; /* access to alarm list */
179 void* alarm; /* alarms bound to this clock */
182 Proc* readied; /* for runproc */
183 ulong schedticks; /* next forced context switch */
196 uvlong fastclock; /* last sampled value */
197 uvlong inidle; /* time spent in idlehands() */
201 Perf perf; /* performance counters */
203 int probing; /* probeaddr() state */
209 uvlong cpuhz; /* speed of cpu */
210 uvlong cyclefreq; /* Frequency of user readable cycle counter */
218 ulong fpscr; /* sw copy */
219 int fppid; /* pid of last fault */
220 uintptr fppc; /* addr of last fault */
221 int fpcnt; /* how many consecutive at that addr */
223 /* save areas for exceptions, hold R0-R4 */
228 u32int smon[5]; /* probably not needed */
238 #define VA(k) ((uintptr)(k))
239 #define kmap(p) (KMap*)((p)->pa|kseg0)
245 char machs[MAXMACH]; /* active CPUs */
246 int wfi; /* bitmap of CPUs in WFI state */
247 int stopped; /* bitmap of CPUs stopped */
248 int exiting; /* shutdown */
251 extern register Mach* m; /* R10 */
252 extern register Proc* up; /* R9 */
254 /* an object guaranteed to be in its own cache line */
255 typedef uchar Cacheline[CACHELINESZ];
262 extern Memcache cachel[]; /* arm arch v7 supports 1-7 */
263 extern ulong intrcount[MAXMACH];
264 extern int irqtooearly;
265 extern uintptr kseg0;
266 extern Isolated l1ptstable;
267 extern uchar *l2pages;
268 extern Mach* machaddr[MAXMACH];
269 extern ulong memsize;
270 extern int navailcpus;
271 extern int normalprint;
274 * a parsed plan9.ini line
291 #define MACHP(n) machaddr[n]
294 * Horrid. But the alternative is 'defined'.
297 #define DBGFLG (dbgflg[_DBGC_])
303 extern char dbgflg[256];
305 #define dbgprint print /* for now */
308 * hardware info about a device
317 ulong intnum; /* interrupt number */
318 char *type; /* card type, malloced */
319 int nports; /* Number of ports */
320 Devport *ports; /* The ports themselves */
323 /* characteristics of a given arm cache level */
325 uint waysh; /* shifts for set/way register */
330 uint level; /* 1 is nearest processor, 2 further away */
332 uint external; /* flag */
333 uint l1ip; /* l1 I policy */
335 uint nways; /* associativity */
337 uint linelen; /* bytes per cache line */
353 * characteristics of cache level, kept at low, fixed address (CACHECONF).
354 * all offsets are known to cache.v7.s.
357 uint l1waysh; /* shifts for set/way register */
364 * cache capabilities. write-back vs write-through is controlled
365 * by the Buffered bit in PTEs.
367 * see cache.v7.s and Memcache in dat.h
376 /* non-architectural L2 cache */
377 typedef struct Cacheimpl Cacheimpl;
379 void (*info)(Memcache *);
387 void (*invse)(void *, int);
388 void (*wbse)(void *, int);
389 void (*wbinvse)(void *, int);
391 /* extern */ Cacheimpl *l2cache, *allcache, *nocache, *l1cache;
400 /* pmu = power management unit */
403 * 1st 32 gic irqs reserved for cpu; private interrupts.
404 * 0—15 are software-generated by other cpus;
405 * 16—31 are private peripheral intrs.
415 /* shared interrupts */
416 Ctlr0base = (1+0)*32, /* primary ctlr */
417 Tn0irq = Ctlr0base + 0, /* tegra timers */
418 Tn1irq = Ctlr0base + 1,
419 Rtcirq = Ctlr0base + 2,
421 Ctlr1base = (1+1)*32, /* secondary ctlr */
422 Uartirq = Ctlr1base + 4,
423 Tn2irq = Ctlr1base + 9, /* tegra timers */
424 Tn3irq = Ctlr1base + 10,
425 /* +24 is cpu0_pmu_intr, +25 is cpu1_pum_intr */
427 Ctlr2base = (1+2)*32, /* ternary ctlr */
428 Extpmuirq = Ctlr2base + 22,
430 Ctlr3base = (1+3)*32, /* quad ctlr */
431 Pcieirq = Ctlr3base + 2,
434 struct Soc { /* addr's of SoC controllers */
442 /* private memory region */
444 uintptr intr; /* `cpu interface' */
445 /* private-peripheral-interrupt cortex-a clocks */
453 /* shared-peripheral-interrupt tegra2 clocks */
454 uintptr rtc; /* real-time clock */