+{
+ struct xencomm_desc *desc;
+ int rc;
+
+ desc = xencomm_alloc_mini(area, arealen);
+ if (!desc)
+ return -ENOMEM;
+ desc->nr_addrs = XENCOMM_MINI_ADDRS;
+
+ rc = xencomm_init(desc, buffer, bytes);
+ if (rc)
+ return rc;
+
+ *ret = desc;
+ return 0;
+}
+
+void *xencomm_map(void *ptr, unsigned long bytes)
+{
+ int rc;
+ struct xencomm_desc *desc;
+
+ if (is_phys_contiguous((unsigned long)ptr))
+ return xencomm_create_inline(ptr);
+
+ rc = xencomm_create(ptr, bytes, &desc, GFP_KERNEL);
+
+ if (rc)
+ return NULL;
+
+ return xencomm_pa(desc);
+}
+
+void *__xencomm_map_early(void *ptr, unsigned long bytes,
+ char *xc_area)
+{
+ int rc;
+ struct xencomm_desc *desc;
+
+ if (is_phys_contiguous((unsigned long)ptr))
+ return xencomm_create_inline(ptr);
+
+ rc = xencomm_create_mini(xc_area, XENCOMM_MINI_AREA,ptr, bytes,
+ &desc);
+
+ if (rc)
+ return NULL;
+
+ return (void*)__pa(desc);
+}
+
+/* check if is physically contiguous memory */
+int is_phys_contiguous(unsigned long addr)
+{
+ return (addr < VMALLOC_START) || (addr >= VMALLOC_END);
+}
diff -r ab3b5849331d -r 82e1886955c3 include/xen/xencomm.h
--- a/include/xen/xencomm.h Sun Jan 21 08:36:53 2007 -0500
+++ b/include/xen/xencomm.h Mon Jan 22 14:47:15 2007 -0600
@@ -16,6 +16,7 @@
* Copyright (C) IBM Corp. 2006
*
*/
#ifndef _LINUX_XENCOMM_H_
@@ -23,10 +24,25 @@
#include <xen/interface/xencomm.h>
-extern int xencomm_create(void *buffer, unsigned long bytes,
- struct xencomm_desc **desc, gfp_t type);
+#define XENCOMM_MINI_ADDRS 3
+struct xencomm_mini {
+ struct xencomm_desc _desc;
+ uint64_t address[XENCOMM_MINI_ADDRS];
+};
+#define XENCOMM_MINI_AREA (sizeof(struct xencomm_mini) * 2)
+
extern void xencomm_free(struct xencomm_desc *desc);
+extern int xencomm_create(void *buffer, unsigned long bytes,
+ struct xencomm_desc **ret, gfp_t gfp_mask);
extern void *xencomm_create_inline(void *ptr);
+extern void *xencomm_map(void *ptr, unsigned long bytes);
+extern void *__xencomm_map_early(void *ptr, unsigned long bytes,
+ char *xc_area);
+extern int is_phys_contiguous(unsigned long addr);
+
+#define xencomm_map_early(ptr, bytes) \
+ ({char xc_area[XENCOMM_MINI_AREA];\
+ __xencomm_map_early(ptr, bytes, xc_area);})
/* provided by architecture code: */
extern unsigned long xencomm_vtop(unsigned long vaddr);
# HG changeset patch
# Date 1169614163 21600
# Node ID c326865b79895e91ac57e548eda03cda3c4c0dcc
# Parent 82e1886955c349ee9c473560ead37f61b787fcd7
Use structure instead of char
diff -r 82e1886955c3 -r c326865b7989 drivers/xen/core/xencomm.c
--- a/drivers/xen/core/xencomm.c Mon Jan 22 14:47:15 2007 -0600
+++ b/drivers/xen/core/xencomm.c Tue Jan 23 22:49:23 2007 -0600
@@ -187,7 +187,7 @@ void *xencomm_map(void *ptr, unsigned lo
}
void *__xencomm_map_early(void *ptr, unsigned long bytes,
- char *xc_area)
+ struct xencomm_mini *xc_area)
{
int rc;
struct xencomm_desc *desc;
diff -r 82e1886955c3 -r c326865b7989 include/xen/xencomm.h
--- a/include/xen/xencomm.h Mon Jan 22 14:47:15 2007 -0600
+++ b/include/xen/xencomm.h Tue Jan 23 22:49:23 2007 -0600
@@ -37,12 +37,13 @@ extern void *xencomm_create_inline(void
extern void *xencomm_create_inline(void *ptr);
extern void *xencomm_map(void *ptr, unsigned long bytes);
extern void *__xencomm_map_early(void *ptr, unsigned long bytes,
- char *xc_area);
+ struct xencomm_mini *xc_area);
extern int is_phys_contiguous(unsigned long addr);
#define xencomm_map_early(ptr, bytes) \
- ({char xc_area[XENCOMM_MINI_AREA];\
- __xencomm_map_early(ptr, bytes, xc_area);})
+ ({struct xencomm_mini xc_area[XENCOMM_MINI_AREA]\
This is no longer and array, and XENCOMM_MINI_AREA can be removed complety.