]> git.lizzy.rs Git - plan9front.git/blob - sys/src/9/kw/dat.h
kernel: page counts a ulong, not usize
[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         ulong   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         ulong   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         Proc*   proc;                   /* current process */
134         MMMU;
135         /* end of offsets known to asm */
136
137         PMach;
138
139         vlong   fastclock;              /* last sampled value */
140         int     inclockintr;
141
142         int     cputype;
143         int     socrev;                 /* system-on-chip revision */
144         ulong   delayloop;
145         uvlong  cpuhz;                  /* speed of cpu */
146
147         /* save areas for exceptions */
148         u32int  sfiq[5];
149         u32int  sirq[5];
150         u32int  sund[5];
151         u32int  sabt[5];
152 #define fiqstack sfiq
153 #define irqstack sirq
154 #define abtstack sabt
155 #define undstack sund
156
157         uintptr stack[1];
158 };
159
160 /*
161  * Fake kmap.
162  */
163 typedef void            KMap;
164 #define VA(k)           ((uintptr)(k))
165 #define kmap(p)         (KMap*)((p)->pa|kseg0)
166 #define kunmap(k)
167
168 struct
169 {
170         char    machs[MAXMACH];         /* active CPUs */
171         int     exiting;                /* shutdown */
172 }active;
173
174 enum {
175         Frequency       = 1200*1000*1000,       /* the processor clock */
176 };
177
178 extern register Mach* m;                        /* R10 */
179 extern register Proc* up;                       /* R9 */
180
181 extern uintptr kseg0;
182 extern Mach* machaddr[MAXMACH];
183
184 enum {
185         Nvec = 8,       /* # of vectors at start of lexception.s */
186 };
187
188 /*
189  * Layout of physical 0.
190  */
191 typedef struct Vectorpage {
192         void    (*vectors[Nvec])(void);
193         uint    vtable[Nvec];
194 } Vectorpage;
195
196 /*
197  *  a parsed plan9.ini line
198  */
199 #define NISAOPT         8
200
201 struct ISAConf {
202         char            *type;
203         ulong   port;
204         int     irq;
205         ulong   dma;
206         ulong   mem;
207         ulong   size;
208         ulong   freq;
209
210         int     nopt;
211         char    *opt[NISAOPT];
212 };
213
214 #define MACHP(n)        (machaddr[n])
215
216 /*
217  * Horrid. But the alternative is 'defined'.
218  */
219 #ifdef _DBGC_
220 #define DBGFLG          (dbgflg[_DBGC_])
221 #else
222 #define DBGFLG          (0)
223 #endif /* _DBGC_ */
224
225 int vflag;
226 extern char dbgflg[256];
227
228 #define dbgprint        print           /* for now */
229
230 /*
231  *  hardware info about a device
232  */
233 typedef struct {
234         ulong   port;   
235         int     size;
236 } Devport;
237
238 struct DevConf
239 {
240         ulong   intnum;                 /* interrupt number */
241         char    *type;                  /* card type, malloced */
242         int     nports;                 /* Number of ports */
243         Devport *ports;                 /* The ports themselves */
244 };
245
246 enum {
247         Dcache,
248         Icache,
249         Unified,
250 };
251
252 /* characteristics of a given cache level */
253 struct Memcache {
254         uint    level;          /* 1 is nearest processor, 2 further away */
255         uint    kind;           /* I, D or unified */
256
257         uint    size;
258         uint    nways;          /* associativity */
259         uint    nsets;
260         uint    linelen;        /* bytes per cache line */
261         uint    setsways;
262
263         uint    log2linelen;
264         uint    waysh;          /* shifts for set/way register */
265         uint    setsh;
266 };
267
268 struct Soc {                    /* addr's of SoC controllers */
269         uintptr cpu;
270         uintptr devid;
271         uintptr l2cache;
272         uintptr sdramc;
273 //      uintptr sdramd;         /* unused */
274
275         uintptr iocfg;
276         uintptr addrmap;
277         uintptr intr;
278         uintptr nand;
279         uintptr cesa;           /* crypto accel. */
280         uintptr ehci;
281         uintptr spi;
282         uintptr twsi;
283
284         uintptr analog;
285         uintptr pci;
286         uintptr pcibase;
287
288         uintptr rtc;            /* real-time clock */
289         uintptr clock;
290
291         uintptr ether[2];
292         uintptr sata[3];
293         uintptr uart[2];
294         uintptr gpio[2];
295 } soc;
296 extern Soc soc;