summaryrefslogtreecommitdiffstats
path: root/hwaccess_x86_msr.h
diff options
context:
space:
mode:
authorThomas Heijligen <thomas.heijligen@secunet.com>2021-12-14 17:25:49 +0100
committerNico Huber <nico.h@gmx.de>2021-12-22 12:35:29 +0000
commit50720a4b0b251eb1d97d4682a4db9c2c589d6019 (patch)
tree4f5229baa9c0e0a3fc42bd1384dc5f5a01c53a7d /hwaccess_x86_msr.h
parent49d758698a0dd166679c48b1a2785e50e9b0cc83 (diff)
downloadflashrom-50720a4b0b251eb1d97d4682a4db9c2c589d6019.tar.gz
flashrom-50720a4b0b251eb1d97d4682a4db9c2c589d6019.tar.bz2
flashrom-50720a4b0b251eb1d97d4682a4db9c2c589d6019.zip
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 <thomas.heijligen@secunet.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/60111 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
Diffstat (limited to 'hwaccess_x86_msr.h')
-rw-r--r--hwaccess_x86_msr.h52
1 files changed, 52 insertions, 0 deletions
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 <stdint.h>
+
+#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 <arch/io.h>
+#include <arch/msr.h>
+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