]> git.lizzy.rs Git - plan9front.git/blob - sys/src/9/pc64/dat.h
kernel: remove Ipifc.mbps, unused.
[plan9front.git] / sys / src / 9 / pc64 / dat.h
1 typedef struct BIOS32si BIOS32si;
2 typedef struct BIOS32ci BIOS32ci;
3 typedef struct Conf     Conf;
4 typedef struct Confmem  Confmem;
5 typedef struct FPsave   FPsave;
6 typedef struct PFPU     PFPU;
7 typedef struct ISAConf  ISAConf;
8 typedef struct Label    Label;
9 typedef struct Lock     Lock;
10 typedef struct MMU      MMU;
11 typedef struct Mach     Mach;
12 typedef struct PCArch   PCArch;
13 typedef struct Pcidev   Pcidev;
14 typedef struct PCMmap   PCMmap;
15 typedef struct PCMslot  PCMslot;
16 typedef struct Page     Page;
17 typedef struct PMMU     PMMU;
18 typedef struct Proc     Proc;
19 typedef struct Segdesc  Segdesc;
20 typedef vlong           Tval;
21 typedef struct Ureg     Ureg;
22 typedef struct Vctl     Vctl;
23
24 #pragma incomplete BIOS32si
25 #pragma incomplete Pcidev
26 #pragma incomplete Ureg
27
28 #define MAXSYSARG       5       /* for mount(fd, afd, mpt, flag, arg) */
29
30 /*
31  *  parameters for sysproc.c
32  */
33 #define AOUT_MAGIC      (S_MAGIC)
34
35 struct Lock
36 {
37         ulong   key;
38         ulong   sr;
39         uintptr pc;
40         Proc    *p;
41         Mach    *m;
42         ushort  isilock;
43         long    lockcycles;
44 };
45
46 struct Label
47 {
48         uintptr sp;
49         uintptr pc;
50 };
51
52 struct FPsave
53 {
54         u16int  fcw;                    /* x87 control word */
55         u16int  fsw;                    /* x87 status word */
56         u8int   ftw;                    /* x87 tag word */
57         u8int   zero;                   /* 0 */
58         u16int  fop;                    /* last x87 opcode */
59         u64int  rip;                    /* last x87 instruction pointer */
60         u64int  rdp;                    /* last x87 data pointer */
61         u32int  mxcsr;                  /* MMX control and status */
62         u32int  mxcsrmask;              /* supported MMX feature bits */
63         uchar   st[128];                /* shared 64-bit media and x87 regs */
64         uchar   xmm[256];               /* 128-bit media regs */
65         uchar   ign[96];                /* reserved, ignored */
66 };
67
68 enum
69 {
70         /* this is a state */
71         FPinit=         0,
72         FPactive=       1,
73         FPinactive=     2,
74
75         /*
76          * the following are bits that can be or'd into the state.
77          *
78          * this is biased so that FPinit, FPactive and FPinactive
79          * without any flags refer to user fp state in fpslot[0].
80          */
81         FPillegal=      1<<8,   /* fp forbidden in note handler */
82         FPpush=         2<<8,   /* trap on use and initialize new fpslot */
83         FPnouser=       4<<8,   /* fpslot[0] is kernel regs */
84         FPkernel=       8<<8,   /* fp use in kernel (user in fpslot[0] when !FPnouser) */
85
86         FPindexs=       16,
87         FPindex1=       1<<FPindexs,
88         FPindexm=       3<<FPindexs,
89 };
90
91 struct PFPU
92 {
93         int     fpstate;
94         FPsave  *fpsave;        /* fpslot[fpstate>>FPindexs] */
95         FPsave  *fpslot[(FPindexm+1)>>FPindexs];
96 };
97
98 struct Confmem
99 {
100         uintptr base;
101         ulong   npage;
102         uintptr kbase;
103         uintptr klimit;
104 };
105
106 struct Conf
107 {
108         ulong   nmach;          /* processors */
109         ulong   nproc;          /* processes */
110         ulong   monitor;        /* has monitor? */
111         Confmem mem[16];        /* physical memory */
112         ulong   npage;          /* total physical pages of memory */
113         ulong   upages;         /* user page pool */
114         ulong   nimage;         /* number of page cache image headers */
115         ulong   nswap;          /* number of swap pages */
116         int     nswppo;         /* max # of pageouts per segment pass */
117         ulong   copymode;       /* 0 is copy on write, 1 is copy on reference */
118         ulong   ialloc;         /* max interrupt time allocation in bytes */
119         ulong   pipeqsize;      /* size in bytes of pipe queues */
120         int     nuart;          /* number of uart devices */
121 };
122
123 struct Segdesc
124 {
125         u32int  d0;
126         u32int  d1;
127 };
128
129 /*
130  *  MMU structure for PDP, PD, PT pages.
131  */
132 struct MMU
133 {
134         MMU     *next;
135         uintptr *page;
136         int     index;
137         int     level;
138 };
139
140 /*
141  *  MMU stuff in proc
142  */
143 #define NCOLOR 1
144 struct PMMU
145 {
146         MMU*    mmuhead;
147         MMU*    mmutail;
148         MMU*    kmaphead;
149         MMU*    kmaptail;
150         ulong   kmapcount;
151         ulong   kmapindex;
152         ulong   mmucount;
153         
154         u64int  dr[8];
155         void    *vmx;
156 };
157
158 #include "../port/portdat.h"
159
160 typedef struct {
161         u32int  _0_;
162         u32int  rsp0[2];
163         u32int  rsp1[2];
164         u32int  rsp2[2];
165         u32int  _28_[2];
166         u32int  ist[14];
167         u16int  _92_[5];
168         u16int  iomap;
169 } Tss;
170
171 struct Mach
172 {
173         int     machno;                 /* physical id of processor (KNOWN TO ASSEMBLY) */
174         uintptr splpc;                  /* pc of last caller to splhi (KNOWN TO ASSEMBLY) */
175
176         Proc*   proc;                   /* current process on this processor (KNOWN TO ASSEMBLY) */
177
178         u64int* pml4;                   /* pml4 base for this processor (va) */
179         Tss*    tss;                    /* tss for this processor */
180         Segdesc *gdt;                   /* gdt for this processor */
181
182         u64int  mmumap[4];              /* bitmap of pml4 entries for zapping */
183         MMU*    mmufree;                /* freelist for MMU structures */
184         ulong   mmucount;               /* number of MMU structures in freelist */
185
186         ulong   ticks;                  /* of the clock since boot time */
187         Label   sched;                  /* scheduler wakeup */
188         Lock    alarmlock;              /* access to alarm list */
189         void*   alarm;                  /* alarms bound to this clock */
190         int     inclockintr;
191
192         Proc*   readied;                /* for runproc */
193         ulong   schedticks;             /* next forced context switch */
194
195         int     tlbfault;
196         int     tlbpurge;
197         int     pfault;
198         int     cs;
199         int     syscall;
200         int     load;
201         int     intr;
202         int     flushmmu;               /* make current proc flush it's mmu state */
203         int     ilockdepth;
204         Perf    perf;                   /* performance counters */
205
206         ulong   spuriousintr;
207         int     lastintr;
208
209         int     loopconst;
210
211         int     cpumhz;
212         uvlong  cyclefreq;              /* Frequency of user readable cycle counter */
213         uvlong  cpuhz;
214         int     cpuidax;
215         int     cpuidcx;
216         int     cpuiddx;
217         char    cpuidid[16];
218         char*   cpuidtype;
219         int     havetsc;
220         int     havepge;
221         int     havewatchpt8;
222         uvlong  tscticks;
223         
224         u64int  dr7;                    /* shadow copy of dr7 */
225         
226         void*   vmx;
227
228         uintptr stack[1];
229 };
230
231 /*
232  * KMap the structure
233  */
234 typedef void KMap;
235 #define VA(k)           ((void*)k)
236
237 extern u32int MemMin;
238
239 struct
240 {
241         char    machs[MAXMACH];         /* bitmap of active CPUs */
242         int     exiting;                /* shutdown */
243 }active;
244
245 /*
246  *  routines for things outside the PC model, like power management
247  */
248 struct PCArch
249 {
250         char*   id;
251         int     (*ident)(void);         /* this should be in the model */
252         void    (*reset)(void);         /* this should be in the model */
253         int     (*serialpower)(int);    /* 1 == on, 0 == off */
254         int     (*modempower)(int);     /* 1 == on, 0 == off */
255
256         void    (*intrinit)(void);
257         int     (*intrenable)(Vctl*);
258         int     (*intrvecno)(int);
259         int     (*intrdisable)(int);
260         void    (*introff)(void);
261         void    (*intron)(void);
262
263         void    (*clockenable)(void);
264         uvlong  (*fastclock)(uvlong*);
265         void    (*timerset)(uvlong);
266 };
267
268 /* cpuid instruction result register bits */
269 enum {
270         /* cx */
271         Monitor = 1<<3,
272
273         /* dx */
274         Fpuonchip = 1<<0,
275         Vmex    = 1<<1,         /* virtual-mode extensions */
276         Pse     = 1<<3,         /* page size extensions */
277         Tsc     = 1<<4,         /* time-stamp counter */
278         Cpumsr  = 1<<5,         /* model-specific registers, rdmsr/wrmsr */
279         Pae     = 1<<6,         /* physical-addr extensions */
280         Mce     = 1<<7,         /* machine-check exception */
281         Cmpxchg8b = 1<<8,
282         Cpuapic = 1<<9,
283         Mtrr    = 1<<12,        /* memory-type range regs.  */
284         Pge     = 1<<13,        /* page global extension */
285         Mca     = 1<<14,        /* machine-check architecture */
286         Pat     = 1<<16,        /* page attribute table */
287         Pse2    = 1<<17,        /* more page size extensions */
288         Clflush = 1<<19,
289         Acpif   = 1<<22,        /* therm control msr */
290         Mmx     = 1<<23,
291         Fxsr    = 1<<24,        /* have SSE FXSAVE/FXRSTOR */
292         Sse     = 1<<25,        /* thus sfence instr. */
293         Sse2    = 1<<26,        /* thus mfence & lfence instr.s */
294         Rdrnd   = 1<<30,        /* RDRAND support bit */
295 };
296
297 enum {                                          /* MSRs */
298         PerfEvtbase     = 0xc0010000,           /* Performance Event Select */
299         PerfCtrbase     = 0xc0010004,           /* Performance Counters */
300
301         Efer            = 0xc0000080,           /* Extended Feature Enable */
302         Star            = 0xc0000081,           /* Legacy Target IP and [CS]S */
303         Lstar           = 0xc0000082,           /* Long Mode Target IP */
304         Cstar           = 0xc0000083,           /* Compatibility Target IP */
305         Sfmask          = 0xc0000084,           /* SYSCALL Flags Mask */
306         FSbase          = 0xc0000100,           /* 64-bit FS Base Address */
307         GSbase          = 0xc0000101,           /* 64-bit GS Base Address */
308         KernelGSbase    = 0xc0000102,           /* SWAPGS instruction */
309 };
310
311 /*
312  *  a parsed plan9.ini line
313  */
314 #define NISAOPT         8
315
316 struct ISAConf {
317         char    *type;
318         ulong   port;
319         int     irq;
320         ulong   dma;
321         ulong   mem;
322         ulong   size;
323         ulong   freq;
324
325         int     nopt;
326         char    *opt[NISAOPT];
327 };
328
329 extern PCArch   *arch;                  /* PC architecture */
330
331 Mach* machp[MAXMACH];
332         
333 #define MACHP(n)        (machp[n])
334
335 extern register Mach* m;                        /* R15 */
336 extern register Proc* up;                       /* R14 */
337
338 /*
339  *  hardware info about a device
340  */
341 typedef struct {
342         ulong   port;   
343         int     size;
344 } Devport;
345
346 struct DevConf
347 {
348         ulong   intnum;                 /* interrupt number */
349         char    *type;                  /* card type, malloced */
350         int     nports;                 /* Number of ports */
351         Devport *ports;                 /* The ports themselves */
352 };
353
354 typedef struct BIOS32ci {               /* BIOS32 Calling Interface */
355         u32int  eax;
356         u32int  ebx;
357         u32int  ecx;
358         u32int  edx;
359         u32int  esi;
360         u32int  edi;
361 } BIOS32ci;