Angel Pons has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/52547 )
Change subject: cpu/x86/msr.h: Turn `msr_t` into a union ......................................................................
cpu/x86/msr.h: Turn `msr_t` into a union
This allows treating MSR values as one 64-bit value, which may be more convenient in some cases. Also add a compile-time size check.
Change-Id: Ia8ac87296628855968005371f8acf2ca486d6c1a Signed-off-by: Angel Pons th3fanbus@gmail.com --- M src/include/cpu/x86/msr.h 1 file changed, 8 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/47/52547/1
diff --git a/src/include/cpu/x86/msr.h b/src/include/cpu/x86/msr.h index 5ae3ddf..fc98d03 100644 --- a/src/include/cpu/x86/msr.h +++ b/src/include/cpu/x86/msr.h @@ -95,12 +95,17 @@ #define IA32_CR_SF_QOS_MASK_2 0x1892
#ifndef __ASSEMBLER__ +#include <assert.h> #include <types.h>
-typedef struct msr_struct { - unsigned int lo; - unsigned int hi; +typedef union { + struct { + unsigned int lo; + unsigned int hi; + }; + uint64_t value; } msr_t; +_Static_assert(sizeof(msr_t) == sizeof(uint64_t), "Size of msr_t is incorrect");
typedef struct msrinit_struct { unsigned int index;