]> git.lizzy.rs Git - plan9front.git/blob - sys/src/9/omap/dat.h
kernel: remove Ipifc.mbps, unused.
[plan9front.git] / sys / src / 9 / omap / 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 /*
16  * More accurate time
17  */
18 #define MS2TMR(t)       ((ulong)(((uvlong)(t) * m->cpuhz)/1000))
19 #define US2TMR(t)       ((ulong)(((uvlong)(t) * m->cpuhz)/1000000))
20
21 /*
22  * we ignore the first 2 uarts on the omap3530 (see uarti8250.c) and use the
23  * third one but call it 0.
24  */
25 #define CONSOLE 0
26
27 typedef struct Conf     Conf;
28 typedef struct Confmem  Confmem;
29 typedef struct FPsave   FPsave;
30 typedef struct PFPU     PFPU;
31 typedef struct ISAConf  ISAConf;
32 typedef struct Label    Label;
33 typedef struct Lock     Lock;
34 typedef struct Memcache Memcache;
35 typedef struct MMMU     MMMU;
36 typedef struct Mach     Mach;
37 typedef u32int Mreg;                            /* Msr - bloody UART */
38 typedef struct Page     Page;
39 typedef struct PhysUart PhysUart;
40 typedef struct PMMU     PMMU;
41 typedef struct Proc     Proc;
42 typedef u32int          PTE;
43 typedef struct Uart     Uart;
44 typedef struct Ureg     Ureg;
45 typedef uvlong          Tval;
46
47 #pragma incomplete Ureg
48
49 #define MAXSYSARG       5       /* for mount(fd, mpt, flag, arg, srv) */
50
51 /*
52  *  parameters for sysproc.c
53  */
54 #define AOUT_MAGIC      (E_MAGIC)
55
56 struct Lock
57 {
58         ulong   key;
59         u32int  sr;
60         uintptr pc;
61         Proc*   p;
62         Mach*   m;
63         int     isilock;
64 };
65
66 struct Label
67 {
68         uintptr sp;
69         uintptr pc;
70 };
71
72 /*
73  * emulated floating point
74  */
75 enum{
76         Nfpctlregs = 16,
77 };
78
79 struct FPsave
80 {
81         ulong   status;
82         ulong   control;
83         ulong   regs[Nfpctlregs][3];
84
85         int     fpstate;
86 };
87
88 struct PFPU
89 {
90         int     fpstate;
91         FPsave  fpsave[1];
92 };
93
94 enum
95 {
96         FPinit,
97         FPactive,
98         FPinactive,
99 };
100
101 struct Confmem
102 {
103         uintptr base;
104         usize   npage;
105         uintptr limit;
106         uintptr kbase;
107         uintptr klimit;
108 };
109
110 struct Conf
111 {
112         ulong   nmach;          /* processors */
113         ulong   nproc;          /* processes */
114         Confmem mem[1];         /* physical memory */
115         ulong   npage;          /* total physical pages of memory */
116         usize   upages;         /* user page pool */
117         ulong   copymode;       /* 0 is copy on write, 1 is copy on reference */
118         ulong   ialloc;         /* max interrupt time allocation in bytes */
119         ulong   pipeqsize;      /* size in bytes of pipe queues */
120         ulong   nimage;         /* number of page cache image headers */
121         ulong   nswap;          /* number of swap pages */
122         int     nswppo;         /* max # of pageouts per segment pass */
123         ulong   hz;             /* processor cycle freq */
124         ulong   mhz;
125         int     monitor;        /* flag */
126 };
127
128 /*
129  *  MMU stuff in Mach.
130  */
131 struct MMMU
132 {
133         PTE*    mmul1;          /* l1 for this processor */
134         int     mmul1lo;
135         int     mmul1hi;
136         int     mmupid;
137 };
138
139 /*
140  *  MMU stuff in proc
141  */
142 #define NCOLOR  1               /* 1 level cache, don't worry about VCE's */
143 struct PMMU
144 {
145         Page*   mmul2;
146         Page*   mmul2cache;     /* free mmu pages */
147 };
148
149 #include "../port/portdat.h"
150
151 struct Mach
152 {
153         int     machno;                 /* physical id of processor */
154         uintptr splpc;                  /* pc of last caller to splhi */
155
156         Proc*   proc;                   /* current process */
157
158         MMMU;
159         int     flushmmu;               /* flush current proc mmu state */
160
161         ulong   ticks;                  /* of the clock since boot time */
162         Label   sched;                  /* scheduler wakeup */
163         Lock    alarmlock;              /* access to alarm list */
164         void*   alarm;                  /* alarms bound to this clock */
165         int     inclockintr;
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         /* save areas for exceptions, hold R0-R4 */
194         u32int  sfiq[5];
195         u32int  sirq[5];
196         u32int  sund[5];
197         u32int  sabt[5];
198         u32int  smon[5];                /* probably not needed */
199         u32int  ssys[5];
200
201         int     stack[1];
202 };
203
204 /*
205  * Fake kmap.
206  */
207 typedef void            KMap;
208 #define VA(k)           ((uintptr)(k))
209 #define kmap(p)         (KMap*)((p)->pa|kseg0)
210 #define kunmap(k)
211
212 struct
213 {
214         char    machs[MAXMACH];         /* active CPUs */
215         int     exiting;                /* shutdown */
216 }active;
217
218 extern register Mach* m;                        /* R10 */
219 extern register Proc* up;                       /* R9 */
220 extern uintptr kseg0;
221 extern Mach* machaddr[MAXMACH];
222 extern ulong memsize;
223 extern int normalprint;
224
225 /*
226  *  a parsed plan9.ini line
227  */
228 #define NISAOPT         8
229
230 struct ISAConf {
231         char    *type;
232         ulong   port;
233         int     irq;
234         ulong   dma;
235         ulong   mem;
236         ulong   size;
237         ulong   freq;
238
239         int     nopt;
240         char    *opt[NISAOPT];
241 };
242
243 #define MACHP(n)        (machaddr[n])
244
245 /*
246  * Horrid. But the alternative is 'defined'.
247  */
248 #ifdef _DBGC_
249 #define DBGFLG          (dbgflg[_DBGC_])
250 #else
251 #define DBGFLG          (0)
252 #endif /* _DBGC_ */
253
254 int vflag;
255 extern char dbgflg[256];
256
257 #define dbgprint        print           /* for now */
258
259 /*
260  *  hardware info about a device
261  */
262 typedef struct {
263         ulong   port;
264         int     size;
265 } Devport;
266
267 struct DevConf
268 {
269         ulong   intnum;                 /* interrupt number */
270         char    *type;                  /* card type, malloced */
271         int     nports;                 /* Number of ports */
272         Devport *ports;                 /* The ports themselves */
273 };
274
275 enum {
276         Dcache,
277         Icache,
278         Unified,
279 };
280
281 /* characteristics of a given cache level */
282 struct Memcache {
283         uint    level;          /* 1 is nearest processor, 2 further away */
284         uint    l1ip;           /* l1 I policy */
285
286         uint    nways;          /* associativity */
287         uint    nsets;
288         uint    linelen;        /* bytes per cache line */
289         uint    setsways;
290
291         uint    log2linelen;
292         uint    waysh;          /* shifts for set/way register */
293         uint    setsh;
294 };
295
296 enum Dmamode {
297         Const,
298         Postincr,
299         Index,
300         Index2,
301 };