]> git.lizzy.rs Git - plan9front.git/blob - sys/src/9/kw/dat.h
devusb: fix format print warnings for ep->ntds and ep->uframes
[plan9front.git] / sys / src / 9 / kw / dat.h
1 typedef struct Conf     Conf;
2 typedef struct Confmem  Confmem;
3 typedef struct FPsave   FPsave;
4 typedef struct PFPU     PFPU;
5 typedef struct ISAConf  ISAConf;
6 typedef struct Label    Label;
7 typedef struct Lock     Lock;
8 typedef struct Memcache Memcache;
9 typedef struct MMMU     MMMU;
10 typedef struct Mach     Mach;
11 typedef struct Page     Page;
12 typedef struct Pcidev   Pcidev;
13 typedef struct PhysUart PhysUart;
14 typedef struct PMMU     PMMU;
15 typedef struct Proc     Proc;
16 typedef u32int          PTE;
17 typedef struct Soc      Soc;
18 typedef struct Uart     Uart;
19 typedef struct Ureg     Ureg;
20 typedef uvlong          Tval;
21
22 #pragma incomplete Pcidev
23 #pragma incomplete Ureg
24
25 #define MAXSYSARG       5       /* for mount(fd, mpt, flag, arg, srv) */
26
27 /*
28  *  parameters for sysproc.c
29  */
30 #define AOUT_MAGIC      (E_MAGIC)
31
32 struct Lock
33 {
34         ulong   key;
35         u32int  sr;
36         uintptr pc;
37         Proc*   p;
38         Mach*   m;
39         int     isilock;
40 };
41
42 struct Label
43 {
44         uintptr sp;
45         uintptr pc;
46 };
47
48 /*
49  * emulated floating point
50  */
51 enum{
52         Nfpctlregs = 16,
53 };
54
55 struct FPsave
56 {
57         ulong   status;
58         ulong   control;
59         ulong   regs[Nfpctlregs][3];
60
61         int     fpstate;
62 };
63
64 struct PFPU
65 {
66         int     fpstate;
67         FPsave  fpsave[1];
68 };
69
70 enum
71 {
72         FPinit,
73         FPactive,
74         FPinactive,
75 };
76
77 struct Confmem
78 {
79         uintptr base;
80         usize   npage;
81         uintptr limit;
82         uintptr kbase;
83         uintptr klimit;
84 };
85
86 struct Conf
87 {
88         ulong   nmach;          /* processors */
89         ulong   nproc;          /* processes */
90         ulong   monitor;        /* has monitor? */
91         Confmem mem[1];         /* physical memory */
92         ulong   npage;          /* total physical pages of memory */
93         usize   upages;         /* user page pool */
94         ulong   copymode;       /* 0 is copy on write, 1 is copy on reference */
95         ulong   ialloc;         /* max interrupt time allocation in bytes */
96         ulong   pipeqsize;      /* size in bytes of pipe queues */
97         ulong   nimage;         /* number of page cache image headers */
98         ulong   nswap;          /* number of swap pages */
99         int     nswppo;         /* max # of pageouts per segment pass */
100 //      ulong   hz;             /* processor cycle freq */
101 //      ulong   mhz;
102 };
103
104 /*
105  *  MMU stuff in Mach.
106  */
107 struct MMMU
108 {
109         PTE*    mmul1;          /* l1 for this processor */
110         int     mmul1lo;
111         int     mmul1hi;
112         int     mmupid;
113 };
114
115 /*
116  *  MMU stuff in proc
117  */
118 #define NCOLOR  1               /* 1 level cache, don't worry about VCE's */
119 struct PMMU
120 {
121         Page*   mmul2;
122         Page*   mmul2cache;     /* free mmu pages */
123 };
124
125 #include "../port/portdat.h"
126
127 struct Mach
128 {
129         int     machno;                 /* physical id of processor */
130         uintptr splpc;                  /* pc of last caller to splhi */
131
132         Proc*   proc;                   /* current process */
133
134         MMMU;
135         int     flushmmu;               /* flush current proc mmu state */
136
137         ulong   ticks;                  /* of the clock since boot time */
138         Label   sched;                  /* scheduler wakeup */
139         Lock    alarmlock;              /* access to alarm list */
140         void*   alarm;                  /* alarms bound to this clock */
141         int     inclockintr;
142
143         Proc*   readied;                /* for runproc */
144         ulong   schedticks;             /* next forced context switch */
145
146         int     cputype;
147         int     socrev;                 /* system-on-chip revision */
148         ulong   delayloop;
149
150         /* stats */
151         int     tlbfault;
152         int     tlbpurge;
153         int     pfault;
154         int     cs;
155         int     syscall;
156         int     load;
157         int     intr;
158         vlong   fastclock;              /* last sampled value */
159         uvlong  inidle;                 /* time spent in idlehands() */
160         ulong   spuriousintr;
161         int     lastintr;
162         int     ilockdepth;
163         Perf    perf;                   /* performance counters */
164
165 //      int     cpumhz;
166         uvlong  cpuhz;                  /* speed of cpu */
167         uvlong  cyclefreq;              /* Frequency of user readable cycle counter */
168
169         /* save areas for exceptions */
170         u32int  sfiq[5];
171         u32int  sirq[5];
172         u32int  sund[5];
173         u32int  sabt[5];
174 #define fiqstack sfiq
175 #define irqstack sirq
176 #define abtstack sabt
177 #define undstack sund
178
179         int     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 enum {
197         Frequency       = 1200*1000*1000,       /* the processor clock */
198 };
199
200 extern register Mach* m;                        /* R10 */
201 extern register Proc* up;                       /* R9 */
202
203 extern uintptr kseg0;
204 extern Mach* machaddr[MAXMACH];
205
206 enum {
207         Nvec = 8,       /* # of vectors at start of lexception.s */
208 };
209
210 /*
211  * Layout of physical 0.
212  */
213 typedef struct Vectorpage {
214         void    (*vectors[Nvec])(void);
215         uint    vtable[Nvec];
216 } Vectorpage;
217
218 /*
219  *  a parsed plan9.ini line
220  */
221 #define NISAOPT         8
222
223 struct ISAConf {
224         char            *type;
225         ulong   port;
226         int     irq;
227         ulong   dma;
228         ulong   mem;
229         ulong   size;
230         ulong   freq;
231
232         int     nopt;
233         char    *opt[NISAOPT];
234 };
235
236 #define MACHP(n)        (machaddr[n])
237
238 /*
239  * Horrid. But the alternative is 'defined'.
240  */
241 #ifdef _DBGC_
242 #define DBGFLG          (dbgflg[_DBGC_])
243 #else
244 #define DBGFLG          (0)
245 #endif /* _DBGC_ */
246
247 int vflag;
248 extern char dbgflg[256];
249
250 #define dbgprint        print           /* for now */
251
252 /*
253  *  hardware info about a device
254  */
255 typedef struct {
256         ulong   port;   
257         int     size;
258 } Devport;
259
260 struct DevConf
261 {
262         ulong   intnum;                 /* interrupt number */
263         char    *type;                  /* card type, malloced */
264         int     nports;                 /* Number of ports */
265         Devport *ports;                 /* The ports themselves */
266 };
267
268 enum {
269         Dcache,
270         Icache,
271         Unified,
272 };
273
274 /* characteristics of a given cache level */
275 struct Memcache {
276         uint    level;          /* 1 is nearest processor, 2 further away */
277         uint    kind;           /* I, D or unified */
278
279         uint    size;
280         uint    nways;          /* associativity */
281         uint    nsets;
282         uint    linelen;        /* bytes per cache line */
283         uint    setsways;
284
285         uint    log2linelen;
286         uint    waysh;          /* shifts for set/way register */
287         uint    setsh;
288 };
289
290 struct Soc {                    /* addr's of SoC controllers */
291         uintptr cpu;
292         uintptr devid;
293         uintptr l2cache;
294         uintptr sdramc;
295 //      uintptr sdramd;         /* unused */
296
297         uintptr iocfg;
298         uintptr addrmap;
299         uintptr intr;
300         uintptr nand;
301         uintptr cesa;           /* crypto accel. */
302         uintptr ehci;
303         uintptr spi;
304         uintptr twsi;
305
306         uintptr analog;
307         uintptr pci;
308         uintptr pcibase;
309
310         uintptr rtc;            /* real-time clock */
311         uintptr clock;
312
313         uintptr ether[2];
314         uintptr sata[3];
315         uintptr uart[2];
316         uintptr gpio[2];
317 } soc;
318 extern Soc soc;