coreboot-v3/include/arch/x86/msr.h
<<
>>
Prefs
   1/*
   2 * This file is part of the coreboot project.
   3 *
   4 * Copyright (C) 2007 Ronald G. Minnich <rminnich@gmail.com>
   5 *
   6 * This program is free software; you can redistribute it and/or modify
   7 * it under the terms of the GNU General Public License as published by
   8 * the Free Software Foundation; version 2 of the License.
   9 *
  10 * This program is distributed in the hope that it will be useful,
  11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13 * GNU General Public License for more details.
  14 *
  15 * You should have received a copy of the GNU General Public License
  16 * along with this program; if not, write to the Free Software
  17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  18 */
  19
  20#ifndef CPU_X86_MSR_H
  21#define CPU_X86_MSR_H
  22
  23#include <types.h>
  24
  25/* standard MSR operations, everyone has written these one hundred times */
  26struct msr {
  27        u32 lo;
  28        u32 hi;
  29};
  30
  31struct msrinit {
  32        u32 msrnum;
  33        struct msr msr;
  34};
  35
  36static inline struct msr rdmsr(u32 index)
  37{
  38        struct msr  result;
  39        __asm__ __volatile__ (
  40                "rdmsr"
  41                : "=a" (result.lo), "=d" (result.hi)
  42                : "c" (index)
  43                );
  44        return result;
  45}
  46
  47static inline void wrmsr(u32 index, struct msr msr)
  48{
  49        __asm__ __volatile__ (
  50                "wrmsr"
  51                : /* No outputs */
  52                : "c" (index), "a" (msr.lo), "d" (msr.hi)
  53                );
  54}
  55
  56
  57#endif /* CPU_X86_MSR_H */
  58
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.