]> git.lizzy.rs Git - plan9front.git/blob - sys/src/9/omap/dat.h
merge
[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 ISAConf  ISAConf;
31 typedef struct Label    Label;
32 typedef struct Lock     Lock;
33 typedef struct Memcache Memcache;
34 typedef struct MMMU     MMMU;
35 typedef struct Mach     Mach;
36 typedef u32int Mreg;                            /* Msr - bloody UART */
37 typedef struct Notsave  Notsave;
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 enum{
73         Nfpctlregs = 16,
74 };
75
76 /*
77  * emulated floating point
78  */
79 struct FPsave
80 {
81         ulong   status;
82         ulong   control;
83         ulong   regs[Nfpctlregs][3];
84
85         int     fpstate;
86 };
87
88 /*
89  * FPsave.status
90  */
91 enum
92 {
93         FPinit,
94         FPactive,
95         FPinactive,
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  *  things saved in the Proc structure during a notify
127  */
128 struct Notsave {
129         int     emptiness;
130 };
131
132 /*
133  *  MMU stuff in Mach.
134  */
135 struct MMMU
136 {
137         PTE*    mmul1;          /* l1 for this processor */
138         int     mmul1lo;
139         int     mmul1hi;
140         int     mmupid;
141 };
142
143 /*
144  *  MMU stuff in proc
145  */
146 #define NCOLOR  1               /* 1 level cache, don't worry about VCE's */
147 struct PMMU
148 {
149         Page*   mmul2;
150         Page*   mmul2cache;     /* free mmu pages */
151 };
152
153 #include "../port/portdat.h"
154
155 struct Mach
156 {
157         int     machno;                 /* physical id of processor */
158         uintptr splpc;                  /* pc of last caller to splhi */
159
160         Proc*   proc;                   /* current process */
161
162         MMMU;
163         int     flushmmu;               /* flush current proc mmu state */
164
165         ulong   ticks;                  /* of the clock since boot time */
166         Label   sched;                  /* scheduler wakeup */
167         Lock    alarmlock;              /* access to alarm list */
168         void*   alarm;                  /* alarms bound to this clock */
169         int     inclockintr;
170
171         Proc*   readied;                /* for runproc */
172         ulong   schedticks;             /* next forced context switch */
173
174         int     cputype;
175         ulong   delayloop;
176
177         /* stats */
178         int     tlbfault;
179         int     tlbpurge;
180         int     pfault;
181         int     cs;
182         int     syscall;
183         int     load;
184         int     intr;
185         uvlong  fastclock;              /* last sampled value */
186         uvlong  inidle;                 /* time spent in idlehands() */
187         ulong   spuriousintr;
188         int     lastintr;
189         int     ilockdepth;
190         Perf    perf;                   /* performance counters */
191
192
193         int     cpumhz;
194         uvlong  cpuhz;                  /* speed of cpu */
195         uvlong  cyclefreq;              /* Frequency of user readable cycle counter */
196
197         /* save areas for exceptions, hold R0-R4 */
198         u32int  sfiq[5];
199         u32int  sirq[5];
200         u32int  sund[5];
201         u32int  sabt[5];
202         u32int  smon[5];                /* probably not needed */
203         u32int  ssys[5];
204
205         int     stack[1];
206 };
207
208 /*
209  * Fake kmap.
210  */
211 typedef void            KMap;
212 #define VA(k)           ((uintptr)(k))
213 #define kmap(p)         (KMap*)((p)->pa|kseg0)
214 #define kunmap(k)
215
216 struct
217 {
218         Lock;
219         int     machs;                  /* bitmap of active CPUs */
220         int     exiting;                /* shutdown */
221         int     ispanic;                /* shutdown in response to a panic */
222 }active;
223
224 extern register Mach* m;                        /* R10 */
225 extern register Proc* up;                       /* R9 */
226 extern uintptr kseg0;
227 extern Mach* machaddr[MAXMACH];
228 extern ulong memsize;
229 extern int normalprint;
230
231 /*
232  *  a parsed plan9.ini line
233  */
234 #define NISAOPT         8
235
236 struct ISAConf {
237         char    *type;
238         ulong   port;
239         int     irq;
240         ulong   dma;
241         ulong   mem;
242         ulong   size;
243         ulong   freq;
244
245         int     nopt;
246         char    *opt[NISAOPT];
247 };
248
249 #define MACHP(n)        (machaddr[n])
250
251 /*
252  * Horrid. But the alternative is 'defined'.
253  */
254 #ifdef _DBGC_
255 #define DBGFLG          (dbgflg[_DBGC_])
256 #else
257 #define DBGFLG          (0)
258 #endif /* _DBGC_ */
259
260 int vflag;
261 extern char dbgflg[256];
262
263 #define dbgprint        print           /* for now */
264
265 /*
266  *  hardware info about a device
267  */
268 typedef struct {
269         ulong   port;
270         int     size;
271 } Devport;
272
273 struct DevConf
274 {
275         ulong   intnum;                 /* interrupt number */
276         char    *type;                  /* card type, malloced */
277         int     nports;                 /* Number of ports */
278         Devport *ports;                 /* The ports themselves */
279 };
280
281 enum {
282         Dcache,
283         Icache,
284         Unified,
285 };
286
287 /* characteristics of a given cache level */
288 struct Memcache {
289         uint    level;          /* 1 is nearest processor, 2 further away */
290         uint    l1ip;           /* l1 I policy */
291
292         uint    nways;          /* associativity */
293         uint    nsets;
294         uint    linelen;        /* bytes per cache line */
295         uint    setsways;
296
297         uint    log2linelen;
298         uint    waysh;          /* shifts for set/way register */
299         uint    setsh;
300 };
301
302 enum Dmamode {
303         Const,
304         Postincr,
305         Index,
306         Index2,
307 };