summaryrefslogtreecommitdiffstats
path: root/physmap.c
diff options
context:
space:
mode:
authorPatrick Georgi <patrick.georgi@coresystems.de>2010-09-30 17:03:32 +0000
committerPatrick Georgi <pgeorgi@google.com>2010-09-30 17:03:32 +0000
commita9095a95450860e7ea96bb6c21ca4f34e406d3d6 (patch)
treef79ff036266bb09b180f27b3552dd30116a221e4 /physmap.c
parent5cfc94a98be9fa2317220c76367fe1792c328461 (diff)
downloadast2050-flashrom-a9095a95450860e7ea96bb6c21ca4f34e406d3d6.zip
ast2050-flashrom-a9095a95450860e7ea96bb6c21ca4f34e406d3d6.tar.gz
Add support for building flashrom against libpayload
This doesn't include changes to the frontend which must be done separately, so this won't work out of the box. This code was tested on hardware. Corresponding to flashrom svn r1184. Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Diffstat (limited to 'physmap.c')
-rw-r--r--physmap.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/physmap.c b/physmap.c
index 7ac8ae0..011c8d1 100644
--- a/physmap.c
+++ b/physmap.c
@@ -28,7 +28,7 @@
#include "flash.h"
/* Do we need any file access or ioctl for physmap or MSR? */
-#if !defined(__DJGPP__)
+#if !defined(__DJGPP__) && !defined(__LIBPAYLOAD__)
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
@@ -104,6 +104,31 @@ void physunmap(void *virt_addr, size_t len)
__dpmi_free_physical_address_mapping(&mi);
}
+#elif defined(__LIBPAYLOAD__)
+#include <arch/virtual.h>
+
+#define MEM_DEV ""
+
+void *sys_physmap(unsigned long phys_addr, size_t len)
+{
+ return (void*)phys_to_virt(phys_addr);
+}
+
+#define sys_physmap_rw_uncached sys_physmap
+#define sys_physmap_ro_cached sys_physmap
+
+void physunmap(void *virt_addr, size_t len)
+{
+}
+
+int setup_cpu_msr(int cpu)
+{
+ return 0;
+}
+
+void cleanup_cpu_msr(void)
+{
+}
#elif defined(__DARWIN__)
#include <DirectIO/darwinio.h>
@@ -453,6 +478,20 @@ void cleanup_cpu_msr(void)
{
// Nothing, yet.
}
+#elif defined(__LIBPAYLOAD__)
+msr_t libpayload_rdmsr(int addr)
+{
+ msr_t msr;
+ unsigned long long val = _rdmsr(addr);
+ msr.lo = val & 0xffffffff;
+ msr.hi = val >> 32;
+ return msr;
+}
+
+int libpayload_wrmsr(int addr, msr_t msr)
+{
+ _wrmsr(addr, msr.lo | ((unsigned long long)msr.hi << 32));
+}
#else
msr_t rdmsr(int addr)
{
OpenPOWER on IntegriCloud