vhci: build kernel module & library
authorMichel Pollet <buserror@gmail.com>
Sat, 25 Feb 2012 16:25:30 +0000 (16:25 +0000)
committerMichel Pollet <buserror@gmail.com>
Sat, 25 Feb 2012 16:25:30 +0000 (16:25 +0000)
This makefile downloads the vhci bits, hack the a little
and compile them in place.
One done it's left as an excercise to the reader to install
the module where they want.

Example board can then link/compile by adding -I../vhci/include and
-L../vhci/lib to their makefile

Signed-off-by: Michel Pollet <buserror@gmail.com>
examples/vhci/Makefile [new file with mode: 0644]
examples/vhci/patches/hcd-0001-SPIN_LOCK_UNLOCKED-has-been-depreciated.patch [new file with mode: 0644]
examples/vhci/patches/hcd-0002-need-transaction-translator.patch [new file with mode: 0644]
examples/vhci/patches/vhci-0001-Comment-out-function-that-doesn-t-compile.patch [new file with mode: 0644]

diff --git a/examples/vhci/Makefile b/examples/vhci/Makefile
new file mode 100644 (file)
index 0000000..6c3a0f8
--- /dev/null
@@ -0,0 +1,53 @@
+#
+# This makefile attempts to compile the vhci core module and the
+# libusb-vhci library by downloading known tarballs, hacking them
+# a little and compiling them
+# 
+# This has been tested on debian, but coild possibly work in other
+# distro. the only "real" dependency is to have the linux kernel
+# header symlinked at /lib/modules/<your host kernel version/build
+#
+
+HCD_V          = 1.14
+VHCI_V                 = 0.6
+BASE_URL       = http://downloads.sourceforge.net/project/usb-vhci
+
+all: library
+
+module: vhci-hcd-$(HCD_V)/usb-vhci-hcd.ko
+
+vhci-hcd-$(HCD_V)/usb-vhci-hcd.ko: vhci-hcd-$(HCD_V)
+       make -C vhci-hcd-$(HCD_V) \
+               KDIR=/lib/modules/${shell uname -r}/build \
+               CORE_INCLUDE_DIR=$(PWD)/vhci-hcd-$(HCD_V)/linux/2.6.32/drivers/usb/core
+
+vhci-hcd-$(HCD_V).tar.bz2: 
+       wget $(BASE_URL)/linux%20kernel%20module/$@
+
+vhci-hcd-$(HCD_V): vhci-hcd-$(HCD_V).tar.bz2
+       tar jxf $@.tar.bz2 && \
+               cd $@ && \
+               cat ../patches/hcd-*.patch | patch --merge -p1 
+       sed -i -e 's|#define DEBUG|#undef DEBUG|' vhci-hcd-$(HCD_V)/usb-vhci-hcd.c
+
+library: lib/libusb_vhci.a
+
+lib/libusb_vhci.a: module libusb_vhci-$(VHCI_V)
+       ln -snf vhci-hcd-$(HCD_V) linux && \
+               cd libusb_vhci-$(VHCI_V) && \
+               ./configure --prefix=$(PWD) CPPFLAGS="-I$(PWD)" --enable-static --disable-shared && \
+                       make && make install
+
+libusb_vhci-$(VHCI_V).tar.bz2:
+       wget $(BASE_URL)/native%20libraries/libusb_vhci-$(VHCI_V).tar.bz2
+
+libusb_vhci-$(VHCI_V): libusb_vhci-$(VHCI_V).tar.bz2
+       tar jxf $@.tar.bz2 && \
+               cd $@ && \
+               cat ../patches/vhci-*.patch | patch --merge -p1 
+
+clean:
+       rm -rf libusb_vhci-$(VHCI_V) vhci-hcd-$(HCD_V) lib include linux
+
+distclean: clean
+       rm -rf *.tar.bz2
diff --git a/examples/vhci/patches/hcd-0001-SPIN_LOCK_UNLOCKED-has-been-depreciated.patch b/examples/vhci/patches/hcd-0001-SPIN_LOCK_UNLOCKED-has-been-depreciated.patch
new file mode 100644 (file)
index 0000000..95c80e9
--- /dev/null
@@ -0,0 +1,25 @@
+From 39a45915645cf308b8f446867399b33244f006b1 Mon Sep 17 00:00:00 2001
+From: root <root@ttyridal.(none)>
+Date: Sun, 19 Feb 2012 17:20:55 +0100
+Subject: [PATCH 1/2] SPIN_LOCK_UNLOCKED has been depreciated
+
+---
+ usb-vhci-hcd.c |    2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/usb-vhci-hcd.c b/usb-vhci-hcd.c
+index fed46aa..b107e1b 100644
+--- a/usb-vhci-hcd.c
++++ b/usb-vhci-hcd.c
+@@ -1040,7 +1040,7 @@ static int device_enum(struct device *dev, void *data)
+       return unlikely(*((const int *)data) == pdev->id) ? -EINVAL : 0;
+ }
+-static spinlock_t dev_enum_lock = SPIN_LOCK_UNLOCKED;
++static DEFINE_SPINLOCK(dev_enum_lock);
+ int usb_vhci_hcd_register(const struct usb_vhci_ifc *ifc, void *context, u8 port_count, struct usb_vhci_device **vdev_ret)
+ {
+-- 
+1.7.5.4
+
diff --git a/examples/vhci/patches/hcd-0002-need-transaction-translator.patch b/examples/vhci/patches/hcd-0002-need-transaction-translator.patch
new file mode 100644 (file)
index 0000000..5dab784
--- /dev/null
@@ -0,0 +1,25 @@
+From 11483dc8c623b93c1ab419a48387161abcf75a45 Mon Sep 17 00:00:00 2001
+From: root <root@ttyridal.(none)>
+Date: Sun, 19 Feb 2012 17:21:07 +0100
+Subject: [PATCH 2/2] need transaction translator
+
+---
+ usb-vhci-hcd.c |    2 ++
+ 1 files changed, 2 insertions(+), 0 deletions(-)
+
+diff --git a/usb-vhci-hcd.c b/usb-vhci-hcd.c
+index b107e1b..fcb9755 100644
+--- a/usb-vhci-hcd.c
++++ b/usb-vhci-hcd.c
+@@ -921,6 +921,8 @@ static int vhci_hcd_probe(struct platform_device *pdev)
+       if(unlikely(!hcd)) return -ENOMEM;
+       vdev->vhc = usbhcd_to_vhcihcd(hcd);
++    hcd->has_tt=1;
++
+       retval = usb_add_hcd(hcd, 0, 0); // calls vhci_start
+       if(unlikely(retval)) usb_put_hcd(hcd);
+-- 
+1.7.5.4
+
diff --git a/examples/vhci/patches/vhci-0001-Comment-out-function-that-doesn-t-compile.patch b/examples/vhci/patches/vhci-0001-Comment-out-function-that-doesn-t-compile.patch
new file mode 100644 (file)
index 0000000..0db9beb
--- /dev/null
@@ -0,0 +1,29 @@
+From 8450b39ce40b2cc2e9e7cf3cfceaafdae2605f17 Mon Sep 17 00:00:00 2001
+From: Torbjorn Tyridal <ttyridal@cisco.com>
+Date: Thu, 23 Feb 2012 13:37:19 +0100
+Subject: [PATCH] Comment out function that doesn't compile
+
+---
+ src/libusb_vhci.c |    8 ++++----
+ 1 files changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/src/libusb_vhci.c b/src/libusb_vhci.c
+index 47fc381..002d7aa 100644
+--- a/src/libusb_vhci.c
++++ b/src/libusb_vhci.c
+@@ -389,8 +389,8 @@ int usb_vhci_to_iso_packets_errno(int32_t status)
+       return usb_vhci_to_errno(status, 0);
+ }
+-int32_t usb_vhci_from_iso_packets_errno(int errno)
+-{
+-      return usb_vhci_from_errno(errno, 0);
+-}
++// int32_t usb_vhci_from_iso_packets_errno(int errno)
++// {
++//    return usb_vhci_from_errno(errno, 0);
++// }
+-- 
+1.7.5.4
+