Subject: Re: rdmsr() function
To: None <port-i386@NetBSD.org>
From: Rui Paulo <phlox-netbsd-i386@fnop.net>
List: port-i386
Date: 09/24/2004 12:41:28
On 2004.09.24 01:46:07 +0000, List Mail User wrote:
> Hi,
>
> I've been watching this exchange for a while, and now that it seems
> to be winding up, the time to correct the problems has come; Two primary
> issues - the constraint letter 'D' is for the "edi" register not for the
> "edx" register (which is constrained with 'd'), AND the use of the 'A'
> constraint makes an explicit reference to BOTH "eax" and "edx" so no
> second argument/constraint is needed - also, the high order and low order
> bits are reversed in some cases.
>
> Corrected (and simpler/smaller - two or three insns. each) functions
> are below:
>
> static __inline u_int64_t
> rdmsr64(u_int msr)
> {
> u_int64_t rv;
>
> __asm __volatile("rdmsr" : "=A" (rv) : "c" (msr));
>
> return rv;
> }
>
> static __inline void
> wrmsr64(u_int msr, u_int64_t newval)
> {
> __asm __volatile("wrmsr" : : "A" (newval), "c" (msr));
> }
>
I said that in my previous post. If you check the cpufunc.h file,
you'll notice that rdmsr() is already using "=A", so no need to change
anything.
--
Rui Paulo "Simplicity is the ultimate sophistication."
-- Leonardo da Vinci