summaryrefslogtreecommitdiff
path: root/sys/src/cmd/vmx/dat.h
blob: 34c2fd888bd1fb1960c4c3f6b0569a8c39a0ef68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
typedef struct PCIDev PCIDev;
typedef struct PCICap PCICap;
typedef struct PCIBar PCIBar;
typedef struct Region Region;

extern int irqactive;

enum {
	VMRUNNING,
	VMHALT,
	VMDEAD,
};
extern int state;

enum {
	BY2PG = 4096
};

#define RPC "pc"
#define RSP "sp"
#define RAX "ax"
#define RBX "bx"
#define RCX "cx"
#define RDX "dx"
#define RBP "bp"
#define RSI "si"
#define RDI "di"
#define R8 "r8"
#define R9 "r9"
#define R10 "r10"
#define R11 "r11"
#define R12 "r12"
#define R13 "r13"
#define R14 "r14"
#define R15 "r15"

enum {
	MMIORD = 0,
	MMIOWRP = 1,
	MMIOWR = 2,
};

struct Region {
	uintptr start, end;
	enum {
		REGALLOC = 1, /* allocate memory for region */
		REGRO = 2, /* read-only */
		
		/* E820 types, 0 == omitted from memory map */
		REGFREE = 1<<8, /* report to OS as free */
		REGRES = 2<<8, /* report to OS as reserved */
	} type;
	char *segname;
	uvlong segoff;
	void *v, *ve;
	Region *next;
};

extern Region *mmap;

#define BDF(b,d,f) ((b)<<16&0xff0000|(d)<<11&0xf800|(f)<<8&0x700)

struct PCIBar {
	PCIDev *d;
	u8int type;
	u32int addr, length;
	PCIBar *busnext, *busprev;
	u32int (*io)(int, u16int, u32int, int, void *);
	void *aux;
};

enum {
	/* type */
	BARIO = 1,
	BARMEM32 = 0,
	BARMEM64 = 4,
	BARPREF = 8,
};

struct PCIDev {
	u32int bdf, viddid, clrev, subid;
	u16int ctrl;
	u8int irqno, irqactive;
	PCIBar bar[6];
	PCIDev *next;
	PCICap *cap;
	u8int capalloc;
};

struct PCICap {
	PCIDev *dev;
	u8int length;
	u8int addr;
	u32int (*read)(PCICap *, u8int);
	void (*write)(PCICap *, u8int, u32int, u32int);
	PCICap *next;
};

enum {
	/* irqline argument */
	IRQLTOGGLE = -1,
	IRQLLOHI = -2,
	
	/* postexc */
	NOERRC = -1,
};

typedef struct VgaMode VgaMode;
struct VgaMode {
	u16int no;
	int w, h, hbytes, sz;
	u32int chan;
	VgaMode *next;
};

extern uchar cmos[0x30];

extern void (*kconfig)(void);

/* arguments for x86access */
enum {
	SEGCS,
	SEGDS,
	SEGES,
	SEGFS,
	SEGGS,
	SEGSS,
	SEGMAX,
};

enum {
	ACCR,
	ACCW,
	ACCX,
};

/* used to speed up consecutive x86access calls */
typedef struct TLB TLB;
struct TLB {
	int asz, seg, acc;
	uintptr start, end;
	uchar *base;
};