]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Changes in shared code that don't affect open-vm-tools functionality.
authorVMware, Inc <>
Mon, 21 Nov 2011 23:17:41 +0000 (15:17 -0800)
committerMarcelo Vanzin <mvanzin@vmware.com>
Mon, 21 Nov 2011 23:17:41 +0000 (15:17 -0800)
Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/lib/include/backdoor_def.h
open-vm-tools/lib/include/hostinfo.h
open-vm-tools/lib/misc/hostinfoPosix.c

index 25836af9b1b96b7b4fee44a0c4a5902d6609ffb1..adc0eb98a1affaed06caab31206de017f2e8aa31 100644 (file)
 #define   BDOOR_CMD_VMK_INFO                 72
 #define   BDOOR_CMD_EFI_BOOT_CONFIG          73 /* CPL 0 only. */
 #  define BDOOR_CMD_EBC_CSM_ENABLED           0
-#define   BDOOR_CMD_MAX                      74
+#define   BDOOR_CMD_GET_HW_MODEL             74 /* CPL 0 only. */
+#define   BDOOR_CMD_MAX                      75
 
 
 /* 
index ab399a374f2471598ec521a61f8a60081e539ce4..fc1ba4316ffa422aa93a7f68ee9620013985e5ec 100644 (file)
@@ -226,6 +226,7 @@ Bool Hostinfo_GetLoadAverage(uint32 *l);
 
 #ifdef __APPLE__
 size_t Hostinfo_GetKernelZoneElemSize(char const *name);
+char *Hostinfo_GetHardwareModel(void);
 #endif
 
 #endif /* ifndef _HOSTINFO_H_ */
index 79eadab4d2b3a45d1edc6ebd5f7e2925d9f65853..49b01d1f1c2ac3aefe1ac033617faf505dc1ab58 100644 (file)
@@ -2405,7 +2405,7 @@ Hostinfo_GetRatedCpuMhz(int32 cpuNumber,  // IN:
    uint32 hz;
    size_t hzSize = sizeof hz;
 
-   /* 'cpuNumber' is ignored: Intel Macs are always perfectly symetric. */
+   /* 'cpuNumber' is ignored: Intel Macs are always perfectly symmetric. */
 
    if (sysctlbyname(CPUMHZ_SYSCTL_NAME, &hz, &hzSize, NULL, 0) == -1) {
       return FALSE;
@@ -2435,12 +2435,13 @@ Hostinfo_GetRatedCpuMhz(int32 cpuNumber,  // IN:
 }
 
 
+#if defined(__APPLE__) || defined(__FreeBSD__)
 /*
  *-----------------------------------------------------------------------------
  *
- * Hostinfo_GetCpuDescription --
+ * HostinfoGetSysctlStringAlloc --
  *
- *      Get the descriptive name associated with a given CPU.
+ *      Obtains the value of a string-type host sysctl.
  *
  * Results:
  *      On success: Allocated, NUL-terminated string.
@@ -2452,22 +2453,13 @@ Hostinfo_GetRatedCpuMhz(int32 cpuNumber,  // IN:
  *-----------------------------------------------------------------------------
  */
 
-char *
-Hostinfo_GetCpuDescription(uint32 cpuNumber)  // IN:
+static char *
+HostinfoGetSysctlStringAlloc(char const *sysctlName) // IN
 {
-#if defined(__APPLE__) || defined(__FreeBSD__)
-#  if defined(__APPLE__)
-#     define CPUDESC_SYSCTL_NAME "machdep.cpu.brand_string"
-#  else
-#     define CPUDESC_SYSCTL_NAME "hw.model"
-#  endif
-
    char *desc;
    size_t descSize;
 
-   /* 'cpuNumber' is ignored: Intel Macs are always perfectly symetric. */
-
-   if (sysctlbyname(CPUDESC_SYSCTL_NAME, NULL, &descSize, NULL, 0) == -1) {
+   if (sysctlbyname(sysctlName, NULL, &descSize, NULL, 0) == -1) {
       return NULL;
    }
 
@@ -2476,13 +2468,42 @@ Hostinfo_GetCpuDescription(uint32 cpuNumber)  // IN:
       return NULL;
    }
 
-   if (sysctlbyname(CPUDESC_SYSCTL_NAME, desc, &descSize, NULL, 0) == -1) {
+   if (sysctlbyname(sysctlName, desc, &descSize, NULL, 0) == -1) {
       free(desc);
 
       return NULL;
    }
 
    return desc;
+}
+#endif
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * Hostinfo_GetCpuDescription --
+ *
+ *      Get the descriptive name associated with a given CPU.
+ *
+ * Results:
+ *      On success: Allocated, NUL-terminated string.
+ *      On failure: NULL.
+ *
+ * Side effects:
+ *      None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+char *
+Hostinfo_GetCpuDescription(uint32 cpuNumber)  // IN:
+{
+#if defined(__APPLE__)
+   /* 'cpuNumber' is ignored: Intel Macs are always perfectly symmetric. */
+   return HostinfoGetSysctlStringAlloc("machdep.cpu.brand_string");
+#elif defined(__FreeBSD__)
+   return HostinfoGetSysctlStringAlloc("hw.model");
 #else
 #ifdef VMX86_SERVER
    if (HostType_OSIsVMK()) {
@@ -2492,7 +2513,7 @@ Hostinfo_GetCpuDescription(uint32 cpuNumber)  // IN:
       mName[0] = '\0';
       if (VMKernel_GetCPUModelName(cpuNumber, mName,
                                    sizeof(mName)) == VMK_OK) {
-        mName[sizeof(mName) - 1] = '\0';
+         mName[sizeof(mName) - 1] = '\0';
 
          return strdup(mName);
       }
@@ -2723,6 +2744,30 @@ Hostinfo_GetKernelZoneElemSize(char const *name) // IN: Kernel zone name
 
    return retval;
 }
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * Hostinfo_GetHardwareModel --
+ *
+ *      Obtains the hardware model identifier (i.e. "MacPro5,1") from the host.
+ *
+ * Results:
+ *      On success: Allocated, NUL-terminated string.
+ *      On failure: NULL.
+ *
+ * Side effects:
+ *      None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+char *
+Hostinfo_GetHardwareModel(void)
+{
+   return HostinfoGetSysctlStringAlloc("hw.model");
+}
 #endif /* __APPLE__ */