vmi.h 7.3 KB

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