]> git.lizzy.rs Git - plan9front.git/blob - sys/src/9/kw/dat.h
merge
[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         FPillegal= 0x100,
77 };
78
79 struct Confmem
80 {
81         uintptr base;
82         usize   npage;
83         uintptr limit;
84         uintptr kbase;
85         uintptr klimit;
86 };
87
88 struct Conf
89 {
90         ulong   nmach;          /* processors */
91         ulong   nproc;          /* processes */
92         ulong   monitor;        /* has monitor? */
93         Confmem mem[1];         /* physical memory */
94         ulong   npage;          /* total physical pages of memory */
95         usize   upages;         /* user page pool */
96         ulong   copymode;       /* 0 is copy on write, 1 is copy on reference */
97         ulong   ialloc;         /* max interrupt time allocation in bytes */
98         ulong   pipeqsize;      /* size in bytes of pipe queues */
99         ulong   nimage;         /* number of page cache image headers */
100         ulong   nswap;          /* number of swap pages */
101         int     nswppo;         /* max # of pageouts per segment pass */
102 //      ulong   hz;             /* processor cycle freq */
103 //      ulong   mhz;
104 };
105
106 /*
107  *  MMU stuff in Mach.
108  */
109 struct MMMU
110 {
111         PTE*    mmul1;          /* l1 for this processor */
112         int     mmul1lo;
113         int     mmul1hi;
114         int     mmupid;
115 };
116
117 /*
118  *  MMU stuff in proc
119  */
120 #define NCOLOR  1               /* 1 level cache, don't worry about VCE's */
121 struct PMMU
122 {
123         Page*   mmul2;
124         Page*   mmul2cache;     /* free mmu pages */
125 };
126
127 #include "../port/portdat.h"
128
129 struct Mach
130 {
131         int     machno;                 /* physical id of processor */
132         uintptr splpc;                  /* pc of last caller to splhi */
133
134         Proc*   proc;                   /* current process */
135
136         MMMU;
137         int     flushmmu;               /* flush current proc mmu state */
138
139         ulong   ticks;                  /* of the clock since boot time */
140         Label   sched;                  /* scheduler wakeup */
141         Lock    alarmlock;              /* access to alarm list */
142         void*   alarm;                  /* alarms bound to this clock */
143         int     inclockintr;
144
145         Proc*   readied;                /* for runproc */
146         ulong   schedticks;             /* next forced context switch */
147
148         int     cputype;
149         int     socrev;                 /* system-on-chip revision */
150         ulong   delayloop;
151
152         /* stats */
153         int     tlbfault;
154         int     tlbpurge;
155         int     pfault;
156         int     cs;
157         int     syscall;
158         int     load;
159         int     intr;
160         vlong   fastclock;              /* last sampled value */
161         uvlong  inidle;                 /* time spent in idlehands() */
162         ulong   spuriousintr;
163         int     lastintr;
164         int     ilockdepth;
165         Perf    perf;                   /* performance counters */
166
167 //      int     cpumhz;
168         uvlong  cpuhz;                  /* speed of cpu */
169         uvlong  cyclefreq;              /* Frequency of user readable cycle counter */
170
171         /* save areas for exceptions */
172         u32int  sfiq[5];
173         u32int  sirq[5];
174         u32int  sund[5];
175         u32int  sabt[5];
176 #define fiqstack sfiq
177 #define irqstack sirq
178 #define abtstack sabt
179 #define undstack sund
180
181         int     stack[1];
182 };
183
184 /*
185  * Fake kmap.
186  */
187 typedef void            KMap;
188 #define VA(k)           ((uintptr)(k))
189 #define kmap(p)         (KMap*)((p)->pa|kseg0)
190 #define kunmap(k)
191
192 struct
193 {
194         char    machs[MAXMACH];         /* active CPUs */
195         int     exiting;                /* shutdown */
196 }active;
197
198 enum {
199         Frequency       = 1200*1000*1000,       /* the processor clock */
200 };
201
202 extern register Mach* m;                        /* R10 */
203 extern register Proc* up;                       /* R9 */
204
205 extern uintptr kseg0;
206 extern Mach* machaddr[MAXMACH];
207
208 enum {
209         Nvec = 8,       /* # of vectors at start of lexception.s */
210 };
211
212 /*
213  * Layout of physical 0.
214  */
215 typedef struct Vectorpage {
216         void    (*vectors[Nvec])(void);
217         uint    vtable[Nvec];
218 } Vectorpage;
219
220 /*
221  *  a parsed plan9.ini line
222  */
223 #define NISAOPT         8
224
225 struct ISAConf {
226         char            *type;
227         ulong   port;
228         int     irq;
229         ulong   dma;
230         ulong   mem;
231         ulong   size;
232         ulong   freq;
233
234         int     nopt;
235         char    *opt[NISAOPT];
236 };
237
238 #define MACHP(n)        (machaddr[n])
239
240 /*
241  * Horrid. But the alternative is 'defined'.
242  */
243 #ifdef _DBGC_
244 #define DBGFLG          (dbgflg[_DBGC_])
245 #else
246 #define DBGFLG          (0)
247 #endif /* _DBGC_ */
248
249 int vflag;
250 extern char dbgflg[256];
251
252 #define dbgprint        print           /* for now */
253
254 /*
255  *  hardware info about a device
256  */
257 typedef struct {
258         ulong   port;   
259         int     size;
260 } Devport;
261
262 struct DevConf
263 {
264         ulong   intnum;                 /* interrupt number */
265         char    *type;                  /* card type, malloced */
266         int     nports;                 /* Number of ports */
267         Devport *ports;                 /* The ports themselves */
268 };
269
270 enum {
271         Dcache,
272         Icache,
273         Unified,
274 };
275
276 /* characteristics of a given cache level */
277 struct Memcache {
278         uint    level;          /* 1 is nearest processor, 2 further away */
279         uint    kind;           /* I, D or unified */
280
281         uint    size;
282         uint    nways;          /* associativity */
283         uint    nsets;
284         uint    linelen;        /* bytes per cache line */
285         uint    setsways;
286
287         uint    log2linelen;
288         uint    waysh;          /* shifts for set/way register */
289         uint    setsh;
290 };
291
292 struct Soc {                    /* addr's of SoC controllers */
293         uintptr cpu;
294         uintptr devid;
295         uintptr l2cache;
296         uintptr sdramc;
297 //      uintptr sdramd;         /* unused */
298
299         uintptr iocfg;
300         uintptr addrmap;
301         uintptr intr;
302         uintptr nand;
303         uintptr cesa;           /* crypto accel. */
304         uintptr ehci;
305         uintptr spi;
306         uintptr twsi;
307
308         uintptr analog;
309         uintptr pci;
310         uintptr pcibase;
311
312         uintptr rtc;            /* real-time clock */
313         uintptr clock;
314
315         uintptr ether[2];
316         uintptr sata[3];
317         uintptr uart[2];
318         uintptr gpio[2];
319 } soc;
320 extern Soc soc;