VirtualBox

Changeset 8882 in vbox for trunk/include/iprt


Ignore:
Timestamp:
May 16, 2008 11:55:20 AM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
30917
Message:

Added ASMGetCpuFamily, ASMGetCpuModel and ASMGetCpuStepping to pack up the bit fiddling.

File:
1 edited

Legend:

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

    r8277 r8882  
    942942#endif
    943943
     944
     945/**
     946 * Extracts the CPU family from ASMCpuId(1) or ASMCpuId(0x80000001)
     947 *
     948 * @returns Family.
     949 * @param   uEAX    EAX return from ASMCpuId(1) or ASMCpuId(0x80000001).
     950 */
     951DECLINLINE(uint32_t) ASMGetCpuFamily(uint32_t uEAX)
     952{
     953    return ((uEAX >> 8) & 0xf) == 0xf
     954         ? ((uEAX >> 20) & 0x7f) + 0xf
     955         : ((uEAX >> 8) & 0xf);
     956}
     957
     958
     959/**
     960 * Extracts the CPU model from ASMCpuId(1) or ASMCpuId(0x80000001)
     961 *
     962 * @returns Model.
     963 * @param   uEAX    EAX from ASMCpuId(1) or ASMCpuId(0x80000001).
     964 */
     965DECLINLINE(uint32_t) ASMGetCpuModel(uint32_t uEAX)
     966{
     967    return ((uEAX >> 8) & 0xf) == 0xf /* family! */
     968         ? ((uEAX >> 4) & 0xf) | ((uEAX >> 12) & 0xf0)
     969         : ((uEAX >> 4) & 0xf);
     970}
     971
     972
     973/**
     974 * Extracts the CPU stepping from ASMCpuId(1) or ASMCpuId(0x80000001)
     975 *
     976 * @returns Model.
     977 * @param   uEAX    EAX from ASMCpuId(1) or ASMCpuId(0x80000001).
     978 */
     979DECLINLINE(uint32_t) ASMGetCpuStepping(uint32_t uEAX)
     980{
     981    return uEAX & 0xf;
     982}
     983
     984
    944985/**
    945986 * Get cr0.
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