summaryrefslogtreecommitdiffstats
path: root/src/arch/x86/include
diff options
context:
space:
mode:
authorMichael Brown2016-01-05 18:20:36 +0100
committerMichael Brown2016-01-05 18:20:36 +0100
commitdd485992dc213dc19876a331f3a044dcb2e7560b (patch)
treebed08bb9d09a1ab0ee96c9f1e8ad447487bf7ea3 /src/arch/x86/include
parent[crypto] Dual-license more selected DRBG files (diff)
downloadipxe-dd485992dc213dc19876a331f3a044dcb2e7560b.tar.gz
ipxe-dd485992dc213dc19876a331f3a044dcb2e7560b.tar.xz
ipxe-dd485992dc213dc19876a331f3a044dcb2e7560b.zip
[vmware] Expose GuestRPC mechanism in 64-bit builds
The GuestRPC mechanism (used for VMWARE_SETTINGS and CONSOLE_VMWARE) does not use any real-mode code and so can be exposed in both 64-bit and 32-bit builds. Reported-by: Matthew Helton <mwhelton@gmail.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/arch/x86/include')
-rw-r--r--src/arch/x86/include/ipxe/guestrpc.h68
-rw-r--r--src/arch/x86/include/ipxe/vmware.h81
2 files changed, 149 insertions, 0 deletions
diff --git a/src/arch/x86/include/ipxe/guestrpc.h b/src/arch/x86/include/ipxe/guestrpc.h
new file mode 100644
index 000000000..bc3d85506
--- /dev/null
+++ b/src/arch/x86/include/ipxe/guestrpc.h
@@ -0,0 +1,68 @@
+#ifndef _IPXE_GUESTRPC_H
+#define _IPXE_GUESTRPC_H
+
+/** @file
+ *
+ * VMware GuestRPC mechanism
+ *
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
+
+#include <stdint.h>
+#include <ipxe/vmware.h>
+
+/** GuestRPC magic number */
+#define GUESTRPC_MAGIC 0x49435052 /* "RPCI" */
+
+/** Open RPC channel */
+#define GUESTRPC_OPEN 0x00
+
+/** Open RPC channel success status */
+#define GUESTRPC_OPEN_SUCCESS 0x00010000
+
+/** Send RPC command length */
+#define GUESTRPC_COMMAND_LEN 0x01
+
+/** Send RPC command length success status */
+#define GUESTRPC_COMMAND_LEN_SUCCESS 0x00810000
+
+/** Send RPC command data */
+#define GUESTRPC_COMMAND_DATA 0x02
+
+/** Send RPC command data success status */
+#define GUESTRPC_COMMAND_DATA_SUCCESS 0x00010000
+
+/** Receive RPC reply length */
+#define GUESTRPC_REPLY_LEN 0x03
+
+/** Receive RPC reply length success status */
+#define GUESTRPC_REPLY_LEN_SUCCESS 0x00830000
+
+/** Receive RPC reply data */
+#define GUESTRPC_REPLY_DATA 0x04
+
+/** Receive RPC reply data success status */
+#define GUESTRPC_REPLY_DATA_SUCCESS 0x00010000
+
+/** Finish receiving RPC reply */
+#define GUESTRPC_REPLY_FINISH 0x05
+
+/** Finish receiving RPC reply success status */
+#define GUESTRPC_REPLY_FINISH_SUCCESS 0x00010000
+
+/** Close RPC channel */
+#define GUESTRPC_CLOSE 0x06
+
+/** Close RPC channel success status */
+#define GUESTRPC_CLOSE_SUCCESS 0x00010000
+
+/** RPC command success status */
+#define GUESTRPC_SUCCESS 0x2031 /* "1 " */
+
+extern int guestrpc_open ( void );
+extern void guestrpc_close ( int channel );
+extern int guestrpc_command ( int channel, const char *command, char *reply,
+ size_t reply_len );
+
+#endif /* _IPXE_GUESTRPC_H */
diff --git a/src/arch/x86/include/ipxe/vmware.h b/src/arch/x86/include/ipxe/vmware.h
new file mode 100644
index 000000000..24f60a03a
--- /dev/null
+++ b/src/arch/x86/include/ipxe/vmware.h
@@ -0,0 +1,81 @@
+#ifndef _IPXE_VMWARE_H
+#define _IPXE_VMWARE_H
+
+/** @file
+ *
+ * VMware backdoor mechanism
+ *
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
+
+#include <stdint.h>
+
+/** VMware backdoor I/O port */
+#define VMW_PORT 0x5658
+
+/** VMware backdoor magic value */
+#define VMW_MAGIC 0x564d5868 /* "VMXh" */
+
+/** VMware backdoor magic instruction */
+#define VMW_BACKDOOR "inl %%dx, %%eax"
+
+/** Get VMware version */
+#define VMW_CMD_GET_VERSION 0x0a
+
+/** Issue GuestRPC command */
+#define VMW_CMD_GUESTRPC 0x1e
+
+/**
+ * Get VMware version
+ *
+ * @ret version VMware version(?)
+ * @ret magic VMware magic number, if present
+ * @ret product_type VMware product type
+ */
+static inline __attribute__ (( always_inline )) void
+vmware_cmd_get_version ( uint32_t *version, uint32_t *magic,
+ uint32_t *product_type ) {
+ uint32_t discard_d;
+
+ /* Perform backdoor call */
+ __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 ) );
+}
+
+/**
+ * Issue GuestRPC command
+ *
+ * @v channel Channel number
+ * @v subcommand GuestRPC subcommand
+ * @v parameter Subcommand-specific parameter
+ * @ret edxhi Subcommand-specific result
+ * @ret ebx Subcommand-specific result
+ * @ret status Command status
+ */
+static inline __attribute__ (( always_inline )) uint32_t
+vmware_cmd_guestrpc ( int channel, uint16_t subcommand, uint32_t parameter,
+ uint16_t *edxhi, uint32_t *ebx ) {
+ uint32_t discard_a;
+ uint32_t status;
+ uint32_t edx;
+
+ /* Perform backdoor call */
+ __asm__ __volatile__ ( VMW_BACKDOOR
+ : "=a" ( discard_a ), "=b" ( *ebx ),
+ "=c" ( status ), "=d" ( edx )
+ : "0" ( VMW_MAGIC ), "1" ( parameter ),
+ "2" ( VMW_CMD_GUESTRPC | ( subcommand << 16 )),
+ "3" ( VMW_PORT | ( channel << 16 ) ) );
+ *edxhi = ( edx >> 16 );
+
+ return status;
+}
+
+extern int vmware_present ( void );
+
+#endif /* _IPXE_VMWARE_H */