diff options
author | Patrick Georgi <patrick.georgi@coresystems.de> | 2010-09-30 17:03:32 +0000 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2010-09-30 17:03:32 +0000 |
commit | a9095a95450860e7ea96bb6c21ca4f34e406d3d6 (patch) | |
tree | f79ff036266bb09b180f27b3552dd30116a221e4 /physmap.c | |
parent | 5cfc94a98be9fa2317220c76367fe1792c328461 (diff) | |
download | ast2050-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.c | 41 |
1 files changed, 40 insertions, 1 deletions
@@ -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) { |