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 int machno; /* physical id of processor */
167 uintptr splpc; /* pc of last caller to splhi */
168 Proc* proc; /* current process on this processor */
171 /* end of offsets known to asm */
175 uvlong fastclock; /* last sampled value */
179 int probing; /* probeaddr() state */
186 uvlong cpuhz; /* speed of cpu */
194 ulong fpscr; /* sw copy */
195 int fppid; /* pid of last fault */
196 uintptr fppc; /* addr of last fault */
197 int fpcnt; /* how many consecutive at that addr */
199 /* save areas for exceptions, hold R0-R4 */
204 u32int smon[5]; /* probably not needed */
214 #define VA(k) ((uintptr)(k))
215 #define kmap(p) (KMap*)((p)->pa|kseg0)
221 char machs[MAXMACH]; /* active CPUs */
222 int wfi; /* bitmap of CPUs in WFI state */
223 int stopped; /* bitmap of CPUs stopped */
224 int exiting; /* shutdown */
227 extern register Mach* m; /* R10 */
228 extern register Proc* up; /* R9 */
230 /* an object guaranteed to be in its own cache line */
231 typedef uchar Cacheline[CACHELINESZ];
238 extern Memcache cachel[]; /* arm arch v7 supports 1-7 */
239 extern ulong intrcount[MAXMACH];
240 extern int irqtooearly;
241 extern uintptr kseg0;
242 extern Isolated l1ptstable;
243 extern uchar *l2pages;
244 extern Mach* machaddr[MAXMACH];
245 extern ulong memsize;
246 extern int navailcpus;
247 extern int normalprint;
250 * a parsed plan9.ini line
267 #define MACHP(n) machaddr[n]
270 * Horrid. But the alternative is 'defined'.
273 #define DBGFLG (dbgflg[_DBGC_])
279 extern char dbgflg[256];
281 #define dbgprint print /* for now */
284 * hardware info about a device
293 ulong intnum; /* interrupt number */
294 char *type; /* card type, malloced */
295 int nports; /* Number of ports */
296 Devport *ports; /* The ports themselves */
299 /* characteristics of a given arm cache level */
301 uint waysh; /* shifts for set/way register */
306 uint level; /* 1 is nearest processor, 2 further away */
308 uint external; /* flag */
309 uint l1ip; /* l1 I policy */
311 uint nways; /* associativity */
313 uint linelen; /* bytes per cache line */
329 * characteristics of cache level, kept at low, fixed address (CACHECONF).
330 * all offsets are known to cache.v7.s.
333 uint l1waysh; /* shifts for set/way register */
340 * cache capabilities. write-back vs write-through is controlled
341 * by the Buffered bit in PTEs.
343 * see cache.v7.s and Memcache in dat.h
352 /* non-architectural L2 cache */
353 typedef struct Cacheimpl Cacheimpl;
355 void (*info)(Memcache *);
363 void (*invse)(void *, int);
364 void (*wbse)(void *, int);
365 void (*wbinvse)(void *, int);
367 /* extern */ Cacheimpl *l2cache, *allcache, *nocache, *l1cache;
376 /* pmu = power management unit */
379 * 1st 32 gic irqs reserved for cpu; private interrupts.
380 * 0—15 are software-generated by other cpus;
381 * 16—31 are private peripheral intrs.
391 /* shared interrupts */
392 Ctlr0base = (1+0)*32, /* primary ctlr */
393 Tn0irq = Ctlr0base + 0, /* tegra timers */
394 Tn1irq = Ctlr0base + 1,
395 Rtcirq = Ctlr0base + 2,
397 Ctlr1base = (1+1)*32, /* secondary ctlr */
398 Uartirq = Ctlr1base + 4,
399 Tn2irq = Ctlr1base + 9, /* tegra timers */
400 Tn3irq = Ctlr1base + 10,
401 /* +24 is cpu0_pmu_intr, +25 is cpu1_pum_intr */
403 Ctlr2base = (1+2)*32, /* ternary ctlr */
404 Extpmuirq = Ctlr2base + 22,
406 Ctlr3base = (1+3)*32, /* quad ctlr */
407 Pcieirq = Ctlr3base + 2,
410 struct Soc { /* addr's of SoC controllers */
418 /* private memory region */
420 uintptr intr; /* `cpu interface' */
421 /* private-peripheral-interrupt cortex-a clocks */
429 /* shared-peripheral-interrupt tegra2 clocks */
430 uintptr rtc; /* real-time clock */