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
10FILE_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 */
36static inline __attribute__ (( always_inline )) void
37vmware_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 */
60static inline __attribute__ (( always_inline )) uint32_t
61vmware_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
79extern int vmware_present ( void );
80
81#endif /* _IPXE_VMWARE_H */
unsigned short uint16_t
Definition stdint.h:11
unsigned int uint32_t
Definition stdint.h:12
u32 version
Driver version.
Definition ath9k_hw.c:1985
uint16_t magic
Magic signature.
Definition bzimage.h:1
static uint32_t uint32_t uint32_t * ebx
Definition cpuid.h:90
static uint32_t uint32_t uint32_t uint32_t uint32_t * edx
Definition cpuid.h:91
uint8_t status
Status.
Definition ena.h:5
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define __attribute__(x)
Definition compiler.h:10
uint32_t channel
RNDIS channel.
Definition netvsc.h:3
__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")
A request parameter.
Definition params.h:29
static uint32_t uint32_t * product_type
Definition vmware.h:38
#define VMW_CMD_GET_VERSION
Get VMware version.
Definition vmware.h:24
#define VMW_MAGIC
VMware backdoor magic value.
Definition vmware.h:18
static uint16_t uint32_t uint16_t * edxhi
Definition vmware.h:62
#define VMW_BACKDOOR
VMware backdoor magic instruction.
Definition vmware.h:21
static uint16_t subcommand
Definition vmware.h:61
#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))
#define VMW_CMD_GUESTRPC
Issue GuestRPC command.
Definition vmware.h:27
int vmware_present(void)
Detect VMware presence.
Definition vmware.c:45