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 02:04:10
On 2004.09.23 00:14:47 +0000, Rui Paulo wrote:
> Thanks for you reply.
> Here is the diff with the changes you suggested:
> 
> Index: cpufunc.h
> ===================================================================
> RCS file: /cvsroot/src/sys/arch/i386/include/cpufunc.h,v
> retrieving revision 1.28
> diff -u -r1.28 cpufunc.h
> --- cpufunc.h	14 Jan 2004 11:31:55 -0000	1.28
> +++ cpufunc.h	22 Sep 2004 23:12:48 -0000
> @@ -245,6 +245,19 @@
>  	return (rv);
>  }
>  
> +static __inline u_int64_t
> +rdmsr64(u_int msr)
> +{       
> +	u_int64_t rv;
> +	u_int32_t regs[2];
> +        
> +	__asm __volatile("rdmsr" : "=A" (regs[0]), "=D" (regs[1]) : "c" (msr));
> +	rv = ((u_int64_t) regs[1] << 32) | regs[0];
> +
> +	return (rv);
> +
> +} 
> +
>  static __inline void
>  wrmsr(u_int msr, u_int64_t newval)
>  {
> @@ -252,6 +265,13 @@
>  }
>  
>  static __inline void
> +wrmsr64(u_int msr, u_int64_t newval)
> +{
> +	__asm __volatile("wrmsr" : : "A" (newval >> 32), 
> +			 "D" (newval & 0xffffffff), "c" (msr));
> +}
> +
> +static __inline void
>  wbinvd(void)
>  {
>  	__asm __volatile("wbinvd");
> 

# "A" : Specifies the `a' or `d' registers. This is primarily useful
# for 64-bit integer values intended to be returned with the `d'
# register holding the most significant bits and the `a' register
# holding the least significant bits.
So, we don't need the rdmsr64() version. Sorry for the hassle.

Regards.
-- 
Rui Paulo                          "Simplicity is the ultimate sophistication."
                                      -- Leonardo da Vinci