From d9c3ea6d71df20007845a8b56fc6245ef86ba480 Mon Sep 17 00:00:00 2001
From: Julien Grall <julien.grall@linaro.org>
Date: Tue, 14 Jan 2014 14:44:08 +0000
Subject: [PATCH 23/48] xen: Introduce xen_pmap

The function to map xen memory is not the same on every architecture.

On ARM, the mappings require to be cacheable and pmap_mapdev doesn't do that.

Replace every call of pmap_mapdev in xen code by xen_pmap
---
 sys/amd64/include/xen/xen-os.h  | 2 ++
 sys/dev/xen/xenstore/xenstore.c | 2 +-
 sys/i386/include/xen/xen-os.h   | 2 ++
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/sys/amd64/include/xen/xen-os.h b/sys/amd64/include/xen/xen-os.h
index d217ca4..cffc213 100644
--- a/sys/amd64/include/xen/xen-os.h
+++ b/sys/amd64/include/xen/xen-os.h
@@ -129,6 +129,8 @@ static __inline__ void clear_bit(int nr, volatile void * addr)
 
 extern start_info_t *xen_start_info;
 
+#define xen_pmap(pa, size)	pmap_mapdev((pa), (size))
+
 #endif /* !__ASSEMBLY__ */
 
 #endif /* _MACHINE_XEN_XEN_OS_H_ */
diff --git a/sys/dev/xen/xenstore/xenstore.c b/sys/dev/xen/xenstore/xenstore.c
index 95e7edf..d675739 100644
--- a/sys/dev/xen/xenstore/xenstore.c
+++ b/sys/dev/xen/xenstore/xenstore.c
@@ -1168,7 +1168,7 @@ xs_attach(device_t dev)
 	if (xen_hvm_domain()) {
 		xs.evtchn = hvm_get_parameter(HVM_PARAM_STORE_EVTCHN);
 		xs.gpfn = hvm_get_parameter(HVM_PARAM_STORE_PFN);
-		xen_store = pmap_mapdev(xs.gpfn * PAGE_SIZE, PAGE_SIZE);
+		xen_store = xen_pmap(xs.gpfn * PAGE_SIZE, PAGE_SIZE);
 		xs.initialized = true;
 	} else if (xen_pv_domain()) {
 		if (HYPERVISOR_start_info->store_evtchn == 0) {
diff --git a/sys/i386/include/xen/xen-os.h b/sys/i386/include/xen/xen-os.h
index e79558fa..a05d668 100644
--- a/sys/i386/include/xen/xen-os.h
+++ b/sys/i386/include/xen/xen-os.h
@@ -284,6 +284,8 @@ static __inline__ void atomic_inc(atomic_t *v)
 #define rdtscll(val) \
      __asm__ __volatile__("rdtsc" : "=A" (val))
 
+#define xen_pmap(pa, size)	pmap_mapdev((pa), (size))
+
 #endif /* !__ASSEMBLY__ */
 
 #endif /* _MACHINE_XEN_XEN_OS_H_ */
-- 
2.1.0

