From: Kruti Date: Mon, 27 May 2024 06:55:32 +0000 (-0700) Subject: Change to common source files not applicable to open-vm-tools. X-Git-Tag: stable-12.5.0~52 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eedd5a4b61bfd2f54eaabffc2553cb9d7fcabbb5;p=thirdparty%2Fopen-vm-tools.git Change to common source files not applicable to open-vm-tools. --- diff --git a/open-vm-tools/lib/include/vmcheck.h b/open-vm-tools/lib/include/vmcheck.h index adbdf18f3..9d3285c51 100644 --- a/open-vm-tools/lib/include/vmcheck.h +++ b/open-vm-tools/lib/include/vmcheck.h @@ -1,5 +1,6 @@ /********************************************************* - * Copyright (C) 2006-2017 VMware, Inc. All rights reserved. + * Copyright (c) 2006-2024 Broadcom. All rights reserved. + * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -16,14 +17,12 @@ * *********************************************************/ - /* * vmcheck.h -- * - * Utility functions for discovering our virtualization status. + * Utility functions for discovering our virtualization status. */ - #ifndef __VMCHECK_H__ # define __VMCHECK_H__ @@ -37,6 +36,9 @@ Bool VmCheck_GetVersion(uint32 *version, // OUT uint32 *type); // OUT +Bool +VmCheck_GetHWVersion(uint32 *hwversion); // OUT + Bool VmCheck_IsVirtualWorld(void); diff --git a/open-vm-tools/lib/vmCheck/vmcheck.c b/open-vm-tools/lib/vmCheck/vmcheck.c index 0e296be5a..153e33034 100644 --- a/open-vm-tools/lib/vmCheck/vmcheck.c +++ b/open-vm-tools/lib/vmCheck/vmcheck.c @@ -1,5 +1,6 @@ /********************************************************* - * Copyright (c) 2006-2021, 2023 VMware, Inc. All rights reserved. + * Copyright (c) 2006-2024 Broadcom. All rights reserved. + * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -20,7 +21,7 @@ /* * vmcheck.c -- * - * Utility functions for discovering our virtualization status. + * Utility functions for discovering our virtualization status. */ #include @@ -197,7 +198,7 @@ VmCheckSafe(SafeCheckFn checkFn) Bool VmCheck_GetVersion(uint32 *version, // OUT - uint32 *type) // OUT + uint32 *type) // OUT { Backdoor_proto bp; @@ -243,6 +244,53 @@ VmCheck_GetVersion(uint32 *version, // OUT } +/* + *---------------------------------------------------------------------- + * + * VmCheck_GetHWVersion -- + * + * Retrieve the VM's hardware version. + * + * Return value: + * TRUE on success + * *hwversion contains the VM hardware version + * FALSE on failure + * + * Side effects: + * None + * + *---------------------------------------------------------------------- + */ + +Bool +VmCheck_GetHWVersion(uint32 *hwversion) // OUT +{ + Backdoor_proto bp; + ASSERT(hwversion); + + /* Make sure EBX does not contain BDOOR_MAGIC */ + bp.in.size = (size_t)~BDOOR_MAGIC; + /* send backdoor command to get hw version */ + bp.in.cx.halfs.low = BDOOR_CMD_GETHWVERSION; + Backdoor(&bp); + + if (bp.out.ax.word == 0xFFFFFFFF) { + /* + * No backdoor device there. This code is not executing in a VMware + * virtual machine. + */ + return FALSE; + } + + if (bp.out.bx.word != BDOOR_MAGIC) { + return FALSE; + } + + *hwversion = bp.out.ax.word; + return TRUE; +} + + /* *---------------------------------------------------------------------- *