From d83d4070bfc116a32ca7b365cd7a614e1b6202ed Mon Sep 17 00:00:00 2001 From: oxygene Date: Thu, 30 Sep 2010 17:03:32 +0000 Subject: 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. Signed-off-by: Patrick Georgi Acked-by: Carl-Daniel Hailfinger git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@1184 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1 --- physmap.c | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'physmap.c') 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 #include #include @@ -104,6 +104,31 @@ void physunmap(void *virt_addr, size_t len) __dpmi_free_physical_address_mapping(&mi); } +#elif defined(__LIBPAYLOAD__) +#include + +#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 @@ -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) { -- cgit v1.2.1