VirtualBox

Changeset 49845 in vbox


Ignore:
Timestamp:
Dec 9, 2013 3:18:59 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
91190
Message:

Adding ASMWrMsrEx and ASMRdMSrEx.

Location:
trunk
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/asm-amd64-x86.h

    r49182 r49845  
    17671767
    17681768/**
     1769 * Reads a machine specific register, extended version (for AMD).
     1770 *
     1771 * @returns Register content.
     1772 * @param   uRegister   Register to read.
     1773 * @param   uXDI        RDI/EDI value.
     1774 */
     1775#if RT_INLINE_ASM_EXTERNAL
     1776DECLASM(uint64_t) ASMRdMsrEx(uint32_t uRegister, RTCCUINTREG uXDI);
     1777#else
     1778DECLINLINE(uint64_t) ASMRdMsrEx(uint32_t uRegister, RTCCUINTREG uXDI)
     1779{
     1780    RTUINT64U u;
     1781# if RT_INLINE_ASM_GNU_STYLE
     1782    __asm__ __volatile__("rdmsr\n\t"
     1783                         : "=a" (u.s.Lo),
     1784                           "=d" (u.s.Hi)
     1785                         : "c" (uRegister),
     1786                           "D" (uXDI));
     1787
     1788# else
     1789    __asm
     1790    {
     1791        mov     ecx, [uRegister]
     1792        xchg    edi, [uXDI]
     1793        rdmsr
     1794        mov     [u.s.Lo], eax
     1795        mov     [u.s.Hi], edx
     1796        xchg    edi, [uXDI]
     1797    }
     1798# endif
     1799
     1800    return u.u;
     1801}
     1802#endif
     1803
     1804
     1805/**
     1806 * Writes a machine specific register, extended version (for AMD).
     1807 *
     1808 * @returns Register content.
     1809 * @param   uRegister   Register to write to.
     1810 * @param   uXDI        RDI/EDI value.
     1811 * @param   u64Val      Value to write.
     1812 */
     1813#if RT_INLINE_ASM_EXTERNAL
     1814DECLASM(void) ASMWrMsrEx(uint32_t uRegister, RTCCUINTREG uXDI, uint64_t u64Val);
     1815#else
     1816DECLINLINE(void) ASMWrMsrEx(uint32_t uRegister, RTCCUINTREG uXDI, uint64_t u64Val)
     1817{
     1818    RTUINT64U u;
     1819
     1820    u.u = u64Val;
     1821# if RT_INLINE_ASM_GNU_STYLE
     1822    __asm__ __volatile__("wrmsr\n\t"
     1823                         ::"a" (u.s.Lo),
     1824                           "d" (u.s.Hi),
     1825                           "c" (uRegister),
     1826                           "D" (uXDI));
     1827
     1828# else
     1829    __asm
     1830    {
     1831        mov     ecx, [uRegister]
     1832        xchg    edi, [uXDI]
     1833        mov     edx, [u.s.Hi]
     1834        mov     eax, [u.s.Lo]
     1835        wrmsr
     1836        xchg    edi, [uXDI]
     1837    }
     1838# endif
     1839}
     1840#endif
     1841
     1842
     1843
     1844/**
    17691845 * Reads low part of a machine specific register.
    17701846 *
  • trunk/src/VBox/Runtime/Makefile.kmk

    r49724 r49845  
    538538        common/asm/ASMAtomicUoAndU32.asm \
    539539        common/asm/ASMAtomicUoOrU64.asm \
    540         common/asm/ASMAtomicUoOrU32.asm
     540        common/asm/ASMAtomicUoOrU32.asm \
     541        common/asm/ASMRdMsrEx.asm \
     542        common/asm/ASMWrMsrEx.asm
    541543RuntimeR3_SOURCES.amd64 += \
    542544        common/asm/ASMCpuIdExSlow.asm \
     
    544546        common/asm/ASMAtomicUoAndU32.asm \
    545547        common/asm/ASMAtomicUoOrU64.asm \
    546         common/asm/ASMAtomicUoOrU32.asm
     548        common/asm/ASMAtomicUoOrU32.asm \
     549        common/asm/ASMRdMsrEx.asm \
     550        common/asm/ASMWrMsrEx.asm
    547551
    548552# Some versions of GCC might require this.
     
    16641668        common/asm/ASMAtomicUoAndU32.asm \
    16651669        common/asm/ASMAtomicUoOrU64.asm \
    1666         common/asm/ASMAtomicUoOrU32.asm
     1670        common/asm/ASMAtomicUoOrU32.asm \
     1671        common/asm/ASMRdMsrEx.asm \
     1672        common/asm/ASMWrMsrEx.asm
    16671673RuntimeR0_SOURCES.amd64 += \
    16681674        common/asm/ASMCpuIdExSlow.asm \
     
    16701676        common/asm/ASMAtomicUoAndU32.asm \
    16711677        common/asm/ASMAtomicUoOrU64.asm \
    1672         common/asm/ASMAtomicUoOrU32.asm
     1678        common/asm/ASMAtomicUoOrU32.asm \
     1679        common/asm/ASMRdMsrEx.asm \
     1680        common/asm/ASMWrMsrEx.asm
    16731681
    16741682#if1of ($(KBUILD_TARGET_ARCH),amd64 x86)
     
    18071815        r0drv/generic/semspinmutex-r0drv-generic.c \
    18081816        VBox/log-vbox.cpp \
     1817
     1818RuntimeR0Drv_SOURCES.amd64 = \
     1819        common/asm/ASMRdMsrEx.asm \
     1820        common/asm/ASMWrMsrEx.asm
     1821RuntimeR0Drv_SOURCES.x86   = \
     1822        common/asm/ASMRdMsrEx.asm \
     1823        common/asm/ASMWrMsrEx.asm
     1824
    18091825
    18101826RuntimeR0Drv_SOURCES.linux = \
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