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