]> git.lizzy.rs Git - plan9front.git/blob - sys/src/9/bcm/dat.h
kernel: page counts a ulong, not usize
[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         ulong   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         ulong   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         Proc*   proc;                   /* current process on this processor */
154
155         MMMU;
156         /* end of offsets known to asm */
157
158         PMach;
159
160         int     cputype;
161         ulong   delayloop;
162         int     cpumhz;
163         uvlong  cpuhz;                  /* speed of cpu */
164
165         /* vfp2 or vfp3 fpu */
166         int     havefp;
167         int     havefpvalid;
168         int     fpon;
169         int     fpconfiged;
170         int     fpnregs;
171         ulong   fpscr;                  /* sw copy */
172         int     fppid;                  /* pid of last fault */
173         uintptr fppc;                   /* addr of last fault */
174         int     fpcnt;                  /* how many consecutive at that addr */
175
176         /* save areas for exceptions, hold R0-R4 */
177         u32int  sfiq[5];
178         u32int  sirq[5];
179         u32int  sund[5];
180         u32int  sabt[5];
181         u32int  smon[5];                /* probably not needed */
182         u32int  ssys[5];
183
184         uintptr stack[1];
185 };
186
187 /*
188  * Fake kmap.
189  */
190 typedef void            KMap;
191 #define VA(k)           ((uintptr)(k))
192 #define kmap(p)         (KMap*)((p)->pa|kseg0)
193 extern void kunmap(KMap*);
194
195 struct
196 {
197         char    machs[MAXMACH];         /* active CPUs */
198         int     exiting;                /* shutdown */
199 }active;
200
201 extern register Mach* m;                        /* R10 */
202 extern register Proc* up;                       /* R9 */
203 extern uintptr kseg0;
204 extern Mach* machaddr[MAXMACH];
205 extern int normalprint;
206
207 /*
208  *  a parsed plan9.ini line
209  */
210 #define NISAOPT         8
211
212 struct ISAConf {
213         char    *type;
214         ulong   port;
215         int     irq;
216         ulong   dma;
217         ulong   mem;
218         ulong   size;
219         ulong   freq;
220
221         int     nopt;
222         char    *opt[NISAOPT];
223 };
224
225 #define MACHP(n)        (machaddr[n])
226
227 /*
228  * Horrid. But the alternative is 'defined'.
229  */
230 #ifdef _DBGC_
231 #define DBGFLG          (dbgflg[_DBGC_])
232 #else
233 #define DBGFLG          (0)
234 #endif /* _DBGC_ */
235
236 int vflag;
237 extern char dbgflg[256];
238
239 #define dbgprint        print           /* for now */
240
241 /*
242  *  hardware info about a device
243  */
244 typedef struct {
245         ulong   port;
246         int     size;
247 } Devport;
248
249 struct DevConf
250 {
251         ulong   intnum;                 /* interrupt number */
252         char    *type;                  /* card type, malloced */
253         int     nports;                 /* Number of ports */
254         Devport *ports;                 /* The ports themselves */
255 };
256
257 struct Soc {                    /* SoC dependent configuration */
258         ulong   dramsize;
259         ulong   iosize;
260         uintptr busdram;
261         uintptr busio;
262         uintptr physio;
263         uintptr virtio;
264         uintptr armlocal;
265         u32int  l1ptedramattrs;
266         u32int  l2ptedramattrs;
267 };
268 extern Soc soc;
269
270 /*
271  * GPIO
272  */
273 enum {
274         Input   = 0x0,
275         Output  = 0x1,
276         Alt0    = 0x4,
277         Alt1    = 0x5,
278         Alt2    = 0x6,
279         Alt3    = 0x7,
280         Alt4    = 0x3,
281         Alt5    = 0x2,
282 };