iPXE
vmware.h
Go to the documentation of this file.
1 #ifndef _IPXE_VMWARE_H
2 #define _IPXE_VMWARE_H
3 
4 /** @file
5  *
6  * VMware backdoor mechanism
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 #include <stdint.h>
13 
14 /** VMware backdoor I/O port */
15 #define VMW_PORT 0x5658
16 
17 /** VMware backdoor magic value */
18 #define VMW_MAGIC 0x564d5868 /* "VMXh" */
19 
20 /** VMware backdoor magic instruction */
21 #define VMW_BACKDOOR "inl %%dx, %%eax"
22 
23 /** Get VMware version */
24 #define VMW_CMD_GET_VERSION 0x0a
25 
26 /** Issue GuestRPC command */
27 #define VMW_CMD_GUESTRPC 0x1e
28 
29 /**
30  * Get VMware version
31  *
32  * @ret version VMware version(?)
33  * @ret magic VMware magic number, if present
34  * @ret product_type VMware product type
35  */
36 static inline __attribute__ (( always_inline )) void
37 vmware_cmd_get_version ( uint32_t *version, uint32_t *magic,
39  uint32_t discard_d;
40 
41  /* Perform backdoor call */
43  : "=a" ( *version ), "=b" ( *magic ),
44  "=c" ( *product_type ), "=d" ( discard_d )
45  : "0" ( VMW_MAGIC ), "1" ( 0 ),
46  "2" ( VMW_CMD_GET_VERSION ),
47  "3" ( VMW_PORT ) );
48 }
49 
50 /**
51  * Issue GuestRPC command
52  *
53  * @v channel Channel number
54  * @v subcommand GuestRPC subcommand
55  * @v parameter Subcommand-specific parameter
56  * @ret edxhi Subcommand-specific result
57  * @ret ebx Subcommand-specific result
58  * @ret status Command status
59  */
60 static inline __attribute__ (( always_inline )) uint32_t
61 vmware_cmd_guestrpc ( int channel, uint16_t subcommand, uint32_t parameter,
63  uint32_t discard_a;
66 
67  /* Perform backdoor call */
69  : "=a" ( discard_a ), "=b" ( *ebx ),
70  "=c" ( status ), "=d" ( edx )
71  : "0" ( VMW_MAGIC ), "1" ( parameter ),
72  "2" ( VMW_CMD_GUESTRPC | ( subcommand << 16 )),
73  "3" ( VMW_PORT | ( channel << 16 ) ) );
74  *edxhi = ( edx >> 16 );
75 
76  return status;
77 }
78 
79 extern int vmware_present ( void );
80 
81 #endif /* _IPXE_VMWARE_H */
static __attribute__((always_inline)) void vmware_cmd_get_version(uint32_t *version
Get VMware version.
unsigned short uint16_t
Definition: stdint.h:11
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
static uint32_t * magic
Definition: vmware.h:37
uint32_t edx
Definition: vmware.h:65
u32 version
Version number.
Definition: ath9k_hw.c:1983
#define VMW_MAGIC
VMware backdoor magic value.
Definition: vmware.h:18
#define VMW_PORT
VMware backdoor I/O port.
Definition: vmware.h:15
__asm__ __volatile__(VMW_BACKDOOR :"=a"(*version), "=b"(*magic), "=c"(*product_type), "=d"(discard_d) :"0"(VMW_MAGIC), "1"(0), "2"(VMW_CMD_GET_VERSION), "3"(VMW_PORT))
static uint16_t subcommand
Definition: vmware.h:61
uint32_t channel
RNDIS channel.
Definition: netvsc.h:14
#define VMW_CMD_GET_VERSION
Get VMware version.
Definition: vmware.h:24
static uint16_t uint32_t uint16_t uint32_t * ebx
Definition: vmware.h:62
#define VMW_BACKDOOR
VMware backdoor magic instruction.
Definition: vmware.h:21
unsigned int uint32_t
Definition: stdint.h:12
static uint32_t uint32_t * product_type
Definition: vmware.h:38
int vmware_present(void)
Detect VMware presence.
Definition: vmware.c:45
__asm__(".section \".rodata\", \"a\", " PROGBITS "\n\t" "\nprivate_key_data:\n\t" ".size private_key_data, ( . - private_key_data )\n\t" ".equ private_key_len, ( . - private_key_data )\n\t" ".previous\n\t")
#define VMW_CMD_GUESTRPC
Issue GuestRPC command.
Definition: vmware.h:27
static uint16_t uint32_t uint16_t * edxhi
Definition: vmware.h:61
A form parameter.
Definition: params.h:28
uint32_t status
Definition: vmware.h:64