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