From 50720a4b0b251eb1d97d4682a4db9c2c589d6019 Mon Sep 17 00:00:00 2001 From: Thomas Heijligen Date: Tue, 14 Dec 2021 17:25:49 +0100 Subject: hwaccess physmap: move x86 msr related code into own files Allow x86 msr related code to be compiled independent from memory mapping functionality. This enables for a better selection of needed hardware access types. Change-Id: Idc9ce9df3ea1e291ad469de59467646b294119c4 Signed-off-by: Thomas Heijligen Reviewed-on: https://review.coreboot.org/c/flashrom/+/60111 Tested-by: build bot (Jenkins) Reviewed-by: Nico Huber --- hwaccess_x86_msr.h | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 hwaccess_x86_msr.h (limited to 'hwaccess_x86_msr.h') diff --git a/hwaccess_x86_msr.h b/hwaccess_x86_msr.h new file mode 100644 index 000000000..4229b3b92 --- /dev/null +++ b/hwaccess_x86_msr.h @@ -0,0 +1,52 @@ +/* + * This file is part of the flashrom project. + * + * Copyright (C) 2009 Carl-Daniel Hailfinger + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef __HWACCESS_X86_MSR_H__ +#define __HWACCESS_X86_MSR_H__ 1 + +#include + +#if !(defined(__MACH__) && defined(__APPLE__)) && !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && !defined(__DragonFly__) && !defined(__LIBPAYLOAD__) +typedef struct { uint32_t hi, lo; } msr_t; +msr_t rdmsr(int addr); +int wrmsr(int addr, msr_t msr); +#endif + +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) +/* FreeBSD already has conflicting definitions for wrmsr/rdmsr. */ +#undef rdmsr +#undef wrmsr +#define rdmsr freebsd_rdmsr +#define wrmsr freebsd_wrmsr +typedef struct { uint32_t hi, lo; } msr_t; +msr_t freebsd_rdmsr(int addr); +int freebsd_wrmsr(int addr, msr_t msr); +#endif + +#if defined(__LIBPAYLOAD__) +#include +#include +typedef struct { uint32_t hi, lo; } msr_t; +msr_t libpayload_rdmsr(int addr); +int libpayload_wrmsr(int addr, msr_t msr); +#undef rdmsr +#define rdmsr libpayload_rdmsr +#define wrmsr libpayload_wrmsr +#endif + +int setup_cpu_msr(int cpu); +void cleanup_cpu_msr(void); + +#endif /* __HWACCESS_X86_MSR_H__ */ \ No newline at end of file -- cgit v1.2.3