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