1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/slab.h>
3 #include <linux/types.h>
8 #include <xen/xenbus.h>
12 static ssize_t
xsd_read(struct file
*file
, char __user
*buf
,
13 size_t size
, loff_t
*off
)
15 const char *str
= (const char *)file
->private_data
;
16 return simple_read_from_buffer(buf
, size
, off
, str
, strlen(str
));
19 static int xsd_release(struct inode
*inode
, struct file
*file
)
21 kfree(file
->private_data
);
25 static int xsd_kva_open(struct inode
*inode
, struct file
*file
)
27 file
->private_data
= (void *)kasprintf(GFP_KERNEL
, "0x%p",
29 if (!file
->private_data
)
34 static int xsd_kva_mmap(struct file
*file
, struct vm_area_struct
*vma
)
36 size_t size
= vma
->vm_end
- vma
->vm_start
;
38 if ((size
> PAGE_SIZE
) || (vma
->vm_pgoff
!= 0))
41 if (remap_pfn_range(vma
, vma
->vm_start
,
42 virt_to_pfn(xen_store_interface
),
43 size
, vma
->vm_page_prot
))
49 const struct file_operations xsd_kva_file_ops
= {
53 .release
= xsd_release
,
56 static int xsd_port_open(struct inode
*inode
, struct file
*file
)
58 file
->private_data
= (void *)kasprintf(GFP_KERNEL
, "%d",
60 if (!file
->private_data
)
65 const struct file_operations xsd_port_file_ops
= {
66 .open
= xsd_port_open
,
68 .release
= xsd_release
,