]> git.lizzy.rs Git - plan9front.git/blob - sys/src/9/omap/dat.h
kernel: page counts a ulong, not usize
[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         FPillegal= 0x100,
101 };
102
103 struct Confmem
104 {
105         uintptr base;
106         ulong   npage;
107         uintptr limit;
108         uintptr kbase;
109         uintptr klimit;
110 };
111
112 struct Conf
113 {
114         ulong   nmach;          /* processors */
115         ulong   nproc;          /* processes */
116         Confmem mem[1];         /* physical memory */
117         ulong   npage;          /* total physical pages of memory */
118         ulong   upages;         /* user page pool */
119         ulong   copymode;       /* 0 is copy on write, 1 is copy on reference */
120         ulong   ialloc;         /* max interrupt time allocation in bytes */
121         ulong   pipeqsize;      /* size in bytes of pipe queues */
122         ulong   nimage;         /* number of page cache image headers */
123         ulong   nswap;          /* number of swap pages */
124         int     nswppo;         /* max # of pageouts per segment pass */
125         ulong   hz;             /* processor cycle freq */
126         ulong   mhz;
127         int     monitor;        /* flag */
128 };
129
130 /*
131  *  MMU stuff in Mach.
132  */
133 struct MMMU
134 {
135         PTE*    mmul1;          /* l1 for this processor */
136         int     mmul1lo;
137         int     mmul1hi;
138         int     mmupid;
139 };
140
141 /*
142  *  MMU stuff in proc
143  */
144 #define NCOLOR  1               /* 1 level cache, don't worry about VCE's */
145 struct PMMU
146 {
147         Page*   mmul2;
148         Page*   mmul2cache;     /* free mmu pages */
149 };
150
151 #include "../port/portdat.h"
152
153 struct Mach
154 {
155         int     machno;                 /* physical id of processor */
156         uintptr splpc;                  /* pc of last caller to splhi */
157         Proc*   proc;                   /* current process */
158         MMMU;
159         /* end of offsets known to asm */
160
161         PMach;
162
163         uvlong  fastclock;              /* last sampled value */
164         int     inclockintr;
165
166         int     cputype;
167         ulong   delayloop;
168         int     cpumhz;
169         uvlong  cpuhz;                  /* speed of cpu */
170
171         /* save areas for exceptions, hold R0-R4 */
172         u32int  sfiq[5];
173         u32int  sirq[5];
174         u32int  sund[5];
175         u32int  sabt[5];
176         u32int  smon[5];                /* probably not needed */
177         u32int  ssys[5];
178
179         uintptr stack[1];
180 };
181
182 /*
183  * Fake kmap.
184  */
185 typedef void            KMap;
186 #define VA(k)           ((uintptr)(k))
187 #define kmap(p)         (KMap*)((p)->pa|kseg0)
188 #define kunmap(k)
189
190 struct
191 {
192         char    machs[MAXMACH];         /* active CPUs */
193         int     exiting;                /* shutdown */
194 }active;
195
196 extern register Mach* m;                        /* R10 */
197 extern register Proc* up;                       /* R9 */
198 extern uintptr kseg0;
199 extern Mach* machaddr[MAXMACH];
200 extern ulong memsize;
201 extern int normalprint;
202
203 /*
204  *  a parsed plan9.ini line
205  */
206 #define NISAOPT         8
207
208 struct ISAConf {
209         char    *type;
210         ulong   port;
211         int     irq;
212         ulong   dma;
213         ulong   mem;
214         ulong   size;
215         ulong   freq;
216
217         int     nopt;
218         char    *opt[NISAOPT];
219 };
220
221 #define BUSUNKNOWN -1
222
223 #define MACHP(n)        (machaddr[n])
224
225 /*
226  * Horrid. But the alternative is 'defined'.
227  */
228 #ifdef _DBGC_
229 #define DBGFLG          (dbgflg[_DBGC_])
230 #else
231 #define DBGFLG          (0)
232 #endif /* _DBGC_ */
233
234 int vflag;
235 extern char dbgflg[256];
236
237 #define dbgprint        print           /* for now */
238
239 /*
240  *  hardware info about a device
241  */
242 typedef struct {
243         ulong   port;
244         int     size;
245 } Devport;
246
247 struct DevConf
248 {
249         ulong   intnum;                 /* interrupt number */
250         char    *type;                  /* card type, malloced */
251         int     nports;                 /* Number of ports */
252         Devport *ports;                 /* The ports themselves */
253 };
254
255 enum {
256         Dcache,
257         Icache,
258         Unified,
259 };
260
261 /* characteristics of a given cache level */
262 struct Memcache {
263         uint    level;          /* 1 is nearest processor, 2 further away */
264         uint    l1ip;           /* l1 I policy */
265
266         uint    nways;          /* associativity */
267         uint    nsets;
268         uint    linelen;        /* bytes per cache line */
269         uint    setsways;
270
271         uint    log2linelen;
272         uint    waysh;          /* shifts for set/way register */
273         uint    setsh;
274 };
275
276 enum Dmamode {
277         Const,
278         Postincr,
279         Index,
280         Index2,
281 };