diff options
author | Vineet Gupta <vgupta@synopsys.com> | 2013-01-18 04:42:25 -0500 |
---|---|---|
committer | Vineet Gupta <vgupta@synopsys.com> | 2013-02-15 12:46:10 -0500 |
commit | cbe056f76a386708f3807b274322f78269aee0f6 (patch) | |
tree | a64ad404b3f912c3885881b32aba3b5559b3333a | |
parent | 8b5850f8ac8d9b809db4588b80b568faca5aaaaf (diff) |
ARC: Hostlink Pseudo-Driver for Metaware Debugger
This allows ARC Target to do I/O to host in absence of any peripherals
whatsoever, assisted by Metaware Hostlink facility.
Further we have a FUSE based filesystem which makes us mount/access host
filesystem on target and do fops.
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
-rw-r--r-- | arch/arc/Kconfig | 9 | ||||
-rw-r--r-- | arch/arc/kernel/Makefile | 1 | ||||
-rw-r--r-- | arch/arc/kernel/arc_hostlink.c | 58 |
3 files changed, 68 insertions, 0 deletions
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index 2611a60cb059..cd4ad61c4c14 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig | |||
@@ -389,6 +389,15 @@ config HZ | |||
389 | int "Timer Frequency" | 389 | int "Timer Frequency" |
390 | default 100 | 390 | default 100 |
391 | 391 | ||
392 | config ARC_METAWARE_HLINK | ||
393 | bool "Support for Metaware debugger assisted Host access" | ||
394 | default n | ||
395 | help | ||
396 | This options allows a Linux userland apps to directly access | ||
397 | host file system (open/creat/read/write etc) with help from | ||
398 | Metaware Debugger. This can come in handy for Linux-host communication | ||
399 | when there is no real usable peripheral such as EMAC. | ||
400 | |||
392 | menuconfig ARC_DBG | 401 | menuconfig ARC_DBG |
393 | bool "ARC debugging" | 402 | bool "ARC debugging" |
394 | default y | 403 | default y |
diff --git a/arch/arc/kernel/Makefile b/arch/arc/kernel/Makefile index 6da2b12cf7e3..c242ef07ba70 100644 --- a/arch/arc/kernel/Makefile +++ b/arch/arc/kernel/Makefile | |||
@@ -18,6 +18,7 @@ obj-$(CONFIG_ARC_DW2_UNWIND) += unwind.o | |||
18 | obj-$(CONFIG_KPROBES) += kprobes.o | 18 | obj-$(CONFIG_KPROBES) += kprobes.o |
19 | obj-$(CONFIG_ARC_MISALIGN_ACCESS) += unaligned.o | 19 | obj-$(CONFIG_ARC_MISALIGN_ACCESS) += unaligned.o |
20 | obj-$(CONFIG_KGDB) += kgdb.o | 20 | obj-$(CONFIG_KGDB) += kgdb.o |
21 | obj-$(CONFIG_ARC_METAWARE_HLINK) += arc_hostlink.o | ||
21 | 22 | ||
22 | obj-$(CONFIG_ARC_FPU_SAVE_RESTORE) += fpu.o | 23 | obj-$(CONFIG_ARC_FPU_SAVE_RESTORE) += fpu.o |
23 | CFLAGS_fpu.o += -mdpfp | 24 | CFLAGS_fpu.o += -mdpfp |
diff --git a/arch/arc/kernel/arc_hostlink.c b/arch/arc/kernel/arc_hostlink.c new file mode 100644 index 000000000000..47b2a17cc52a --- /dev/null +++ b/arch/arc/kernel/arc_hostlink.c | |||
@@ -0,0 +1,58 @@ | |||
1 | /* | ||
2 | * arc_hostlink.c: Pseudo-driver for Metaware provided "hostlink" facility | ||
3 | * | ||
4 | * Allows Linux userland access to host in absence of any peripherals. | ||
5 | * | ||
6 | * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | #include <linux/fs.h> /* file_operations */ | ||
14 | #include <linux/miscdevice.h> | ||
15 | #include <linux/mm.h> /* VM_IO */ | ||
16 | #include <linux/module.h> | ||
17 | #include <linux/uaccess.h> | ||
18 | |||
19 | static unsigned char __HOSTLINK__[4 * PAGE_SIZE] __aligned(PAGE_SIZE); | ||
20 | |||
21 | static int arc_hl_mmap(struct file *fp, struct vm_area_struct *vma) | ||
22 | { | ||
23 | vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); | ||
24 | |||
25 | if (io_remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, | ||
26 | vma->vm_end - vma->vm_start, | ||
27 | vma->vm_page_prot)) { | ||
28 | pr_warn("Hostlink buffer mmap ERROR\n"); | ||
29 | return -EAGAIN; | ||
30 | } | ||
31 | return 0; | ||
32 | } | ||
33 | |||
34 | static long arc_hl_ioctl(struct file *file, unsigned int cmd, | ||
35 | unsigned long arg) | ||
36 | { | ||
37 | /* we only support, returning the physical addr to mmap in user space */ | ||
38 | put_user((unsigned int)__HOSTLINK__, (int __user *)arg); | ||
39 | return 0; | ||
40 | } | ||
41 | |||
42 | static const struct file_operations arc_hl_fops = { | ||
43 | .unlocked_ioctl = arc_hl_ioctl, | ||
44 | .mmap = arc_hl_mmap, | ||
45 | }; | ||
46 | |||
47 | static struct miscdevice arc_hl_dev = { | ||
48 | .minor = MISC_DYNAMIC_MINOR, | ||
49 | .name = "hostlink", | ||
50 | .fops = &arc_hl_fops | ||
51 | }; | ||
52 | |||
53 | static int __init arc_hl_init(void) | ||
54 | { | ||
55 | pr_info("ARC Hostlink driver mmap at 0x%p\n", __HOSTLINK__); | ||
56 | return misc_register(&arc_hl_dev); | ||
57 | } | ||
58 | module_init(arc_hl_init); | ||