VirtualBox

Changeset 24452 in vbox


Ignore:
Timestamp:
Nov 6, 2009 3:43:24 PM (15 years ago)
Author:
vboxsync
Message:

iprt/asm.h: Added ASMIsAmdCpuEx and ASMIsAmdCpu.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/asm.h

    r24060 r24452  
    980980DECLINLINE(bool) ASMIsIntelCpuEx(uint32_t uEBX, uint32_t uECX, uint32_t uEDX)
    981981{
    982     return uEBX == 0x756e6547
    983         && uECX == 0x6c65746e
    984         && uEDX == 0x49656e69;
     982    return uEBX == UINT32_C(0x756e6547)
     983        && uECX == UINT32_C(0x6c65746e)
     984        && uEDX == UINT32_C(0x49656e69);
    985985}
    986986
     
    997997    ASMCpuId(0, &uEAX, &uEBX, &uECX, &uEDX);
    998998    return ASMIsIntelCpuEx(uEBX, uECX, uEDX);
     999}
     1000
     1001
     1002/**
     1003 * Tests if it a authentic AMD CPU based on the ASMCpuId(0) output.
     1004 *
     1005 * @returns true/false.
     1006 * @param   uEBX    EBX return from ASMCpuId(0)
     1007 * @param   uECX    ECX return from ASMCpuId(0)
     1008 * @param   uEDX    EDX return from ASMCpuId(0)
     1009 */
     1010DECLINLINE(bool) ASMIsAmdCpuEx(uint32_t uEBX, uint32_t uECX, uint32_t uEDX)
     1011{
     1012    return uEBX == UINT32_C(0x68747541)
     1013        && uECX == UINT32_C(0x444d4163)
     1014        && uEDX == UINT32_C(0x69746e65);
     1015}
     1016
     1017
     1018/**
     1019 * Tests if this is an authentic AMD CPU.
     1020 *
     1021 * @returns true/false.
     1022 * @remarks ASSUMES that cpuid is supported by the CPU.
     1023 */
     1024DECLINLINE(bool) ASMIsAmdCpu(void)
     1025{
     1026    uint32_t uEAX, uEBX, uECX, uEDX;
     1027    ASMCpuId(0, &uEAX, &uEBX, &uECX, &uEDX);
     1028    return ASMIsAmdCpuEx(uEBX, uECX, uEDX);
    9991029}
    10001030
Note: See TracChangeset for help on using the changeset viewer.

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