1 #include <linux/slab.h>
2 #include <linux/types.h>
9 #include "../xenbus/xenbus_comms.h"
11 static ssize_t
xsd_read(struct file
*file
, char __user
*buf
,
12 size_t size
, loff_t
*off
)
14 const char *str
= (const char *)file
->private_data
;
15 return simple_read_from_buffer(buf
, size
, off
, str
, strlen(str
));
18 static int xsd_release(struct inode
*inode
, struct file
*file
)
20 kfree(file
->private_data
);
24 static int xsd_kva_open(struct inode
*inode
, struct file
*file
)
26 file
->private_data
= (void *)kasprintf(GFP_KERNEL
, "0x%p",
28 if (!file
->private_data
)
33 static int xsd_kva_mmap(struct file
*file
, struct vm_area_struct
*vma
)
35 size_t size
= vma
->vm_end
- vma
->vm_start
;
37 if ((size
> PAGE_SIZE
) || (vma
->vm_pgoff
!= 0))
40 if (remap_pfn_range(vma
, vma
->vm_start
,
41 virt_to_pfn(xen_store_interface
),
42 size
, vma
->vm_page_prot
))
48 const struct file_operations xsd_kva_file_ops
= {
52 .release
= xsd_release
,
55 static int xsd_port_open(struct inode
*inode
, struct file
*file
)
57 file
->private_data
= (void *)kasprintf(GFP_KERNEL
, "%d",
59 if (!file
->private_data
)
64 const struct file_operations xsd_port_file_ops
= {
65 .open
= xsd_port_open
,
67 .release
= xsd_release
,