VirtualBox

Changeset 14521 in vbox


Ignore:
Timestamp:
Nov 24, 2008 2:48:30 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
39809
Message:

Added GetProcessorFeature method to IHost.

Location:
trunk/src/VBox/Main
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/HostImpl.cpp

    r14337 r14521  
    11761176}
    11771177
     1178/**
     1179 * Returns whether a host processor feature is supported or not
     1180 *
     1181 * @returns COM status code
     1182 * @param   Feature to query.
     1183 * @param   address of supported bool result variable
     1184 */
     1185STDMETHODIMP Host::GetProcessorFeature(ProcessorFeature_T feature, BOOL *supported)
     1186{
     1187    if (!supported)
     1188        return E_POINTER;
     1189    AutoWriteLock alock (this);
     1190    CHECK_READY();
     1191
     1192    bool fVTxAMDVSupported = false;
     1193    bool fLongModeSupported = false;
     1194    bool fPAESupported = false;
     1195
     1196    if (ASMHasCpuId())
     1197    {
     1198        uint32_t u32FeaturesECX;
     1199        uint32_t u32Dummy;
     1200        uint32_t u32FeaturesEDX;
     1201        uint32_t u32VendorEBX, u32VendorECX, u32VendorEDX, u32AMDFeatureEDX, u32AMDFeatureECX;
     1202
     1203        ASMCpuId (0, &u32Dummy, &u32VendorEBX, &u32VendorECX, &u32VendorEDX);
     1204        ASMCpuId (1, &u32Dummy, &u32Dummy, &u32FeaturesECX, &u32FeaturesEDX);
     1205        /* Query AMD features. */
     1206        ASMCpuId (0x80000001, &u32Dummy, &u32Dummy, &u32AMDFeatureECX, &u32AMDFeatureEDX);
     1207
     1208        fLongModeSupported = !!(u32AMDFeatureEDX & X86_CPUID_AMD_FEATURE_EDX_LONG_MODE);
     1209        fPAESupported      = !!(u32FeaturesEDX & X86_CPUID_FEATURE_EDX_PAE);
     1210
     1211        if (    u32VendorEBX == X86_CPUID_VENDOR_INTEL_EBX
     1212            &&  u32VendorECX == X86_CPUID_VENDOR_INTEL_ECX
     1213            &&  u32VendorEDX == X86_CPUID_VENDOR_INTEL_EDX
     1214           )
     1215        {
     1216            if (    (u32FeaturesECX & X86_CPUID_FEATURE_ECX_VMX)
     1217                 && (u32FeaturesEDX & X86_CPUID_FEATURE_EDX_MSR)
     1218                 && (u32FeaturesEDX & X86_CPUID_FEATURE_EDX_FXSR)
     1219               )
     1220                fVTxAMDVSupported = true;
     1221        }
     1222        else
     1223        if (    u32VendorEBX == X86_CPUID_VENDOR_AMD_EBX
     1224            &&  u32VendorECX == X86_CPUID_VENDOR_AMD_ECX
     1225            &&  u32VendorEDX == X86_CPUID_VENDOR_AMD_EDX
     1226           )
     1227        {
     1228            if (   (u32AMDFeatureECX & X86_CPUID_AMD_FEATURE_ECX_SVM)
     1229                && (u32FeaturesEDX & X86_CPUID_FEATURE_EDX_MSR)
     1230                && (u32FeaturesEDX & X86_CPUID_FEATURE_EDX_FXSR)
     1231               )
     1232                fVTxAMDVSupported = true;
     1233        }
     1234    }
     1235
     1236    switch (feature)
     1237    {
     1238    case ProcessorFeature_HWVirtEx:
     1239        *supported = fVTxAMDVSupported;
     1240        break;
     1241
     1242    case ProcessorFeature_PAE:
     1243        *supported = fPAESupported;
     1244        break;
     1245
     1246    case ProcessorFeature_LongMode:
     1247        *supported = fLongModeSupported;
     1248        break;
     1249
     1250    default:
     1251        return E_NOTIMPL;
     1252    }
     1253    return S_OK;
     1254}
    11781255
    11791256/**
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r14469 r14521  
    611611  </enum>
    612612
     613  <enum
     614    name="ProcessorFeature"
     615    uuid="b8353b35-705d-4796-9967-ebfb7ba54af4"
     616  >
     617    <desc>
     618      CPU features.
     619    </desc>
     620
     621    <const name="HWVirtEx"        value="0"/>
     622    <const name="PAE"             value="1"/>
     623    <const name="LongMode"        value="2"/>
     624  </enum>
     625
    613626
    614627  <!--
     
    50325045  <interface
    50335046     name="IHost" extends="$unknown"
    5034      uuid="489fb370-c227-4d43-9761-ceb28484fd9f"
     5047     uuid="4be2e85f-a54c-4bc7-8bf6-f070f9113940"
    50355048     wsmap="managed"
    50365049     >
     
    51195132          Speed value. 0 is returned if value is not known or @a cpuId is
    51205133          invalid.
     5134        </desc>
     5135      </param>
     5136    </method>
     5137
     5138    <method name="getProcessorFeature">
     5139      <desc>Query whether a CPU feature is supported or not.</desc>
     5140      <param name="feature" type="ProcessorFeature" dir="in">
     5141        <desc>
     5142          CPU Feature identifier.
     5143        </desc>
     5144      </param>
     5145      <param name="supported" type="boolean" dir="return">
     5146        <desc>
     5147          Feature is supported or not.
    51215148        </desc>
    51225149      </param>
  • trunk/src/VBox/Main/include/HostImpl.h

    r13713 r14521  
    8686    STDMETHOD(GetProcessorSpeed)(ULONG cpuId, ULONG *speed);
    8787    STDMETHOD(GetProcessorDescription)(ULONG cpuId, BSTR *description);
     88    STDMETHOD(GetProcessorFeature) (ProcessorFeature_T feature, BOOL *supported);
    8889    STDMETHOD(COMGETTER(MemorySize))(ULONG *size);
    8990    STDMETHOD(COMGETTER(MemoryAvailable))(ULONG *available);
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette