]> git.lizzy.rs Git - plan9front.git/blob - sys/src/9/bcm/dat.h
merge
[plan9front.git] / sys / src / 9 / bcm / dat.h
1 /*
2  * Time.
3  *
4  * HZ should divide 1000 evenly, ideally.
5  * 100, 125, 200, 250 and 333 are okay.
6  */
7 #define HZ              100                     /* clock frequency */
8 #define MS2HZ           (1000/HZ)               /* millisec per clock tick */
9 #define TK2SEC(t)       ((t)/HZ)                /* ticks to seconds */
10
11 enum {
12         Mhz     = 1000 * 1000,
13 };
14
15 typedef struct Conf     Conf;
16 typedef struct Confmem  Confmem;
17 typedef struct FPsave   FPsave;
18 typedef struct PFPU     PFPU;
19 typedef struct ISAConf  ISAConf;
20 typedef struct Label    Label;
21 typedef struct Lock     Lock;
22 typedef struct Memcache Memcache;
23 typedef struct MMMU     MMMU;
24 typedef struct Mach     Mach;
25 typedef struct Page     Page;
26 typedef struct PhysUart PhysUart;
27 typedef struct PMMU     PMMU;
28 typedef struct Proc     Proc;
29 typedef u32int          PTE;
30 typedef struct Soc      Soc;
31 typedef struct Uart     Uart;
32 typedef struct Ureg     Ureg;
33 typedef uvlong          Tval;
34
35 #pragma incomplete Ureg
36
37 #define MAXSYSARG       5       /* for mount(fd, mpt, flag, arg, srv) */
38
39 /*
40  *  parameters for sysproc.c
41  */
42 #define AOUT_MAGIC      (E_MAGIC)
43
44 struct Lock
45 {
46         ulong   key;
47         u32int  sr;
48         uintptr pc;
49         Proc*   p;
50         Mach*   m;
51         int     isilock;
52 };
53
54 struct Label
55 {
56         uintptr sp;
57         uintptr pc;
58 };
59
60 /*
61  * emulated or vfp3 floating point
62  */
63 enum {
64         Maxfpregs       = 32,   /* could be 16 or 32, see Mach.fpnregs */
65         Nfpctlregs      = 16,
66 };
67
68 struct FPsave
69 {
70         ulong   status;
71         ulong   control;
72         /*
73          * vfp3 with ieee fp regs; uvlong is sufficient for hardware but
74          * each must be able to hold an Internal from fpi.h for sw emulation.
75          */
76         ulong   regs[Maxfpregs][3];
77
78         int     fpstate;
79         uintptr pc;             /* of failed fp instr. */
80 };
81
82 struct PFPU
83 {
84         int     fpstate;
85         FPsave  fpsave[1];
86 };
87
88 enum
89 {
90         FPinit,
91         FPactive,
92         FPinactive,
93         FPemu,
94
95         /* bits or'd with the state */
96         FPillegal= 0x100,
97 };
98
99 struct Confmem
100 {
101         uintptr base;
102         usize   npage;
103         uintptr limit;
104         uintptr kbase;
105         uintptr klimit;
106 };
107
108 struct Conf
109 {
110         ulong   nmach;          /* processors */
111         ulong   nproc;          /* processes */
112         Confmem mem[1];         /* physical memory */
113         ulong   npage;          /* total physical pages of memory */
114         usize   upages;         /* user page pool */
115         ulong   copymode;       /* 0 is copy on write, 1 is copy on reference */
116         ulong   ialloc;         /* max interrupt time allocation in bytes */
117         ulong   pipeqsize;      /* size in bytes of pipe queues */
118         ulong   nimage;         /* number of page cache image headers */
119         ulong   nswap;          /* number of swap pages */
120         int     nswppo;         /* max # of pageouts per segment pass */
121         ulong   hz;             /* processor cycle freq */
122         ulong   mhz;
123         int     monitor;        /* flag */
124 };
125
126 /*
127  *  MMU stuff in Mach.
128  */
129 struct MMMU
130 {
131         PTE*    mmul1;          /* l1 for this processor */
132         int     mmul1lo;
133         int     mmul1hi;
134         int     mmupid;
135 };
136
137 /*
138  *  MMU stuff in proc
139  */
140 #define NCOLOR  1               /* 1 level cache, don't worry about VCE's */
141 struct PMMU
142 {
143         Page*   mmul2;
144         Page*   mmul2cache;     /* free mmu pages */
145 };
146
147 #include "../port/portdat.h"
148
149 struct Mach
150 {
151         int     machno;                 /* physical id of processor */
152         uintptr splpc;                  /* pc of last caller to splhi */
153
154         Proc*   proc;                   /* current process */
155
156         MMMU;
157         int     flushmmu;               /* flush current proc mmu state */
158
159         ulong   ticks;                  /* of the clock since boot time */
160         Label   sched;                  /* scheduler wakeup */
161         Lock    alarmlock;              /* access to alarm list */
162         void*   alarm;                  /* alarms bound to this clock */
163
164         Proc*   readied;                /* for runproc */
165         ulong   schedticks;             /* next forced context switch */
166
167         int     cputype;
168         ulong   delayloop;
169
170         /* stats */
171         int     tlbfault;
172         int     tlbpurge;
173         int     pfault;
174         int     cs;
175         int     syscall;
176         int     load;
177         int     intr;
178         uvlong  fastclock;              /* last sampled value */
179         uvlong  inidle;                 /* time spent in idlehands() */
180         ulong   spuriousintr;
181         int     lastintr;
182         int     ilockdepth;
183         Perf    perf;                   /* performance counters */
184
185
186         int     cpumhz;
187         uvlong  cpuhz;                  /* speed of cpu */
188         uvlong  cyclefreq;              /* Frequency of user readable cycle counter */
189
190         /* vfp2 or vfp3 fpu */
191         int     havefp;
192         int     havefpvalid;
193         int     fpon;
194         int     fpconfiged;
195         int     fpnregs;
196         ulong   fpscr;                  /* sw copy */
197         int     fppid;                  /* pid of last fault */
198         uintptr fppc;                   /* addr of last fault */
199         int     fpcnt;                  /* how many consecutive at that addr */
200
201         /* save areas for exceptions, hold R0-R4 */
202         u32int  sfiq[5];
203         u32int  sirq[5];
204         u32int  sund[5];
205         u32int  sabt[5];
206         u32int  smon[5];                /* probably not needed */
207         u32int  ssys[5];
208
209         int     stack[1];
210 };
211
212 /*
213  * Fake kmap.
214  */
215 typedef void            KMap;
216 #define VA(k)           ((uintptr)(k))
217 #define kmap(p)         (KMap*)((p)->pa|kseg0)
218 extern void kunmap(KMap*);
219
220 struct
221 {
222         char    machs[MAXMACH];         /* active CPUs */
223         int     exiting;                /* shutdown */
224 }active;
225
226 extern register Mach* m;                        /* R10 */
227 extern register Proc* up;                       /* R9 */
228 extern uintptr kseg0;
229 extern Mach* machaddr[MAXMACH];
230 extern ulong memsize;
231 extern int normalprint;
232
233 /*
234  *  a parsed plan9.ini line
235  */
236 #define NISAOPT         8
237
238 struct ISAConf {
239         char    *type;
240         ulong   port;
241         int     irq;
242         ulong   dma;
243         ulong   mem;
244         ulong   size;
245         ulong   freq;
246
247         int     nopt;
248         char    *opt[NISAOPT];
249 };
250
251 #define MACHP(n)        (machaddr[n])
252
253 /*
254  * Horrid. But the alternative is 'defined'.
255  */
256 #ifdef _DBGC_
257 #define DBGFLG          (dbgflg[_DBGC_])
258 #else
259 #define DBGFLG          (0)
260 #endif /* _DBGC_ */
261
262 int vflag;
263 extern char dbgflg[256];
264
265 #define dbgprint        print           /* for now */
266
267 /*
268  *  hardware info about a device
269  */
270 typedef struct {
271         ulong   port;
272         int     size;
273 } Devport;
274
275 struct DevConf
276 {
277         ulong   intnum;                 /* interrupt number */
278         char    *type;                  /* card type, malloced */
279         int     nports;                 /* Number of ports */
280         Devport *ports;                 /* The ports themselves */
281 };
282
283 struct Soc {                    /* SoC dependent configuration */
284         ulong   dramsize;
285         uintptr physio;
286         uintptr busdram;
287         uintptr busio;
288         uintptr armlocal;
289         u32int  l1ptedramattrs;
290         u32int  l2ptedramattrs;
291 };
292 extern Soc soc;
293
294 #define BUSUNKNOWN -1
295
296 /*
297  * GPIO
298  */
299 enum {
300         Input   = 0x0,
301         Output  = 0x1,
302         Alt0    = 0x4,
303         Alt1    = 0x5,
304         Alt2    = 0x6,
305         Alt3    = 0x7,
306         Alt4    = 0x3,
307         Alt5    = 0x2,
308 };