]>
Commit | Line | Data |
---|---|---|
7ce0bcfd ZA |
1 | /* |
2 | * VMI interface definition | |
3 | * | |
4 | * Copyright (C) 2005, VMware, Inc. | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or | |
9 | * (at your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, but | |
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | |
14 | * NON INFRINGEMENT. See the GNU General Public License for more | |
15 | * details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with this program; if not, write to the Free Software | |
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
20 | * | |
21 | * Maintained by: Zachary Amsden zach@vmware.com | |
22 | * | |
23 | */ | |
24 | #include <linux/types.h> | |
25 | ||
26 | /* | |
27 | *--------------------------------------------------------------------- | |
28 | * | |
29 | * VMI Option ROM API | |
30 | * | |
31 | *--------------------------------------------------------------------- | |
32 | */ | |
33 | #define VMI_SIGNATURE 0x696d5663 /* "cVmi" */ | |
34 | ||
35 | #define PCI_VENDOR_ID_VMWARE 0x15AD | |
36 | #define PCI_DEVICE_ID_VMWARE_VMI 0x0801 | |
37 | ||
38 | /* | |
39 | * We use two version numbers for compatibility, with the major | |
40 | * number signifying interface breakages, and the minor number | |
41 | * interface extensions. | |
42 | */ | |
43 | #define VMI_API_REV_MAJOR 3 | |
44 | #define VMI_API_REV_MINOR 0 | |
45 | ||
46 | #define VMI_CALL_CPUID 0 | |
47 | #define VMI_CALL_WRMSR 1 | |
48 | #define VMI_CALL_RDMSR 2 | |
49 | #define VMI_CALL_SetGDT 3 | |
50 | #define VMI_CALL_SetLDT 4 | |
51 | #define VMI_CALL_SetIDT 5 | |
52 | #define VMI_CALL_SetTR 6 | |
53 | #define VMI_CALL_GetGDT 7 | |
54 | #define VMI_CALL_GetLDT 8 | |
55 | #define VMI_CALL_GetIDT 9 | |
56 | #define VMI_CALL_GetTR 10 | |
57 | #define VMI_CALL_WriteGDTEntry 11 | |
58 | #define VMI_CALL_WriteLDTEntry 12 | |
59 | #define VMI_CALL_WriteIDTEntry 13 | |
60 | #define VMI_CALL_UpdateKernelStack 14 | |
61 | #define VMI_CALL_SetCR0 15 | |
62 | #define VMI_CALL_SetCR2 16 | |
63 | #define VMI_CALL_SetCR3 17 | |
64 | #define VMI_CALL_SetCR4 18 | |
65 | #define VMI_CALL_GetCR0 19 | |
66 | #define VMI_CALL_GetCR2 20 | |
67 | #define VMI_CALL_GetCR3 21 | |
68 | #define VMI_CALL_GetCR4 22 | |
69 | #define VMI_CALL_WBINVD 23 | |
70 | #define VMI_CALL_SetDR 24 | |
71 | #define VMI_CALL_GetDR 25 | |
72 | #define VMI_CALL_RDPMC 26 | |
73 | #define VMI_CALL_RDTSC 27 | |
74 | #define VMI_CALL_CLTS 28 | |
75 | #define VMI_CALL_EnableInterrupts 29 | |
76 | #define VMI_CALL_DisableInterrupts 30 | |
77 | #define VMI_CALL_GetInterruptMask 31 | |
78 | #define VMI_CALL_SetInterruptMask 32 | |
79 | #define VMI_CALL_IRET 33 | |
80 | #define VMI_CALL_SYSEXIT 34 | |
81 | #define VMI_CALL_Halt 35 | |
82 | #define VMI_CALL_Reboot 36 | |
83 | #define VMI_CALL_Shutdown 37 | |
84 | #define VMI_CALL_SetPxE 38 | |
85 | #define VMI_CALL_SetPxELong 39 | |
86 | #define VMI_CALL_UpdatePxE 40 | |
87 | #define VMI_CALL_UpdatePxELong 41 | |
88 | #define VMI_CALL_MachineToPhysical 42 | |
89 | #define VMI_CALL_PhysicalToMachine 43 | |
90 | #define VMI_CALL_AllocatePage 44 | |
91 | #define VMI_CALL_ReleasePage 45 | |
92 | #define VMI_CALL_InvalPage 46 | |
93 | #define VMI_CALL_FlushTLB 47 | |
94 | #define VMI_CALL_SetLinearMapping 48 | |
95 | ||
96 | #define VMI_CALL_SetIOPLMask 61 | |
97 | #define VMI_CALL_SetInitialAPState 62 | |
98 | #define VMI_CALL_APICWrite 63 | |
99 | #define VMI_CALL_APICRead 64 | |
100 | #define VMI_CALL_SetLazyMode 73 | |
101 | ||
102 | /* | |
103 | *--------------------------------------------------------------------- | |
104 | * | |
105 | * MMU operation flags | |
106 | * | |
107 | *--------------------------------------------------------------------- | |
108 | */ | |
109 | ||
110 | /* Flags used by VMI_{Allocate|Release}Page call */ | |
111 | #define VMI_PAGE_PAE 0x10 /* Allocate PAE shadow */ | |
112 | #define VMI_PAGE_CLONE 0x20 /* Clone from another shadow */ | |
113 | #define VMI_PAGE_ZEROED 0x40 /* Page is pre-zeroed */ | |
114 | ||
115 | ||
116 | /* Flags shared by Allocate|Release Page and PTE updates */ | |
117 | #define VMI_PAGE_PT 0x01 | |
118 | #define VMI_PAGE_PD 0x02 | |
119 | #define VMI_PAGE_PDP 0x04 | |
120 | #define VMI_PAGE_PML4 0x08 | |
121 | ||
122 | #define VMI_PAGE_NORMAL 0x00 /* for debugging */ | |
123 | ||
124 | /* Flags used by PTE updates */ | |
125 | #define VMI_PAGE_CURRENT_AS 0x10 /* implies VMI_PAGE_VA_MASK is valid */ | |
126 | #define VMI_PAGE_DEFER 0x20 /* may queue update until TLB inval */ | |
127 | #define VMI_PAGE_VA_MASK 0xfffff000 | |
128 | ||
129 | #ifdef CONFIG_X86_PAE | |
130 | #define VMI_PAGE_L1 (VMI_PAGE_PT | VMI_PAGE_PAE | VMI_PAGE_ZEROED) | |
131 | #define VMI_PAGE_L2 (VMI_PAGE_PD | VMI_PAGE_PAE | VMI_PAGE_ZEROED) | |
132 | #else | |
133 | #define VMI_PAGE_L1 (VMI_PAGE_PT | VMI_PAGE_ZEROED) | |
134 | #define VMI_PAGE_L2 (VMI_PAGE_PD | VMI_PAGE_ZEROED) | |
135 | #endif | |
136 | ||
137 | /* Flags used by VMI_FlushTLB call */ | |
138 | #define VMI_FLUSH_TLB 0x01 | |
139 | #define VMI_FLUSH_GLOBAL 0x02 | |
140 | ||
141 | /* | |
142 | *--------------------------------------------------------------------- | |
143 | * | |
144 | * VMI relocation definitions for ROM call get_reloc | |
145 | * | |
146 | *--------------------------------------------------------------------- | |
147 | */ | |
148 | ||
149 | /* VMI Relocation types */ | |
150 | #define VMI_RELOCATION_NONE 0 | |
151 | #define VMI_RELOCATION_CALL_REL 1 | |
152 | #define VMI_RELOCATION_JUMP_REL 2 | |
153 | #define VMI_RELOCATION_NOP 3 | |
154 | ||
155 | #ifndef __ASSEMBLY__ | |
156 | struct vmi_relocation_info { | |
157 | unsigned char *eip; | |
158 | unsigned char type; | |
159 | unsigned char reserved[3]; | |
160 | }; | |
161 | #endif | |
162 | ||
163 | ||
164 | /* | |
165 | *--------------------------------------------------------------------- | |
166 | * | |
167 | * Generic ROM structures and definitions | |
168 | * | |
169 | *--------------------------------------------------------------------- | |
170 | */ | |
171 | ||
172 | #ifndef __ASSEMBLY__ | |
173 | ||
174 | struct vrom_header { | |
175 | u16 rom_signature; // option ROM signature | |
176 | u8 rom_length; // ROM length in 512 byte chunks | |
177 | u8 rom_entry[4]; // 16-bit code entry point | |
178 | u8 rom_pad0; // 4-byte align pad | |
179 | u32 vrom_signature; // VROM identification signature | |
180 | u8 api_version_min;// Minor version of API | |
181 | u8 api_version_maj;// Major version of API | |
182 | u8 jump_slots; // Number of jump slots | |
183 | u8 reserved1; // Reserved for expansion | |
184 | u32 virtual_top; // Hypervisor virtual address start | |
185 | u16 reserved2; // Reserved for expansion | |
186 | u16 license_offs; // Offset to License string | |
187 | u16 pci_header_offs;// Offset to PCI OPROM header | |
188 | u16 pnp_header_offs;// Offset to PnP OPROM header | |
189 | u32 rom_pad3; // PnP reserverd / VMI reserved | |
190 | u8 reserved[96]; // Reserved for headers | |
191 | char vmi_init[8]; // VMI_Init jump point | |
192 | char get_reloc[8]; // VMI_GetRelocationInfo jump point | |
193 | } __attribute__((packed)); | |
194 | ||
195 | struct pnp_header { | |
196 | char sig[4]; | |
197 | char rev; | |
198 | char size; | |
199 | short next; | |
200 | short res; | |
201 | long devID; | |
202 | unsigned short manufacturer_offset; | |
203 | unsigned short product_offset; | |
204 | } __attribute__((packed)); | |
205 | ||
206 | struct pci_header { | |
207 | char sig[4]; | |
208 | short vendorID; | |
209 | short deviceID; | |
210 | short vpdData; | |
211 | short size; | |
212 | char rev; | |
213 | char class; | |
214 | char subclass; | |
215 | char interface; | |
216 | short chunks; | |
217 | char rom_version_min; | |
218 | char rom_version_maj; | |
219 | char codetype; | |
220 | char lastRom; | |
221 | short reserved; | |
222 | } __attribute__((packed)); | |
223 | ||
224 | /* Function prototypes for bootstrapping */ | |
225 | extern void vmi_init(void); | |
226 | extern void vmi_bringup(void); | |
227 | extern void vmi_apply_boot_page_allocations(void); | |
228 | ||
229 | /* State needed to start an application processor in an SMP system. */ | |
230 | struct vmi_ap_state { | |
231 | u32 cr0; | |
232 | u32 cr2; | |
233 | u32 cr3; | |
234 | u32 cr4; | |
235 | ||
236 | u64 efer; | |
237 | ||
238 | u32 eip; | |
239 | u32 eflags; | |
240 | u32 eax; | |
241 | u32 ebx; | |
242 | u32 ecx; | |
243 | u32 edx; | |
244 | u32 esp; | |
245 | u32 ebp; | |
246 | u32 esi; | |
247 | u32 edi; | |
248 | u16 cs; | |
249 | u16 ss; | |
250 | u16 ds; | |
251 | u16 es; | |
252 | u16 fs; | |
253 | u16 gs; | |
254 | u16 ldtr; | |
255 | ||
256 | u16 gdtr_limit; | |
257 | u32 gdtr_base; | |
258 | u32 idtr_base; | |
259 | u16 idtr_limit; | |
260 | }; | |
261 | ||
262 | #endif |