]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ARC: Hostlink Pseudo-Driver for Metaware Debugger
authorVineet Gupta <vgupta@synopsys.com>
Fri, 18 Jan 2013 09:42:25 +0000 (15:12 +0530)
committerVineet Gupta <vgupta@synopsys.com>
Fri, 15 Feb 2013 17:46:10 +0000 (23:16 +0530)
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>
arch/arc/Kconfig
arch/arc/kernel/Makefile
arch/arc/kernel/arc_hostlink.c [new file with mode: 0644]

index 2611a60cb0598994b1d8de8ee925b578f3a3e343..cd4ad61c4c14bf7343fead74f23b38f5faddc62f 100644 (file)
@@ -389,6 +389,15 @@ config HZ
        int "Timer Frequency"
        default 100
 
+config ARC_METAWARE_HLINK
+       bool "Support for Metaware debugger assisted Host access"
+       default n
+       help
+         This options allows a Linux userland apps to directly access
+         host file system (open/creat/read/write etc) with help from
+         Metaware Debugger. This can come in handy for Linux-host communication
+         when there is no real usable peripheral such as EMAC.
+
 menuconfig ARC_DBG
        bool "ARC debugging"
        default y
index 6da2b12cf7e3b8ec24bf87541beacc225228fc8d..c242ef07ba704d5437edeacd7dddf7e414431876 100644 (file)
@@ -18,6 +18,7 @@ obj-$(CONFIG_ARC_DW2_UNWIND)          += unwind.o
 obj-$(CONFIG_KPROBES)                  += kprobes.o
 obj-$(CONFIG_ARC_MISALIGN_ACCESS)      += unaligned.o
 obj-$(CONFIG_KGDB)                     += kgdb.o
+obj-$(CONFIG_ARC_METAWARE_HLINK)       += arc_hostlink.o
 
 obj-$(CONFIG_ARC_FPU_SAVE_RESTORE)     += fpu.o
 CFLAGS_fpu.o   += -mdpfp
diff --git a/arch/arc/kernel/arc_hostlink.c b/arch/arc/kernel/arc_hostlink.c
new file mode 100644 (file)
index 0000000..47b2a17
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * arc_hostlink.c: Pseudo-driver for Metaware provided "hostlink" facility
+ *
+ * Allows Linux userland access to host in absence of any peripherals.
+ *
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/fs.h>          /* file_operations */
+#include <linux/miscdevice.h>
+#include <linux/mm.h>          /* VM_IO */
+#include <linux/module.h>
+#include <linux/uaccess.h>
+
+static unsigned char __HOSTLINK__[4 * PAGE_SIZE] __aligned(PAGE_SIZE);
+
+static int arc_hl_mmap(struct file *fp, struct vm_area_struct *vma)
+{
+       vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+
+       if (io_remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
+                              vma->vm_end - vma->vm_start,
+                              vma->vm_page_prot)) {
+               pr_warn("Hostlink buffer mmap ERROR\n");
+               return -EAGAIN;
+       }
+       return 0;
+}
+
+static long arc_hl_ioctl(struct file *file, unsigned int cmd,
+                       unsigned long arg)
+{
+       /* we only support, returning the physical addr to mmap in user space */
+       put_user((unsigned int)__HOSTLINK__, (int __user *)arg);
+       return 0;
+}
+
+static const struct file_operations arc_hl_fops = {
+       .unlocked_ioctl = arc_hl_ioctl,
+       .mmap           = arc_hl_mmap,
+};
+
+static struct miscdevice arc_hl_dev = {
+       .minor  = MISC_DYNAMIC_MINOR,
+       .name   = "hostlink",
+       .fops   = &arc_hl_fops
+};
+
+static int __init arc_hl_init(void)
+{
+       pr_info("ARC Hostlink driver mmap at 0x%p\n", __HOSTLINK__);
+       return misc_register(&arc_hl_dev);
+}
+module_init(arc_hl_init);