22 #include <linux/slab.h>
24 #include <xen/xencomm.h>
31 unsigned long recorded = 0;
34 while ((recorded < bytes) && (i < desc->nr_addrs)) {
35 unsigned long vaddr = (
unsigned long)buffer + recorded;
54 if (recorded < bytes) {
56 "%s: could only translate %ld of %ld bytes\n",
57 __func__, recorded, bytes);
62 while (i < desc->nr_addrs)
71 void *buffer,
unsigned long bytes)
74 unsigned long buffer_ulong = (
unsigned long)buffer;
76 unsigned long end = (buffer_ulong +
bytes) | ~PAGE_MASK;
77 unsigned long nr_addrs = (end - start + 1) >>
PAGE_SHIFT;
78 unsigned long size =
sizeof(*desc) +
79 sizeof(desc->
address[0]) * nr_addrs;
86 if (
sizeof(*desc) >
sizeof(
void *)) {
110 if (
sizeof(*desc__) >
sizeof(
void *)) {
111 unsigned long size =
sizeof(*desc__) +
120 static int xencomm_create(
void *buffer,
unsigned long bytes,
126 pr_debug(
"%s: %p[%ld]\n", __func__, buffer, bytes);
137 desc = xencomm_alloc(gfp_mask, buffer, bytes);
143 rc = xencomm_init(desc, buffer, bytes);
154 static struct xencomm_handle *xencomm_create_inline(
void *
ptr)
158 BUG_ON(!xencomm_is_phys_contiguous((
unsigned long)ptr));
160 paddr = (
unsigned long)xencomm_pa(ptr);
166 static int xencomm_create_mini(
void *buffer,
172 BUG_ON(((
unsigned long)xc_desc) %
sizeof(*xc_desc) != 0);
174 desc = (
void *)xc_desc;
178 rc = xencomm_init(desc, buffer, bytes);
185 struct xencomm_handle *
xencomm_map(
void *ptr,
unsigned long bytes)
190 if (xencomm_is_phys_contiguous((
unsigned long)ptr))
191 return xencomm_create_inline(ptr);
193 rc = xencomm_create(ptr, bytes, &desc,
GFP_KERNEL);
195 if (rc || desc ==
NULL)
198 return xencomm_pa(desc);
207 if (xencomm_is_phys_contiguous((
unsigned long)ptr))
208 return xencomm_create_inline(ptr);
210 rc = xencomm_create_mini(ptr, bytes, xc_desc,
216 return xencomm_pa(desc);