]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/vmx/dat.h
show line numbers in dtracy type errors
[plan9front.git] / sys / src / cmd / vmx / dat.h
1 typedef struct PCIDev PCIDev;
2 typedef struct PCICap PCICap;
3 typedef struct PCIBar PCIBar;
4 typedef struct Region Region;
5
6 extern int irqactive;
7
8 enum {
9         VMRUNNING,
10         VMHALT,
11         VMDEAD,
12 };
13 extern int state;
14
15 enum {
16         BY2PG = 4096
17 };
18
19 #define RPC "pc"
20 #define RSP "sp"
21 #define RAX "ax"
22 #define RBX "bx"
23 #define RCX "cx"
24 #define RDX "dx"
25 #define RBP "bp"
26 #define RSI "si"
27 #define RDI "di"
28 #define R8 "r8"
29 #define R9 "r9"
30 #define R10 "r10"
31 #define R11 "r11"
32 #define R12 "r12"
33 #define R13 "r13"
34 #define R14 "r14"
35 #define R15 "r15"
36 #define RFLAGS "flags"
37
38 enum {
39         MMIORD = 0,
40         MMIOWRP = 1,
41         MMIOWR = 2,
42 };
43
44 struct Region {
45         uintptr start, end;
46         enum {
47                 REGALLOC = 1, /* allocate memory for region */
48                 REGR = 2, /* can read */
49                 REGW = 4, /* can write */
50                 REGX = 8, /* can execute */
51                 
52                 REGRWX = REGR|REGW|REGX,
53                 REGRX = REGR|REGX,
54                 
55                 /* E820 types, 0 == omitted from memory map */
56                 REGFREE = 1<<8, /* report to OS as free */
57                 REGRES = 2<<8, /* report to OS as reserved */
58         } type;
59         char *segname;
60         uvlong segoff;
61         void *v, *ve;
62         Region *next;
63         int (*mmio)(uintptr, void *, int, int);
64 };
65
66 extern Region *mmap;
67
68 #define BDF(b,d,f) ((b)<<16&0xff0000|(d)<<11&0xf800|(f)<<8&0x700)
69
70 struct PCIBar {
71         PCIDev *d;
72         u8int type;
73         u32int addr, length;
74         PCIBar *busnext, *busprev;
75         u32int (*io)(int, u16int, u32int, int, void *);
76         void *aux;
77 };
78
79 enum {
80         /* type */
81         BARIO = 1,
82         BARMEM32 = 0,
83         BARMEM64 = 4,
84         BARPREF = 8,
85 };
86
87 struct PCIDev {
88         u32int bdf, viddid, clrev, subid;
89         u16int ctrl;
90         u8int irqno, irqactive;
91         PCIBar bar[6];
92         PCIDev *next;
93         PCICap *cap;
94         u8int capalloc;
95 };
96
97 struct PCICap {
98         PCIDev *dev;
99         u8int length;
100         u8int addr;
101         u32int (*read)(PCICap *, u8int);
102         void (*write)(PCICap *, u8int, u32int, u32int);
103         PCICap *next;
104 };
105
106 enum {
107         /* irqline argument */
108         IRQLTOGGLE = -1,
109         IRQLLOHI = -2,
110         
111         /* postexc */
112         NOERRC = -1,
113 };
114
115 typedef struct VgaMode VgaMode;
116 struct VgaMode {
117         u16int no;
118         int w, h, hbytes, sz;
119         u32int chan;
120         VgaMode *next;
121 };
122
123 extern uchar cmos[0x30];
124
125 extern void (*kconfig)(void);
126
127 /* arguments for x86access */
128 enum {
129         SEGCS,
130         SEGDS,
131         SEGES,
132         SEGFS,
133         SEGGS,
134         SEGSS,
135         SEGMAX,
136 };
137
138 enum {
139         ACCR,
140         ACCW,
141         ACCX,
142         ACCSAFE = 0x100, /* don't post exceptions on fault */
143 };
144
145 /* used to speed up consecutive x86access calls */
146 typedef struct TLB TLB;
147 struct TLB {
148         int asz, seg, acc;
149         uintptr start, end;
150         uintptr pabase;
151         Region *reg;
152         uchar *base;
153 };