~n-muench/ubuntu/oneiric/open-vm-tools/open-vm-tools.fix-836277

« back to all changes in this revision

Viewing changes to lib/include/cpuid_info.h

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2008-10-23 15:32:00 UTC
  • mfrom: (1.1.2 upstream) (2.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20081023153200-gc1bfx89hj35c799
Tags: 2008.10.10-123053-2
* Correcting typo in dh_installinit call.
* Downgrading depends on module-assistant to recommends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*********************************************************
2
 
 * Copyright (C) 1998 VMware, Inc. All rights reserved.
 
2
 * Copyright (C) 1998-2008 VMware, Inc. All rights reserved.
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify it
5
5
 * under the terms of the GNU Lesser General Public License as published
26
26
#define INCLUDE_ALLOW_VMKERNEL
27
27
#include "includeCheck.h"
28
28
 
 
29
#include "vm_basic_asm.h"
29
30
#include "x86cpuid.h"
30
 
#include "vm_basic_asm.h"
31
 
 
32
31
 
33
32
 
34
33
typedef struct CPUID0 {
66
65
   CPUIDRegs id88, id8a;
67
66
} CPUIDSummary;
68
67
 
 
68
 
 
69
/*
 
70
 *----------------------------------------------------------------------
 
71
 *
 
72
 * CPUIDSummary_RegsFromCpuid0 --
 
73
 *
 
74
 *      Fills in the given CPUIDRegs struct with the values from the CPUID0 struct.
 
75
 *
 
76
 * Results:
 
77
 *      Returns the CPUIDRegs pointer passed in.
 
78
 *
 
79
 * Side effects:
 
80
 *      None.
 
81
 *
 
82
 *----------------------------------------------------------------------
 
83
 */
 
84
static INLINE CPUIDRegs*
 
85
CPUIDSummary_RegsFromCpuid0(CPUID0* id0In,
 
86
                            CPUIDRegs* id0Out)
 
87
{
 
88
   id0Out->eax = id0In->numEntries;
 
89
   id0Out->ebx = *(uint32 *) (id0In->name + 0);
 
90
   id0Out->edx = *(uint32 *) (id0In->name + 4);
 
91
   id0Out->ecx = *(uint32 *) (id0In->name + 8);
 
92
   return id0Out;
 
93
}
 
94
 
 
95
 
 
96
/*
 
97
 *----------------------------------------------------------------------
 
98
 *
 
99
 * CPUIDSummary_SafeToUseMC0_CTL --
 
100
 *
 
101
 *      Determines whether it is safe to write to the MCE control
 
102
 *      register MC0_CTL.
 
103
 *      Known safe:     P4, Nahalem, All AMD.
 
104
 *      Known not safe: P6, Core, Core2, Penryn
 
105
 *      Don't know:     P2, P3
 
106
 *
 
107
 * Results:
 
108
 *      True iff it is known to be safe.
 
109
 *
 
110
 * Side effects:
 
111
 *      None.
 
112
 *
 
113
 *----------------------------------------------------------------------
 
114
 */
 
115
static INLINE Bool
 
116
CPUIDSummary_SafeToUseMC0_CTL(CPUIDSummary* cpuidSummary)
 
117
{
 
118
   CPUIDRegs id0;
 
119
 
 
120
   CPUIDSummary_RegsFromCpuid0(&cpuidSummary->id0, &id0);   
 
121
   return CPUID_IsVendorAMD(&id0) ||
 
122
      (CPUID_IsVendorIntel(&id0) &&
 
123
       (CPUID_FAMILY_IS_PENTIUM4(id0.eax) ||
 
124
        CPUID_UARCH_IS_NEHALEM(cpuidSummary->id1.version)));
 
125
}
 
126
 
 
127
 
69
128
/* The following two functions return the number of cores per package
70
129
   and set *numThreadsPerCore to the number of hardware threads per core. */ 
71
130
static INLINE uint32