linux/generic: update & refresh 2.6.36 & 2.6.37. (closes #8324)
[openwrt.git] / target / linux / goldfish / patches-2.6.30 / 0133--ARM-goldfish-qemutrace-Add-mmap-support.patch
1 From 2309613958ee518f94f1a7ba900e08e604e06048 Mon Sep 17 00:00:00 2001
2 From: Jack Veenstra <veenstra@android.com>
3 Date: Fri, 1 May 2009 18:50:10 -0700
4 Subject: [PATCH 133/134] [ARM] goldfish: qemutrace: Add mmap support.
5
6 This makes a page of data available for writing from user-space to allow
7 the Dalvik interpreter to send method trace information to the emulator.
8
9 Signed-off-by: Jack Veenstra <veenstra@android.com>
10 ---
11 drivers/misc/qemutrace/qemu_trace.c | 35 ++++++++++++++++++++++++++++++++++-
12 1 files changed, 34 insertions(+), 1 deletions(-)
13
14 --- a/drivers/misc/qemutrace/qemu_trace.c
15 +++ b/drivers/misc/qemutrace/qemu_trace.c
16 @@ -53,6 +53,7 @@
17
18 static unsigned char __iomem *qt_base;
19 static int init_called;
20 +static uint32_t qemu_trace_paddr;
21
22 /* PIDs that start before our device registered */
23 #define MAX_INIT_PIDS 2048
24 @@ -330,8 +331,30 @@ static void qemu_trace_dump_init_threads
25 }
26 }
27
28 +static int qemu_trace_mmap_fop(struct file *file, struct vm_area_struct *vma)
29 +{
30 + int ret = io_remap_pfn_range(vma, vma->vm_start,
31 + (qemu_trace_paddr >> PAGE_SHIFT) + 1,
32 + PAGE_SIZE, vma->vm_page_prot);
33 + if (ret < 0)
34 + return ret;
35 + return 0;
36 +}
37 +
38 +static const struct file_operations qemu_trace_fops = {
39 + .owner = THIS_MODULE,
40 + .mmap = qemu_trace_mmap_fop,
41 +};
42 +
43 +static struct miscdevice qemu_trace_device = {
44 + .minor = MISC_DYNAMIC_MINOR,
45 + .name = "qemu_trace",
46 + .fops = &qemu_trace_fops,
47 +};
48 +
49 static int qemu_trace_probe(struct platform_device *pdev)
50 {
51 + int err;
52 struct resource *r;
53
54 /* not thread safe, but this should not happen */
55 @@ -340,18 +363,28 @@ static int qemu_trace_probe(struct platf
56 return -ENODEV;
57 }
58 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
59 - if (r == NULL)
60 + if (r == NULL || r->end - r->start < 2 * PAGE_SIZE - 1)
61 return -EINVAL;
62 + qemu_trace_paddr = r->start;
63 qt_base = ioremap(r->start, PAGE_SIZE);
64 printk(KERN_INFO "QEMU TRACE Device: The mapped IO base is %p\n", qt_base);
65
66 qemu_trace_dump_init_threads();
67 + err = misc_register(&qemu_trace_device);
68 + if (err)
69 + goto err_misc_register;
70
71 return 0;
72 +
73 +err_misc_register:
74 + iounmap(qt_base);
75 + qt_base = NULL;
76 + return err;
77 }
78
79 static int qemu_trace_remove(struct platform_device *pdev)
80 {
81 + misc_deregister(&qemu_trace_device);
82 iounmap(qt_base);
83 qt_base = NULL;
84 return 0;
This page took 0.046035 seconds and 5 git commands to generate.