From b047b4dc190c03ca20078391f4da5cf28aac53ea Mon Sep 17 00:00:00 2001 From: cvsdist Date: Thu, 9 Sep 2004 07:38:34 +0000 Subject: [PATCH 001/100] Setup of module libraw1394 --- .cvsignore | 0 Makefile | 6 ++++++ sources | 0 3 files changed, 6 insertions(+) create mode 100644 .cvsignore create mode 100644 Makefile create mode 100644 sources diff --git a/.cvsignore b/.cvsignore new file mode 100644 index 0000000..e69de29 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1c57459 --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ +# Makefile for source rpm: libraw1394 +# $Id$ +NAME := libraw1394 +SPECFILE = $(firstword $(wildcard *.spec)) + +include ../common/Makefile.common diff --git a/sources b/sources new file mode 100644 index 0000000..e69de29 From 2eb984f781730cade17998ce1d33563414b2ef68 Mon Sep 17 00:00:00 2001 From: cvsdist Date: Thu, 9 Sep 2004 07:38:36 +0000 Subject: [PATCH 002/100] auto-import changelog data from libraw1394-0.9.0-5.src.rpm Wed Jun 19 2002 Michael Fulbright - fixed up %files list for devel subpackage and included api docs Sun Jun 09 2002 Michael Fulbright - First RPM build --- .cvsignore | 1 + libraw1394.spec | 71 +++++++++++++++++++++++++++++++++++++++++++++++++ sources | 1 + 3 files changed, 73 insertions(+) create mode 100644 libraw1394.spec diff --git a/.cvsignore b/.cvsignore index e69de29..1d14064 100644 --- a/.cvsignore +++ b/.cvsignore @@ -0,0 +1 @@ +libraw1394_0.9.0.tar.gz diff --git a/libraw1394.spec b/libraw1394.spec new file mode 100644 index 0000000..5443c7d --- /dev/null +++ b/libraw1394.spec @@ -0,0 +1,71 @@ +%define name libraw1394 +%define version 0.9.0 +%define release 5 + +Summary: Library providing low-level IEEE-1394 access +Name: %{name} +Version: %{version} +Release: %{release} +Copyright: GPL +Group: Applications/Multimedia +Source: http://download.sourceforge.net/libraw1394/libraw1394_0.9.0.tar.gz +BuildRoot: /var/tmp/%{name}-%{version}-root + +%description +The libraw1394 library provides direct access to the +IEEE-1394 bus through the Linux 1394 subsystem's raw1394 user space +interface. + +%package devel +Summary: Development libs for libraw1394 +Group: Development/Libraries + +%description devel +Development libraries needed to build applications against libraw1394. + +%prep +%setup + +%build +%configure +make + +%install +rm -rf %{buildroot} +make install DESTDIR=$RPM_BUILD_ROOT + +%clean +rm -rf $RPM_BUILD_ROOT + +%post +/sbin/ldconfig + +%postun +/sbin/ldconfig + + +%files +%defattr(-,root,root) +%doc COPYING INSTALL README +%doc /usr/share/man/man1/testlibraw.1.gz +/usr/bin/testlibraw +/usr/lib/libraw1394.so.5.0.0 + +%files devel +%defattr(-,root,root) +/usr/include/libraw1394 +/usr/lib/libraw1394.a +/usr/lib/libraw1394.la +/usr/lib/libraw1394.so +/usr/share/aclocal/libraw1394.m4 +%doc doc/libraw1394.ps +%doc doc/libraw1394 + + +%changelog +* Wed Jun 19 2002 Michael Fulbright +- fixed up %files list for devel subpackage and included api docs + +* Sun Jun 09 2002 Michael Fulbright +- First RPM build + diff --git a/sources b/sources index e69de29..85b0435 100644 --- a/sources +++ b/sources @@ -0,0 +1 @@ +56fc0bc6f00efdebb635dcc52d91f7bc libraw1394_0.9.0.tar.gz From a51c58b87ca0ef42dad67b7614033409906dd208 Mon Sep 17 00:00:00 2001 From: cvsdist Date: Thu, 9 Sep 2004 07:39:05 +0000 Subject: [PATCH 003/100] auto-import changelog data from libraw1394-0.9.0-6.src.rpm Fri Jun 21 2002 Tim Powers - automated rebuild --- libraw1394.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index 5443c7d..cd77135 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,6 +1,6 @@ %define name libraw1394 %define version 0.9.0 -%define release 5 +%define release 6 Summary: Library providing low-level IEEE-1394 access Name: %{name} @@ -63,6 +63,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Fri Jun 21 2002 Tim Powers +- automated rebuild + * Wed Jun 19 2002 Michael Fulbright - fixed up %files list for devel subpackage and included api docs From 889042b43f87c8b4cecb508d468f5e04c6f53a31 Mon Sep 17 00:00:00 2001 From: cvsdist Date: Thu, 9 Sep 2004 07:39:15 +0000 Subject: [PATCH 004/100] auto-import changelog data from libraw1394-0.9.0-8.src.rpm Wed Jan 22 2003 Tim Powers - rebuilt Wed Nov 20 2002 Florian La Roche - exclude mainframe - allow lib64 --- libraw1394.spec | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/libraw1394.spec b/libraw1394.spec index cd77135..76801eb 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,6 +1,6 @@ %define name libraw1394 %define version 0.9.0 -%define release 6 +%define release 8 Summary: Library providing low-level IEEE-1394 access Name: %{name} @@ -9,6 +9,7 @@ Release: %{release} Copyright: GPL Group: Applications/Multimedia Source: http://download.sourceforge.net/libraw1394/libraw1394_0.9.0.tar.gz +ExcludeArch: s390 s390x BuildRoot: /var/tmp/%{name}-%{version}-root %description @@ -49,20 +50,27 @@ rm -rf $RPM_BUILD_ROOT %doc COPYING INSTALL README %doc /usr/share/man/man1/testlibraw.1.gz /usr/bin/testlibraw -/usr/lib/libraw1394.so.5.0.0 +%{_libdir}/libraw1394.so.5.0.0 %files devel %defattr(-,root,root) /usr/include/libraw1394 -/usr/lib/libraw1394.a -/usr/lib/libraw1394.la -/usr/lib/libraw1394.so +%{_libdir}/libraw1394.a +%{_libdir}/libraw1394.la +%{_libdir}/libraw1394.so /usr/share/aclocal/libraw1394.m4 %doc doc/libraw1394.ps %doc doc/libraw1394 %changelog +* Wed Jan 22 2003 Tim Powers +- rebuilt + +* Wed Nov 20 2002 Florian La Roche +- exclude mainframe +- allow lib64 + * Fri Jun 21 2002 Tim Powers - automated rebuild From 2b5d98e5650e4ffb4bdd07adeaedca80aa0b7d98 Mon Sep 17 00:00:00 2001 From: cvsdist Date: Thu, 9 Sep 2004 07:39:52 +0000 Subject: [PATCH 005/100] auto-import changelog data from libraw1394-0.9.0-12.src.rpm Mon Aug 25 2003 Bill Nottingham 0.9.0-12 - have -devel require main pacakge Wed Jun 04 2003 Elliot Lee - rebuilt Thu May 22 2003 Jeremy Katz 0.9.0-10 - fix build with gcc 3.3 Mon Feb 17 2003 Elliot Lee - ppc64 fix --- libraw1394.spec | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/libraw1394.spec b/libraw1394.spec index 76801eb..37ac611 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,16 +1,14 @@ -%define name libraw1394 -%define version 0.9.0 -%define release 8 - Summary: Library providing low-level IEEE-1394 access -Name: %{name} -Version: %{version} -Release: %{release} -Copyright: GPL +Name: libraw1394 +Version: 0.9.0 +Release: 12 +License: GPL Group: Applications/Multimedia Source: http://download.sourceforge.net/libraw1394/libraw1394_0.9.0.tar.gz +Patch0: libraw1394-0.9.0-gcc33.patch ExcludeArch: s390 s390x -BuildRoot: /var/tmp/%{name}-%{version}-root +BuildRequires: libtool automake autoconf +BuildRoot: %{_tmppath}/%{name}-%{version}-root %description The libraw1394 library provides direct access to the @@ -20,12 +18,18 @@ interface. %package devel Summary: Development libs for libraw1394 Group: Development/Libraries +Requires: %{name} = %{version}-%{release} %description devel Development libraries needed to build applications against libraw1394. %prep %setup +%patch0 -p1 -b .gcc33 +libtoolize --force +aclocal +automake --add-missing +autoconf %build %configure @@ -38,12 +42,9 @@ make install DESTDIR=$RPM_BUILD_ROOT %clean rm -rf $RPM_BUILD_ROOT -%post -/sbin/ldconfig - -%postun -/sbin/ldconfig +%post -p /sbin/ldconfig +%postun -p /sbin/ldconfig %files %defattr(-,root,root) @@ -64,6 +65,18 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Mon Aug 25 2003 Bill Nottingham 0.9.0-12 +- have -devel require main pacakge + +* Wed Jun 04 2003 Elliot Lee +- rebuilt + +* Thu May 22 2003 Jeremy Katz 0.9.0-10 +- fix build with gcc 3.3 + +* Mon Feb 17 2003 Elliot Lee +- ppc64 fix + * Wed Jan 22 2003 Tim Powers - rebuilt From 744fe97ec038acb3bfe45cb610f7079c882face0 Mon Sep 17 00:00:00 2001 From: cvsdist Date: Thu, 9 Sep 2004 07:40:18 +0000 Subject: [PATCH 006/100] auto-import changelog data from libraw1394-0.10.0-2.1.src.rpm Tue Mar 02 2004 Elliot Lee - rebuilt Sat Feb 21 2004 Florian La Roche - add symlinks to shared libs already at install time Thu Feb 12 2004 Warren Togami 0.10.0-1 - upgrade to 0.10.0 - Spec cleanups - Remove INSTALL, add NEWS - Add new binaries - libtool, auto* not needed --- .cvsignore | 2 +- libraw1394.spec | 73 +++++++++++++++++++++++++++++++------------------ sources | 2 +- 3 files changed, 48 insertions(+), 29 deletions(-) diff --git a/.cvsignore b/.cvsignore index 1d14064..6a7b1ef 100644 --- a/.cvsignore +++ b/.cvsignore @@ -1 +1 @@ -libraw1394_0.9.0.tar.gz +libraw1394-0.10.0.tar.gz diff --git a/libraw1394.spec b/libraw1394.spec index 37ac611..8b19b1f 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,19 +1,19 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 -Version: 0.9.0 -Release: 12 +Version: 0.10.0 +Release: 2.1 License: GPL -Group: Applications/Multimedia -Source: http://download.sourceforge.net/libraw1394/libraw1394_0.9.0.tar.gz -Patch0: libraw1394-0.9.0-gcc33.patch +Group: System Environment/Libraries +Source: http://www.linux1394.org/files/libraw1394/libraw1394-0.10.0.tar.gz +URL: http://www.linux1394.org/ ExcludeArch: s390 s390x -BuildRequires: libtool automake autoconf +## not needed +# BuildRequires: libtool automake14 autoconf BuildRoot: %{_tmppath}/%{name}-%{version}-root %description -The libraw1394 library provides direct access to the -IEEE-1394 bus through the Linux 1394 subsystem's raw1394 user space -interface. +The libraw1394 library provides direct access to the IEEE-1394 bus through +the Linux 1394 subsystem's raw1394 user space interface. %package devel Summary: Development libs for libraw1394 @@ -24,20 +24,22 @@ Requires: %{name} = %{version}-%{release} Development libraries needed to build applications against libraw1394. %prep -%setup -%patch0 -p1 -b .gcc33 -libtoolize --force -aclocal -automake --add-missing -autoconf +%setup -q + +## not needed +#libtoolize --force +#aclocal-1.4 +#automake-1.4 --add-missing +#autoconf %build %configure -make +make %{?_smp_mflags} %install -rm -rf %{buildroot} +rm -rf $RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT +/sbin/ldconfig -n $RPM_BUILD_ROOT%{_libdir} %clean rm -rf $RPM_BUILD_ROOT @@ -47,24 +49,41 @@ rm -rf $RPM_BUILD_ROOT %postun -p /sbin/ldconfig %files -%defattr(-,root,root) -%doc COPYING INSTALL README -%doc /usr/share/man/man1/testlibraw.1.gz -/usr/bin/testlibraw -%{_libdir}/libraw1394.so.5.0.0 +%defattr(-,root,root,-) +%doc COPYING README NEWS +%doc %{_mandir}/man1/testlibraw.1.gz +%doc %{_mandir}/man1/dumpiso.1.gz +%doc %{_mandir}/man1/sendiso.1.gz +%doc %{_mandir}/man5/isodump.5.gz +%{_bindir}/testlibraw +%{_bindir}/dumpiso +%{_bindir}/sendiso +%{_libdir}/libraw1394.so.* %files devel -%defattr(-,root,root) -/usr/include/libraw1394 +%defattr(-,root,root,-) +%doc doc/libraw1394.sgml +%{_includedir}/libraw1394 %{_libdir}/libraw1394.a %{_libdir}/libraw1394.la %{_libdir}/libraw1394.so -/usr/share/aclocal/libraw1394.m4 -%doc doc/libraw1394.ps -%doc doc/libraw1394 +%{_datadir}/aclocal/libraw1394.m4 %changelog +* Tue Mar 02 2004 Elliot Lee +- rebuilt + +* Sat Feb 21 2004 Florian La Roche +- add symlinks to shared libs already at install time + +* Thu Feb 12 2004 Warren Togami 0.10.0-1 +- upgrade to 0.10.0 +- Spec cleanups +- Remove INSTALL, add NEWS +- Add new binaries +- libtool, auto* not needed + * Mon Aug 25 2003 Bill Nottingham 0.9.0-12 - have -devel require main pacakge diff --git a/sources b/sources index 85b0435..afa4c65 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -56fc0bc6f00efdebb635dcc52d91f7bc libraw1394_0.9.0.tar.gz +95f4e9a6dbd7543b94e2cc70562d9073 libraw1394-0.10.0.tar.gz From 5225ccbfeb8b7620e029fa72d5fd82b33842c3eb Mon Sep 17 00:00:00 2001 From: cvsdist Date: Thu, 9 Sep 2004 07:40:29 +0000 Subject: [PATCH 007/100] auto-import changelog data from libraw1394-0.10.1-1.src.rpm Mon Apr 05 2004 Warren Togami 0.10.1-1 - 0.10.1, license LGPL --- .cvsignore | 2 +- libraw1394.spec | 14 +++++++++----- sources | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.cvsignore b/.cvsignore index 6a7b1ef..d97f8d6 100644 --- a/.cvsignore +++ b/.cvsignore @@ -1 +1 @@ -libraw1394-0.10.0.tar.gz +libraw1394-0.10.1.tar.gz diff --git a/libraw1394.spec b/libraw1394.spec index 8b19b1f..63a2c5f 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,10 +1,10 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 -Version: 0.10.0 -Release: 2.1 -License: GPL +Version: 0.10.1 +Release: 1 +License: LGPL Group: System Environment/Libraries -Source: http://www.linux1394.org/files/libraw1394/libraw1394-0.10.0.tar.gz +Source: http://www.linux1394.org/files/libraw1394/libraw1394-0.10.1.tar.gz URL: http://www.linux1394.org/ ExcludeArch: s390 s390x ## not needed @@ -50,7 +50,7 @@ rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root,-) -%doc COPYING README NEWS +%doc COPYING.LIB README NEWS %doc %{_mandir}/man1/testlibraw.1.gz %doc %{_mandir}/man1/dumpiso.1.gz %doc %{_mandir}/man1/sendiso.1.gz @@ -68,9 +68,13 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/libraw1394.la %{_libdir}/libraw1394.so %{_datadir}/aclocal/libraw1394.m4 +%{_libdir}/pkgconfig/libraw1394.pc %changelog +* Mon Apr 05 2004 Warren Togami 0.10.1-1 +- 0.10.1, license LGPL + * Tue Mar 02 2004 Elliot Lee - rebuilt diff --git a/sources b/sources index afa4c65..e9e9341 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -95f4e9a6dbd7543b94e2cc70562d9073 libraw1394-0.10.0.tar.gz +f243011cc20d4b7357a48732ea555e3a libraw1394-0.10.1.tar.gz From d5c6c36656ca27449da76d6c21cc7f88a2d968dc Mon Sep 17 00:00:00 2001 From: cvsdist Date: Thu, 9 Sep 2004 07:40:33 +0000 Subject: [PATCH 008/100] auto-import changelog data from libraw1394-0.10.1-2.src.rpm Tue Jun 15 2004 Elliot Lee - rebuilt --- libraw1394.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index 63a2c5f..bbc5e19 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 0.10.1 -Release: 1 +Release: 2 License: LGPL Group: System Environment/Libraries Source: http://www.linux1394.org/files/libraw1394/libraw1394-0.10.1.tar.gz @@ -72,6 +72,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Tue Jun 15 2004 Elliot Lee +- rebuilt + * Mon Apr 05 2004 Warren Togami 0.10.1-1 - 0.10.1, license LGPL From e2a1fd97d2e933f030245ef3b56cef4cd83c9004 Mon Sep 17 00:00:00 2001 From: cvsdist Date: Thu, 9 Sep 2004 07:40:55 +0000 Subject: [PATCH 009/100] auto-import changelog data from libraw1394-0.10.1-3.src.rpm Thu Jul 15 2004 Tim Waugh 0.10.1-3 - Fixed warnings in shipped m4 file. --- libraw1394-underquoted.patch | 47 ++++++++++++++++++++++++++++++++++++ libraw1394.spec | 7 +++++- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 libraw1394-underquoted.patch diff --git a/libraw1394-underquoted.patch b/libraw1394-underquoted.patch new file mode 100644 index 0000000..a1e677d --- /dev/null +++ b/libraw1394-underquoted.patch @@ -0,0 +1,47 @@ +--- libraw1394-0.10.1/libraw1394.m4.underquoted 2004-07-15 12:59:11.467143881 +0100 ++++ libraw1394-0.10.1/libraw1394.m4 2004-07-15 12:59:57.705291918 +0100 +@@ -3,7 +3,7 @@ + dnl This just unconditionally sets the options. It should offer an option for + dnl explicitly giving the path to libraw1394 on the configure command line. + dnl +-AC_DEFUN(AC_LIB_RAW1394_FLAGS, [ ++AC_DEFUN([AC_LIB_RAW1394_FLAGS], [ + LIBRAW1394_CPPFLAGS="" + LIBRAW1394_CFLAGS="" + LIBRAW1394_LIBS="-lraw1394" +@@ -16,7 +16,7 @@ + dnl + dnl AC_LIB_RAW1394_HEADERS([ACTION_IF_FOUND[,ACTION_IF_NOT_FOUND]]) + dnl +-AC_DEFUN(AC_LIB_RAW1394_HEADERS, [ ++AC_DEFUN([AC_LIB_RAW1394_HEADERS], [ + AC_REQUIRE([AC_LIB_RAW1394_FLAGS]) + + ac_libraw1394_save_cppflags=$CPPFLAGS +@@ -38,7 +38,7 @@ + dnl + dnl AC_LIB_RAW1394_LIBVERSION(MINIMUMVERSION[,ACTION_IF_FOUND[,ACTION_IF_NOT_FOUND]]) + dnl +-AC_DEFUN(AC_LIB_RAW1394_LIBVERSION, [ ++AC_DEFUN([AC_LIB_RAW1394_LIBVERSION], [ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_LIB_RAW1394_FLAGS]) + +@@ -72,7 +72,7 @@ + dnl + dnl AC_LIB_RAW1394_RUNTEST(MINIMUMVERSION[,ACTION_IF_FOUND + dnl [,ACTION_IF_NOT_FOUND[,ACTION_IF_CROSS_COMPILING]]]) +-AC_DEFUN(AC_LIB_RAW1394_RUNTEST, [ ++AC_DEFUN([AC_LIB_RAW1394_RUNTEST], [ + ac_libraw1394_save_cppflags=$CPPFLAGS + ac_libraw1394_save_cflags=$CFLAGS + ac_libraw1394_save_libs=$LIBS +@@ -135,7 +135,7 @@ + dnl Versions before 0.9 can't be checked, so this will always fail if the + dnl installed libraw1394 is older than 0.9 as if the library weren't found. + dnl +-AC_DEFUN(AC_LIB_RAW1394, [ ++AC_DEFUN([AC_LIB_RAW1394], [ + + AC_LIB_RAW1394_FLAGS + AC_LIB_RAW1394_HEADERS(ac_libraw1394_found=yes, ac_libraw1394_found=no) diff --git a/libraw1394.spec b/libraw1394.spec index bbc5e19..9ac15ab 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,10 +1,11 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 0.10.1 -Release: 2 +Release: 3 License: LGPL Group: System Environment/Libraries Source: http://www.linux1394.org/files/libraw1394/libraw1394-0.10.1.tar.gz +Patch0: libraw1394-underquoted.patch URL: http://www.linux1394.org/ ExcludeArch: s390 s390x ## not needed @@ -25,6 +26,7 @@ Development libraries needed to build applications against libraw1394. %prep %setup -q +%patch0 -p1 -b .underquoted ## not needed #libtoolize --force @@ -72,6 +74,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Thu Jul 15 2004 Tim Waugh 0.10.1-3 +- Fixed warnings in shipped m4 file. + * Tue Jun 15 2004 Elliot Lee - rebuilt From dcb5933d6ff40ceb067d4b37b227aaa384624154 Mon Sep 17 00:00:00 2001 From: Warren Togami Date: Mon, 7 Feb 2005 01:34:11 +0000 Subject: [PATCH 010/100] 1.1.0 --- .cvsignore | 1 + libraw1394.spec | 20 ++++++-------------- sources | 2 +- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/.cvsignore b/.cvsignore index d97f8d6..46b395d 100644 --- a/.cvsignore +++ b/.cvsignore @@ -1 +1,2 @@ libraw1394-0.10.1.tar.gz +libraw1394-1.1.0.tar.gz diff --git a/libraw1394.spec b/libraw1394.spec index 9ac15ab..34ef307 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,15 +1,12 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 -Version: 0.10.1 -Release: 3 +Version: 1.1.0 +Release: 1 License: LGPL Group: System Environment/Libraries -Source: http://www.linux1394.org/files/libraw1394/libraw1394-0.10.1.tar.gz -Patch0: libraw1394-underquoted.patch +Source: http://www.linux1394.org/dl/libraw1394-1.1.0.tar.gz URL: http://www.linux1394.org/ ExcludeArch: s390 s390x -## not needed -# BuildRequires: libtool automake14 autoconf BuildRoot: %{_tmppath}/%{name}-%{version}-root %description @@ -26,13 +23,6 @@ Development libraries needed to build applications against libraw1394. %prep %setup -q -%patch0 -p1 -b .underquoted - -## not needed -#libtoolize --force -#aclocal-1.4 -#automake-1.4 --add-missing -#autoconf %build %configure @@ -69,11 +59,13 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/libraw1394.a %{_libdir}/libraw1394.la %{_libdir}/libraw1394.so -%{_datadir}/aclocal/libraw1394.m4 %{_libdir}/pkgconfig/libraw1394.pc %changelog +* Sun Feb 06 2005 Warren Togami 1.1.0-1 +- 1.1.0 + * Thu Jul 15 2004 Tim Waugh 0.10.1-3 - Fixed warnings in shipped m4 file. diff --git a/sources b/sources index e9e9341..433afba 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -f243011cc20d4b7357a48732ea555e3a libraw1394-0.10.1.tar.gz +bd0b262d017631c171385db64b6e659d libraw1394-1.1.0.tar.gz From ee7471daee0210ef99b401a5ec87021f60d19fb6 Mon Sep 17 00:00:00 2001 From: Warren Togami Date: Tue, 1 Mar 2005 03:26:21 +0000 Subject: [PATCH 011/100] gcc4 rebuild --- libraw1394.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index 34ef307..5f06a01 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 1.1.0 -Release: 1 +Release: 2 License: LGPL Group: System Environment/Libraries Source: http://www.linux1394.org/dl/libraw1394-1.1.0.tar.gz @@ -63,6 +63,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Mon Feb 28 2005 Warren Togami 1.1.0-1 - 1.1.0 From 9955f63572edc4c0a8e1bc10417f3d7f53919898 Mon Sep 17 00:00:00 2001 From: Elliot Lee Date: Wed, 16 Mar 2005 21:41:07 +0000 Subject: [PATCH 012/100] sync --- libraw1394.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index 5f06a01..8e2e6e8 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 1.1.0 -Release: 2 +Release: 3 License: LGPL Group: System Environment/Libraries Source: http://www.linux1394.org/dl/libraw1394-1.1.0.tar.gz @@ -63,6 +63,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Wed Mar 16 2005 Elliot Lee +- rebuilt + * Mon Feb 28 2005 Warren Togami Date: Sat, 23 Jul 2005 03:00:48 +0000 Subject: [PATCH 013/100] 1.2.0 --- .cvsignore | 3 +-- libraw1394.spec | 9 ++++++--- sources | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.cvsignore b/.cvsignore index 46b395d..d017dcd 100644 --- a/.cvsignore +++ b/.cvsignore @@ -1,2 +1 @@ -libraw1394-0.10.1.tar.gz -libraw1394-1.1.0.tar.gz +libraw1394-1.2.0.tar.gz diff --git a/libraw1394.spec b/libraw1394.spec index 8e2e6e8..353c758 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,10 +1,10 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 -Version: 1.1.0 -Release: 3 +Version: 1.2.0 +Release: 1.fc5 License: LGPL Group: System Environment/Libraries -Source: http://www.linux1394.org/dl/libraw1394-1.1.0.tar.gz +Source: http://www.linux1394.org/dl/libraw1394-1.2.0.tar.gz URL: http://www.linux1394.org/ ExcludeArch: s390 s390x BuildRoot: %{_tmppath}/%{name}-%{version}-root @@ -63,6 +63,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Fri Jul 22 2005 Warren Togami - 1.2.0-1 +- 1.2.0 + * Wed Mar 16 2005 Elliot Lee - rebuilt diff --git a/sources b/sources index 433afba..538611d 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -bd0b262d017631c171385db64b6e659d libraw1394-1.1.0.tar.gz +eea394f74afecd6a22f74110128c9fb6 libraw1394-1.2.0.tar.gz From 10c2bc93dcaa0c41f98ccb074fcb39a12aa9b41d Mon Sep 17 00:00:00 2001 From: Warren Togami Date: Fri, 11 Nov 2005 22:03:52 +0000 Subject: [PATCH 014/100] spec fixes from Matthias (#172105) --- libraw1394.spec | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/libraw1394.spec b/libraw1394.spec index 353c758..797bae6 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,22 +1,22 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 1.2.0 -Release: 1.fc5 +Release: 2.fc5 License: LGPL -Group: System Environment/Libraries -Source: http://www.linux1394.org/dl/libraw1394-1.2.0.tar.gz +Group: System Environment/Libraries +Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz URL: http://www.linux1394.org/ ExcludeArch: s390 s390x BuildRoot: %{_tmppath}/%{name}-%{version}-root %description -The libraw1394 library provides direct access to the IEEE-1394 bus through +The libraw1394 library provides direct access to the IEEE-1394 bus through the Linux 1394 subsystem's raw1394 user space interface. %package devel Summary: Development libs for libraw1394 Group: Development/Libraries -Requires: %{name} = %{version}-%{release} +Requires: %{name} = %{version}-%{release}, pkgconfig %description devel Development libraries needed to build applications against libraw1394. @@ -31,7 +31,6 @@ make %{?_smp_mflags} %install rm -rf $RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT -/sbin/ldconfig -n $RPM_BUILD_ROOT%{_libdir} %clean rm -rf $RPM_BUILD_ROOT @@ -41,28 +40,31 @@ rm -rf $RPM_BUILD_ROOT %postun -p /sbin/ldconfig %files -%defattr(-,root,root,-) +%defattr(-,root,root,0755) %doc COPYING.LIB README NEWS -%doc %{_mandir}/man1/testlibraw.1.gz -%doc %{_mandir}/man1/dumpiso.1.gz -%doc %{_mandir}/man1/sendiso.1.gz -%doc %{_mandir}/man5/isodump.5.gz -%{_bindir}/testlibraw %{_bindir}/dumpiso %{_bindir}/sendiso +%{_bindir}/testlibraw %{_libdir}/libraw1394.so.* +%{_mandir}/man1/dumpiso.1.gz +%{_mandir}/man1/sendiso.1.gz +%{_mandir}/man1/testlibraw.1.gz +%{_mandir}/man5/isodump.5.gz %files devel -%defattr(-,root,root,-) +%defattr(-,root,root,0755) %doc doc/libraw1394.sgml -%{_includedir}/libraw1394 +%{_includedir}/libraw1394/ %{_libdir}/libraw1394.a -%{_libdir}/libraw1394.la +%exclude %{_libdir}/libraw1394.la %{_libdir}/libraw1394.so %{_libdir}/pkgconfig/libraw1394.pc %changelog +* Fri Nov 11 2005 Warren Togami - 1.2.0-2 +- spec fixes from Matthias (#172105) + * Fri Jul 22 2005 Warren Togami - 1.2.0-1 - 1.2.0 From 5ae0ad750e99236a89800d48604799cd905ba69a Mon Sep 17 00:00:00 2001 From: Jesse Keating Date: Fri, 9 Dec 2005 22:41:40 +0000 Subject: [PATCH 015/100] gcc update bump --- libraw1394.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index 797bae6..0f62a9c 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 1.2.0 -Release: 2.fc5 +Release: 2.fc5.1 License: LGPL Group: System Environment/Libraries Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz @@ -62,6 +62,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Fri Dec 09 2005 Jesse Keating +- rebuilt + * Fri Nov 11 2005 Warren Togami - 1.2.0-2 - spec fixes from Matthias (#172105) From c3a8479c4eefff96b3577560c77c2e49ee502880 Mon Sep 17 00:00:00 2001 From: Warren Togami Date: Tue, 13 Dec 2005 22:06:28 +0000 Subject: [PATCH 016/100] disable static and remove .la (#172642) --- libraw1394.spec | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libraw1394.spec b/libraw1394.spec index 0f62a9c..9c6b8e7 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 1.2.0 -Release: 2.fc5.1 +Release: 3.fc5 License: LGPL Group: System Environment/Libraries Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz @@ -25,12 +25,13 @@ Development libraries needed to build applications against libraw1394. %setup -q %build -%configure +%configure --disable-static make %{?_smp_mflags} %install rm -rf $RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT +rm -f $RPM_BUILD_ROOT%{_libdir}/libraw1394.la %clean rm -rf $RPM_BUILD_ROOT @@ -55,13 +56,14 @@ rm -rf $RPM_BUILD_ROOT %defattr(-,root,root,0755) %doc doc/libraw1394.sgml %{_includedir}/libraw1394/ -%{_libdir}/libraw1394.a -%exclude %{_libdir}/libraw1394.la %{_libdir}/libraw1394.so %{_libdir}/pkgconfig/libraw1394.pc %changelog +* Tue Dec 13 2005 Warren Togami - 1.2.0-3 +- disable static and remove .la (#172642) + * Fri Dec 09 2005 Jesse Keating - rebuilt From 3509bb9f4511e8a5683addeaf4b3e3cfbaba1399 Mon Sep 17 00:00:00 2001 From: Jesse Keating Date: Tue, 7 Feb 2006 12:43:14 +0000 Subject: [PATCH 017/100] bump for new gcc/glibc --- libraw1394.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index 9c6b8e7..448e64e 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 1.2.0 -Release: 3.fc5 +Release: 3.fc5.1 License: LGPL Group: System Environment/Libraries Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz @@ -61,6 +61,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Tue Feb 07 2006 Jesse Keating - 1.2.0-3.fc5.1 +- rebuilt for new gcc4.1 snapshot and glibc changes + * Tue Dec 13 2005 Warren Togami - 1.2.0-3 - disable static and remove .la (#172642) From aced8c5039eb7b87ddad769e8e4a0ffa776cc4a0 Mon Sep 17 00:00:00 2001 From: Jesse Keating Date: Sat, 11 Feb 2006 04:11:44 +0000 Subject: [PATCH 018/100] bump for bug in double-long on ppc(64) --- libraw1394.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index 448e64e..731f7d0 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 1.2.0 -Release: 3.fc5.1 +Release: 3.fc5.2 License: LGPL Group: System Environment/Libraries Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz @@ -61,6 +61,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Fri Feb 10 2006 Jesse Keating - 1.2.0-3.fc5.2 +- bump again for double-long bug on ppc(64) + * Tue Feb 07 2006 Jesse Keating - 1.2.0-3.fc5.1 - rebuilt for new gcc4.1 snapshot and glibc changes From a14c17c551c18d02f7ad4e95f326bb5f1373dfd7 Mon Sep 17 00:00:00 2001 From: Jesse Keating Date: Wed, 12 Jul 2006 06:55:35 +0000 Subject: [PATCH 019/100] bumped for rebuild --- libraw1394.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index 731f7d0..1d5cf27 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 1.2.0 -Release: 3.fc5.2 +Release: 3.fc5.2.1 License: LGPL Group: System Environment/Libraries Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz @@ -61,6 +61,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Wed Jul 12 2006 Jesse Keating - 1.2.0-3.fc5.2.1 +- rebuild + * Fri Feb 10 2006 Jesse Keating - 1.2.0-3.fc5.2 - bump again for double-long bug on ppc(64) From 55933bd06e3f0d6713eb19a324597d2fe225ba38 Mon Sep 17 00:00:00 2001 From: Jarod Wilson Date: Wed, 12 Jul 2006 15:19:56 +0000 Subject: [PATCH 020/100] Bump to 1.2.1, add %dist tag --- libraw1394.spec | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libraw1394.spec b/libraw1394.spec index 1d5cf27..4f77f5f 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 -Version: 1.2.0 -Release: 3.fc5.2.1 +Version: 1.2.1 +Release: 1%{?dist} License: LGPL Group: System Environment/Libraries Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz @@ -61,6 +61,10 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Wed Jul 12 2006 Jarod Wilson - 1.2.1-1 +- update to 1.2.1 +- use %dist tag + * Wed Jul 12 2006 Jesse Keating - 1.2.0-3.fc5.2.1 - rebuild From 4e4cbc427d490f01dce79b86ce880d92078504d5 Mon Sep 17 00:00:00 2001 From: Jarod Wilson Date: Wed, 12 Jul 2006 15:21:04 +0000 Subject: [PATCH 021/100] update sources w/1.2.1 tarball --- .cvsignore | 1 + sources | 1 + 2 files changed, 2 insertions(+) diff --git a/.cvsignore b/.cvsignore index d017dcd..e72d9ae 100644 --- a/.cvsignore +++ b/.cvsignore @@ -1 +1,2 @@ libraw1394-1.2.0.tar.gz +libraw1394-1.2.1.tar.gz diff --git a/sources b/sources index 538611d..bf7ceef 100644 --- a/sources +++ b/sources @@ -1 +1,2 @@ eea394f74afecd6a22f74110128c9fb6 libraw1394-1.2.0.tar.gz +e6210ff05b7f4ec0401ad3d11f493e1a libraw1394-1.2.1.tar.gz From c653bbc0dd1c892c91efa4190aaabb9588ee8e9b Mon Sep 17 00:00:00 2001 From: Jarod Wilson Date: Sun, 4 Feb 2007 15:17:55 +0000 Subject: [PATCH 022/100] Minor fixes for core/extras merge review (#226039) --- libraw1394.spec | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/libraw1394.spec b/libraw1394.spec index 4f77f5f..5f01599 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,22 +1,22 @@ -Summary: Library providing low-level IEEE-1394 access -Name: libraw1394 -Version: 1.2.1 -Release: 1%{?dist} -License: LGPL -Group: System Environment/Libraries -Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz -URL: http://www.linux1394.org/ -ExcludeArch: s390 s390x -BuildRoot: %{_tmppath}/%{name}-%{version}-root +Summary: Library providing low-level IEEE-1394 access +Name: libraw1394 +Version: 1.2.1 +Release: 2%{?dist} +License: LGPL +Group: System Environment/Libraries +Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz +URL: http://www.linux1394.org/ +ExcludeArch: s390 s390x +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) %description The libraw1394 library provides direct access to the IEEE-1394 bus through the Linux 1394 subsystem's raw1394 user space interface. %package devel -Summary: Development libs for libraw1394 -Group: Development/Libraries -Requires: %{name} = %{version}-%{release}, pkgconfig +Summary: Development libs for libraw1394 +Group: Development/Libraries +Requires: %{name} = %{version}-%{release}, pkgconfig %description devel Development libraries needed to build applications against libraw1394. @@ -61,9 +61,12 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Sun Feb 04 2007 Jarod Wilson - 1.2.1-2 +- Minor spec cleanups for Core/Extras merger (#226039) + * Wed Jul 12 2006 Jarod Wilson - 1.2.1-1 - update to 1.2.1 -- use %dist tag +- use %%dist tag * Wed Jul 12 2006 Jesse Keating - 1.2.0-3.fc5.2.1 - rebuild @@ -140,7 +143,7 @@ rm -rf $RPM_BUILD_ROOT - automated rebuild * Wed Jun 19 2002 Michael Fulbright -- fixed up %files list for devel subpackage and included api docs +- fixed up %%files list for devel subpackage and included api docs * Sun Jun 09 2002 Michael Fulbright - First RPM build From 9ebbc4947fde0fb11098554654c693110001460d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Mon, 19 Mar 2007 23:03:07 +0000 Subject: [PATCH 023/100] - Add support for new stack (juju). --- libraw1394.spec | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/libraw1394.spec b/libraw1394.spec index 5f01599..2d80bee 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 1.2.1 -Release: 2%{?dist} +Release: 3%{?dist} License: LGPL Group: System Environment/Libraries Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz @@ -9,6 +9,9 @@ URL: http://www.linux1394.org/ ExcludeArch: s390 s390x BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +Source1: fw-device-cdev.h +Patch0: libraw1394-juju.patch + %description The libraw1394 library provides direct access to the IEEE-1394 bus through the Linux 1394 subsystem's raw1394 user space interface. @@ -24,8 +27,13 @@ Development libraries needed to build applications against libraw1394. %prep %setup -q +%patch0 -p0 -b .juju + %build -%configure --disable-static +aclocal +autoconf +automake +%configure --disable-static --with-juju-dir=$PWD/.. make %{?_smp_mflags} %install @@ -61,6 +69,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Mon Mar 19 2007 Kristian Høgsberg 1.2.1-3 +- Add support for new stack (juju). + * Sun Feb 04 2007 Jarod Wilson - 1.2.1-2 - Minor spec cleanups for Core/Extras merger (#226039) From 70b65d33eec0b9a41e86df7e488106799cf015b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Mon, 19 Mar 2007 23:09:25 +0000 Subject: [PATCH 024/100] - Add support for new stack (juju). --- libraw1394.spec | 1 - 1 file changed, 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index 2d80bee..419af54 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -9,7 +9,6 @@ URL: http://www.linux1394.org/ ExcludeArch: s390 s390x BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -Source1: fw-device-cdev.h Patch0: libraw1394-juju.patch %description From 94a94c7d256085e185f9f4d8469040ae6d46fad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Mon, 19 Mar 2007 23:14:07 +0000 Subject: [PATCH 025/100] - Add support for new stack (juju). --- libraw1394.spec | 1 + sources | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index 419af54..8fe099a 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -8,6 +8,7 @@ Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz URL: http://www.linux1394.org/ ExcludeArch: s390 s390x BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +BuildRequires: autoconf automake libtool Patch0: libraw1394-juju.patch diff --git a/sources b/sources index bf7ceef..790bc15 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ -eea394f74afecd6a22f74110128c9fb6 libraw1394-1.2.0.tar.gz e6210ff05b7f4ec0401ad3d11f493e1a libraw1394-1.2.1.tar.gz +1be31713ca1e4d3387310fd96274ebb4 fw-device-cdev.h From ab95aadd08ff3617f2433fd80618b1cc4536cae8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Mon, 19 Mar 2007 23:25:30 +0000 Subject: [PATCH 026/100] - Add support for new stack (juju). --- .cvsignore | 1 + libraw1394-juju.patch | 1877 +++++++++++++++++++++++++++++++++++++++++ libraw1394.spec | 4 + sources | 1 - 4 files changed, 1882 insertions(+), 1 deletion(-) create mode 100644 libraw1394-juju.patch diff --git a/.cvsignore b/.cvsignore index e72d9ae..5de9d16 100644 --- a/.cvsignore +++ b/.cvsignore @@ -1,2 +1,3 @@ libraw1394-1.2.0.tar.gz libraw1394-1.2.1.tar.gz +fw-device-cdev.h diff --git a/libraw1394-juju.patch b/libraw1394-juju.patch new file mode 100644 index 0000000..c04f781 --- /dev/null +++ b/libraw1394-juju.patch @@ -0,0 +1,1877 @@ +Index: tools/testlibraw.c +=================================================================== +--- tools/testlibraw.c (revision 171) ++++ tools/testlibraw.c (working copy) +@@ -1,4 +1,5 @@ +-/* ++/* -*- c-basic-offset: 8 -*- ++ * + * libraw1394 - library for raw access to the 1394 bus with the Linux subsystem. + * + * Copyright (C) 1999,2000 Andreas Bombe +@@ -13,12 +14,13 @@ + #include + #include + #include ++#include + + #include "../src/raw1394.h" + #include "../src/csr.h" + + +-#define TESTADDR (CSR_REGISTER_BASE + CSR_CYCLE_TIME) ++#define TESTADDR (CSR_REGISTER_BASE + CSR_CONFIG_ROM) + + const char not_compatible[] = "\ + This libraw1394 does not work with your version of Linux. You need a different\n\ +@@ -45,12 +47,18 @@ + return 0; + } + ++static const unsigned char fcp_data[] = ++ { 0x1, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }; ++ + int my_fcp_handler(raw1394handle_t handle, nodeid_t nodeid, int response, + size_t length, unsigned char *data) + { + printf("got fcp %s from node %d of %d bytes:", + (response ? "response" : "command"), nodeid & 0x3f, length); + ++ if (memcmp(fcp_data, data, sizeof fcp_data) != 0) ++ printf("ERROR: fcp payload not correct\n"); ++ + while (length) { + printf(" %02x", *data); + data++; +@@ -62,7 +70,48 @@ + return 0; + } + ++static void ++test_fcp(raw1394handle_t handle) ++{ ++ printf("\ntesting FCP monitoring on local node\n"); ++ raw1394_set_fcp_handler(handle, my_fcp_handler); ++ raw1394_start_fcp_listen(handle); ++ raw1394_write(handle, raw1394_get_local_id(handle), ++ CSR_REGISTER_BASE + CSR_FCP_COMMAND, sizeof(fcp_data), ++ (quadlet_t *)fcp_data); ++ raw1394_write(handle, raw1394_get_local_id(handle), ++ CSR_REGISTER_BASE + CSR_FCP_RESPONSE, sizeof(fcp_data), ++ (quadlet_t *)fcp_data); ++} + ++static void ++read_topology_map(raw1394handle_t handle) ++{ ++ quadlet_t map[70]; ++ nodeid_t local_id; ++ int node_count, self_id_count, i, retval; ++ ++ local_id = raw1394_get_local_id(handle) | 0xffc0; ++ ++ retval = raw1394_read(handle, local_id, ++ CSR_REGISTER_BASE + CSR_TOPOLOGY_MAP, 12, &map[0]); ++ if (retval < 0) ++ perror("topology map: raw1394_read failed with error"); ++ ++ self_id_count = ntohl(map[2]) & 0xffff; ++ node_count = ntohl(map[2]) >> 16; ++ retval = raw1394_read(handle, local_id, ++ CSR_REGISTER_BASE + CSR_TOPOLOGY_MAP + 12, ++ self_id_count * sizeof map[0], &map[3]); ++ if (retval < 0) ++ perror("topology map: raw1394_read failed with error"); ++ ++ printf("topology map: %d nodes, %d self ids, generation %d\n", ++ node_count, self_id_count, ntohl(map[1])); ++ for (i = 0; i < self_id_count; i++) ++ printf(" 0x%08x\n", ntohl(map[3 + i])); ++} ++ + int main(int argc, char **argv) + { + raw1394handle_t handle; +@@ -73,7 +122,6 @@ + int retval; + + struct pollfd pfd; +- unsigned char fcp_test[] = { 0x1, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }; + quadlet_t rom[0x100]; + size_t rom_size; + unsigned char rom_version; +@@ -150,18 +198,9 @@ + } + } + +- printf("\ntesting FCP monitoring on local node\n"); +- raw1394_set_fcp_handler(handle, my_fcp_handler); +- raw1394_start_fcp_listen(handle); +- raw1394_write(handle, raw1394_get_local_id(handle), +- CSR_REGISTER_BASE + CSR_FCP_COMMAND, sizeof(fcp_test), +- (quadlet_t *)fcp_test); +- raw1394_write(handle, raw1394_get_local_id(handle), +- CSR_REGISTER_BASE + CSR_FCP_RESPONSE, sizeof(fcp_test), +- (quadlet_t *)fcp_test); ++ test_fcp(handle); ++ read_topology_map(handle); + +- +- + printf("testing config rom stuff\n"); + retval=raw1394_get_config_rom(handle, rom, 0x100, &rom_size, &rom_version); + printf("get_config_rom returned %d, romsize %d, rom_version %d\n",retval,rom_size,rom_version); +@@ -176,16 +215,19 @@ + retval=raw1394_update_config_rom(handle, rom, rom_size, rom_version); + printf("update_config_rom returned %d\n",retval); + ++ printf("\nposting 0xdeadbeef as an echo request\n"); ++ raw1394_echo_request(handle, 0xdeadbeef); + +- +- printf("\npolling for leftover messages\n"); ++ printf("polling for leftover messages\n"); + pfd.fd = raw1394_get_fd(handle); + pfd.events = POLLIN; + pfd.revents = 0; + while (1) { + retval = poll(&pfd, 1, 10); + if (retval < 1) break; +- raw1394_loop_iterate(handle); ++ retval = raw1394_loop_iterate(handle); ++ if (retval != 0) ++ printf("raw1394_loop_iterate() returned 0x%08x\n", retval); + } + + if (retval < 0) perror("poll failed"); +Index: tools/Makefile.am +=================================================================== +--- tools/Makefile.am (revision 171) ++++ tools/Makefile.am (working copy) +@@ -2,4 +2,4 @@ + + # testlibraw + bin_PROGRAMS = testlibraw sendiso dumpiso +-LDADD = ../src/libraw1394.la ++LDADD = ../$(LIB_SUBDIR)/libraw1394.la +Index: configure.ac +=================================================================== +--- configure.ac (revision 171) ++++ configure.ac (working copy) +@@ -24,13 +24,35 @@ + AC_SUBST(lt_revision) + AC_SUBST(lt_age) + ++AC_ARG_WITH(juju-dir,[ --with-juju-dir= Path to juju include files]) ++if ! test -z "$with_juju_dir" ; then ++ JUJU_DIR="$with_juju_dir" ++ LIB_SUBDIR=juju ++ AC_SUBST(JUJU_DIR) ++else ++ LIB_SUBDIR=src ++fi ++AC_SUBST(LIB_SUBDIR) + ++AC_ARG_WITH(fw-device-prefix, ++ [ --with-fw-device-prefix= Prefix of firewire device file names (default "fw").], ++ [FW_DEVICE_PREFIX="\"$withval\""], [FW_DEVICE_PREFIX="\"fw\""]) ++AC_ARG_WITH(fw-device-dir, ++ [ --with-fw-device-dir= Directory to watch for firewire device files (default "/dev").], ++ [FW_DEVICE_DIR="\"$withval\""], [FW_DEVICE_DIR="\"/dev\""]) ++ ++AC_DEFINE_UNQUOTED(FW_DEVICE_PREFIX, $FW_DEVICE_PREFIX, ++ [Prefix of firewire device file names.]) ++AC_DEFINE_UNQUOTED(FW_DEVICE_DIR, $FW_DEVICE_DIR, ++ [Directory to watch for firewire device files.]) ++ + #CFLAGS=${CFLAGS:-"-Wall"} + AC_OUTPUT([ + Makefile + libraw1394.pc + libraw1394.spec + src/Makefile ++juju/Makefile + tools/Makefile + doc/Makefile + doc/testlibraw.1 +Index: Makefile.am +=================================================================== +--- Makefile.am (revision 171) ++++ Makefile.am (working copy) +@@ -1,6 +1,7 @@ + # process this file with automake to create a Makefile.in + +-SUBDIRS = src tools doc debian ++SUBDIRS = $(LIB_SUBDIR) tools doc debian ++DIST_SUBDIRS = src juju + + pkgconfigdir = @libdir@/pkgconfig + pkgconfig_DATA = libraw1394.pc +Index: juju/raw1394-iso.c +=================================================================== +--- juju/raw1394-iso.c (revision 0) ++++ juju/raw1394-iso.c (revision 0) +@@ -0,0 +1,197 @@ ++/* -*- c-basic-offset: 8 -*- ++ * ++ * raw1394-iso.c -- Emulation of the raw1394 rawiso API on the juju stack ++ * ++ * Copyright (C) 2007 Kristian Hoegsberg ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software Foundation, ++ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ */ ++ ++#include ++#include ++ ++#include "juju.h" ++ ++int raw1394_iso_xmit_init(raw1394handle_t handle, ++ raw1394_iso_xmit_handler_t handler, ++ unsigned int buf_packets, ++ unsigned int max_packet_size, ++ unsigned char channel, ++ enum raw1394_iso_speed speed, ++ int irq_interval) ++{ ++ struct fw_cdev_create_iso_context create; ++ ++ handle->iso.buffer = ++ mmap(NULL, buf_packets * max_packet_size, ++ PROT_READ | PROT_WRITE, MAP_SHARED, handle->local_fd, 0); ++ ++ if (handle->iso.buffer == MAP_FAILED) ++ return -1; ++ ++ create.type = FW_CDEV_ISO_CONTEXT_TRANSMIT; ++ create.channel = channel; ++ create.speed = speed; ++ ++ handle->iso.type = FW_CDEV_ISO_CONTEXT_TRANSMIT; ++ handle->iso.irq_interval = irq_interval; ++ handle->iso.xmit_handler = handler; ++ ++ return ioctl(handle->local_fd, ++ FW_CDEV_IOC_CREATE_ISO_CONTEXT, &create); ++} ++ ++int raw1394_iso_recv_init(raw1394handle_t handle, ++ raw1394_iso_recv_handler_t handler, ++ unsigned int buf_packets, ++ unsigned int max_packet_size, ++ unsigned char channel, ++ enum raw1394_iso_dma_recv_mode mode, ++ int irq_interval) ++{ ++ struct fw_cdev_create_iso_context create; ++ ++ /* FIXME: Do we need this? When would you ever want this...? */ ++ if (mode == RAW1394_DMA_PACKET_PER_BUFFER) ++ return -1; ++ ++ handle->iso.buffer = ++ mmap(NULL, buf_packets * max_packet_size, ++ PROT_READ, MAP_SHARED, handle->local_fd, 0); ++ ++ if (handle->iso.buffer == MAP_FAILED) ++ return -1; ++ ++ create.type = FW_CDEV_ISO_CONTEXT_TRANSMIT; ++ create.channel = channel; ++ create.speed = 0; ++ create.header_size = 0; /* Never strip any headers. */ ++ ++ handle->iso.type = FW_CDEV_ISO_CONTEXT_TRANSMIT; ++ handle->iso.irq_interval = irq_interval; ++ handle->iso.recv_handler = handler; ++ ++ return ioctl(handle->local_fd, ++ FW_CDEV_IOC_CREATE_ISO_CONTEXT, &create); ++} ++ ++int raw1394_iso_multichannel_recv_init(raw1394handle_t handle, ++ raw1394_iso_recv_handler_t handler, ++ unsigned int buf_packets, ++ unsigned int max_packet_size, ++ int irq_interval) ++{ ++ /* FIXME: gah */ ++ return -1; ++} ++ ++int raw1394_iso_recv_listen_channel(raw1394handle_t handle, ++ unsigned char channel) ++{ ++ /* FIXME: multichannel */ ++ return -1; ++} ++ ++int raw1394_iso_recv_unlisten_channel(raw1394handle_t handle, ++ unsigned char channel) ++{ ++ /* FIXME: multichannel */ ++ return -1; ++} ++ ++int raw1394_iso_recv_set_channel_mask(raw1394handle_t handle, u_int64_t mask) ++{ ++ /* FIXME: multichannel */ ++ return -1; ++} ++ ++int raw1394_iso_xmit_start(raw1394handle_t handle, int start_on_cycle, ++ int prebuffer_packets) ++{ ++ struct fw_cdev_start_iso start_iso; ++ ++ handle->iso.start_cycle = start_on_cycle; ++ if (prebuffer_packets == -1) ++ handle->iso.prebuffer = 64; ++ else ++ handle->iso.prebuffer = prebuffer_packets; ++ ++ if (handle->iso.buffered_packet_count < handle->iso.prebuffer) ++ return 0; ++ ++ start_iso.cycle = handle->iso.start_cycle; ++ ++ return ioctl(handle->local_fd, FW_CDEV_IOC_START_ISO, &start_iso); ++} ++ ++int raw1394_iso_recv_start(raw1394handle_t handle, int start_on_cycle, ++ int tag_mask, int sync) ++{ ++ struct fw_cdev_start_iso start_iso; ++ ++ start_iso.cycle = start_on_cycle; ++ start_iso.tags = ++ tag_mask == -1 ? FW_CDEV_ISO_CONTEXT_MATCH_ALL_TAGS : tag_mask; ++ /* sync is documented as 'not used' */ ++ start_iso.sync = 0; ++ ++ return ioctl(handle->local_fd, FW_CDEV_IOC_START_ISO, &start_iso); ++} ++ ++int raw1394_iso_xmit_write(raw1394handle_t handle, unsigned char *data, ++ unsigned int len, unsigned char tag, ++ unsigned char sy) ++{ ++ struct fw_cdev_iso_packet packet; ++ ++ packet.payload_length = len; ++ packet.interrupt = handle->iso.packet_phase == 0; ++ packet.skip = 0; ++ packet.tag = tag; ++ packet.sy = sy; ++ packet.header_length = 0; ++ ++ handle->iso.packet_phase++; ++ if (handle->iso.packet_phase == handle->iso.irq_interval) ++ handle->iso.packet_phase = 0; ++ ++ /* FIXME: circular buffer goo. */ ++ ++ memcpy(handle->iso.head, data, len); ++ handle->iso.head += len; ++ ++ return -1; ++} ++ ++int raw1394_iso_xmit_sync(raw1394handle_t handle) ++{ ++ /* FIXME: queue a skip packet and wait for that interrupt. */ ++} ++ ++int raw1394_iso_recv_flush(raw1394handle_t handle) ++{ ++ /* FIXME: huh, we'll need kernel support here... */ ++} ++ ++void raw1394_iso_stop(raw1394handle_t handle) ++{ ++ ioctl(handle->local_fd, FW_CDEV_IOC_STOP_ISO); ++} ++ ++void raw1394_iso_shutdown(raw1394handle_t handle) ++{ ++ /* Maybe we should just open a new fd for the local device and ++ * close that here... */ ++} +Index: juju/juju.h +=================================================================== +--- juju/juju.h (revision 0) ++++ juju/juju.h (revision 0) +@@ -0,0 +1,107 @@ ++/* -*- c-basic-offset: 8 -*- ++ * ++ * juju.h -- Internal header file for raw1394 emulation ++ * ++ * Copyright (C) 2007 Kristian Hoegsberg ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software Foundation, ++ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ */ ++ ++#ifndef __juju_h ++#define __juju_h ++ ++#include ++#include ++#include "../src/raw1394.h" ++#include "../src/csr.h" ++#include "config.h" ++ ++#define ACK_COMPLETE 1 ++ ++#define ptr_to_u64(p) ((__u64)(unsigned long)(p)) ++#define u64_to_ptr(p) ((void *)(unsigned long)(p)) ++ ++#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0]) ++ ++#define BUFFER_SIZE (16 * 1024) ++ ++#define MAX_PORTS 16 ++ ++struct port { ++ char device_file[32]; ++ char *name; ++ int node_count; ++ int card; ++}; ++ ++#define MAX_DEVICES 63 ++#define INOTIFY_INDEX 64 ++#define PIPE_INDEX 65 ++ ++struct device { ++ int fd; ++ int node_id; ++ int generation; ++ char filename[16]; ++}; ++ ++struct closure { ++ void *data; ++ size_t length; ++ unsigned long tag; ++ struct raw1394_reqhandle reqhandle; ++}; ++ ++struct raw1394_handle { ++ struct port ports[MAX_PORTS]; ++ int port_count; ++ int err; ++ int generation; ++ void *user_data; ++ int notify_bus_reset; ++ ++ bus_reset_handler_t bus_reset_handler; ++ tag_handler_t tag_handler; ++ arm_tag_handler_t arm_tag_handler; ++ fcp_handler_t fcp_handler; ++ ++ int epoll_fd; ++ int inotify_fd; ++ int inotify_watch; ++ int pipe_fds[2]; ++ ++ struct device devices[MAX_DEVICES]; ++ int nodes[MAX_DEVICES]; ++ int local_fd; ++ ++ struct fw_cdev_event_bus_reset reset; ++ ++ struct { ++ int type; ++ int irq_interval; ++ int prebuffer; ++ int start_cycle; ++ int buffered_packet_count; ++ int packet_phase; ++ enum raw1394_iso_dma_recv_mode recv_mode; ++ raw1394_iso_xmit_handler_t xmit_handler; ++ raw1394_iso_recv_handler_t recv_handler; ++ unsigned char *buffer, *head, *tail; ++ } iso; ++ ++ char buffer[BUFFER_SIZE]; ++}; ++ ++#endif +Index: juju/Makefile.am +=================================================================== +--- juju/Makefile.am (revision 0) ++++ juju/Makefile.am (revision 0) +@@ -0,0 +1,8 @@ ++lib_LTLIBRARIES = libraw1394.la ++ ++INCLUDES = -I$(JUJU_DIR) ++libraw1394_la_LDFLAGS = -version-info @lt_major@:@lt_revision@:@lt_age@ ++ ++libraw1394_la_SOURCES = raw1394.c raw1394-iso.c juju.h ++ ++pkginclude_HEADERS = ../src/raw1394.h ../src/csr.h ../src/ieee1394.h +Index: juju/raw1394.c +=================================================================== +--- juju/raw1394.c (revision 0) ++++ juju/raw1394.c (revision 0) +@@ -0,0 +1,1336 @@ ++/* -*- c-basic-offset: 8 -*- ++ * ++ * raw1394.c -- Emulation of the raw1394 API on the juju stack ++ * ++ * Copyright (C) 2007 Kristian Hoegsberg ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software Foundation, ++ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "juju.h" ++ ++raw1394_errcode_t ++raw1394_get_errcode(raw1394handle_t handle) ++{ ++ return handle->err; ++} ++ ++int ++raw1394_errcode_to_errno(raw1394_errcode_t errcode) ++{ ++ switch (errcode) { ++ ++ case -RCODE_SEND_ERROR: ++ case -RCODE_CANCELLED: ++ case -RCODE_BUSY: ++ case -RCODE_GENERATION: ++ case -RCODE_NO_ACK: ++ return EAGAIN; ++ ++ case raw1394_make_errcode(ACK_COMPLETE, RCODE_COMPLETE): ++ return 0; ++ case raw1394_make_errcode(ACK_COMPLETE, RCODE_CONFLICT_ERROR): ++ return EAGAIN; ++ case raw1394_make_errcode(ACK_COMPLETE, RCODE_DATA_ERROR): ++ return EREMOTEIO; ++ case raw1394_make_errcode(ACK_COMPLETE, RCODE_TYPE_ERROR): ++ return EPERM; ++ case raw1394_make_errcode(ACK_COMPLETE, RCODE_ADDRESS_ERROR): ++ return EINVAL; ++ default: ++ return EINVAL; ++ } ++} ++ ++static int ++juju_to_raw1394_errcode(int rcode) ++{ ++ /* Best effort matching juju extended rcodes to raw1394 err ++ * code. Since the raw1394 errcode decoding are macros we try ++ * to convert the juju rcodes to something that looks enough ++ * like the raw1394 errcodes that we retain ABI compatibility. ++ * ++ * Juju rcodes less than 0x10 are standard ieee1394 rcodes, ++ * which we map to a raw1394 errcode by or'ing in an ++ * ACK_COMPLETE ack code in the upper 16 bits. Errors ++ * internal to raw1394 are negative values, but juju encodes ++ * these errors as rcodes greater than or equal to 0x10. In ++ * this case, we just the negated value, which will look like ++ * an raw1394 internal error code. */ ++ ++ if (rcode < 0x10) ++ return raw1394_make_errcode(ACK_COMPLETE, rcode); ++ else ++ return -rcode; ++} ++ ++static int ++default_tag_handler(raw1394handle_t handle, ++ unsigned long tag, raw1394_errcode_t err) ++{ ++ struct raw1394_reqhandle *rh = (struct raw1394_reqhandle *) tag; ++ ++ if (rh != NULL) ++ return rh->callback(handle, rh->data, err); ++ ++ return -1; ++} ++ ++static int ++default_arm_tag_handler(raw1394handle_t handle, unsigned long arm_tag, ++ byte_t type, unsigned int length, void *data) ++{ ++ struct raw1394_arm_reqhandle *rh; ++ ++ if (arm_tag == 0) ++ return -1; ++ ++ rh = (struct raw1394_arm_reqhandle *) arm_tag; ++ ++ rh->arm_callback(handle, data, length, rh->pcontext, type); ++} ++ ++static int ++default_bus_reset_handler(struct raw1394_handle *handle, unsigned int gen) ++{ ++ raw1394_update_generation(handle, gen); ++ ++ return 0; ++} ++ ++static int ++scan_devices(raw1394handle_t handle) ++{ ++ DIR *dir; ++ struct dirent *de; ++ char filename[32]; ++ struct fw_cdev_get_info get_info; ++ struct fw_cdev_event_bus_reset reset; ++ int fd, err, i; ++ struct port *ports; ++ size_t size; ++ ++ ports = handle->ports; ++ memset(ports, 0, sizeof handle->ports); ++ dir = opendir(FW_DEVICE_DIR); ++ if (dir == NULL) ++ return -1; ++ ++ i = 0; ++ while (1) { ++ de = readdir(dir); ++ if (de == NULL) ++ break; ++ ++ if (strncmp(de->d_name, ++ FW_DEVICE_PREFIX, strlen(FW_DEVICE_PREFIX)) != 0) ++ continue; ++ ++ snprintf(filename, sizeof filename, FW_DEVICE_DIR "/%s", de->d_name); ++ ++ fd = open(filename, O_RDWR); ++ if (fd < 0) ++ continue; ++ get_info.version = FW_CDEV_VERSION; ++ get_info.rom = 0; ++ get_info.rom_length = 0; ++ get_info.bus_reset = ptr_to_u64(&reset); ++ err = ioctl(fd, FW_CDEV_IOC_GET_INFO, &get_info); ++ close(fd); ++ ++ if (err < 0) ++ continue; ++ ++ if (i < MAX_PORTS && reset.node_id == reset.local_node_id) { ++ strncpy(ports[i].device_file, filename, ++ sizeof ports[i].device_file); ++ ports[i].node_count = (reset.root_node_id & 0x3f) + 1; ++ ports[i].card = get_info.card; ++ i++; ++ } ++ } ++ closedir(dir); ++ ++ handle->port_count = i; ++ ++ return 0; ++} ++ ++static int ++handle_echo_pipe(raw1394handle_t handle) ++{ ++ quadlet_t value; ++ ++ if (read(handle->pipe_fds[0], &value, sizeof value) < 0) ++ return -1; ++ ++ return value; ++} ++ ++static int ++handle_new_device(raw1394handle_t handle) ++{ ++ struct inotify_event *event; ++ char filename[32]; ++ struct fw_cdev_get_info info; ++ struct fw_cdev_event_bus_reset reset; ++ struct epoll_event ep; ++ int i, len, fd, phy_id; ++ ++ event = (struct inotify_event *) handle->buffer; ++ len = read(handle->inotify_fd, event, BUFFER_SIZE); ++ if (!(event->mask & IN_CREATE)) ++ return -1; ++ if (strncmp(event->name, ++ FW_DEVICE_PREFIX, strlen(FW_DEVICE_PREFIX)) != 0) ++ return 0; ++ snprintf(filename, sizeof filename, FW_DEVICE_DIR "/%s", event->name); ++ fd = open(filename, O_RDWR); ++ if (fd < 0) { ++ switch (errno) { ++ case ENOENT: ++ /* Huh, it disappeared before we could ++ * open it. */ ++ return 0; ++ case EACCES: ++ /* We don't have permission to talk to ++ * this device, maybe it's a storage ++ * device. */ ++ return 0; ++ default: ++ /* Anything else is bad news. */ ++ return -1; ++ } ++ } ++ ++ info.version = FW_CDEV_VERSION; ++ info.rom = 0; ++ info.rom_length = 0; ++ info.bus_reset = ptr_to_u64(&reset); ++ if (ioctl(fd, FW_CDEV_IOC_GET_INFO, &info) < 0) { ++ close(fd); ++ return -1; ++ } ++ ++ for (i = 0; i < MAX_DEVICES; i++) ++ if (handle->devices[i].node_id == -1) ++ break; ++ if (i == MAX_DEVICES) { ++ close(fd); ++ return -1; ++ } ++ ++ phy_id = reset.node_id & 0x3f; ++ handle->nodes[phy_id] = i; ++ handle->devices[i].node_id = reset.node_id; ++ handle->devices[i].generation = reset.generation; ++ handle->devices[i].fd = fd; ++ strncpy(handle->devices[i].filename, filename, ++ sizeof handle->devices[i].filename); ++ ep.events = EPOLLIN; ++ ep.data.u32 = i; ++ if (epoll_ctl(handle->epoll_fd, EPOLL_CTL_ADD, fd, &ep) < 0) { ++ close(fd); ++ return -1; ++ } ++ ++ return 0; ++} ++ ++static int ++handle_lost_device(raw1394handle_t handle, int i) ++{ ++ int phy_id; ++ ++ /* The device got unplugged, get rid of it. The fd is ++ * automatically dropped from the epoll context when we close it. */ ++ ++ close(handle->devices[i].fd); ++ phy_id = handle->devices[i].node_id & 0x3f; ++ if (handle->nodes[phy_id] == i) ++ handle->nodes[phy_id] = -1; ++ handle->devices[i].node_id = -1; ++ ++ return 0; ++} ++ ++struct address_closure { ++ int (*callback)(raw1394handle_t handle, struct address_closure *ac, ++ struct fw_cdev_event_request *request, int i); ++}; ++ ++static int ++handle_fcp_request(raw1394handle_t handle, struct address_closure *ac, ++ struct fw_cdev_event_request *request, int i) ++{ ++ struct fw_cdev_send_response response; ++ int is_response; ++ ++ response.serial = request->serial; ++ response.rcode = RCODE_COMPLETE; ++ response.length = 0; ++ response.data = 0; ++ ++ if (handle->fcp_handler == NULL) ++ response.rcode = RCODE_ADDRESS_ERROR; ++ ++ if (request->tcode >= TCODE_WRITE_RESPONSE) ++ response.rcode = RCODE_CONFLICT_ERROR; ++ ++ if (ioctl(handle->devices[i].fd, ++ FW_CDEV_IOC_SEND_RESPONSE, &response) < 0) ++ return -1; ++ ++ if (response.rcode != RCODE_COMPLETE) ++ return 0; ++ ++ is_response = request->offset >= CSR_REGISTER_BASE + CSR_FCP_RESPONSE; ++ ++ handle->fcp_handler(handle, ++ handle->devices[i].node_id, ++ is_response, ++ request->length, ++ (unsigned char *) request->data); ++} ++ ++static int ++handle_device_event(raw1394handle_t handle, int i) ++{ ++ union { ++ struct fw_cdev_event_bus_reset bus_reset; ++ struct fw_cdev_event_response response; ++ struct fw_cdev_event_request request; ++ struct fw_cdev_event_iso_interrupt interrupt; ++ } *u; ++ struct address_closure *ac; ++ struct closure *closure; ++ raw1394_errcode_t errcode; ++ int fd, last, len, phy_id; ++ ++ len = read(handle->devices[i].fd, ++ handle->buffer, sizeof handle->buffer); ++ if (len < 0) ++ return -1; ++ ++ u = (void *) handle->buffer; ++ switch (u->response.type) { ++ case FW_CDEV_EVENT_BUS_RESET: ++ /* Clear old entry, unless it's been overwritten. */ ++ phy_id = handle->devices[i].node_id & 0x3f; ++ if (handle->nodes[phy_id] == i) ++ handle->nodes[phy_id] = -1; ++ handle->nodes[u->bus_reset.node_id & 0x3f] = i; ++ handle->devices[i].node_id = u->bus_reset.node_id; ++ handle->devices[i].generation = u->bus_reset.generation; ++ ++ if (u->bus_reset.node_id != u->bus_reset.local_node_id) ++ return 0; ++ ++ memcpy(&handle->reset, &u->bus_reset, sizeof handle->reset); ++ return handle->bus_reset_handler(handle, ++ u->bus_reset.generation); ++ ++ case FW_CDEV_EVENT_RESPONSE: ++ closure = u64_to_ptr(u->response.closure); ++ ++ if (closure->data != NULL) ++ memcpy(closure->data, ++ u->response.data, closure->length); ++ ++ errcode = juju_to_raw1394_errcode(u->response.rcode); ++ ++ return handle->tag_handler(handle, closure->tag, errcode); ++ ++ case FW_CDEV_EVENT_REQUEST: ++ ac = u64_to_ptr(u->request.closure); ++ return ac->callback(handle, ac, &u->request, i); ++ ++ case FW_CDEV_EVENT_ISO_INTERRUPT: ++ return 0; ++ } ++} ++ ++int raw1394_loop_iterate(raw1394handle_t handle) ++{ ++ int i, last, count, retval = 0; ++ ++ struct epoll_event ep[32]; ++ ++ count = epoll_wait(handle->epoll_fd, ep, ARRAY_LENGTH(ep), -1); ++ if (count < 0) ++ return -1; ++ ++ for (i = 0; i < count; i++) { ++ if (ep[i].data.u32 == PIPE_INDEX) ++ retval = handle_echo_pipe(handle); ++ else if (ep[i].data.u32 == INOTIFY_INDEX) ++ retval = handle_new_device(handle); ++ else if (ep[i].events & EPOLLHUP) ++ retval = handle_lost_device(handle, ep[i].data.u32); ++ else if (ep[i].events & EPOLLIN) ++ retval = handle_device_event(handle, ep[i].data.u32); ++ } ++ ++ /* It looks like we have to add this work-around to get epoll ++ * to recompute the POLLIN status of the epoll_fd. */ ++ epoll_wait(handle->epoll_fd, ep, ARRAY_LENGTH(ep), 0); ++ ++ return retval; ++} ++ ++raw1394handle_t raw1394_new_handle(void) ++{ ++ raw1394handle_t handle; ++ struct epoll_event ep; ++ int i; ++ ++ handle = malloc(sizeof *handle); ++ ++ handle->tag_handler = default_tag_handler; ++ handle->arm_tag_handler = default_arm_tag_handler; ++ ++ handle->notify_bus_reset = RAW1394_NOTIFY_ON; ++ handle->bus_reset_handler = default_bus_reset_handler; ++ ++ handle->epoll_fd = epoll_create(16); ++ if (handle->epoll_fd < 0) ++ goto out_handle; ++ ++ if (pipe(handle->pipe_fds) < 0) ++ goto out_epoll; ++ ++ handle->inotify_fd = inotify_init(); ++ if (handle->inotify_fd < 0) ++ goto out_pipe; ++ ++ handle->inotify_watch = ++ inotify_add_watch(handle->inotify_fd, FW_DEVICE_DIR, IN_CREATE); ++ if (handle->inotify_watch < 0) ++ goto out_inotify; ++ ++ ep.events = EPOLLIN; ++ ep.data.u32 = PIPE_INDEX; ++ if (epoll_ctl(handle->epoll_fd, EPOLL_CTL_ADD, ++ handle->pipe_fds[0], &ep) < 0) ++ goto out_inotify; ++ ++ ep.events = EPOLLIN; ++ ep.data.u32 = INOTIFY_INDEX; ++ if (epoll_ctl(handle->epoll_fd, EPOLL_CTL_ADD, ++ handle->inotify_fd, &ep) < 0) ++ goto out_inotify; ++ ++ for (i = 0; i < MAX_DEVICES; i++) { ++ handle->nodes[i] = -1; ++ handle->devices[i].node_id = -1; ++ } ++ ++ scan_devices(handle); ++ ++ return handle; ++ ++ out_inotify: ++ close(handle->inotify_fd); ++ out_pipe: ++ close(handle->pipe_fds[0]); ++ close(handle->pipe_fds[1]); ++ out_epoll: ++ close(handle->epoll_fd); ++ out_handle: ++ free(handle); ++ return NULL; ++} ++ ++void raw1394_destroy_handle(raw1394handle_t handle) ++{ ++ int i; ++ ++ close(handle->inotify_fd); ++ close(handle->pipe_fds[0]); ++ close(handle->pipe_fds[1]); ++ ++ for (i = 0; i < MAX_DEVICES; i++) { ++ if (handle->devices[i].node_id == -1) ++ continue; ++ ++ close(handle->devices[i].fd); ++ } ++ ++ close(handle->epoll_fd); ++ ++ free(handle); ++ ++ return; ++} ++ ++raw1394handle_t raw1394_new_handle_on_port(int port) ++{ ++ raw1394handle_t handle; ++ ++ handle = raw1394_new_handle(); ++ if (handle == NULL) ++ return NULL; ++ ++ if (raw1394_set_port(handle, port) < 0) ++ return NULL; ++ ++ return handle; ++} ++ ++int raw1394_busreset_notify (raw1394handle_t handle, int off_on_switch) ++{ ++ handle->notify_bus_reset = off_on_switch; ++ ++ return 0; ++} ++ ++int raw1394_get_fd(raw1394handle_t handle) ++{ ++ return handle->epoll_fd; ++} ++ ++void raw1394_set_userdata(raw1394handle_t handle, void *data) ++{ ++ handle->user_data = data; ++} ++ ++void *raw1394_get_userdata(raw1394handle_t handle) ++{ ++ return handle->user_data; ++} ++ ++nodeid_t raw1394_get_local_id(raw1394handle_t handle) ++{ ++ return handle->reset.local_node_id; ++} ++ ++nodeid_t raw1394_get_irm_id(raw1394handle_t handle) ++{ ++ return handle->reset.irm_node_id; ++} ++ ++int raw1394_get_nodecount(raw1394handle_t handle) ++{ ++ return (handle->reset.root_node_id & 0x3f) + 1; ++} ++ ++int raw1394_get_port_info(raw1394handle_t handle, ++ struct raw1394_portinfo *pinf, ++ int maxports) ++{ ++ int i; ++ ++ if (maxports >= handle->port_count) ++ maxports = handle->port_count; ++ ++ for (i = 0; i < maxports; i++) { ++ pinf[i].nodes = handle->ports[i].node_count; ++ strncpy(pinf[i].name, handle->ports[i].device_file, ++ sizeof pinf[i].name); ++ } ++ ++ return handle->port_count; ++} ++ ++int raw1394_set_port(raw1394handle_t handle, int port) ++{ ++ struct fw_cdev_get_info get_info; ++ struct fw_cdev_event_bus_reset reset; ++ struct epoll_event ep; ++ struct dirent *de; ++ char filename[32]; ++ DIR *dir; ++ int i, fd, phy_id; ++ ++ if (port >= handle->port_count) { ++ errno = EINVAL; ++ return -1; ++ } ++ ++ dir = opendir("/dev"); ++ if (dir == NULL) ++ return -1; ++ ++ for (i = 0; i < MAX_DEVICES; ) { ++ de = readdir(dir); ++ if (de == NULL) ++ break; ++ ++ if (strncmp(de->d_name, "fw", 2) != 0) ++ continue; ++ ++ snprintf(filename, sizeof filename, "/dev/%s", de->d_name); ++ ++ fd = open(filename, O_RDWR); ++ if (fd < 0) ++ continue; ++ ++ get_info.version = FW_CDEV_VERSION; ++ get_info.rom = 0; ++ get_info.rom_length = 0; ++ get_info.bus_reset = ptr_to_u64(&reset); ++ if (ioctl(fd, FW_CDEV_IOC_GET_INFO, &get_info) < 0) { ++ close(fd); ++ continue; ++ } ++ ++ if (get_info.card != handle->ports[port].card) { ++ close(fd); ++ continue; ++ } ++ ++ phy_id = reset.node_id & 0x3f; ++ handle->nodes[phy_id] = i; ++ handle->devices[i].node_id = reset.node_id; ++ handle->devices[i].generation = reset.generation; ++ handle->devices[i].fd = fd; ++ strncpy(handle->devices[i].filename, filename, ++ sizeof handle->devices[i].filename); ++ ++ ep.events = EPOLLIN; ++ ep.data.u32 = i; ++ if (epoll_ctl(handle->epoll_fd, EPOLL_CTL_ADD, fd, &ep) < 0) { ++ close(fd); ++ return -1; ++ } ++ ++ handle->generation = reset.generation; ++ if (reset.node_id == reset.local_node_id) { ++ memcpy(&handle->reset, &reset, sizeof handle->reset); ++ handle->local_fd = fd; ++ } ++ ++ i++; ++ } ++ ++ return 0; ++} ++ ++int raw1394_reset_bus(raw1394handle_t handle) ++{ ++ raw1394_reset_bus_new(handle, RAW1394_LONG_RESET); ++} ++ ++int raw1394_reset_bus_new(raw1394handle_t handle, int type) ++{ ++ struct fw_cdev_initiate_bus_reset initiate; ++ ++ switch (type) { ++ case RAW1394_LONG_RESET: ++ initiate.type = FW_CDEV_LONG_RESET; ++ break; ++ case RAW1394_SHORT_RESET: ++ initiate.type = FW_CDEV_SHORT_RESET; ++ break; ++ } ++ ++ return ioctl(handle->local_fd, FW_CDEV_IOC_INITIATE_BUS_RESET, &initiate); ++} ++ ++bus_reset_handler_t raw1394_set_bus_reset_handler(raw1394handle_t handle, ++ bus_reset_handler_t new_h) ++{ ++ bus_reset_handler_t old_h = handle->bus_reset_handler; ++ ++ handle->bus_reset_handler = new_h; ++ ++ return old_h; ++} ++ ++unsigned int raw1394_get_generation(raw1394handle_t handle) ++{ ++ return handle->generation; ++} ++ ++void raw1394_update_generation(raw1394handle_t handle, unsigned int generation) ++{ ++ handle->generation = generation; ++} ++ ++tag_handler_t ++raw1394_set_tag_handler(raw1394handle_t handle, tag_handler_t new_h) ++{ ++ tag_handler_t old_h = handle->tag_handler; ++ ++ handle->tag_handler = new_h; ++ ++ return old_h; ++} ++ ++arm_tag_handler_t ++raw1394_set_arm_tag_handler(raw1394handle_t handle, arm_tag_handler_t new_h) ++{ ++ arm_tag_handler_t old_h = handle->arm_tag_handler; ++ ++ handle->arm_tag_handler = new_h; ++ ++ return old_h; ++} ++ ++fcp_handler_t ++raw1394_set_fcp_handler(raw1394handle_t handle, fcp_handler_t new_h) ++{ ++ fcp_handler_t old_h = handle->fcp_handler; ++ ++ handle->fcp_handler = new_h; ++ ++ return old_h; ++} ++ ++struct request_response_block { ++ struct raw1394_arm_request_response request_response; ++ struct raw1394_arm_request request; ++ struct raw1394_arm_response response; ++ unsigned char data[0]; ++}; ++ ++struct allocation { ++ struct address_closure closure; ++ byte_t *buffer; ++ octlet_t tag; ++ arm_options_t access_rights; ++ arm_options_t notification_options; ++ arm_options_t client_transactions; ++ nodeaddr_t offset; ++ size_t length; ++ unsigned char data[0]; ++}; ++ ++static int ++handle_arm_request(raw1394handle_t handle, struct address_closure *ac, ++ struct fw_cdev_event_request *request, int i) ++{ ++ struct allocation *allocation = (struct allocation *) ac; ++ struct request_response_block *rrb; ++ struct fw_cdev_send_response response; ++ struct raw1394_arm_request_response *arm_req_resp; ++ arm_options_t type; ++ size_t in_length; ++ int offset; ++ ++ offset = request->offset - allocation->offset; ++ response.serial = request->serial; ++ ++ switch (request->tcode) { ++ case TCODE_WRITE_QUADLET_REQUEST: ++ case TCODE_WRITE_BLOCK_REQUEST: ++ printf("got write request, offset=0x%012llx, length=%d\n", ++ request->offset, request->length); ++ ++ type = RAW1394_ARM_WRITE; ++ in_length = request->length; ++ response.rcode = RCODE_COMPLETE; ++ response.length = 0; ++ response.data = 0; ++ break; ++ ++ case TCODE_READ_QUADLET_REQUEST: ++ case TCODE_READ_BLOCK_REQUEST: ++ printf("got read request, offset=0x%012llx, length=%d\n", ++ request->offset, request->length); ++ ++ type = RAW1394_ARM_READ; ++ in_length = 0; ++ response.rcode = RCODE_COMPLETE; ++ response.length = request->length; ++ response.data = ptr_to_u64(allocation->data + offset); ++ break; ++ ++ case TCODE_LOCK_REQUEST: ++ type = RAW1394_ARM_LOCK; ++ in_length = request->length; ++ response.length = 4; ++ break; ++ ++ default: ++ type = 0; ++ break; ++ } ++ ++ if (!(allocation->access_rights & type)) { ++ response.rcode = RCODE_TYPE_ERROR; ++ response.length = 0; ++ response.data = 0; ++ if (ioctl(handle->devices[i].fd, ++ FW_CDEV_IOC_SEND_RESPONSE, &response) < 0) ++ return -1; ++ } else if (!(allocation->client_transactions & type)) { ++ if (type == RAW1394_ARM_WRITE) ++ memcpy(allocation->data + offset, ++ request->data, request->length); ++ else if (type == RAW1394_ARM_LOCK) ++ /* FIXME: do lock ops here */; ++ ++ if (ioctl(handle->devices[i].fd, ++ FW_CDEV_IOC_SEND_RESPONSE, &response) < 0) ++ return -1; ++ } ++ ++ if (!(allocation->notification_options & type)) ++ return 0; ++ ++ rrb = malloc(sizeof *rrb + in_length + response.length); ++ ++ rrb->request_response.request = &rrb->request; ++ rrb->request_response.response = &rrb->response; ++ ++ rrb->request.destination_nodeid = handle->reset.local_node_id; ++ rrb->request.source_nodeid = handle->devices[i].node_id; ++ rrb->request.destination_offset = request->offset; ++ rrb->request.tlabel = 0; ++ if (request->tcode < 0x10) { ++ rrb->request.tcode = request->tcode; ++ rrb->request.extended_transaction_code = 0; ++ } else { ++ rrb->request.tcode = TCODE_LOCK_REQUEST; ++ rrb->request.extended_transaction_code = request->tcode - 0x10; ++ } ++ rrb->request.generation = handle->reset.generation; ++ rrb->request.buffer_length = in_length; ++ memcpy(rrb->request.buffer, request->data, in_length); ++ ++ rrb->response.response_code = response.rcode; ++ rrb->response.buffer_length = response.length; ++ memcpy(rrb->response.buffer, ++ allocation->data + offset, response.length); ++ ++ handle->arm_tag_handler(handle, allocation->tag, type, ++ request->length, &rrb->request_response); ++} ++ ++int ++raw1394_arm_register(raw1394handle_t handle, nodeaddr_t start, ++ size_t length, byte_t *initial_value, ++ octlet_t arm_tag, arm_options_t access_rights, ++ arm_options_t notification_options, ++ arm_options_t client_transactions) ++{ ++ struct fw_cdev_allocate request; ++ struct allocation *allocation; ++ ++ allocation = malloc(sizeof *allocation + length); ++ if (allocation == NULL) ++ return -1; ++ ++ allocation->closure.callback = handle_arm_request; ++ allocation->buffer = initial_value; ++ allocation->tag = arm_tag; ++ allocation->access_rights = access_rights; ++ allocation->notification_options = notification_options; ++ allocation->client_transactions = client_transactions; ++ allocation->offset = start; ++ allocation->length = length; ++ if (initial_value != NULL) ++ memcpy(allocation->data, initial_value, length); ++ ++ request.offset = start; ++ request.length = length; ++ request.closure = ptr_to_u64(&allocation->closure); ++ ++ retval = ioctl(handle->local_fd, FW_CDEV_IOC_ALLOCATE, &request); ++ if (retval < 0) { ++ free(allocation); ++ return -1; ++ } ++ ++ allocation->next = handle->allocations; ++ handle->allocations = allocation; ++ ++ return 0; ++} ++ ++static struct allocation * ++lookup_allocation(raw1394handle_t handle, nodeaddr_t start, int delete) ++{ ++ struct allocation *a, **prev; ++ ++ prev = &handle->allocations; ++ for (a = handle->allocations; a != NULL; a = a->next) { ++ if (a->offset <= start && start < a->offset + a->length) ++ break; ++ prev = &a->next; ++ } ++ ++ if (a != NULL && delete) ++ *prev = a->next; ++ ++ return a; ++} ++ ++int ++raw1394_arm_unregister(raw1394handle_t handle, nodeaddr_t start) ++{ ++ struct fw_cdev_deallocate request; ++ struct allocation *allocation; ++ ++ allocation = lookup_allocation(handle, start, 1); ++ if (allocation == NULL) { ++ errno = EINVAL; ++ return -1; ++ } ++ ++ free(allocation); ++ ++ request.offset = start; ++ ++ return ioctl(handle->local_fd, FW_CDEV_IOC_DEALLOCATE, &request); ++} ++ ++int ++raw1394_arm_set_buf(raw1394handle_t handle, nodeaddr_t start, ++ size_t length, void *buf) ++{ ++ struct allocation *allocation; ++ ++ allocation = lookup_allocation(handle, start, 0); ++ if (allocation == NULL) { ++ errno = ENOENT; ++ return -1; ++ } ++ ++ memcpy(allocation->data + allocation->offset - start, buf, length); ++ ++ return 0; ++} ++ ++int ++raw1394_arm_get_buf(raw1394handle_t handle, nodeaddr_t start, ++ size_t length, void *buf) ++{ ++ struct allocation *allocation; ++ ++ allocation = lookup_allocation(handle, start, 0); ++ if (allocation == NULL) { ++ errno = ENOENT; ++ return -1; ++ } ++ ++ memcpy(buf, allocation->data + allocation->offset - start, length); ++ ++ return 0; ++} ++ ++int ++raw1394_echo_request(raw1394handle_t handle, quadlet_t data) ++{ ++ return write(handle->pipe_fds[1], &data, sizeof data); ++} ++ ++int raw1394_wake_up(raw1394handle_t handle) ++{ ++ return raw1394_echo_request(handle, 0); ++} ++ ++int raw1394_phy_packet_write (raw1394handle_t handle, quadlet_t data) ++{ ++} ++ ++int ++raw1394_start_phy_packet_write(raw1394handle_t handle, ++ quadlet_t data, unsigned long tag) ++{ ++} ++ ++static int ++send_request(raw1394handle_t handle, int tcode, ++ nodeid_t node, nodeaddr_t addr, ++ size_t length, void *in, void *out, unsigned long tag) ++{ ++ struct fw_cdev_send_request *request; ++ struct closure *closure; ++ int i, fd; ++ ++ if (node > handle->reset.root_node_id) { ++ handle->err = -RCODE_NO_ACK; ++ errno = raw1394_errcode_to_errno(handle->err); ++ return -1; ++ } ++ ++ i = handle->nodes[node & 0x3f]; ++ if (i == -1) { ++ handle->err = -RCODE_NO_ACK; ++ errno = raw1394_errcode_to_errno(handle->err); ++ return -1; ++ } ++ ++ if (handle->generation != handle->devices[i].generation) { ++ handle->err = -RCODE_GENERATION; ++ errno = raw1394_errcode_to_errno(handle->err); ++ return -1; ++ } ++ ++ closure = malloc(sizeof *closure); ++ if (closure == NULL) { ++ handle->err = -RCODE_SEND_ERROR; ++ errno = raw1394_errcode_to_errno(handle->err); ++ return -1; ++ } ++ ++ closure->data = out; ++ closure->length = length; ++ closure->tag = tag; ++ ++ request = (struct fw_cdev_send_request *) handle->buffer; ++ request->tcode = tcode; ++ request->generation = handle->generation; ++ request->offset = addr; ++ request->length = length; ++ request->closure = ptr_to_u64(closure); ++ request->data = ptr_to_u64(in); ++ ++ return ioctl(handle->devices[i].fd, FW_CDEV_IOC_SEND_REQUEST, request); ++} ++ ++int ++raw1394_start_read(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, ++ size_t length, quadlet_t *buffer, unsigned long tag) ++{ ++ int tcode; ++ ++ if (length == 4) ++ tcode = TCODE_READ_QUADLET_REQUEST; ++ else ++ tcode = TCODE_READ_BLOCK_REQUEST; ++ ++ return send_request(handle, tcode, ++ node, addr, length, NULL, buffer, tag); ++} ++ ++int ++raw1394_start_write(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, ++ size_t length, quadlet_t *data, unsigned long tag) ++{ ++ int tcode; ++ ++ if (length == 4) ++ tcode = TCODE_WRITE_QUADLET_REQUEST; ++ else ++ tcode = TCODE_WRITE_BLOCK_REQUEST; ++ ++ return send_request(handle, tcode, ++ node, addr, length, data, NULL, tag); ++} ++ ++static int ++setup_lock(int extcode, quadlet_t data, quadlet_t arg, quadlet_t *buffer) ++{ ++ switch (extcode) { ++ case RAW1394_EXTCODE_FETCH_ADD: ++ case RAW1394_EXTCODE_LITTLE_ADD: ++ buffer[0] = data; ++ return sizeof buffer[0]; ++ ++ case RAW1394_EXTCODE_MASK_SWAP: ++ case RAW1394_EXTCODE_COMPARE_SWAP: ++ case RAW1394_EXTCODE_BOUNDED_ADD: ++ case RAW1394_EXTCODE_WRAP_ADD: ++ buffer[0] = arg; ++ buffer[1] = data; ++ return sizeof buffer; ++ ++ default: ++ errno = EINVAL; ++ return -1; ++ } ++} ++ ++static int ++setup_lock64(int extcode, octlet_t data, octlet_t arg, octlet_t *buffer) ++{ ++ switch (extcode) { ++ case RAW1394_EXTCODE_FETCH_ADD: ++ case RAW1394_EXTCODE_LITTLE_ADD: ++ buffer[0] = data; ++ return sizeof buffer[0]; ++ ++ case RAW1394_EXTCODE_MASK_SWAP: ++ case RAW1394_EXTCODE_COMPARE_SWAP: ++ case RAW1394_EXTCODE_BOUNDED_ADD: ++ case RAW1394_EXTCODE_WRAP_ADD: ++ buffer[0] = arg; ++ buffer[1] = data; ++ return sizeof buffer; ++ ++ default: ++ errno = EINVAL; ++ return -1; ++ } ++} ++ ++int ++raw1394_start_lock(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, ++ unsigned int extcode, quadlet_t data, quadlet_t arg, ++ quadlet_t *result, unsigned long tag) ++{ ++ quadlet_t buffer[2]; ++ int length; ++ ++ length = setup_lock(extcode, data, arg, buffer); ++ if (length < 0) ++ return length; ++ ++ return send_request(handle, 16 + extcode, ++ node, addr, length, buffer, result, tag); ++} ++ ++int ++raw1394_start_lock64(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, ++ unsigned int extcode, octlet_t data, octlet_t arg, ++ octlet_t *result, unsigned long tag) ++{ ++ octlet_t buffer[2]; ++ int length; ++ ++ length = setup_lock64(extcode, data, arg, buffer); ++ if (length < 0) ++ return length; ++ ++ return send_request(handle, 16 + extcode, ++ node, addr, length, buffer, result, tag); ++} ++ ++int ++raw1394_start_async_stream(raw1394handle_t handle, unsigned int channel, ++ unsigned int tag, unsigned int sy, ++ unsigned int speed, size_t length, quadlet_t *data, ++ unsigned long rawtag) ++{ ++ /* FIXME: implement this? */ ++ return -1; ++} ++ ++ ++int ++raw1394_start_async_send(raw1394handle_t handle, ++ size_t length, size_t header_length, ++ unsigned int expect_response, ++ quadlet_t *data, unsigned long rawtag) ++{ ++ /* FIXME: implement this? */ ++ return -1; ++} ++ ++struct sync_data { ++ raw1394_errcode_t err; ++ int done; ++}; ++ ++static int ++sync_callback(raw1394handle_t handle, void *data, raw1394_errcode_t err) ++{ ++ struct sync_data *sd = data; ++ ++ sd->err = err; ++ sd->done = 1; ++} ++ ++static int ++send_request_sync(raw1394handle_t handle, int tcode, ++ nodeid_t node, nodeaddr_t addr, ++ size_t length, void *in, void *out) ++{ ++ struct raw1394_reqhandle reqhandle; ++ struct sync_data sd = { 0, 0 }; ++ int err; ++ ++ reqhandle.callback = sync_callback; ++ reqhandle.data = &sd; ++ ++ err = send_request(handle, tcode, node, addr, ++ length, in, out, (unsigned long) &reqhandle); ++ ++ while (!sd.done) { ++ if (err < 0) ++ return err; ++ err = raw1394_loop_iterate(handle); ++ } ++ ++ handle->err = sd.err; ++ errno = raw1394_errcode_to_errno(sd.err); ++ ++ return (errno ? -1 : 0); ++} ++ ++int ++raw1394_read(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, ++ size_t length, quadlet_t *buffer) ++{ ++ int tcode; ++ ++ if (length == 4) ++ tcode = TCODE_READ_QUADLET_REQUEST; ++ else ++ tcode = TCODE_READ_BLOCK_REQUEST; ++ ++ return send_request_sync(handle, tcode, ++ node, addr, length, NULL, buffer); ++} ++ ++int ++raw1394_write(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, ++ size_t length, quadlet_t *data) ++{ ++ int tcode; ++ ++ if (length == 4) ++ tcode = TCODE_WRITE_QUADLET_REQUEST; ++ else ++ tcode = TCODE_WRITE_BLOCK_REQUEST; ++ ++ return send_request_sync(handle, tcode, ++ node, addr, length, data, NULL); ++} ++ ++int ++raw1394_lock(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, ++ unsigned int extcode, quadlet_t data, quadlet_t arg, ++ quadlet_t *result) ++{ ++ quadlet_t buffer[2]; ++ size_t length; ++ ++ length = setup_lock(extcode, data, arg, buffer); ++ if (length < 0) ++ return length; ++ ++ return send_request_sync(handle, 16 + extcode, node, addr, ++ length, buffer, result); ++} ++ ++int ++raw1394_lock64(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, ++ unsigned int extcode, octlet_t data, octlet_t arg, ++ octlet_t *result) ++{ ++ octlet_t buffer[2]; ++ size_t length; ++ ++ length = setup_lock64(extcode, data, arg, buffer); ++ if (length < 0) ++ return length; ++ ++ return send_request_sync(handle, 16 + extcode, node, addr, ++ length, buffer, result); ++} ++ ++int ++raw1394_async_stream(raw1394handle_t handle, unsigned int channel, ++ unsigned int tag, unsigned int sy, unsigned int speed, ++ size_t length, quadlet_t *data) ++{ ++ /* FIXME: implement this? */ ++ return -1; ++} ++ ++int ++raw1394_async_send(raw1394handle_t handle, ++ size_t length, size_t header_length, ++ unsigned int expect_response, ++ quadlet_t *data) ++{ ++ /* FIXME: implement this? */ ++ return -1; ++} ++ ++int ++raw1394_start_fcp_listen(raw1394handle_t handle) ++{ ++ struct fw_cdev_allocate request; ++ struct address_closure *closure; ++ ++ closure = malloc(sizeof *closure); ++ if (closure == NULL) ++ return -1; ++ ++ closure->callback = handle_fcp_request; ++ ++ request.offset = CSR_REGISTER_BASE + CSR_FCP_COMMAND; ++ request.length = CSR_FCP_END - CSR_FCP_COMMAND; ++ request.closure = ptr_to_u64(closure); ++ if (ioctl(handle->local_fd, FW_CDEV_IOC_ALLOCATE, &request) < 0) ++ return -1; ++ ++ return 0; ++} ++ ++int ++raw1394_stop_fcp_listen(raw1394handle_t handle) ++{ ++ struct fw_cdev_deallocate request; ++ ++ request.offset = CSR_REGISTER_BASE + CSR_FCP_COMMAND; ++ ++ return ioctl(handle->local_fd, FW_CDEV_IOC_DEALLOCATE, &request); ++} ++ ++const char * ++raw1394_get_libversion(void) ++{ ++ return VERSION " (Juju)"; ++} ++ ++int ++raw1394_update_config_rom(raw1394handle_t handle, const quadlet_t *new_rom, ++ size_t size, unsigned char rom_version) ++{ ++ return -1; ++} ++ ++int ++raw1394_get_config_rom(raw1394handle_t handle, quadlet_t *buffer, ++ size_t buffersize, size_t *rom_size, ++ unsigned char *rom_version) ++{ ++ struct fw_cdev_get_info get_info; ++ int err; ++ ++ get_info.version = FW_CDEV_VERSION; ++ get_info.rom = ptr_to_u64(buffer); ++ get_info.rom_length = buffersize; ++ get_info.bus_reset = 0; ++ ++ err = ioctl(handle->local_fd, FW_CDEV_IOC_GET_INFO, &get_info); ++ if (err) ++ return err; ++ ++ *rom_size = get_info.rom_length; ++ *rom_version = 0; ++ ++ return 0; ++} ++ ++int ++raw1394_bandwidth_modify (raw1394handle_t handle, unsigned int bandwidth, ++ enum raw1394_modify_mode mode) ++{ ++ /* FIXME: copy and audit the libraw1394 version */ ++} ++ ++int ++raw1394_channel_modify (raw1394handle_t handle, unsigned int channel, ++ enum raw1394_modify_mode mode) ++{ ++ /* FIXME: copy and audit the libraw1394 version */ ++} diff --git a/libraw1394.spec b/libraw1394.spec index 8fe099a..4cf008f 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -30,6 +30,10 @@ Development libraries needed to build applications against libraw1394. %patch0 -p0 -b .juju %build + +test -e %{_builddir}/fw-device-cdev.h || \ + cp %{_sourcedir}/fw-device-cdev.h %{_builddir} + aclocal autoconf automake diff --git a/sources b/sources index 790bc15..09a25fe 100644 --- a/sources +++ b/sources @@ -1,2 +1 @@ e6210ff05b7f4ec0401ad3d11f493e1a libraw1394-1.2.1.tar.gz -1be31713ca1e4d3387310fd96274ebb4 fw-device-cdev.h From 712d67d1b655c70a70506e74ea9663042d5cfcf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Tue, 20 Mar 2007 01:12:20 +0000 Subject: [PATCH 027/100] - Add support for new stack (juju). --- libraw1394.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/libraw1394.spec b/libraw1394.spec index 4cf008f..a2fa2d7 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -10,6 +10,7 @@ ExcludeArch: s390 s390x BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: autoconf automake libtool +Source1: fw-device-cdev.h Patch0: libraw1394-juju.patch %description From c7c35b57d16156fbcf9603acb2d72f6946266f0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Tue, 20 Mar 2007 16:14:44 +0000 Subject: [PATCH 028/100] Update juju patch. --- libraw1394-juju.patch | 642 +++++++++++++++++++++++++++++------------- 1 file changed, 441 insertions(+), 201 deletions(-) diff --git a/libraw1394-juju.patch b/libraw1394-juju.patch index c04f781..0f4d039 100644 --- a/libraw1394-juju.patch +++ b/libraw1394-juju.patch @@ -211,7 +211,7 @@ Index: juju/raw1394-iso.c =================================================================== --- juju/raw1394-iso.c (revision 0) +++ juju/raw1394-iso.c (revision 0) -@@ -0,0 +1,197 @@ +@@ -0,0 +1,377 @@ +/* -*- c-basic-offset: 8 -*- + * + * raw1394-iso.c -- Emulation of the raw1394 rawiso API on the juju stack @@ -235,9 +235,204 @@ Index: juju/raw1394-iso.c + +#include +#include ++#include ++#include ++#include ++#include ++#include + +#include "juju.h" + ++static int ++refill_xmit_buffer(raw1394handle_t handle, struct fw_cdev_queue_iso *queue_iso) ++{ ++ int i; ++ struct fw_cdev_iso_packet *p = handle->iso.packets; ++ enum raw1394_iso_disposition d; ++ unsigned int len, dropped; ++ unsigned char tag, sy, *data, *buffer; ++ int cycle; ++ ++ buffer = handle->iso.buffer + ++ handle->iso.packet_index * handle->iso.max_packet_size; ++ data = buffer; ++ ++ for (i = 0; i < handle->iso.irq_interval; i++) { ++ cycle = -1; ++ dropped = 0; ++ d = handle->iso.xmit_handler(handle, data, ++ &len, &tag, &sy, cycle, dropped); ++ /* FIXME: handle the different dispositions. */ ++ ++ p->payload_length = len; ++ p->interrupt = handle->iso.packet_phase == 0; ++ p->skip = 0; ++ p->tag = tag; ++ p->sy = sy; ++ p->header_length = 0; ++ ++ data += handle->iso.max_packet_size; ++ handle->iso.packet_index++; ++ if (handle->iso.packet_index == handle->iso.buf_packets) { ++ handle->iso.packet_index = 0; ++ break; ++ } ++ ++ handle->iso.packet_phase++; ++ if (handle->iso.packet_phase == handle->iso.irq_interval) ++ handle->iso.packet_phase = 0; ++ ++ } ++ ++ queue_iso->packets = ptr_to_u64(handle->iso.packets); ++ queue_iso->size = ++ handle->iso.irq_interval * sizeof handle->iso.packets[0]; ++ queue_iso->data = ptr_to_u64(buffer); ++} ++ ++static int ++flush_xmit_packets(raw1394handle_t handle, int limit) ++{ ++ struct fw_cdev_queue_iso queue_iso; ++ int len; ++ ++ while (handle->iso.packet_index + handle->iso.irq_interval <= limit) { ++ if (handle->iso.queue_iso.size == 0) ++ refill_xmit_buffer(handle, &queue_iso); ++ len = ioctl(handle->iso.fd, ++ FW_CDEV_IOC_QUEUE_ISO, &queue_iso); ++ if (len < 0) ++ return -1; ++ if (handle->iso.queue_iso.size > 0) ++ break; ++ } ++ ++ return 0; ++} ++ ++int raw1394_iso_xmit_start(raw1394handle_t handle, int start_on_cycle, ++ int prebuffer_packets) ++{ ++ struct fw_cdev_start_iso start_iso; ++ int retval; ++ ++ if (prebuffer_packets == -1) ++ prebuffer_packets = handle->iso.irq_interval; ++ ++ flush_xmit_packets(handle, prebuffer_packets); ++ ++ start_iso.cycle = start_on_cycle; ++ ++ retval = ioctl(handle->iso.fd, FW_CDEV_IOC_START_ISO, &start_iso); ++ if (retval < 0) ++ return retval; ++ ++ return flush_xmit_packets(handle, handle->iso.buf_packets); ++} ++ ++static int ++handle_recv_packets(raw1394handle_t handle, ++ struct fw_cdev_event_iso_interrupt *interrupt) ++{ ++ enum raw1394_iso_disposition d; ++ quadlet_t header, *p, *end; ++ unsigned int len, cycle, dropped; ++ unsigned char channel, tag, sy; ++ unsigned char *data; ++ ++ p = interrupt->header; ++ end = (void *) interrupt->header + interrupt->header_length; ++ cycle = interrupt->cycle; ++ data = NULL; ++ ++ while (p < end) { ++ header = be32_to_cpu(*p++); ++ len = header >> 8; ++ channel = header >> 8; ++ tag = header >> 8; ++ sy = header >> 8; ++ ++ d = handle->iso.recv_handler(handle, data, len, channel, ++ tag, sy, cycle, dropped); ++ cycle++; ++ } ++} ++ ++int raw1394_iso_recv_start(raw1394handle_t handle, int start_on_cycle, ++ int tag_mask, int sync) ++{ ++ struct fw_cdev_start_iso start_iso; ++ ++ start_iso.cycle = start_on_cycle; ++ start_iso.tags = ++ tag_mask == -1 ? FW_CDEV_ISO_CONTEXT_MATCH_ALL_TAGS : tag_mask; ++ /* sync is documented as 'not used' */ ++ start_iso.sync = 0; ++ ++ return ioctl(handle->iso.fd, FW_CDEV_IOC_START_ISO, &start_iso); ++} ++ ++static int handle_iso_event(raw1394handle_t handle, ++ struct epoll_closure *closure, __uint32_t events) ++{ ++ struct fw_cdev_event_iso_interrupt *interrupt; ++ int len; ++ ++ len = read(handle->iso.fd, handle->buffer, sizeof handle->buffer); ++ if (len < 0) ++ return -1; ++ ++ interrupt = (struct fw_cdev_event_iso_interrupt *) handle->buffer; ++ if (interrupt->type != FW_CDEV_EVENT_BUS_RESET) ++ return 0; ++ ++ switch (handle->iso.type) { ++ case FW_CDEV_ISO_CONTEXT_TRANSMIT: ++ handle->iso.packet_index -= handle->iso.irq_interval; ++ return flush_xmit_packets(handle, handle->iso.buf_packets); ++ case FW_CDEV_ISO_CONTEXT_RECEIVE: ++ break; ++ default: ++ /* Doesn't happen. */ ++ break; ++ } ++} ++ ++int raw1394_iso_xmit_write(raw1394handle_t handle, unsigned char *data, ++ unsigned int len, unsigned char tag, ++ unsigned char sy) ++{ ++ struct fw_cdev_iso_packet packet; ++ ++ packet.payload_length = len; ++ packet.interrupt = handle->iso.packet_phase == 0; ++ packet.skip = 0; ++ packet.tag = tag; ++ packet.sy = sy; ++ packet.header_length = 0; ++ ++ handle->iso.packet_phase++; ++ if (handle->iso.packet_phase == handle->iso.irq_interval) ++ handle->iso.packet_phase = 0; ++ ++ /* FIXME: circular buffer goo. */ ++ ++ memcpy(handle->iso.head, data, len); ++ handle->iso.head += len; ++ ++ return -1; ++} ++ ++int raw1394_iso_xmit_sync(raw1394handle_t handle) ++{ ++ /* FIXME: queue a skip packet and wait for that interrupt. */ ++} ++ ++int raw1394_iso_recv_flush(raw1394handle_t handle) ++{ ++ /* FIXME: huh, we'll need kernel support here... */ ++} ++ +int raw1394_iso_xmit_init(raw1394handle_t handle, + raw1394_iso_xmit_handler_t handler, + unsigned int buf_packets, @@ -247,24 +442,66 @@ Index: juju/raw1394-iso.c + int irq_interval) +{ + struct fw_cdev_create_iso_context create; ++ struct epoll_event ep; ++ int retval; + -+ handle->iso.buffer = -+ mmap(NULL, buf_packets * max_packet_size, -+ PROT_READ | PROT_WRITE, MAP_SHARED, handle->local_fd, 0); ++ if (handle->iso.fd != -1) { ++ errno = EBUSY; ++ return -1; ++ } + -+ if (handle->iso.buffer == MAP_FAILED) ++ handle->iso.type = FW_CDEV_ISO_CONTEXT_TRANSMIT; ++ handle->iso.irq_interval = irq_interval; ++ handle->iso.xmit_handler = handler; ++ handle->iso.buf_packets = buf_packets; ++ handle->iso.max_packet_size = max_packet_size; ++ handle->iso.packet_index = 0; ++ handle->iso.packet_phase = 0; ++ handle->iso.queue_iso.size = 0; ++ handle->iso.packets = ++ malloc(irq_interval * sizeof handle->iso.packets[0]); ++ if (handle->iso.packets == NULL) ++ return -1; ++ ++ handle->iso.fd = open(handle->local_filename, O_RDWR); ++ if (handle->iso.fd < 0) { ++ free(handle->iso.packets); + return -1; ++ } ++ ++ handle->iso.closure.func = handle_iso_event; ++ ep.events = EPOLLIN; ++ ep.data.ptr = &handle->iso.closure; ++ if (epoll_ctl(handle->epoll_fd, EPOLL_CTL_ADD, ++ handle->iso.fd, &ep) < 0) { ++ close(handle->iso.fd); ++ free(handle->iso.packets); ++ return -1; ++ } + + create.type = FW_CDEV_ISO_CONTEXT_TRANSMIT; + create.channel = channel; + create.speed = speed; + -+ handle->iso.type = FW_CDEV_ISO_CONTEXT_TRANSMIT; -+ handle->iso.irq_interval = irq_interval; -+ handle->iso.xmit_handler = handler; ++ retval = ioctl(handle->iso.fd, ++ FW_CDEV_IOC_CREATE_ISO_CONTEXT, &create); ++ if (retval < 0) { ++ close(handle->iso.fd); ++ free(handle->iso.packets); ++ return retval; ++ } + -+ return ioctl(handle->local_fd, -+ FW_CDEV_IOC_CREATE_ISO_CONTEXT, &create); ++ handle->iso.buffer = ++ mmap(NULL, buf_packets * max_packet_size, ++ PROT_READ | PROT_WRITE, MAP_SHARED, handle->iso.fd, 0); ++ ++ if (handle->iso.buffer == MAP_FAILED) { ++ close(handle->iso.fd); ++ free(handle->iso.packets); ++ return -1; ++ } ++ ++ return 0; +} + +int raw1394_iso_recv_init(raw1394handle_t handle, @@ -277,27 +514,32 @@ Index: juju/raw1394-iso.c +{ + struct fw_cdev_create_iso_context create; + ++ if (handle->iso.fd != -1) { ++ errno = EBUSY; ++ return -1; ++ } ++ + /* FIXME: Do we need this? When would you ever want this...? */ + if (mode == RAW1394_DMA_PACKET_PER_BUFFER) + return -1; + + handle->iso.buffer = + mmap(NULL, buf_packets * max_packet_size, -+ PROT_READ, MAP_SHARED, handle->local_fd, 0); ++ PROT_READ, MAP_SHARED, handle->iso.fd, 0); + + if (handle->iso.buffer == MAP_FAILED) + return -1; + -+ create.type = FW_CDEV_ISO_CONTEXT_TRANSMIT; ++ create.type = FW_CDEV_ISO_CONTEXT_RECEIVE; + create.channel = channel; + create.speed = 0; + create.header_size = 0; /* Never strip any headers. */ + -+ handle->iso.type = FW_CDEV_ISO_CONTEXT_TRANSMIT; ++ handle->iso.type = FW_CDEV_ISO_CONTEXT_RECEIVE; + handle->iso.irq_interval = irq_interval; + handle->iso.recv_handler = handler; + -+ return ioctl(handle->local_fd, ++ return ioctl(handle->iso.fd, + FW_CDEV_IOC_CREATE_ISO_CONTEXT, &create); +} + @@ -308,6 +550,7 @@ Index: juju/raw1394-iso.c + int irq_interval) +{ + /* FIXME: gah */ ++ errno = ENOSYS; + return -1; +} + @@ -315,6 +558,7 @@ Index: juju/raw1394-iso.c + unsigned char channel) +{ + /* FIXME: multichannel */ ++ errno = ENOSYS; + return -1; +} + @@ -322,98 +566,34 @@ Index: juju/raw1394-iso.c + unsigned char channel) +{ + /* FIXME: multichannel */ ++ errno = ENOSYS; + return -1; +} + +int raw1394_iso_recv_set_channel_mask(raw1394handle_t handle, u_int64_t mask) +{ + /* FIXME: multichannel */ ++ errno = ENOSYS; + return -1; +} + -+int raw1394_iso_xmit_start(raw1394handle_t handle, int start_on_cycle, -+ int prebuffer_packets) -+{ -+ struct fw_cdev_start_iso start_iso; -+ -+ handle->iso.start_cycle = start_on_cycle; -+ if (prebuffer_packets == -1) -+ handle->iso.prebuffer = 64; -+ else -+ handle->iso.prebuffer = prebuffer_packets; -+ -+ if (handle->iso.buffered_packet_count < handle->iso.prebuffer) -+ return 0; -+ -+ start_iso.cycle = handle->iso.start_cycle; -+ -+ return ioctl(handle->local_fd, FW_CDEV_IOC_START_ISO, &start_iso); -+} -+ -+int raw1394_iso_recv_start(raw1394handle_t handle, int start_on_cycle, -+ int tag_mask, int sync) -+{ -+ struct fw_cdev_start_iso start_iso; -+ -+ start_iso.cycle = start_on_cycle; -+ start_iso.tags = -+ tag_mask == -1 ? FW_CDEV_ISO_CONTEXT_MATCH_ALL_TAGS : tag_mask; -+ /* sync is documented as 'not used' */ -+ start_iso.sync = 0; -+ -+ return ioctl(handle->local_fd, FW_CDEV_IOC_START_ISO, &start_iso); -+} -+ -+int raw1394_iso_xmit_write(raw1394handle_t handle, unsigned char *data, -+ unsigned int len, unsigned char tag, -+ unsigned char sy) -+{ -+ struct fw_cdev_iso_packet packet; -+ -+ packet.payload_length = len; -+ packet.interrupt = handle->iso.packet_phase == 0; -+ packet.skip = 0; -+ packet.tag = tag; -+ packet.sy = sy; -+ packet.header_length = 0; -+ -+ handle->iso.packet_phase++; -+ if (handle->iso.packet_phase == handle->iso.irq_interval) -+ handle->iso.packet_phase = 0; -+ -+ /* FIXME: circular buffer goo. */ -+ -+ memcpy(handle->iso.head, data, len); -+ handle->iso.head += len; -+ -+ return -1; -+} -+ -+int raw1394_iso_xmit_sync(raw1394handle_t handle) -+{ -+ /* FIXME: queue a skip packet and wait for that interrupt. */ -+} -+ -+int raw1394_iso_recv_flush(raw1394handle_t handle) -+{ -+ /* FIXME: huh, we'll need kernel support here... */ -+} -+ +void raw1394_iso_stop(raw1394handle_t handle) +{ -+ ioctl(handle->local_fd, FW_CDEV_IOC_STOP_ISO); ++ ioctl(handle->iso.fd, FW_CDEV_IOC_STOP_ISO); +} + +void raw1394_iso_shutdown(raw1394handle_t handle) +{ -+ /* Maybe we should just open a new fd for the local device and -+ * close that here... */ ++ munmap(handle->iso.buffer, ++ handle->iso.buf_packets * handle->iso.max_packet_size); ++ close(handle->iso.fd); ++ free(handle->iso.packets); +} Index: juju/juju.h =================================================================== --- juju/juju.h (revision 0) +++ juju/juju.h (revision 0) -@@ -0,0 +1,107 @@ +@@ -0,0 +1,139 @@ +/* -*- c-basic-offset: 8 -*- + * + * juju.h -- Internal header file for raw1394 emulation @@ -439,6 +619,7 @@ Index: juju/juju.h +#define __juju_h + +#include ++#include +#include +#include "../src/raw1394.h" +#include "../src/csr.h" @@ -449,12 +630,31 @@ Index: juju/juju.h +#define ptr_to_u64(p) ((__u64)(unsigned long)(p)) +#define u64_to_ptr(p) ((void *)(unsigned long)(p)) + ++static inline __u32 ++be32_to_cpu(__u32 q) ++{ ++ union { char c[4]; __u32 q; } u = { { 1, 0, 0, 0 } }; ++ ++ return u.q == 1 ? bswap_32(q) : q; ++} ++ ++static inline __u32 ++cpu_to_be32(__u32 q) ++{ ++ return be32_to_cpu(q); ++} ++ +#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0]) + +#define BUFFER_SIZE (16 * 1024) + +#define MAX_PORTS 16 + ++struct epoll_closure { ++ int (*func)(raw1394handle_t handle, ++ struct epoll_closure *closure, __uint32_t events); ++}; ++ +struct port { + char device_file[32]; + char *name; @@ -463,23 +663,25 @@ Index: juju/juju.h +}; + +#define MAX_DEVICES 63 -+#define INOTIFY_INDEX 64 -+#define PIPE_INDEX 65 ++#define FILENAME_SIZE 16 + +struct device { ++ struct epoll_closure closure; + int fd; + int node_id; + int generation; -+ char filename[16]; ++ char filename[FILENAME_SIZE]; +}; + -+struct closure { ++struct request_closure { + void *data; + size_t length; + unsigned long tag; + struct raw1394_reqhandle reqhandle; +}; + ++struct allocation; ++ +struct raw1394_handle { + struct port ports[MAX_PORTS]; + int port_count; @@ -492,29 +694,39 @@ Index: juju/juju.h + tag_handler_t tag_handler; + arm_tag_handler_t arm_tag_handler; + fcp_handler_t fcp_handler; ++ struct allocation *allocations; + + int epoll_fd; + int inotify_fd; + int inotify_watch; + int pipe_fds[2]; + ++ struct epoll_closure pipe_closure; ++ struct epoll_closure inotify_closure; ++ + struct device devices[MAX_DEVICES]; + int nodes[MAX_DEVICES]; + int local_fd; ++ char local_filename[FILENAME_SIZE]; + + struct fw_cdev_event_bus_reset reset; + + struct { ++ struct epoll_closure closure; ++ int fd; + int type; + int irq_interval; -+ int prebuffer; -+ int start_cycle; -+ int buffered_packet_count; ++ int packet_index; + int packet_phase; ++ int buf_packets; ++ int max_packet_size; + enum raw1394_iso_dma_recv_mode recv_mode; + raw1394_iso_xmit_handler_t xmit_handler; + raw1394_iso_recv_handler_t recv_handler; + unsigned char *buffer, *head, *tail; ++ ++ struct fw_cdev_queue_iso queue_iso; ++ struct fw_cdev_iso_packet *packets; + } iso; + + char buffer[BUFFER_SIZE]; @@ -538,7 +750,7 @@ Index: juju/raw1394.c =================================================================== --- juju/raw1394.c (revision 0) +++ juju/raw1394.c (revision 0) -@@ -0,0 +1,1336 @@ +@@ -0,0 +1,1364 @@ +/* -*- c-basic-offset: 8 -*- + * + * raw1394.c -- Emulation of the raw1394 API on the juju stack @@ -564,6 +776,7 @@ Index: juju/raw1394.c +#include +#include +#include ++#include +#include +#include +#include @@ -650,7 +863,7 @@ Index: juju/raw1394.c + + rh = (struct raw1394_arm_reqhandle *) arm_tag; + -+ rh->arm_callback(handle, data, length, rh->pcontext, type); ++ return rh->arm_callback(handle, data, length, rh->pcontext, type); +} + +static int @@ -671,7 +884,6 @@ Index: juju/raw1394.c + struct fw_cdev_event_bus_reset reset; + int fd, err, i; + struct port *ports; -+ size_t size; + + ports = handle->ports; + memset(ports, 0, sizeof handle->ports); @@ -720,7 +932,8 @@ Index: juju/raw1394.c +} + +static int -+handle_echo_pipe(raw1394handle_t handle) ++handle_echo_pipe(raw1394handle_t handle, ++ struct epoll_closure *ec, __uint32_t events) +{ + quadlet_t value; + @@ -731,76 +944,6 @@ Index: juju/raw1394.c +} + +static int -+handle_new_device(raw1394handle_t handle) -+{ -+ struct inotify_event *event; -+ char filename[32]; -+ struct fw_cdev_get_info info; -+ struct fw_cdev_event_bus_reset reset; -+ struct epoll_event ep; -+ int i, len, fd, phy_id; -+ -+ event = (struct inotify_event *) handle->buffer; -+ len = read(handle->inotify_fd, event, BUFFER_SIZE); -+ if (!(event->mask & IN_CREATE)) -+ return -1; -+ if (strncmp(event->name, -+ FW_DEVICE_PREFIX, strlen(FW_DEVICE_PREFIX)) != 0) -+ return 0; -+ snprintf(filename, sizeof filename, FW_DEVICE_DIR "/%s", event->name); -+ fd = open(filename, O_RDWR); -+ if (fd < 0) { -+ switch (errno) { -+ case ENOENT: -+ /* Huh, it disappeared before we could -+ * open it. */ -+ return 0; -+ case EACCES: -+ /* We don't have permission to talk to -+ * this device, maybe it's a storage -+ * device. */ -+ return 0; -+ default: -+ /* Anything else is bad news. */ -+ return -1; -+ } -+ } -+ -+ info.version = FW_CDEV_VERSION; -+ info.rom = 0; -+ info.rom_length = 0; -+ info.bus_reset = ptr_to_u64(&reset); -+ if (ioctl(fd, FW_CDEV_IOC_GET_INFO, &info) < 0) { -+ close(fd); -+ return -1; -+ } -+ -+ for (i = 0; i < MAX_DEVICES; i++) -+ if (handle->devices[i].node_id == -1) -+ break; -+ if (i == MAX_DEVICES) { -+ close(fd); -+ return -1; -+ } -+ -+ phy_id = reset.node_id & 0x3f; -+ handle->nodes[phy_id] = i; -+ handle->devices[i].node_id = reset.node_id; -+ handle->devices[i].generation = reset.generation; -+ handle->devices[i].fd = fd; -+ strncpy(handle->devices[i].filename, filename, -+ sizeof handle->devices[i].filename); -+ ep.events = EPOLLIN; -+ ep.data.u32 = i; -+ if (epoll_ctl(handle->epoll_fd, EPOLL_CTL_ADD, fd, &ep) < 0) { -+ close(fd); -+ return -1; -+ } -+ -+ return 0; -+} -+ -+static int +handle_lost_device(raw1394handle_t handle, int i) +{ + int phy_id; @@ -849,26 +992,32 @@ Index: juju/raw1394.c + + is_response = request->offset >= CSR_REGISTER_BASE + CSR_FCP_RESPONSE; + -+ handle->fcp_handler(handle, -+ handle->devices[i].node_id, -+ is_response, -+ request->length, -+ (unsigned char *) request->data); ++ return handle->fcp_handler(handle, ++ handle->devices[i].node_id, ++ is_response, ++ request->length, ++ (unsigned char *) request->data); +} + +static int -+handle_device_event(raw1394handle_t handle, int i) ++handle_device_event(raw1394handle_t handle, ++ struct epoll_closure *ec, __uint32_t events) +{ + union { + struct fw_cdev_event_bus_reset bus_reset; + struct fw_cdev_event_response response; + struct fw_cdev_event_request request; -+ struct fw_cdev_event_iso_interrupt interrupt; + } *u; ++ struct device *device = (struct device *) ec; + struct address_closure *ac; -+ struct closure *closure; ++ struct request_closure *rc; + raw1394_errcode_t errcode; -+ int fd, last, len, phy_id; ++ int len, phy_id; ++ int i; ++ ++ i = device - handle->devices; ++ if (events == EPOLLHUP) ++ return handle_lost_device(handle, i); + + len = read(handle->devices[i].fd, + handle->buffer, sizeof handle->buffer); @@ -894,29 +1043,102 @@ Index: juju/raw1394.c + u->bus_reset.generation); + + case FW_CDEV_EVENT_RESPONSE: -+ closure = u64_to_ptr(u->response.closure); ++ rc = u64_to_ptr(u->response.closure); + -+ if (closure->data != NULL) -+ memcpy(closure->data, -+ u->response.data, closure->length); ++ if (rc->data != NULL) ++ memcpy(rc->data, u->response.data, rc->length); + + errcode = juju_to_raw1394_errcode(u->response.rcode); + -+ return handle->tag_handler(handle, closure->tag, errcode); ++ return handle->tag_handler(handle, rc->tag, errcode); + + case FW_CDEV_EVENT_REQUEST: + ac = u64_to_ptr(u->request.closure); + return ac->callback(handle, ac, &u->request, i); + ++ default: + case FW_CDEV_EVENT_ISO_INTERRUPT: ++ /* Never happens. */ ++ return -1; ++ } ++} ++ ++static int ++handle_inotify(raw1394handle_t handle, struct epoll_closure *ec, ++ __uint32_t events) ++{ ++ struct inotify_event *event; ++ char filename[32]; ++ struct fw_cdev_get_info info; ++ struct fw_cdev_event_bus_reset reset; ++ struct epoll_event ep; ++ int i, len, fd, phy_id; ++ ++ event = (struct inotify_event *) handle->buffer; ++ len = read(handle->inotify_fd, event, BUFFER_SIZE); ++ if (!(event->mask & IN_CREATE)) ++ return -1; ++ if (strncmp(event->name, ++ FW_DEVICE_PREFIX, strlen(FW_DEVICE_PREFIX)) != 0) + return 0; ++ snprintf(filename, sizeof filename, FW_DEVICE_DIR "/%s", event->name); ++ fd = open(filename, O_RDWR); ++ if (fd < 0) { ++ switch (errno) { ++ case ENOENT: ++ /* Huh, it disappeared before we could ++ * open it. */ ++ return 0; ++ case EACCES: ++ /* We don't have permission to talk to ++ * this device, maybe it's a storage ++ * device. */ ++ return 0; ++ default: ++ /* Anything else is bad news. */ ++ return -1; ++ } + } ++ ++ info.version = FW_CDEV_VERSION; ++ info.rom = 0; ++ info.rom_length = 0; ++ info.bus_reset = ptr_to_u64(&reset); ++ if (ioctl(fd, FW_CDEV_IOC_GET_INFO, &info) < 0) { ++ close(fd); ++ return -1; ++ } ++ ++ for (i = 0; i < MAX_DEVICES; i++) ++ if (handle->devices[i].node_id == -1) ++ break; ++ if (i == MAX_DEVICES) { ++ close(fd); ++ return -1; ++ } ++ ++ phy_id = reset.node_id & 0x3f; ++ handle->nodes[phy_id] = i; ++ handle->devices[i].node_id = reset.node_id; ++ handle->devices[i].generation = reset.generation; ++ handle->devices[i].fd = fd; ++ strncpy(handle->devices[i].filename, filename, ++ sizeof handle->devices[i].filename); ++ handle->devices[i].closure.func = handle_device_event; ++ ep.events = EPOLLIN; ++ ep.data.ptr = &handle->devices[i].closure; ++ if (epoll_ctl(handle->epoll_fd, EPOLL_CTL_ADD, fd, &ep) < 0) { ++ close(fd); ++ return -1; ++ } ++ ++ return 0; +} + +int raw1394_loop_iterate(raw1394handle_t handle) +{ -+ int i, last, count, retval = 0; -+ ++ int i, count, retval = 0; ++ struct epoll_closure *closure; + struct epoll_event ep[32]; + + count = epoll_wait(handle->epoll_fd, ep, ARRAY_LENGTH(ep), -1); @@ -924,14 +1146,8 @@ Index: juju/raw1394.c + return -1; + + for (i = 0; i < count; i++) { -+ if (ep[i].data.u32 == PIPE_INDEX) -+ retval = handle_echo_pipe(handle); -+ else if (ep[i].data.u32 == INOTIFY_INDEX) -+ retval = handle_new_device(handle); -+ else if (ep[i].events & EPOLLHUP) -+ retval = handle_lost_device(handle, ep[i].data.u32); -+ else if (ep[i].events & EPOLLIN) -+ retval = handle_device_event(handle, ep[i].data.u32); ++ closure = ep[i].data.ptr; ++ retval = closure->func(handle, closure, ep[i].events); + } + + /* It looks like we have to add this work-around to get epoll @@ -951,10 +1167,13 @@ Index: juju/raw1394.c + + handle->tag_handler = default_tag_handler; + handle->arm_tag_handler = default_arm_tag_handler; ++ handle->allocations = NULL; + + handle->notify_bus_reset = RAW1394_NOTIFY_ON; + handle->bus_reset_handler = default_bus_reset_handler; + ++ handle->iso.fd = -1; ++ + handle->epoll_fd = epoll_create(16); + if (handle->epoll_fd < 0) + goto out_handle; @@ -971,14 +1190,16 @@ Index: juju/raw1394.c + if (handle->inotify_watch < 0) + goto out_inotify; + ++ handle->pipe_closure.func = handle_echo_pipe; + ep.events = EPOLLIN; -+ ep.data.u32 = PIPE_INDEX; ++ ep.data.ptr = &handle->pipe_closure; + if (epoll_ctl(handle->epoll_fd, EPOLL_CTL_ADD, + handle->pipe_fds[0], &ep) < 0) + goto out_inotify; + ++ handle->inotify_closure.func = handle_inotify; + ep.events = EPOLLIN; -+ ep.data.u32 = INOTIFY_INDEX; ++ ep.data.ptr = &handle->inotify_closure; + if (epoll_ctl(handle->epoll_fd, EPOLL_CTL_ADD, + handle->inotify_fd, &ep) < 0) + goto out_inotify; @@ -1150,8 +1371,9 @@ Index: juju/raw1394.c + strncpy(handle->devices[i].filename, filename, + sizeof handle->devices[i].filename); + ++ handle->devices[i].closure.func = handle_device_event; + ep.events = EPOLLIN; -+ ep.data.u32 = i; ++ ep.data.ptr = &handle->devices[i].closure; + if (epoll_ctl(handle->epoll_fd, EPOLL_CTL_ADD, fd, &ep) < 0) { + close(fd); + return -1; @@ -1161,6 +1383,8 @@ Index: juju/raw1394.c + if (reset.node_id == reset.local_node_id) { + memcpy(&handle->reset, &reset, sizeof handle->reset); + handle->local_fd = fd; ++ strncpy(handle->local_filename, filename, ++ sizeof handle->local_filename); + } + + i++; @@ -1171,7 +1395,7 @@ Index: juju/raw1394.c + +int raw1394_reset_bus(raw1394handle_t handle) +{ -+ raw1394_reset_bus_new(handle, RAW1394_LONG_RESET); ++ return raw1394_reset_bus_new(handle, RAW1394_LONG_RESET); +} + +int raw1394_reset_bus_new(raw1394handle_t handle, int type) @@ -1187,7 +1411,8 @@ Index: juju/raw1394.c + break; + } + -+ return ioctl(handle->local_fd, FW_CDEV_IOC_INITIATE_BUS_RESET, &initiate); ++ return ioctl(handle->local_fd, ++ FW_CDEV_IOC_INITIATE_BUS_RESET, &initiate); +} + +bus_reset_handler_t raw1394_set_bus_reset_handler(raw1394handle_t handle, @@ -1249,6 +1474,7 @@ Index: juju/raw1394.c + +struct allocation { + struct address_closure closure; ++ struct allocation *next; + byte_t *buffer; + octlet_t tag; + arm_options_t access_rights; @@ -1266,7 +1492,6 @@ Index: juju/raw1394.c + struct allocation *allocation = (struct allocation *) ac; + struct request_response_block *rrb; + struct fw_cdev_send_response response; -+ struct raw1394_arm_request_response *arm_req_resp; + arm_options_t type; + size_t in_length; + int offset; @@ -1306,6 +1531,7 @@ Index: juju/raw1394.c + break; + + default: ++ in_length = 0; + type = 0; + break; + } @@ -1357,8 +1583,9 @@ Index: juju/raw1394.c + memcpy(rrb->response.buffer, + allocation->data + offset, response.length); + -+ handle->arm_tag_handler(handle, allocation->tag, type, -+ request->length, &rrb->request_response); ++ return handle->arm_tag_handler(handle, allocation->tag, type, ++ request->length, ++ &rrb->request_response); +} + +int @@ -1370,6 +1597,7 @@ Index: juju/raw1394.c +{ + struct fw_cdev_allocate request; + struct allocation *allocation; ++ int retval; + + allocation = malloc(sizeof *allocation + length); + if (allocation == NULL) @@ -1486,12 +1714,16 @@ Index: juju/raw1394.c + +int raw1394_phy_packet_write (raw1394handle_t handle, quadlet_t data) +{ ++ errno = ENOSYS; ++ return -1; +} + +int +raw1394_start_phy_packet_write(raw1394handle_t handle, + quadlet_t data, unsigned long tag) +{ ++ errno = ENOSYS; ++ return -1; +} + +static int @@ -1500,8 +1732,8 @@ Index: juju/raw1394.c + size_t length, void *in, void *out, unsigned long tag) +{ + struct fw_cdev_send_request *request; -+ struct closure *closure; -+ int i, fd; ++ struct request_closure *closure; ++ int i; + + if (node > handle->reset.root_node_id) { + handle->err = -RCODE_NO_ACK; @@ -1685,6 +1917,8 @@ Index: juju/raw1394.c + + sd->err = err; + sd->done = 1; ++ ++ return 0; +} + +static int @@ -1867,6 +2101,9 @@ Index: juju/raw1394.c + enum raw1394_modify_mode mode) +{ + /* FIXME: copy and audit the libraw1394 version */ ++ ++ errno = ENOSYS; ++ return -1; +} + +int @@ -1874,4 +2111,7 @@ Index: juju/raw1394.c + enum raw1394_modify_mode mode) +{ + /* FIXME: copy and audit the libraw1394 version */ ++ ++ errno = ENOSYS; ++ return -1; +} From ef2a11fff1ce64599150124115d3b9272d0954ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Tue, 20 Mar 2007 16:23:18 +0000 Subject: [PATCH 029/100] More updates to patch, run autoheader. --- libraw1394-juju.patch | 16 ++++++++++++---- libraw1394.spec | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/libraw1394-juju.patch b/libraw1394-juju.patch index 0f4d039..b49312b 100644 --- a/libraw1394-juju.patch +++ b/libraw1394-juju.patch @@ -211,7 +211,7 @@ Index: juju/raw1394-iso.c =================================================================== --- juju/raw1394-iso.c (revision 0) +++ juju/raw1394-iso.c (revision 0) -@@ -0,0 +1,377 @@ +@@ -0,0 +1,385 @@ +/* -*- c-basic-offset: 8 -*- + * + * raw1394-iso.c -- Emulation of the raw1394 rawiso API on the juju stack @@ -288,6 +288,8 @@ Index: juju/raw1394-iso.c + queue_iso->size = + handle->iso.irq_interval * sizeof handle->iso.packets[0]; + queue_iso->data = ptr_to_u64(buffer); ++ ++ return 0; +} + +static int @@ -329,7 +331,7 @@ Index: juju/raw1394-iso.c + + return flush_xmit_packets(handle, handle->iso.buf_packets); +} -+ ++ +static int +handle_recv_packets(raw1394handle_t handle, + struct fw_cdev_event_iso_interrupt *interrupt) @@ -356,6 +358,8 @@ Index: juju/raw1394-iso.c + tag, sy, cycle, dropped); + cycle++; + } ++ ++ return 0; +} + +int raw1394_iso_recv_start(raw1394handle_t handle, int start_on_cycle, @@ -391,10 +395,10 @@ Index: juju/raw1394-iso.c + handle->iso.packet_index -= handle->iso.irq_interval; + return flush_xmit_packets(handle, handle->iso.buf_packets); + case FW_CDEV_ISO_CONTEXT_RECEIVE: -+ break; ++ return handle_recv_packets(handle, interrupt); + default: + /* Doesn't happen. */ -+ break; ++ return -1; + } +} + @@ -426,11 +430,15 @@ Index: juju/raw1394-iso.c +int raw1394_iso_xmit_sync(raw1394handle_t handle) +{ + /* FIXME: queue a skip packet and wait for that interrupt. */ ++ ++ return 0; +} + +int raw1394_iso_recv_flush(raw1394handle_t handle) +{ + /* FIXME: huh, we'll need kernel support here... */ ++ ++ return 0; +} + +int raw1394_iso_xmit_init(raw1394handle_t handle, diff --git a/libraw1394.spec b/libraw1394.spec index a2fa2d7..c85c29a 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -36,6 +36,7 @@ test -e %{_builddir}/fw-device-cdev.h || \ cp %{_sourcedir}/fw-device-cdev.h %{_builddir} aclocal +autoheader autoconf automake %configure --disable-static --with-juju-dir=$PWD/.. From 5e2c1a2bbf55ac722ddde0a175628d541b8f6254 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Wed, 4 Apr 2007 01:26:40 +0000 Subject: [PATCH 030/100] - Update juju patch with rawiso support. --- libraw1394-juju.patch | 1294 ++++++++++++++++++++++++----------------- libraw1394.spec | 5 +- 2 files changed, 773 insertions(+), 526 deletions(-) diff --git a/libraw1394-juju.patch b/libraw1394-juju.patch index b49312b..e18e779 100644 --- a/libraw1394-juju.patch +++ b/libraw1394-juju.patch @@ -1,164 +1,21 @@ -Index: tools/testlibraw.c -=================================================================== ---- tools/testlibraw.c (revision 171) -+++ tools/testlibraw.c (working copy) -@@ -1,4 +1,5 @@ --/* -+/* -*- c-basic-offset: 8 -*- -+ * - * libraw1394 - library for raw access to the 1394 bus with the Linux subsystem. - * - * Copyright (C) 1999,2000 Andreas Bombe -@@ -13,12 +14,13 @@ - #include - #include - #include -+#include - - #include "../src/raw1394.h" - #include "../src/csr.h" - - --#define TESTADDR (CSR_REGISTER_BASE + CSR_CYCLE_TIME) -+#define TESTADDR (CSR_REGISTER_BASE + CSR_CONFIG_ROM) - - const char not_compatible[] = "\ - This libraw1394 does not work with your version of Linux. You need a different\n\ -@@ -45,12 +47,18 @@ - return 0; - } - -+static const unsigned char fcp_data[] = -+ { 0x1, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }; -+ - int my_fcp_handler(raw1394handle_t handle, nodeid_t nodeid, int response, - size_t length, unsigned char *data) - { - printf("got fcp %s from node %d of %d bytes:", - (response ? "response" : "command"), nodeid & 0x3f, length); - -+ if (memcmp(fcp_data, data, sizeof fcp_data) != 0) -+ printf("ERROR: fcp payload not correct\n"); -+ - while (length) { - printf(" %02x", *data); - data++; -@@ -62,7 +70,48 @@ - return 0; - } - -+static void -+test_fcp(raw1394handle_t handle) -+{ -+ printf("\ntesting FCP monitoring on local node\n"); -+ raw1394_set_fcp_handler(handle, my_fcp_handler); -+ raw1394_start_fcp_listen(handle); -+ raw1394_write(handle, raw1394_get_local_id(handle), -+ CSR_REGISTER_BASE + CSR_FCP_COMMAND, sizeof(fcp_data), -+ (quadlet_t *)fcp_data); -+ raw1394_write(handle, raw1394_get_local_id(handle), -+ CSR_REGISTER_BASE + CSR_FCP_RESPONSE, sizeof(fcp_data), -+ (quadlet_t *)fcp_data); -+} - -+static void -+read_topology_map(raw1394handle_t handle) -+{ -+ quadlet_t map[70]; -+ nodeid_t local_id; -+ int node_count, self_id_count, i, retval; -+ -+ local_id = raw1394_get_local_id(handle) | 0xffc0; -+ -+ retval = raw1394_read(handle, local_id, -+ CSR_REGISTER_BASE + CSR_TOPOLOGY_MAP, 12, &map[0]); -+ if (retval < 0) -+ perror("topology map: raw1394_read failed with error"); -+ -+ self_id_count = ntohl(map[2]) & 0xffff; -+ node_count = ntohl(map[2]) >> 16; -+ retval = raw1394_read(handle, local_id, -+ CSR_REGISTER_BASE + CSR_TOPOLOGY_MAP + 12, -+ self_id_count * sizeof map[0], &map[3]); -+ if (retval < 0) -+ perror("topology map: raw1394_read failed with error"); -+ -+ printf("topology map: %d nodes, %d self ids, generation %d\n", -+ node_count, self_id_count, ntohl(map[1])); -+ for (i = 0; i < self_id_count; i++) -+ printf(" 0x%08x\n", ntohl(map[3 + i])); -+} -+ - int main(int argc, char **argv) - { - raw1394handle_t handle; -@@ -73,7 +122,6 @@ - int retval; - - struct pollfd pfd; -- unsigned char fcp_test[] = { 0x1, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }; - quadlet_t rom[0x100]; - size_t rom_size; - unsigned char rom_version; -@@ -150,18 +198,9 @@ - } - } - -- printf("\ntesting FCP monitoring on local node\n"); -- raw1394_set_fcp_handler(handle, my_fcp_handler); -- raw1394_start_fcp_listen(handle); -- raw1394_write(handle, raw1394_get_local_id(handle), -- CSR_REGISTER_BASE + CSR_FCP_COMMAND, sizeof(fcp_test), -- (quadlet_t *)fcp_test); -- raw1394_write(handle, raw1394_get_local_id(handle), -- CSR_REGISTER_BASE + CSR_FCP_RESPONSE, sizeof(fcp_test), -- (quadlet_t *)fcp_test); -+ test_fcp(handle); -+ read_topology_map(handle); - -- -- - printf("testing config rom stuff\n"); - retval=raw1394_get_config_rom(handle, rom, 0x100, &rom_size, &rom_version); - printf("get_config_rom returned %d, romsize %d, rom_version %d\n",retval,rom_size,rom_version); -@@ -176,16 +215,19 @@ - retval=raw1394_update_config_rom(handle, rom, rom_size, rom_version); - printf("update_config_rom returned %d\n",retval); - -+ printf("\nposting 0xdeadbeef as an echo request\n"); -+ raw1394_echo_request(handle, 0xdeadbeef); - -- -- printf("\npolling for leftover messages\n"); -+ printf("polling for leftover messages\n"); - pfd.fd = raw1394_get_fd(handle); - pfd.events = POLLIN; - pfd.revents = 0; - while (1) { - retval = poll(&pfd, 1, 10); - if (retval < 1) break; -- raw1394_loop_iterate(handle); -+ retval = raw1394_loop_iterate(handle); -+ if (retval != 0) -+ printf("raw1394_loop_iterate() returned 0x%08x\n", retval); - } +diff --git a/Makefile.am b/Makefile.am +index 04ed38a..21df527 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -1,6 +1,7 @@ + # process this file with automake to create a Makefile.in - if (retval < 0) perror("poll failed"); -Index: tools/Makefile.am -=================================================================== ---- tools/Makefile.am (revision 171) -+++ tools/Makefile.am (working copy) -@@ -2,4 +2,4 @@ +-SUBDIRS = src tools doc debian ++SUBDIRS = $(LIB_SUBDIR) tools doc debian ++DIST_SUBDIRS = src juju - # testlibraw - bin_PROGRAMS = testlibraw sendiso dumpiso --LDADD = ../src/libraw1394.la -+LDADD = ../$(LIB_SUBDIR)/libraw1394.la -Index: configure.ac -=================================================================== ---- configure.ac (revision 171) -+++ configure.ac (working copy) -@@ -24,13 +24,35 @@ + pkgconfigdir = @libdir@/pkgconfig + pkgconfig_DATA = libraw1394.pc +diff --git a/configure.ac b/configure.ac +index fe23ca8..7e5dd66 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -24,6 +24,27 @@ AC_SUBST(lt_major) AC_SUBST(lt_revision) AC_SUBST(lt_age) @@ -171,7 +28,7 @@ Index: configure.ac + LIB_SUBDIR=src +fi +AC_SUBST(LIB_SUBDIR) - ++ +AC_ARG_WITH(fw-device-prefix, + [ --with-fw-device-prefix= Prefix of firewire device file names (default "fw").], + [FW_DEVICE_PREFIX="\"$withval\""], [FW_DEVICE_PREFIX="\"fw\""]) @@ -183,10 +40,10 @@ Index: configure.ac + [Prefix of firewire device file names.]) +AC_DEFINE_UNQUOTED(FW_DEVICE_DIR, $FW_DEVICE_DIR, + [Directory to watch for firewire device files.]) -+ + #CFLAGS=${CFLAGS:-"-Wall"} AC_OUTPUT([ - Makefile +@@ -31,6 +52,7 @@ Makefile libraw1394.pc libraw1394.spec src/Makefile @@ -194,24 +51,175 @@ Index: configure.ac tools/Makefile doc/Makefile doc/testlibraw.1 -Index: Makefile.am -=================================================================== ---- Makefile.am (revision 171) -+++ Makefile.am (working copy) -@@ -1,6 +1,7 @@ - # process this file with automake to create a Makefile.in - --SUBDIRS = src tools doc debian -+SUBDIRS = $(LIB_SUBDIR) tools doc debian -+DIST_SUBDIRS = src juju - - pkgconfigdir = @libdir@/pkgconfig - pkgconfig_DATA = libraw1394.pc -Index: juju/raw1394-iso.c -=================================================================== ---- juju/raw1394-iso.c (revision 0) -+++ juju/raw1394-iso.c (revision 0) -@@ -0,0 +1,385 @@ +diff --git a/juju/Makefile.am b/juju/Makefile.am +new file mode 100644 +index 0000000..6fd6a5e +--- /dev/null ++++ b/juju/Makefile.am +@@ -0,0 +1,8 @@ ++lib_LTLIBRARIES = libraw1394.la ++ ++INCLUDES = -I$(JUJU_DIR) ++libraw1394_la_LDFLAGS = -version-info @lt_major@:@lt_revision@:@lt_age@ ++ ++libraw1394_la_SOURCES = raw1394.c raw1394-iso.c juju.h ++ ++pkginclude_HEADERS = ../src/raw1394.h ../src/csr.h ../src/ieee1394.h +diff --git a/juju/juju.h b/juju/juju.h +new file mode 100644 +index 0000000..8c18630 +--- /dev/null ++++ b/juju/juju.h +@@ -0,0 +1,143 @@ ++/* -*- c-basic-offset: 8 -*- ++ * ++ * juju.h -- Internal header file for raw1394 emulation ++ * ++ * Copyright (C) 2007 Kristian Hoegsberg ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software Foundation, ++ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ */ ++ ++#ifndef __juju_h ++#define __juju_h ++ ++#include ++#include ++#include ++#include "../src/raw1394.h" ++#include "../src/csr.h" ++#include "config.h" ++ ++#define ACK_COMPLETE 1 ++ ++#define ptr_to_u64(p) ((__u64)(unsigned long)(p)) ++#define u64_to_ptr(p) ((void *)(unsigned long)(p)) ++ ++static inline __u32 ++be32_to_cpu(__u32 q) ++{ ++ union { char c[4]; __u32 q; } u = { { 1, 0, 0, 0 } }; ++ ++ return u.q == 1 ? bswap_32(q) : q; ++} ++ ++static inline __u32 ++cpu_to_be32(__u32 q) ++{ ++ return be32_to_cpu(q); ++} ++ ++#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0]) ++ ++#define BUFFER_SIZE (16 * 1024) ++ ++#define MAX_PORTS 16 ++ ++struct epoll_closure { ++ int (*func)(raw1394handle_t handle, ++ struct epoll_closure *closure, __uint32_t events); ++}; ++ ++struct port { ++ char device_file[32]; ++ char *name; ++ int node_count; ++ int card; ++}; ++ ++#define MAX_DEVICES 63 ++#define FILENAME_SIZE 16 ++ ++struct device { ++ struct epoll_closure closure; ++ int fd; ++ int node_id; ++ int generation; ++ char filename[FILENAME_SIZE]; ++}; ++ ++struct request_closure { ++ void *data; ++ size_t length; ++ unsigned long tag; ++ struct raw1394_reqhandle reqhandle; ++}; ++ ++struct allocation; ++ ++struct raw1394_handle { ++ struct port ports[MAX_PORTS]; ++ int port_count; ++ int err; ++ int generation; ++ void *user_data; ++ int notify_bus_reset; ++ ++ bus_reset_handler_t bus_reset_handler; ++ tag_handler_t tag_handler; ++ arm_tag_handler_t arm_tag_handler; ++ fcp_handler_t fcp_handler; ++ __u32 fcp_allocation_handle; ++ struct allocation *allocations; ++ ++ int epoll_fd; ++ int inotify_fd; ++ int inotify_watch; ++ int pipe_fds[2]; ++ ++ struct epoll_closure pipe_closure; ++ struct epoll_closure inotify_closure; ++ ++ struct device devices[MAX_DEVICES]; ++ int nodes[MAX_DEVICES]; ++ int local_fd; ++ char local_filename[FILENAME_SIZE]; ++ ++ struct fw_cdev_event_bus_reset reset; ++ ++ struct { ++ struct epoll_closure closure; ++ int fd; ++ int type; ++ int irq_interval; ++ int packet_phase; ++ int packet_count; ++ int buf_packets; ++ int max_packet_size; ++ int packet_header_index; ++ int prebuffer; ++ int start_on_cycle; ++ enum raw1394_iso_dma_recv_mode recv_mode; ++ raw1394_iso_xmit_handler_t xmit_handler; ++ raw1394_iso_recv_handler_t recv_handler; ++ unsigned char *buffer, *buffer_end, *head; ++ unsigned char *tail, *first_payload; ++ ++ struct fw_cdev_iso_packet *packets; ++ } iso; ++ ++ char buffer[BUFFER_SIZE]; ++}; ++ ++#endif +diff --git a/juju/raw1394-iso.c b/juju/raw1394-iso.c +new file mode 100644 +index 0000000..bbf49f0 +--- /dev/null ++++ b/juju/raw1394-iso.c +@@ -0,0 +1,547 @@ +/* -*- c-basic-offset: 8 -*- + * + * raw1394-iso.c -- Emulation of the raw1394 rawiso API on the juju stack @@ -238,75 +246,89 @@ Index: juju/raw1394-iso.c +#include +#include +#include ++#include +#include +#include + +#include "juju.h" + -+static int -+refill_xmit_buffer(raw1394handle_t handle, struct fw_cdev_queue_iso *queue_iso) ++static enum raw1394_iso_disposition ++queue_xmit_packets(raw1394handle_t handle) +{ -+ int i; + struct fw_cdev_iso_packet *p = handle->iso.packets; ++ struct fw_cdev_queue_iso queue_iso; + enum raw1394_iso_disposition d; + unsigned int len, dropped; -+ unsigned char tag, sy, *data, *buffer; -+ int cycle; -+ -+ buffer = handle->iso.buffer + -+ handle->iso.packet_index * handle->iso.max_packet_size; -+ data = buffer; ++ unsigned char tag, sy, *first_payload; ++ int cycle, i; + ++ first_payload = handle->iso.head; + for (i = 0; i < handle->iso.irq_interval; i++) { + cycle = -1; + dropped = 0; -+ d = handle->iso.xmit_handler(handle, data, ++ ++ if (handle->iso.head + handle->iso.max_packet_size > ++ handle->iso.buffer_end) { ++ handle->iso.head = handle->iso.buffer; ++ break; ++ } ++ ++ d = handle->iso.xmit_handler(handle, handle->iso.head, + &len, &tag, &sy, cycle, dropped); -+ /* FIXME: handle the different dispositions. */ ++ if (d != RAW1394_ISO_OK) ++ break; + + p->payload_length = len; -+ p->interrupt = handle->iso.packet_phase == 0; ++ p->interrupt = ++ handle->iso.packet_phase == handle->iso.irq_interval - 1; + p->skip = 0; + p->tag = tag; + p->sy = sy; + p->header_length = 0; + -+ data += handle->iso.max_packet_size; -+ handle->iso.packet_index++; -+ if (handle->iso.packet_index == handle->iso.buf_packets) { -+ handle->iso.packet_index = 0; -+ break; -+ } -+ ++ handle->iso.head += len; ++ handle->iso.packet_count++; + handle->iso.packet_phase++; ++ + if (handle->iso.packet_phase == handle->iso.irq_interval) + handle->iso.packet_phase = 0; -+ + } + -+ queue_iso->packets = ptr_to_u64(handle->iso.packets); -+ queue_iso->size = -+ handle->iso.irq_interval * sizeof handle->iso.packets[0]; -+ queue_iso->data = ptr_to_u64(buffer); ++ queue_iso.packets = ptr_to_u64(handle->iso.packets); ++ queue_iso.size = i * sizeof handle->iso.packets[0]; ++ queue_iso.data = ptr_to_u64(first_payload); + -+ return 0; ++ len = ioctl(handle->iso.fd, FW_CDEV_IOC_QUEUE_ISO, &queue_iso); ++ if (len < 0) ++ return RAW1394_ISO_ERROR; ++ ++ return d; +} + +static int +flush_xmit_packets(raw1394handle_t handle, int limit) +{ -+ struct fw_cdev_queue_iso queue_iso; ++ enum raw1394_iso_disposition d; + int len; + -+ while (handle->iso.packet_index + handle->iso.irq_interval <= limit) { -+ if (handle->iso.queue_iso.size == 0) -+ refill_xmit_buffer(handle, &queue_iso); -+ len = ioctl(handle->iso.fd, -+ FW_CDEV_IOC_QUEUE_ISO, &queue_iso); -+ if (len < 0) ++ if (handle->iso.xmit_handler == NULL) ++ return 0; ++ ++ if (limit < handle->iso.irq_interval) ++ limit = handle->iso.irq_interval; ++ ++ while (handle->iso.packet_count + handle->iso.irq_interval <= limit) { ++ d = queue_xmit_packets(handle); ++ switch (d) { ++ case RAW1394_ISO_DEFER: ++ case RAW1394_ISO_AGAIN: ++ return 0; ++ case RAW1394_ISO_ERROR: + return -1; -+ if (handle->iso.queue_iso.size > 0) -+ break; ++ case RAW1394_ISO_STOP: ++ raw1394_iso_stop(handle); ++ return 0; ++ } + } + + return 0; @@ -318,23 +340,72 @@ Index: juju/raw1394-iso.c + struct fw_cdev_start_iso start_iso; + int retval; + -+ if (prebuffer_packets == -1) -+ prebuffer_packets = handle->iso.irq_interval; ++ if (prebuffer_packets == -1) ++ prebuffer_packets = handle->iso.irq_interval; ++ ++ handle->iso.prebuffer = prebuffer_packets; ++ handle->iso.start_on_cycle = start_on_cycle; ++ ++ flush_xmit_packets(handle, prebuffer_packets); ++ ++ if (handle->iso.prebuffer <= handle->iso.packet_count) { ++ start_iso.cycle = start_on_cycle; ++ ++ retval = ioctl(handle->iso.fd, ++ FW_CDEV_IOC_START_ISO, &start_iso); ++ if (retval < 0) ++ return retval; ++ } ++ ++ return flush_xmit_packets(handle, handle->iso.buf_packets); ++} ++ ++static int ++queue_recv_packets(raw1394handle_t handle) ++{ ++ struct fw_cdev_queue_iso queue_iso; ++ struct fw_cdev_iso_packet *p = handle->iso.packets; ++ unsigned int len; ++ unsigned char *first_payload; ++ int i; ++ ++ first_payload = handle->iso.head; ++ for (i = 0; i < handle->iso.irq_interval; i++, p++) { ++ if (handle->iso.head + handle->iso.max_packet_size > ++ handle->iso.buffer_end) { ++ handle->iso.head = handle->iso.buffer; ++ break; ++ } ++ ++ p->payload_length = handle->iso.max_packet_size; ++ p->interrupt = handle->iso.packet_phase == handle->iso.irq_interval - 1; ++ p->skip = 0; ++ p->tag = 0; ++ p->sy = 0; ++ p->header_length = 4; + -+ flush_xmit_packets(handle, prebuffer_packets); ++ handle->iso.head += handle->iso.max_packet_size; ++ handle->iso.packet_count++; ++ handle->iso.packet_phase++; + -+ start_iso.cycle = start_on_cycle; ++ if (handle->iso.packet_phase == handle->iso.irq_interval) ++ handle->iso.packet_phase = 0; ++ } + -+ retval = ioctl(handle->iso.fd, FW_CDEV_IOC_START_ISO, &start_iso); -+ if (retval < 0) -+ return retval; ++ queue_iso.packets = ptr_to_u64(handle->iso.packets); ++ queue_iso.size = i * sizeof handle->iso.packets[0]; ++ queue_iso.data = ptr_to_u64(first_payload); + -+ return flush_xmit_packets(handle, handle->iso.buf_packets); ++ len = ioctl(handle->iso.fd, FW_CDEV_IOC_QUEUE_ISO, &queue_iso); ++ if (len < 0) ++ return -1; ++ ++ return 0; +} + -+static int -+handle_recv_packets(raw1394handle_t handle, -+ struct fw_cdev_event_iso_interrupt *interrupt) ++static enum raw1394_iso_disposition ++flush_recv_packets(raw1394handle_t handle, ++ struct fw_cdev_event_iso_interrupt *interrupt) +{ + enum raw1394_iso_disposition d; + quadlet_t header, *p, *end; @@ -345,20 +416,46 @@ Index: juju/raw1394-iso.c + p = interrupt->header; + end = (void *) interrupt->header + interrupt->header_length; + cycle = interrupt->cycle; -+ data = NULL; ++ dropped = 0; + + while (p < end) { + header = be32_to_cpu(*p++); -+ len = header >> 8; -+ channel = header >> 8; -+ tag = header >> 8; -+ sy = header >> 8; -+ -+ d = handle->iso.recv_handler(handle, data, len, channel, -+ tag, sy, cycle, dropped); ++ len = header >> 16; ++ tag = (header >> 14) & 0x3; ++ channel = (header >> 8) & 0x3f; ++ sy = header & 0x0f; ++ ++ d = handle->iso.recv_handler(handle, handle->iso.tail, len, ++ channel, tag, sy, cycle, dropped); ++ if (d != RAW1394_ISO_OK) ++ /* FIXME: we need to save the headers so we ++ * can restart this loop. */ ++ break; + cycle++; ++ ++ handle->iso.tail += handle->iso.max_packet_size; ++ handle->iso.packet_count--; ++ if (handle->iso.tail == handle->iso.buffer_end) ++ handle->iso.tail = handle->iso.buffer; ++ } ++ ++ switch (d) { ++ case RAW1394_ISO_OK: ++ case RAW1394_ISO_DEFER: ++ break; ++ ++ case RAW1394_ISO_ERROR: ++ return -1; ++ ++ case RAW1394_ISO_STOP: ++ raw1394_iso_stop(handle); ++ return 0; + } + ++ while (handle->iso.packet_count + handle->iso.irq_interval <= ++ handle->iso.buf_packets) ++ queue_recv_packets(handle); ++ + return 0; +} + @@ -367,6 +464,10 @@ Index: juju/raw1394-iso.c +{ + struct fw_cdev_start_iso start_iso; + ++ while (handle->iso.packet_count + handle->iso.irq_interval <= ++ handle->iso.buf_packets) ++ queue_recv_packets(handle); ++ + start_iso.cycle = start_on_cycle; + start_iso.tags = + tag_mask == -1 ? FW_CDEV_ISO_CONTEXT_MATCH_ALL_TAGS : tag_mask; @@ -387,15 +488,15 @@ Index: juju/raw1394-iso.c + return -1; + + interrupt = (struct fw_cdev_event_iso_interrupt *) handle->buffer; -+ if (interrupt->type != FW_CDEV_EVENT_BUS_RESET) ++ if (interrupt->type != FW_CDEV_EVENT_ISO_INTERRUPT) + return 0; + + switch (handle->iso.type) { + case FW_CDEV_ISO_CONTEXT_TRANSMIT: -+ handle->iso.packet_index -= handle->iso.irq_interval; ++ handle->iso.packet_count -= handle->iso.irq_interval; + return flush_xmit_packets(handle, handle->iso.buf_packets); + case FW_CDEV_ISO_CONTEXT_RECEIVE: -+ return handle_recv_packets(handle, interrupt); ++ return flush_recv_packets(handle, interrupt); + default: + /* Doesn't happen. */ + return -1; @@ -406,25 +507,81 @@ Index: juju/raw1394-iso.c + unsigned int len, unsigned char tag, + unsigned char sy) +{ -+ struct fw_cdev_iso_packet packet; ++ struct fw_cdev_queue_iso queue_iso; ++ struct fw_cdev_start_iso start_iso; ++ struct fw_cdev_iso_packet *p; ++ ++ { ++ int i; ++ __u32 *p = (__u32 *) data; + -+ packet.payload_length = len; -+ packet.interrupt = handle->iso.packet_phase == 0; -+ packet.skip = 0; -+ packet.tag = tag; -+ packet.sy = sy; -+ packet.header_length = 0; ++ for (i = 0; i < 10; i++) ++ fprintf(stderr, "0x%08x ", p[i]); ++ fprintf(stderr, "\n"); ++ } ++ ++ if (len > handle->iso.max_packet_size) { ++ errno = EINVAL; ++ return -1; ++ } ++ ++ /* Block until we have space for another packet. */ ++ while (handle->iso.packet_count + handle->iso.irq_interval > ++ handle->iso.buf_packets) ++ raw1394_loop_iterate(handle); ++ ++ p = &handle->iso.packets[handle->iso.packet_header_index]; ++ p->payload_length = len; ++ p->interrupt = ++ handle->iso.packet_phase == handle->iso.irq_interval - 1; ++ p->skip = 0; ++ p->tag = tag; ++ p->sy = sy; ++ p->header_length = 0; ++ ++ memcpy(handle->iso.head, data, len); + ++ handle->iso.head += len; ++ handle->iso.packet_count++; + handle->iso.packet_phase++; ++ handle->iso.packet_header_index++; ++ + if (handle->iso.packet_phase == handle->iso.irq_interval) + handle->iso.packet_phase = 0; + -+ /* FIXME: circular buffer goo. */ ++ if (handle->iso.head + handle->iso.max_packet_size > handle->iso.buffer_end) ++ handle->iso.head = handle->iso.buffer; + -+ memcpy(handle->iso.head, data, len); -+ handle->iso.head += len; ++ /* Queue the packets in the kernel if we filled up the packets ++ * array or wrapped the payload buffer. */ ++ if (handle->iso.packet_header_index == handle->iso.irq_interval || ++ handle->iso.head == handle->iso.buffer) { ++ queue_iso.packets = ptr_to_u64(handle->iso.packets); ++ queue_iso.size = handle->iso.packet_header_index * sizeof handle->iso.packets[0]; ++ queue_iso.data = ptr_to_u64(handle->iso.first_payload); ++ handle->iso.packet_header_index = 0; ++ handle->iso.first_payload = handle->iso.head; + -+ return -1; ++ len = ioctl(handle->iso.fd, FW_CDEV_IOC_QUEUE_ISO, &queue_iso); ++ if (len < 0) ++ return -1; ++ } ++ ++ /* Start the streaming if it's not already running and if ++ * we've buffered up enough packets. */ ++ if (handle->iso.prebuffer > 0 && ++ handle->iso.packet_count >= handle->iso.prebuffer) { ++ /* Set this to 0 to indicate that we're running. */ ++ handle->iso.prebuffer = 0; ++ start_iso.cycle = handle->iso.start_on_cycle; ++ ++ len = ioctl(handle->iso.fd, ++ FW_CDEV_IOC_START_ISO, &start_iso); ++ if (len < 0) ++ return len; ++ } ++ ++ return 0; +} + +int raw1394_iso_xmit_sync(raw1394handle_t handle) @@ -441,33 +598,38 @@ Index: juju/raw1394-iso.c + return 0; +} + -+int raw1394_iso_xmit_init(raw1394handle_t handle, -+ raw1394_iso_xmit_handler_t handler, -+ unsigned int buf_packets, -+ unsigned int max_packet_size, -+ unsigned char channel, -+ enum raw1394_iso_speed speed, -+ int irq_interval) ++static int ++iso_init(raw1394handle_t handle, int type, ++ raw1394_iso_xmit_handler_t xmit_handler, ++ raw1394_iso_recv_handler_t recv_handler, ++ unsigned int buf_packets, ++ unsigned int max_packet_size, ++ unsigned char channel, ++ enum raw1394_iso_speed speed, ++ int irq_interval) +{ + struct fw_cdev_create_iso_context create; + struct epoll_event ep; -+ int retval; ++ int retval, prot; + + if (handle->iso.fd != -1) { + errno = EBUSY; + return -1; + } + -+ handle->iso.type = FW_CDEV_ISO_CONTEXT_TRANSMIT; -+ handle->iso.irq_interval = irq_interval; -+ handle->iso.xmit_handler = handler; ++ handle->iso.type = type; ++ if (irq_interval < 0) ++ handle->iso.irq_interval = 256; ++ else ++ handle->iso.irq_interval = irq_interval; ++ handle->iso.xmit_handler = xmit_handler; ++ handle->iso.recv_handler = recv_handler; + handle->iso.buf_packets = buf_packets; + handle->iso.max_packet_size = max_packet_size; -+ handle->iso.packet_index = 0; + handle->iso.packet_phase = 0; -+ handle->iso.queue_iso.size = 0; ++ handle->iso.packet_count = 0; + handle->iso.packets = -+ malloc(irq_interval * sizeof handle->iso.packets[0]); ++ malloc(handle->iso.irq_interval * sizeof handle->iso.packets[0]); + if (handle->iso.packets == NULL) + return -1; + @@ -487,9 +649,10 @@ Index: juju/raw1394-iso.c + return -1; + } + -+ create.type = FW_CDEV_ISO_CONTEXT_TRANSMIT; ++ create.type = type; + create.channel = channel; + create.speed = speed; ++ create.header_size = 4; + + retval = ioctl(handle->iso.fd, + FW_CDEV_IOC_CREATE_ISO_CONTEXT, &create); @@ -499,266 +662,117 @@ Index: juju/raw1394-iso.c + return retval; + } + ++ switch (type) { ++ case FW_CDEV_ISO_CONTEXT_TRANSMIT: ++ prot = PROT_READ | PROT_WRITE; ++ break; ++ case FW_CDEV_ISO_CONTEXT_RECEIVE: ++ prot = PROT_READ; ++ break; ++ } ++ + handle->iso.buffer = + mmap(NULL, buf_packets * max_packet_size, -+ PROT_READ | PROT_WRITE, MAP_SHARED, handle->iso.fd, 0); ++ prot, MAP_SHARED, handle->iso.fd, 0); + + if (handle->iso.buffer == MAP_FAILED) { + close(handle->iso.fd); + free(handle->iso.packets); -+ return -1; -+ } -+ -+ return 0; -+} -+ -+int raw1394_iso_recv_init(raw1394handle_t handle, -+ raw1394_iso_recv_handler_t handler, -+ unsigned int buf_packets, -+ unsigned int max_packet_size, -+ unsigned char channel, -+ enum raw1394_iso_dma_recv_mode mode, -+ int irq_interval) -+{ -+ struct fw_cdev_create_iso_context create; -+ -+ if (handle->iso.fd != -1) { -+ errno = EBUSY; -+ return -1; -+ } -+ -+ /* FIXME: Do we need this? When would you ever want this...? */ -+ if (mode == RAW1394_DMA_PACKET_PER_BUFFER) -+ return -1; -+ -+ handle->iso.buffer = -+ mmap(NULL, buf_packets * max_packet_size, -+ PROT_READ, MAP_SHARED, handle->iso.fd, 0); -+ -+ if (handle->iso.buffer == MAP_FAILED) -+ return -1; -+ -+ create.type = FW_CDEV_ISO_CONTEXT_RECEIVE; -+ create.channel = channel; -+ create.speed = 0; -+ create.header_size = 0; /* Never strip any headers. */ -+ -+ handle->iso.type = FW_CDEV_ISO_CONTEXT_RECEIVE; -+ handle->iso.irq_interval = irq_interval; -+ handle->iso.recv_handler = handler; -+ -+ return ioctl(handle->iso.fd, -+ FW_CDEV_IOC_CREATE_ISO_CONTEXT, &create); -+} -+ -+int raw1394_iso_multichannel_recv_init(raw1394handle_t handle, -+ raw1394_iso_recv_handler_t handler, -+ unsigned int buf_packets, -+ unsigned int max_packet_size, -+ int irq_interval) -+{ -+ /* FIXME: gah */ -+ errno = ENOSYS; -+ return -1; -+} -+ -+int raw1394_iso_recv_listen_channel(raw1394handle_t handle, -+ unsigned char channel) -+{ -+ /* FIXME: multichannel */ -+ errno = ENOSYS; -+ return -1; -+} -+ -+int raw1394_iso_recv_unlisten_channel(raw1394handle_t handle, -+ unsigned char channel) -+{ -+ /* FIXME: multichannel */ -+ errno = ENOSYS; -+ return -1; -+} -+ -+int raw1394_iso_recv_set_channel_mask(raw1394handle_t handle, u_int64_t mask) -+{ -+ /* FIXME: multichannel */ -+ errno = ENOSYS; -+ return -1; -+} -+ -+void raw1394_iso_stop(raw1394handle_t handle) -+{ -+ ioctl(handle->iso.fd, FW_CDEV_IOC_STOP_ISO); -+} -+ -+void raw1394_iso_shutdown(raw1394handle_t handle) -+{ -+ munmap(handle->iso.buffer, -+ handle->iso.buf_packets * handle->iso.max_packet_size); -+ close(handle->iso.fd); -+ free(handle->iso.packets); -+} -Index: juju/juju.h -=================================================================== ---- juju/juju.h (revision 0) -+++ juju/juju.h (revision 0) -@@ -0,0 +1,139 @@ -+/* -*- c-basic-offset: 8 -*- -+ * -+ * juju.h -- Internal header file for raw1394 emulation -+ * -+ * Copyright (C) 2007 Kristian Hoegsberg -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software Foundation, -+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+ */ -+ -+#ifndef __juju_h -+#define __juju_h -+ -+#include -+#include -+#include -+#include "../src/raw1394.h" -+#include "../src/csr.h" -+#include "config.h" -+ -+#define ACK_COMPLETE 1 -+ -+#define ptr_to_u64(p) ((__u64)(unsigned long)(p)) -+#define u64_to_ptr(p) ((void *)(unsigned long)(p)) -+ -+static inline __u32 -+be32_to_cpu(__u32 q) -+{ -+ union { char c[4]; __u32 q; } u = { { 1, 0, 0, 0 } }; -+ -+ return u.q == 1 ? bswap_32(q) : q; -+} -+ -+static inline __u32 -+cpu_to_be32(__u32 q) -+{ -+ return be32_to_cpu(q); -+} -+ -+#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0]) -+ -+#define BUFFER_SIZE (16 * 1024) -+ -+#define MAX_PORTS 16 -+ -+struct epoll_closure { -+ int (*func)(raw1394handle_t handle, -+ struct epoll_closure *closure, __uint32_t events); -+}; -+ -+struct port { -+ char device_file[32]; -+ char *name; -+ int node_count; -+ int card; -+}; -+ -+#define MAX_DEVICES 63 -+#define FILENAME_SIZE 16 -+ -+struct device { -+ struct epoll_closure closure; -+ int fd; -+ int node_id; -+ int generation; -+ char filename[FILENAME_SIZE]; -+}; -+ -+struct request_closure { -+ void *data; -+ size_t length; -+ unsigned long tag; -+ struct raw1394_reqhandle reqhandle; -+}; -+ -+struct allocation; -+ -+struct raw1394_handle { -+ struct port ports[MAX_PORTS]; -+ int port_count; -+ int err; -+ int generation; -+ void *user_data; -+ int notify_bus_reset; -+ -+ bus_reset_handler_t bus_reset_handler; -+ tag_handler_t tag_handler; -+ arm_tag_handler_t arm_tag_handler; -+ fcp_handler_t fcp_handler; -+ struct allocation *allocations; -+ -+ int epoll_fd; -+ int inotify_fd; -+ int inotify_watch; -+ int pipe_fds[2]; ++ return -1; ++ } + -+ struct epoll_closure pipe_closure; -+ struct epoll_closure inotify_closure; ++ handle->iso.buffer_end = handle->iso.buffer + ++ buf_packets * max_packet_size; ++ handle->iso.head = handle->iso.buffer; ++ handle->iso.tail = handle->iso.buffer; ++ handle->iso.first_payload = handle->iso.buffer; + -+ struct device devices[MAX_DEVICES]; -+ int nodes[MAX_DEVICES]; -+ int local_fd; -+ char local_filename[FILENAME_SIZE]; ++ return 0; ++} + -+ struct fw_cdev_event_bus_reset reset; ++int raw1394_iso_xmit_init(raw1394handle_t handle, ++ raw1394_iso_xmit_handler_t handler, ++ unsigned int buf_packets, ++ unsigned int max_packet_size, ++ unsigned char channel, ++ enum raw1394_iso_speed speed, ++ int irq_interval) ++{ ++ return iso_init(handle, FW_CDEV_ISO_CONTEXT_TRANSMIT, ++ handler, NULL, buf_packets, max_packet_size, ++ channel, speed, irq_interval); ++} + -+ struct { -+ struct epoll_closure closure; -+ int fd; -+ int type; -+ int irq_interval; -+ int packet_index; -+ int packet_phase; -+ int buf_packets; -+ int max_packet_size; -+ enum raw1394_iso_dma_recv_mode recv_mode; -+ raw1394_iso_xmit_handler_t xmit_handler; -+ raw1394_iso_recv_handler_t recv_handler; -+ unsigned char *buffer, *head, *tail; ++int raw1394_iso_recv_init(raw1394handle_t handle, ++ raw1394_iso_recv_handler_t handler, ++ unsigned int buf_packets, ++ unsigned int max_packet_size, ++ unsigned char channel, ++ enum raw1394_iso_dma_recv_mode mode, ++ int irq_interval) ++{ ++ return iso_init(handle, FW_CDEV_ISO_CONTEXT_RECEIVE, ++ NULL, handler, buf_packets, max_packet_size, ++ channel, 0, irq_interval); ++} + -+ struct fw_cdev_queue_iso queue_iso; -+ struct fw_cdev_iso_packet *packets; -+ } iso; ++int raw1394_iso_multichannel_recv_init(raw1394handle_t handle, ++ raw1394_iso_recv_handler_t handler, ++ unsigned int buf_packets, ++ unsigned int max_packet_size, ++ int irq_interval) ++{ ++ /* FIXME: gah */ ++ errno = ENOSYS; ++ return -1; ++} + -+ char buffer[BUFFER_SIZE]; -+}; ++int raw1394_iso_recv_listen_channel(raw1394handle_t handle, ++ unsigned char channel) ++{ ++ /* FIXME: multichannel */ ++ errno = ENOSYS; ++ return -1; ++} + -+#endif -Index: juju/Makefile.am -=================================================================== ---- juju/Makefile.am (revision 0) -+++ juju/Makefile.am (revision 0) -@@ -0,0 +1,8 @@ -+lib_LTLIBRARIES = libraw1394.la ++int raw1394_iso_recv_unlisten_channel(raw1394handle_t handle, ++ unsigned char channel) ++{ ++ /* FIXME: multichannel */ ++ errno = ENOSYS; ++ return -1; ++} + -+INCLUDES = -I$(JUJU_DIR) -+libraw1394_la_LDFLAGS = -version-info @lt_major@:@lt_revision@:@lt_age@ ++int raw1394_iso_recv_set_channel_mask(raw1394handle_t handle, u_int64_t mask) ++{ ++ /* FIXME: multichannel */ ++ errno = ENOSYS; ++ return -1; ++} + -+libraw1394_la_SOURCES = raw1394.c raw1394-iso.c juju.h ++void raw1394_iso_stop(raw1394handle_t handle) ++{ ++ ioctl(handle->iso.fd, FW_CDEV_IOC_STOP_ISO); ++ handle->iso.head = handle->iso.buffer; ++ handle->iso.tail = handle->iso.buffer; ++ handle->iso.first_payload = handle->iso.buffer; ++ handle->iso.packet_phase = 0; ++ handle->iso.packet_count = 0; ++} + -+pkginclude_HEADERS = ../src/raw1394.h ../src/csr.h ../src/ieee1394.h -Index: juju/raw1394.c -=================================================================== ---- juju/raw1394.c (revision 0) -+++ juju/raw1394.c (revision 0) -@@ -0,0 +1,1364 @@ ++void raw1394_iso_shutdown(raw1394handle_t handle) ++{ ++ munmap(handle->iso.buffer, ++ handle->iso.buf_packets * handle->iso.max_packet_size); ++ close(handle->iso.fd); ++ free(handle->iso.packets); ++} +diff --git a/juju/raw1394.c b/juju/raw1394.c +new file mode 100644 +index 0000000..fd5756d +--- /dev/null ++++ b/juju/raw1394.c +@@ -0,0 +1,1440 @@ +/* -*- c-basic-offset: 8 -*- + * + * raw1394.c -- Emulation of the raw1394 API on the juju stack @@ -980,7 +994,7 @@ Index: juju/raw1394.c + struct fw_cdev_send_response response; + int is_response; + -+ response.serial = request->serial; ++ response.handle = request->handle; + response.rcode = RCODE_COMPLETE; + response.length = 0; + response.data = 0; @@ -1011,11 +1025,7 @@ Index: juju/raw1394.c +handle_device_event(raw1394handle_t handle, + struct epoll_closure *ec, __uint32_t events) +{ -+ union { -+ struct fw_cdev_event_bus_reset bus_reset; -+ struct fw_cdev_event_response response; -+ struct fw_cdev_event_request request; -+ } *u; ++ union fw_cdev_event *u; + struct device *device = (struct device *) ec; + struct address_closure *ac; + struct request_closure *rc; @@ -1033,7 +1043,7 @@ Index: juju/raw1394.c + return -1; + + u = (void *) handle->buffer; -+ switch (u->response.type) { ++ switch (u->common.type) { + case FW_CDEV_EVENT_BUS_RESET: + /* Clear old entry, unless it's been overwritten. */ + phy_id = handle->devices[i].node_id & 0x3f; @@ -1483,6 +1493,7 @@ Index: juju/raw1394.c +struct allocation { + struct address_closure closure; + struct allocation *next; ++ __u32 handle; + byte_t *buffer; + octlet_t tag; + arm_options_t access_rights; @@ -1505,7 +1516,7 @@ Index: juju/raw1394.c + int offset; + + offset = request->offset - allocation->offset; -+ response.serial = request->serial; ++ response.handle = request->handle; + + switch (request->tcode) { + case TCODE_WRITE_QUADLET_REQUEST: @@ -1632,6 +1643,7 @@ Index: juju/raw1394.c + return -1; + } + ++ allocation->handle = request.handle; + allocation->next = handle->allocations; + handle->allocations = allocation; + @@ -1668,10 +1680,9 @@ Index: juju/raw1394.c + return -1; + } + ++ request.handle = allocation->handle; + free(allocation); + -+ request.offset = start; -+ + return ioctl(handle->local_fd, FW_CDEV_IOC_DEALLOCATE, &request); +} + @@ -2055,6 +2066,8 @@ Index: juju/raw1394.c + if (ioctl(handle->local_fd, FW_CDEV_IOC_ALLOCATE, &request) < 0) + return -1; + ++ handle->fcp_allocation_handle = request.handle; ++ + return 0; +} + @@ -2063,7 +2076,7 @@ Index: juju/raw1394.c +{ + struct fw_cdev_deallocate request; + -+ request.offset = CSR_REGISTER_BASE + CSR_FCP_COMMAND; ++ request.handle = handle->fcp_allocation_handle; + + return ioctl(handle->local_fd, FW_CDEV_IOC_DEALLOCATE, &request); +} @@ -2104,22 +2117,253 @@ Index: juju/raw1394.c + return 0; +} + ++#define MAXIMUM_BANDWIDTH 4915 ++ +int -+raw1394_bandwidth_modify (raw1394handle_t handle, unsigned int bandwidth, ++raw1394_bandwidth_modify (raw1394handle_t handle, ++ unsigned int bandwidth, + enum raw1394_modify_mode mode) +{ -+ /* FIXME: copy and audit the libraw1394 version */ ++ quadlet_t buffer, compare, swap; ++ nodeaddr_t addr; ++ int result; ++ ++ if (bandwidth == 0) ++ return 0; ++ ++ addr = CSR_REGISTER_BASE + CSR_BANDWIDTH_AVAILABLE; ++ /* Read current bandwidth usage from IRM. */ ++ result = raw1394_read (handle, raw1394_get_irm_id (handle), addr, ++ sizeof buffer, &buffer); ++ if (result < 0) ++ return -1; ++ ++ compare = ntohl (buffer); ++ switch (mode) { ++ case RAW1394_MODIFY_ALLOC: ++ swap = compare - bandwidth; ++ if (swap < 0) ++ return -1; ++ break; + -+ errno = ENOSYS; -+ return -1; ++ case RAW1394_MODIFY_FREE: ++ swap = compare + bandwidth; ++ if (swap > MAXIMUM_BANDWIDTH) ++ swap = MAXIMUM_BANDWIDTH; ++ break; ++ ++ default: ++ return -1; ++ } ++ ++ result = raw1394_lock(handle, raw1394_get_irm_id (handle), addr, ++ RAW1394_EXTCODE_COMPARE_SWAP, ++ htonl(swap), htonl(compare), &buffer); ++ if (result < 0 || ntohl(buffer) != compare) ++ return -1; ++ ++ return 0; +} + +int -+raw1394_channel_modify (raw1394handle_t handle, unsigned int channel, ++raw1394_channel_modify (raw1394handle_t handle, ++ unsigned int channel, + enum raw1394_modify_mode mode) +{ -+ /* FIXME: copy and audit the libraw1394 version */ ++ quadlet_t buffer, compare, swap, bit; ++ nodeaddr_t addr; ++ int result; ++ ++ if (channel >= 64) ++ return -1; ++ addr = CSR_REGISTER_BASE + ++ CSR_CHANNELS_AVAILABLE_HI + 4 * (channel / 32); ++ /* Read currently available channels from IRM. */ ++ result = raw1394_read(handle, raw1394_get_irm_id (handle), addr, ++ sizeof buffer, &buffer); ++ if (result < 0) ++ return -1; ++ ++ /* IEEE numbers bits from MSB (0) to LSB (31). */ ++ bit = 1 << (31 - (channel & 31)); ++ compare = ntohl(buffer); ++ switch (mode) { ++ case RAW1394_MODIFY_ALLOC: ++ if ((compare & bit) == 0) ++ return -1; ++ swap = buffer & ~bit; ++ break; + -+ errno = ENOSYS; -+ return -1; ++ case RAW1394_MODIFY_FREE: ++ if ((buffer & bit) != 0) ++ return -1; ++ swap = buffer | bit; ++ break; ++ ++ default: ++ return -1; ++ } ++ ++ result = raw1394_lock (handle, raw1394_get_irm_id (handle), addr, ++ RAW1394_EXTCODE_COMPARE_SWAP, ++ htonl(swap), htonl(compare), &buffer); ++ ++ if (result < 0 || ntohl(buffer) != compare) ++ return -1; ++ ++ return 0; ++} +diff --git a/tools/Makefile.am b/tools/Makefile.am +index 29b250e..5be1b6f 100644 +--- a/tools/Makefile.am ++++ b/tools/Makefile.am +@@ -2,4 +2,4 @@ MAINTAINERCLEANFILES = Makefile.in + + # testlibraw + bin_PROGRAMS = testlibraw sendiso dumpiso +-LDADD = ../src/libraw1394.la ++LDADD = ../$(LIB_SUBDIR)/libraw1394.la +diff --git a/tools/testlibraw.c b/tools/testlibraw.c +index 5f73bd9..2f02a6d 100644 +--- a/tools/testlibraw.c ++++ b/tools/testlibraw.c +@@ -1,4 +1,5 @@ +-/* ++/* -*- c-basic-offset: 8 -*- ++ * + * libraw1394 - library for raw access to the 1394 bus with the Linux subsystem. + * + * Copyright (C) 1999,2000 Andreas Bombe +@@ -13,12 +14,13 @@ + #include + #include + #include ++#include + + #include "../src/raw1394.h" + #include "../src/csr.h" + + +-#define TESTADDR (CSR_REGISTER_BASE + CSR_CYCLE_TIME) ++#define TESTADDR (CSR_REGISTER_BASE + CSR_CONFIG_ROM) + + const char not_compatible[] = "\ + This libraw1394 does not work with your version of Linux. You need a different\n\ +@@ -45,12 +47,18 @@ int my_tag_handler(raw1394handle_t handle, unsigned long tag, + return 0; + } + ++static const unsigned char fcp_data[] = ++ { 0x1, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }; ++ + int my_fcp_handler(raw1394handle_t handle, nodeid_t nodeid, int response, + size_t length, unsigned char *data) + { + printf("got fcp %s from node %d of %d bytes:", + (response ? "response" : "command"), nodeid & 0x3f, length); + ++ if (memcmp(fcp_data, data, sizeof fcp_data) != 0) ++ printf("ERROR: fcp payload not correct\n"); ++ + while (length) { + printf(" %02x", *data); + data++; +@@ -62,6 +70,47 @@ int my_fcp_handler(raw1394handle_t handle, nodeid_t nodeid, int response, + return 0; + } + ++static void ++test_fcp(raw1394handle_t handle) ++{ ++ printf("\ntesting FCP monitoring on local node\n"); ++ raw1394_set_fcp_handler(handle, my_fcp_handler); ++ raw1394_start_fcp_listen(handle); ++ raw1394_write(handle, raw1394_get_local_id(handle), ++ CSR_REGISTER_BASE + CSR_FCP_COMMAND, sizeof(fcp_data), ++ (quadlet_t *)fcp_data); ++ raw1394_write(handle, raw1394_get_local_id(handle), ++ CSR_REGISTER_BASE + CSR_FCP_RESPONSE, sizeof(fcp_data), ++ (quadlet_t *)fcp_data); ++} ++ ++static void ++read_topology_map(raw1394handle_t handle) ++{ ++ quadlet_t map[70]; ++ nodeid_t local_id; ++ int node_count, self_id_count, i, retval; ++ ++ local_id = raw1394_get_local_id(handle) | 0xffc0; ++ ++ retval = raw1394_read(handle, local_id, ++ CSR_REGISTER_BASE + CSR_TOPOLOGY_MAP, 12, &map[0]); ++ if (retval < 0) ++ perror("topology map: raw1394_read failed with error"); ++ ++ self_id_count = ntohl(map[2]) & 0xffff; ++ node_count = ntohl(map[2]) >> 16; ++ retval = raw1394_read(handle, local_id, ++ CSR_REGISTER_BASE + CSR_TOPOLOGY_MAP + 12, ++ self_id_count * sizeof map[0], &map[3]); ++ if (retval < 0) ++ perror("topology map: raw1394_read failed with error"); ++ ++ printf("topology map: %d nodes, %d self ids, generation %d\n", ++ node_count, self_id_count, ntohl(map[1])); ++ for (i = 0; i < self_id_count; i++) ++ printf(" 0x%08x\n", ntohl(map[3 + i])); +} + + int main(int argc, char **argv) + { +@@ -73,7 +122,6 @@ int main(int argc, char **argv) + int retval; + + struct pollfd pfd; +- unsigned char fcp_test[] = { 0x1, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }; + quadlet_t rom[0x100]; + size_t rom_size; + unsigned char rom_version; +@@ -150,17 +198,8 @@ int main(int argc, char **argv) + } + } + +- printf("\ntesting FCP monitoring on local node\n"); +- raw1394_set_fcp_handler(handle, my_fcp_handler); +- raw1394_start_fcp_listen(handle); +- raw1394_write(handle, raw1394_get_local_id(handle), +- CSR_REGISTER_BASE + CSR_FCP_COMMAND, sizeof(fcp_test), +- (quadlet_t *)fcp_test); +- raw1394_write(handle, raw1394_get_local_id(handle), +- CSR_REGISTER_BASE + CSR_FCP_RESPONSE, sizeof(fcp_test), +- (quadlet_t *)fcp_test); +- +- ++ test_fcp(handle); ++ read_topology_map(handle); + + printf("testing config rom stuff\n"); + retval=raw1394_get_config_rom(handle, rom, 0x100, &rom_size, &rom_version); +@@ -176,16 +215,19 @@ int main(int argc, char **argv) + retval=raw1394_update_config_rom(handle, rom, rom_size, rom_version); + printf("update_config_rom returned %d\n",retval); + ++ printf("\nposting 0xdeadbeef as an echo request\n"); ++ raw1394_echo_request(handle, 0xdeadbeef); + +- +- printf("\npolling for leftover messages\n"); ++ printf("polling for leftover messages\n"); + pfd.fd = raw1394_get_fd(handle); + pfd.events = POLLIN; + pfd.revents = 0; + while (1) { + retval = poll(&pfd, 1, 10); + if (retval < 1) break; +- raw1394_loop_iterate(handle); ++ retval = raw1394_loop_iterate(handle); ++ if (retval != 0) ++ printf("raw1394_loop_iterate() returned 0x%08x\n", retval); + } + + if (retval < 0) perror("poll failed"); diff --git a/libraw1394.spec b/libraw1394.spec index c85c29a..3c5a578 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 1.2.1 -Release: 3%{?dist} +Release: 4%{?dist} License: LGPL Group: System Environment/Libraries Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz @@ -75,6 +75,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Tue Apr 3 2007 Kristian Høgsberg - 1.2.1-4 +- Update juju patch with rawiso support. + * Mon Mar 19 2007 Kristian Høgsberg 1.2.1-3 - Add support for new stack (juju). From bf9a5589d11c512d42947c54e3638c4ce121cd7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Thu, 12 Apr 2007 21:24:30 +0000 Subject: [PATCH 031/100] - Make rawiso support actually work. - Update fw-device-cdev.h to sync with latest kernel patch. --- libraw1394-juju.patch | 285 +++++++++++++++++++----------------------- libraw1394.spec | 8 +- 2 files changed, 132 insertions(+), 161 deletions(-) diff --git a/libraw1394-juju.patch b/libraw1394-juju.patch index e18e779..cb221fe 100644 --- a/libraw1394-juju.patch +++ b/libraw1394-juju.patch @@ -67,7 +67,7 @@ index 0000000..6fd6a5e +pkginclude_HEADERS = ../src/raw1394.h ../src/csr.h ../src/ieee1394.h diff --git a/juju/juju.h b/juju/juju.h new file mode 100644 -index 0000000..8c18630 +index 0000000..d78d362 --- /dev/null +++ b/juju/juju.h @@ -0,0 +1,143 @@ @@ -196,9 +196,9 @@ index 0000000..8c18630 + int irq_interval; + int packet_phase; + int packet_count; ++ int packet_index; + int buf_packets; + int max_packet_size; -+ int packet_header_index; + int prebuffer; + int start_on_cycle; + enum raw1394_iso_dma_recv_mode recv_mode; @@ -216,10 +216,10 @@ index 0000000..8c18630 +#endif diff --git a/juju/raw1394-iso.c b/juju/raw1394-iso.c new file mode 100644 -index 0000000..bbf49f0 +index 0000000..a320440 --- /dev/null +++ b/juju/raw1394-iso.c -@@ -0,0 +1,547 @@ +@@ -0,0 +1,513 @@ +/* -*- c-basic-offset: 8 -*- + * + * raw1394-iso.c -- Emulation of the raw1394 rawiso API on the juju stack @@ -252,76 +252,73 @@ index 0000000..bbf49f0 + +#include "juju.h" + -+static enum raw1394_iso_disposition -+queue_xmit_packets(raw1394handle_t handle) ++static int ++queue_packet(raw1394handle_t handle, ++ unsigned int length, unsigned int header_length, ++ unsigned char tag, unsigned char sy) +{ -+ struct fw_cdev_iso_packet *p = handle->iso.packets; + struct fw_cdev_queue_iso queue_iso; -+ enum raw1394_iso_disposition d; -+ unsigned int len, dropped; -+ unsigned char tag, sy, *first_payload; -+ int cycle, i; -+ -+ first_payload = handle->iso.head; -+ for (i = 0; i < handle->iso.irq_interval; i++) { -+ cycle = -1; -+ dropped = 0; -+ -+ if (handle->iso.head + handle->iso.max_packet_size > -+ handle->iso.buffer_end) { -+ handle->iso.head = handle->iso.buffer; -+ break; -+ } -+ -+ d = handle->iso.xmit_handler(handle, handle->iso.head, -+ &len, &tag, &sy, cycle, dropped); -+ if (d != RAW1394_ISO_OK) -+ break; ++ struct fw_cdev_iso_packet *p; ++ int err; + -+ p->payload_length = len; -+ p->interrupt = -+ handle->iso.packet_phase == handle->iso.irq_interval - 1; -+ p->skip = 0; -+ p->tag = tag; -+ p->sy = sy; -+ p->header_length = 0; ++ p = &handle->iso.packets[handle->iso.packet_index]; ++ p->payload_length = length; ++ p->interrupt = ++ handle->iso.packet_phase == handle->iso.irq_interval - 1; ++ p->skip = 0; ++ p->tag = tag; ++ p->sy = sy; ++ p->header_length = header_length; + -+ handle->iso.head += len; -+ handle->iso.packet_count++; -+ handle->iso.packet_phase++; ++ handle->iso.head += length; ++ handle->iso.packet_count++; ++ handle->iso.packet_phase++; ++ handle->iso.packet_index++; + -+ if (handle->iso.packet_phase == handle->iso.irq_interval) -+ handle->iso.packet_phase = 0; -+ } ++ if (handle->iso.packet_phase == handle->iso.irq_interval) ++ handle->iso.packet_phase = 0; + -+ queue_iso.packets = ptr_to_u64(handle->iso.packets); -+ queue_iso.size = i * sizeof handle->iso.packets[0]; -+ queue_iso.data = ptr_to_u64(first_payload); ++ if (handle->iso.head + handle->iso.max_packet_size > handle->iso.buffer_end) ++ handle->iso.head = handle->iso.buffer; + -+ len = ioctl(handle->iso.fd, FW_CDEV_IOC_QUEUE_ISO, &queue_iso); -+ if (len < 0) -+ return RAW1394_ISO_ERROR; ++ /* Queue the packets in the kernel if we filled up the packets ++ * array or wrapped the payload buffer. */ ++ if (handle->iso.packet_index == handle->iso.irq_interval || ++ handle->iso.head == handle->iso.buffer) { ++ queue_iso.packets = ptr_to_u64(handle->iso.packets); ++ queue_iso.size = handle->iso.packet_index * sizeof handle->iso.packets[0]; ++ queue_iso.data = ptr_to_u64(handle->iso.first_payload); ++ handle->iso.packet_index = 0; ++ handle->iso.first_payload = handle->iso.head; + -+ return d; ++ err = ioctl(handle->iso.fd, FW_CDEV_IOC_QUEUE_ISO, &queue_iso); ++ if (err < 0) ++ return -1; ++ } +} + +static int -+flush_xmit_packets(raw1394handle_t handle, int limit) ++queue_xmit_packets(raw1394handle_t handle, int limit) +{ + enum raw1394_iso_disposition d; -+ int len; ++ unsigned char tag, sy; ++ int len, cycle, dropped; + + if (handle->iso.xmit_handler == NULL) + return 0; + -+ if (limit < handle->iso.irq_interval) -+ limit = handle->iso.irq_interval; ++ while (handle->iso.packet_count < limit) { ++ ++ d = handle->iso.xmit_handler(handle, handle->iso.head, ++ &len, &tag, &sy, cycle, dropped); + -+ while (handle->iso.packet_count + handle->iso.irq_interval <= limit) { -+ d = queue_xmit_packets(handle); + switch (d) { ++ case RAW1394_ISO_OK: ++ queue_packet(handle, len, 0, tag, sy); ++ break; + case RAW1394_ISO_DEFER: + case RAW1394_ISO_AGAIN: ++ default: + return 0; + case RAW1394_ISO_ERROR: + return -1; @@ -346,7 +343,7 @@ index 0000000..bbf49f0 + handle->iso.prebuffer = prebuffer_packets; + handle->iso.start_on_cycle = start_on_cycle; + -+ flush_xmit_packets(handle, prebuffer_packets); ++ queue_xmit_packets(handle, prebuffer_packets); + + if (handle->iso.prebuffer <= handle->iso.packet_count) { + start_iso.cycle = start_on_cycle; @@ -357,48 +354,14 @@ index 0000000..bbf49f0 + return retval; + } + -+ return flush_xmit_packets(handle, handle->iso.buf_packets); ++ return queue_xmit_packets(handle, handle->iso.buf_packets); +} + +static int +queue_recv_packets(raw1394handle_t handle) +{ -+ struct fw_cdev_queue_iso queue_iso; -+ struct fw_cdev_iso_packet *p = handle->iso.packets; -+ unsigned int len; -+ unsigned char *first_payload; -+ int i; -+ -+ first_payload = handle->iso.head; -+ for (i = 0; i < handle->iso.irq_interval; i++, p++) { -+ if (handle->iso.head + handle->iso.max_packet_size > -+ handle->iso.buffer_end) { -+ handle->iso.head = handle->iso.buffer; -+ break; -+ } -+ -+ p->payload_length = handle->iso.max_packet_size; -+ p->interrupt = handle->iso.packet_phase == handle->iso.irq_interval - 1; -+ p->skip = 0; -+ p->tag = 0; -+ p->sy = 0; -+ p->header_length = 4; -+ -+ handle->iso.head += handle->iso.max_packet_size; -+ handle->iso.packet_count++; -+ handle->iso.packet_phase++; -+ -+ if (handle->iso.packet_phase == handle->iso.irq_interval) -+ handle->iso.packet_phase = 0; -+ } -+ -+ queue_iso.packets = ptr_to_u64(handle->iso.packets); -+ queue_iso.size = i * sizeof handle->iso.packets[0]; -+ queue_iso.data = ptr_to_u64(first_payload); -+ -+ len = ioctl(handle->iso.fd, FW_CDEV_IOC_QUEUE_ISO, &queue_iso); -+ if (len < 0) -+ return -1; ++ while (handle->iso.packet_count <= handle->iso.buf_packets) ++ queue_packet(handle, handle->iso.max_packet_size, 4, 0, 0); + + return 0; +} @@ -411,12 +374,12 @@ index 0000000..bbf49f0 + quadlet_t header, *p, *end; + unsigned int len, cycle, dropped; + unsigned char channel, tag, sy; -+ unsigned char *data; + + p = interrupt->header; + end = (void *) interrupt->header + interrupt->header_length; + cycle = interrupt->cycle; + dropped = 0; ++ d = RAW1394_ISO_OK; + + while (p < end) { + header = be32_to_cpu(*p++); @@ -435,13 +398,15 @@ index 0000000..bbf49f0 + + handle->iso.tail += handle->iso.max_packet_size; + handle->iso.packet_count--; -+ if (handle->iso.tail == handle->iso.buffer_end) ++ ++ if (handle->iso.tail + handle->iso.max_packet_size > handle->iso.buffer_end) + handle->iso.tail = handle->iso.buffer; + } + + switch (d) { + case RAW1394_ISO_OK: + case RAW1394_ISO_DEFER: ++ default: + break; + + case RAW1394_ISO_ERROR: @@ -452,9 +417,7 @@ index 0000000..bbf49f0 + return 0; + } + -+ while (handle->iso.packet_count + handle->iso.irq_interval <= -+ handle->iso.buf_packets) -+ queue_recv_packets(handle); ++ queue_recv_packets(handle); + + return 0; +} @@ -464,9 +427,7 @@ index 0000000..bbf49f0 +{ + struct fw_cdev_start_iso start_iso; + -+ while (handle->iso.packet_count + handle->iso.irq_interval <= -+ handle->iso.buf_packets) -+ queue_recv_packets(handle); ++ queue_recv_packets(handle); + + start_iso.cycle = start_on_cycle; + start_iso.tags = @@ -494,7 +455,7 @@ index 0000000..bbf49f0 + switch (handle->iso.type) { + case FW_CDEV_ISO_CONTEXT_TRANSMIT: + handle->iso.packet_count -= handle->iso.irq_interval; -+ return flush_xmit_packets(handle, handle->iso.buf_packets); ++ return queue_xmit_packets(handle, handle->iso.buf_packets); + case FW_CDEV_ISO_CONTEXT_RECEIVE: + return flush_recv_packets(handle, interrupt); + default: @@ -511,15 +472,6 @@ index 0000000..bbf49f0 + struct fw_cdev_start_iso start_iso; + struct fw_cdev_iso_packet *p; + -+ { -+ int i; -+ __u32 *p = (__u32 *) data; -+ -+ for (i = 0; i < 10; i++) -+ fprintf(stderr, "0x%08x ", p[i]); -+ fprintf(stderr, "\n"); -+ } -+ + if (len > handle->iso.max_packet_size) { + errno = EINVAL; + return -1; @@ -529,43 +481,10 @@ index 0000000..bbf49f0 + while (handle->iso.packet_count + handle->iso.irq_interval > + handle->iso.buf_packets) + raw1394_loop_iterate(handle); -+ -+ p = &handle->iso.packets[handle->iso.packet_header_index]; -+ p->payload_length = len; -+ p->interrupt = -+ handle->iso.packet_phase == handle->iso.irq_interval - 1; -+ p->skip = 0; -+ p->tag = tag; -+ p->sy = sy; -+ p->header_length = 0; + + memcpy(handle->iso.head, data, len); -+ -+ handle->iso.head += len; -+ handle->iso.packet_count++; -+ handle->iso.packet_phase++; -+ handle->iso.packet_header_index++; -+ -+ if (handle->iso.packet_phase == handle->iso.irq_interval) -+ handle->iso.packet_phase = 0; -+ -+ if (handle->iso.head + handle->iso.max_packet_size > handle->iso.buffer_end) -+ handle->iso.head = handle->iso.buffer; -+ -+ /* Queue the packets in the kernel if we filled up the packets -+ * array or wrapped the payload buffer. */ -+ if (handle->iso.packet_header_index == handle->iso.irq_interval || -+ handle->iso.head == handle->iso.buffer) { -+ queue_iso.packets = ptr_to_u64(handle->iso.packets); -+ queue_iso.size = handle->iso.packet_header_index * sizeof handle->iso.packets[0]; -+ queue_iso.data = ptr_to_u64(handle->iso.first_payload); -+ handle->iso.packet_header_index = 0; -+ handle->iso.first_payload = handle->iso.head; -+ -+ len = ioctl(handle->iso.fd, FW_CDEV_IOC_QUEUE_ISO, &queue_iso); -+ if (len < 0) -+ return -1; -+ } ++ if (queue_packet(handle, len, 0, tag, sy) < 0) ++ return -1; + + /* Start the streaming if it's not already running and if + * we've buffered up enough packets. */ @@ -586,7 +505,39 @@ index 0000000..bbf49f0 + +int raw1394_iso_xmit_sync(raw1394handle_t handle) +{ -+ /* FIXME: queue a skip packet and wait for that interrupt. */ ++ struct fw_cdev_iso_packet skip; ++ struct fw_cdev_queue_iso queue_iso; ++ int len; ++ ++ skip.payload_length = 0; ++ skip.interrupt = 1; ++ skip.skip = 1; ++ skip.tag = 0; ++ skip.sy = 0; ++ skip.header_length = 0; ++ ++ queue_iso.packets = ptr_to_u64(&skip); ++ queue_iso.size = sizeof skip; ++ queue_iso.data = 0; ++ ++ len = ioctl(handle->iso.fd, FW_CDEV_IOC_QUEUE_ISO, &queue_iso); ++ if (len < 0) ++ return -1; ++ ++ /* Now that we've queued the skip packet, we'll get an ++ * interrupt when the transmit buffer is flushed, so all we do ++ * here is wait. */ ++ while (handle->iso.packet_count > 0) ++ raw1394_loop_iterate(handle); ++ ++ /* The iso mainloop thinks that interrutps indicate another ++ * irq_interval number of packets was sent, so the skip ++ * interrupt makes it go out of whack. We just reset it. */ ++ handle->iso.head = handle->iso.buffer; ++ handle->iso.tail = handle->iso.buffer; ++ handle->iso.first_payload = handle->iso.buffer; ++ handle->iso.packet_phase = 0; ++ handle->iso.packet_count = 0; + + return 0; +} @@ -598,6 +549,18 @@ index 0000000..bbf49f0 + return 0; +} + ++static unsigned int ++round_to_power_of_two(unsigned int value) ++{ ++ unsigned int pot; ++ ++ pot = 1; ++ while (pot < value) ++ pot <<= 1; ++ ++ return pot; ++} ++ +static int +iso_init(raw1394handle_t handle, int type, + raw1394_iso_xmit_handler_t xmit_handler, @@ -617,6 +580,18 @@ index 0000000..bbf49f0 + return -1; + } + ++ switch (type) { ++ case FW_CDEV_ISO_CONTEXT_TRANSMIT: ++ prot = PROT_READ | PROT_WRITE; ++ break; ++ case FW_CDEV_ISO_CONTEXT_RECEIVE: ++ prot = PROT_READ; ++ break; ++ default: ++ errno = EINVAL; ++ return -1; ++ } ++ + handle->iso.type = type; + if (irq_interval < 0) + handle->iso.irq_interval = 256; @@ -625,7 +600,7 @@ index 0000000..bbf49f0 + handle->iso.xmit_handler = xmit_handler; + handle->iso.recv_handler = recv_handler; + handle->iso.buf_packets = buf_packets; -+ handle->iso.max_packet_size = max_packet_size; ++ handle->iso.max_packet_size = round_to_power_of_two(max_packet_size); + handle->iso.packet_phase = 0; + handle->iso.packet_count = 0; + handle->iso.packets = @@ -662,15 +637,6 @@ index 0000000..bbf49f0 + return retval; + } + -+ switch (type) { -+ case FW_CDEV_ISO_CONTEXT_TRANSMIT: -+ prot = PROT_READ | PROT_WRITE; -+ break; -+ case FW_CDEV_ISO_CONTEXT_RECEIVE: -+ prot = PROT_READ; -+ break; -+ } -+ + handle->iso.buffer = + mmap(NULL, buf_packets * max_packet_size, + prot, MAP_SHARED, handle->iso.fd, 0); @@ -769,10 +735,10 @@ index 0000000..bbf49f0 +} diff --git a/juju/raw1394.c b/juju/raw1394.c new file mode 100644 -index 0000000..fd5756d +index 0000000..7f73b3b --- /dev/null +++ b/juju/raw1394.c -@@ -0,0 +1,1440 @@ +@@ -0,0 +1,1441 @@ +/* -*- c-basic-offset: 8 -*- + * + * raw1394.c -- Emulation of the raw1394 API on the juju stack @@ -804,6 +770,7 @@ index 0000000..fd5756d +#include +#include +#include ++#include /* for ntohl and htonl */ + +#include "juju.h" + @@ -1840,7 +1807,7 @@ index 0000000..fd5756d + case RAW1394_EXTCODE_WRAP_ADD: + buffer[0] = arg; + buffer[1] = data; -+ return sizeof buffer; ++ return 2 * sizeof buffer[0]; + + default: + errno = EINVAL; @@ -1863,7 +1830,7 @@ index 0000000..fd5756d + case RAW1394_EXTCODE_WRAP_ADD: + buffer[0] = arg; + buffer[1] = data; -+ return sizeof buffer; ++ return 2 * sizeof buffer[0]; + + default: + errno = EINVAL; diff --git a/libraw1394.spec b/libraw1394.spec index 3c5a578..51151e0 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 1.2.1 -Release: 4%{?dist} +Release: 5%{?dist} License: LGPL Group: System Environment/Libraries Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz @@ -28,7 +28,7 @@ Development libraries needed to build applications against libraw1394. %prep %setup -q -%patch0 -p0 -b .juju +%patch0 -p1 -b .juju %build @@ -75,6 +75,10 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Thu Apr 12 2007 Kristian Høgsberg - 1.2.1-5 +- Make rawiso support actually work. +- Update fw-device-cdev.h to sync with latest kernel patch. + * Tue Apr 3 2007 Kristian Høgsberg - 1.2.1-4 - Update juju patch with rawiso support. From f6235567b908552b65160ce30921795c874f5952 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Thu, 12 Apr 2007 21:30:02 +0000 Subject: [PATCH 032/100] - Make rawiso support actually work. - Update fw-device-cdev.h to sync with latest kernel patch. - Add Requires to pull in a recent enough kernel. --- libraw1394.spec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraw1394.spec b/libraw1394.spec index 51151e0..491bd8a 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -12,6 +12,7 @@ BuildRequires: autoconf automake libtool Source1: fw-device-cdev.h Patch0: libraw1394-juju.patch +Requires: kernel >= 2.6.20-1.3062.fc7 %description The libraw1394 library provides direct access to the IEEE-1394 bus through @@ -78,6 +79,7 @@ rm -rf $RPM_BUILD_ROOT * Thu Apr 12 2007 Kristian Høgsberg - 1.2.1-5 - Make rawiso support actually work. - Update fw-device-cdev.h to sync with latest kernel patch. +- Add Requires to pull in a recent enough kernel. * Tue Apr 3 2007 Kristian Høgsberg - 1.2.1-4 - Update juju patch with rawiso support. From 2abe1ba178a5d2cb92ecb79d31a6c30899ba0045 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Wed, 18 Apr 2007 00:59:15 +0000 Subject: [PATCH 033/100] - Update to latest ioctl changes. --- firewire-cdev.h | 267 ++++++++++++++++++++++++++++++++++++++++++ libraw1394-juju.patch | 21 +++- libraw1394.spec | 13 +- 3 files changed, 291 insertions(+), 10 deletions(-) create mode 100644 firewire-cdev.h diff --git a/firewire-cdev.h b/firewire-cdev.h new file mode 100644 index 0000000..1fbd8bf --- /dev/null +++ b/firewire-cdev.h @@ -0,0 +1,267 @@ +/* -*- c-basic-offset: 8 -*- + * + * fw-device-cdev.h -- Char device interface. + * + * Copyright (C) 2005-2006 Kristian Hoegsberg + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __fw_cdev_h +#define __fw_cdev_h + +#include +#include + +#define TCODE_WRITE_QUADLET_REQUEST 0 +#define TCODE_WRITE_BLOCK_REQUEST 1 +#define TCODE_WRITE_RESPONSE 2 +#define TCODE_READ_QUADLET_REQUEST 4 +#define TCODE_READ_BLOCK_REQUEST 5 +#define TCODE_READ_QUADLET_RESPONSE 6 +#define TCODE_READ_BLOCK_RESPONSE 7 +#define TCODE_CYCLE_START 8 +#define TCODE_LOCK_REQUEST 9 +#define TCODE_STREAM_DATA 10 +#define TCODE_LOCK_RESPONSE 11 + +#define TCODE_LOCK_MASK_SWAP 0x11 +#define TCODE_LOCK_COMPARE_SWAP 0x12 +#define TCODE_LOCK_FETCH_ADD 0x13 +#define TCODE_LOCK_LITTLE_ADD 0x14 +#define TCODE_LOCK_BOUNDED_ADD 0x15 +#define TCODE_LOCK_WRAP_ADD 0x16 +#define TCODE_LOCK_VENDOR_DEPENDENT 0x17 + +#define RCODE_COMPLETE 0x0 +#define RCODE_CONFLICT_ERROR 0x4 +#define RCODE_DATA_ERROR 0x5 +#define RCODE_TYPE_ERROR 0x6 +#define RCODE_ADDRESS_ERROR 0x7 + +#define RCODE_SEND_ERROR 0x10 +#define RCODE_CANCELLED 0x11 +#define RCODE_BUSY 0x12 +#define RCODE_GENERATION 0x13 +#define RCODE_NO_ACK 0x14 + +#define SCODE_100 0x0 +#define SCODE_200 0x1 +#define SCODE_400 0x2 +#define SCODE_800 0x3 +#define SCODE_1600 0x4 +#define SCODE_3200 0x5 + +#define FW_CDEV_EVENT_BUS_RESET 0x00 +#define FW_CDEV_EVENT_RESPONSE 0x01 +#define FW_CDEV_EVENT_REQUEST 0x02 +#define FW_CDEV_EVENT_ISO_INTERRUPT 0x03 + +/* The 'closure' fields are for user space to use. Data passed in the + * 'closure' field for a request will be returned in the corresponding + * event. It's a 64-bit type so that it's a fixed size type big + * enough to hold a pointer on all platforms. */ + +struct fw_cdev_event_common { + __u64 closure; + __u32 type; +}; + +struct fw_cdev_event_bus_reset { + __u64 closure; + __u32 type; + __u32 node_id; + __u32 local_node_id; + __u32 bm_node_id; + __u32 irm_node_id; + __u32 root_node_id; + __u32 generation; +}; + +struct fw_cdev_event_response { + __u64 closure; + __u32 type; + __u32 rcode; + __u32 length; + __u32 data[0]; +}; + +struct fw_cdev_event_request { + __u64 closure; + __u32 type; + __u32 tcode; + __u64 offset; + __u32 handle; + __u32 length; + __u32 data[0]; +}; + +struct fw_cdev_event_iso_interrupt { + __u64 closure; + __u32 type; + __u32 cycle; + __u32 header_length; /* Length in bytes of following headers. */ + __u32 header[0]; +}; + +union fw_cdev_event { + struct fw_cdev_event_common common; + struct fw_cdev_event_bus_reset bus_reset; + struct fw_cdev_event_response response; + struct fw_cdev_event_request request; + struct fw_cdev_event_iso_interrupt iso_interrupt; +}; + +#define FW_CDEV_IOC_GET_INFO _IOWR('#', 0x00, struct fw_cdev_get_info) +#define FW_CDEV_IOC_SEND_REQUEST _IOW('#', 0x01, struct fw_cdev_send_request) +#define FW_CDEV_IOC_ALLOCATE _IOWR('#', 0x02, struct fw_cdev_allocate) +#define FW_CDEV_IOC_DEALLOCATE _IOW('#', 0x03, struct fw_cdev_deallocate) +#define FW_CDEV_IOC_SEND_RESPONSE _IOW('#', 0x04, struct fw_cdev_send_response) +#define FW_CDEV_IOC_INITIATE_BUS_RESET _IOW('#', 0x05, struct fw_cdev_initiate_bus_reset) +#define FW_CDEV_IOC_ADD_DESCRIPTOR _IOWR('#', 0x06, struct fw_cdev_add_descriptor) +#define FW_CDEV_IOC_REMOVE_DESCRIPTOR _IOW('#', 0x07, struct fw_cdev_remove_descriptor) + +#define FW_CDEV_IOC_CREATE_ISO_CONTEXT _IOW('#', 0x08, struct fw_cdev_create_iso_context) +#define FW_CDEV_IOC_QUEUE_ISO _IOWR('#', 0x09, struct fw_cdev_queue_iso) +#define FW_CDEV_IOC_START_ISO _IOW('#', 0x0a, struct fw_cdev_start_iso) +#define FW_CDEV_IOC_STOP_ISO _IOW('#', 0x0b, struct fw_cdev_stop_iso) + +/* FW_CDEV_VERSION History + * + * 1 Feb 18, 2007: Initial version. + */ +#define FW_CDEV_VERSION 1 + +struct fw_cdev_get_info { + /* The version field is just a running serial number. We + * never break backwards compatibility. Userspace passes in + * the version it expects and the kernel passes back the + * highest version it can provide. Even if the structs in + * this interface are extended in a later version, the kernel + * will not copy back more data than what was present in the + * interface version userspace expects. */ + __u32 version; + + /* If non-zero, at most rom_length bytes of config rom will be + * copied into that user space address. In either case, + * rom_length is updated with the actual length of the config + * rom. */ + __u32 rom_length; + __u64 rom; + + /* If non-zero, a fw_cdev_event_bus_reset struct will be + * copied here with the current state of the bus. This does + * not cause a bus reset to happen. The value of closure in + * this and sub-sequent bus reset events is set to + * bus_reset_closure. */ + __u64 bus_reset; + __u64 bus_reset_closure; + + /* The index of the card this devices belongs to. */ + __u32 card; +}; + +struct fw_cdev_send_request { + __u32 tcode; + __u32 length; + __u64 offset; + __u64 closure; + __u64 data; + __u32 generation; +}; + +struct fw_cdev_send_response { + __u32 rcode; + __u32 length; + __u64 data; + __u32 handle; +}; + +struct fw_cdev_allocate { + __u64 offset; + __u64 closure; + __u32 length; + __u32 handle; +}; + +struct fw_cdev_deallocate { + __u32 handle; +}; + +#define FW_CDEV_LONG_RESET 0 +#define FW_CDEV_SHORT_RESET 1 + +struct fw_cdev_initiate_bus_reset { + __u32 type; +}; + +struct fw_cdev_add_descriptor { + __u32 immediate; + __u32 key; + __u64 data; + __u32 length; + __u32 handle; +}; + +struct fw_cdev_remove_descriptor { + __u32 handle; +}; + +#define FW_CDEV_ISO_CONTEXT_TRANSMIT 0 +#define FW_CDEV_ISO_CONTEXT_RECEIVE 1 + +#define FW_CDEV_ISO_CONTEXT_MATCH_TAG0 1 +#define FW_CDEV_ISO_CONTEXT_MATCH_TAG1 2 +#define FW_CDEV_ISO_CONTEXT_MATCH_TAG2 4 +#define FW_CDEV_ISO_CONTEXT_MATCH_TAG3 8 +#define FW_CDEV_ISO_CONTEXT_MATCH_ALL_TAGS 15 + +struct fw_cdev_create_iso_context { + __u32 type; + __u32 header_size; + __u32 channel; + __u32 speed; + __u32 handle; +}; + +struct fw_cdev_iso_packet { + __u16 payload_length; /* Length of indirect payload. */ + __u32 interrupt : 1; /* Generate interrupt on this packet */ + __u32 skip : 1; /* Set to not send packet at all. */ + __u32 tag : 2; + __u32 sy : 4; + __u32 header_length : 8; /* Length of immediate header. */ + __u32 header[0]; +}; + +struct fw_cdev_queue_iso { + __u64 packets; + __u64 data; + __u32 size; + __u32 handle; +}; + +struct fw_cdev_start_iso { + __s32 cycle; + __u32 sync; + __u32 tags; + __u32 handle; +}; + +struct fw_cdev_stop_iso { + __u32 handle; +}; + +#endif /* __fw_cdev_h */ diff --git a/libraw1394-juju.patch b/libraw1394-juju.patch index cb221fe..47a5613 100644 --- a/libraw1394-juju.patch +++ b/libraw1394-juju.patch @@ -67,7 +67,7 @@ index 0000000..6fd6a5e +pkginclude_HEADERS = ../src/raw1394.h ../src/csr.h ../src/ieee1394.h diff --git a/juju/juju.h b/juju/juju.h new file mode 100644 -index 0000000..d78d362 +index 0000000..c7a2ebd --- /dev/null +++ b/juju/juju.h @@ -0,0 +1,143 @@ @@ -97,7 +97,7 @@ index 0000000..d78d362 + +#include +#include -+#include ++#include +#include "../src/raw1394.h" +#include "../src/csr.h" +#include "config.h" @@ -216,10 +216,10 @@ index 0000000..d78d362 +#endif diff --git a/juju/raw1394-iso.c b/juju/raw1394-iso.c new file mode 100644 -index 0000000..a320440 +index 0000000..5e18dab --- /dev/null +++ b/juju/raw1394-iso.c -@@ -0,0 +1,513 @@ +@@ -0,0 +1,522 @@ +/* -*- c-basic-offset: 8 -*- + * + * raw1394-iso.c -- Emulation of the raw1394 rawiso API on the juju stack @@ -288,6 +288,7 @@ index 0000000..a320440 + queue_iso.packets = ptr_to_u64(handle->iso.packets); + queue_iso.size = handle->iso.packet_index * sizeof handle->iso.packets[0]; + queue_iso.data = ptr_to_u64(handle->iso.first_payload); ++ queue_iso.handle = 0; + handle->iso.packet_index = 0; + handle->iso.first_payload = handle->iso.head; + @@ -346,7 +347,8 @@ index 0000000..a320440 + queue_xmit_packets(handle, prebuffer_packets); + + if (handle->iso.prebuffer <= handle->iso.packet_count) { -+ start_iso.cycle = start_on_cycle; ++ start_iso.cycle = start_on_cycle; ++ start_iso.handle = 0; + + retval = ioctl(handle->iso.fd, + FW_CDEV_IOC_START_ISO, &start_iso); @@ -434,6 +436,7 @@ index 0000000..a320440 + tag_mask == -1 ? FW_CDEV_ISO_CONTEXT_MATCH_ALL_TAGS : tag_mask; + /* sync is documented as 'not used' */ + start_iso.sync = 0; ++ start_iso.handle = 0; + + return ioctl(handle->iso.fd, FW_CDEV_IOC_START_ISO, &start_iso); +} @@ -492,7 +495,8 @@ index 0000000..a320440 + handle->iso.packet_count >= handle->iso.prebuffer) { + /* Set this to 0 to indicate that we're running. */ + handle->iso.prebuffer = 0; -+ start_iso.cycle = handle->iso.start_on_cycle; ++ start_iso.cycle = handle->iso.start_on_cycle; ++ start_iso.handle = 0; + + len = ioctl(handle->iso.fd, + FW_CDEV_IOC_START_ISO, &start_iso); @@ -519,6 +523,7 @@ index 0000000..a320440 + queue_iso.packets = ptr_to_u64(&skip); + queue_iso.size = sizeof skip; + queue_iso.data = 0; ++ queue_iso.handle = 0; + + len = ioctl(handle->iso.fd, FW_CDEV_IOC_QUEUE_ISO, &queue_iso); + if (len < 0) @@ -718,7 +723,11 @@ index 0000000..a320440 + +void raw1394_iso_stop(raw1394handle_t handle) +{ ++ struct fw_cdev_stop_iso stop_iso; ++ ++ stop_iso.handle = 0; + ioctl(handle->iso.fd, FW_CDEV_IOC_STOP_ISO); ++ + handle->iso.head = handle->iso.buffer; + handle->iso.tail = handle->iso.buffer; + handle->iso.first_payload = handle->iso.buffer; diff --git a/libraw1394.spec b/libraw1394.spec index 491bd8a..b53d668 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 1.2.1 -Release: 5%{?dist} +Release: 6%{?dist} License: LGPL Group: System Environment/Libraries Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz @@ -10,7 +10,7 @@ ExcludeArch: s390 s390x BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: autoconf automake libtool -Source1: fw-device-cdev.h +Source1: firewire-cdev.h Patch0: libraw1394-juju.patch Requires: kernel >= 2.6.20-1.3062.fc7 @@ -33,8 +33,10 @@ Development libraries needed to build applications against libraw1394. %build -test -e %{_builddir}/fw-device-cdev.h || \ - cp %{_sourcedir}/fw-device-cdev.h %{_builddir} +if test ! -e %{_builddir}/linux/firewire-cdev.h; then + mkdir %{_builddir}/linux + cp %{_sourcedir}/firewire-cdev.h %{_builddir}/linux +fi aclocal autoheader @@ -76,6 +78,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Tue Apr 17 2007 Kristian Høgsberg - 1.2.1--6 +- Update to latest ioctl changes. + * Thu Apr 12 2007 Kristian Høgsberg - 1.2.1-5 - Make rawiso support actually work. - Update fw-device-cdev.h to sync with latest kernel patch. From 19d00d3767144fc7b0646810f6289273772f9af4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Wed, 18 Apr 2007 14:55:42 +0000 Subject: [PATCH 034/100] - Update firewire-cdev.h again to get the iso context create ioctl changes. - Bump kernel requires accordingly. --- firewire-cdev.h | 3 ++- libraw1394.spec | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/firewire-cdev.h b/firewire-cdev.h index 1fbd8bf..026c768 100644 --- a/firewire-cdev.h +++ b/firewire-cdev.h @@ -133,7 +133,7 @@ union fw_cdev_event { #define FW_CDEV_IOC_ADD_DESCRIPTOR _IOWR('#', 0x06, struct fw_cdev_add_descriptor) #define FW_CDEV_IOC_REMOVE_DESCRIPTOR _IOW('#', 0x07, struct fw_cdev_remove_descriptor) -#define FW_CDEV_IOC_CREATE_ISO_CONTEXT _IOW('#', 0x08, struct fw_cdev_create_iso_context) +#define FW_CDEV_IOC_CREATE_ISO_CONTEXT _IOWR('#', 0x08, struct fw_cdev_create_iso_context) #define FW_CDEV_IOC_QUEUE_ISO _IOWR('#', 0x09, struct fw_cdev_queue_iso) #define FW_CDEV_IOC_START_ISO _IOW('#', 0x0a, struct fw_cdev_start_iso) #define FW_CDEV_IOC_STOP_ISO _IOW('#', 0x0b, struct fw_cdev_stop_iso) @@ -233,6 +233,7 @@ struct fw_cdev_create_iso_context { __u32 header_size; __u32 channel; __u32 speed; + __u64 closure; __u32 handle; }; diff --git a/libraw1394.spec b/libraw1394.spec index b53d668..09c5a7c 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -12,7 +12,7 @@ BuildRequires: autoconf automake libtool Source1: firewire-cdev.h Patch0: libraw1394-juju.patch -Requires: kernel >= 2.6.20-1.3062.fc7 +Requires: kernel >= 2.6.20-1.3087.fc7 %description The libraw1394 library provides direct access to the IEEE-1394 bus through @@ -78,7 +78,11 @@ rm -rf $RPM_BUILD_ROOT %changelog -* Tue Apr 17 2007 Kristian Høgsberg - 1.2.1--6 +* Wed Apr 18 2007 Kristian Høgsberg - 1.2.1-7 +- Update firewire-cdev.h again to get the iso context create ioctl changes. +- Bump kernel requires accordingly. + +* Tue Apr 17 2007 Kristian Høgsberg - 1.2.1-6 - Update to latest ioctl changes. * Thu Apr 12 2007 Kristian Høgsberg - 1.2.1-5 From 128298931941e04aaedcbfb25ace8b7f59c7ec8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Wed, 18 Apr 2007 14:56:32 +0000 Subject: [PATCH 035/100] Bump release. --- libraw1394.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index 09c5a7c..e888d13 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 1.2.1 -Release: 6%{?dist} +Release: 7%{?dist} License: LGPL Group: System Environment/Libraries Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz From 37cc2880430b68bc71262ace8a663291ec78acc1 Mon Sep 17 00:00:00 2001 From: Jarod Wilson Date: Thu, 14 Jun 2007 15:37:37 +0000 Subject: [PATCH 036/100] Flip kernel dep from a Req to a Conflict to prevent unnecessarily pulling kernels into build chroots --- libraw1394.spec | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libraw1394.spec b/libraw1394.spec index e888d13..5434731 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 1.2.1 -Release: 7%{?dist} +Release: 8%{?dist} License: LGPL Group: System Environment/Libraries Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz @@ -10,9 +10,9 @@ ExcludeArch: s390 s390x BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: autoconf automake libtool -Source1: firewire-cdev.h -Patch0: libraw1394-juju.patch -Requires: kernel >= 2.6.20-1.3087.fc7 +Source1: firewire-cdev.h +Patch0: libraw1394-juju.patch +Conflicts: kernel < 2.6.21-1.3194.fc7 %description The libraw1394 library provides direct access to the IEEE-1394 bus through @@ -78,6 +78,10 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Thu Jun 14 2007 Jarod Wilson - 1.2.1-8 +- Switch kernel Requires to a Conflicts so we don't end up + pulling kernels into build chroot, and bump to GA kernel ver + * Wed Apr 18 2007 Kristian Høgsberg - 1.2.1-7 - Update firewire-cdev.h again to get the iso context create ioctl changes. - Bump kernel requires accordingly. From c27f5852802e205f7208b575903cfc2a7507cfe3 Mon Sep 17 00:00:00 2001 From: Jarod Wilson Date: Sat, 16 Jun 2007 03:38:36 +0000 Subject: [PATCH 037/100] Don't use either Requires or Conflicts w/kernel... --- libraw1394.spec | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libraw1394.spec b/libraw1394.spec index 5434731..bafe8fa 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 1.2.1 -Release: 8%{?dist} +Release: 9%{?dist} License: LGPL Group: System Environment/Libraries Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz @@ -12,7 +12,6 @@ BuildRequires: autoconf automake libtool Source1: firewire-cdev.h Patch0: libraw1394-juju.patch -Conflicts: kernel < 2.6.21-1.3194.fc7 %description The libraw1394 library provides direct access to the IEEE-1394 bus through @@ -78,9 +77,13 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Fri Jun 15 2007 Jarod Wilson - 1.2.1-9 +- Drop Conficts, causes interesting issues if people have an + older kernel installed and/or kernel-xen installed (#244474) + * Thu Jun 14 2007 Jarod Wilson - 1.2.1-8 -- Switch kernel Requires to a Conflicts so we don't end up - pulling kernels into build chroot, and bump to GA kernel ver +- Switch kernel Requires to a Conflicts so we don't end up pulling + kernels into build chroot, and bump to GA kernel ver (#244128) * Wed Apr 18 2007 Kristian Høgsberg - 1.2.1-7 - Update firewire-cdev.h again to get the iso context create ioctl changes. From 58ded16449e704965063d45b49b0bf89c17b0f93 Mon Sep 17 00:00:00 2001 From: Jesse Keating Date: Wed, 29 Aug 2007 04:42:37 +0000 Subject: [PATCH 038/100] - Rebuild for selinux ppc32 issue. --- libraw1394.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index bafe8fa..ed7b49a 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 1.2.1 -Release: 9%{?dist} +Release: 10%{?dist} License: LGPL Group: System Environment/Libraries Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz @@ -77,6 +77,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Wed Aug 29 2007 Fedora Release Engineering - 1.2.1-10 +- Rebuild for selinux ppc32 issue. + * Fri Jun 15 2007 Jarod Wilson - 1.2.1-9 - Drop Conficts, causes interesting issues if people have an older kernel installed and/or kernel-xen installed (#244474) From c30eff291937dbda8a989d500db475735f3efea4 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Mon, 15 Oct 2007 19:04:03 +0000 Subject: [PATCH 039/100] makefile update to properly grab makefile.common --- Makefile | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 1c57459..ccec37c 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,21 @@ # Makefile for source rpm: libraw1394 -# $Id$ +# $Id: Makefile,v 1.1 2004/09/09 07:38:34 cvsdist Exp $ NAME := libraw1394 SPECFILE = $(firstword $(wildcard *.spec)) -include ../common/Makefile.common +define find-makefile-common +for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done +endef + +MAKEFILE_COMMON := $(shell $(find-makefile-common)) + +ifeq ($(MAKEFILE_COMMON),) +# attempt a checkout +define checkout-makefile-common +test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2 +endef + +MAKEFILE_COMMON := $(shell $(checkout-makefile-common)) +endif + +include $(MAKEFILE_COMMON) From a20e9ac4803b5c252016099f00b9911895fe40cf Mon Sep 17 00:00:00 2001 From: Jarod Wilson Date: Fri, 19 Oct 2007 13:36:16 +0000 Subject: [PATCH 040/100] libraw1394 v1.3.0 --- .cvsignore | 1 + libraw1394-juju.patch | 3057 +++++++++++++++++----------------- libraw1394-underquoted.patch | 47 - libraw1394.spec | 7 +- sources | 2 +- 5 files changed, 1530 insertions(+), 1584 deletions(-) delete mode 100644 libraw1394-underquoted.patch diff --git a/.cvsignore b/.cvsignore index 5de9d16..ad0dec6 100644 --- a/.cvsignore +++ b/.cvsignore @@ -1,3 +1,4 @@ libraw1394-1.2.0.tar.gz libraw1394-1.2.1.tar.gz fw-device-cdev.h +libraw1394-1.3.0.tar.gz diff --git a/libraw1394-juju.patch b/libraw1394-juju.patch index 47a5613..fe2d80b 100644 --- a/libraw1394-juju.patch +++ b/libraw1394-juju.patch @@ -1,49 +1,36 @@ -diff --git a/Makefile.am b/Makefile.am -index 04ed38a..21df527 100644 ---- a/Makefile.am -+++ b/Makefile.am -@@ -1,6 +1,7 @@ - # process this file with automake to create a Makefile.in - --SUBDIRS = src tools doc debian -+SUBDIRS = $(LIB_SUBDIR) tools doc debian -+DIST_SUBDIRS = src juju - - pkgconfigdir = @libdir@/pkgconfig - pkgconfig_DATA = libraw1394.pc -diff --git a/configure.ac b/configure.ac -index fe23ca8..7e5dd66 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -24,6 +24,27 @@ AC_SUBST(lt_major) +diff -Naurp libraw1394-1.3.0.orig/configure.ac libraw1394-1.3.0/configure.ac +--- libraw1394-1.3.0.orig/configure.ac 2007-05-30 01:32:37.000000000 -0400 ++++ libraw1394-1.3.0/configure.ac 2007-10-18 22:21:34.000000000 -0400 +@@ -24,6 +24,28 @@ AC_SUBST(lt_major) AC_SUBST(lt_revision) AC_SUBST(lt_age) +AC_ARG_WITH(juju-dir,[ --with-juju-dir= Path to juju include files]) +if ! test -z "$with_juju_dir" ; then -+ JUJU_DIR="$with_juju_dir" -+ LIB_SUBDIR=juju -+ AC_SUBST(JUJU_DIR) ++ JUJU_DIR="$with_juju_dir" ++ LIB_SUBDIR=juju ++ AC_SUBST(JUJU_DIR) +else -+ LIB_SUBDIR=src ++ LIB_SUBDIR=src +fi +AC_SUBST(LIB_SUBDIR) + +AC_ARG_WITH(fw-device-prefix, -+ [ --with-fw-device-prefix= Prefix of firewire device file names (default "fw").], -+ [FW_DEVICE_PREFIX="\"$withval\""], [FW_DEVICE_PREFIX="\"fw\""]) ++ [ --with-fw-device-prefix= Prefix of firewire device file names (default "fw").], ++ [FW_DEVICE_PREFIX="\"$withval\""], [FW_DEVICE_PREFIX="\"fw\""]) +AC_ARG_WITH(fw-device-dir, -+ [ --with-fw-device-dir= Directory to watch for firewire device files (default "/dev").], -+ [FW_DEVICE_DIR="\"$withval\""], [FW_DEVICE_DIR="\"/dev\""]) ++ [ --with-fw-device-dir= Directory to watch for firewire device files (default "/dev").], ++ [FW_DEVICE_DIR="\"$withval\""], [FW_DEVICE_DIR="\"/dev\""]) + +AC_DEFINE_UNQUOTED(FW_DEVICE_PREFIX, $FW_DEVICE_PREFIX, -+ [Prefix of firewire device file names.]) ++ [Prefix of firewire device file names.]) +AC_DEFINE_UNQUOTED(FW_DEVICE_DIR, $FW_DEVICE_DIR, -+ [Directory to watch for firewire device files.]) - - #CFLAGS=${CFLAGS:-"-Wall"} - AC_OUTPUT([ -@@ -31,6 +52,7 @@ Makefile ++ [Directory to watch for firewire device files.]) ++ + dnl Check to see if valgrind is available + AC_ARG_WITH(valgrind, AC_HELP_STRING([--with-valgrind],[compile with valgrind support])) + if test x$with_valgrind = xyes ; then +@@ -36,6 +58,7 @@ Makefile libraw1394.pc libraw1394.spec src/Makefile @@ -51,25 +38,9 @@ index fe23ca8..7e5dd66 100644 tools/Makefile doc/Makefile doc/testlibraw.1 -diff --git a/juju/Makefile.am b/juju/Makefile.am -new file mode 100644 -index 0000000..6fd6a5e ---- /dev/null -+++ b/juju/Makefile.am -@@ -0,0 +1,8 @@ -+lib_LTLIBRARIES = libraw1394.la -+ -+INCLUDES = -I$(JUJU_DIR) -+libraw1394_la_LDFLAGS = -version-info @lt_major@:@lt_revision@:@lt_age@ -+ -+libraw1394_la_SOURCES = raw1394.c raw1394-iso.c juju.h -+ -+pkginclude_HEADERS = ../src/raw1394.h ../src/csr.h ../src/ieee1394.h -diff --git a/juju/juju.h b/juju/juju.h -new file mode 100644 -index 0000000..c7a2ebd ---- /dev/null -+++ b/juju/juju.h +diff -Naurp libraw1394-1.3.0.orig/juju/juju.h libraw1394-1.3.0/juju/juju.h +--- libraw1394-1.3.0.orig/juju/juju.h 1969-12-31 19:00:00.000000000 -0500 ++++ libraw1394-1.3.0/juju/juju.h 2007-10-18 22:18:46.000000000 -0400 @@ -0,0 +1,143 @@ +/* -*- c-basic-offset: 8 -*- + * @@ -214,15 +185,25 @@ index 0000000..c7a2ebd +}; + +#endif -diff --git a/juju/raw1394-iso.c b/juju/raw1394-iso.c -new file mode 100644 -index 0000000..5e18dab ---- /dev/null -+++ b/juju/raw1394-iso.c -@@ -0,0 +1,522 @@ +diff -Naurp libraw1394-1.3.0.orig/juju/Makefile.am libraw1394-1.3.0/juju/Makefile.am +--- libraw1394-1.3.0.orig/juju/Makefile.am 1969-12-31 19:00:00.000000000 -0500 ++++ libraw1394-1.3.0/juju/Makefile.am 2007-10-18 22:18:46.000000000 -0400 +@@ -0,0 +1,8 @@ ++lib_LTLIBRARIES = libraw1394.la ++ ++INCLUDES = -I$(JUJU_DIR) ++libraw1394_la_LDFLAGS = -version-info @lt_major@:@lt_revision@:@lt_age@ ++ ++libraw1394_la_SOURCES = raw1394.c raw1394-iso.c juju.h ++ ++pkginclude_HEADERS = ../src/raw1394.h ../src/csr.h ../src/ieee1394.h +diff -Naurp libraw1394-1.3.0.orig/juju/raw1394.c libraw1394-1.3.0/juju/raw1394.c +--- libraw1394-1.3.0.orig/juju/raw1394.c 1969-12-31 19:00:00.000000000 -0500 ++++ libraw1394-1.3.0/juju/raw1394.c 2007-10-18 22:18:46.000000000 -0400 +@@ -0,0 +1,1441 @@ +/* -*- c-basic-offset: 8 -*- + * -+ * raw1394-iso.c -- Emulation of the raw1394 rawiso API on the juju stack ++ * raw1394.c -- Emulation of the raw1394 API on the juju stack + * + * Copyright (C) 2007 Kristian Hoegsberg + * @@ -241,1968 +222,1976 @@ index 0000000..5e18dab + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + ++#include +#include -+#include -+#include -+#include -+#include +#include -+#include ++#include +#include ++#include ++#include ++#include ++#include ++#include ++#include /* for ntohl and htonl */ + +#include "juju.h" + -+static int -+queue_packet(raw1394handle_t handle, -+ unsigned int length, unsigned int header_length, -+ unsigned char tag, unsigned char sy) ++raw1394_errcode_t ++raw1394_get_errcode(raw1394handle_t handle) +{ -+ struct fw_cdev_queue_iso queue_iso; -+ struct fw_cdev_iso_packet *p; -+ int err; -+ -+ p = &handle->iso.packets[handle->iso.packet_index]; -+ p->payload_length = length; -+ p->interrupt = -+ handle->iso.packet_phase == handle->iso.irq_interval - 1; -+ p->skip = 0; -+ p->tag = tag; -+ p->sy = sy; -+ p->header_length = header_length; -+ -+ handle->iso.head += length; -+ handle->iso.packet_count++; -+ handle->iso.packet_phase++; -+ handle->iso.packet_index++; -+ -+ if (handle->iso.packet_phase == handle->iso.irq_interval) -+ handle->iso.packet_phase = 0; ++ return handle->err; ++} + -+ if (handle->iso.head + handle->iso.max_packet_size > handle->iso.buffer_end) -+ handle->iso.head = handle->iso.buffer; ++int ++raw1394_errcode_to_errno(raw1394_errcode_t errcode) ++{ ++ switch (errcode) { + -+ /* Queue the packets in the kernel if we filled up the packets -+ * array or wrapped the payload buffer. */ -+ if (handle->iso.packet_index == handle->iso.irq_interval || -+ handle->iso.head == handle->iso.buffer) { -+ queue_iso.packets = ptr_to_u64(handle->iso.packets); -+ queue_iso.size = handle->iso.packet_index * sizeof handle->iso.packets[0]; -+ queue_iso.data = ptr_to_u64(handle->iso.first_payload); -+ queue_iso.handle = 0; -+ handle->iso.packet_index = 0; -+ handle->iso.first_payload = handle->iso.head; ++ case -RCODE_SEND_ERROR: ++ case -RCODE_CANCELLED: ++ case -RCODE_BUSY: ++ case -RCODE_GENERATION: ++ case -RCODE_NO_ACK: ++ return EAGAIN; + -+ err = ioctl(handle->iso.fd, FW_CDEV_IOC_QUEUE_ISO, &queue_iso); -+ if (err < 0) -+ return -1; ++ case raw1394_make_errcode(ACK_COMPLETE, RCODE_COMPLETE): ++ return 0; ++ case raw1394_make_errcode(ACK_COMPLETE, RCODE_CONFLICT_ERROR): ++ return EAGAIN; ++ case raw1394_make_errcode(ACK_COMPLETE, RCODE_DATA_ERROR): ++ return EREMOTEIO; ++ case raw1394_make_errcode(ACK_COMPLETE, RCODE_TYPE_ERROR): ++ return EPERM; ++ case raw1394_make_errcode(ACK_COMPLETE, RCODE_ADDRESS_ERROR): ++ return EINVAL; ++ default: ++ return EINVAL; + } +} + +static int -+queue_xmit_packets(raw1394handle_t handle, int limit) ++juju_to_raw1394_errcode(int rcode) +{ -+ enum raw1394_iso_disposition d; -+ unsigned char tag, sy; -+ int len, cycle, dropped; -+ -+ if (handle->iso.xmit_handler == NULL) -+ return 0; -+ -+ while (handle->iso.packet_count < limit) { -+ -+ d = handle->iso.xmit_handler(handle, handle->iso.head, -+ &len, &tag, &sy, cycle, dropped); -+ -+ switch (d) { -+ case RAW1394_ISO_OK: -+ queue_packet(handle, len, 0, tag, sy); -+ break; -+ case RAW1394_ISO_DEFER: -+ case RAW1394_ISO_AGAIN: -+ default: -+ return 0; -+ case RAW1394_ISO_ERROR: -+ return -1; -+ case RAW1394_ISO_STOP: -+ raw1394_iso_stop(handle); -+ return 0; -+ } -+ } ++ /* Best effort matching juju extended rcodes to raw1394 err ++ * code. Since the raw1394 errcode decoding are macros we try ++ * to convert the juju rcodes to something that looks enough ++ * like the raw1394 errcodes that we retain ABI compatibility. ++ * ++ * Juju rcodes less than 0x10 are standard ieee1394 rcodes, ++ * which we map to a raw1394 errcode by or'ing in an ++ * ACK_COMPLETE ack code in the upper 16 bits. Errors ++ * internal to raw1394 are negative values, but juju encodes ++ * these errors as rcodes greater than or equal to 0x10. In ++ * this case, we just the negated value, which will look like ++ * an raw1394 internal error code. */ + -+ return 0; ++ if (rcode < 0x10) ++ return raw1394_make_errcode(ACK_COMPLETE, rcode); ++ else ++ return -rcode; +} + -+int raw1394_iso_xmit_start(raw1394handle_t handle, int start_on_cycle, -+ int prebuffer_packets) ++static int ++default_tag_handler(raw1394handle_t handle, ++ unsigned long tag, raw1394_errcode_t err) +{ -+ struct fw_cdev_start_iso start_iso; -+ int retval; ++ struct raw1394_reqhandle *rh = (struct raw1394_reqhandle *) tag; + -+ if (prebuffer_packets == -1) -+ prebuffer_packets = handle->iso.irq_interval; ++ if (rh != NULL) ++ return rh->callback(handle, rh->data, err); + -+ handle->iso.prebuffer = prebuffer_packets; -+ handle->iso.start_on_cycle = start_on_cycle; ++ return -1; ++} + -+ queue_xmit_packets(handle, prebuffer_packets); ++static int ++default_arm_tag_handler(raw1394handle_t handle, unsigned long arm_tag, ++ byte_t type, unsigned int length, void *data) ++{ ++ struct raw1394_arm_reqhandle *rh; + -+ if (handle->iso.prebuffer <= handle->iso.packet_count) { -+ start_iso.cycle = start_on_cycle; -+ start_iso.handle = 0; ++ if (arm_tag == 0) ++ return -1; + -+ retval = ioctl(handle->iso.fd, -+ FW_CDEV_IOC_START_ISO, &start_iso); -+ if (retval < 0) -+ return retval; -+ } ++ rh = (struct raw1394_arm_reqhandle *) arm_tag; + -+ return queue_xmit_packets(handle, handle->iso.buf_packets); ++ return rh->arm_callback(handle, data, length, rh->pcontext, type); +} + +static int -+queue_recv_packets(raw1394handle_t handle) ++default_bus_reset_handler(struct raw1394_handle *handle, unsigned int gen) +{ -+ while (handle->iso.packet_count <= handle->iso.buf_packets) -+ queue_packet(handle, handle->iso.max_packet_size, 4, 0, 0); ++ raw1394_update_generation(handle, gen); + + return 0; +} -+ -+static enum raw1394_iso_disposition -+flush_recv_packets(raw1394handle_t handle, -+ struct fw_cdev_event_iso_interrupt *interrupt) -+{ -+ enum raw1394_iso_disposition d; -+ quadlet_t header, *p, *end; -+ unsigned int len, cycle, dropped; -+ unsigned char channel, tag, sy; + -+ p = interrupt->header; -+ end = (void *) interrupt->header + interrupt->header_length; -+ cycle = interrupt->cycle; -+ dropped = 0; -+ d = RAW1394_ISO_OK; ++static int ++scan_devices(raw1394handle_t handle) ++{ ++ DIR *dir; ++ struct dirent *de; ++ char filename[32]; ++ struct fw_cdev_get_info get_info; ++ struct fw_cdev_event_bus_reset reset; ++ int fd, err, i; ++ struct port *ports; + -+ while (p < end) { -+ header = be32_to_cpu(*p++); -+ len = header >> 16; -+ tag = (header >> 14) & 0x3; -+ channel = (header >> 8) & 0x3f; -+ sy = header & 0x0f; ++ ports = handle->ports; ++ memset(ports, 0, sizeof handle->ports); ++ dir = opendir(FW_DEVICE_DIR); ++ if (dir == NULL) ++ return -1; + -+ d = handle->iso.recv_handler(handle, handle->iso.tail, len, -+ channel, tag, sy, cycle, dropped); -+ if (d != RAW1394_ISO_OK) -+ /* FIXME: we need to save the headers so we -+ * can restart this loop. */ ++ i = 0; ++ while (1) { ++ de = readdir(dir); ++ if (de == NULL) + break; -+ cycle++; + -+ handle->iso.tail += handle->iso.max_packet_size; -+ handle->iso.packet_count--; ++ if (strncmp(de->d_name, ++ FW_DEVICE_PREFIX, strlen(FW_DEVICE_PREFIX)) != 0) ++ continue; + -+ if (handle->iso.tail + handle->iso.max_packet_size > handle->iso.buffer_end) -+ handle->iso.tail = handle->iso.buffer; -+ } ++ snprintf(filename, sizeof filename, FW_DEVICE_DIR "/%s", de->d_name); + -+ switch (d) { -+ case RAW1394_ISO_OK: -+ case RAW1394_ISO_DEFER: -+ default: -+ break; -+ -+ case RAW1394_ISO_ERROR: -+ return -1; ++ fd = open(filename, O_RDWR); ++ if (fd < 0) ++ continue; ++ get_info.version = FW_CDEV_VERSION; ++ get_info.rom = 0; ++ get_info.rom_length = 0; ++ get_info.bus_reset = ptr_to_u64(&reset); ++ err = ioctl(fd, FW_CDEV_IOC_GET_INFO, &get_info); ++ close(fd); + -+ case RAW1394_ISO_STOP: -+ raw1394_iso_stop(handle); -+ return 0; ++ if (err < 0) ++ continue; ++ ++ if (i < MAX_PORTS && reset.node_id == reset.local_node_id) { ++ strncpy(ports[i].device_file, filename, ++ sizeof ports[i].device_file); ++ ports[i].node_count = (reset.root_node_id & 0x3f) + 1; ++ ports[i].card = get_info.card; ++ i++; ++ } + } ++ closedir(dir); + -+ queue_recv_packets(handle); ++ handle->port_count = i; + + return 0; +} + -+int raw1394_iso_recv_start(raw1394handle_t handle, int start_on_cycle, -+ int tag_mask, int sync) ++static int ++handle_echo_pipe(raw1394handle_t handle, ++ struct epoll_closure *ec, __uint32_t events) +{ -+ struct fw_cdev_start_iso start_iso; -+ -+ queue_recv_packets(handle); ++ quadlet_t value; + -+ start_iso.cycle = start_on_cycle; -+ start_iso.tags = -+ tag_mask == -1 ? FW_CDEV_ISO_CONTEXT_MATCH_ALL_TAGS : tag_mask; -+ /* sync is documented as 'not used' */ -+ start_iso.sync = 0; -+ start_iso.handle = 0; ++ if (read(handle->pipe_fds[0], &value, sizeof value) < 0) ++ return -1; + -+ return ioctl(handle->iso.fd, FW_CDEV_IOC_START_ISO, &start_iso); ++ return value; +} + -+static int handle_iso_event(raw1394handle_t handle, -+ struct epoll_closure *closure, __uint32_t events) ++static int ++handle_lost_device(raw1394handle_t handle, int i) +{ -+ struct fw_cdev_event_iso_interrupt *interrupt; -+ int len; ++ int phy_id; + -+ len = read(handle->iso.fd, handle->buffer, sizeof handle->buffer); -+ if (len < 0) -+ return -1; ++ /* The device got unplugged, get rid of it. The fd is ++ * automatically dropped from the epoll context when we close it. */ + -+ interrupt = (struct fw_cdev_event_iso_interrupt *) handle->buffer; -+ if (interrupt->type != FW_CDEV_EVENT_ISO_INTERRUPT) -+ return 0; ++ close(handle->devices[i].fd); ++ phy_id = handle->devices[i].node_id & 0x3f; ++ if (handle->nodes[phy_id] == i) ++ handle->nodes[phy_id] = -1; ++ handle->devices[i].node_id = -1; + -+ switch (handle->iso.type) { -+ case FW_CDEV_ISO_CONTEXT_TRANSMIT: -+ handle->iso.packet_count -= handle->iso.irq_interval; -+ return queue_xmit_packets(handle, handle->iso.buf_packets); -+ case FW_CDEV_ISO_CONTEXT_RECEIVE: -+ return flush_recv_packets(handle, interrupt); -+ default: -+ /* Doesn't happen. */ -+ return -1; -+ } ++ return 0; +} + -+int raw1394_iso_xmit_write(raw1394handle_t handle, unsigned char *data, -+ unsigned int len, unsigned char tag, -+ unsigned char sy) ++struct address_closure { ++ int (*callback)(raw1394handle_t handle, struct address_closure *ac, ++ struct fw_cdev_event_request *request, int i); ++}; ++ ++static int ++handle_fcp_request(raw1394handle_t handle, struct address_closure *ac, ++ struct fw_cdev_event_request *request, int i) +{ -+ struct fw_cdev_queue_iso queue_iso; -+ struct fw_cdev_start_iso start_iso; -+ struct fw_cdev_iso_packet *p; ++ struct fw_cdev_send_response response; ++ int is_response; + -+ if (len > handle->iso.max_packet_size) { -+ errno = EINVAL; -+ return -1; -+ } ++ response.handle = request->handle; ++ response.rcode = RCODE_COMPLETE; ++ response.length = 0; ++ response.data = 0; + -+ /* Block until we have space for another packet. */ -+ while (handle->iso.packet_count + handle->iso.irq_interval > -+ handle->iso.buf_packets) -+ raw1394_loop_iterate(handle); -+ -+ memcpy(handle->iso.head, data, len); -+ if (queue_packet(handle, len, 0, tag, sy) < 0) ++ if (handle->fcp_handler == NULL) ++ response.rcode = RCODE_ADDRESS_ERROR; ++ ++ if (request->tcode >= TCODE_WRITE_RESPONSE) ++ response.rcode = RCODE_CONFLICT_ERROR; ++ ++ if (ioctl(handle->devices[i].fd, ++ FW_CDEV_IOC_SEND_RESPONSE, &response) < 0) + return -1; + -+ /* Start the streaming if it's not already running and if -+ * we've buffered up enough packets. */ -+ if (handle->iso.prebuffer > 0 && -+ handle->iso.packet_count >= handle->iso.prebuffer) { -+ /* Set this to 0 to indicate that we're running. */ -+ handle->iso.prebuffer = 0; -+ start_iso.cycle = handle->iso.start_on_cycle; -+ start_iso.handle = 0; ++ if (response.rcode != RCODE_COMPLETE) ++ return 0; + -+ len = ioctl(handle->iso.fd, -+ FW_CDEV_IOC_START_ISO, &start_iso); -+ if (len < 0) -+ return len; -+ } ++ is_response = request->offset >= CSR_REGISTER_BASE + CSR_FCP_RESPONSE; + -+ return 0; ++ return handle->fcp_handler(handle, ++ handle->devices[i].node_id, ++ is_response, ++ request->length, ++ (unsigned char *) request->data); +} + -+int raw1394_iso_xmit_sync(raw1394handle_t handle) ++static int ++handle_device_event(raw1394handle_t handle, ++ struct epoll_closure *ec, __uint32_t events) +{ -+ struct fw_cdev_iso_packet skip; -+ struct fw_cdev_queue_iso queue_iso; -+ int len; -+ -+ skip.payload_length = 0; -+ skip.interrupt = 1; -+ skip.skip = 1; -+ skip.tag = 0; -+ skip.sy = 0; -+ skip.header_length = 0; ++ union fw_cdev_event *u; ++ struct device *device = (struct device *) ec; ++ struct address_closure *ac; ++ struct request_closure *rc; ++ raw1394_errcode_t errcode; ++ int len, phy_id; ++ int i; + -+ queue_iso.packets = ptr_to_u64(&skip); -+ queue_iso.size = sizeof skip; -+ queue_iso.data = 0; -+ queue_iso.handle = 0; ++ i = device - handle->devices; ++ if (events == EPOLLHUP) ++ return handle_lost_device(handle, i); + -+ len = ioctl(handle->iso.fd, FW_CDEV_IOC_QUEUE_ISO, &queue_iso); ++ len = read(handle->devices[i].fd, ++ handle->buffer, sizeof handle->buffer); + if (len < 0) + return -1; + -+ /* Now that we've queued the skip packet, we'll get an -+ * interrupt when the transmit buffer is flushed, so all we do -+ * here is wait. */ -+ while (handle->iso.packet_count > 0) -+ raw1394_loop_iterate(handle); ++ u = (void *) handle->buffer; ++ switch (u->common.type) { ++ case FW_CDEV_EVENT_BUS_RESET: ++ /* Clear old entry, unless it's been overwritten. */ ++ phy_id = handle->devices[i].node_id & 0x3f; ++ if (handle->nodes[phy_id] == i) ++ handle->nodes[phy_id] = -1; ++ handle->nodes[u->bus_reset.node_id & 0x3f] = i; ++ handle->devices[i].node_id = u->bus_reset.node_id; ++ handle->devices[i].generation = u->bus_reset.generation; + -+ /* The iso mainloop thinks that interrutps indicate another -+ * irq_interval number of packets was sent, so the skip -+ * interrupt makes it go out of whack. We just reset it. */ -+ handle->iso.head = handle->iso.buffer; -+ handle->iso.tail = handle->iso.buffer; -+ handle->iso.first_payload = handle->iso.buffer; -+ handle->iso.packet_phase = 0; -+ handle->iso.packet_count = 0; ++ if (u->bus_reset.node_id != u->bus_reset.local_node_id) ++ return 0; + -+ return 0; -+} ++ memcpy(&handle->reset, &u->bus_reset, sizeof handle->reset); ++ return handle->bus_reset_handler(handle, ++ u->bus_reset.generation); + -+int raw1394_iso_recv_flush(raw1394handle_t handle) -+{ -+ /* FIXME: huh, we'll need kernel support here... */ ++ case FW_CDEV_EVENT_RESPONSE: ++ rc = u64_to_ptr(u->response.closure); + -+ return 0; -+} ++ if (rc->data != NULL) ++ memcpy(rc->data, u->response.data, rc->length); + -+static unsigned int -+round_to_power_of_two(unsigned int value) -+{ -+ unsigned int pot; ++ errcode = juju_to_raw1394_errcode(u->response.rcode); + -+ pot = 1; -+ while (pot < value) -+ pot <<= 1; ++ return handle->tag_handler(handle, rc->tag, errcode); + -+ return pot; ++ case FW_CDEV_EVENT_REQUEST: ++ ac = u64_to_ptr(u->request.closure); ++ return ac->callback(handle, ac, &u->request, i); ++ ++ default: ++ case FW_CDEV_EVENT_ISO_INTERRUPT: ++ /* Never happens. */ ++ return -1; ++ } +} + +static int -+iso_init(raw1394handle_t handle, int type, -+ raw1394_iso_xmit_handler_t xmit_handler, -+ raw1394_iso_recv_handler_t recv_handler, -+ unsigned int buf_packets, -+ unsigned int max_packet_size, -+ unsigned char channel, -+ enum raw1394_iso_speed speed, -+ int irq_interval) ++handle_inotify(raw1394handle_t handle, struct epoll_closure *ec, ++ __uint32_t events) +{ -+ struct fw_cdev_create_iso_context create; ++ struct inotify_event *event; ++ char filename[32]; ++ struct fw_cdev_get_info info; ++ struct fw_cdev_event_bus_reset reset; + struct epoll_event ep; -+ int retval, prot; ++ int i, len, fd, phy_id; + -+ if (handle->iso.fd != -1) { -+ errno = EBUSY; -+ return -1; -+ } -+ -+ switch (type) { -+ case FW_CDEV_ISO_CONTEXT_TRANSMIT: -+ prot = PROT_READ | PROT_WRITE; -+ break; -+ case FW_CDEV_ISO_CONTEXT_RECEIVE: -+ prot = PROT_READ; -+ break; -+ default: -+ errno = EINVAL; ++ event = (struct inotify_event *) handle->buffer; ++ len = read(handle->inotify_fd, event, BUFFER_SIZE); ++ if (!(event->mask & IN_CREATE)) + return -1; ++ if (strncmp(event->name, ++ FW_DEVICE_PREFIX, strlen(FW_DEVICE_PREFIX)) != 0) ++ return 0; ++ snprintf(filename, sizeof filename, FW_DEVICE_DIR "/%s", event->name); ++ fd = open(filename, O_RDWR); ++ if (fd < 0) { ++ switch (errno) { ++ case ENOENT: ++ /* Huh, it disappeared before we could ++ * open it. */ ++ return 0; ++ case EACCES: ++ /* We don't have permission to talk to ++ * this device, maybe it's a storage ++ * device. */ ++ return 0; ++ default: ++ /* Anything else is bad news. */ ++ return -1; ++ } + } + -+ handle->iso.type = type; -+ if (irq_interval < 0) -+ handle->iso.irq_interval = 256; -+ else -+ handle->iso.irq_interval = irq_interval; -+ handle->iso.xmit_handler = xmit_handler; -+ handle->iso.recv_handler = recv_handler; -+ handle->iso.buf_packets = buf_packets; -+ handle->iso.max_packet_size = round_to_power_of_two(max_packet_size); -+ handle->iso.packet_phase = 0; -+ handle->iso.packet_count = 0; -+ handle->iso.packets = -+ malloc(handle->iso.irq_interval * sizeof handle->iso.packets[0]); -+ if (handle->iso.packets == NULL) ++ info.version = FW_CDEV_VERSION; ++ info.rom = 0; ++ info.rom_length = 0; ++ info.bus_reset = ptr_to_u64(&reset); ++ if (ioctl(fd, FW_CDEV_IOC_GET_INFO, &info) < 0) { ++ close(fd); + return -1; ++ } + -+ handle->iso.fd = open(handle->local_filename, O_RDWR); -+ if (handle->iso.fd < 0) { -+ free(handle->iso.packets); ++ for (i = 0; i < MAX_DEVICES; i++) ++ if (handle->devices[i].node_id == -1) ++ break; ++ if (i == MAX_DEVICES) { ++ close(fd); + return -1; + } + -+ handle->iso.closure.func = handle_iso_event; ++ phy_id = reset.node_id & 0x3f; ++ handle->nodes[phy_id] = i; ++ handle->devices[i].node_id = reset.node_id; ++ handle->devices[i].generation = reset.generation; ++ handle->devices[i].fd = fd; ++ strncpy(handle->devices[i].filename, filename, ++ sizeof handle->devices[i].filename); ++ handle->devices[i].closure.func = handle_device_event; + ep.events = EPOLLIN; -+ ep.data.ptr = &handle->iso.closure; -+ if (epoll_ctl(handle->epoll_fd, EPOLL_CTL_ADD, -+ handle->iso.fd, &ep) < 0) { -+ close(handle->iso.fd); -+ free(handle->iso.packets); ++ ep.data.ptr = &handle->devices[i].closure; ++ if (epoll_ctl(handle->epoll_fd, EPOLL_CTL_ADD, fd, &ep) < 0) { ++ close(fd); + return -1; + } + -+ create.type = type; -+ create.channel = channel; -+ create.speed = speed; -+ create.header_size = 4; -+ -+ retval = ioctl(handle->iso.fd, -+ FW_CDEV_IOC_CREATE_ISO_CONTEXT, &create); -+ if (retval < 0) { -+ close(handle->iso.fd); -+ free(handle->iso.packets); -+ return retval; -+ } ++ return 0; ++} + -+ handle->iso.buffer = -+ mmap(NULL, buf_packets * max_packet_size, -+ prot, MAP_SHARED, handle->iso.fd, 0); ++int raw1394_loop_iterate(raw1394handle_t handle) ++{ ++ int i, count, retval = 0; ++ struct epoll_closure *closure; ++ struct epoll_event ep[32]; + -+ if (handle->iso.buffer == MAP_FAILED) { -+ close(handle->iso.fd); -+ free(handle->iso.packets); ++ count = epoll_wait(handle->epoll_fd, ep, ARRAY_LENGTH(ep), -1); ++ if (count < 0) + return -1; ++ ++ for (i = 0; i < count; i++) { ++ closure = ep[i].data.ptr; ++ retval = closure->func(handle, closure, ep[i].events); + } + -+ handle->iso.buffer_end = handle->iso.buffer + -+ buf_packets * max_packet_size; -+ handle->iso.head = handle->iso.buffer; -+ handle->iso.tail = handle->iso.buffer; -+ handle->iso.first_payload = handle->iso.buffer; ++ /* It looks like we have to add this work-around to get epoll ++ * to recompute the POLLIN status of the epoll_fd. */ ++ epoll_wait(handle->epoll_fd, ep, ARRAY_LENGTH(ep), 0); + -+ return 0; ++ return retval; +} + -+int raw1394_iso_xmit_init(raw1394handle_t handle, -+ raw1394_iso_xmit_handler_t handler, -+ unsigned int buf_packets, -+ unsigned int max_packet_size, -+ unsigned char channel, -+ enum raw1394_iso_speed speed, -+ int irq_interval) ++raw1394handle_t raw1394_new_handle(void) +{ -+ return iso_init(handle, FW_CDEV_ISO_CONTEXT_TRANSMIT, -+ handler, NULL, buf_packets, max_packet_size, -+ channel, speed, irq_interval); ++ raw1394handle_t handle; ++ struct epoll_event ep; ++ int i; ++ ++ handle = malloc(sizeof *handle); ++ ++ handle->tag_handler = default_tag_handler; ++ handle->arm_tag_handler = default_arm_tag_handler; ++ handle->allocations = NULL; ++ ++ handle->notify_bus_reset = RAW1394_NOTIFY_ON; ++ handle->bus_reset_handler = default_bus_reset_handler; ++ ++ handle->iso.fd = -1; ++ ++ handle->epoll_fd = epoll_create(16); ++ if (handle->epoll_fd < 0) ++ goto out_handle; ++ ++ if (pipe(handle->pipe_fds) < 0) ++ goto out_epoll; ++ ++ handle->inotify_fd = inotify_init(); ++ if (handle->inotify_fd < 0) ++ goto out_pipe; ++ ++ handle->inotify_watch = ++ inotify_add_watch(handle->inotify_fd, FW_DEVICE_DIR, IN_CREATE); ++ if (handle->inotify_watch < 0) ++ goto out_inotify; ++ ++ handle->pipe_closure.func = handle_echo_pipe; ++ ep.events = EPOLLIN; ++ ep.data.ptr = &handle->pipe_closure; ++ if (epoll_ctl(handle->epoll_fd, EPOLL_CTL_ADD, ++ handle->pipe_fds[0], &ep) < 0) ++ goto out_inotify; ++ ++ handle->inotify_closure.func = handle_inotify; ++ ep.events = EPOLLIN; ++ ep.data.ptr = &handle->inotify_closure; ++ if (epoll_ctl(handle->epoll_fd, EPOLL_CTL_ADD, ++ handle->inotify_fd, &ep) < 0) ++ goto out_inotify; ++ ++ for (i = 0; i < MAX_DEVICES; i++) { ++ handle->nodes[i] = -1; ++ handle->devices[i].node_id = -1; ++ } ++ ++ scan_devices(handle); ++ ++ return handle; ++ ++ out_inotify: ++ close(handle->inotify_fd); ++ out_pipe: ++ close(handle->pipe_fds[0]); ++ close(handle->pipe_fds[1]); ++ out_epoll: ++ close(handle->epoll_fd); ++ out_handle: ++ free(handle); ++ return NULL; +} + -+int raw1394_iso_recv_init(raw1394handle_t handle, -+ raw1394_iso_recv_handler_t handler, -+ unsigned int buf_packets, -+ unsigned int max_packet_size, -+ unsigned char channel, -+ enum raw1394_iso_dma_recv_mode mode, -+ int irq_interval) ++void raw1394_destroy_handle(raw1394handle_t handle) +{ -+ return iso_init(handle, FW_CDEV_ISO_CONTEXT_RECEIVE, -+ NULL, handler, buf_packets, max_packet_size, -+ channel, 0, irq_interval); ++ int i; ++ ++ close(handle->inotify_fd); ++ close(handle->pipe_fds[0]); ++ close(handle->pipe_fds[1]); ++ ++ for (i = 0; i < MAX_DEVICES; i++) { ++ if (handle->devices[i].node_id == -1) ++ continue; ++ ++ close(handle->devices[i].fd); ++ } ++ ++ close(handle->epoll_fd); ++ ++ free(handle); ++ ++ return; +} + -+int raw1394_iso_multichannel_recv_init(raw1394handle_t handle, -+ raw1394_iso_recv_handler_t handler, -+ unsigned int buf_packets, -+ unsigned int max_packet_size, -+ int irq_interval) ++raw1394handle_t raw1394_new_handle_on_port(int port) +{ -+ /* FIXME: gah */ -+ errno = ENOSYS; -+ return -1; ++ raw1394handle_t handle; ++ ++ handle = raw1394_new_handle(); ++ if (handle == NULL) ++ return NULL; ++ ++ if (raw1394_set_port(handle, port) < 0) ++ return NULL; ++ ++ return handle; +} + -+int raw1394_iso_recv_listen_channel(raw1394handle_t handle, -+ unsigned char channel) ++int raw1394_busreset_notify (raw1394handle_t handle, int off_on_switch) +{ -+ /* FIXME: multichannel */ -+ errno = ENOSYS; -+ return -1; ++ handle->notify_bus_reset = off_on_switch; ++ ++ return 0; +} + -+int raw1394_iso_recv_unlisten_channel(raw1394handle_t handle, -+ unsigned char channel) ++int raw1394_get_fd(raw1394handle_t handle) +{ -+ /* FIXME: multichannel */ -+ errno = ENOSYS; -+ return -1; ++ return handle->epoll_fd; +} + -+int raw1394_iso_recv_set_channel_mask(raw1394handle_t handle, u_int64_t mask) ++void raw1394_set_userdata(raw1394handle_t handle, void *data) +{ -+ /* FIXME: multichannel */ -+ errno = ENOSYS; -+ return -1; -+} -+ -+void raw1394_iso_stop(raw1394handle_t handle) -+{ -+ struct fw_cdev_stop_iso stop_iso; -+ -+ stop_iso.handle = 0; -+ ioctl(handle->iso.fd, FW_CDEV_IOC_STOP_ISO); -+ -+ handle->iso.head = handle->iso.buffer; -+ handle->iso.tail = handle->iso.buffer; -+ handle->iso.first_payload = handle->iso.buffer; -+ handle->iso.packet_phase = 0; -+ handle->iso.packet_count = 0; -+} -+ -+void raw1394_iso_shutdown(raw1394handle_t handle) -+{ -+ munmap(handle->iso.buffer, -+ handle->iso.buf_packets * handle->iso.max_packet_size); -+ close(handle->iso.fd); -+ free(handle->iso.packets); ++ handle->user_data = data; +} -diff --git a/juju/raw1394.c b/juju/raw1394.c -new file mode 100644 -index 0000000..7f73b3b ---- /dev/null -+++ b/juju/raw1394.c -@@ -0,0 +1,1441 @@ -+/* -*- c-basic-offset: 8 -*- -+ * -+ * raw1394.c -- Emulation of the raw1394 API on the juju stack -+ * -+ * Copyright (C) 2007 Kristian Hoegsberg -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software Foundation, -+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include /* for ntohl and htonl */ -+ -+#include "juju.h" + -+raw1394_errcode_t -+raw1394_get_errcode(raw1394handle_t handle) ++void *raw1394_get_userdata(raw1394handle_t handle) +{ -+ return handle->err; ++ return handle->user_data; +} + -+int -+raw1394_errcode_to_errno(raw1394_errcode_t errcode) ++nodeid_t raw1394_get_local_id(raw1394handle_t handle) +{ -+ switch (errcode) { -+ -+ case -RCODE_SEND_ERROR: -+ case -RCODE_CANCELLED: -+ case -RCODE_BUSY: -+ case -RCODE_GENERATION: -+ case -RCODE_NO_ACK: -+ return EAGAIN; -+ -+ case raw1394_make_errcode(ACK_COMPLETE, RCODE_COMPLETE): -+ return 0; -+ case raw1394_make_errcode(ACK_COMPLETE, RCODE_CONFLICT_ERROR): -+ return EAGAIN; -+ case raw1394_make_errcode(ACK_COMPLETE, RCODE_DATA_ERROR): -+ return EREMOTEIO; -+ case raw1394_make_errcode(ACK_COMPLETE, RCODE_TYPE_ERROR): -+ return EPERM; -+ case raw1394_make_errcode(ACK_COMPLETE, RCODE_ADDRESS_ERROR): -+ return EINVAL; -+ default: -+ return EINVAL; -+ } ++ return handle->reset.local_node_id; +} + -+static int -+juju_to_raw1394_errcode(int rcode) ++nodeid_t raw1394_get_irm_id(raw1394handle_t handle) +{ -+ /* Best effort matching juju extended rcodes to raw1394 err -+ * code. Since the raw1394 errcode decoding are macros we try -+ * to convert the juju rcodes to something that looks enough -+ * like the raw1394 errcodes that we retain ABI compatibility. -+ * -+ * Juju rcodes less than 0x10 are standard ieee1394 rcodes, -+ * which we map to a raw1394 errcode by or'ing in an -+ * ACK_COMPLETE ack code in the upper 16 bits. Errors -+ * internal to raw1394 are negative values, but juju encodes -+ * these errors as rcodes greater than or equal to 0x10. In -+ * this case, we just the negated value, which will look like -+ * an raw1394 internal error code. */ -+ -+ if (rcode < 0x10) -+ return raw1394_make_errcode(ACK_COMPLETE, rcode); -+ else -+ return -rcode; ++ return handle->reset.irm_node_id; +} + -+static int -+default_tag_handler(raw1394handle_t handle, -+ unsigned long tag, raw1394_errcode_t err) ++int raw1394_get_nodecount(raw1394handle_t handle) +{ -+ struct raw1394_reqhandle *rh = (struct raw1394_reqhandle *) tag; -+ -+ if (rh != NULL) -+ return rh->callback(handle, rh->data, err); -+ -+ return -1; ++ return (handle->reset.root_node_id & 0x3f) + 1; +} + -+static int -+default_arm_tag_handler(raw1394handle_t handle, unsigned long arm_tag, -+ byte_t type, unsigned int length, void *data) ++int raw1394_get_port_info(raw1394handle_t handle, ++ struct raw1394_portinfo *pinf, ++ int maxports) +{ -+ struct raw1394_arm_reqhandle *rh; -+ -+ if (arm_tag == 0) -+ return -1; -+ -+ rh = (struct raw1394_arm_reqhandle *) arm_tag; ++ int i; + -+ return rh->arm_callback(handle, data, length, rh->pcontext, type); -+} ++ if (maxports >= handle->port_count) ++ maxports = handle->port_count; + -+static int -+default_bus_reset_handler(struct raw1394_handle *handle, unsigned int gen) -+{ -+ raw1394_update_generation(handle, gen); ++ for (i = 0; i < maxports; i++) { ++ pinf[i].nodes = handle->ports[i].node_count; ++ strncpy(pinf[i].name, handle->ports[i].device_file, ++ sizeof pinf[i].name); ++ } + -+ return 0; ++ return handle->port_count; +} + -+static int -+scan_devices(raw1394handle_t handle) ++int raw1394_set_port(raw1394handle_t handle, int port) +{ -+ DIR *dir; -+ struct dirent *de; -+ char filename[32]; + struct fw_cdev_get_info get_info; + struct fw_cdev_event_bus_reset reset; -+ int fd, err, i; -+ struct port *ports; ++ struct epoll_event ep; ++ struct dirent *de; ++ char filename[32]; ++ DIR *dir; ++ int i, fd, phy_id; + -+ ports = handle->ports; -+ memset(ports, 0, sizeof handle->ports); -+ dir = opendir(FW_DEVICE_DIR); ++ if (port >= handle->port_count) { ++ errno = EINVAL; ++ return -1; ++ } ++ ++ dir = opendir("/dev"); + if (dir == NULL) + return -1; + -+ i = 0; -+ while (1) { ++ for (i = 0; i < MAX_DEVICES; ) { + de = readdir(dir); + if (de == NULL) + break; + -+ if (strncmp(de->d_name, -+ FW_DEVICE_PREFIX, strlen(FW_DEVICE_PREFIX)) != 0) ++ if (strncmp(de->d_name, "fw", 2) != 0) + continue; + -+ snprintf(filename, sizeof filename, FW_DEVICE_DIR "/%s", de->d_name); ++ snprintf(filename, sizeof filename, "/dev/%s", de->d_name); + + fd = open(filename, O_RDWR); + if (fd < 0) + continue; ++ + get_info.version = FW_CDEV_VERSION; + get_info.rom = 0; + get_info.rom_length = 0; + get_info.bus_reset = ptr_to_u64(&reset); -+ err = ioctl(fd, FW_CDEV_IOC_GET_INFO, &get_info); -+ close(fd); ++ if (ioctl(fd, FW_CDEV_IOC_GET_INFO, &get_info) < 0) { ++ close(fd); ++ continue; ++ } + -+ if (err < 0) ++ if (get_info.card != handle->ports[port].card) { ++ close(fd); + continue; ++ } + -+ if (i < MAX_PORTS && reset.node_id == reset.local_node_id) { -+ strncpy(ports[i].device_file, filename, -+ sizeof ports[i].device_file); -+ ports[i].node_count = (reset.root_node_id & 0x3f) + 1; -+ ports[i].card = get_info.card; -+ i++; ++ phy_id = reset.node_id & 0x3f; ++ handle->nodes[phy_id] = i; ++ handle->devices[i].node_id = reset.node_id; ++ handle->devices[i].generation = reset.generation; ++ handle->devices[i].fd = fd; ++ strncpy(handle->devices[i].filename, filename, ++ sizeof handle->devices[i].filename); ++ ++ handle->devices[i].closure.func = handle_device_event; ++ ep.events = EPOLLIN; ++ ep.data.ptr = &handle->devices[i].closure; ++ if (epoll_ctl(handle->epoll_fd, EPOLL_CTL_ADD, fd, &ep) < 0) { ++ close(fd); ++ return -1; + } -+ } -+ closedir(dir); + -+ handle->port_count = i; ++ handle->generation = reset.generation; ++ if (reset.node_id == reset.local_node_id) { ++ memcpy(&handle->reset, &reset, sizeof handle->reset); ++ handle->local_fd = fd; ++ strncpy(handle->local_filename, filename, ++ sizeof handle->local_filename); ++ } ++ ++ i++; ++ } + + return 0; +} + -+static int -+handle_echo_pipe(raw1394handle_t handle, -+ struct epoll_closure *ec, __uint32_t events) ++int raw1394_reset_bus(raw1394handle_t handle) +{ -+ quadlet_t value; ++ return raw1394_reset_bus_new(handle, RAW1394_LONG_RESET); ++} + -+ if (read(handle->pipe_fds[0], &value, sizeof value) < 0) -+ return -1; ++int raw1394_reset_bus_new(raw1394handle_t handle, int type) ++{ ++ struct fw_cdev_initiate_bus_reset initiate; + -+ return value; ++ switch (type) { ++ case RAW1394_LONG_RESET: ++ initiate.type = FW_CDEV_LONG_RESET; ++ break; ++ case RAW1394_SHORT_RESET: ++ initiate.type = FW_CDEV_SHORT_RESET; ++ break; ++ } ++ ++ return ioctl(handle->local_fd, ++ FW_CDEV_IOC_INITIATE_BUS_RESET, &initiate); +} + -+static int -+handle_lost_device(raw1394handle_t handle, int i) ++bus_reset_handler_t raw1394_set_bus_reset_handler(raw1394handle_t handle, ++ bus_reset_handler_t new_h) +{ -+ int phy_id; ++ bus_reset_handler_t old_h = handle->bus_reset_handler; + -+ /* The device got unplugged, get rid of it. The fd is -+ * automatically dropped from the epoll context when we close it. */ -+ -+ close(handle->devices[i].fd); -+ phy_id = handle->devices[i].node_id & 0x3f; -+ if (handle->nodes[phy_id] == i) -+ handle->nodes[phy_id] = -1; -+ handle->devices[i].node_id = -1; ++ handle->bus_reset_handler = new_h; + -+ return 0; ++ return old_h; +} + -+struct address_closure { -+ int (*callback)(raw1394handle_t handle, struct address_closure *ac, -+ struct fw_cdev_event_request *request, int i); -+}; -+ -+static int -+handle_fcp_request(raw1394handle_t handle, struct address_closure *ac, -+ struct fw_cdev_event_request *request, int i) ++unsigned int raw1394_get_generation(raw1394handle_t handle) +{ -+ struct fw_cdev_send_response response; -+ int is_response; ++ return handle->generation; ++} + -+ response.handle = request->handle; -+ response.rcode = RCODE_COMPLETE; -+ response.length = 0; -+ response.data = 0; ++void raw1394_update_generation(raw1394handle_t handle, unsigned int generation) ++{ ++ handle->generation = generation; ++} + -+ if (handle->fcp_handler == NULL) -+ response.rcode = RCODE_ADDRESS_ERROR; ++tag_handler_t ++raw1394_set_tag_handler(raw1394handle_t handle, tag_handler_t new_h) ++{ ++ tag_handler_t old_h = handle->tag_handler; + -+ if (request->tcode >= TCODE_WRITE_RESPONSE) -+ response.rcode = RCODE_CONFLICT_ERROR; ++ handle->tag_handler = new_h; + -+ if (ioctl(handle->devices[i].fd, -+ FW_CDEV_IOC_SEND_RESPONSE, &response) < 0) -+ return -1; ++ return old_h; ++} + -+ if (response.rcode != RCODE_COMPLETE) -+ return 0; ++arm_tag_handler_t ++raw1394_set_arm_tag_handler(raw1394handle_t handle, arm_tag_handler_t new_h) ++{ ++ arm_tag_handler_t old_h = handle->arm_tag_handler; + -+ is_response = request->offset >= CSR_REGISTER_BASE + CSR_FCP_RESPONSE; ++ handle->arm_tag_handler = new_h; + -+ return handle->fcp_handler(handle, -+ handle->devices[i].node_id, -+ is_response, -+ request->length, -+ (unsigned char *) request->data); ++ return old_h; +} + -+static int -+handle_device_event(raw1394handle_t handle, -+ struct epoll_closure *ec, __uint32_t events) ++fcp_handler_t ++raw1394_set_fcp_handler(raw1394handle_t handle, fcp_handler_t new_h) +{ -+ union fw_cdev_event *u; -+ struct device *device = (struct device *) ec; -+ struct address_closure *ac; -+ struct request_closure *rc; -+ raw1394_errcode_t errcode; -+ int len, phy_id; -+ int i; ++ fcp_handler_t old_h = handle->fcp_handler; + -+ i = device - handle->devices; -+ if (events == EPOLLHUP) -+ return handle_lost_device(handle, i); ++ handle->fcp_handler = new_h; + -+ len = read(handle->devices[i].fd, -+ handle->buffer, sizeof handle->buffer); -+ if (len < 0) -+ return -1; ++ return old_h; ++} + -+ u = (void *) handle->buffer; -+ switch (u->common.type) { -+ case FW_CDEV_EVENT_BUS_RESET: -+ /* Clear old entry, unless it's been overwritten. */ -+ phy_id = handle->devices[i].node_id & 0x3f; -+ if (handle->nodes[phy_id] == i) -+ handle->nodes[phy_id] = -1; -+ handle->nodes[u->bus_reset.node_id & 0x3f] = i; -+ handle->devices[i].node_id = u->bus_reset.node_id; -+ handle->devices[i].generation = u->bus_reset.generation; ++struct request_response_block { ++ struct raw1394_arm_request_response request_response; ++ struct raw1394_arm_request request; ++ struct raw1394_arm_response response; ++ unsigned char data[0]; ++}; + -+ if (u->bus_reset.node_id != u->bus_reset.local_node_id) -+ return 0; ++struct allocation { ++ struct address_closure closure; ++ struct allocation *next; ++ __u32 handle; ++ byte_t *buffer; ++ octlet_t tag; ++ arm_options_t access_rights; ++ arm_options_t notification_options; ++ arm_options_t client_transactions; ++ nodeaddr_t offset; ++ size_t length; ++ unsigned char data[0]; ++}; + -+ memcpy(&handle->reset, &u->bus_reset, sizeof handle->reset); -+ return handle->bus_reset_handler(handle, -+ u->bus_reset.generation); ++static int ++handle_arm_request(raw1394handle_t handle, struct address_closure *ac, ++ struct fw_cdev_event_request *request, int i) ++{ ++ struct allocation *allocation = (struct allocation *) ac; ++ struct request_response_block *rrb; ++ struct fw_cdev_send_response response; ++ arm_options_t type; ++ size_t in_length; ++ int offset; + -+ case FW_CDEV_EVENT_RESPONSE: -+ rc = u64_to_ptr(u->response.closure); ++ offset = request->offset - allocation->offset; ++ response.handle = request->handle; + -+ if (rc->data != NULL) -+ memcpy(rc->data, u->response.data, rc->length); ++ switch (request->tcode) { ++ case TCODE_WRITE_QUADLET_REQUEST: ++ case TCODE_WRITE_BLOCK_REQUEST: ++ printf("got write request, offset=0x%012llx, length=%d\n", ++ request->offset, request->length); + -+ errcode = juju_to_raw1394_errcode(u->response.rcode); ++ type = RAW1394_ARM_WRITE; ++ in_length = request->length; ++ response.rcode = RCODE_COMPLETE; ++ response.length = 0; ++ response.data = 0; ++ break; + -+ return handle->tag_handler(handle, rc->tag, errcode); ++ case TCODE_READ_QUADLET_REQUEST: ++ case TCODE_READ_BLOCK_REQUEST: ++ printf("got read request, offset=0x%012llx, length=%d\n", ++ request->offset, request->length); + -+ case FW_CDEV_EVENT_REQUEST: -+ ac = u64_to_ptr(u->request.closure); -+ return ac->callback(handle, ac, &u->request, i); ++ type = RAW1394_ARM_READ; ++ in_length = 0; ++ response.rcode = RCODE_COMPLETE; ++ response.length = request->length; ++ response.data = ptr_to_u64(allocation->data + offset); ++ break; ++ ++ case TCODE_LOCK_REQUEST: ++ type = RAW1394_ARM_LOCK; ++ in_length = request->length; ++ response.length = 4; ++ break; + + default: -+ case FW_CDEV_EVENT_ISO_INTERRUPT: -+ /* Never happens. */ -+ return -1; ++ in_length = 0; ++ type = 0; ++ break; + } -+} -+ -+static int -+handle_inotify(raw1394handle_t handle, struct epoll_closure *ec, -+ __uint32_t events) -+{ -+ struct inotify_event *event; -+ char filename[32]; -+ struct fw_cdev_get_info info; -+ struct fw_cdev_event_bus_reset reset; -+ struct epoll_event ep; -+ int i, len, fd, phy_id; + -+ event = (struct inotify_event *) handle->buffer; -+ len = read(handle->inotify_fd, event, BUFFER_SIZE); -+ if (!(event->mask & IN_CREATE)) -+ return -1; -+ if (strncmp(event->name, -+ FW_DEVICE_PREFIX, strlen(FW_DEVICE_PREFIX)) != 0) -+ return 0; -+ snprintf(filename, sizeof filename, FW_DEVICE_DIR "/%s", event->name); -+ fd = open(filename, O_RDWR); -+ if (fd < 0) { -+ switch (errno) { -+ case ENOENT: -+ /* Huh, it disappeared before we could -+ * open it. */ -+ return 0; -+ case EACCES: -+ /* We don't have permission to talk to -+ * this device, maybe it's a storage -+ * device. */ -+ return 0; -+ default: -+ /* Anything else is bad news. */ ++ if (!(allocation->access_rights & type)) { ++ response.rcode = RCODE_TYPE_ERROR; ++ response.length = 0; ++ response.data = 0; ++ if (ioctl(handle->devices[i].fd, ++ FW_CDEV_IOC_SEND_RESPONSE, &response) < 0) + return -1; -+ } -+ } ++ } else if (!(allocation->client_transactions & type)) { ++ if (type == RAW1394_ARM_WRITE) ++ memcpy(allocation->data + offset, ++ request->data, request->length); ++ else if (type == RAW1394_ARM_LOCK) ++ /* FIXME: do lock ops here */; + -+ info.version = FW_CDEV_VERSION; -+ info.rom = 0; -+ info.rom_length = 0; -+ info.bus_reset = ptr_to_u64(&reset); -+ if (ioctl(fd, FW_CDEV_IOC_GET_INFO, &info) < 0) { -+ close(fd); -+ return -1; ++ if (ioctl(handle->devices[i].fd, ++ FW_CDEV_IOC_SEND_RESPONSE, &response) < 0) ++ return -1; + } + -+ for (i = 0; i < MAX_DEVICES; i++) -+ if (handle->devices[i].node_id == -1) -+ break; -+ if (i == MAX_DEVICES) { -+ close(fd); -+ return -1; -+ } ++ if (!(allocation->notification_options & type)) ++ return 0; + -+ phy_id = reset.node_id & 0x3f; -+ handle->nodes[phy_id] = i; -+ handle->devices[i].node_id = reset.node_id; -+ handle->devices[i].generation = reset.generation; -+ handle->devices[i].fd = fd; -+ strncpy(handle->devices[i].filename, filename, -+ sizeof handle->devices[i].filename); -+ handle->devices[i].closure.func = handle_device_event; -+ ep.events = EPOLLIN; -+ ep.data.ptr = &handle->devices[i].closure; -+ if (epoll_ctl(handle->epoll_fd, EPOLL_CTL_ADD, fd, &ep) < 0) { -+ close(fd); -+ return -1; -+ } ++ rrb = malloc(sizeof *rrb + in_length + response.length); + -+ return 0; -+} ++ rrb->request_response.request = &rrb->request; ++ rrb->request_response.response = &rrb->response; + -+int raw1394_loop_iterate(raw1394handle_t handle) -+{ -+ int i, count, retval = 0; -+ struct epoll_closure *closure; -+ struct epoll_event ep[32]; -+ -+ count = epoll_wait(handle->epoll_fd, ep, ARRAY_LENGTH(ep), -1); -+ if (count < 0) -+ return -1; -+ -+ for (i = 0; i < count; i++) { -+ closure = ep[i].data.ptr; -+ retval = closure->func(handle, closure, ep[i].events); ++ rrb->request.destination_nodeid = handle->reset.local_node_id; ++ rrb->request.source_nodeid = handle->devices[i].node_id; ++ rrb->request.destination_offset = request->offset; ++ rrb->request.tlabel = 0; ++ if (request->tcode < 0x10) { ++ rrb->request.tcode = request->tcode; ++ rrb->request.extended_transaction_code = 0; ++ } else { ++ rrb->request.tcode = TCODE_LOCK_REQUEST; ++ rrb->request.extended_transaction_code = request->tcode - 0x10; + } ++ rrb->request.generation = handle->reset.generation; ++ rrb->request.buffer_length = in_length; ++ memcpy(rrb->request.buffer, request->data, in_length); + -+ /* It looks like we have to add this work-around to get epoll -+ * to recompute the POLLIN status of the epoll_fd. */ -+ epoll_wait(handle->epoll_fd, ep, ARRAY_LENGTH(ep), 0); ++ rrb->response.response_code = response.rcode; ++ rrb->response.buffer_length = response.length; ++ memcpy(rrb->response.buffer, ++ allocation->data + offset, response.length); + -+ return retval; ++ return handle->arm_tag_handler(handle, allocation->tag, type, ++ request->length, ++ &rrb->request_response); +} + -+raw1394handle_t raw1394_new_handle(void) ++int ++raw1394_arm_register(raw1394handle_t handle, nodeaddr_t start, ++ size_t length, byte_t *initial_value, ++ octlet_t arm_tag, arm_options_t access_rights, ++ arm_options_t notification_options, ++ arm_options_t client_transactions) +{ -+ raw1394handle_t handle; -+ struct epoll_event ep; -+ int i; -+ -+ handle = malloc(sizeof *handle); -+ -+ handle->tag_handler = default_tag_handler; -+ handle->arm_tag_handler = default_arm_tag_handler; -+ handle->allocations = NULL; -+ -+ handle->notify_bus_reset = RAW1394_NOTIFY_ON; -+ handle->bus_reset_handler = default_bus_reset_handler; ++ struct fw_cdev_allocate request; ++ struct allocation *allocation; ++ int retval; + -+ handle->iso.fd = -1; ++ allocation = malloc(sizeof *allocation + length); ++ if (allocation == NULL) ++ return -1; + -+ handle->epoll_fd = epoll_create(16); -+ if (handle->epoll_fd < 0) -+ goto out_handle; ++ allocation->closure.callback = handle_arm_request; ++ allocation->buffer = initial_value; ++ allocation->tag = arm_tag; ++ allocation->access_rights = access_rights; ++ allocation->notification_options = notification_options; ++ allocation->client_transactions = client_transactions; ++ allocation->offset = start; ++ allocation->length = length; ++ if (initial_value != NULL) ++ memcpy(allocation->data, initial_value, length); + -+ if (pipe(handle->pipe_fds) < 0) -+ goto out_epoll; ++ request.offset = start; ++ request.length = length; ++ request.closure = ptr_to_u64(&allocation->closure); + -+ handle->inotify_fd = inotify_init(); -+ if (handle->inotify_fd < 0) -+ goto out_pipe; ++ retval = ioctl(handle->local_fd, FW_CDEV_IOC_ALLOCATE, &request); ++ if (retval < 0) { ++ free(allocation); ++ return -1; ++ } + -+ handle->inotify_watch = -+ inotify_add_watch(handle->inotify_fd, FW_DEVICE_DIR, IN_CREATE); -+ if (handle->inotify_watch < 0) -+ goto out_inotify; ++ allocation->handle = request.handle; ++ allocation->next = handle->allocations; ++ handle->allocations = allocation; + -+ handle->pipe_closure.func = handle_echo_pipe; -+ ep.events = EPOLLIN; -+ ep.data.ptr = &handle->pipe_closure; -+ if (epoll_ctl(handle->epoll_fd, EPOLL_CTL_ADD, -+ handle->pipe_fds[0], &ep) < 0) -+ goto out_inotify; ++ return 0; ++} + -+ handle->inotify_closure.func = handle_inotify; -+ ep.events = EPOLLIN; -+ ep.data.ptr = &handle->inotify_closure; -+ if (epoll_ctl(handle->epoll_fd, EPOLL_CTL_ADD, -+ handle->inotify_fd, &ep) < 0) -+ goto out_inotify; ++static struct allocation * ++lookup_allocation(raw1394handle_t handle, nodeaddr_t start, int delete) ++{ ++ struct allocation *a, **prev; + -+ for (i = 0; i < MAX_DEVICES; i++) { -+ handle->nodes[i] = -1; -+ handle->devices[i].node_id = -1; ++ prev = &handle->allocations; ++ for (a = handle->allocations; a != NULL; a = a->next) { ++ if (a->offset <= start && start < a->offset + a->length) ++ break; ++ prev = &a->next; + } + -+ scan_devices(handle); -+ -+ return handle; ++ if (a != NULL && delete) ++ *prev = a->next; + -+ out_inotify: -+ close(handle->inotify_fd); -+ out_pipe: -+ close(handle->pipe_fds[0]); -+ close(handle->pipe_fds[1]); -+ out_epoll: -+ close(handle->epoll_fd); -+ out_handle: -+ free(handle); -+ return NULL; ++ return a; +} + -+void raw1394_destroy_handle(raw1394handle_t handle) ++int ++raw1394_arm_unregister(raw1394handle_t handle, nodeaddr_t start) +{ -+ int i; -+ -+ close(handle->inotify_fd); -+ close(handle->pipe_fds[0]); -+ close(handle->pipe_fds[1]); -+ -+ for (i = 0; i < MAX_DEVICES; i++) { -+ if (handle->devices[i].node_id == -1) -+ continue; ++ struct fw_cdev_deallocate request; ++ struct allocation *allocation; + -+ close(handle->devices[i].fd); ++ allocation = lookup_allocation(handle, start, 1); ++ if (allocation == NULL) { ++ errno = EINVAL; ++ return -1; + } + -+ close(handle->epoll_fd); -+ -+ free(handle); ++ request.handle = allocation->handle; ++ free(allocation); + -+ return; ++ return ioctl(handle->local_fd, FW_CDEV_IOC_DEALLOCATE, &request); +} + -+raw1394handle_t raw1394_new_handle_on_port(int port) ++int ++raw1394_arm_set_buf(raw1394handle_t handle, nodeaddr_t start, ++ size_t length, void *buf) +{ -+ raw1394handle_t handle; ++ struct allocation *allocation; + -+ handle = raw1394_new_handle(); -+ if (handle == NULL) -+ return NULL; ++ allocation = lookup_allocation(handle, start, 0); ++ if (allocation == NULL) { ++ errno = ENOENT; ++ return -1; ++ } + -+ if (raw1394_set_port(handle, port) < 0) -+ return NULL; ++ memcpy(allocation->data + allocation->offset - start, buf, length); + -+ return handle; ++ return 0; +} + -+int raw1394_busreset_notify (raw1394handle_t handle, int off_on_switch) ++int ++raw1394_arm_get_buf(raw1394handle_t handle, nodeaddr_t start, ++ size_t length, void *buf) +{ -+ handle->notify_bus_reset = off_on_switch; ++ struct allocation *allocation; + -+ return 0; -+} ++ allocation = lookup_allocation(handle, start, 0); ++ if (allocation == NULL) { ++ errno = ENOENT; ++ return -1; ++ } + -+int raw1394_get_fd(raw1394handle_t handle) -+{ -+ return handle->epoll_fd; -+} ++ memcpy(buf, allocation->data + allocation->offset - start, length); + -+void raw1394_set_userdata(raw1394handle_t handle, void *data) -+{ -+ handle->user_data = data; ++ return 0; +} + -+void *raw1394_get_userdata(raw1394handle_t handle) ++int ++raw1394_echo_request(raw1394handle_t handle, quadlet_t data) +{ -+ return handle->user_data; ++ return write(handle->pipe_fds[1], &data, sizeof data); +} + -+nodeid_t raw1394_get_local_id(raw1394handle_t handle) ++int raw1394_wake_up(raw1394handle_t handle) +{ -+ return handle->reset.local_node_id; ++ return raw1394_echo_request(handle, 0); +} + -+nodeid_t raw1394_get_irm_id(raw1394handle_t handle) ++int raw1394_phy_packet_write (raw1394handle_t handle, quadlet_t data) +{ -+ return handle->reset.irm_node_id; ++ errno = ENOSYS; ++ return -1; +} + -+int raw1394_get_nodecount(raw1394handle_t handle) ++int ++raw1394_start_phy_packet_write(raw1394handle_t handle, ++ quadlet_t data, unsigned long tag) +{ -+ return (handle->reset.root_node_id & 0x3f) + 1; ++ errno = ENOSYS; ++ return -1; +} + -+int raw1394_get_port_info(raw1394handle_t handle, -+ struct raw1394_portinfo *pinf, -+ int maxports) ++static int ++send_request(raw1394handle_t handle, int tcode, ++ nodeid_t node, nodeaddr_t addr, ++ size_t length, void *in, void *out, unsigned long tag) +{ ++ struct fw_cdev_send_request *request; ++ struct request_closure *closure; + int i; + -+ if (maxports >= handle->port_count) -+ maxports = handle->port_count; -+ -+ for (i = 0; i < maxports; i++) { -+ pinf[i].nodes = handle->ports[i].node_count; -+ strncpy(pinf[i].name, handle->ports[i].device_file, -+ sizeof pinf[i].name); ++ if (node > handle->reset.root_node_id) { ++ handle->err = -RCODE_NO_ACK; ++ errno = raw1394_errcode_to_errno(handle->err); ++ return -1; + } + -+ return handle->port_count; -+} ++ i = handle->nodes[node & 0x3f]; ++ if (i == -1) { ++ handle->err = -RCODE_NO_ACK; ++ errno = raw1394_errcode_to_errno(handle->err); ++ return -1; ++ } + -+int raw1394_set_port(raw1394handle_t handle, int port) -+{ -+ struct fw_cdev_get_info get_info; -+ struct fw_cdev_event_bus_reset reset; -+ struct epoll_event ep; -+ struct dirent *de; -+ char filename[32]; -+ DIR *dir; -+ int i, fd, phy_id; -+ -+ if (port >= handle->port_count) { -+ errno = EINVAL; ++ if (handle->generation != handle->devices[i].generation) { ++ handle->err = -RCODE_GENERATION; ++ errno = raw1394_errcode_to_errno(handle->err); + return -1; + } + -+ dir = opendir("/dev"); -+ if (dir == NULL) ++ closure = malloc(sizeof *closure); ++ if (closure == NULL) { ++ handle->err = -RCODE_SEND_ERROR; ++ errno = raw1394_errcode_to_errno(handle->err); + return -1; ++ } + -+ for (i = 0; i < MAX_DEVICES; ) { -+ de = readdir(dir); -+ if (de == NULL) -+ break; ++ closure->data = out; ++ closure->length = length; ++ closure->tag = tag; + -+ if (strncmp(de->d_name, "fw", 2) != 0) -+ continue; ++ request = (struct fw_cdev_send_request *) handle->buffer; ++ request->tcode = tcode; ++ request->generation = handle->generation; ++ request->offset = addr; ++ request->length = length; ++ request->closure = ptr_to_u64(closure); ++ request->data = ptr_to_u64(in); + -+ snprintf(filename, sizeof filename, "/dev/%s", de->d_name); ++ return ioctl(handle->devices[i].fd, FW_CDEV_IOC_SEND_REQUEST, request); ++} + -+ fd = open(filename, O_RDWR); -+ if (fd < 0) -+ continue; ++int ++raw1394_start_read(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, ++ size_t length, quadlet_t *buffer, unsigned long tag) ++{ ++ int tcode; + -+ get_info.version = FW_CDEV_VERSION; -+ get_info.rom = 0; -+ get_info.rom_length = 0; -+ get_info.bus_reset = ptr_to_u64(&reset); -+ if (ioctl(fd, FW_CDEV_IOC_GET_INFO, &get_info) < 0) { -+ close(fd); -+ continue; -+ } ++ if (length == 4) ++ tcode = TCODE_READ_QUADLET_REQUEST; ++ else ++ tcode = TCODE_READ_BLOCK_REQUEST; + -+ if (get_info.card != handle->ports[port].card) { -+ close(fd); -+ continue; -+ } ++ return send_request(handle, tcode, ++ node, addr, length, NULL, buffer, tag); ++} + -+ phy_id = reset.node_id & 0x3f; -+ handle->nodes[phy_id] = i; -+ handle->devices[i].node_id = reset.node_id; -+ handle->devices[i].generation = reset.generation; -+ handle->devices[i].fd = fd; -+ strncpy(handle->devices[i].filename, filename, -+ sizeof handle->devices[i].filename); ++int ++raw1394_start_write(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, ++ size_t length, quadlet_t *data, unsigned long tag) ++{ ++ int tcode; + -+ handle->devices[i].closure.func = handle_device_event; -+ ep.events = EPOLLIN; -+ ep.data.ptr = &handle->devices[i].closure; -+ if (epoll_ctl(handle->epoll_fd, EPOLL_CTL_ADD, fd, &ep) < 0) { -+ close(fd); -+ return -1; -+ } ++ if (length == 4) ++ tcode = TCODE_WRITE_QUADLET_REQUEST; ++ else ++ tcode = TCODE_WRITE_BLOCK_REQUEST; + -+ handle->generation = reset.generation; -+ if (reset.node_id == reset.local_node_id) { -+ memcpy(&handle->reset, &reset, sizeof handle->reset); -+ handle->local_fd = fd; -+ strncpy(handle->local_filename, filename, -+ sizeof handle->local_filename); -+ } ++ return send_request(handle, tcode, ++ node, addr, length, data, NULL, tag); ++} + -+ i++; -+ } ++static int ++setup_lock(int extcode, quadlet_t data, quadlet_t arg, quadlet_t *buffer) ++{ ++ switch (extcode) { ++ case RAW1394_EXTCODE_FETCH_ADD: ++ case RAW1394_EXTCODE_LITTLE_ADD: ++ buffer[0] = data; ++ return sizeof buffer[0]; + -+ return 0; ++ case RAW1394_EXTCODE_MASK_SWAP: ++ case RAW1394_EXTCODE_COMPARE_SWAP: ++ case RAW1394_EXTCODE_BOUNDED_ADD: ++ case RAW1394_EXTCODE_WRAP_ADD: ++ buffer[0] = arg; ++ buffer[1] = data; ++ return 2 * sizeof buffer[0]; ++ ++ default: ++ errno = EINVAL; ++ return -1; ++ } +} + -+int raw1394_reset_bus(raw1394handle_t handle) ++static int ++setup_lock64(int extcode, octlet_t data, octlet_t arg, octlet_t *buffer) +{ -+ return raw1394_reset_bus_new(handle, RAW1394_LONG_RESET); ++ switch (extcode) { ++ case RAW1394_EXTCODE_FETCH_ADD: ++ case RAW1394_EXTCODE_LITTLE_ADD: ++ buffer[0] = data; ++ return sizeof buffer[0]; ++ ++ case RAW1394_EXTCODE_MASK_SWAP: ++ case RAW1394_EXTCODE_COMPARE_SWAP: ++ case RAW1394_EXTCODE_BOUNDED_ADD: ++ case RAW1394_EXTCODE_WRAP_ADD: ++ buffer[0] = arg; ++ buffer[1] = data; ++ return 2 * sizeof buffer[0]; ++ ++ default: ++ errno = EINVAL; ++ return -1; ++ } +} + -+int raw1394_reset_bus_new(raw1394handle_t handle, int type) ++int ++raw1394_start_lock(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, ++ unsigned int extcode, quadlet_t data, quadlet_t arg, ++ quadlet_t *result, unsigned long tag) +{ -+ struct fw_cdev_initiate_bus_reset initiate; ++ quadlet_t buffer[2]; ++ int length; + -+ switch (type) { -+ case RAW1394_LONG_RESET: -+ initiate.type = FW_CDEV_LONG_RESET; -+ break; -+ case RAW1394_SHORT_RESET: -+ initiate.type = FW_CDEV_SHORT_RESET; -+ break; -+ } ++ length = setup_lock(extcode, data, arg, buffer); ++ if (length < 0) ++ return length; + -+ return ioctl(handle->local_fd, -+ FW_CDEV_IOC_INITIATE_BUS_RESET, &initiate); ++ return send_request(handle, 16 + extcode, ++ node, addr, length, buffer, result, tag); +} + -+bus_reset_handler_t raw1394_set_bus_reset_handler(raw1394handle_t handle, -+ bus_reset_handler_t new_h) ++int ++raw1394_start_lock64(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, ++ unsigned int extcode, octlet_t data, octlet_t arg, ++ octlet_t *result, unsigned long tag) +{ -+ bus_reset_handler_t old_h = handle->bus_reset_handler; ++ octlet_t buffer[2]; ++ int length; + -+ handle->bus_reset_handler = new_h; ++ length = setup_lock64(extcode, data, arg, buffer); ++ if (length < 0) ++ return length; + -+ return old_h; ++ return send_request(handle, 16 + extcode, ++ node, addr, length, buffer, result, tag); +} + -+unsigned int raw1394_get_generation(raw1394handle_t handle) ++int ++raw1394_start_async_stream(raw1394handle_t handle, unsigned int channel, ++ unsigned int tag, unsigned int sy, ++ unsigned int speed, size_t length, quadlet_t *data, ++ unsigned long rawtag) +{ -+ return handle->generation; ++ /* FIXME: implement this? */ ++ return -1; +} + -+void raw1394_update_generation(raw1394handle_t handle, unsigned int generation) ++ ++int ++raw1394_start_async_send(raw1394handle_t handle, ++ size_t length, size_t header_length, ++ unsigned int expect_response, ++ quadlet_t *data, unsigned long rawtag) +{ -+ handle->generation = generation; ++ /* FIXME: implement this? */ ++ return -1; +} + -+tag_handler_t -+raw1394_set_tag_handler(raw1394handle_t handle, tag_handler_t new_h) ++struct sync_data { ++ raw1394_errcode_t err; ++ int done; ++}; ++ ++static int ++sync_callback(raw1394handle_t handle, void *data, raw1394_errcode_t err) +{ -+ tag_handler_t old_h = handle->tag_handler; ++ struct sync_data *sd = data; + -+ handle->tag_handler = new_h; ++ sd->err = err; ++ sd->done = 1; + -+ return old_h; ++ return 0; +} + -+arm_tag_handler_t -+raw1394_set_arm_tag_handler(raw1394handle_t handle, arm_tag_handler_t new_h) ++static int ++send_request_sync(raw1394handle_t handle, int tcode, ++ nodeid_t node, nodeaddr_t addr, ++ size_t length, void *in, void *out) +{ -+ arm_tag_handler_t old_h = handle->arm_tag_handler; ++ struct raw1394_reqhandle reqhandle; ++ struct sync_data sd = { 0, 0 }; ++ int err; + -+ handle->arm_tag_handler = new_h; ++ reqhandle.callback = sync_callback; ++ reqhandle.data = &sd; + -+ return old_h; -+} ++ err = send_request(handle, tcode, node, addr, ++ length, in, out, (unsigned long) &reqhandle); + -+fcp_handler_t -+raw1394_set_fcp_handler(raw1394handle_t handle, fcp_handler_t new_h) -+{ -+ fcp_handler_t old_h = handle->fcp_handler; ++ while (!sd.done) { ++ if (err < 0) ++ return err; ++ err = raw1394_loop_iterate(handle); ++ } + -+ handle->fcp_handler = new_h; ++ handle->err = sd.err; ++ errno = raw1394_errcode_to_errno(sd.err); + -+ return old_h; ++ return (errno ? -1 : 0); +} + -+struct request_response_block { -+ struct raw1394_arm_request_response request_response; -+ struct raw1394_arm_request request; -+ struct raw1394_arm_response response; -+ unsigned char data[0]; -+}; -+ -+struct allocation { -+ struct address_closure closure; -+ struct allocation *next; -+ __u32 handle; -+ byte_t *buffer; -+ octlet_t tag; -+ arm_options_t access_rights; -+ arm_options_t notification_options; -+ arm_options_t client_transactions; -+ nodeaddr_t offset; -+ size_t length; -+ unsigned char data[0]; -+}; -+ -+static int -+handle_arm_request(raw1394handle_t handle, struct address_closure *ac, -+ struct fw_cdev_event_request *request, int i) ++int ++raw1394_read(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, ++ size_t length, quadlet_t *buffer) +{ -+ struct allocation *allocation = (struct allocation *) ac; -+ struct request_response_block *rrb; -+ struct fw_cdev_send_response response; -+ arm_options_t type; -+ size_t in_length; -+ int offset; -+ -+ offset = request->offset - allocation->offset; -+ response.handle = request->handle; -+ -+ switch (request->tcode) { -+ case TCODE_WRITE_QUADLET_REQUEST: -+ case TCODE_WRITE_BLOCK_REQUEST: -+ printf("got write request, offset=0x%012llx, length=%d\n", -+ request->offset, request->length); ++ int tcode; + -+ type = RAW1394_ARM_WRITE; -+ in_length = request->length; -+ response.rcode = RCODE_COMPLETE; -+ response.length = 0; -+ response.data = 0; -+ break; ++ if (length == 4) ++ tcode = TCODE_READ_QUADLET_REQUEST; ++ else ++ tcode = TCODE_READ_BLOCK_REQUEST; + -+ case TCODE_READ_QUADLET_REQUEST: -+ case TCODE_READ_BLOCK_REQUEST: -+ printf("got read request, offset=0x%012llx, length=%d\n", -+ request->offset, request->length); ++ return send_request_sync(handle, tcode, ++ node, addr, length, NULL, buffer); ++} + -+ type = RAW1394_ARM_READ; -+ in_length = 0; -+ response.rcode = RCODE_COMPLETE; -+ response.length = request->length; -+ response.data = ptr_to_u64(allocation->data + offset); -+ break; ++int ++raw1394_write(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, ++ size_t length, quadlet_t *data) ++{ ++ int tcode; + -+ case TCODE_LOCK_REQUEST: -+ type = RAW1394_ARM_LOCK; -+ in_length = request->length; -+ response.length = 4; -+ break; ++ if (length == 4) ++ tcode = TCODE_WRITE_QUADLET_REQUEST; ++ else ++ tcode = TCODE_WRITE_BLOCK_REQUEST; + -+ default: -+ in_length = 0; -+ type = 0; -+ break; -+ } ++ return send_request_sync(handle, tcode, ++ node, addr, length, data, NULL); ++} + -+ if (!(allocation->access_rights & type)) { -+ response.rcode = RCODE_TYPE_ERROR; -+ response.length = 0; -+ response.data = 0; -+ if (ioctl(handle->devices[i].fd, -+ FW_CDEV_IOC_SEND_RESPONSE, &response) < 0) -+ return -1; -+ } else if (!(allocation->client_transactions & type)) { -+ if (type == RAW1394_ARM_WRITE) -+ memcpy(allocation->data + offset, -+ request->data, request->length); -+ else if (type == RAW1394_ARM_LOCK) -+ /* FIXME: do lock ops here */; ++int ++raw1394_lock(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, ++ unsigned int extcode, quadlet_t data, quadlet_t arg, ++ quadlet_t *result) ++{ ++ quadlet_t buffer[2]; ++ size_t length; + -+ if (ioctl(handle->devices[i].fd, -+ FW_CDEV_IOC_SEND_RESPONSE, &response) < 0) -+ return -1; -+ } ++ length = setup_lock(extcode, data, arg, buffer); ++ if (length < 0) ++ return length; + -+ if (!(allocation->notification_options & type)) -+ return 0; ++ return send_request_sync(handle, 16 + extcode, node, addr, ++ length, buffer, result); ++} + -+ rrb = malloc(sizeof *rrb + in_length + response.length); ++int ++raw1394_lock64(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, ++ unsigned int extcode, octlet_t data, octlet_t arg, ++ octlet_t *result) ++{ ++ octlet_t buffer[2]; ++ size_t length; + -+ rrb->request_response.request = &rrb->request; -+ rrb->request_response.response = &rrb->response; ++ length = setup_lock64(extcode, data, arg, buffer); ++ if (length < 0) ++ return length; + -+ rrb->request.destination_nodeid = handle->reset.local_node_id; -+ rrb->request.source_nodeid = handle->devices[i].node_id; -+ rrb->request.destination_offset = request->offset; -+ rrb->request.tlabel = 0; -+ if (request->tcode < 0x10) { -+ rrb->request.tcode = request->tcode; -+ rrb->request.extended_transaction_code = 0; -+ } else { -+ rrb->request.tcode = TCODE_LOCK_REQUEST; -+ rrb->request.extended_transaction_code = request->tcode - 0x10; -+ } -+ rrb->request.generation = handle->reset.generation; -+ rrb->request.buffer_length = in_length; -+ memcpy(rrb->request.buffer, request->data, in_length); ++ return send_request_sync(handle, 16 + extcode, node, addr, ++ length, buffer, result); ++} + -+ rrb->response.response_code = response.rcode; -+ rrb->response.buffer_length = response.length; -+ memcpy(rrb->response.buffer, -+ allocation->data + offset, response.length); ++int ++raw1394_async_stream(raw1394handle_t handle, unsigned int channel, ++ unsigned int tag, unsigned int sy, unsigned int speed, ++ size_t length, quadlet_t *data) ++{ ++ /* FIXME: implement this? */ ++ return -1; ++} + -+ return handle->arm_tag_handler(handle, allocation->tag, type, -+ request->length, -+ &rrb->request_response); ++int ++raw1394_async_send(raw1394handle_t handle, ++ size_t length, size_t header_length, ++ unsigned int expect_response, ++ quadlet_t *data) ++{ ++ /* FIXME: implement this? */ ++ return -1; +} + +int -+raw1394_arm_register(raw1394handle_t handle, nodeaddr_t start, -+ size_t length, byte_t *initial_value, -+ octlet_t arm_tag, arm_options_t access_rights, -+ arm_options_t notification_options, -+ arm_options_t client_transactions) ++raw1394_start_fcp_listen(raw1394handle_t handle) +{ + struct fw_cdev_allocate request; -+ struct allocation *allocation; -+ int retval; ++ struct address_closure *closure; + -+ allocation = malloc(sizeof *allocation + length); -+ if (allocation == NULL) ++ closure = malloc(sizeof *closure); ++ if (closure == NULL) + return -1; + -+ allocation->closure.callback = handle_arm_request; -+ allocation->buffer = initial_value; -+ allocation->tag = arm_tag; -+ allocation->access_rights = access_rights; -+ allocation->notification_options = notification_options; -+ allocation->client_transactions = client_transactions; -+ allocation->offset = start; -+ allocation->length = length; -+ if (initial_value != NULL) -+ memcpy(allocation->data, initial_value, length); -+ -+ request.offset = start; -+ request.length = length; -+ request.closure = ptr_to_u64(&allocation->closure); ++ closure->callback = handle_fcp_request; + -+ retval = ioctl(handle->local_fd, FW_CDEV_IOC_ALLOCATE, &request); -+ if (retval < 0) { -+ free(allocation); ++ request.offset = CSR_REGISTER_BASE + CSR_FCP_COMMAND; ++ request.length = CSR_FCP_END - CSR_FCP_COMMAND; ++ request.closure = ptr_to_u64(closure); ++ if (ioctl(handle->local_fd, FW_CDEV_IOC_ALLOCATE, &request) < 0) + return -1; -+ } + -+ allocation->handle = request.handle; -+ allocation->next = handle->allocations; -+ handle->allocations = allocation; ++ handle->fcp_allocation_handle = request.handle; + + return 0; +} + -+static struct allocation * -+lookup_allocation(raw1394handle_t handle, nodeaddr_t start, int delete) -+{ -+ struct allocation *a, **prev; -+ -+ prev = &handle->allocations; -+ for (a = handle->allocations; a != NULL; a = a->next) { -+ if (a->offset <= start && start < a->offset + a->length) -+ break; -+ prev = &a->next; -+ } -+ -+ if (a != NULL && delete) -+ *prev = a->next; -+ -+ return a; -+} -+ +int -+raw1394_arm_unregister(raw1394handle_t handle, nodeaddr_t start) ++raw1394_stop_fcp_listen(raw1394handle_t handle) +{ + struct fw_cdev_deallocate request; -+ struct allocation *allocation; -+ -+ allocation = lookup_allocation(handle, start, 1); -+ if (allocation == NULL) { -+ errno = EINVAL; -+ return -1; -+ } + -+ request.handle = allocation->handle; -+ free(allocation); ++ request.handle = handle->fcp_allocation_handle; + + return ioctl(handle->local_fd, FW_CDEV_IOC_DEALLOCATE, &request); +} + -+int -+raw1394_arm_set_buf(raw1394handle_t handle, nodeaddr_t start, -+ size_t length, void *buf) ++const char * ++raw1394_get_libversion(void) +{ -+ struct allocation *allocation; -+ -+ allocation = lookup_allocation(handle, start, 0); -+ if (allocation == NULL) { -+ errno = ENOENT; -+ return -1; -+ } -+ -+ memcpy(allocation->data + allocation->offset - start, buf, length); -+ -+ return 0; ++ return VERSION " (Juju)"; +} + +int -+raw1394_arm_get_buf(raw1394handle_t handle, nodeaddr_t start, -+ size_t length, void *buf) ++raw1394_update_config_rom(raw1394handle_t handle, const quadlet_t *new_rom, ++ size_t size, unsigned char rom_version) +{ -+ struct allocation *allocation; -+ -+ allocation = lookup_allocation(handle, start, 0); -+ if (allocation == NULL) { -+ errno = ENOENT; -+ return -1; -+ } -+ -+ memcpy(buf, allocation->data + allocation->offset - start, length); -+ -+ return 0; ++ return -1; +} + +int -+raw1394_echo_request(raw1394handle_t handle, quadlet_t data) ++raw1394_get_config_rom(raw1394handle_t handle, quadlet_t *buffer, ++ size_t buffersize, size_t *rom_size, ++ unsigned char *rom_version) +{ -+ return write(handle->pipe_fds[1], &data, sizeof data); -+} ++ struct fw_cdev_get_info get_info; ++ int err; + -+int raw1394_wake_up(raw1394handle_t handle) -+{ -+ return raw1394_echo_request(handle, 0); -+} ++ get_info.version = FW_CDEV_VERSION; ++ get_info.rom = ptr_to_u64(buffer); ++ get_info.rom_length = buffersize; ++ get_info.bus_reset = 0; + -+int raw1394_phy_packet_write (raw1394handle_t handle, quadlet_t data) -+{ -+ errno = ENOSYS; -+ return -1; ++ err = ioctl(handle->local_fd, FW_CDEV_IOC_GET_INFO, &get_info); ++ if (err) ++ return err; ++ ++ *rom_size = get_info.rom_length; ++ *rom_version = 0; ++ ++ return 0; +} + ++#define MAXIMUM_BANDWIDTH 4915 ++ +int -+raw1394_start_phy_packet_write(raw1394handle_t handle, -+ quadlet_t data, unsigned long tag) ++raw1394_bandwidth_modify (raw1394handle_t handle, ++ unsigned int bandwidth, ++ enum raw1394_modify_mode mode) +{ -+ errno = ENOSYS; -+ return -1; -+} ++ quadlet_t buffer, compare, swap; ++ nodeaddr_t addr; ++ int result; + -+static int -+send_request(raw1394handle_t handle, int tcode, -+ nodeid_t node, nodeaddr_t addr, -+ size_t length, void *in, void *out, unsigned long tag) -+{ -+ struct fw_cdev_send_request *request; -+ struct request_closure *closure; -+ int i; ++ if (bandwidth == 0) ++ return 0; ++ ++ addr = CSR_REGISTER_BASE + CSR_BANDWIDTH_AVAILABLE; ++ /* Read current bandwidth usage from IRM. */ ++ result = raw1394_read (handle, raw1394_get_irm_id (handle), addr, ++ sizeof buffer, &buffer); ++ if (result < 0) ++ return -1; + -+ if (node > handle->reset.root_node_id) { -+ handle->err = -RCODE_NO_ACK; -+ errno = raw1394_errcode_to_errno(handle->err); -+ return -1; -+ } ++ compare = ntohl (buffer); ++ switch (mode) { ++ case RAW1394_MODIFY_ALLOC: ++ swap = compare - bandwidth; ++ if (swap < 0) ++ return -1; ++ break; + -+ i = handle->nodes[node & 0x3f]; -+ if (i == -1) { -+ handle->err = -RCODE_NO_ACK; -+ errno = raw1394_errcode_to_errno(handle->err); ++ case RAW1394_MODIFY_FREE: ++ swap = compare + bandwidth; ++ if (swap > MAXIMUM_BANDWIDTH) ++ swap = MAXIMUM_BANDWIDTH; ++ break; ++ ++ default: + return -1; + } + -+ if (handle->generation != handle->devices[i].generation) { -+ handle->err = -RCODE_GENERATION; -+ errno = raw1394_errcode_to_errno(handle->err); ++ result = raw1394_lock(handle, raw1394_get_irm_id (handle), addr, ++ RAW1394_EXTCODE_COMPARE_SWAP, ++ htonl(swap), htonl(compare), &buffer); ++ if (result < 0 || ntohl(buffer) != compare) + return -1; -+ } ++ ++ return 0; ++} + -+ closure = malloc(sizeof *closure); -+ if (closure == NULL) { -+ handle->err = -RCODE_SEND_ERROR; -+ errno = raw1394_errcode_to_errno(handle->err); ++int ++raw1394_channel_modify (raw1394handle_t handle, ++ unsigned int channel, ++ enum raw1394_modify_mode mode) ++{ ++ quadlet_t buffer, compare, swap, bit; ++ nodeaddr_t addr; ++ int result; ++ ++ if (channel >= 64) + return -1; -+ } ++ addr = CSR_REGISTER_BASE + ++ CSR_CHANNELS_AVAILABLE_HI + 4 * (channel / 32); ++ /* Read currently available channels from IRM. */ ++ result = raw1394_read(handle, raw1394_get_irm_id (handle), addr, ++ sizeof buffer, &buffer); ++ if (result < 0) ++ return -1; ++ ++ /* IEEE numbers bits from MSB (0) to LSB (31). */ ++ bit = 1 << (31 - (channel & 31)); ++ compare = ntohl(buffer); ++ switch (mode) { ++ case RAW1394_MODIFY_ALLOC: ++ if ((compare & bit) == 0) ++ return -1; ++ swap = buffer & ~bit; ++ break; + -+ closure->data = out; -+ closure->length = length; -+ closure->tag = tag; ++ case RAW1394_MODIFY_FREE: ++ if ((buffer & bit) != 0) ++ return -1; ++ swap = buffer | bit; ++ break; + -+ request = (struct fw_cdev_send_request *) handle->buffer; -+ request->tcode = tcode; -+ request->generation = handle->generation; -+ request->offset = addr; -+ request->length = length; -+ request->closure = ptr_to_u64(closure); -+ request->data = ptr_to_u64(in); ++ default: ++ return -1; ++ } ++ ++ result = raw1394_lock (handle, raw1394_get_irm_id (handle), addr, ++ RAW1394_EXTCODE_COMPARE_SWAP, ++ htonl(swap), htonl(compare), &buffer); + -+ return ioctl(handle->devices[i].fd, FW_CDEV_IOC_SEND_REQUEST, request); ++ if (result < 0 || ntohl(buffer) != compare) ++ return -1; ++ ++ return 0; +} +diff -Naurp libraw1394-1.3.0.orig/juju/raw1394-iso.c libraw1394-1.3.0/juju/raw1394-iso.c +--- libraw1394-1.3.0.orig/juju/raw1394-iso.c 1969-12-31 19:00:00.000000000 -0500 ++++ libraw1394-1.3.0/juju/raw1394-iso.c 2007-10-18 22:18:46.000000000 -0400 +@@ -0,0 +1,522 @@ ++/* -*- c-basic-offset: 8 -*- ++ * ++ * raw1394-iso.c -- Emulation of the raw1394 rawiso API on the juju stack ++ * ++ * Copyright (C) 2007 Kristian Hoegsberg ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software Foundation, ++ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ */ + -+int -+raw1394_start_read(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, -+ size_t length, quadlet_t *buffer, unsigned long tag) ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "juju.h" ++ ++static int ++queue_packet(raw1394handle_t handle, ++ unsigned int length, unsigned int header_length, ++ unsigned char tag, unsigned char sy) +{ -+ int tcode; ++ struct fw_cdev_queue_iso queue_iso; ++ struct fw_cdev_iso_packet *p; ++ int err; + -+ if (length == 4) -+ tcode = TCODE_READ_QUADLET_REQUEST; -+ else -+ tcode = TCODE_READ_BLOCK_REQUEST; ++ p = &handle->iso.packets[handle->iso.packet_index]; ++ p->payload_length = length; ++ p->interrupt = ++ handle->iso.packet_phase == handle->iso.irq_interval - 1; ++ p->skip = 0; ++ p->tag = tag; ++ p->sy = sy; ++ p->header_length = header_length; + -+ return send_request(handle, tcode, -+ node, addr, length, NULL, buffer, tag); -+} ++ handle->iso.head += length; ++ handle->iso.packet_count++; ++ handle->iso.packet_phase++; ++ handle->iso.packet_index++; + -+int -+raw1394_start_write(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, -+ size_t length, quadlet_t *data, unsigned long tag) -+{ -+ int tcode; ++ if (handle->iso.packet_phase == handle->iso.irq_interval) ++ handle->iso.packet_phase = 0; + -+ if (length == 4) -+ tcode = TCODE_WRITE_QUADLET_REQUEST; -+ else -+ tcode = TCODE_WRITE_BLOCK_REQUEST; ++ if (handle->iso.head + handle->iso.max_packet_size > handle->iso.buffer_end) ++ handle->iso.head = handle->iso.buffer; + -+ return send_request(handle, tcode, -+ node, addr, length, data, NULL, tag); ++ /* Queue the packets in the kernel if we filled up the packets ++ * array or wrapped the payload buffer. */ ++ if (handle->iso.packet_index == handle->iso.irq_interval || ++ handle->iso.head == handle->iso.buffer) { ++ queue_iso.packets = ptr_to_u64(handle->iso.packets); ++ queue_iso.size = handle->iso.packet_index * sizeof handle->iso.packets[0]; ++ queue_iso.data = ptr_to_u64(handle->iso.first_payload); ++ queue_iso.handle = 0; ++ handle->iso.packet_index = 0; ++ handle->iso.first_payload = handle->iso.head; ++ ++ err = ioctl(handle->iso.fd, FW_CDEV_IOC_QUEUE_ISO, &queue_iso); ++ if (err < 0) ++ return -1; ++ } +} + +static int -+setup_lock(int extcode, quadlet_t data, quadlet_t arg, quadlet_t *buffer) ++queue_xmit_packets(raw1394handle_t handle, int limit) +{ -+ switch (extcode) { -+ case RAW1394_EXTCODE_FETCH_ADD: -+ case RAW1394_EXTCODE_LITTLE_ADD: -+ buffer[0] = data; -+ return sizeof buffer[0]; ++ enum raw1394_iso_disposition d; ++ unsigned char tag, sy; ++ int len, cycle, dropped; + -+ case RAW1394_EXTCODE_MASK_SWAP: -+ case RAW1394_EXTCODE_COMPARE_SWAP: -+ case RAW1394_EXTCODE_BOUNDED_ADD: -+ case RAW1394_EXTCODE_WRAP_ADD: -+ buffer[0] = arg; -+ buffer[1] = data; -+ return 2 * sizeof buffer[0]; ++ if (handle->iso.xmit_handler == NULL) ++ return 0; + -+ default: -+ errno = EINVAL; -+ return -1; ++ while (handle->iso.packet_count < limit) { ++ ++ d = handle->iso.xmit_handler(handle, handle->iso.head, ++ &len, &tag, &sy, cycle, dropped); ++ ++ switch (d) { ++ case RAW1394_ISO_OK: ++ queue_packet(handle, len, 0, tag, sy); ++ break; ++ case RAW1394_ISO_DEFER: ++ case RAW1394_ISO_AGAIN: ++ default: ++ return 0; ++ case RAW1394_ISO_ERROR: ++ return -1; ++ case RAW1394_ISO_STOP: ++ raw1394_iso_stop(handle); ++ return 0; ++ } + } ++ ++ return 0; +} + -+static int -+setup_lock64(int extcode, octlet_t data, octlet_t arg, octlet_t *buffer) ++int raw1394_iso_xmit_start(raw1394handle_t handle, int start_on_cycle, ++ int prebuffer_packets) +{ -+ switch (extcode) { -+ case RAW1394_EXTCODE_FETCH_ADD: -+ case RAW1394_EXTCODE_LITTLE_ADD: -+ buffer[0] = data; -+ return sizeof buffer[0]; ++ struct fw_cdev_start_iso start_iso; ++ int retval; + -+ case RAW1394_EXTCODE_MASK_SWAP: -+ case RAW1394_EXTCODE_COMPARE_SWAP: -+ case RAW1394_EXTCODE_BOUNDED_ADD: -+ case RAW1394_EXTCODE_WRAP_ADD: -+ buffer[0] = arg; -+ buffer[1] = data; -+ return 2 * sizeof buffer[0]; ++ if (prebuffer_packets == -1) ++ prebuffer_packets = handle->iso.irq_interval; + -+ default: -+ errno = EINVAL; -+ return -1; ++ handle->iso.prebuffer = prebuffer_packets; ++ handle->iso.start_on_cycle = start_on_cycle; ++ ++ queue_xmit_packets(handle, prebuffer_packets); ++ ++ if (handle->iso.prebuffer <= handle->iso.packet_count) { ++ start_iso.cycle = start_on_cycle; ++ start_iso.handle = 0; ++ ++ retval = ioctl(handle->iso.fd, ++ FW_CDEV_IOC_START_ISO, &start_iso); ++ if (retval < 0) ++ return retval; + } ++ ++ return queue_xmit_packets(handle, handle->iso.buf_packets); +} + -+int -+raw1394_start_lock(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, -+ unsigned int extcode, quadlet_t data, quadlet_t arg, -+ quadlet_t *result, unsigned long tag) ++static int ++queue_recv_packets(raw1394handle_t handle) +{ -+ quadlet_t buffer[2]; -+ int length; -+ -+ length = setup_lock(extcode, data, arg, buffer); -+ if (length < 0) -+ return length; ++ while (handle->iso.packet_count <= handle->iso.buf_packets) ++ queue_packet(handle, handle->iso.max_packet_size, 4, 0, 0); + -+ return send_request(handle, 16 + extcode, -+ node, addr, length, buffer, result, tag); ++ return 0; +} -+ -+int -+raw1394_start_lock64(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, -+ unsigned int extcode, octlet_t data, octlet_t arg, -+ octlet_t *result, unsigned long tag) ++ ++static enum raw1394_iso_disposition ++flush_recv_packets(raw1394handle_t handle, ++ struct fw_cdev_event_iso_interrupt *interrupt) +{ -+ octlet_t buffer[2]; -+ int length; ++ enum raw1394_iso_disposition d; ++ quadlet_t header, *p, *end; ++ unsigned int len, cycle, dropped; ++ unsigned char channel, tag, sy; ++ ++ p = interrupt->header; ++ end = (void *) interrupt->header + interrupt->header_length; ++ cycle = interrupt->cycle; ++ dropped = 0; ++ d = RAW1394_ISO_OK; ++ ++ while (p < end) { ++ header = be32_to_cpu(*p++); ++ len = header >> 16; ++ tag = (header >> 14) & 0x3; ++ channel = (header >> 8) & 0x3f; ++ sy = header & 0x0f; ++ ++ d = handle->iso.recv_handler(handle, handle->iso.tail, len, ++ channel, tag, sy, cycle, dropped); ++ if (d != RAW1394_ISO_OK) ++ /* FIXME: we need to save the headers so we ++ * can restart this loop. */ ++ break; ++ cycle++; ++ ++ handle->iso.tail += handle->iso.max_packet_size; ++ handle->iso.packet_count--; ++ ++ if (handle->iso.tail + handle->iso.max_packet_size > handle->iso.buffer_end) ++ handle->iso.tail = handle->iso.buffer; ++ } ++ ++ switch (d) { ++ case RAW1394_ISO_OK: ++ case RAW1394_ISO_DEFER: ++ default: ++ break; ++ ++ case RAW1394_ISO_ERROR: ++ return -1; + -+ length = setup_lock64(extcode, data, arg, buffer); -+ if (length < 0) -+ return length; ++ case RAW1394_ISO_STOP: ++ raw1394_iso_stop(handle); ++ return 0; ++ } + -+ return send_request(handle, 16 + extcode, -+ node, addr, length, buffer, result, tag); ++ queue_recv_packets(handle); ++ ++ return 0; +} + -+int -+raw1394_start_async_stream(raw1394handle_t handle, unsigned int channel, -+ unsigned int tag, unsigned int sy, -+ unsigned int speed, size_t length, quadlet_t *data, -+ unsigned long rawtag) ++int raw1394_iso_recv_start(raw1394handle_t handle, int start_on_cycle, ++ int tag_mask, int sync) +{ -+ /* FIXME: implement this? */ -+ return -1; -+} ++ struct fw_cdev_start_iso start_iso; + ++ queue_recv_packets(handle); + -+int -+raw1394_start_async_send(raw1394handle_t handle, -+ size_t length, size_t header_length, -+ unsigned int expect_response, -+ quadlet_t *data, unsigned long rawtag) -+{ -+ /* FIXME: implement this? */ -+ return -1; -+} ++ start_iso.cycle = start_on_cycle; ++ start_iso.tags = ++ tag_mask == -1 ? FW_CDEV_ISO_CONTEXT_MATCH_ALL_TAGS : tag_mask; ++ /* sync is documented as 'not used' */ ++ start_iso.sync = 0; ++ start_iso.handle = 0; + -+struct sync_data { -+ raw1394_errcode_t err; -+ int done; -+}; ++ return ioctl(handle->iso.fd, FW_CDEV_IOC_START_ISO, &start_iso); ++} + -+static int -+sync_callback(raw1394handle_t handle, void *data, raw1394_errcode_t err) ++static int handle_iso_event(raw1394handle_t handle, ++ struct epoll_closure *closure, __uint32_t events) +{ -+ struct sync_data *sd = data; ++ struct fw_cdev_event_iso_interrupt *interrupt; ++ int len; + -+ sd->err = err; -+ sd->done = 1; ++ len = read(handle->iso.fd, handle->buffer, sizeof handle->buffer); ++ if (len < 0) ++ return -1; + -+ return 0; ++ interrupt = (struct fw_cdev_event_iso_interrupt *) handle->buffer; ++ if (interrupt->type != FW_CDEV_EVENT_ISO_INTERRUPT) ++ return 0; ++ ++ switch (handle->iso.type) { ++ case FW_CDEV_ISO_CONTEXT_TRANSMIT: ++ handle->iso.packet_count -= handle->iso.irq_interval; ++ return queue_xmit_packets(handle, handle->iso.buf_packets); ++ case FW_CDEV_ISO_CONTEXT_RECEIVE: ++ return flush_recv_packets(handle, interrupt); ++ default: ++ /* Doesn't happen. */ ++ return -1; ++ } +} + -+static int -+send_request_sync(raw1394handle_t handle, int tcode, -+ nodeid_t node, nodeaddr_t addr, -+ size_t length, void *in, void *out) ++int raw1394_iso_xmit_write(raw1394handle_t handle, unsigned char *data, ++ unsigned int len, unsigned char tag, ++ unsigned char sy) +{ -+ struct raw1394_reqhandle reqhandle; -+ struct sync_data sd = { 0, 0 }; -+ int err; ++ struct fw_cdev_queue_iso queue_iso; ++ struct fw_cdev_start_iso start_iso; ++ struct fw_cdev_iso_packet *p; + -+ reqhandle.callback = sync_callback; -+ reqhandle.data = &sd; ++ if (len > handle->iso.max_packet_size) { ++ errno = EINVAL; ++ return -1; ++ } + -+ err = send_request(handle, tcode, node, addr, -+ length, in, out, (unsigned long) &reqhandle); ++ /* Block until we have space for another packet. */ ++ while (handle->iso.packet_count + handle->iso.irq_interval > ++ handle->iso.buf_packets) ++ raw1394_loop_iterate(handle); ++ ++ memcpy(handle->iso.head, data, len); ++ if (queue_packet(handle, len, 0, tag, sy) < 0) ++ return -1; + -+ while (!sd.done) { -+ if (err < 0) -+ return err; -+ err = raw1394_loop_iterate(handle); -+ } ++ /* Start the streaming if it's not already running and if ++ * we've buffered up enough packets. */ ++ if (handle->iso.prebuffer > 0 && ++ handle->iso.packet_count >= handle->iso.prebuffer) { ++ /* Set this to 0 to indicate that we're running. */ ++ handle->iso.prebuffer = 0; ++ start_iso.cycle = handle->iso.start_on_cycle; ++ start_iso.handle = 0; + -+ handle->err = sd.err; -+ errno = raw1394_errcode_to_errno(sd.err); ++ len = ioctl(handle->iso.fd, ++ FW_CDEV_IOC_START_ISO, &start_iso); ++ if (len < 0) ++ return len; ++ } + -+ return (errno ? -1 : 0); ++ return 0; +} + -+int -+raw1394_read(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, -+ size_t length, quadlet_t *buffer) ++int raw1394_iso_xmit_sync(raw1394handle_t handle) +{ -+ int tcode; ++ struct fw_cdev_iso_packet skip; ++ struct fw_cdev_queue_iso queue_iso; ++ int len; + -+ if (length == 4) -+ tcode = TCODE_READ_QUADLET_REQUEST; -+ else -+ tcode = TCODE_READ_BLOCK_REQUEST; ++ skip.payload_length = 0; ++ skip.interrupt = 1; ++ skip.skip = 1; ++ skip.tag = 0; ++ skip.sy = 0; ++ skip.header_length = 0; + -+ return send_request_sync(handle, tcode, -+ node, addr, length, NULL, buffer); ++ queue_iso.packets = ptr_to_u64(&skip); ++ queue_iso.size = sizeof skip; ++ queue_iso.data = 0; ++ queue_iso.handle = 0; ++ ++ len = ioctl(handle->iso.fd, FW_CDEV_IOC_QUEUE_ISO, &queue_iso); ++ if (len < 0) ++ return -1; ++ ++ /* Now that we've queued the skip packet, we'll get an ++ * interrupt when the transmit buffer is flushed, so all we do ++ * here is wait. */ ++ while (handle->iso.packet_count > 0) ++ raw1394_loop_iterate(handle); ++ ++ /* The iso mainloop thinks that interrutps indicate another ++ * irq_interval number of packets was sent, so the skip ++ * interrupt makes it go out of whack. We just reset it. */ ++ handle->iso.head = handle->iso.buffer; ++ handle->iso.tail = handle->iso.buffer; ++ handle->iso.first_payload = handle->iso.buffer; ++ handle->iso.packet_phase = 0; ++ handle->iso.packet_count = 0; ++ ++ return 0; +} + -+int -+raw1394_write(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, -+ size_t length, quadlet_t *data) ++int raw1394_iso_recv_flush(raw1394handle_t handle) +{ -+ int tcode; -+ -+ if (length == 4) -+ tcode = TCODE_WRITE_QUADLET_REQUEST; -+ else -+ tcode = TCODE_WRITE_BLOCK_REQUEST; ++ /* FIXME: huh, we'll need kernel support here... */ + -+ return send_request_sync(handle, tcode, -+ node, addr, length, data, NULL); ++ return 0; +} + -+int -+raw1394_lock(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, -+ unsigned int extcode, quadlet_t data, quadlet_t arg, -+ quadlet_t *result) ++static unsigned int ++round_to_power_of_two(unsigned int value) +{ -+ quadlet_t buffer[2]; -+ size_t length; ++ unsigned int pot; + -+ length = setup_lock(extcode, data, arg, buffer); -+ if (length < 0) -+ return length; ++ pot = 1; ++ while (pot < value) ++ pot <<= 1; + -+ return send_request_sync(handle, 16 + extcode, node, addr, -+ length, buffer, result); ++ return pot; +} + -+int -+raw1394_lock64(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, -+ unsigned int extcode, octlet_t data, octlet_t arg, -+ octlet_t *result) ++static int ++iso_init(raw1394handle_t handle, int type, ++ raw1394_iso_xmit_handler_t xmit_handler, ++ raw1394_iso_recv_handler_t recv_handler, ++ unsigned int buf_packets, ++ unsigned int max_packet_size, ++ unsigned char channel, ++ enum raw1394_iso_speed speed, ++ int irq_interval) +{ -+ octlet_t buffer[2]; -+ size_t length; ++ struct fw_cdev_create_iso_context create; ++ struct epoll_event ep; ++ int retval, prot; + -+ length = setup_lock64(extcode, data, arg, buffer); -+ if (length < 0) -+ return length; ++ if (handle->iso.fd != -1) { ++ errno = EBUSY; ++ return -1; ++ } + -+ return send_request_sync(handle, 16 + extcode, node, addr, -+ length, buffer, result); -+} ++ switch (type) { ++ case FW_CDEV_ISO_CONTEXT_TRANSMIT: ++ prot = PROT_READ | PROT_WRITE; ++ break; ++ case FW_CDEV_ISO_CONTEXT_RECEIVE: ++ prot = PROT_READ; ++ break; ++ default: ++ errno = EINVAL; ++ return -1; ++ } ++ ++ handle->iso.type = type; ++ if (irq_interval < 0) ++ handle->iso.irq_interval = 256; ++ else ++ handle->iso.irq_interval = irq_interval; ++ handle->iso.xmit_handler = xmit_handler; ++ handle->iso.recv_handler = recv_handler; ++ handle->iso.buf_packets = buf_packets; ++ handle->iso.max_packet_size = round_to_power_of_two(max_packet_size); ++ handle->iso.packet_phase = 0; ++ handle->iso.packet_count = 0; ++ handle->iso.packets = ++ malloc(handle->iso.irq_interval * sizeof handle->iso.packets[0]); ++ if (handle->iso.packets == NULL) ++ return -1; + -+int -+raw1394_async_stream(raw1394handle_t handle, unsigned int channel, -+ unsigned int tag, unsigned int sy, unsigned int speed, -+ size_t length, quadlet_t *data) -+{ -+ /* FIXME: implement this? */ -+ return -1; -+} ++ handle->iso.fd = open(handle->local_filename, O_RDWR); ++ if (handle->iso.fd < 0) { ++ free(handle->iso.packets); ++ return -1; ++ } + -+int -+raw1394_async_send(raw1394handle_t handle, -+ size_t length, size_t header_length, -+ unsigned int expect_response, -+ quadlet_t *data) -+{ -+ /* FIXME: implement this? */ -+ return -1; -+} ++ handle->iso.closure.func = handle_iso_event; ++ ep.events = EPOLLIN; ++ ep.data.ptr = &handle->iso.closure; ++ if (epoll_ctl(handle->epoll_fd, EPOLL_CTL_ADD, ++ handle->iso.fd, &ep) < 0) { ++ close(handle->iso.fd); ++ free(handle->iso.packets); ++ return -1; ++ } + -+int -+raw1394_start_fcp_listen(raw1394handle_t handle) -+{ -+ struct fw_cdev_allocate request; -+ struct address_closure *closure; ++ create.type = type; ++ create.channel = channel; ++ create.speed = speed; ++ create.header_size = 4; + -+ closure = malloc(sizeof *closure); -+ if (closure == NULL) -+ return -1; ++ retval = ioctl(handle->iso.fd, ++ FW_CDEV_IOC_CREATE_ISO_CONTEXT, &create); ++ if (retval < 0) { ++ close(handle->iso.fd); ++ free(handle->iso.packets); ++ return retval; ++ } + -+ closure->callback = handle_fcp_request; ++ handle->iso.buffer = ++ mmap(NULL, buf_packets * max_packet_size, ++ prot, MAP_SHARED, handle->iso.fd, 0); + -+ request.offset = CSR_REGISTER_BASE + CSR_FCP_COMMAND; -+ request.length = CSR_FCP_END - CSR_FCP_COMMAND; -+ request.closure = ptr_to_u64(closure); -+ if (ioctl(handle->local_fd, FW_CDEV_IOC_ALLOCATE, &request) < 0) ++ if (handle->iso.buffer == MAP_FAILED) { ++ close(handle->iso.fd); ++ free(handle->iso.packets); + return -1; ++ } + -+ handle->fcp_allocation_handle = request.handle; ++ handle->iso.buffer_end = handle->iso.buffer + ++ buf_packets * max_packet_size; ++ handle->iso.head = handle->iso.buffer; ++ handle->iso.tail = handle->iso.buffer; ++ handle->iso.first_payload = handle->iso.buffer; + + return 0; +} + -+int -+raw1394_stop_fcp_listen(raw1394handle_t handle) ++int raw1394_iso_xmit_init(raw1394handle_t handle, ++ raw1394_iso_xmit_handler_t handler, ++ unsigned int buf_packets, ++ unsigned int max_packet_size, ++ unsigned char channel, ++ enum raw1394_iso_speed speed, ++ int irq_interval) +{ -+ struct fw_cdev_deallocate request; -+ -+ request.handle = handle->fcp_allocation_handle; -+ -+ return ioctl(handle->local_fd, FW_CDEV_IOC_DEALLOCATE, &request); ++ return iso_init(handle, FW_CDEV_ISO_CONTEXT_TRANSMIT, ++ handler, NULL, buf_packets, max_packet_size, ++ channel, speed, irq_interval); +} + -+const char * -+raw1394_get_libversion(void) ++int raw1394_iso_recv_init(raw1394handle_t handle, ++ raw1394_iso_recv_handler_t handler, ++ unsigned int buf_packets, ++ unsigned int max_packet_size, ++ unsigned char channel, ++ enum raw1394_iso_dma_recv_mode mode, ++ int irq_interval) +{ -+ return VERSION " (Juju)"; ++ return iso_init(handle, FW_CDEV_ISO_CONTEXT_RECEIVE, ++ NULL, handler, buf_packets, max_packet_size, ++ channel, 0, irq_interval); +} + -+int -+raw1394_update_config_rom(raw1394handle_t handle, const quadlet_t *new_rom, -+ size_t size, unsigned char rom_version) ++int raw1394_iso_multichannel_recv_init(raw1394handle_t handle, ++ raw1394_iso_recv_handler_t handler, ++ unsigned int buf_packets, ++ unsigned int max_packet_size, ++ int irq_interval) +{ ++ /* FIXME: gah */ ++ errno = ENOSYS; + return -1; +} + -+int -+raw1394_get_config_rom(raw1394handle_t handle, quadlet_t *buffer, -+ size_t buffersize, size_t *rom_size, -+ unsigned char *rom_version) ++int raw1394_iso_recv_listen_channel(raw1394handle_t handle, ++ unsigned char channel) +{ -+ struct fw_cdev_get_info get_info; -+ int err; -+ -+ get_info.version = FW_CDEV_VERSION; -+ get_info.rom = ptr_to_u64(buffer); -+ get_info.rom_length = buffersize; -+ get_info.bus_reset = 0; -+ -+ err = ioctl(handle->local_fd, FW_CDEV_IOC_GET_INFO, &get_info); -+ if (err) -+ return err; -+ -+ *rom_size = get_info.rom_length; -+ *rom_version = 0; -+ -+ return 0; ++ /* FIXME: multichannel */ ++ errno = ENOSYS; ++ return -1; +} + -+#define MAXIMUM_BANDWIDTH 4915 -+ -+int -+raw1394_bandwidth_modify (raw1394handle_t handle, -+ unsigned int bandwidth, -+ enum raw1394_modify_mode mode) ++int raw1394_iso_recv_unlisten_channel(raw1394handle_t handle, ++ unsigned char channel) +{ -+ quadlet_t buffer, compare, swap; -+ nodeaddr_t addr; -+ int result; -+ -+ if (bandwidth == 0) -+ return 0; -+ -+ addr = CSR_REGISTER_BASE + CSR_BANDWIDTH_AVAILABLE; -+ /* Read current bandwidth usage from IRM. */ -+ result = raw1394_read (handle, raw1394_get_irm_id (handle), addr, -+ sizeof buffer, &buffer); -+ if (result < 0) -+ return -1; -+ -+ compare = ntohl (buffer); -+ switch (mode) { -+ case RAW1394_MODIFY_ALLOC: -+ swap = compare - bandwidth; -+ if (swap < 0) -+ return -1; -+ break; -+ -+ case RAW1394_MODIFY_FREE: -+ swap = compare + bandwidth; -+ if (swap > MAXIMUM_BANDWIDTH) -+ swap = MAXIMUM_BANDWIDTH; -+ break; -+ -+ default: -+ return -1; -+ } ++ /* FIXME: multichannel */ ++ errno = ENOSYS; ++ return -1; ++} + -+ result = raw1394_lock(handle, raw1394_get_irm_id (handle), addr, -+ RAW1394_EXTCODE_COMPARE_SWAP, -+ htonl(swap), htonl(compare), &buffer); -+ if (result < 0 || ntohl(buffer) != compare) -+ return -1; -+ -+ return 0; ++int raw1394_iso_recv_set_channel_mask(raw1394handle_t handle, u_int64_t mask) ++{ ++ /* FIXME: multichannel */ ++ errno = ENOSYS; ++ return -1; +} + -+int -+raw1394_channel_modify (raw1394handle_t handle, -+ unsigned int channel, -+ enum raw1394_modify_mode mode) ++void raw1394_iso_stop(raw1394handle_t handle) +{ -+ quadlet_t buffer, compare, swap, bit; -+ nodeaddr_t addr; -+ int result; -+ -+ if (channel >= 64) -+ return -1; -+ addr = CSR_REGISTER_BASE + -+ CSR_CHANNELS_AVAILABLE_HI + 4 * (channel / 32); -+ /* Read currently available channels from IRM. */ -+ result = raw1394_read(handle, raw1394_get_irm_id (handle), addr, -+ sizeof buffer, &buffer); -+ if (result < 0) -+ return -1; -+ -+ /* IEEE numbers bits from MSB (0) to LSB (31). */ -+ bit = 1 << (31 - (channel & 31)); -+ compare = ntohl(buffer); -+ switch (mode) { -+ case RAW1394_MODIFY_ALLOC: -+ if ((compare & bit) == 0) -+ return -1; -+ swap = buffer & ~bit; -+ break; ++ struct fw_cdev_stop_iso stop_iso; + -+ case RAW1394_MODIFY_FREE: -+ if ((buffer & bit) != 0) -+ return -1; -+ swap = buffer | bit; -+ break; ++ stop_iso.handle = 0; ++ ioctl(handle->iso.fd, FW_CDEV_IOC_STOP_ISO); + -+ default: -+ return -1; -+ } -+ -+ result = raw1394_lock (handle, raw1394_get_irm_id (handle), addr, -+ RAW1394_EXTCODE_COMPARE_SWAP, -+ htonl(swap), htonl(compare), &buffer); ++ handle->iso.head = handle->iso.buffer; ++ handle->iso.tail = handle->iso.buffer; ++ handle->iso.first_payload = handle->iso.buffer; ++ handle->iso.packet_phase = 0; ++ handle->iso.packet_count = 0; ++} + -+ if (result < 0 || ntohl(buffer) != compare) -+ return -1; -+ -+ return 0; ++void raw1394_iso_shutdown(raw1394handle_t handle) ++{ ++ munmap(handle->iso.buffer, ++ handle->iso.buf_packets * handle->iso.max_packet_size); ++ close(handle->iso.fd); ++ free(handle->iso.packets); +} -diff --git a/tools/Makefile.am b/tools/Makefile.am -index 29b250e..5be1b6f 100644 ---- a/tools/Makefile.am -+++ b/tools/Makefile.am +diff -Naurp libraw1394-1.3.0.orig/Makefile.am libraw1394-1.3.0/Makefile.am +--- libraw1394-1.3.0.orig/Makefile.am 2004-11-05 19:26:44.000000000 -0500 ++++ libraw1394-1.3.0/Makefile.am 2007-10-18 22:18:46.000000000 -0400 +@@ -1,6 +1,7 @@ + # process this file with automake to create a Makefile.in + +-SUBDIRS = src tools doc debian ++SUBDIRS = $(LIB_SUBDIR) tools doc debian ++DIST_SUBDIRS = src juju + + pkgconfigdir = @libdir@/pkgconfig + pkgconfig_DATA = libraw1394.pc +diff -Naurp libraw1394-1.3.0.orig/tools/Makefile.am libraw1394-1.3.0/tools/Makefile.am +--- libraw1394-1.3.0.orig/tools/Makefile.am 2004-11-05 19:26:44.000000000 -0500 ++++ libraw1394-1.3.0/tools/Makefile.am 2007-10-18 22:18:46.000000000 -0400 @@ -2,4 +2,4 @@ MAINTAINERCLEANFILES = Makefile.in # testlibraw bin_PROGRAMS = testlibraw sendiso dumpiso -LDADD = ../src/libraw1394.la +LDADD = ../$(LIB_SUBDIR)/libraw1394.la -diff --git a/tools/testlibraw.c b/tools/testlibraw.c -index 5f73bd9..2f02a6d 100644 ---- a/tools/testlibraw.c -+++ b/tools/testlibraw.c +diff -Naurp libraw1394-1.3.0.orig/tools/testlibraw.c libraw1394-1.3.0/tools/testlibraw.c +--- libraw1394-1.3.0.orig/tools/testlibraw.c 2004-01-31 15:26:03.000000000 -0500 ++++ libraw1394-1.3.0/tools/testlibraw.c 2007-10-18 22:18:46.000000000 -0400 @@ -1,4 +1,5 @@ -/* +/* -*- c-basic-offset: 8 -*- @@ -2225,7 +2214,7 @@ index 5f73bd9..2f02a6d 100644 const char not_compatible[] = "\ This libraw1394 does not work with your version of Linux. You need a different\n\ -@@ -45,12 +47,18 @@ int my_tag_handler(raw1394handle_t handle, unsigned long tag, +@@ -45,12 +47,18 @@ int my_tag_handler(raw1394handle_t handl return 0; } @@ -2244,7 +2233,7 @@ index 5f73bd9..2f02a6d 100644 while (length) { printf(" %02x", *data); data++; -@@ -62,6 +70,47 @@ int my_fcp_handler(raw1394handle_t handle, nodeid_t nodeid, int response, +@@ -62,6 +70,47 @@ int my_fcp_handler(raw1394handle_t handl return 0; } diff --git a/libraw1394-underquoted.patch b/libraw1394-underquoted.patch deleted file mode 100644 index a1e677d..0000000 --- a/libraw1394-underquoted.patch +++ /dev/null @@ -1,47 +0,0 @@ ---- libraw1394-0.10.1/libraw1394.m4.underquoted 2004-07-15 12:59:11.467143881 +0100 -+++ libraw1394-0.10.1/libraw1394.m4 2004-07-15 12:59:57.705291918 +0100 -@@ -3,7 +3,7 @@ - dnl This just unconditionally sets the options. It should offer an option for - dnl explicitly giving the path to libraw1394 on the configure command line. - dnl --AC_DEFUN(AC_LIB_RAW1394_FLAGS, [ -+AC_DEFUN([AC_LIB_RAW1394_FLAGS], [ - LIBRAW1394_CPPFLAGS="" - LIBRAW1394_CFLAGS="" - LIBRAW1394_LIBS="-lraw1394" -@@ -16,7 +16,7 @@ - dnl - dnl AC_LIB_RAW1394_HEADERS([ACTION_IF_FOUND[,ACTION_IF_NOT_FOUND]]) - dnl --AC_DEFUN(AC_LIB_RAW1394_HEADERS, [ -+AC_DEFUN([AC_LIB_RAW1394_HEADERS], [ - AC_REQUIRE([AC_LIB_RAW1394_FLAGS]) - - ac_libraw1394_save_cppflags=$CPPFLAGS -@@ -38,7 +38,7 @@ - dnl - dnl AC_LIB_RAW1394_LIBVERSION(MINIMUMVERSION[,ACTION_IF_FOUND[,ACTION_IF_NOT_FOUND]]) - dnl --AC_DEFUN(AC_LIB_RAW1394_LIBVERSION, [ -+AC_DEFUN([AC_LIB_RAW1394_LIBVERSION], [ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_LIB_RAW1394_FLAGS]) - -@@ -72,7 +72,7 @@ - dnl - dnl AC_LIB_RAW1394_RUNTEST(MINIMUMVERSION[,ACTION_IF_FOUND - dnl [,ACTION_IF_NOT_FOUND[,ACTION_IF_CROSS_COMPILING]]]) --AC_DEFUN(AC_LIB_RAW1394_RUNTEST, [ -+AC_DEFUN([AC_LIB_RAW1394_RUNTEST], [ - ac_libraw1394_save_cppflags=$CPPFLAGS - ac_libraw1394_save_cflags=$CFLAGS - ac_libraw1394_save_libs=$LIBS -@@ -135,7 +135,7 @@ - dnl Versions before 0.9 can't be checked, so this will always fail if the - dnl installed libraw1394 is older than 0.9 as if the library weren't found. - dnl --AC_DEFUN(AC_LIB_RAW1394, [ -+AC_DEFUN([AC_LIB_RAW1394], [ - - AC_LIB_RAW1394_FLAGS - AC_LIB_RAW1394_HEADERS(ac_libraw1394_found=yes, ac_libraw1394_found=no) diff --git a/libraw1394.spec b/libraw1394.spec index ed7b49a..c12b991 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 -Version: 1.2.1 -Release: 10%{?dist} +Version: 1.3.0 +Release: 1%{?dist} License: LGPL Group: System Environment/Libraries Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz @@ -77,6 +77,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Thu Oct 18 2007 Jarod Wilson - 1.3.0-1 +- libraw1394 v1.3.0 + * Wed Aug 29 2007 Fedora Release Engineering - 1.2.1-10 - Rebuild for selinux ppc32 issue. diff --git a/sources b/sources index 09a25fe..23e349f 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -e6210ff05b7f4ec0401ad3d11f493e1a libraw1394-1.2.1.tar.gz +c5d9ab62bd25dba96af010b3471e816a libraw1394-1.3.0.tar.gz From c8912377addf944bbd9d2524db818106ac0c58b8 Mon Sep 17 00:00:00 2001 From: Jarod Wilson Date: Fri, 19 Oct 2007 21:35:40 +0000 Subject: [PATCH 041/100] Fix the 'double free' crash on shutdown (#328011). Note that avc stuff still doesn't work, but at least this crash is gone, and I've got a better idea of where things are actually going awry... --- libraw1394.spec | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index c12b991..e8f1725 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 1.3.0 -Release: 1%{?dist} +Release: 2%{?dist} License: LGPL Group: System Environment/Libraries Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz @@ -12,6 +12,7 @@ BuildRequires: autoconf automake libtool Source1: firewire-cdev.h Patch0: libraw1394-juju.patch +Patch1: libraw1394-juju-no-double-free-on-shutdown.patch %description The libraw1394 library provides direct access to the IEEE-1394 bus through @@ -29,6 +30,7 @@ Development libraries needed to build applications against libraw1394. %setup -q %patch0 -p1 -b .juju +%patch1 -p1 -b .free %build @@ -77,6 +79,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Fri Oct 19 2007 Jarod Wilson - 1.3.0-2 +- Fix the 'double free' crash on shutdown (#328011) + * Thu Oct 18 2007 Jarod Wilson - 1.3.0-1 - libraw1394 v1.3.0 From b2e6c10306b48d19f6601f8dc1e91719fc1a473c Mon Sep 17 00:00:00 2001 From: Jarod Wilson Date: Sun, 21 Oct 2007 19:24:52 +0000 Subject: [PATCH 042/100] Add patch left out of last commit... --- ...1394-juju-no-double-free-on-shutdown.patch | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 libraw1394-juju-no-double-free-on-shutdown.patch diff --git a/libraw1394-juju-no-double-free-on-shutdown.patch b/libraw1394-juju-no-double-free-on-shutdown.patch new file mode 100644 index 0000000..4f35ca4 --- /dev/null +++ b/libraw1394-juju-no-double-free-on-shutdown.patch @@ -0,0 +1,36 @@ +diff -Naurp libraw1394-1.3.0/juju/raw1394-iso.c libraw1394-1.3.0.fix/juju/raw1394-iso.c +--- libraw1394-1.3.0/juju/raw1394-iso.c 2007-10-19 16:05:09.000000000 -0400 ++++ libraw1394-1.3.0.fix/juju/raw1394-iso.c 2007-10-19 17:14:40.000000000 -0400 +@@ -394,6 +394,7 @@ iso_init(raw1394handle_t handle, int typ + handle->iso.fd = open(handle->local_filename, O_RDWR); + if (handle->iso.fd < 0) { + free(handle->iso.packets); ++ handle->iso.packets = NULL; + return -1; + } + +@@ -404,6 +405,7 @@ iso_init(raw1394handle_t handle, int typ + handle->iso.fd, &ep) < 0) { + close(handle->iso.fd); + free(handle->iso.packets); ++ handle->iso.packets = NULL; + return -1; + } + +@@ -417,6 +419,8 @@ iso_init(raw1394handle_t handle, int typ + if (retval < 0) { + close(handle->iso.fd); + free(handle->iso.packets); ++ handle->iso.packets = NULL; ++ printf("ioctl call failed, retval = %d\n", retval); + return retval; + } + +@@ -427,6 +431,7 @@ iso_init(raw1394handle_t handle, int typ + if (handle->iso.buffer == MAP_FAILED) { + close(handle->iso.fd); + free(handle->iso.packets); ++ handle->iso.packets = NULL; + return -1; + } + From c950d6d40d505edbc1cfd82645e42c665f0788ee Mon Sep 17 00:00:00 2001 From: Jarod Wilson Date: Wed, 24 Oct 2007 20:10:53 +0000 Subject: [PATCH 043/100] - Update firewire-cdev.h to match kernel --- firewire-cdev.h | 366 ++++++++++++++---- ...1394-juju-no-double-free-on-shutdown.patch | 19 +- libraw1394.spec | 5 +- 3 files changed, 301 insertions(+), 89 deletions(-) diff --git a/firewire-cdev.h b/firewire-cdev.h index 026c768..1a45d6f 100644 --- a/firewire-cdev.h +++ b/firewire-cdev.h @@ -1,6 +1,5 @@ -/* -*- c-basic-offset: 8 -*- - * - * fw-device-cdev.h -- Char device interface. +/* + * Char device interface. * * Copyright (C) 2005-2006 Kristian Hoegsberg * @@ -19,66 +18,50 @@ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef __fw_cdev_h -#define __fw_cdev_h - -#include -#include - -#define TCODE_WRITE_QUADLET_REQUEST 0 -#define TCODE_WRITE_BLOCK_REQUEST 1 -#define TCODE_WRITE_RESPONSE 2 -#define TCODE_READ_QUADLET_REQUEST 4 -#define TCODE_READ_BLOCK_REQUEST 5 -#define TCODE_READ_QUADLET_RESPONSE 6 -#define TCODE_READ_BLOCK_RESPONSE 7 -#define TCODE_CYCLE_START 8 -#define TCODE_LOCK_REQUEST 9 -#define TCODE_STREAM_DATA 10 -#define TCODE_LOCK_RESPONSE 11 - -#define TCODE_LOCK_MASK_SWAP 0x11 -#define TCODE_LOCK_COMPARE_SWAP 0x12 -#define TCODE_LOCK_FETCH_ADD 0x13 -#define TCODE_LOCK_LITTLE_ADD 0x14 -#define TCODE_LOCK_BOUNDED_ADD 0x15 -#define TCODE_LOCK_WRAP_ADD 0x16 -#define TCODE_LOCK_VENDOR_DEPENDENT 0x17 - -#define RCODE_COMPLETE 0x0 -#define RCODE_CONFLICT_ERROR 0x4 -#define RCODE_DATA_ERROR 0x5 -#define RCODE_TYPE_ERROR 0x6 -#define RCODE_ADDRESS_ERROR 0x7 +#ifndef _LINUX_FIREWIRE_CDEV_H +#define _LINUX_FIREWIRE_CDEV_H -#define RCODE_SEND_ERROR 0x10 -#define RCODE_CANCELLED 0x11 -#define RCODE_BUSY 0x12 -#define RCODE_GENERATION 0x13 -#define RCODE_NO_ACK 0x14 - -#define SCODE_100 0x0 -#define SCODE_200 0x1 -#define SCODE_400 0x2 -#define SCODE_800 0x3 -#define SCODE_1600 0x4 -#define SCODE_3200 0x5 +#include +#include +#include #define FW_CDEV_EVENT_BUS_RESET 0x00 #define FW_CDEV_EVENT_RESPONSE 0x01 #define FW_CDEV_EVENT_REQUEST 0x02 #define FW_CDEV_EVENT_ISO_INTERRUPT 0x03 -/* The 'closure' fields are for user space to use. Data passed in the - * 'closure' field for a request will be returned in the corresponding - * event. It's a 64-bit type so that it's a fixed size type big - * enough to hold a pointer on all platforms. */ - +/** + * struct fw_cdev_event_common - Common part of all fw_cdev_event_ types + * @closure: For arbitrary use by userspace + * @type: Discriminates the fw_cdev_event_ types + * + * This struct may be used to access generic members of all fw_cdev_event_ + * types regardless of the specific type. + * + * Data passed in the @closure field for a request will be returned in the + * corresponding event. It is big enough to hold a pointer on all platforms. + * The ioctl used to set @closure depends on the @type of event. + */ struct fw_cdev_event_common { __u64 closure; __u32 type; }; +/** + * struct fw_cdev_event_bus_reset - Sent when a bus reset occurred + * @closure: See &fw_cdev_event_common; set by %FW_CDEV_IOC_GET_INFO ioctl + * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_BUS_RESET + * @node_id: New node ID of this node + * @local_node_id: Node ID of the local node, i.e. of the controller + * @bm_node_id: Node ID of the bus manager + * @irm_node_id: Node ID of the iso resource manager + * @root_node_id: Node ID of the root node + * @generation: New bus generation + * + * This event is sent when the bus the device belongs to goes through a bus + * reset. It provides information about the new bus configuration, such as + * new node ID for this device, new root ID, and others. + */ struct fw_cdev_event_bus_reset { __u64 closure; __u32 type; @@ -90,6 +73,20 @@ struct fw_cdev_event_bus_reset { __u32 generation; }; +/** + * struct fw_cdev_event_response - Sent when a response packet was received + * @closure: See &fw_cdev_event_common; + * set by %FW_CDEV_IOC_SEND_REQUEST ioctl + * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_RESPONSE + * @rcode: Response code returned by the remote node + * @length: Data length, i.e. the response's payload size in bytes + * @data: Payload data, if any + * + * This event is sent when the stack receives a response to an outgoing request + * sent by %FW_CDEV_IOC_SEND_REQUEST ioctl. The payload data for responses + * carrying data (read and lock responses) follows immediately and can be + * accessed through the @data field. + */ struct fw_cdev_event_response { __u64 closure; __u32 type; @@ -98,6 +95,25 @@ struct fw_cdev_event_response { __u32 data[0]; }; +/** + * struct fw_cdev_event_request - Sent on incoming request to an address region + * @closure: See &fw_cdev_event_common; set by %FW_CDEV_IOC_ALLOCATE ioctl + * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_REQUEST + * @tcode: Transaction code of the incoming request + * @offset: The offset into the 48-bit per-node address space + * @handle: Reference to the kernel-side pending request + * @length: Data length, i.e. the request's payload size in bytes + * @data: Incoming data, if any + * + * This event is sent when the stack receives an incoming request to an address + * region registered using the %FW_CDEV_IOC_ALLOCATE ioctl. The request is + * guaranteed to be completely contained in the specified region. Userspace is + * responsible for sending the response by %FW_CDEV_IOC_SEND_RESPONSE ioctl, + * using the same @handle. + * + * The payload data for requests carrying data (write and lock requests) + * follows immediately and can be accessed through the @data field. + */ struct fw_cdev_event_request { __u64 closure; __u32 type; @@ -108,14 +124,39 @@ struct fw_cdev_event_request { __u32 data[0]; }; +/** + * struct fw_cdev_event_iso_interrupt - Sent when an iso packet was completed + * @closure: See &fw_cdev_event_common; + * set by %FW_CDEV_CREATE_ISO_CONTEXT ioctl + * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_ISO_INTERRUPT + * @cycle: Cycle counter of the interrupt packet + * @header_length: Total length of following headers, in bytes + * @header: Stripped headers, if any + * + * This event is sent when the controller has completed an &fw_cdev_iso_packet + * with the %FW_CDEV_ISO_INTERRUPT bit set. In the receive case, the headers + * stripped of all packets up until and including the interrupt packet are + * returned in the @header field. + */ struct fw_cdev_event_iso_interrupt { __u64 closure; __u32 type; __u32 cycle; - __u32 header_length; /* Length in bytes of following headers. */ + __u32 header_length; __u32 header[0]; }; +/** + * union fw_cdev_event - Convenience union of fw_cdev_event_ types + * @common: Valid for all types + * @bus_reset: Valid if @common.type == %FW_CDEV_EVENT_BUS_RESET + * @response: Valid if @common.type == %FW_CDEV_EVENT_RESPONSE + * @request: Valid if @common.type == %FW_CDEV_EVENT_REQUEST + * @iso_interrupt: Valid if @common.type == %FW_CDEV_EVENT_ISO_INTERRUPT + * + * Convenience union for userspace use. Events could be read(2) into a char + * buffer and then cast to this union for further processing. + */ union fw_cdev_event { struct fw_cdev_event_common common; struct fw_cdev_event_bus_reset bus_reset; @@ -144,35 +185,47 @@ union fw_cdev_event { */ #define FW_CDEV_VERSION 1 +/** + * struct fw_cdev_get_info - General purpose information ioctl + * @version: The version field is just a running serial number. + * We never break backwards compatibility, but may add more + * structs and ioctls in later revisions. + * @rom_length: If @rom is non-zero, at most rom_length bytes of configuration + * ROM will be copied into that user space address. In either + * case, @rom_length is updated with the actual length of the + * configuration ROM. + * @rom: If non-zero, address of a buffer to be filled by a copy of the + * local node's configuration ROM + * @bus_reset: If non-zero, address of a buffer to be filled by a + * &struct fw_cdev_event_bus_reset with the current state + * of the bus. This does not cause a bus reset to happen. + * @bus_reset_closure: Value of &closure in this and subsequent bus reset events + * @card: The index of the card this device belongs to + */ struct fw_cdev_get_info { - /* The version field is just a running serial number. We - * never break backwards compatibility. Userspace passes in - * the version it expects and the kernel passes back the - * highest version it can provide. Even if the structs in - * this interface are extended in a later version, the kernel - * will not copy back more data than what was present in the - * interface version userspace expects. */ __u32 version; - - /* If non-zero, at most rom_length bytes of config rom will be - * copied into that user space address. In either case, - * rom_length is updated with the actual length of the config - * rom. */ __u32 rom_length; __u64 rom; - - /* If non-zero, a fw_cdev_event_bus_reset struct will be - * copied here with the current state of the bus. This does - * not cause a bus reset to happen. The value of closure in - * this and sub-sequent bus reset events is set to - * bus_reset_closure. */ __u64 bus_reset; __u64 bus_reset_closure; - - /* The index of the card this devices belongs to. */ __u32 card; }; +/** + * struct fw_cdev_send_request - Send an asynchronous request packet + * @tcode: Transaction code of the request + * @length: Length of outgoing payload, in bytes + * @offset: 48-bit offset at destination node + * @closure: Passed back to userspace in the response event + * @data: Userspace pointer to payload + * @generation: The bus generation where packet is valid + * + * Send a request to the device. This ioctl implements all outgoing requests. + * Both quadlet and block request specify the payload as a pointer to the data + * in the @data field. Once the transaction completes, the kernel writes an + * &fw_cdev_event_request event back. The @closure field is passed back to + * user space in the response event. + */ struct fw_cdev_send_request { __u32 tcode; __u32 length; @@ -182,6 +235,19 @@ struct fw_cdev_send_request { __u32 generation; }; +/** + * struct fw_cdev_send_response - Send an asynchronous response packet + * @rcode: Response code as determined by the userspace handler + * @length: Length of outgoing payload, in bytes + * @data: Userspace pointer to payload + * @handle: The handle from the &fw_cdev_event_request + * + * Send a response to an incoming request. By setting up an address range using + * the %FW_CDEV_IOC_ALLOCATE ioctl, userspace can listen for incoming requests. An + * incoming request will generate an %FW_CDEV_EVENT_REQUEST, and userspace must + * send a reply using this ioctl. The event has a handle to the kernel-side + * pending transaction, which should be used with this ioctl. + */ struct fw_cdev_send_response { __u32 rcode; __u32 length; @@ -189,6 +255,21 @@ struct fw_cdev_send_response { __u32 handle; }; +/** + * struct fw_cdev_allocate - Allocate a CSR address range + * @offset: Start offset of the address range + * @closure: To be passed back to userspace in request events + * @length: Length of the address range, in bytes + * @handle: Handle to the allocation, written by the kernel + * + * Allocate an address range in the 48-bit address space on the local node + * (the controller). This allows userspace to listen for requests with an + * offset within that address range. When the kernel receives a request + * within the range, an &fw_cdev_event_request event will be written back. + * The @closure field is passed back to userspace in the response event. + * The @handle field is an out parameter, returning a handle to the allocated + * range to be used for later deallocation of the range. + */ struct fw_cdev_allocate { __u64 offset; __u64 closure; @@ -196,6 +277,11 @@ struct fw_cdev_allocate { __u32 handle; }; +/** + * struct fw_cdev_deallocate - Free an address range allocation + * @handle: Handle to the address range, as returned by the kernel when the + * range was allocated + */ struct fw_cdev_deallocate { __u32 handle; }; @@ -203,10 +289,41 @@ struct fw_cdev_deallocate { #define FW_CDEV_LONG_RESET 0 #define FW_CDEV_SHORT_RESET 1 +/** + * struct fw_cdev_initiate_bus_reset - Initiate a bus reset + * @type: %FW_CDEV_SHORT_RESET or %FW_CDEV_LONG_RESET + * + * Initiate a bus reset for the bus this device is on. The bus reset can be + * either the original (long) bus reset or the arbitrated (short) bus reset + * introduced in 1394a-2000. + */ struct fw_cdev_initiate_bus_reset { - __u32 type; + __u32 type; /* FW_CDEV_SHORT_RESET or FW_CDEV_LONG_RESET */ }; +/** + * struct fw_cdev_add_descriptor - Add contents to the local node's config ROM + * @immediate: If non-zero, immediate key to insert before pointer + * @key: Upper 8 bits of root directory pointer + * @data: Userspace pointer to contents of descriptor block + * @length: Length of descriptor block data, in bytes + * @handle: Handle to the descriptor, written by the kernel + * + * Add a descriptor block and optionally a preceding immediate key to the local + * node's configuration ROM. + * + * The @key field specifies the upper 8 bits of the descriptor root directory + * pointer and the @data and @length fields specify the contents. The @key + * should be of the form 0xXX000000. The offset part of the root directory entry + * will be filled in by the kernel. + * + * If not 0, the @immediate field specifies an immediate key which will be + * inserted before the root directory pointer. + * + * If successful, the kernel adds the descriptor and writes back a handle to the + * kernel-side object to be used for later removal of the descriptor block and + * immediate key. + */ struct fw_cdev_add_descriptor { __u32 immediate; __u32 key; @@ -215,6 +332,14 @@ struct fw_cdev_add_descriptor { __u32 handle; }; +/** + * struct fw_cdev_remove_descriptor - Remove contents from the configuration ROM + * @handle: Handle to the descriptor, as returned by the kernel when the + * descriptor was added + * + * Remove a descriptor block and accompanying immediate key from the local + * node's configuration ROM. + */ struct fw_cdev_remove_descriptor { __u32 handle; }; @@ -222,12 +347,24 @@ struct fw_cdev_remove_descriptor { #define FW_CDEV_ISO_CONTEXT_TRANSMIT 0 #define FW_CDEV_ISO_CONTEXT_RECEIVE 1 -#define FW_CDEV_ISO_CONTEXT_MATCH_TAG0 1 -#define FW_CDEV_ISO_CONTEXT_MATCH_TAG1 2 -#define FW_CDEV_ISO_CONTEXT_MATCH_TAG2 4 -#define FW_CDEV_ISO_CONTEXT_MATCH_TAG3 8 -#define FW_CDEV_ISO_CONTEXT_MATCH_ALL_TAGS 15 - +/** + * struct fw_cdev_create_iso_context - Create a context for isochronous IO + * @type: %FW_CDEV_ISO_CONTEXT_TRANSMIT or %FW_CDEV_ISO_CONTEXT_RECEIVE + * @header_size: Header size to strip for receive contexts + * @channel: Channel to bind to + * @speed: Speed to transmit at + * @closure: To be returned in &fw_cdev_event_iso_interrupt + * @handle: Handle to context, written back by kernel + * + * Prior to sending or receiving isochronous I/O, a context must be created. + * The context records information about the transmit or receive configuration + * and typically maps to an underlying hardware resource. A context is set up + * for either sending or receiving. It is bound to a specific isochronous + * channel. + * + * If a context was successfully created, the kernel writes back a handle to the + * context, which must be passed in for subsequent operations on that context. + */ struct fw_cdev_create_iso_context { __u32 type; __u32 header_size; @@ -237,16 +374,52 @@ struct fw_cdev_create_iso_context { __u32 handle; }; +#define FW_CDEV_ISO_PAYLOAD_LENGTH(v) (v) +#define FW_CDEV_ISO_INTERRUPT (1 << 16) +#define FW_CDEV_ISO_SKIP (1 << 17) +#define FW_CDEV_ISO_SYNC (1 << 17) +#define FW_CDEV_ISO_TAG(v) ((v) << 18) +#define FW_CDEV_ISO_SY(v) ((v) << 20) +#define FW_CDEV_ISO_HEADER_LENGTH(v) ((v) << 24) + +/** + * struct fw_cdev_iso_packet - Isochronous packet + * @control: Contains the header length (8 uppermost bits), the sy field + * (4 bits), the tag field (2 bits), a sync flag (1 bit), + * a skip flag (1 bit), an interrupt flag (1 bit), and the + * payload length (16 lowermost bits) + * @header: Header and payload + * + * &struct fw_cdev_iso_packet is used to describe isochronous packet queues. + * + * Use the FW_CDEV_ISO_ macros to fill in @control. The sy and tag fields are + * specified by IEEE 1394a and IEC 61883. + * + * FIXME - finish this documentation + */ struct fw_cdev_iso_packet { - __u16 payload_length; /* Length of indirect payload. */ - __u32 interrupt : 1; /* Generate interrupt on this packet */ - __u32 skip : 1; /* Set to not send packet at all. */ - __u32 tag : 2; - __u32 sy : 4; - __u32 header_length : 8; /* Length of immediate header. */ + __u32 control; __u32 header[0]; }; +/** + * struct fw_cdev_queue_iso - Queue isochronous packets for I/O + * @packets: Userspace pointer to packet data + * @data: Pointer into mmap()'ed payload buffer + * @size: Size of packet data in bytes + * @handle: Isochronous context handle + * + * Queue a number of isochronous packets for reception or transmission. + * This ioctl takes a pointer to an array of &fw_cdev_iso_packet structs, + * which describe how to transmit from or receive into a contiguous region + * of a mmap()'ed payload buffer. As part of the packet descriptors, + * a series of headers can be supplied, which will be prepended to the + * payload during DMA. + * + * The kernel may or may not queue all packets, but will write back updated + * values of the @packets, @data and @size fields, so the ioctl can be + * resubmitted easily. + */ struct fw_cdev_queue_iso { __u64 packets; __u64 data; @@ -254,6 +427,23 @@ struct fw_cdev_queue_iso { __u32 handle; }; +#define FW_CDEV_ISO_CONTEXT_MATCH_TAG0 1 +#define FW_CDEV_ISO_CONTEXT_MATCH_TAG1 2 +#define FW_CDEV_ISO_CONTEXT_MATCH_TAG2 4 +#define FW_CDEV_ISO_CONTEXT_MATCH_TAG3 8 +#define FW_CDEV_ISO_CONTEXT_MATCH_ALL_TAGS 15 + +/** + * struct fw_cdev_start_iso - Start an isochronous transmission or reception + * @cycle: Cycle in which to start I/O. If @cycle is greater than or + * equal to 0, the I/O will start on that cycle. + * @sync: Determines the value to wait for for receive packets that have + * the %FW_CDEV_ISO_SYNC bit set + * @tags: Tag filter bit mask. Only valid for isochronous reception. + * Determines the tag values for which packets will be accepted. + * Use FW_CDEV_ISO_CONTEXT_MATCH_ macros to set @tags. + * @handle: Isochronous context handle within which to transmit or receive + */ struct fw_cdev_start_iso { __s32 cycle; __u32 sync; @@ -261,8 +451,12 @@ struct fw_cdev_start_iso { __u32 handle; }; +/** + * struct fw_cdev_stop_iso - Stop an isochronous transmission or reception + * @handle: Handle of isochronous context to stop + */ struct fw_cdev_stop_iso { __u32 handle; }; -#endif /* __fw_cdev_h */ +#endif /* _LINUX_FIREWIRE_CDEV_H */ diff --git a/libraw1394-juju-no-double-free-on-shutdown.patch b/libraw1394-juju-no-double-free-on-shutdown.patch index 4f35ca4..f05fd63 100644 --- a/libraw1394-juju-no-double-free-on-shutdown.patch +++ b/libraw1394-juju-no-double-free-on-shutdown.patch @@ -1,6 +1,6 @@ diff -Naurp libraw1394-1.3.0/juju/raw1394-iso.c libraw1394-1.3.0.fix/juju/raw1394-iso.c ---- libraw1394-1.3.0/juju/raw1394-iso.c 2007-10-19 16:05:09.000000000 -0400 -+++ libraw1394-1.3.0.fix/juju/raw1394-iso.c 2007-10-19 17:14:40.000000000 -0400 +--- libraw1394-1.3.0/juju/raw1394-iso.c 2007-10-22 13:55:58.000000000 -0400 ++++ libraw1394-1.3.0.fix/juju/raw1394-iso.c 2007-10-22 15:27:54.000000000 -0400 @@ -394,6 +394,7 @@ iso_init(raw1394handle_t handle, int typ handle->iso.fd = open(handle->local_filename, O_RDWR); if (handle->iso.fd < 0) { @@ -34,3 +34,18 @@ diff -Naurp libraw1394-1.3.0/juju/raw1394-iso.c libraw1394-1.3.0.fix/juju/raw139 return -1; } +@@ -515,8 +520,12 @@ void raw1394_iso_stop(raw1394handle_t ha + + void raw1394_iso_shutdown(raw1394handle_t handle) + { +- munmap(handle->iso.buffer, +- handle->iso.buf_packets * handle->iso.max_packet_size); ++ if (handle->iso.buffer) { ++ munmap(handle->iso.buffer, ++ handle->iso.buf_packets * handle->iso.max_packet_size); ++ handle->iso.buffer = NULL; ++ } + close(handle->iso.fd); + free(handle->iso.packets); ++ handle->iso.packets = NULL; + } diff --git a/libraw1394.spec b/libraw1394.spec index e8f1725..9bf1d9a 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 1.3.0 -Release: 2%{?dist} +Release: 3%{?dist} License: LGPL Group: System Environment/Libraries Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz @@ -79,6 +79,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Wed Oct 24 2007 Jarod Wilson - 1.3.0-3 +- Update firewire-cdev.h to match kernel + * Fri Oct 19 2007 Jarod Wilson - 1.3.0-2 - Fix the 'double free' crash on shutdown (#328011) From 0b651b445105869a550a0cc314a5688de38cad9c Mon Sep 17 00:00:00 2001 From: Jarod Wilson Date: Wed, 30 Jan 2008 19:52:39 +0000 Subject: [PATCH 044/100] - Use firewire-cdev.h provided by kernel-headers --- firewire-cdev.h | 462 -------------------------- libraw1394-juju-bitfield-update.patch | 51 +++ libraw1394.spec | 19 +- 3 files changed, 60 insertions(+), 472 deletions(-) delete mode 100644 firewire-cdev.h create mode 100644 libraw1394-juju-bitfield-update.patch diff --git a/firewire-cdev.h b/firewire-cdev.h deleted file mode 100644 index 1a45d6f..0000000 --- a/firewire-cdev.h +++ /dev/null @@ -1,462 +0,0 @@ -/* - * Char device interface. - * - * Copyright (C) 2005-2006 Kristian Hoegsberg - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _LINUX_FIREWIRE_CDEV_H -#define _LINUX_FIREWIRE_CDEV_H - -#include -#include -#include - -#define FW_CDEV_EVENT_BUS_RESET 0x00 -#define FW_CDEV_EVENT_RESPONSE 0x01 -#define FW_CDEV_EVENT_REQUEST 0x02 -#define FW_CDEV_EVENT_ISO_INTERRUPT 0x03 - -/** - * struct fw_cdev_event_common - Common part of all fw_cdev_event_ types - * @closure: For arbitrary use by userspace - * @type: Discriminates the fw_cdev_event_ types - * - * This struct may be used to access generic members of all fw_cdev_event_ - * types regardless of the specific type. - * - * Data passed in the @closure field for a request will be returned in the - * corresponding event. It is big enough to hold a pointer on all platforms. - * The ioctl used to set @closure depends on the @type of event. - */ -struct fw_cdev_event_common { - __u64 closure; - __u32 type; -}; - -/** - * struct fw_cdev_event_bus_reset - Sent when a bus reset occurred - * @closure: See &fw_cdev_event_common; set by %FW_CDEV_IOC_GET_INFO ioctl - * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_BUS_RESET - * @node_id: New node ID of this node - * @local_node_id: Node ID of the local node, i.e. of the controller - * @bm_node_id: Node ID of the bus manager - * @irm_node_id: Node ID of the iso resource manager - * @root_node_id: Node ID of the root node - * @generation: New bus generation - * - * This event is sent when the bus the device belongs to goes through a bus - * reset. It provides information about the new bus configuration, such as - * new node ID for this device, new root ID, and others. - */ -struct fw_cdev_event_bus_reset { - __u64 closure; - __u32 type; - __u32 node_id; - __u32 local_node_id; - __u32 bm_node_id; - __u32 irm_node_id; - __u32 root_node_id; - __u32 generation; -}; - -/** - * struct fw_cdev_event_response - Sent when a response packet was received - * @closure: See &fw_cdev_event_common; - * set by %FW_CDEV_IOC_SEND_REQUEST ioctl - * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_RESPONSE - * @rcode: Response code returned by the remote node - * @length: Data length, i.e. the response's payload size in bytes - * @data: Payload data, if any - * - * This event is sent when the stack receives a response to an outgoing request - * sent by %FW_CDEV_IOC_SEND_REQUEST ioctl. The payload data for responses - * carrying data (read and lock responses) follows immediately and can be - * accessed through the @data field. - */ -struct fw_cdev_event_response { - __u64 closure; - __u32 type; - __u32 rcode; - __u32 length; - __u32 data[0]; -}; - -/** - * struct fw_cdev_event_request - Sent on incoming request to an address region - * @closure: See &fw_cdev_event_common; set by %FW_CDEV_IOC_ALLOCATE ioctl - * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_REQUEST - * @tcode: Transaction code of the incoming request - * @offset: The offset into the 48-bit per-node address space - * @handle: Reference to the kernel-side pending request - * @length: Data length, i.e. the request's payload size in bytes - * @data: Incoming data, if any - * - * This event is sent when the stack receives an incoming request to an address - * region registered using the %FW_CDEV_IOC_ALLOCATE ioctl. The request is - * guaranteed to be completely contained in the specified region. Userspace is - * responsible for sending the response by %FW_CDEV_IOC_SEND_RESPONSE ioctl, - * using the same @handle. - * - * The payload data for requests carrying data (write and lock requests) - * follows immediately and can be accessed through the @data field. - */ -struct fw_cdev_event_request { - __u64 closure; - __u32 type; - __u32 tcode; - __u64 offset; - __u32 handle; - __u32 length; - __u32 data[0]; -}; - -/** - * struct fw_cdev_event_iso_interrupt - Sent when an iso packet was completed - * @closure: See &fw_cdev_event_common; - * set by %FW_CDEV_CREATE_ISO_CONTEXT ioctl - * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_ISO_INTERRUPT - * @cycle: Cycle counter of the interrupt packet - * @header_length: Total length of following headers, in bytes - * @header: Stripped headers, if any - * - * This event is sent when the controller has completed an &fw_cdev_iso_packet - * with the %FW_CDEV_ISO_INTERRUPT bit set. In the receive case, the headers - * stripped of all packets up until and including the interrupt packet are - * returned in the @header field. - */ -struct fw_cdev_event_iso_interrupt { - __u64 closure; - __u32 type; - __u32 cycle; - __u32 header_length; - __u32 header[0]; -}; - -/** - * union fw_cdev_event - Convenience union of fw_cdev_event_ types - * @common: Valid for all types - * @bus_reset: Valid if @common.type == %FW_CDEV_EVENT_BUS_RESET - * @response: Valid if @common.type == %FW_CDEV_EVENT_RESPONSE - * @request: Valid if @common.type == %FW_CDEV_EVENT_REQUEST - * @iso_interrupt: Valid if @common.type == %FW_CDEV_EVENT_ISO_INTERRUPT - * - * Convenience union for userspace use. Events could be read(2) into a char - * buffer and then cast to this union for further processing. - */ -union fw_cdev_event { - struct fw_cdev_event_common common; - struct fw_cdev_event_bus_reset bus_reset; - struct fw_cdev_event_response response; - struct fw_cdev_event_request request; - struct fw_cdev_event_iso_interrupt iso_interrupt; -}; - -#define FW_CDEV_IOC_GET_INFO _IOWR('#', 0x00, struct fw_cdev_get_info) -#define FW_CDEV_IOC_SEND_REQUEST _IOW('#', 0x01, struct fw_cdev_send_request) -#define FW_CDEV_IOC_ALLOCATE _IOWR('#', 0x02, struct fw_cdev_allocate) -#define FW_CDEV_IOC_DEALLOCATE _IOW('#', 0x03, struct fw_cdev_deallocate) -#define FW_CDEV_IOC_SEND_RESPONSE _IOW('#', 0x04, struct fw_cdev_send_response) -#define FW_CDEV_IOC_INITIATE_BUS_RESET _IOW('#', 0x05, struct fw_cdev_initiate_bus_reset) -#define FW_CDEV_IOC_ADD_DESCRIPTOR _IOWR('#', 0x06, struct fw_cdev_add_descriptor) -#define FW_CDEV_IOC_REMOVE_DESCRIPTOR _IOW('#', 0x07, struct fw_cdev_remove_descriptor) - -#define FW_CDEV_IOC_CREATE_ISO_CONTEXT _IOWR('#', 0x08, struct fw_cdev_create_iso_context) -#define FW_CDEV_IOC_QUEUE_ISO _IOWR('#', 0x09, struct fw_cdev_queue_iso) -#define FW_CDEV_IOC_START_ISO _IOW('#', 0x0a, struct fw_cdev_start_iso) -#define FW_CDEV_IOC_STOP_ISO _IOW('#', 0x0b, struct fw_cdev_stop_iso) - -/* FW_CDEV_VERSION History - * - * 1 Feb 18, 2007: Initial version. - */ -#define FW_CDEV_VERSION 1 - -/** - * struct fw_cdev_get_info - General purpose information ioctl - * @version: The version field is just a running serial number. - * We never break backwards compatibility, but may add more - * structs and ioctls in later revisions. - * @rom_length: If @rom is non-zero, at most rom_length bytes of configuration - * ROM will be copied into that user space address. In either - * case, @rom_length is updated with the actual length of the - * configuration ROM. - * @rom: If non-zero, address of a buffer to be filled by a copy of the - * local node's configuration ROM - * @bus_reset: If non-zero, address of a buffer to be filled by a - * &struct fw_cdev_event_bus_reset with the current state - * of the bus. This does not cause a bus reset to happen. - * @bus_reset_closure: Value of &closure in this and subsequent bus reset events - * @card: The index of the card this device belongs to - */ -struct fw_cdev_get_info { - __u32 version; - __u32 rom_length; - __u64 rom; - __u64 bus_reset; - __u64 bus_reset_closure; - __u32 card; -}; - -/** - * struct fw_cdev_send_request - Send an asynchronous request packet - * @tcode: Transaction code of the request - * @length: Length of outgoing payload, in bytes - * @offset: 48-bit offset at destination node - * @closure: Passed back to userspace in the response event - * @data: Userspace pointer to payload - * @generation: The bus generation where packet is valid - * - * Send a request to the device. This ioctl implements all outgoing requests. - * Both quadlet and block request specify the payload as a pointer to the data - * in the @data field. Once the transaction completes, the kernel writes an - * &fw_cdev_event_request event back. The @closure field is passed back to - * user space in the response event. - */ -struct fw_cdev_send_request { - __u32 tcode; - __u32 length; - __u64 offset; - __u64 closure; - __u64 data; - __u32 generation; -}; - -/** - * struct fw_cdev_send_response - Send an asynchronous response packet - * @rcode: Response code as determined by the userspace handler - * @length: Length of outgoing payload, in bytes - * @data: Userspace pointer to payload - * @handle: The handle from the &fw_cdev_event_request - * - * Send a response to an incoming request. By setting up an address range using - * the %FW_CDEV_IOC_ALLOCATE ioctl, userspace can listen for incoming requests. An - * incoming request will generate an %FW_CDEV_EVENT_REQUEST, and userspace must - * send a reply using this ioctl. The event has a handle to the kernel-side - * pending transaction, which should be used with this ioctl. - */ -struct fw_cdev_send_response { - __u32 rcode; - __u32 length; - __u64 data; - __u32 handle; -}; - -/** - * struct fw_cdev_allocate - Allocate a CSR address range - * @offset: Start offset of the address range - * @closure: To be passed back to userspace in request events - * @length: Length of the address range, in bytes - * @handle: Handle to the allocation, written by the kernel - * - * Allocate an address range in the 48-bit address space on the local node - * (the controller). This allows userspace to listen for requests with an - * offset within that address range. When the kernel receives a request - * within the range, an &fw_cdev_event_request event will be written back. - * The @closure field is passed back to userspace in the response event. - * The @handle field is an out parameter, returning a handle to the allocated - * range to be used for later deallocation of the range. - */ -struct fw_cdev_allocate { - __u64 offset; - __u64 closure; - __u32 length; - __u32 handle; -}; - -/** - * struct fw_cdev_deallocate - Free an address range allocation - * @handle: Handle to the address range, as returned by the kernel when the - * range was allocated - */ -struct fw_cdev_deallocate { - __u32 handle; -}; - -#define FW_CDEV_LONG_RESET 0 -#define FW_CDEV_SHORT_RESET 1 - -/** - * struct fw_cdev_initiate_bus_reset - Initiate a bus reset - * @type: %FW_CDEV_SHORT_RESET or %FW_CDEV_LONG_RESET - * - * Initiate a bus reset for the bus this device is on. The bus reset can be - * either the original (long) bus reset or the arbitrated (short) bus reset - * introduced in 1394a-2000. - */ -struct fw_cdev_initiate_bus_reset { - __u32 type; /* FW_CDEV_SHORT_RESET or FW_CDEV_LONG_RESET */ -}; - -/** - * struct fw_cdev_add_descriptor - Add contents to the local node's config ROM - * @immediate: If non-zero, immediate key to insert before pointer - * @key: Upper 8 bits of root directory pointer - * @data: Userspace pointer to contents of descriptor block - * @length: Length of descriptor block data, in bytes - * @handle: Handle to the descriptor, written by the kernel - * - * Add a descriptor block and optionally a preceding immediate key to the local - * node's configuration ROM. - * - * The @key field specifies the upper 8 bits of the descriptor root directory - * pointer and the @data and @length fields specify the contents. The @key - * should be of the form 0xXX000000. The offset part of the root directory entry - * will be filled in by the kernel. - * - * If not 0, the @immediate field specifies an immediate key which will be - * inserted before the root directory pointer. - * - * If successful, the kernel adds the descriptor and writes back a handle to the - * kernel-side object to be used for later removal of the descriptor block and - * immediate key. - */ -struct fw_cdev_add_descriptor { - __u32 immediate; - __u32 key; - __u64 data; - __u32 length; - __u32 handle; -}; - -/** - * struct fw_cdev_remove_descriptor - Remove contents from the configuration ROM - * @handle: Handle to the descriptor, as returned by the kernel when the - * descriptor was added - * - * Remove a descriptor block and accompanying immediate key from the local - * node's configuration ROM. - */ -struct fw_cdev_remove_descriptor { - __u32 handle; -}; - -#define FW_CDEV_ISO_CONTEXT_TRANSMIT 0 -#define FW_CDEV_ISO_CONTEXT_RECEIVE 1 - -/** - * struct fw_cdev_create_iso_context - Create a context for isochronous IO - * @type: %FW_CDEV_ISO_CONTEXT_TRANSMIT or %FW_CDEV_ISO_CONTEXT_RECEIVE - * @header_size: Header size to strip for receive contexts - * @channel: Channel to bind to - * @speed: Speed to transmit at - * @closure: To be returned in &fw_cdev_event_iso_interrupt - * @handle: Handle to context, written back by kernel - * - * Prior to sending or receiving isochronous I/O, a context must be created. - * The context records information about the transmit or receive configuration - * and typically maps to an underlying hardware resource. A context is set up - * for either sending or receiving. It is bound to a specific isochronous - * channel. - * - * If a context was successfully created, the kernel writes back a handle to the - * context, which must be passed in for subsequent operations on that context. - */ -struct fw_cdev_create_iso_context { - __u32 type; - __u32 header_size; - __u32 channel; - __u32 speed; - __u64 closure; - __u32 handle; -}; - -#define FW_CDEV_ISO_PAYLOAD_LENGTH(v) (v) -#define FW_CDEV_ISO_INTERRUPT (1 << 16) -#define FW_CDEV_ISO_SKIP (1 << 17) -#define FW_CDEV_ISO_SYNC (1 << 17) -#define FW_CDEV_ISO_TAG(v) ((v) << 18) -#define FW_CDEV_ISO_SY(v) ((v) << 20) -#define FW_CDEV_ISO_HEADER_LENGTH(v) ((v) << 24) - -/** - * struct fw_cdev_iso_packet - Isochronous packet - * @control: Contains the header length (8 uppermost bits), the sy field - * (4 bits), the tag field (2 bits), a sync flag (1 bit), - * a skip flag (1 bit), an interrupt flag (1 bit), and the - * payload length (16 lowermost bits) - * @header: Header and payload - * - * &struct fw_cdev_iso_packet is used to describe isochronous packet queues. - * - * Use the FW_CDEV_ISO_ macros to fill in @control. The sy and tag fields are - * specified by IEEE 1394a and IEC 61883. - * - * FIXME - finish this documentation - */ -struct fw_cdev_iso_packet { - __u32 control; - __u32 header[0]; -}; - -/** - * struct fw_cdev_queue_iso - Queue isochronous packets for I/O - * @packets: Userspace pointer to packet data - * @data: Pointer into mmap()'ed payload buffer - * @size: Size of packet data in bytes - * @handle: Isochronous context handle - * - * Queue a number of isochronous packets for reception or transmission. - * This ioctl takes a pointer to an array of &fw_cdev_iso_packet structs, - * which describe how to transmit from or receive into a contiguous region - * of a mmap()'ed payload buffer. As part of the packet descriptors, - * a series of headers can be supplied, which will be prepended to the - * payload during DMA. - * - * The kernel may or may not queue all packets, but will write back updated - * values of the @packets, @data and @size fields, so the ioctl can be - * resubmitted easily. - */ -struct fw_cdev_queue_iso { - __u64 packets; - __u64 data; - __u32 size; - __u32 handle; -}; - -#define FW_CDEV_ISO_CONTEXT_MATCH_TAG0 1 -#define FW_CDEV_ISO_CONTEXT_MATCH_TAG1 2 -#define FW_CDEV_ISO_CONTEXT_MATCH_TAG2 4 -#define FW_CDEV_ISO_CONTEXT_MATCH_TAG3 8 -#define FW_CDEV_ISO_CONTEXT_MATCH_ALL_TAGS 15 - -/** - * struct fw_cdev_start_iso - Start an isochronous transmission or reception - * @cycle: Cycle in which to start I/O. If @cycle is greater than or - * equal to 0, the I/O will start on that cycle. - * @sync: Determines the value to wait for for receive packets that have - * the %FW_CDEV_ISO_SYNC bit set - * @tags: Tag filter bit mask. Only valid for isochronous reception. - * Determines the tag values for which packets will be accepted. - * Use FW_CDEV_ISO_CONTEXT_MATCH_ macros to set @tags. - * @handle: Isochronous context handle within which to transmit or receive - */ -struct fw_cdev_start_iso { - __s32 cycle; - __u32 sync; - __u32 tags; - __u32 handle; -}; - -/** - * struct fw_cdev_stop_iso - Stop an isochronous transmission or reception - * @handle: Handle of isochronous context to stop - */ -struct fw_cdev_stop_iso { - __u32 handle; -}; - -#endif /* _LINUX_FIREWIRE_CDEV_H */ diff --git a/libraw1394-juju-bitfield-update.patch b/libraw1394-juju-bitfield-update.patch new file mode 100644 index 0000000..9df17f6 --- /dev/null +++ b/libraw1394-juju-bitfield-update.patch @@ -0,0 +1,51 @@ +diff -Naurp libraw1394-1.3.0/juju/juju.h libraw1394-1.3.0.bitfield/juju/juju.h +--- libraw1394-1.3.0/juju/juju.h 2007-10-24 16:47:26.000000000 -0400 ++++ libraw1394-1.3.0.bitfield/juju/juju.h 2007-10-24 16:50:47.000000000 -0400 +@@ -29,8 +29,6 @@ + #include "../src/csr.h" + #include "config.h" + +-#define ACK_COMPLETE 1 +- + #define ptr_to_u64(p) ((__u64)(unsigned long)(p)) + #define u64_to_ptr(p) ((void *)(unsigned long)(p)) + +diff -Naurp libraw1394-1.3.0/juju/raw1394-iso.c libraw1394-1.3.0.bitfield/juju/raw1394-iso.c +--- libraw1394-1.3.0/juju/raw1394-iso.c 2007-10-24 16:47:26.000000000 -0400 ++++ libraw1394-1.3.0.bitfield/juju/raw1394-iso.c 2007-10-24 16:53:06.000000000 -0400 +@@ -40,13 +40,14 @@ queue_packet(raw1394handle_t handle, + int err; + + p = &handle->iso.packets[handle->iso.packet_index]; +- p->payload_length = length; +- p->interrupt = +- handle->iso.packet_phase == handle->iso.irq_interval - 1; +- p->skip = 0; +- p->tag = tag; +- p->sy = sy; +- p->header_length = header_length; ++ p->control = ++ FW_CDEV_ISO_PAYLOAD_LENGTH(length) | ++ FW_CDEV_ISO_TAG(tag) | ++ FW_CDEV_ISO_SY(sy) | ++ FW_CDEV_ISO_HEADER_LENGTH(header_length); ++ ++ if (handle->iso.packet_phase == handle->iso.irq_interval - 1) ++ p->control |= FW_CDEV_ISO_INTERRUPT; + + handle->iso.head += length; + handle->iso.packet_count++; +@@ -291,12 +292,7 @@ int raw1394_iso_xmit_sync(raw1394handle_ + struct fw_cdev_queue_iso queue_iso; + int len; + +- skip.payload_length = 0; +- skip.interrupt = 1; +- skip.skip = 1; +- skip.tag = 0; +- skip.sy = 0; +- skip.header_length = 0; ++ skip.control = FW_CDEV_ISO_INTERRUPT | FW_CDEV_ISO_SKIP; + + queue_iso.packets = ptr_to_u64(&skip); + queue_iso.size = sizeof skip; diff --git a/libraw1394.spec b/libraw1394.spec index 9bf1d9a..d0b1d92 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,18 +1,18 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 1.3.0 -Release: 3%{?dist} +Release: 4%{?dist} License: LGPL Group: System Environment/Libraries Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz URL: http://www.linux1394.org/ ExcludeArch: s390 s390x BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -BuildRequires: autoconf automake libtool +BuildRequires: autoconf automake libtool kernel-headers -Source1: firewire-cdev.h Patch0: libraw1394-juju.patch Patch1: libraw1394-juju-no-double-free-on-shutdown.patch +Patch2: libraw1394-juju-bitfield-update.patch %description The libraw1394 library provides direct access to the IEEE-1394 bus through @@ -31,14 +31,9 @@ Development libraries needed to build applications against libraw1394. %patch0 -p1 -b .juju %patch1 -p1 -b .free +%patch2 -p1 -b .bitf %build - -if test ! -e %{_builddir}/linux/firewire-cdev.h; then - mkdir %{_builddir}/linux - cp %{_sourcedir}/firewire-cdev.h %{_builddir}/linux -fi - aclocal autoheader autoconf @@ -79,8 +74,12 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Wed Jan 30 2008 Jarod Wilson - 1.3.0-4 +- Use firewire-cdev.h provided by kernel-headers + * Wed Oct 24 2007 Jarod Wilson - 1.3.0-3 -- Update firewire-cdev.h to match kernel +- Update firewire-cdev.h to match kernel and eliminate + bitfield usage, fixes capture on big-endian systems (#345221) * Fri Oct 19 2007 Jarod Wilson - 1.3.0-2 - Fix the 'double free' crash on shutdown (#328011) From eea6dc24f7352bf479c12786ef9582f97b8d5dc8 Mon Sep 17 00:00:00 2001 From: Jarod Wilson Date: Tue, 26 Feb 2008 14:32:58 +0000 Subject: [PATCH 045/100] - Update license and kill an errant tab (#226039) --- libraw1394.spec | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libraw1394.spec b/libraw1394.spec index d0b1d92..42acbe1 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,14 +1,14 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 1.3.0 -Release: 4%{?dist} -License: LGPL +Release: 5%{?dist} +License: LGPLv2+ Group: System Environment/Libraries Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz URL: http://www.linux1394.org/ ExcludeArch: s390 s390x BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -BuildRequires: autoconf automake libtool kernel-headers +BuildRequires: autoconf automake libtool kernel-headers Patch0: libraw1394-juju.patch Patch1: libraw1394-juju-no-double-free-on-shutdown.patch @@ -74,6 +74,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Tue Feb 26 2008 Jarod Wilson - 1.3.0-5 +- Update license and kill an errant tab (#226039) + * Wed Jan 30 2008 Jarod Wilson - 1.3.0-4 - Use firewire-cdev.h provided by kernel-headers From 37839e2a1748f4094ba5bf6cbdb0f9685f90c579 Mon Sep 17 00:00:00 2001 From: Jarod Wilson Date: Mon, 28 Apr 2008 22:09:15 +0000 Subject: [PATCH 046/100] - Unmap the correct memory range on iso receive teardown, fixes segfault on exit from dvgrab (Mladen Kuntner, #444354) --- ...-juju-munmap-correct-max_packet_size.patch | 21 +++++++++++++++++++ libraw1394.spec | 10 +++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 libraw1394-juju-munmap-correct-max_packet_size.patch diff --git a/libraw1394-juju-munmap-correct-max_packet_size.patch b/libraw1394-juju-munmap-correct-max_packet_size.patch new file mode 100644 index 0000000..8903436 --- /dev/null +++ b/libraw1394-juju-munmap-correct-max_packet_size.patch @@ -0,0 +1,21 @@ +diff -Naurp libraw1394-1.3.0/juju/raw1394-iso.c libraw1394-1.3.0.fix/juju/raw1394-iso.c +--- libraw1394-1.3.0/juju/raw1394-iso.c 2008-04-28 13:57:30.000000000 -0400 ++++ libraw1394-1.3.0.fix/juju/raw1394-iso.c 2008-04-28 14:06:21.000000000 -0400 +@@ -421,7 +421,7 @@ iso_init(raw1394handle_t handle, int typ + } + + handle->iso.buffer = +- mmap(NULL, buf_packets * max_packet_size, ++ mmap(NULL, buf_packets * handle->iso.max_packet_size, + prot, MAP_SHARED, handle->iso.fd, 0); + + if (handle->iso.buffer == MAP_FAILED) { +@@ -432,7 +432,7 @@ iso_init(raw1394handle_t handle, int typ + } + + handle->iso.buffer_end = handle->iso.buffer + +- buf_packets * max_packet_size; ++ buf_packets * handle->iso.max_packet_size; + handle->iso.head = handle->iso.buffer; + handle->iso.tail = handle->iso.buffer; + handle->iso.first_payload = handle->iso.buffer; diff --git a/libraw1394.spec b/libraw1394.spec index 42acbe1..48d6fe0 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 1.3.0 -Release: 5%{?dist} +Release: 6%{?dist} License: LGPLv2+ Group: System Environment/Libraries Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz @@ -13,6 +13,7 @@ BuildRequires: autoconf automake libtool kernel-headers Patch0: libraw1394-juju.patch Patch1: libraw1394-juju-no-double-free-on-shutdown.patch Patch2: libraw1394-juju-bitfield-update.patch +Patch3: libraw1394-juju-munmap-correct-max_packet_size.patch %description The libraw1394 library provides direct access to the IEEE-1394 bus through @@ -29,9 +30,10 @@ Development libraries needed to build applications against libraw1394. %prep %setup -q -%patch0 -p1 -b .juju +%patch0 -p1 %patch1 -p1 -b .free %patch2 -p1 -b .bitf +%patch3 -p1 -b .munmap %build aclocal @@ -74,6 +76,10 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Mon Apr 28 2008 Jarod Wilson - 1.3.0-6 +- Unmap the correct memory range on iso receive teardown, fixes + segfault on exit from dvgrab (Mladen Kuntner, #444354) + * Tue Feb 26 2008 Jarod Wilson - 1.3.0-5 - Update license and kill an errant tab (#226039) From 8d810a51d303aaa46448e49bdb1a09a4866414fa Mon Sep 17 00:00:00 2001 From: Jarod Wilson Date: Tue, 17 Jun 2008 15:53:04 +0000 Subject: [PATCH 047/100] - Update to pre-2.0.0 git tree, which features merged "juju" firewire stack support, enabled simultaneously with classic ieee1394 support --- .cvsignore | 1 + libraw1394-juju-bitfield-update.patch | 51 - ...-juju-munmap-correct-max_packet_size.patch | 21 - ...1394-juju-no-double-free-on-shutdown.patch | 51 - libraw1394-juju.patch | 2334 ----------------- ...aw1394-memset-and-patch-up-leaks-git.patch | 140 + libraw1394.spec | 38 +- sources | 2 +- 8 files changed, 164 insertions(+), 2474 deletions(-) delete mode 100644 libraw1394-juju-bitfield-update.patch delete mode 100644 libraw1394-juju-munmap-correct-max_packet_size.patch delete mode 100644 libraw1394-juju-no-double-free-on-shutdown.patch delete mode 100644 libraw1394-juju.patch create mode 100644 libraw1394-memset-and-patch-up-leaks-git.patch diff --git a/.cvsignore b/.cvsignore index ad0dec6..750d5f4 100644 --- a/.cvsignore +++ b/.cvsignore @@ -2,3 +2,4 @@ libraw1394-1.2.0.tar.gz libraw1394-1.2.1.tar.gz fw-device-cdev.h libraw1394-1.3.0.tar.gz +libraw1394-2.0.0-20080430_git.tar.bz2 diff --git a/libraw1394-juju-bitfield-update.patch b/libraw1394-juju-bitfield-update.patch deleted file mode 100644 index 9df17f6..0000000 --- a/libraw1394-juju-bitfield-update.patch +++ /dev/null @@ -1,51 +0,0 @@ -diff -Naurp libraw1394-1.3.0/juju/juju.h libraw1394-1.3.0.bitfield/juju/juju.h ---- libraw1394-1.3.0/juju/juju.h 2007-10-24 16:47:26.000000000 -0400 -+++ libraw1394-1.3.0.bitfield/juju/juju.h 2007-10-24 16:50:47.000000000 -0400 -@@ -29,8 +29,6 @@ - #include "../src/csr.h" - #include "config.h" - --#define ACK_COMPLETE 1 -- - #define ptr_to_u64(p) ((__u64)(unsigned long)(p)) - #define u64_to_ptr(p) ((void *)(unsigned long)(p)) - -diff -Naurp libraw1394-1.3.0/juju/raw1394-iso.c libraw1394-1.3.0.bitfield/juju/raw1394-iso.c ---- libraw1394-1.3.0/juju/raw1394-iso.c 2007-10-24 16:47:26.000000000 -0400 -+++ libraw1394-1.3.0.bitfield/juju/raw1394-iso.c 2007-10-24 16:53:06.000000000 -0400 -@@ -40,13 +40,14 @@ queue_packet(raw1394handle_t handle, - int err; - - p = &handle->iso.packets[handle->iso.packet_index]; -- p->payload_length = length; -- p->interrupt = -- handle->iso.packet_phase == handle->iso.irq_interval - 1; -- p->skip = 0; -- p->tag = tag; -- p->sy = sy; -- p->header_length = header_length; -+ p->control = -+ FW_CDEV_ISO_PAYLOAD_LENGTH(length) | -+ FW_CDEV_ISO_TAG(tag) | -+ FW_CDEV_ISO_SY(sy) | -+ FW_CDEV_ISO_HEADER_LENGTH(header_length); -+ -+ if (handle->iso.packet_phase == handle->iso.irq_interval - 1) -+ p->control |= FW_CDEV_ISO_INTERRUPT; - - handle->iso.head += length; - handle->iso.packet_count++; -@@ -291,12 +292,7 @@ int raw1394_iso_xmit_sync(raw1394handle_ - struct fw_cdev_queue_iso queue_iso; - int len; - -- skip.payload_length = 0; -- skip.interrupt = 1; -- skip.skip = 1; -- skip.tag = 0; -- skip.sy = 0; -- skip.header_length = 0; -+ skip.control = FW_CDEV_ISO_INTERRUPT | FW_CDEV_ISO_SKIP; - - queue_iso.packets = ptr_to_u64(&skip); - queue_iso.size = sizeof skip; diff --git a/libraw1394-juju-munmap-correct-max_packet_size.patch b/libraw1394-juju-munmap-correct-max_packet_size.patch deleted file mode 100644 index 8903436..0000000 --- a/libraw1394-juju-munmap-correct-max_packet_size.patch +++ /dev/null @@ -1,21 +0,0 @@ -diff -Naurp libraw1394-1.3.0/juju/raw1394-iso.c libraw1394-1.3.0.fix/juju/raw1394-iso.c ---- libraw1394-1.3.0/juju/raw1394-iso.c 2008-04-28 13:57:30.000000000 -0400 -+++ libraw1394-1.3.0.fix/juju/raw1394-iso.c 2008-04-28 14:06:21.000000000 -0400 -@@ -421,7 +421,7 @@ iso_init(raw1394handle_t handle, int typ - } - - handle->iso.buffer = -- mmap(NULL, buf_packets * max_packet_size, -+ mmap(NULL, buf_packets * handle->iso.max_packet_size, - prot, MAP_SHARED, handle->iso.fd, 0); - - if (handle->iso.buffer == MAP_FAILED) { -@@ -432,7 +432,7 @@ iso_init(raw1394handle_t handle, int typ - } - - handle->iso.buffer_end = handle->iso.buffer + -- buf_packets * max_packet_size; -+ buf_packets * handle->iso.max_packet_size; - handle->iso.head = handle->iso.buffer; - handle->iso.tail = handle->iso.buffer; - handle->iso.first_payload = handle->iso.buffer; diff --git a/libraw1394-juju-no-double-free-on-shutdown.patch b/libraw1394-juju-no-double-free-on-shutdown.patch deleted file mode 100644 index f05fd63..0000000 --- a/libraw1394-juju-no-double-free-on-shutdown.patch +++ /dev/null @@ -1,51 +0,0 @@ -diff -Naurp libraw1394-1.3.0/juju/raw1394-iso.c libraw1394-1.3.0.fix/juju/raw1394-iso.c ---- libraw1394-1.3.0/juju/raw1394-iso.c 2007-10-22 13:55:58.000000000 -0400 -+++ libraw1394-1.3.0.fix/juju/raw1394-iso.c 2007-10-22 15:27:54.000000000 -0400 -@@ -394,6 +394,7 @@ iso_init(raw1394handle_t handle, int typ - handle->iso.fd = open(handle->local_filename, O_RDWR); - if (handle->iso.fd < 0) { - free(handle->iso.packets); -+ handle->iso.packets = NULL; - return -1; - } - -@@ -404,6 +405,7 @@ iso_init(raw1394handle_t handle, int typ - handle->iso.fd, &ep) < 0) { - close(handle->iso.fd); - free(handle->iso.packets); -+ handle->iso.packets = NULL; - return -1; - } - -@@ -417,6 +419,8 @@ iso_init(raw1394handle_t handle, int typ - if (retval < 0) { - close(handle->iso.fd); - free(handle->iso.packets); -+ handle->iso.packets = NULL; -+ printf("ioctl call failed, retval = %d\n", retval); - return retval; - } - -@@ -427,6 +431,7 @@ iso_init(raw1394handle_t handle, int typ - if (handle->iso.buffer == MAP_FAILED) { - close(handle->iso.fd); - free(handle->iso.packets); -+ handle->iso.packets = NULL; - return -1; - } - -@@ -515,8 +520,12 @@ void raw1394_iso_stop(raw1394handle_t ha - - void raw1394_iso_shutdown(raw1394handle_t handle) - { -- munmap(handle->iso.buffer, -- handle->iso.buf_packets * handle->iso.max_packet_size); -+ if (handle->iso.buffer) { -+ munmap(handle->iso.buffer, -+ handle->iso.buf_packets * handle->iso.max_packet_size); -+ handle->iso.buffer = NULL; -+ } - close(handle->iso.fd); - free(handle->iso.packets); -+ handle->iso.packets = NULL; - } diff --git a/libraw1394-juju.patch b/libraw1394-juju.patch deleted file mode 100644 index fe2d80b..0000000 --- a/libraw1394-juju.patch +++ /dev/null @@ -1,2334 +0,0 @@ -diff -Naurp libraw1394-1.3.0.orig/configure.ac libraw1394-1.3.0/configure.ac ---- libraw1394-1.3.0.orig/configure.ac 2007-05-30 01:32:37.000000000 -0400 -+++ libraw1394-1.3.0/configure.ac 2007-10-18 22:21:34.000000000 -0400 -@@ -24,6 +24,28 @@ AC_SUBST(lt_major) - AC_SUBST(lt_revision) - AC_SUBST(lt_age) - -+AC_ARG_WITH(juju-dir,[ --with-juju-dir= Path to juju include files]) -+if ! test -z "$with_juju_dir" ; then -+ JUJU_DIR="$with_juju_dir" -+ LIB_SUBDIR=juju -+ AC_SUBST(JUJU_DIR) -+else -+ LIB_SUBDIR=src -+fi -+AC_SUBST(LIB_SUBDIR) -+ -+AC_ARG_WITH(fw-device-prefix, -+ [ --with-fw-device-prefix= Prefix of firewire device file names (default "fw").], -+ [FW_DEVICE_PREFIX="\"$withval\""], [FW_DEVICE_PREFIX="\"fw\""]) -+AC_ARG_WITH(fw-device-dir, -+ [ --with-fw-device-dir= Directory to watch for firewire device files (default "/dev").], -+ [FW_DEVICE_DIR="\"$withval\""], [FW_DEVICE_DIR="\"/dev\""]) -+ -+AC_DEFINE_UNQUOTED(FW_DEVICE_PREFIX, $FW_DEVICE_PREFIX, -+ [Prefix of firewire device file names.]) -+AC_DEFINE_UNQUOTED(FW_DEVICE_DIR, $FW_DEVICE_DIR, -+ [Directory to watch for firewire device files.]) -+ - dnl Check to see if valgrind is available - AC_ARG_WITH(valgrind, AC_HELP_STRING([--with-valgrind],[compile with valgrind support])) - if test x$with_valgrind = xyes ; then -@@ -36,6 +58,7 @@ Makefile - libraw1394.pc - libraw1394.spec - src/Makefile -+juju/Makefile - tools/Makefile - doc/Makefile - doc/testlibraw.1 -diff -Naurp libraw1394-1.3.0.orig/juju/juju.h libraw1394-1.3.0/juju/juju.h ---- libraw1394-1.3.0.orig/juju/juju.h 1969-12-31 19:00:00.000000000 -0500 -+++ libraw1394-1.3.0/juju/juju.h 2007-10-18 22:18:46.000000000 -0400 -@@ -0,0 +1,143 @@ -+/* -*- c-basic-offset: 8 -*- -+ * -+ * juju.h -- Internal header file for raw1394 emulation -+ * -+ * Copyright (C) 2007 Kristian Hoegsberg -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software Foundation, -+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+ */ -+ -+#ifndef __juju_h -+#define __juju_h -+ -+#include -+#include -+#include -+#include "../src/raw1394.h" -+#include "../src/csr.h" -+#include "config.h" -+ -+#define ACK_COMPLETE 1 -+ -+#define ptr_to_u64(p) ((__u64)(unsigned long)(p)) -+#define u64_to_ptr(p) ((void *)(unsigned long)(p)) -+ -+static inline __u32 -+be32_to_cpu(__u32 q) -+{ -+ union { char c[4]; __u32 q; } u = { { 1, 0, 0, 0 } }; -+ -+ return u.q == 1 ? bswap_32(q) : q; -+} -+ -+static inline __u32 -+cpu_to_be32(__u32 q) -+{ -+ return be32_to_cpu(q); -+} -+ -+#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0]) -+ -+#define BUFFER_SIZE (16 * 1024) -+ -+#define MAX_PORTS 16 -+ -+struct epoll_closure { -+ int (*func)(raw1394handle_t handle, -+ struct epoll_closure *closure, __uint32_t events); -+}; -+ -+struct port { -+ char device_file[32]; -+ char *name; -+ int node_count; -+ int card; -+}; -+ -+#define MAX_DEVICES 63 -+#define FILENAME_SIZE 16 -+ -+struct device { -+ struct epoll_closure closure; -+ int fd; -+ int node_id; -+ int generation; -+ char filename[FILENAME_SIZE]; -+}; -+ -+struct request_closure { -+ void *data; -+ size_t length; -+ unsigned long tag; -+ struct raw1394_reqhandle reqhandle; -+}; -+ -+struct allocation; -+ -+struct raw1394_handle { -+ struct port ports[MAX_PORTS]; -+ int port_count; -+ int err; -+ int generation; -+ void *user_data; -+ int notify_bus_reset; -+ -+ bus_reset_handler_t bus_reset_handler; -+ tag_handler_t tag_handler; -+ arm_tag_handler_t arm_tag_handler; -+ fcp_handler_t fcp_handler; -+ __u32 fcp_allocation_handle; -+ struct allocation *allocations; -+ -+ int epoll_fd; -+ int inotify_fd; -+ int inotify_watch; -+ int pipe_fds[2]; -+ -+ struct epoll_closure pipe_closure; -+ struct epoll_closure inotify_closure; -+ -+ struct device devices[MAX_DEVICES]; -+ int nodes[MAX_DEVICES]; -+ int local_fd; -+ char local_filename[FILENAME_SIZE]; -+ -+ struct fw_cdev_event_bus_reset reset; -+ -+ struct { -+ struct epoll_closure closure; -+ int fd; -+ int type; -+ int irq_interval; -+ int packet_phase; -+ int packet_count; -+ int packet_index; -+ int buf_packets; -+ int max_packet_size; -+ int prebuffer; -+ int start_on_cycle; -+ enum raw1394_iso_dma_recv_mode recv_mode; -+ raw1394_iso_xmit_handler_t xmit_handler; -+ raw1394_iso_recv_handler_t recv_handler; -+ unsigned char *buffer, *buffer_end, *head; -+ unsigned char *tail, *first_payload; -+ -+ struct fw_cdev_iso_packet *packets; -+ } iso; -+ -+ char buffer[BUFFER_SIZE]; -+}; -+ -+#endif -diff -Naurp libraw1394-1.3.0.orig/juju/Makefile.am libraw1394-1.3.0/juju/Makefile.am ---- libraw1394-1.3.0.orig/juju/Makefile.am 1969-12-31 19:00:00.000000000 -0500 -+++ libraw1394-1.3.0/juju/Makefile.am 2007-10-18 22:18:46.000000000 -0400 -@@ -0,0 +1,8 @@ -+lib_LTLIBRARIES = libraw1394.la -+ -+INCLUDES = -I$(JUJU_DIR) -+libraw1394_la_LDFLAGS = -version-info @lt_major@:@lt_revision@:@lt_age@ -+ -+libraw1394_la_SOURCES = raw1394.c raw1394-iso.c juju.h -+ -+pkginclude_HEADERS = ../src/raw1394.h ../src/csr.h ../src/ieee1394.h -diff -Naurp libraw1394-1.3.0.orig/juju/raw1394.c libraw1394-1.3.0/juju/raw1394.c ---- libraw1394-1.3.0.orig/juju/raw1394.c 1969-12-31 19:00:00.000000000 -0500 -+++ libraw1394-1.3.0/juju/raw1394.c 2007-10-18 22:18:46.000000000 -0400 -@@ -0,0 +1,1441 @@ -+/* -*- c-basic-offset: 8 -*- -+ * -+ * raw1394.c -- Emulation of the raw1394 API on the juju stack -+ * -+ * Copyright (C) 2007 Kristian Hoegsberg -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software Foundation, -+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include /* for ntohl and htonl */ -+ -+#include "juju.h" -+ -+raw1394_errcode_t -+raw1394_get_errcode(raw1394handle_t handle) -+{ -+ return handle->err; -+} -+ -+int -+raw1394_errcode_to_errno(raw1394_errcode_t errcode) -+{ -+ switch (errcode) { -+ -+ case -RCODE_SEND_ERROR: -+ case -RCODE_CANCELLED: -+ case -RCODE_BUSY: -+ case -RCODE_GENERATION: -+ case -RCODE_NO_ACK: -+ return EAGAIN; -+ -+ case raw1394_make_errcode(ACK_COMPLETE, RCODE_COMPLETE): -+ return 0; -+ case raw1394_make_errcode(ACK_COMPLETE, RCODE_CONFLICT_ERROR): -+ return EAGAIN; -+ case raw1394_make_errcode(ACK_COMPLETE, RCODE_DATA_ERROR): -+ return EREMOTEIO; -+ case raw1394_make_errcode(ACK_COMPLETE, RCODE_TYPE_ERROR): -+ return EPERM; -+ case raw1394_make_errcode(ACK_COMPLETE, RCODE_ADDRESS_ERROR): -+ return EINVAL; -+ default: -+ return EINVAL; -+ } -+} -+ -+static int -+juju_to_raw1394_errcode(int rcode) -+{ -+ /* Best effort matching juju extended rcodes to raw1394 err -+ * code. Since the raw1394 errcode decoding are macros we try -+ * to convert the juju rcodes to something that looks enough -+ * like the raw1394 errcodes that we retain ABI compatibility. -+ * -+ * Juju rcodes less than 0x10 are standard ieee1394 rcodes, -+ * which we map to a raw1394 errcode by or'ing in an -+ * ACK_COMPLETE ack code in the upper 16 bits. Errors -+ * internal to raw1394 are negative values, but juju encodes -+ * these errors as rcodes greater than or equal to 0x10. In -+ * this case, we just the negated value, which will look like -+ * an raw1394 internal error code. */ -+ -+ if (rcode < 0x10) -+ return raw1394_make_errcode(ACK_COMPLETE, rcode); -+ else -+ return -rcode; -+} -+ -+static int -+default_tag_handler(raw1394handle_t handle, -+ unsigned long tag, raw1394_errcode_t err) -+{ -+ struct raw1394_reqhandle *rh = (struct raw1394_reqhandle *) tag; -+ -+ if (rh != NULL) -+ return rh->callback(handle, rh->data, err); -+ -+ return -1; -+} -+ -+static int -+default_arm_tag_handler(raw1394handle_t handle, unsigned long arm_tag, -+ byte_t type, unsigned int length, void *data) -+{ -+ struct raw1394_arm_reqhandle *rh; -+ -+ if (arm_tag == 0) -+ return -1; -+ -+ rh = (struct raw1394_arm_reqhandle *) arm_tag; -+ -+ return rh->arm_callback(handle, data, length, rh->pcontext, type); -+} -+ -+static int -+default_bus_reset_handler(struct raw1394_handle *handle, unsigned int gen) -+{ -+ raw1394_update_generation(handle, gen); -+ -+ return 0; -+} -+ -+static int -+scan_devices(raw1394handle_t handle) -+{ -+ DIR *dir; -+ struct dirent *de; -+ char filename[32]; -+ struct fw_cdev_get_info get_info; -+ struct fw_cdev_event_bus_reset reset; -+ int fd, err, i; -+ struct port *ports; -+ -+ ports = handle->ports; -+ memset(ports, 0, sizeof handle->ports); -+ dir = opendir(FW_DEVICE_DIR); -+ if (dir == NULL) -+ return -1; -+ -+ i = 0; -+ while (1) { -+ de = readdir(dir); -+ if (de == NULL) -+ break; -+ -+ if (strncmp(de->d_name, -+ FW_DEVICE_PREFIX, strlen(FW_DEVICE_PREFIX)) != 0) -+ continue; -+ -+ snprintf(filename, sizeof filename, FW_DEVICE_DIR "/%s", de->d_name); -+ -+ fd = open(filename, O_RDWR); -+ if (fd < 0) -+ continue; -+ get_info.version = FW_CDEV_VERSION; -+ get_info.rom = 0; -+ get_info.rom_length = 0; -+ get_info.bus_reset = ptr_to_u64(&reset); -+ err = ioctl(fd, FW_CDEV_IOC_GET_INFO, &get_info); -+ close(fd); -+ -+ if (err < 0) -+ continue; -+ -+ if (i < MAX_PORTS && reset.node_id == reset.local_node_id) { -+ strncpy(ports[i].device_file, filename, -+ sizeof ports[i].device_file); -+ ports[i].node_count = (reset.root_node_id & 0x3f) + 1; -+ ports[i].card = get_info.card; -+ i++; -+ } -+ } -+ closedir(dir); -+ -+ handle->port_count = i; -+ -+ return 0; -+} -+ -+static int -+handle_echo_pipe(raw1394handle_t handle, -+ struct epoll_closure *ec, __uint32_t events) -+{ -+ quadlet_t value; -+ -+ if (read(handle->pipe_fds[0], &value, sizeof value) < 0) -+ return -1; -+ -+ return value; -+} -+ -+static int -+handle_lost_device(raw1394handle_t handle, int i) -+{ -+ int phy_id; -+ -+ /* The device got unplugged, get rid of it. The fd is -+ * automatically dropped from the epoll context when we close it. */ -+ -+ close(handle->devices[i].fd); -+ phy_id = handle->devices[i].node_id & 0x3f; -+ if (handle->nodes[phy_id] == i) -+ handle->nodes[phy_id] = -1; -+ handle->devices[i].node_id = -1; -+ -+ return 0; -+} -+ -+struct address_closure { -+ int (*callback)(raw1394handle_t handle, struct address_closure *ac, -+ struct fw_cdev_event_request *request, int i); -+}; -+ -+static int -+handle_fcp_request(raw1394handle_t handle, struct address_closure *ac, -+ struct fw_cdev_event_request *request, int i) -+{ -+ struct fw_cdev_send_response response; -+ int is_response; -+ -+ response.handle = request->handle; -+ response.rcode = RCODE_COMPLETE; -+ response.length = 0; -+ response.data = 0; -+ -+ if (handle->fcp_handler == NULL) -+ response.rcode = RCODE_ADDRESS_ERROR; -+ -+ if (request->tcode >= TCODE_WRITE_RESPONSE) -+ response.rcode = RCODE_CONFLICT_ERROR; -+ -+ if (ioctl(handle->devices[i].fd, -+ FW_CDEV_IOC_SEND_RESPONSE, &response) < 0) -+ return -1; -+ -+ if (response.rcode != RCODE_COMPLETE) -+ return 0; -+ -+ is_response = request->offset >= CSR_REGISTER_BASE + CSR_FCP_RESPONSE; -+ -+ return handle->fcp_handler(handle, -+ handle->devices[i].node_id, -+ is_response, -+ request->length, -+ (unsigned char *) request->data); -+} -+ -+static int -+handle_device_event(raw1394handle_t handle, -+ struct epoll_closure *ec, __uint32_t events) -+{ -+ union fw_cdev_event *u; -+ struct device *device = (struct device *) ec; -+ struct address_closure *ac; -+ struct request_closure *rc; -+ raw1394_errcode_t errcode; -+ int len, phy_id; -+ int i; -+ -+ i = device - handle->devices; -+ if (events == EPOLLHUP) -+ return handle_lost_device(handle, i); -+ -+ len = read(handle->devices[i].fd, -+ handle->buffer, sizeof handle->buffer); -+ if (len < 0) -+ return -1; -+ -+ u = (void *) handle->buffer; -+ switch (u->common.type) { -+ case FW_CDEV_EVENT_BUS_RESET: -+ /* Clear old entry, unless it's been overwritten. */ -+ phy_id = handle->devices[i].node_id & 0x3f; -+ if (handle->nodes[phy_id] == i) -+ handle->nodes[phy_id] = -1; -+ handle->nodes[u->bus_reset.node_id & 0x3f] = i; -+ handle->devices[i].node_id = u->bus_reset.node_id; -+ handle->devices[i].generation = u->bus_reset.generation; -+ -+ if (u->bus_reset.node_id != u->bus_reset.local_node_id) -+ return 0; -+ -+ memcpy(&handle->reset, &u->bus_reset, sizeof handle->reset); -+ return handle->bus_reset_handler(handle, -+ u->bus_reset.generation); -+ -+ case FW_CDEV_EVENT_RESPONSE: -+ rc = u64_to_ptr(u->response.closure); -+ -+ if (rc->data != NULL) -+ memcpy(rc->data, u->response.data, rc->length); -+ -+ errcode = juju_to_raw1394_errcode(u->response.rcode); -+ -+ return handle->tag_handler(handle, rc->tag, errcode); -+ -+ case FW_CDEV_EVENT_REQUEST: -+ ac = u64_to_ptr(u->request.closure); -+ return ac->callback(handle, ac, &u->request, i); -+ -+ default: -+ case FW_CDEV_EVENT_ISO_INTERRUPT: -+ /* Never happens. */ -+ return -1; -+ } -+} -+ -+static int -+handle_inotify(raw1394handle_t handle, struct epoll_closure *ec, -+ __uint32_t events) -+{ -+ struct inotify_event *event; -+ char filename[32]; -+ struct fw_cdev_get_info info; -+ struct fw_cdev_event_bus_reset reset; -+ struct epoll_event ep; -+ int i, len, fd, phy_id; -+ -+ event = (struct inotify_event *) handle->buffer; -+ len = read(handle->inotify_fd, event, BUFFER_SIZE); -+ if (!(event->mask & IN_CREATE)) -+ return -1; -+ if (strncmp(event->name, -+ FW_DEVICE_PREFIX, strlen(FW_DEVICE_PREFIX)) != 0) -+ return 0; -+ snprintf(filename, sizeof filename, FW_DEVICE_DIR "/%s", event->name); -+ fd = open(filename, O_RDWR); -+ if (fd < 0) { -+ switch (errno) { -+ case ENOENT: -+ /* Huh, it disappeared before we could -+ * open it. */ -+ return 0; -+ case EACCES: -+ /* We don't have permission to talk to -+ * this device, maybe it's a storage -+ * device. */ -+ return 0; -+ default: -+ /* Anything else is bad news. */ -+ return -1; -+ } -+ } -+ -+ info.version = FW_CDEV_VERSION; -+ info.rom = 0; -+ info.rom_length = 0; -+ info.bus_reset = ptr_to_u64(&reset); -+ if (ioctl(fd, FW_CDEV_IOC_GET_INFO, &info) < 0) { -+ close(fd); -+ return -1; -+ } -+ -+ for (i = 0; i < MAX_DEVICES; i++) -+ if (handle->devices[i].node_id == -1) -+ break; -+ if (i == MAX_DEVICES) { -+ close(fd); -+ return -1; -+ } -+ -+ phy_id = reset.node_id & 0x3f; -+ handle->nodes[phy_id] = i; -+ handle->devices[i].node_id = reset.node_id; -+ handle->devices[i].generation = reset.generation; -+ handle->devices[i].fd = fd; -+ strncpy(handle->devices[i].filename, filename, -+ sizeof handle->devices[i].filename); -+ handle->devices[i].closure.func = handle_device_event; -+ ep.events = EPOLLIN; -+ ep.data.ptr = &handle->devices[i].closure; -+ if (epoll_ctl(handle->epoll_fd, EPOLL_CTL_ADD, fd, &ep) < 0) { -+ close(fd); -+ return -1; -+ } -+ -+ return 0; -+} -+ -+int raw1394_loop_iterate(raw1394handle_t handle) -+{ -+ int i, count, retval = 0; -+ struct epoll_closure *closure; -+ struct epoll_event ep[32]; -+ -+ count = epoll_wait(handle->epoll_fd, ep, ARRAY_LENGTH(ep), -1); -+ if (count < 0) -+ return -1; -+ -+ for (i = 0; i < count; i++) { -+ closure = ep[i].data.ptr; -+ retval = closure->func(handle, closure, ep[i].events); -+ } -+ -+ /* It looks like we have to add this work-around to get epoll -+ * to recompute the POLLIN status of the epoll_fd. */ -+ epoll_wait(handle->epoll_fd, ep, ARRAY_LENGTH(ep), 0); -+ -+ return retval; -+} -+ -+raw1394handle_t raw1394_new_handle(void) -+{ -+ raw1394handle_t handle; -+ struct epoll_event ep; -+ int i; -+ -+ handle = malloc(sizeof *handle); -+ -+ handle->tag_handler = default_tag_handler; -+ handle->arm_tag_handler = default_arm_tag_handler; -+ handle->allocations = NULL; -+ -+ handle->notify_bus_reset = RAW1394_NOTIFY_ON; -+ handle->bus_reset_handler = default_bus_reset_handler; -+ -+ handle->iso.fd = -1; -+ -+ handle->epoll_fd = epoll_create(16); -+ if (handle->epoll_fd < 0) -+ goto out_handle; -+ -+ if (pipe(handle->pipe_fds) < 0) -+ goto out_epoll; -+ -+ handle->inotify_fd = inotify_init(); -+ if (handle->inotify_fd < 0) -+ goto out_pipe; -+ -+ handle->inotify_watch = -+ inotify_add_watch(handle->inotify_fd, FW_DEVICE_DIR, IN_CREATE); -+ if (handle->inotify_watch < 0) -+ goto out_inotify; -+ -+ handle->pipe_closure.func = handle_echo_pipe; -+ ep.events = EPOLLIN; -+ ep.data.ptr = &handle->pipe_closure; -+ if (epoll_ctl(handle->epoll_fd, EPOLL_CTL_ADD, -+ handle->pipe_fds[0], &ep) < 0) -+ goto out_inotify; -+ -+ handle->inotify_closure.func = handle_inotify; -+ ep.events = EPOLLIN; -+ ep.data.ptr = &handle->inotify_closure; -+ if (epoll_ctl(handle->epoll_fd, EPOLL_CTL_ADD, -+ handle->inotify_fd, &ep) < 0) -+ goto out_inotify; -+ -+ for (i = 0; i < MAX_DEVICES; i++) { -+ handle->nodes[i] = -1; -+ handle->devices[i].node_id = -1; -+ } -+ -+ scan_devices(handle); -+ -+ return handle; -+ -+ out_inotify: -+ close(handle->inotify_fd); -+ out_pipe: -+ close(handle->pipe_fds[0]); -+ close(handle->pipe_fds[1]); -+ out_epoll: -+ close(handle->epoll_fd); -+ out_handle: -+ free(handle); -+ return NULL; -+} -+ -+void raw1394_destroy_handle(raw1394handle_t handle) -+{ -+ int i; -+ -+ close(handle->inotify_fd); -+ close(handle->pipe_fds[0]); -+ close(handle->pipe_fds[1]); -+ -+ for (i = 0; i < MAX_DEVICES; i++) { -+ if (handle->devices[i].node_id == -1) -+ continue; -+ -+ close(handle->devices[i].fd); -+ } -+ -+ close(handle->epoll_fd); -+ -+ free(handle); -+ -+ return; -+} -+ -+raw1394handle_t raw1394_new_handle_on_port(int port) -+{ -+ raw1394handle_t handle; -+ -+ handle = raw1394_new_handle(); -+ if (handle == NULL) -+ return NULL; -+ -+ if (raw1394_set_port(handle, port) < 0) -+ return NULL; -+ -+ return handle; -+} -+ -+int raw1394_busreset_notify (raw1394handle_t handle, int off_on_switch) -+{ -+ handle->notify_bus_reset = off_on_switch; -+ -+ return 0; -+} -+ -+int raw1394_get_fd(raw1394handle_t handle) -+{ -+ return handle->epoll_fd; -+} -+ -+void raw1394_set_userdata(raw1394handle_t handle, void *data) -+{ -+ handle->user_data = data; -+} -+ -+void *raw1394_get_userdata(raw1394handle_t handle) -+{ -+ return handle->user_data; -+} -+ -+nodeid_t raw1394_get_local_id(raw1394handle_t handle) -+{ -+ return handle->reset.local_node_id; -+} -+ -+nodeid_t raw1394_get_irm_id(raw1394handle_t handle) -+{ -+ return handle->reset.irm_node_id; -+} -+ -+int raw1394_get_nodecount(raw1394handle_t handle) -+{ -+ return (handle->reset.root_node_id & 0x3f) + 1; -+} -+ -+int raw1394_get_port_info(raw1394handle_t handle, -+ struct raw1394_portinfo *pinf, -+ int maxports) -+{ -+ int i; -+ -+ if (maxports >= handle->port_count) -+ maxports = handle->port_count; -+ -+ for (i = 0; i < maxports; i++) { -+ pinf[i].nodes = handle->ports[i].node_count; -+ strncpy(pinf[i].name, handle->ports[i].device_file, -+ sizeof pinf[i].name); -+ } -+ -+ return handle->port_count; -+} -+ -+int raw1394_set_port(raw1394handle_t handle, int port) -+{ -+ struct fw_cdev_get_info get_info; -+ struct fw_cdev_event_bus_reset reset; -+ struct epoll_event ep; -+ struct dirent *de; -+ char filename[32]; -+ DIR *dir; -+ int i, fd, phy_id; -+ -+ if (port >= handle->port_count) { -+ errno = EINVAL; -+ return -1; -+ } -+ -+ dir = opendir("/dev"); -+ if (dir == NULL) -+ return -1; -+ -+ for (i = 0; i < MAX_DEVICES; ) { -+ de = readdir(dir); -+ if (de == NULL) -+ break; -+ -+ if (strncmp(de->d_name, "fw", 2) != 0) -+ continue; -+ -+ snprintf(filename, sizeof filename, "/dev/%s", de->d_name); -+ -+ fd = open(filename, O_RDWR); -+ if (fd < 0) -+ continue; -+ -+ get_info.version = FW_CDEV_VERSION; -+ get_info.rom = 0; -+ get_info.rom_length = 0; -+ get_info.bus_reset = ptr_to_u64(&reset); -+ if (ioctl(fd, FW_CDEV_IOC_GET_INFO, &get_info) < 0) { -+ close(fd); -+ continue; -+ } -+ -+ if (get_info.card != handle->ports[port].card) { -+ close(fd); -+ continue; -+ } -+ -+ phy_id = reset.node_id & 0x3f; -+ handle->nodes[phy_id] = i; -+ handle->devices[i].node_id = reset.node_id; -+ handle->devices[i].generation = reset.generation; -+ handle->devices[i].fd = fd; -+ strncpy(handle->devices[i].filename, filename, -+ sizeof handle->devices[i].filename); -+ -+ handle->devices[i].closure.func = handle_device_event; -+ ep.events = EPOLLIN; -+ ep.data.ptr = &handle->devices[i].closure; -+ if (epoll_ctl(handle->epoll_fd, EPOLL_CTL_ADD, fd, &ep) < 0) { -+ close(fd); -+ return -1; -+ } -+ -+ handle->generation = reset.generation; -+ if (reset.node_id == reset.local_node_id) { -+ memcpy(&handle->reset, &reset, sizeof handle->reset); -+ handle->local_fd = fd; -+ strncpy(handle->local_filename, filename, -+ sizeof handle->local_filename); -+ } -+ -+ i++; -+ } -+ -+ return 0; -+} -+ -+int raw1394_reset_bus(raw1394handle_t handle) -+{ -+ return raw1394_reset_bus_new(handle, RAW1394_LONG_RESET); -+} -+ -+int raw1394_reset_bus_new(raw1394handle_t handle, int type) -+{ -+ struct fw_cdev_initiate_bus_reset initiate; -+ -+ switch (type) { -+ case RAW1394_LONG_RESET: -+ initiate.type = FW_CDEV_LONG_RESET; -+ break; -+ case RAW1394_SHORT_RESET: -+ initiate.type = FW_CDEV_SHORT_RESET; -+ break; -+ } -+ -+ return ioctl(handle->local_fd, -+ FW_CDEV_IOC_INITIATE_BUS_RESET, &initiate); -+} -+ -+bus_reset_handler_t raw1394_set_bus_reset_handler(raw1394handle_t handle, -+ bus_reset_handler_t new_h) -+{ -+ bus_reset_handler_t old_h = handle->bus_reset_handler; -+ -+ handle->bus_reset_handler = new_h; -+ -+ return old_h; -+} -+ -+unsigned int raw1394_get_generation(raw1394handle_t handle) -+{ -+ return handle->generation; -+} -+ -+void raw1394_update_generation(raw1394handle_t handle, unsigned int generation) -+{ -+ handle->generation = generation; -+} -+ -+tag_handler_t -+raw1394_set_tag_handler(raw1394handle_t handle, tag_handler_t new_h) -+{ -+ tag_handler_t old_h = handle->tag_handler; -+ -+ handle->tag_handler = new_h; -+ -+ return old_h; -+} -+ -+arm_tag_handler_t -+raw1394_set_arm_tag_handler(raw1394handle_t handle, arm_tag_handler_t new_h) -+{ -+ arm_tag_handler_t old_h = handle->arm_tag_handler; -+ -+ handle->arm_tag_handler = new_h; -+ -+ return old_h; -+} -+ -+fcp_handler_t -+raw1394_set_fcp_handler(raw1394handle_t handle, fcp_handler_t new_h) -+{ -+ fcp_handler_t old_h = handle->fcp_handler; -+ -+ handle->fcp_handler = new_h; -+ -+ return old_h; -+} -+ -+struct request_response_block { -+ struct raw1394_arm_request_response request_response; -+ struct raw1394_arm_request request; -+ struct raw1394_arm_response response; -+ unsigned char data[0]; -+}; -+ -+struct allocation { -+ struct address_closure closure; -+ struct allocation *next; -+ __u32 handle; -+ byte_t *buffer; -+ octlet_t tag; -+ arm_options_t access_rights; -+ arm_options_t notification_options; -+ arm_options_t client_transactions; -+ nodeaddr_t offset; -+ size_t length; -+ unsigned char data[0]; -+}; -+ -+static int -+handle_arm_request(raw1394handle_t handle, struct address_closure *ac, -+ struct fw_cdev_event_request *request, int i) -+{ -+ struct allocation *allocation = (struct allocation *) ac; -+ struct request_response_block *rrb; -+ struct fw_cdev_send_response response; -+ arm_options_t type; -+ size_t in_length; -+ int offset; -+ -+ offset = request->offset - allocation->offset; -+ response.handle = request->handle; -+ -+ switch (request->tcode) { -+ case TCODE_WRITE_QUADLET_REQUEST: -+ case TCODE_WRITE_BLOCK_REQUEST: -+ printf("got write request, offset=0x%012llx, length=%d\n", -+ request->offset, request->length); -+ -+ type = RAW1394_ARM_WRITE; -+ in_length = request->length; -+ response.rcode = RCODE_COMPLETE; -+ response.length = 0; -+ response.data = 0; -+ break; -+ -+ case TCODE_READ_QUADLET_REQUEST: -+ case TCODE_READ_BLOCK_REQUEST: -+ printf("got read request, offset=0x%012llx, length=%d\n", -+ request->offset, request->length); -+ -+ type = RAW1394_ARM_READ; -+ in_length = 0; -+ response.rcode = RCODE_COMPLETE; -+ response.length = request->length; -+ response.data = ptr_to_u64(allocation->data + offset); -+ break; -+ -+ case TCODE_LOCK_REQUEST: -+ type = RAW1394_ARM_LOCK; -+ in_length = request->length; -+ response.length = 4; -+ break; -+ -+ default: -+ in_length = 0; -+ type = 0; -+ break; -+ } -+ -+ if (!(allocation->access_rights & type)) { -+ response.rcode = RCODE_TYPE_ERROR; -+ response.length = 0; -+ response.data = 0; -+ if (ioctl(handle->devices[i].fd, -+ FW_CDEV_IOC_SEND_RESPONSE, &response) < 0) -+ return -1; -+ } else if (!(allocation->client_transactions & type)) { -+ if (type == RAW1394_ARM_WRITE) -+ memcpy(allocation->data + offset, -+ request->data, request->length); -+ else if (type == RAW1394_ARM_LOCK) -+ /* FIXME: do lock ops here */; -+ -+ if (ioctl(handle->devices[i].fd, -+ FW_CDEV_IOC_SEND_RESPONSE, &response) < 0) -+ return -1; -+ } -+ -+ if (!(allocation->notification_options & type)) -+ return 0; -+ -+ rrb = malloc(sizeof *rrb + in_length + response.length); -+ -+ rrb->request_response.request = &rrb->request; -+ rrb->request_response.response = &rrb->response; -+ -+ rrb->request.destination_nodeid = handle->reset.local_node_id; -+ rrb->request.source_nodeid = handle->devices[i].node_id; -+ rrb->request.destination_offset = request->offset; -+ rrb->request.tlabel = 0; -+ if (request->tcode < 0x10) { -+ rrb->request.tcode = request->tcode; -+ rrb->request.extended_transaction_code = 0; -+ } else { -+ rrb->request.tcode = TCODE_LOCK_REQUEST; -+ rrb->request.extended_transaction_code = request->tcode - 0x10; -+ } -+ rrb->request.generation = handle->reset.generation; -+ rrb->request.buffer_length = in_length; -+ memcpy(rrb->request.buffer, request->data, in_length); -+ -+ rrb->response.response_code = response.rcode; -+ rrb->response.buffer_length = response.length; -+ memcpy(rrb->response.buffer, -+ allocation->data + offset, response.length); -+ -+ return handle->arm_tag_handler(handle, allocation->tag, type, -+ request->length, -+ &rrb->request_response); -+} -+ -+int -+raw1394_arm_register(raw1394handle_t handle, nodeaddr_t start, -+ size_t length, byte_t *initial_value, -+ octlet_t arm_tag, arm_options_t access_rights, -+ arm_options_t notification_options, -+ arm_options_t client_transactions) -+{ -+ struct fw_cdev_allocate request; -+ struct allocation *allocation; -+ int retval; -+ -+ allocation = malloc(sizeof *allocation + length); -+ if (allocation == NULL) -+ return -1; -+ -+ allocation->closure.callback = handle_arm_request; -+ allocation->buffer = initial_value; -+ allocation->tag = arm_tag; -+ allocation->access_rights = access_rights; -+ allocation->notification_options = notification_options; -+ allocation->client_transactions = client_transactions; -+ allocation->offset = start; -+ allocation->length = length; -+ if (initial_value != NULL) -+ memcpy(allocation->data, initial_value, length); -+ -+ request.offset = start; -+ request.length = length; -+ request.closure = ptr_to_u64(&allocation->closure); -+ -+ retval = ioctl(handle->local_fd, FW_CDEV_IOC_ALLOCATE, &request); -+ if (retval < 0) { -+ free(allocation); -+ return -1; -+ } -+ -+ allocation->handle = request.handle; -+ allocation->next = handle->allocations; -+ handle->allocations = allocation; -+ -+ return 0; -+} -+ -+static struct allocation * -+lookup_allocation(raw1394handle_t handle, nodeaddr_t start, int delete) -+{ -+ struct allocation *a, **prev; -+ -+ prev = &handle->allocations; -+ for (a = handle->allocations; a != NULL; a = a->next) { -+ if (a->offset <= start && start < a->offset + a->length) -+ break; -+ prev = &a->next; -+ } -+ -+ if (a != NULL && delete) -+ *prev = a->next; -+ -+ return a; -+} -+ -+int -+raw1394_arm_unregister(raw1394handle_t handle, nodeaddr_t start) -+{ -+ struct fw_cdev_deallocate request; -+ struct allocation *allocation; -+ -+ allocation = lookup_allocation(handle, start, 1); -+ if (allocation == NULL) { -+ errno = EINVAL; -+ return -1; -+ } -+ -+ request.handle = allocation->handle; -+ free(allocation); -+ -+ return ioctl(handle->local_fd, FW_CDEV_IOC_DEALLOCATE, &request); -+} -+ -+int -+raw1394_arm_set_buf(raw1394handle_t handle, nodeaddr_t start, -+ size_t length, void *buf) -+{ -+ struct allocation *allocation; -+ -+ allocation = lookup_allocation(handle, start, 0); -+ if (allocation == NULL) { -+ errno = ENOENT; -+ return -1; -+ } -+ -+ memcpy(allocation->data + allocation->offset - start, buf, length); -+ -+ return 0; -+} -+ -+int -+raw1394_arm_get_buf(raw1394handle_t handle, nodeaddr_t start, -+ size_t length, void *buf) -+{ -+ struct allocation *allocation; -+ -+ allocation = lookup_allocation(handle, start, 0); -+ if (allocation == NULL) { -+ errno = ENOENT; -+ return -1; -+ } -+ -+ memcpy(buf, allocation->data + allocation->offset - start, length); -+ -+ return 0; -+} -+ -+int -+raw1394_echo_request(raw1394handle_t handle, quadlet_t data) -+{ -+ return write(handle->pipe_fds[1], &data, sizeof data); -+} -+ -+int raw1394_wake_up(raw1394handle_t handle) -+{ -+ return raw1394_echo_request(handle, 0); -+} -+ -+int raw1394_phy_packet_write (raw1394handle_t handle, quadlet_t data) -+{ -+ errno = ENOSYS; -+ return -1; -+} -+ -+int -+raw1394_start_phy_packet_write(raw1394handle_t handle, -+ quadlet_t data, unsigned long tag) -+{ -+ errno = ENOSYS; -+ return -1; -+} -+ -+static int -+send_request(raw1394handle_t handle, int tcode, -+ nodeid_t node, nodeaddr_t addr, -+ size_t length, void *in, void *out, unsigned long tag) -+{ -+ struct fw_cdev_send_request *request; -+ struct request_closure *closure; -+ int i; -+ -+ if (node > handle->reset.root_node_id) { -+ handle->err = -RCODE_NO_ACK; -+ errno = raw1394_errcode_to_errno(handle->err); -+ return -1; -+ } -+ -+ i = handle->nodes[node & 0x3f]; -+ if (i == -1) { -+ handle->err = -RCODE_NO_ACK; -+ errno = raw1394_errcode_to_errno(handle->err); -+ return -1; -+ } -+ -+ if (handle->generation != handle->devices[i].generation) { -+ handle->err = -RCODE_GENERATION; -+ errno = raw1394_errcode_to_errno(handle->err); -+ return -1; -+ } -+ -+ closure = malloc(sizeof *closure); -+ if (closure == NULL) { -+ handle->err = -RCODE_SEND_ERROR; -+ errno = raw1394_errcode_to_errno(handle->err); -+ return -1; -+ } -+ -+ closure->data = out; -+ closure->length = length; -+ closure->tag = tag; -+ -+ request = (struct fw_cdev_send_request *) handle->buffer; -+ request->tcode = tcode; -+ request->generation = handle->generation; -+ request->offset = addr; -+ request->length = length; -+ request->closure = ptr_to_u64(closure); -+ request->data = ptr_to_u64(in); -+ -+ return ioctl(handle->devices[i].fd, FW_CDEV_IOC_SEND_REQUEST, request); -+} -+ -+int -+raw1394_start_read(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, -+ size_t length, quadlet_t *buffer, unsigned long tag) -+{ -+ int tcode; -+ -+ if (length == 4) -+ tcode = TCODE_READ_QUADLET_REQUEST; -+ else -+ tcode = TCODE_READ_BLOCK_REQUEST; -+ -+ return send_request(handle, tcode, -+ node, addr, length, NULL, buffer, tag); -+} -+ -+int -+raw1394_start_write(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, -+ size_t length, quadlet_t *data, unsigned long tag) -+{ -+ int tcode; -+ -+ if (length == 4) -+ tcode = TCODE_WRITE_QUADLET_REQUEST; -+ else -+ tcode = TCODE_WRITE_BLOCK_REQUEST; -+ -+ return send_request(handle, tcode, -+ node, addr, length, data, NULL, tag); -+} -+ -+static int -+setup_lock(int extcode, quadlet_t data, quadlet_t arg, quadlet_t *buffer) -+{ -+ switch (extcode) { -+ case RAW1394_EXTCODE_FETCH_ADD: -+ case RAW1394_EXTCODE_LITTLE_ADD: -+ buffer[0] = data; -+ return sizeof buffer[0]; -+ -+ case RAW1394_EXTCODE_MASK_SWAP: -+ case RAW1394_EXTCODE_COMPARE_SWAP: -+ case RAW1394_EXTCODE_BOUNDED_ADD: -+ case RAW1394_EXTCODE_WRAP_ADD: -+ buffer[0] = arg; -+ buffer[1] = data; -+ return 2 * sizeof buffer[0]; -+ -+ default: -+ errno = EINVAL; -+ return -1; -+ } -+} -+ -+static int -+setup_lock64(int extcode, octlet_t data, octlet_t arg, octlet_t *buffer) -+{ -+ switch (extcode) { -+ case RAW1394_EXTCODE_FETCH_ADD: -+ case RAW1394_EXTCODE_LITTLE_ADD: -+ buffer[0] = data; -+ return sizeof buffer[0]; -+ -+ case RAW1394_EXTCODE_MASK_SWAP: -+ case RAW1394_EXTCODE_COMPARE_SWAP: -+ case RAW1394_EXTCODE_BOUNDED_ADD: -+ case RAW1394_EXTCODE_WRAP_ADD: -+ buffer[0] = arg; -+ buffer[1] = data; -+ return 2 * sizeof buffer[0]; -+ -+ default: -+ errno = EINVAL; -+ return -1; -+ } -+} -+ -+int -+raw1394_start_lock(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, -+ unsigned int extcode, quadlet_t data, quadlet_t arg, -+ quadlet_t *result, unsigned long tag) -+{ -+ quadlet_t buffer[2]; -+ int length; -+ -+ length = setup_lock(extcode, data, arg, buffer); -+ if (length < 0) -+ return length; -+ -+ return send_request(handle, 16 + extcode, -+ node, addr, length, buffer, result, tag); -+} -+ -+int -+raw1394_start_lock64(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, -+ unsigned int extcode, octlet_t data, octlet_t arg, -+ octlet_t *result, unsigned long tag) -+{ -+ octlet_t buffer[2]; -+ int length; -+ -+ length = setup_lock64(extcode, data, arg, buffer); -+ if (length < 0) -+ return length; -+ -+ return send_request(handle, 16 + extcode, -+ node, addr, length, buffer, result, tag); -+} -+ -+int -+raw1394_start_async_stream(raw1394handle_t handle, unsigned int channel, -+ unsigned int tag, unsigned int sy, -+ unsigned int speed, size_t length, quadlet_t *data, -+ unsigned long rawtag) -+{ -+ /* FIXME: implement this? */ -+ return -1; -+} -+ -+ -+int -+raw1394_start_async_send(raw1394handle_t handle, -+ size_t length, size_t header_length, -+ unsigned int expect_response, -+ quadlet_t *data, unsigned long rawtag) -+{ -+ /* FIXME: implement this? */ -+ return -1; -+} -+ -+struct sync_data { -+ raw1394_errcode_t err; -+ int done; -+}; -+ -+static int -+sync_callback(raw1394handle_t handle, void *data, raw1394_errcode_t err) -+{ -+ struct sync_data *sd = data; -+ -+ sd->err = err; -+ sd->done = 1; -+ -+ return 0; -+} -+ -+static int -+send_request_sync(raw1394handle_t handle, int tcode, -+ nodeid_t node, nodeaddr_t addr, -+ size_t length, void *in, void *out) -+{ -+ struct raw1394_reqhandle reqhandle; -+ struct sync_data sd = { 0, 0 }; -+ int err; -+ -+ reqhandle.callback = sync_callback; -+ reqhandle.data = &sd; -+ -+ err = send_request(handle, tcode, node, addr, -+ length, in, out, (unsigned long) &reqhandle); -+ -+ while (!sd.done) { -+ if (err < 0) -+ return err; -+ err = raw1394_loop_iterate(handle); -+ } -+ -+ handle->err = sd.err; -+ errno = raw1394_errcode_to_errno(sd.err); -+ -+ return (errno ? -1 : 0); -+} -+ -+int -+raw1394_read(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, -+ size_t length, quadlet_t *buffer) -+{ -+ int tcode; -+ -+ if (length == 4) -+ tcode = TCODE_READ_QUADLET_REQUEST; -+ else -+ tcode = TCODE_READ_BLOCK_REQUEST; -+ -+ return send_request_sync(handle, tcode, -+ node, addr, length, NULL, buffer); -+} -+ -+int -+raw1394_write(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, -+ size_t length, quadlet_t *data) -+{ -+ int tcode; -+ -+ if (length == 4) -+ tcode = TCODE_WRITE_QUADLET_REQUEST; -+ else -+ tcode = TCODE_WRITE_BLOCK_REQUEST; -+ -+ return send_request_sync(handle, tcode, -+ node, addr, length, data, NULL); -+} -+ -+int -+raw1394_lock(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, -+ unsigned int extcode, quadlet_t data, quadlet_t arg, -+ quadlet_t *result) -+{ -+ quadlet_t buffer[2]; -+ size_t length; -+ -+ length = setup_lock(extcode, data, arg, buffer); -+ if (length < 0) -+ return length; -+ -+ return send_request_sync(handle, 16 + extcode, node, addr, -+ length, buffer, result); -+} -+ -+int -+raw1394_lock64(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, -+ unsigned int extcode, octlet_t data, octlet_t arg, -+ octlet_t *result) -+{ -+ octlet_t buffer[2]; -+ size_t length; -+ -+ length = setup_lock64(extcode, data, arg, buffer); -+ if (length < 0) -+ return length; -+ -+ return send_request_sync(handle, 16 + extcode, node, addr, -+ length, buffer, result); -+} -+ -+int -+raw1394_async_stream(raw1394handle_t handle, unsigned int channel, -+ unsigned int tag, unsigned int sy, unsigned int speed, -+ size_t length, quadlet_t *data) -+{ -+ /* FIXME: implement this? */ -+ return -1; -+} -+ -+int -+raw1394_async_send(raw1394handle_t handle, -+ size_t length, size_t header_length, -+ unsigned int expect_response, -+ quadlet_t *data) -+{ -+ /* FIXME: implement this? */ -+ return -1; -+} -+ -+int -+raw1394_start_fcp_listen(raw1394handle_t handle) -+{ -+ struct fw_cdev_allocate request; -+ struct address_closure *closure; -+ -+ closure = malloc(sizeof *closure); -+ if (closure == NULL) -+ return -1; -+ -+ closure->callback = handle_fcp_request; -+ -+ request.offset = CSR_REGISTER_BASE + CSR_FCP_COMMAND; -+ request.length = CSR_FCP_END - CSR_FCP_COMMAND; -+ request.closure = ptr_to_u64(closure); -+ if (ioctl(handle->local_fd, FW_CDEV_IOC_ALLOCATE, &request) < 0) -+ return -1; -+ -+ handle->fcp_allocation_handle = request.handle; -+ -+ return 0; -+} -+ -+int -+raw1394_stop_fcp_listen(raw1394handle_t handle) -+{ -+ struct fw_cdev_deallocate request; -+ -+ request.handle = handle->fcp_allocation_handle; -+ -+ return ioctl(handle->local_fd, FW_CDEV_IOC_DEALLOCATE, &request); -+} -+ -+const char * -+raw1394_get_libversion(void) -+{ -+ return VERSION " (Juju)"; -+} -+ -+int -+raw1394_update_config_rom(raw1394handle_t handle, const quadlet_t *new_rom, -+ size_t size, unsigned char rom_version) -+{ -+ return -1; -+} -+ -+int -+raw1394_get_config_rom(raw1394handle_t handle, quadlet_t *buffer, -+ size_t buffersize, size_t *rom_size, -+ unsigned char *rom_version) -+{ -+ struct fw_cdev_get_info get_info; -+ int err; -+ -+ get_info.version = FW_CDEV_VERSION; -+ get_info.rom = ptr_to_u64(buffer); -+ get_info.rom_length = buffersize; -+ get_info.bus_reset = 0; -+ -+ err = ioctl(handle->local_fd, FW_CDEV_IOC_GET_INFO, &get_info); -+ if (err) -+ return err; -+ -+ *rom_size = get_info.rom_length; -+ *rom_version = 0; -+ -+ return 0; -+} -+ -+#define MAXIMUM_BANDWIDTH 4915 -+ -+int -+raw1394_bandwidth_modify (raw1394handle_t handle, -+ unsigned int bandwidth, -+ enum raw1394_modify_mode mode) -+{ -+ quadlet_t buffer, compare, swap; -+ nodeaddr_t addr; -+ int result; -+ -+ if (bandwidth == 0) -+ return 0; -+ -+ addr = CSR_REGISTER_BASE + CSR_BANDWIDTH_AVAILABLE; -+ /* Read current bandwidth usage from IRM. */ -+ result = raw1394_read (handle, raw1394_get_irm_id (handle), addr, -+ sizeof buffer, &buffer); -+ if (result < 0) -+ return -1; -+ -+ compare = ntohl (buffer); -+ switch (mode) { -+ case RAW1394_MODIFY_ALLOC: -+ swap = compare - bandwidth; -+ if (swap < 0) -+ return -1; -+ break; -+ -+ case RAW1394_MODIFY_FREE: -+ swap = compare + bandwidth; -+ if (swap > MAXIMUM_BANDWIDTH) -+ swap = MAXIMUM_BANDWIDTH; -+ break; -+ -+ default: -+ return -1; -+ } -+ -+ result = raw1394_lock(handle, raw1394_get_irm_id (handle), addr, -+ RAW1394_EXTCODE_COMPARE_SWAP, -+ htonl(swap), htonl(compare), &buffer); -+ if (result < 0 || ntohl(buffer) != compare) -+ return -1; -+ -+ return 0; -+} -+ -+int -+raw1394_channel_modify (raw1394handle_t handle, -+ unsigned int channel, -+ enum raw1394_modify_mode mode) -+{ -+ quadlet_t buffer, compare, swap, bit; -+ nodeaddr_t addr; -+ int result; -+ -+ if (channel >= 64) -+ return -1; -+ addr = CSR_REGISTER_BASE + -+ CSR_CHANNELS_AVAILABLE_HI + 4 * (channel / 32); -+ /* Read currently available channels from IRM. */ -+ result = raw1394_read(handle, raw1394_get_irm_id (handle), addr, -+ sizeof buffer, &buffer); -+ if (result < 0) -+ return -1; -+ -+ /* IEEE numbers bits from MSB (0) to LSB (31). */ -+ bit = 1 << (31 - (channel & 31)); -+ compare = ntohl(buffer); -+ switch (mode) { -+ case RAW1394_MODIFY_ALLOC: -+ if ((compare & bit) == 0) -+ return -1; -+ swap = buffer & ~bit; -+ break; -+ -+ case RAW1394_MODIFY_FREE: -+ if ((buffer & bit) != 0) -+ return -1; -+ swap = buffer | bit; -+ break; -+ -+ default: -+ return -1; -+ } -+ -+ result = raw1394_lock (handle, raw1394_get_irm_id (handle), addr, -+ RAW1394_EXTCODE_COMPARE_SWAP, -+ htonl(swap), htonl(compare), &buffer); -+ -+ if (result < 0 || ntohl(buffer) != compare) -+ return -1; -+ -+ return 0; -+} -diff -Naurp libraw1394-1.3.0.orig/juju/raw1394-iso.c libraw1394-1.3.0/juju/raw1394-iso.c ---- libraw1394-1.3.0.orig/juju/raw1394-iso.c 1969-12-31 19:00:00.000000000 -0500 -+++ libraw1394-1.3.0/juju/raw1394-iso.c 2007-10-18 22:18:46.000000000 -0400 -@@ -0,0 +1,522 @@ -+/* -*- c-basic-offset: 8 -*- -+ * -+ * raw1394-iso.c -- Emulation of the raw1394 rawiso API on the juju stack -+ * -+ * Copyright (C) 2007 Kristian Hoegsberg -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software Foundation, -+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include "juju.h" -+ -+static int -+queue_packet(raw1394handle_t handle, -+ unsigned int length, unsigned int header_length, -+ unsigned char tag, unsigned char sy) -+{ -+ struct fw_cdev_queue_iso queue_iso; -+ struct fw_cdev_iso_packet *p; -+ int err; -+ -+ p = &handle->iso.packets[handle->iso.packet_index]; -+ p->payload_length = length; -+ p->interrupt = -+ handle->iso.packet_phase == handle->iso.irq_interval - 1; -+ p->skip = 0; -+ p->tag = tag; -+ p->sy = sy; -+ p->header_length = header_length; -+ -+ handle->iso.head += length; -+ handle->iso.packet_count++; -+ handle->iso.packet_phase++; -+ handle->iso.packet_index++; -+ -+ if (handle->iso.packet_phase == handle->iso.irq_interval) -+ handle->iso.packet_phase = 0; -+ -+ if (handle->iso.head + handle->iso.max_packet_size > handle->iso.buffer_end) -+ handle->iso.head = handle->iso.buffer; -+ -+ /* Queue the packets in the kernel if we filled up the packets -+ * array or wrapped the payload buffer. */ -+ if (handle->iso.packet_index == handle->iso.irq_interval || -+ handle->iso.head == handle->iso.buffer) { -+ queue_iso.packets = ptr_to_u64(handle->iso.packets); -+ queue_iso.size = handle->iso.packet_index * sizeof handle->iso.packets[0]; -+ queue_iso.data = ptr_to_u64(handle->iso.first_payload); -+ queue_iso.handle = 0; -+ handle->iso.packet_index = 0; -+ handle->iso.first_payload = handle->iso.head; -+ -+ err = ioctl(handle->iso.fd, FW_CDEV_IOC_QUEUE_ISO, &queue_iso); -+ if (err < 0) -+ return -1; -+ } -+} -+ -+static int -+queue_xmit_packets(raw1394handle_t handle, int limit) -+{ -+ enum raw1394_iso_disposition d; -+ unsigned char tag, sy; -+ int len, cycle, dropped; -+ -+ if (handle->iso.xmit_handler == NULL) -+ return 0; -+ -+ while (handle->iso.packet_count < limit) { -+ -+ d = handle->iso.xmit_handler(handle, handle->iso.head, -+ &len, &tag, &sy, cycle, dropped); -+ -+ switch (d) { -+ case RAW1394_ISO_OK: -+ queue_packet(handle, len, 0, tag, sy); -+ break; -+ case RAW1394_ISO_DEFER: -+ case RAW1394_ISO_AGAIN: -+ default: -+ return 0; -+ case RAW1394_ISO_ERROR: -+ return -1; -+ case RAW1394_ISO_STOP: -+ raw1394_iso_stop(handle); -+ return 0; -+ } -+ } -+ -+ return 0; -+} -+ -+int raw1394_iso_xmit_start(raw1394handle_t handle, int start_on_cycle, -+ int prebuffer_packets) -+{ -+ struct fw_cdev_start_iso start_iso; -+ int retval; -+ -+ if (prebuffer_packets == -1) -+ prebuffer_packets = handle->iso.irq_interval; -+ -+ handle->iso.prebuffer = prebuffer_packets; -+ handle->iso.start_on_cycle = start_on_cycle; -+ -+ queue_xmit_packets(handle, prebuffer_packets); -+ -+ if (handle->iso.prebuffer <= handle->iso.packet_count) { -+ start_iso.cycle = start_on_cycle; -+ start_iso.handle = 0; -+ -+ retval = ioctl(handle->iso.fd, -+ FW_CDEV_IOC_START_ISO, &start_iso); -+ if (retval < 0) -+ return retval; -+ } -+ -+ return queue_xmit_packets(handle, handle->iso.buf_packets); -+} -+ -+static int -+queue_recv_packets(raw1394handle_t handle) -+{ -+ while (handle->iso.packet_count <= handle->iso.buf_packets) -+ queue_packet(handle, handle->iso.max_packet_size, 4, 0, 0); -+ -+ return 0; -+} -+ -+static enum raw1394_iso_disposition -+flush_recv_packets(raw1394handle_t handle, -+ struct fw_cdev_event_iso_interrupt *interrupt) -+{ -+ enum raw1394_iso_disposition d; -+ quadlet_t header, *p, *end; -+ unsigned int len, cycle, dropped; -+ unsigned char channel, tag, sy; -+ -+ p = interrupt->header; -+ end = (void *) interrupt->header + interrupt->header_length; -+ cycle = interrupt->cycle; -+ dropped = 0; -+ d = RAW1394_ISO_OK; -+ -+ while (p < end) { -+ header = be32_to_cpu(*p++); -+ len = header >> 16; -+ tag = (header >> 14) & 0x3; -+ channel = (header >> 8) & 0x3f; -+ sy = header & 0x0f; -+ -+ d = handle->iso.recv_handler(handle, handle->iso.tail, len, -+ channel, tag, sy, cycle, dropped); -+ if (d != RAW1394_ISO_OK) -+ /* FIXME: we need to save the headers so we -+ * can restart this loop. */ -+ break; -+ cycle++; -+ -+ handle->iso.tail += handle->iso.max_packet_size; -+ handle->iso.packet_count--; -+ -+ if (handle->iso.tail + handle->iso.max_packet_size > handle->iso.buffer_end) -+ handle->iso.tail = handle->iso.buffer; -+ } -+ -+ switch (d) { -+ case RAW1394_ISO_OK: -+ case RAW1394_ISO_DEFER: -+ default: -+ break; -+ -+ case RAW1394_ISO_ERROR: -+ return -1; -+ -+ case RAW1394_ISO_STOP: -+ raw1394_iso_stop(handle); -+ return 0; -+ } -+ -+ queue_recv_packets(handle); -+ -+ return 0; -+} -+ -+int raw1394_iso_recv_start(raw1394handle_t handle, int start_on_cycle, -+ int tag_mask, int sync) -+{ -+ struct fw_cdev_start_iso start_iso; -+ -+ queue_recv_packets(handle); -+ -+ start_iso.cycle = start_on_cycle; -+ start_iso.tags = -+ tag_mask == -1 ? FW_CDEV_ISO_CONTEXT_MATCH_ALL_TAGS : tag_mask; -+ /* sync is documented as 'not used' */ -+ start_iso.sync = 0; -+ start_iso.handle = 0; -+ -+ return ioctl(handle->iso.fd, FW_CDEV_IOC_START_ISO, &start_iso); -+} -+ -+static int handle_iso_event(raw1394handle_t handle, -+ struct epoll_closure *closure, __uint32_t events) -+{ -+ struct fw_cdev_event_iso_interrupt *interrupt; -+ int len; -+ -+ len = read(handle->iso.fd, handle->buffer, sizeof handle->buffer); -+ if (len < 0) -+ return -1; -+ -+ interrupt = (struct fw_cdev_event_iso_interrupt *) handle->buffer; -+ if (interrupt->type != FW_CDEV_EVENT_ISO_INTERRUPT) -+ return 0; -+ -+ switch (handle->iso.type) { -+ case FW_CDEV_ISO_CONTEXT_TRANSMIT: -+ handle->iso.packet_count -= handle->iso.irq_interval; -+ return queue_xmit_packets(handle, handle->iso.buf_packets); -+ case FW_CDEV_ISO_CONTEXT_RECEIVE: -+ return flush_recv_packets(handle, interrupt); -+ default: -+ /* Doesn't happen. */ -+ return -1; -+ } -+} -+ -+int raw1394_iso_xmit_write(raw1394handle_t handle, unsigned char *data, -+ unsigned int len, unsigned char tag, -+ unsigned char sy) -+{ -+ struct fw_cdev_queue_iso queue_iso; -+ struct fw_cdev_start_iso start_iso; -+ struct fw_cdev_iso_packet *p; -+ -+ if (len > handle->iso.max_packet_size) { -+ errno = EINVAL; -+ return -1; -+ } -+ -+ /* Block until we have space for another packet. */ -+ while (handle->iso.packet_count + handle->iso.irq_interval > -+ handle->iso.buf_packets) -+ raw1394_loop_iterate(handle); -+ -+ memcpy(handle->iso.head, data, len); -+ if (queue_packet(handle, len, 0, tag, sy) < 0) -+ return -1; -+ -+ /* Start the streaming if it's not already running and if -+ * we've buffered up enough packets. */ -+ if (handle->iso.prebuffer > 0 && -+ handle->iso.packet_count >= handle->iso.prebuffer) { -+ /* Set this to 0 to indicate that we're running. */ -+ handle->iso.prebuffer = 0; -+ start_iso.cycle = handle->iso.start_on_cycle; -+ start_iso.handle = 0; -+ -+ len = ioctl(handle->iso.fd, -+ FW_CDEV_IOC_START_ISO, &start_iso); -+ if (len < 0) -+ return len; -+ } -+ -+ return 0; -+} -+ -+int raw1394_iso_xmit_sync(raw1394handle_t handle) -+{ -+ struct fw_cdev_iso_packet skip; -+ struct fw_cdev_queue_iso queue_iso; -+ int len; -+ -+ skip.payload_length = 0; -+ skip.interrupt = 1; -+ skip.skip = 1; -+ skip.tag = 0; -+ skip.sy = 0; -+ skip.header_length = 0; -+ -+ queue_iso.packets = ptr_to_u64(&skip); -+ queue_iso.size = sizeof skip; -+ queue_iso.data = 0; -+ queue_iso.handle = 0; -+ -+ len = ioctl(handle->iso.fd, FW_CDEV_IOC_QUEUE_ISO, &queue_iso); -+ if (len < 0) -+ return -1; -+ -+ /* Now that we've queued the skip packet, we'll get an -+ * interrupt when the transmit buffer is flushed, so all we do -+ * here is wait. */ -+ while (handle->iso.packet_count > 0) -+ raw1394_loop_iterate(handle); -+ -+ /* The iso mainloop thinks that interrutps indicate another -+ * irq_interval number of packets was sent, so the skip -+ * interrupt makes it go out of whack. We just reset it. */ -+ handle->iso.head = handle->iso.buffer; -+ handle->iso.tail = handle->iso.buffer; -+ handle->iso.first_payload = handle->iso.buffer; -+ handle->iso.packet_phase = 0; -+ handle->iso.packet_count = 0; -+ -+ return 0; -+} -+ -+int raw1394_iso_recv_flush(raw1394handle_t handle) -+{ -+ /* FIXME: huh, we'll need kernel support here... */ -+ -+ return 0; -+} -+ -+static unsigned int -+round_to_power_of_two(unsigned int value) -+{ -+ unsigned int pot; -+ -+ pot = 1; -+ while (pot < value) -+ pot <<= 1; -+ -+ return pot; -+} -+ -+static int -+iso_init(raw1394handle_t handle, int type, -+ raw1394_iso_xmit_handler_t xmit_handler, -+ raw1394_iso_recv_handler_t recv_handler, -+ unsigned int buf_packets, -+ unsigned int max_packet_size, -+ unsigned char channel, -+ enum raw1394_iso_speed speed, -+ int irq_interval) -+{ -+ struct fw_cdev_create_iso_context create; -+ struct epoll_event ep; -+ int retval, prot; -+ -+ if (handle->iso.fd != -1) { -+ errno = EBUSY; -+ return -1; -+ } -+ -+ switch (type) { -+ case FW_CDEV_ISO_CONTEXT_TRANSMIT: -+ prot = PROT_READ | PROT_WRITE; -+ break; -+ case FW_CDEV_ISO_CONTEXT_RECEIVE: -+ prot = PROT_READ; -+ break; -+ default: -+ errno = EINVAL; -+ return -1; -+ } -+ -+ handle->iso.type = type; -+ if (irq_interval < 0) -+ handle->iso.irq_interval = 256; -+ else -+ handle->iso.irq_interval = irq_interval; -+ handle->iso.xmit_handler = xmit_handler; -+ handle->iso.recv_handler = recv_handler; -+ handle->iso.buf_packets = buf_packets; -+ handle->iso.max_packet_size = round_to_power_of_two(max_packet_size); -+ handle->iso.packet_phase = 0; -+ handle->iso.packet_count = 0; -+ handle->iso.packets = -+ malloc(handle->iso.irq_interval * sizeof handle->iso.packets[0]); -+ if (handle->iso.packets == NULL) -+ return -1; -+ -+ handle->iso.fd = open(handle->local_filename, O_RDWR); -+ if (handle->iso.fd < 0) { -+ free(handle->iso.packets); -+ return -1; -+ } -+ -+ handle->iso.closure.func = handle_iso_event; -+ ep.events = EPOLLIN; -+ ep.data.ptr = &handle->iso.closure; -+ if (epoll_ctl(handle->epoll_fd, EPOLL_CTL_ADD, -+ handle->iso.fd, &ep) < 0) { -+ close(handle->iso.fd); -+ free(handle->iso.packets); -+ return -1; -+ } -+ -+ create.type = type; -+ create.channel = channel; -+ create.speed = speed; -+ create.header_size = 4; -+ -+ retval = ioctl(handle->iso.fd, -+ FW_CDEV_IOC_CREATE_ISO_CONTEXT, &create); -+ if (retval < 0) { -+ close(handle->iso.fd); -+ free(handle->iso.packets); -+ return retval; -+ } -+ -+ handle->iso.buffer = -+ mmap(NULL, buf_packets * max_packet_size, -+ prot, MAP_SHARED, handle->iso.fd, 0); -+ -+ if (handle->iso.buffer == MAP_FAILED) { -+ close(handle->iso.fd); -+ free(handle->iso.packets); -+ return -1; -+ } -+ -+ handle->iso.buffer_end = handle->iso.buffer + -+ buf_packets * max_packet_size; -+ handle->iso.head = handle->iso.buffer; -+ handle->iso.tail = handle->iso.buffer; -+ handle->iso.first_payload = handle->iso.buffer; -+ -+ return 0; -+} -+ -+int raw1394_iso_xmit_init(raw1394handle_t handle, -+ raw1394_iso_xmit_handler_t handler, -+ unsigned int buf_packets, -+ unsigned int max_packet_size, -+ unsigned char channel, -+ enum raw1394_iso_speed speed, -+ int irq_interval) -+{ -+ return iso_init(handle, FW_CDEV_ISO_CONTEXT_TRANSMIT, -+ handler, NULL, buf_packets, max_packet_size, -+ channel, speed, irq_interval); -+} -+ -+int raw1394_iso_recv_init(raw1394handle_t handle, -+ raw1394_iso_recv_handler_t handler, -+ unsigned int buf_packets, -+ unsigned int max_packet_size, -+ unsigned char channel, -+ enum raw1394_iso_dma_recv_mode mode, -+ int irq_interval) -+{ -+ return iso_init(handle, FW_CDEV_ISO_CONTEXT_RECEIVE, -+ NULL, handler, buf_packets, max_packet_size, -+ channel, 0, irq_interval); -+} -+ -+int raw1394_iso_multichannel_recv_init(raw1394handle_t handle, -+ raw1394_iso_recv_handler_t handler, -+ unsigned int buf_packets, -+ unsigned int max_packet_size, -+ int irq_interval) -+{ -+ /* FIXME: gah */ -+ errno = ENOSYS; -+ return -1; -+} -+ -+int raw1394_iso_recv_listen_channel(raw1394handle_t handle, -+ unsigned char channel) -+{ -+ /* FIXME: multichannel */ -+ errno = ENOSYS; -+ return -1; -+} -+ -+int raw1394_iso_recv_unlisten_channel(raw1394handle_t handle, -+ unsigned char channel) -+{ -+ /* FIXME: multichannel */ -+ errno = ENOSYS; -+ return -1; -+} -+ -+int raw1394_iso_recv_set_channel_mask(raw1394handle_t handle, u_int64_t mask) -+{ -+ /* FIXME: multichannel */ -+ errno = ENOSYS; -+ return -1; -+} -+ -+void raw1394_iso_stop(raw1394handle_t handle) -+{ -+ struct fw_cdev_stop_iso stop_iso; -+ -+ stop_iso.handle = 0; -+ ioctl(handle->iso.fd, FW_CDEV_IOC_STOP_ISO); -+ -+ handle->iso.head = handle->iso.buffer; -+ handle->iso.tail = handle->iso.buffer; -+ handle->iso.first_payload = handle->iso.buffer; -+ handle->iso.packet_phase = 0; -+ handle->iso.packet_count = 0; -+} -+ -+void raw1394_iso_shutdown(raw1394handle_t handle) -+{ -+ munmap(handle->iso.buffer, -+ handle->iso.buf_packets * handle->iso.max_packet_size); -+ close(handle->iso.fd); -+ free(handle->iso.packets); -+} -diff -Naurp libraw1394-1.3.0.orig/Makefile.am libraw1394-1.3.0/Makefile.am ---- libraw1394-1.3.0.orig/Makefile.am 2004-11-05 19:26:44.000000000 -0500 -+++ libraw1394-1.3.0/Makefile.am 2007-10-18 22:18:46.000000000 -0400 -@@ -1,6 +1,7 @@ - # process this file with automake to create a Makefile.in - --SUBDIRS = src tools doc debian -+SUBDIRS = $(LIB_SUBDIR) tools doc debian -+DIST_SUBDIRS = src juju - - pkgconfigdir = @libdir@/pkgconfig - pkgconfig_DATA = libraw1394.pc -diff -Naurp libraw1394-1.3.0.orig/tools/Makefile.am libraw1394-1.3.0/tools/Makefile.am ---- libraw1394-1.3.0.orig/tools/Makefile.am 2004-11-05 19:26:44.000000000 -0500 -+++ libraw1394-1.3.0/tools/Makefile.am 2007-10-18 22:18:46.000000000 -0400 -@@ -2,4 +2,4 @@ MAINTAINERCLEANFILES = Makefile.in - - # testlibraw - bin_PROGRAMS = testlibraw sendiso dumpiso --LDADD = ../src/libraw1394.la -+LDADD = ../$(LIB_SUBDIR)/libraw1394.la -diff -Naurp libraw1394-1.3.0.orig/tools/testlibraw.c libraw1394-1.3.0/tools/testlibraw.c ---- libraw1394-1.3.0.orig/tools/testlibraw.c 2004-01-31 15:26:03.000000000 -0500 -+++ libraw1394-1.3.0/tools/testlibraw.c 2007-10-18 22:18:46.000000000 -0400 -@@ -1,4 +1,5 @@ --/* -+/* -*- c-basic-offset: 8 -*- -+ * - * libraw1394 - library for raw access to the 1394 bus with the Linux subsystem. - * - * Copyright (C) 1999,2000 Andreas Bombe -@@ -13,12 +14,13 @@ - #include - #include - #include -+#include - - #include "../src/raw1394.h" - #include "../src/csr.h" - - --#define TESTADDR (CSR_REGISTER_BASE + CSR_CYCLE_TIME) -+#define TESTADDR (CSR_REGISTER_BASE + CSR_CONFIG_ROM) - - const char not_compatible[] = "\ - This libraw1394 does not work with your version of Linux. You need a different\n\ -@@ -45,12 +47,18 @@ int my_tag_handler(raw1394handle_t handl - return 0; - } - -+static const unsigned char fcp_data[] = -+ { 0x1, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }; -+ - int my_fcp_handler(raw1394handle_t handle, nodeid_t nodeid, int response, - size_t length, unsigned char *data) - { - printf("got fcp %s from node %d of %d bytes:", - (response ? "response" : "command"), nodeid & 0x3f, length); - -+ if (memcmp(fcp_data, data, sizeof fcp_data) != 0) -+ printf("ERROR: fcp payload not correct\n"); -+ - while (length) { - printf(" %02x", *data); - data++; -@@ -62,6 +70,47 @@ int my_fcp_handler(raw1394handle_t handl - return 0; - } - -+static void -+test_fcp(raw1394handle_t handle) -+{ -+ printf("\ntesting FCP monitoring on local node\n"); -+ raw1394_set_fcp_handler(handle, my_fcp_handler); -+ raw1394_start_fcp_listen(handle); -+ raw1394_write(handle, raw1394_get_local_id(handle), -+ CSR_REGISTER_BASE + CSR_FCP_COMMAND, sizeof(fcp_data), -+ (quadlet_t *)fcp_data); -+ raw1394_write(handle, raw1394_get_local_id(handle), -+ CSR_REGISTER_BASE + CSR_FCP_RESPONSE, sizeof(fcp_data), -+ (quadlet_t *)fcp_data); -+} -+ -+static void -+read_topology_map(raw1394handle_t handle) -+{ -+ quadlet_t map[70]; -+ nodeid_t local_id; -+ int node_count, self_id_count, i, retval; -+ -+ local_id = raw1394_get_local_id(handle) | 0xffc0; -+ -+ retval = raw1394_read(handle, local_id, -+ CSR_REGISTER_BASE + CSR_TOPOLOGY_MAP, 12, &map[0]); -+ if (retval < 0) -+ perror("topology map: raw1394_read failed with error"); -+ -+ self_id_count = ntohl(map[2]) & 0xffff; -+ node_count = ntohl(map[2]) >> 16; -+ retval = raw1394_read(handle, local_id, -+ CSR_REGISTER_BASE + CSR_TOPOLOGY_MAP + 12, -+ self_id_count * sizeof map[0], &map[3]); -+ if (retval < 0) -+ perror("topology map: raw1394_read failed with error"); -+ -+ printf("topology map: %d nodes, %d self ids, generation %d\n", -+ node_count, self_id_count, ntohl(map[1])); -+ for (i = 0; i < self_id_count; i++) -+ printf(" 0x%08x\n", ntohl(map[3 + i])); -+} - - int main(int argc, char **argv) - { -@@ -73,7 +122,6 @@ int main(int argc, char **argv) - int retval; - - struct pollfd pfd; -- unsigned char fcp_test[] = { 0x1, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }; - quadlet_t rom[0x100]; - size_t rom_size; - unsigned char rom_version; -@@ -150,17 +198,8 @@ int main(int argc, char **argv) - } - } - -- printf("\ntesting FCP monitoring on local node\n"); -- raw1394_set_fcp_handler(handle, my_fcp_handler); -- raw1394_start_fcp_listen(handle); -- raw1394_write(handle, raw1394_get_local_id(handle), -- CSR_REGISTER_BASE + CSR_FCP_COMMAND, sizeof(fcp_test), -- (quadlet_t *)fcp_test); -- raw1394_write(handle, raw1394_get_local_id(handle), -- CSR_REGISTER_BASE + CSR_FCP_RESPONSE, sizeof(fcp_test), -- (quadlet_t *)fcp_test); -- -- -+ test_fcp(handle); -+ read_topology_map(handle); - - printf("testing config rom stuff\n"); - retval=raw1394_get_config_rom(handle, rom, 0x100, &rom_size, &rom_version); -@@ -176,16 +215,19 @@ int main(int argc, char **argv) - retval=raw1394_update_config_rom(handle, rom, rom_size, rom_version); - printf("update_config_rom returned %d\n",retval); - -+ printf("\nposting 0xdeadbeef as an echo request\n"); -+ raw1394_echo_request(handle, 0xdeadbeef); - -- -- printf("\npolling for leftover messages\n"); -+ printf("polling for leftover messages\n"); - pfd.fd = raw1394_get_fd(handle); - pfd.events = POLLIN; - pfd.revents = 0; - while (1) { - retval = poll(&pfd, 1, 10); - if (retval < 1) break; -- raw1394_loop_iterate(handle); -+ retval = raw1394_loop_iterate(handle); -+ if (retval != 0) -+ printf("raw1394_loop_iterate() returned 0x%08x\n", retval); - } - - if (retval < 0) perror("poll failed"); diff --git a/libraw1394-memset-and-patch-up-leaks-git.patch b/libraw1394-memset-and-patch-up-leaks-git.patch new file mode 100644 index 0000000..7d432e9 --- /dev/null +++ b/libraw1394-memset-and-patch-up-leaks-git.patch @@ -0,0 +1,140 @@ +Originally submitted via Red Hat bugzilla by Philippe Troin: +https://bugzilla.redhat.com/show_bug.cgi?id=451727 + +Description: + +While trying to track down some crashes in kino, I found the following problems +with libraw1394: + + * There is a DIR* leak in raw1394_set_port(). + * Lots of data structures are not fully initialized when calling IEEE1394 + ioctl()s. These cause valgrind errors (benign, as valgrind does not know + how to interpret all ioctls. However these also cause kino to crash in + libraw1394. I've added a bunch of memset()s to prevent this problem from + happening. + +Author: Philippe Troin + +Forward-ported to libraw1394 git tree by Jarod Wilson. + +Signed-off-by: Jarod Wilson + +-- + + src/fw-iso.c | 2 ++ + src/fw.c | 15 ++++++++++++++- + tools/testlibraw.c | 1 + + 3 files changed, 17 insertions(+), 1 deletions(-) + +diff --git a/src/fw-iso.c b/src/fw-iso.c +index 471d981..a1794c3 100644 +--- a/src/fw-iso.c ++++ b/src/fw-iso.c +@@ -401,6 +401,7 @@ iso_init(fw_handle_t handle, int type, + } + + handle->iso.closure.func = handle_iso_event; ++ memset(&ep, 0, sizeof(ep)); + ep.events = EPOLLIN; + ep.data.ptr = &handle->iso.closure; + if (epoll_ctl(handle->epoll_fd, EPOLL_CTL_ADD, +@@ -411,6 +412,7 @@ iso_init(fw_handle_t handle, int type, + return -1; + } + ++ memset(&create, 0, sizeof(create)); + create.type = type; + create.channel = channel; + create.speed = speed; +diff --git a/src/fw.c b/src/fw.c +index 1322fe2..3c61385 100644 +--- a/src/fw.c ++++ b/src/fw.c +@@ -149,6 +149,8 @@ scan_devices(fw_handle_t handle) + fd = open(filename, O_RDWR); + if (fd < 0) + continue; ++ memset(&get_info, 0, sizeof(get_info)); ++ memset(&reset, 0, sizeof(reset)); + get_info.version = FW_CDEV_VERSION; + get_info.rom = 0; + get_info.rom_length = 0; +@@ -404,7 +406,10 @@ fw_handle_t fw_new_handle(void) + struct epoll_event ep; + int i; + ++ memset(&ep, 0, sizeof(ep)); ++ + handle = malloc(sizeof *handle); ++ memset(handle, 0, sizeof(*handle)); + + handle->tag_handler = default_tag_handler; + handle->arm_tag_handler = default_arm_tag_handler; +@@ -580,6 +585,8 @@ int fw_set_port(fw_handle_t handle, int port) + if (fd < 0) + continue; + ++ memset(&get_info, 0, sizeof(get_info)); ++ memset(&reset, 0, sizeof(reset)); + get_info.version = FW_CDEV_VERSION; + get_info.rom = 0; + get_info.rom_length = 0; +@@ -603,10 +610,12 @@ int fw_set_port(fw_handle_t handle, int port) + sizeof handle->devices[i].filename); + + handle->devices[i].closure.func = handle_device_event; ++ memset(&ep, 0, sizeof(ep)); + ep.events = EPOLLIN; + ep.data.ptr = &handle->devices[i].closure; + if (epoll_ctl(handle->epoll_fd, EPOLL_CTL_ADD, fd, &ep) < 0) { + close(fd); ++ closedir(dir); + return -1; + } + +@@ -621,6 +630,8 @@ int fw_set_port(fw_handle_t handle, int port) + i++; + } + ++ closedir(dir); ++ + return 0; + } + +@@ -1220,6 +1231,7 @@ fw_start_fcp_listen(fw_handle_t handle) + + closure->callback = handle_fcp_request; + ++ memset(&request, 0, sizeof(request)); + request.offset = CSR_REGISTER_BASE + CSR_FCP_COMMAND; + request.length = CSR_FCP_END - CSR_FCP_COMMAND; + request.closure = ptr_to_u64(closure); +@@ -1256,6 +1268,7 @@ fw_get_config_rom(fw_handle_t handle, quadlet_t *buffer, + struct fw_cdev_get_info get_info; + int err; + ++ memset(&get_info, 0, sizeof(get_info)); + get_info.version = FW_CDEV_VERSION; + get_info.rom = ptr_to_u64(buffer); + get_info.rom_length = buffersize; +@@ -1284,7 +1297,7 @@ fw_bandwidth_modify (raw1394handle_t handle, + + if (bandwidth == 0) + return 0; +- ++ + addr = CSR_REGISTER_BASE + CSR_BANDWIDTH_AVAILABLE; + /* Read current bandwidth usage from IRM. */ + result = raw1394_read (handle, raw1394_get_irm_id (handle), addr, +diff --git a/tools/testlibraw.c b/tools/testlibraw.c +index 2f02a6d..efd87ad 100644 +--- a/tools/testlibraw.c ++++ b/tools/testlibraw.c +@@ -202,6 +202,7 @@ int main(int argc, char **argv) + read_topology_map(handle); + + printf("testing config rom stuff\n"); ++ memset(rom, 0, sizeof(rom)); + retval=raw1394_get_config_rom(handle, rom, 0x100, &rom_size, &rom_version); + printf("get_config_rom returned %d, romsize %d, rom_version %d\n",retval,rom_size,rom_version); + printf("here are the first 10 quadlets:\n"); diff --git a/libraw1394.spec b/libraw1394.spec index 48d6fe0..c7dc27c 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,23 +1,27 @@ +%define gitrev 20080430_git + Summary: Library providing low-level IEEE-1394 access Name: libraw1394 -Version: 1.3.0 -Release: 6%{?dist} +Version: 2.0.0 +Release: 0.1.%{gitrev}%{?dist} License: LGPLv2+ Group: System Environment/Libraries -Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz +#Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz +# Pre-2.0.0 snapshot generated from git://dennedy.org/libraw1394.git +Source: %{name}-%{version}-%{gitrev}.tar.bz2 URL: http://www.linux1394.org/ ExcludeArch: s390 s390x BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: autoconf automake libtool kernel-headers -Patch0: libraw1394-juju.patch -Patch1: libraw1394-juju-no-double-free-on-shutdown.patch -Patch2: libraw1394-juju-bitfield-update.patch -Patch3: libraw1394-juju-munmap-correct-max_packet_size.patch +Patch0: libraw1394-memset-and-patch-up-leaks-git.patch %description The libraw1394 library provides direct access to the IEEE-1394 bus through -the Linux 1394 subsystem's raw1394 user space interface. +the Linux 1394 subsystem's raw1394 user space interface. Support for both +the classic ieee1394 and new firewire linux driver stacks is included, with +run-time detection of the active stack. Fedora comes with the firewire stack +by default. %package devel Summary: Development libs for libraw1394 @@ -31,16 +35,10 @@ Development libraries needed to build applications against libraw1394. %setup -q %patch0 -p1 -%patch1 -p1 -b .free -%patch2 -p1 -b .bitf -%patch3 -p1 -b .munmap %build -aclocal -autoheader -autoconf -automake -%configure --disable-static --with-juju-dir=$PWD/.. +./autogen.sh +%configure --disable-static make %{?_smp_mflags} %install @@ -76,6 +74,14 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Tue Jun 17 2008 Jarod Wilson - 2.0.0-0.1.20080430_git +- Update to pre-2.0.0 git tree, which features merged "juju" firewire + stack support, enabled simultaneously with classic ieee1394 support + +* Tue Jun 17 2008 Jarod Wilson - 1.3.0-7 +- Fully initialize data structures and plug dir leak. Resolves + crashes when used with kino (Philippe Troin, #451727) + * Mon Apr 28 2008 Jarod Wilson - 1.3.0-6 - Unmap the correct memory range on iso receive teardown, fixes segfault on exit from dvgrab (Mladen Kuntner, #444354) diff --git a/sources b/sources index 23e349f..eabe1d8 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -c5d9ab62bd25dba96af010b3471e816a libraw1394-1.3.0.tar.gz +6ef4d6b593d919c36d65856f19be34b5 libraw1394-2.0.0-20080430_git.tar.bz2 From 3083b2968e06aaa1ba0bbabc4a89b7dfff884a4a Mon Sep 17 00:00:00 2001 From: Jarod Wilson Date: Mon, 23 Jun 2008 12:44:29 +0000 Subject: [PATCH 048/100] - Restore ieee1394 raw1394_read_cycle_timer, add firewire variant --- ...394-restore-raw1394_read_cycle_timer.patch | 176 ++++++++++++++++++ libraw1394.spec | 7 +- 2 files changed, 182 insertions(+), 1 deletion(-) create mode 100644 libraw1394-restore-raw1394_read_cycle_timer.patch diff --git a/libraw1394-restore-raw1394_read_cycle_timer.patch b/libraw1394-restore-raw1394_read_cycle_timer.patch new file mode 100644 index 0000000..758ece2 --- /dev/null +++ b/libraw1394-restore-raw1394_read_cycle_timer.patch @@ -0,0 +1,176 @@ +From stefanr@s5r6.in-berlin.de Sat Jun 21 09:38:52 2008 +Return-Path: +Received: from mail.boston.redhat.com ([unix socket]) + by mail.boston.redhat.com (Cyrus v2.2.12-Invoca-RPM-2.2.12-8.1.RHEL4) with LMTPA; + Sat, 21 Jun 2008 12:23:29 -0400 +X-Sieve: CMU Sieve 2.2 +Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) + by mail.boston.redhat.com (8.13.1/8.13.1) with ESMTP id m5LGNTgY024156 + for ; Sat, 21 Jun 2008 12:23:29 -0400 +Received: from mx3.redhat.com (mx3.redhat.com [172.16.48.32]) + by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m5LGNSrM016955 + for ; Sat, 21 Jun 2008 12:23:28 -0400 +Received: from lists-outbound.sourceforge.net (lists-outbound.sourceforge.net [66.35.250.225]) + by mx3.redhat.com (8.13.8/8.13.8) with ESMTP id m5LGNER3009229 + for ; Sat, 21 Jun 2008 12:23:15 -0400 +Received: from sc8-sf-list1-new.sourceforge.net (sc8-sf-list1-new-b.sourceforge.net [10.3.1.93]) + by sc8-sf-spam2.sourceforge.net (Postfix) with ESMTP + id 61A4C13B5E; Sat, 21 Jun 2008 09:23:09 -0700 (PDT) +Received: from sc8-sf-mx2-b.sourceforge.net ([10.3.1.92] + helo=mail.sourceforge.net) + by sc8-sf-list1-new.sourceforge.net with esmtp (Exim 4.43) + id 1KA5r3-0001G2-Jl for linux1394-devel@lists.sourceforge.net; + Sat, 21 Jun 2008 09:22:22 -0700 +Received: from einhorn.in-berlin.de ([192.109.42.8] ident=root) + by mail.sourceforge.net with esmtps (TLSv1:AES256-SHA:256) + (Exim 4.44) id 1KA5ot-0005aS-SV + for linux1394-devel@lists.sourceforge.net; + Sat, 21 Jun 2008 09:20:10 -0700 +X-Envelope-From: stefanr@s5r6.in-berlin.de +Received: from stein ([83.221.231.7]) (authenticated bits=0) + by einhorn.in-berlin.de (8.13.6/8.13.6/Debian-1) with ESMTP id + m5LDcvG8006732; Sat, 21 Jun 2008 15:39:03 +0200 +Date: Sat, 21 Jun 2008 15:38:52 +0200 (CEST) +From: Stefan Richter +Subject: [libraw1394 patch] Fix raw1394_read_cycle_timer after juju + integration +To: Dan Dennedy +Message-ID: +MIME-Version: 1.0 +Content-Disposition: INLINE +X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 +X-Scanned-By: MIMEDefang 2.63 on 172.16.48.32 +X-Scanned-By: MIMEDefang_at_IN-Berlin_e.V. on 192.109.42.8 +X-Spam-Report: Spam Filtering performed by sourceforge.net. + See http://spamassassin.org/tag/ for more details. + Report problems to + http://sf.net/tracker/?func=add&group_id=1&atid=200001 +Cc: linux1394-devel@lists.sourceforge.net, + Pieter Palmers +X-BeenThere: linux1394-devel@lists.sourceforge.net +X-Mailman-Version: 2.1.8 +Precedence: list +List-Id: Linux IEEE 1394 development list + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +Sender: linux1394-devel-bounces@lists.sourceforge.net +Errors-To: linux1394-devel-bounces@lists.sourceforge.net +X-RedHat-Spam-Score: -0.943 +X-Length: 6916 +X-UID: 4508 + +The ieee1394 version of raw1394_read_cycle_timer() fell over the cliff +in "First cut at integrating juju". This brings it back and adds a juju +version of it. + +Also correct a typo in the inline documentation: s/get/read/ +--- + +This is only compile-tested. I have no idea if the juju version works +at all. But at least the ieee1394 part is quite obvious. + + src/dispatch.c | 11 +++++++++++ + src/fw-iso.c | 19 +++++++++++++++++++ + src/fw.h | 2 ++ + src/raw1394.h | 2 +- + 4 files changed, 33 insertions(+), 1 deletions(-) + +diff --git a/src/dispatch.c b/src/dispatch.c +index 4fe805e..aa40071 100644 +--- a/src/dispatch.c ++++ b/src/dispatch.c +@@ -543,3 +543,14 @@ void raw1394_iso_shutdown(raw1394handle_t handle) + else + ieee1394_iso_shutdown(handle->mode.ieee1394); + } ++ ++int raw1394_read_cycle_timer(raw1394handle_t handle, ++ u_int32_t *cycle_timer, u_int64_t *local_time) ++{ ++ if (handle && handle->is_fw) ++ return fw_read_cycle_timer(handle->mode.fw, ++ cycle_timer, local_time); ++ else ++ return ieee1394_read_cycle_timer(handle->mode.ieee1394, ++ cycle_timer, local_time); ++} +diff --git a/src/fw-iso.c b/src/fw-iso.c +index a1794c3..f493444 100644 +--- a/src/fw-iso.c ++++ b/src/fw-iso.c +@@ -529,3 +529,22 @@ void fw_iso_shutdown(fw_handle_t handle) + free(handle->iso.packets); + handle->iso.packets = NULL; + } ++ ++int fw_read_cycle_timer(fw_handle_t handle, ++ u_int32_t *cycle_timer, u_int64_t *local_time) ++{ ++#ifdef FW_CDEV_IOC_GET_CYCLE_TIMER /* added in kernel 2.6.24 */ ++ int err; ++ struct fw_cdev_get_cycle_timer ctr = { 0 }; ++ ++ err = ioctl(handle->iso.fd, FW_CDEV_IOC_GET_CYCLE_TIMER, &ctr); ++ if (!err) { ++ *cycle_timer = ctr.cycle_timer; ++ *local_time = ctr.local_time; ++ } ++ return err; ++#else ++ errno = ENOSYS; ++ return -1; ++#endif /* defined(FW_CDEV_IOC_GET_CYCLE_TIMER) */ ++} +diff --git a/src/fw.h b/src/fw.h +index e3196de..4ee9017 100644 +--- a/src/fw.h ++++ b/src/fw.h +@@ -253,5 +253,7 @@ int fw_iso_recv_unlisten_channel(fw_handle_t handle, + int fw_iso_recv_set_channel_mask(fw_handle_t handle, u_int64_t mask); + void fw_iso_stop(fw_handle_t handle); + void fw_iso_shutdown(fw_handle_t handle); ++int fw_read_cycle_timer(fw_handle_t handle, ++ u_int32_t *cycle_timer, u_int64_t *local_time); + + #endif +diff --git a/src/raw1394.h b/src/raw1394.h +index 1bcdf19..7cc07e6 100644 +--- a/src/raw1394.h ++++ b/src/raw1394.h +@@ -329,7 +329,7 @@ void raw1394_iso_stop(raw1394handle_t handle); + void raw1394_iso_shutdown(raw1394handle_t handle); + + /** +- * raw1394_get_cycle_timer - get the current value of the cycle timer ++ * raw1394_read_cycle_timer - get the current value of the cycle timer + * @handle: libraw1394 handle + * @cycle_timer: buffer for Isochronous Cycle Timer + * @local_time: buffer for local system time in microseconds since Epoch +-- +1.5.4.5 + + +-- +Stefan Richter +-=====-==--- -==- =-=-= +http://arcgraph.de/sr/ + + +------------------------------------------------------------------------- +Check out the new SourceForge.net Marketplace. +It's the best place to buy or sell services for +just about anything Open Source. +http://sourceforge.net/services/buy/index.php +_______________________________________________ +mailing list linux1394-devel@lists.sourceforge.net +https://lists.sourceforge.net/lists/listinfo/linux1394-devel + diff --git a/libraw1394.spec b/libraw1394.spec index c7dc27c..94ec001 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -3,7 +3,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 2.0.0 -Release: 0.1.%{gitrev}%{?dist} +Release: 0.2.%{gitrev}%{?dist} License: LGPLv2+ Group: System Environment/Libraries #Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz @@ -15,6 +15,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: autoconf automake libtool kernel-headers Patch0: libraw1394-memset-and-patch-up-leaks-git.patch +Patch1: libraw1394-restore-raw1394_read_cycle_timer.patch %description The libraw1394 library provides direct access to the IEEE-1394 bus through @@ -35,6 +36,7 @@ Development libraries needed to build applications against libraw1394. %setup -q %patch0 -p1 +%patch1 -p1 %build ./autogen.sh @@ -74,6 +76,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Mon Jun 23 2008 Jarod Wilson - 2.0.0-0.2.20080430_git +- Restore ieee1394 raw1394_read_cycle_timer, add firewire variant + * Tue Jun 17 2008 Jarod Wilson - 2.0.0-0.1.20080430_git - Update to pre-2.0.0 git tree, which features merged "juju" firewire stack support, enabled simultaneously with classic ieee1394 support From cdb72e8774660ea43493ffdaf61e8bc3d3546737 Mon Sep 17 00:00:00 2001 From: Jarod Wilson Date: Fri, 18 Jul 2008 20:51:15 +0000 Subject: [PATCH 049/100] - Update to libraw1394 v2.0.0 release --- .cvsignore | 1 + ...aw1394-memset-and-patch-up-leaks-git.patch | 140 -------------- ...394-restore-raw1394_read_cycle_timer.patch | 176 ------------------ libraw1394.spec | 18 +- sources | 2 +- 5 files changed, 7 insertions(+), 330 deletions(-) delete mode 100644 libraw1394-memset-and-patch-up-leaks-git.patch delete mode 100644 libraw1394-restore-raw1394_read_cycle_timer.patch diff --git a/.cvsignore b/.cvsignore index 750d5f4..22da05b 100644 --- a/.cvsignore +++ b/.cvsignore @@ -3,3 +3,4 @@ libraw1394-1.2.1.tar.gz fw-device-cdev.h libraw1394-1.3.0.tar.gz libraw1394-2.0.0-20080430_git.tar.bz2 +libraw1394-2.0.0.tar.gz diff --git a/libraw1394-memset-and-patch-up-leaks-git.patch b/libraw1394-memset-and-patch-up-leaks-git.patch deleted file mode 100644 index 7d432e9..0000000 --- a/libraw1394-memset-and-patch-up-leaks-git.patch +++ /dev/null @@ -1,140 +0,0 @@ -Originally submitted via Red Hat bugzilla by Philippe Troin: -https://bugzilla.redhat.com/show_bug.cgi?id=451727 - -Description: - -While trying to track down some crashes in kino, I found the following problems -with libraw1394: - - * There is a DIR* leak in raw1394_set_port(). - * Lots of data structures are not fully initialized when calling IEEE1394 - ioctl()s. These cause valgrind errors (benign, as valgrind does not know - how to interpret all ioctls. However these also cause kino to crash in - libraw1394. I've added a bunch of memset()s to prevent this problem from - happening. - -Author: Philippe Troin - -Forward-ported to libraw1394 git tree by Jarod Wilson. - -Signed-off-by: Jarod Wilson - --- - - src/fw-iso.c | 2 ++ - src/fw.c | 15 ++++++++++++++- - tools/testlibraw.c | 1 + - 3 files changed, 17 insertions(+), 1 deletions(-) - -diff --git a/src/fw-iso.c b/src/fw-iso.c -index 471d981..a1794c3 100644 ---- a/src/fw-iso.c -+++ b/src/fw-iso.c -@@ -401,6 +401,7 @@ iso_init(fw_handle_t handle, int type, - } - - handle->iso.closure.func = handle_iso_event; -+ memset(&ep, 0, sizeof(ep)); - ep.events = EPOLLIN; - ep.data.ptr = &handle->iso.closure; - if (epoll_ctl(handle->epoll_fd, EPOLL_CTL_ADD, -@@ -411,6 +412,7 @@ iso_init(fw_handle_t handle, int type, - return -1; - } - -+ memset(&create, 0, sizeof(create)); - create.type = type; - create.channel = channel; - create.speed = speed; -diff --git a/src/fw.c b/src/fw.c -index 1322fe2..3c61385 100644 ---- a/src/fw.c -+++ b/src/fw.c -@@ -149,6 +149,8 @@ scan_devices(fw_handle_t handle) - fd = open(filename, O_RDWR); - if (fd < 0) - continue; -+ memset(&get_info, 0, sizeof(get_info)); -+ memset(&reset, 0, sizeof(reset)); - get_info.version = FW_CDEV_VERSION; - get_info.rom = 0; - get_info.rom_length = 0; -@@ -404,7 +406,10 @@ fw_handle_t fw_new_handle(void) - struct epoll_event ep; - int i; - -+ memset(&ep, 0, sizeof(ep)); -+ - handle = malloc(sizeof *handle); -+ memset(handle, 0, sizeof(*handle)); - - handle->tag_handler = default_tag_handler; - handle->arm_tag_handler = default_arm_tag_handler; -@@ -580,6 +585,8 @@ int fw_set_port(fw_handle_t handle, int port) - if (fd < 0) - continue; - -+ memset(&get_info, 0, sizeof(get_info)); -+ memset(&reset, 0, sizeof(reset)); - get_info.version = FW_CDEV_VERSION; - get_info.rom = 0; - get_info.rom_length = 0; -@@ -603,10 +610,12 @@ int fw_set_port(fw_handle_t handle, int port) - sizeof handle->devices[i].filename); - - handle->devices[i].closure.func = handle_device_event; -+ memset(&ep, 0, sizeof(ep)); - ep.events = EPOLLIN; - ep.data.ptr = &handle->devices[i].closure; - if (epoll_ctl(handle->epoll_fd, EPOLL_CTL_ADD, fd, &ep) < 0) { - close(fd); -+ closedir(dir); - return -1; - } - -@@ -621,6 +630,8 @@ int fw_set_port(fw_handle_t handle, int port) - i++; - } - -+ closedir(dir); -+ - return 0; - } - -@@ -1220,6 +1231,7 @@ fw_start_fcp_listen(fw_handle_t handle) - - closure->callback = handle_fcp_request; - -+ memset(&request, 0, sizeof(request)); - request.offset = CSR_REGISTER_BASE + CSR_FCP_COMMAND; - request.length = CSR_FCP_END - CSR_FCP_COMMAND; - request.closure = ptr_to_u64(closure); -@@ -1256,6 +1268,7 @@ fw_get_config_rom(fw_handle_t handle, quadlet_t *buffer, - struct fw_cdev_get_info get_info; - int err; - -+ memset(&get_info, 0, sizeof(get_info)); - get_info.version = FW_CDEV_VERSION; - get_info.rom = ptr_to_u64(buffer); - get_info.rom_length = buffersize; -@@ -1284,7 +1297,7 @@ fw_bandwidth_modify (raw1394handle_t handle, - - if (bandwidth == 0) - return 0; -- -+ - addr = CSR_REGISTER_BASE + CSR_BANDWIDTH_AVAILABLE; - /* Read current bandwidth usage from IRM. */ - result = raw1394_read (handle, raw1394_get_irm_id (handle), addr, -diff --git a/tools/testlibraw.c b/tools/testlibraw.c -index 2f02a6d..efd87ad 100644 ---- a/tools/testlibraw.c -+++ b/tools/testlibraw.c -@@ -202,6 +202,7 @@ int main(int argc, char **argv) - read_topology_map(handle); - - printf("testing config rom stuff\n"); -+ memset(rom, 0, sizeof(rom)); - retval=raw1394_get_config_rom(handle, rom, 0x100, &rom_size, &rom_version); - printf("get_config_rom returned %d, romsize %d, rom_version %d\n",retval,rom_size,rom_version); - printf("here are the first 10 quadlets:\n"); diff --git a/libraw1394-restore-raw1394_read_cycle_timer.patch b/libraw1394-restore-raw1394_read_cycle_timer.patch deleted file mode 100644 index 758ece2..0000000 --- a/libraw1394-restore-raw1394_read_cycle_timer.patch +++ /dev/null @@ -1,176 +0,0 @@ -From stefanr@s5r6.in-berlin.de Sat Jun 21 09:38:52 2008 -Return-Path: -Received: from mail.boston.redhat.com ([unix socket]) - by mail.boston.redhat.com (Cyrus v2.2.12-Invoca-RPM-2.2.12-8.1.RHEL4) with LMTPA; - Sat, 21 Jun 2008 12:23:29 -0400 -X-Sieve: CMU Sieve 2.2 -Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) - by mail.boston.redhat.com (8.13.1/8.13.1) with ESMTP id m5LGNTgY024156 - for ; Sat, 21 Jun 2008 12:23:29 -0400 -Received: from mx3.redhat.com (mx3.redhat.com [172.16.48.32]) - by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m5LGNSrM016955 - for ; Sat, 21 Jun 2008 12:23:28 -0400 -Received: from lists-outbound.sourceforge.net (lists-outbound.sourceforge.net [66.35.250.225]) - by mx3.redhat.com (8.13.8/8.13.8) with ESMTP id m5LGNER3009229 - for ; Sat, 21 Jun 2008 12:23:15 -0400 -Received: from sc8-sf-list1-new.sourceforge.net (sc8-sf-list1-new-b.sourceforge.net [10.3.1.93]) - by sc8-sf-spam2.sourceforge.net (Postfix) with ESMTP - id 61A4C13B5E; Sat, 21 Jun 2008 09:23:09 -0700 (PDT) -Received: from sc8-sf-mx2-b.sourceforge.net ([10.3.1.92] - helo=mail.sourceforge.net) - by sc8-sf-list1-new.sourceforge.net with esmtp (Exim 4.43) - id 1KA5r3-0001G2-Jl for linux1394-devel@lists.sourceforge.net; - Sat, 21 Jun 2008 09:22:22 -0700 -Received: from einhorn.in-berlin.de ([192.109.42.8] ident=root) - by mail.sourceforge.net with esmtps (TLSv1:AES256-SHA:256) - (Exim 4.44) id 1KA5ot-0005aS-SV - for linux1394-devel@lists.sourceforge.net; - Sat, 21 Jun 2008 09:20:10 -0700 -X-Envelope-From: stefanr@s5r6.in-berlin.de -Received: from stein ([83.221.231.7]) (authenticated bits=0) - by einhorn.in-berlin.de (8.13.6/8.13.6/Debian-1) with ESMTP id - m5LDcvG8006732; Sat, 21 Jun 2008 15:39:03 +0200 -Date: Sat, 21 Jun 2008 15:38:52 +0200 (CEST) -From: Stefan Richter -Subject: [libraw1394 patch] Fix raw1394_read_cycle_timer after juju - integration -To: Dan Dennedy -Message-ID: -MIME-Version: 1.0 -Content-Disposition: INLINE -X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 -X-Scanned-By: MIMEDefang 2.63 on 172.16.48.32 -X-Scanned-By: MIMEDefang_at_IN-Berlin_e.V. on 192.109.42.8 -X-Spam-Report: Spam Filtering performed by sourceforge.net. - See http://spamassassin.org/tag/ for more details. - Report problems to - http://sf.net/tracker/?func=add&group_id=1&atid=200001 -Cc: linux1394-devel@lists.sourceforge.net, - Pieter Palmers -X-BeenThere: linux1394-devel@lists.sourceforge.net -X-Mailman-Version: 2.1.8 -Precedence: list -List-Id: Linux IEEE 1394 development list - -List-Unsubscribe: , - -List-Archive: -List-Post: -List-Help: -List-Subscribe: , - -Content-Type: text/plain; - charset="us-ascii" -Content-Transfer-Encoding: 7bit -Sender: linux1394-devel-bounces@lists.sourceforge.net -Errors-To: linux1394-devel-bounces@lists.sourceforge.net -X-RedHat-Spam-Score: -0.943 -X-Length: 6916 -X-UID: 4508 - -The ieee1394 version of raw1394_read_cycle_timer() fell over the cliff -in "First cut at integrating juju". This brings it back and adds a juju -version of it. - -Also correct a typo in the inline documentation: s/get/read/ ---- - -This is only compile-tested. I have no idea if the juju version works -at all. But at least the ieee1394 part is quite obvious. - - src/dispatch.c | 11 +++++++++++ - src/fw-iso.c | 19 +++++++++++++++++++ - src/fw.h | 2 ++ - src/raw1394.h | 2 +- - 4 files changed, 33 insertions(+), 1 deletions(-) - -diff --git a/src/dispatch.c b/src/dispatch.c -index 4fe805e..aa40071 100644 ---- a/src/dispatch.c -+++ b/src/dispatch.c -@@ -543,3 +543,14 @@ void raw1394_iso_shutdown(raw1394handle_t handle) - else - ieee1394_iso_shutdown(handle->mode.ieee1394); - } -+ -+int raw1394_read_cycle_timer(raw1394handle_t handle, -+ u_int32_t *cycle_timer, u_int64_t *local_time) -+{ -+ if (handle && handle->is_fw) -+ return fw_read_cycle_timer(handle->mode.fw, -+ cycle_timer, local_time); -+ else -+ return ieee1394_read_cycle_timer(handle->mode.ieee1394, -+ cycle_timer, local_time); -+} -diff --git a/src/fw-iso.c b/src/fw-iso.c -index a1794c3..f493444 100644 ---- a/src/fw-iso.c -+++ b/src/fw-iso.c -@@ -529,3 +529,22 @@ void fw_iso_shutdown(fw_handle_t handle) - free(handle->iso.packets); - handle->iso.packets = NULL; - } -+ -+int fw_read_cycle_timer(fw_handle_t handle, -+ u_int32_t *cycle_timer, u_int64_t *local_time) -+{ -+#ifdef FW_CDEV_IOC_GET_CYCLE_TIMER /* added in kernel 2.6.24 */ -+ int err; -+ struct fw_cdev_get_cycle_timer ctr = { 0 }; -+ -+ err = ioctl(handle->iso.fd, FW_CDEV_IOC_GET_CYCLE_TIMER, &ctr); -+ if (!err) { -+ *cycle_timer = ctr.cycle_timer; -+ *local_time = ctr.local_time; -+ } -+ return err; -+#else -+ errno = ENOSYS; -+ return -1; -+#endif /* defined(FW_CDEV_IOC_GET_CYCLE_TIMER) */ -+} -diff --git a/src/fw.h b/src/fw.h -index e3196de..4ee9017 100644 ---- a/src/fw.h -+++ b/src/fw.h -@@ -253,5 +253,7 @@ int fw_iso_recv_unlisten_channel(fw_handle_t handle, - int fw_iso_recv_set_channel_mask(fw_handle_t handle, u_int64_t mask); - void fw_iso_stop(fw_handle_t handle); - void fw_iso_shutdown(fw_handle_t handle); -+int fw_read_cycle_timer(fw_handle_t handle, -+ u_int32_t *cycle_timer, u_int64_t *local_time); - - #endif -diff --git a/src/raw1394.h b/src/raw1394.h -index 1bcdf19..7cc07e6 100644 ---- a/src/raw1394.h -+++ b/src/raw1394.h -@@ -329,7 +329,7 @@ void raw1394_iso_stop(raw1394handle_t handle); - void raw1394_iso_shutdown(raw1394handle_t handle); - - /** -- * raw1394_get_cycle_timer - get the current value of the cycle timer -+ * raw1394_read_cycle_timer - get the current value of the cycle timer - * @handle: libraw1394 handle - * @cycle_timer: buffer for Isochronous Cycle Timer - * @local_time: buffer for local system time in microseconds since Epoch --- -1.5.4.5 - - --- -Stefan Richter --=====-==--- -==- =-=-= -http://arcgraph.de/sr/ - - -------------------------------------------------------------------------- -Check out the new SourceForge.net Marketplace. -It's the best place to buy or sell services for -just about anything Open Source. -http://sourceforge.net/services/buy/index.php -_______________________________________________ -mailing list linux1394-devel@lists.sourceforge.net -https://lists.sourceforge.net/lists/listinfo/linux1394-devel - diff --git a/libraw1394.spec b/libraw1394.spec index 94ec001..5d80015 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,22 +1,15 @@ -%define gitrev 20080430_git - Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 2.0.0 -Release: 0.2.%{gitrev}%{?dist} +Release: 1%{?dist} License: LGPLv2+ Group: System Environment/Libraries -#Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz -# Pre-2.0.0 snapshot generated from git://dennedy.org/libraw1394.git -Source: %{name}-%{version}-%{gitrev}.tar.bz2 +Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz URL: http://www.linux1394.org/ ExcludeArch: s390 s390x BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: autoconf automake libtool kernel-headers -Patch0: libraw1394-memset-and-patch-up-leaks-git.patch -Patch1: libraw1394-restore-raw1394_read_cycle_timer.patch - %description The libraw1394 library provides direct access to the IEEE-1394 bus through the Linux 1394 subsystem's raw1394 user space interface. Support for both @@ -35,11 +28,7 @@ Development libraries needed to build applications against libraw1394. %prep %setup -q -%patch0 -p1 -%patch1 -p1 - %build -./autogen.sh %configure --disable-static make %{?_smp_mflags} @@ -76,6 +65,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Fri Jul 18 2008 Jarod Wilson - 2.0.0-1 +- Update to libraw1394 v2.0.0 release + * Mon Jun 23 2008 Jarod Wilson - 2.0.0-0.2.20080430_git - Restore ieee1394 raw1394_read_cycle_timer, add firewire variant diff --git a/sources b/sources index eabe1d8..8f7dc98 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -6ef4d6b593d919c36d65856f19be34b5 libraw1394-2.0.0-20080430_git.tar.bz2 +f037629cc02509d4f24f6170bd656694 libraw1394-2.0.0.tar.gz From fdb38798c4bda73eee70df0ec134d22c5d158369 Mon Sep 17 00:00:00 2001 From: Jarod Wilson Date: Wed, 1 Oct 2008 15:13:24 +0000 Subject: [PATCH 050/100] - Misc fixes from Erik Hovland, based on coverity prevent analysis --- libraw1394-2.0.0-coverity-prevent-fixes.patch | 298 ++++++++++++++++++ libraw1394.spec | 5 + 2 files changed, 303 insertions(+) create mode 100644 libraw1394-2.0.0-coverity-prevent-fixes.patch diff --git a/libraw1394-2.0.0-coverity-prevent-fixes.patch b/libraw1394-2.0.0-coverity-prevent-fixes.patch new file mode 100644 index 0000000..b6ec3c3 --- /dev/null +++ b/libraw1394-2.0.0-coverity-prevent-fixes.patch @@ -0,0 +1,298 @@ +From: Erik Hovland + +Series of coverity prevent-inspired fixes. + +-- +Makes extra sure strings are not overrun. + +When using strncpy with the exact size of the destination string the +string may end up lacking null termination because the source string is +bigger then the destination. + +-- +Makes sure to check any return values + +The return value of any function should be checked if that function +uses the return value to provide some sort of status information. + +-- +Makes sure a value is returned by the function. + +A function can compile without returning something always. + +-- +Make sure that we have the right types. + +When an unsigned type is assigned a signed value, the +negatived value is never seen. + + +-- +Compare unsigned values instead of subtracting them. + +Unsigned values do not return signed values when subtracted +and the right operand is larger then the left operand. + +-- +Protect against resource leaks. + +-- +Make sure variables are initialized before used. + + +Signed-off-by: Erik Hovland +--- + + src/dispatch.c | 11 ++++++++--- + src/fw-iso.c | 11 +++++++---- + src/fw.c | 49 +++++++++++++++++++++++++++++-------------------- + tools/testlibraw.c | 3 ++- + 4 files changed, 46 insertions(+), 28 deletions(-) + +diff -Naurp libraw1394-2.0.0.orig/src/dispatch.c libraw1394-2.0.0/src/dispatch.c +--- libraw1394-2.0.0.orig/src/dispatch.c 2008-07-06 14:48:17.000000000 -0400 ++++ libraw1394-2.0.0/src/dispatch.c 2008-10-01 10:58:16.000000000 -0400 +@@ -48,7 +48,10 @@ raw1394handle_t raw1394_new_handle(void) + else if (handle) { + handle->is_fw = 1; + handle->mode.fw = fw_handle; +- } ++ } else if (fw_handle) ++ fw_destroy_handle(fw_handle); ++ else if (ieee1394_handle) ++ ieee1394_destroy_handle(ieee1394_handle); + } + return handle; + } +@@ -75,14 +78,16 @@ raw1394handle_t raw1394_new_handle_on_po + if (handle) { + handle->is_fw = 0; + handle->mode.ieee1394 = ieee1394_handle; +- } ++ } else ++ ieee1394_destroy_handle(ieee1394_handle); + } + else if (fw_handle = fw_new_handle_on_port(port)) { + handle = (raw1394handle_t) malloc(sizeof(struct raw1394_handle)); + if (handle) { + handle->is_fw = 1; + handle->mode.fw = fw_handle; +- } ++ } else ++ fw_destroy_handle(fw_handle); + } + return handle; + } +diff -Naurp libraw1394-2.0.0.orig/src/fw.c libraw1394-2.0.0/src/fw.c +--- libraw1394-2.0.0.orig/src/fw.c 2008-07-05 16:09:29.000000000 -0400 ++++ libraw1394-2.0.0/src/fw.c 2008-10-01 10:58:16.000000000 -0400 +@@ -125,7 +125,7 @@ scan_devices(fw_handle_t handle) + char filename[32]; + struct fw_cdev_get_info get_info; + struct fw_cdev_event_bus_reset reset; +- int fd, err, i; ++ int fd, err, i, fname_str_sz; + struct port *ports; + + ports = handle->ports; +@@ -162,8 +162,9 @@ scan_devices(fw_handle_t handle) + continue; + + if (i < MAX_PORTS && reset.node_id == reset.local_node_id) { +- strncpy(ports[i].device_file, filename, +- sizeof ports[i].device_file); ++ fname_str_sz = sizeof(ports[i].device_file) - 1; ++ strncpy(ports[i].device_file, filename, fname_str_sz); ++ ports[i].device_file[fname_str_sz] = '\0'; + ports[i].node_count = (reset.root_node_id & 0x3f) + 1; + ports[i].card = get_info.card; + i++; +@@ -315,7 +316,7 @@ handle_inotify(raw1394handle_t handle, s + struct fw_cdev_get_info info; + struct fw_cdev_event_bus_reset reset; + struct epoll_event ep; +- int i, len, fd, phy_id; ++ int i, len, fd, phy_id, fname_str_sz; + + event = (struct inotify_event *) fwhandle->buffer; + len = read(fwhandle->inotify_fd, event, BUFFER_SIZE); +@@ -365,8 +366,9 @@ handle_inotify(raw1394handle_t handle, s + fwhandle->devices[i].node_id = reset.node_id; + fwhandle->devices[i].generation = reset.generation; + fwhandle->devices[i].fd = fd; +- strncpy(fwhandle->devices[i].filename, filename, +- sizeof fwhandle->devices[i].filename); ++ fname_str_sz = sizeof(fwhandle->devices[i].filename) - 1; ++ strncpy(fwhandle->devices[i].filename, filename, fname_str_sz); ++ fwhandle->devices[i].filename[fname_str_sz] = '\0'; + fwhandle->devices[i].closure.func = handle_device_event; + ep.events = EPOLLIN; + ep.data.ptr = &fwhandle->devices[i].closure; +@@ -501,8 +503,10 @@ fw_handle_t fw_new_handle_on_port(int po + if (handle == NULL) + return NULL; + +- if (fw_set_port(handle, port) < 0) ++ if (fw_set_port(handle, port) < 0) { ++ fw_destroy_handle(handle); + return NULL; ++ } + + return handle; + } +@@ -538,15 +542,17 @@ int fw_get_port_info(fw_handle_t handle, + struct raw1394_portinfo *pinf, + int maxports) + { +- int i; ++ int i, port_name_sz; + + if (maxports >= handle->port_count) + maxports = handle->port_count; + + for (i = 0; i < maxports; i++) { + pinf[i].nodes = handle->ports[i].node_count; ++ port_name_sz = sizeof(pinf[i].name) - 1; + strncpy(pinf[i].name, handle->ports[i].device_file, +- sizeof pinf[i].name); ++ port_name_sz); ++ pinf[i].name[port_name_sz] = '\0'; + } + + return handle->port_count; +@@ -560,7 +566,7 @@ int fw_set_port(fw_handle_t handle, int + struct dirent *de; + char filename[32]; + DIR *dir; +- int i, fd, phy_id; ++ int i, fd, phy_id, fname_str_sz; + + if (port >= handle->port_count) { + errno = EINVAL; +@@ -606,8 +612,9 @@ int fw_set_port(fw_handle_t handle, int + handle->devices[i].node_id = reset.node_id; + handle->devices[i].generation = reset.generation; + handle->devices[i].fd = fd; +- strncpy(handle->devices[i].filename, filename, +- sizeof handle->devices[i].filename); ++ fname_str_sz = sizeof(handle->devices[i].filename) -1; ++ strncpy(handle->devices[i].filename, filename, fname_str_sz); ++ handle->devices[i].filename[fname_str_sz] = '\0'; + + handle->devices[i].closure.func = handle_device_event; + memset(&ep, 0, sizeof(ep)); +@@ -623,8 +630,9 @@ int fw_set_port(fw_handle_t handle, int + if (reset.node_id == reset.local_node_id) { + memcpy(&handle->reset, &reset, sizeof handle->reset); + handle->local_fd = fd; +- strncpy(handle->local_filename, filename, +- sizeof handle->local_filename); ++ fname_str_sz = sizeof(handle->local_filename) -1; ++ strncpy(handle->local_filename, filename, fname_str_sz); ++ handle->local_filename[fname_str_sz] = '\0'; + } + + i++; +@@ -1174,14 +1182,14 @@ fw_lock(raw1394handle_t handle, nodeid_t + quadlet_t *result) + { + quadlet_t buffer[2]; +- size_t length; ++ ssize_t length; + + length = setup_lock(extcode, data, arg, buffer); + if (length < 0) + return length; + + return send_request_sync(handle, 16 + extcode, node, addr, +- length, buffer, result); ++ (size_t) length, buffer, result); + } + + int +@@ -1190,14 +1198,14 @@ fw_lock64(raw1394handle_t handle, nodeid + octlet_t *result) + { + octlet_t buffer[2]; +- size_t length; ++ ssize_t length; + + length = setup_lock64(extcode, data, arg, buffer); + if (length < 0) + return length; + + return send_request_sync(handle, 16 + extcode, node, addr, +- length, buffer, result); ++ (size_t) length, buffer, result); + } + + int +@@ -1308,9 +1316,10 @@ fw_bandwidth_modify (raw1394handle_t han + compare = ntohl (buffer); + switch (mode) { + case RAW1394_MODIFY_ALLOC: +- swap = compare - bandwidth; +- if (swap < 0) ++ if (compare < bandwidth) + return -1; ++ ++ swap = compare - bandwidth; + break; + + case RAW1394_MODIFY_FREE: +diff -Naurp libraw1394-2.0.0.orig/src/fw-iso.c libraw1394-2.0.0/src/fw-iso.c +--- libraw1394-2.0.0.orig/src/fw-iso.c 2008-07-05 16:16:30.000000000 -0400 ++++ libraw1394-2.0.0/src/fw-iso.c 2008-10-01 10:58:40.000000000 -0400 +@@ -76,6 +76,7 @@ queue_packet(fw_handle_t handle, + if (err < 0) + return -1; + } ++ return 0; + } + + static int +@@ -84,7 +85,8 @@ queue_xmit_packets(raw1394handle_t handl + fw_handle_t fwhandle = handle->mode.fw; + enum raw1394_iso_disposition d; + unsigned char tag, sy; +- int len, cycle, dropped; ++ int len, cycle = -1; ++ unsigned int dropped = 0; + + if (fwhandle->iso.xmit_handler == NULL) + return 0; +@@ -259,6 +261,7 @@ int fw_iso_xmit_write(raw1394handle_t ha + struct fw_cdev_queue_iso queue_iso; + struct fw_cdev_start_iso start_iso; + struct fw_cdev_iso_packet *p; ++ int retval; + + if (len > fwhandle->iso.max_packet_size) { + errno = EINVAL; +@@ -283,10 +286,10 @@ int fw_iso_xmit_write(raw1394handle_t ha + start_iso.cycle = fwhandle->iso.start_on_cycle; + start_iso.handle = 0; + +- len = ioctl(fwhandle->iso.fd, ++ retval = ioctl(fwhandle->iso.fd, + FW_CDEV_IOC_START_ISO, &start_iso); +- if (len < 0) +- return len; ++ if (retval < 0) ++ return retval; + } + + return 0; +diff -Naurp libraw1394-2.0.0.orig/tools/testlibraw.c libraw1394-2.0.0/tools/testlibraw.c +--- libraw1394-2.0.0.orig/tools/testlibraw.c 2008-07-05 16:09:29.000000000 -0400 ++++ libraw1394-2.0.0/tools/testlibraw.c 2008-10-01 10:58:02.000000000 -0400 +@@ -180,7 +180,8 @@ int main(int argc, char **argv) + perror("failed"); + continue; + } +- raw1394_loop_iterate(handle); ++ if (raw1394_loop_iterate(handle)) ++ perror("failed"); + } + + printf("\nusing standard tag handler and synchronous calls\n"); diff --git a/libraw1394.spec b/libraw1394.spec index 5d80015..09f839b 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -5,6 +5,7 @@ Release: 1%{?dist} License: LGPLv2+ Group: System Environment/Libraries Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz +Patch0: libraw1394-2.0.0-coverity-prevent-fixes.patch URL: http://www.linux1394.org/ ExcludeArch: s390 s390x BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) @@ -27,6 +28,7 @@ Development libraries needed to build applications against libraw1394. %prep %setup -q +%patch0 -p1 %build %configure --disable-static @@ -65,6 +67,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Wed Oct 01 2008 Jarod Wilson - 2.0.0-2 +- Misc fixes from Erik Hovland, based on coverity prevent analysis + * Fri Jul 18 2008 Jarod Wilson - 2.0.0-1 - Update to libraw1394 v2.0.0 release From 3e099f60f475dca43f6f605c6eb979a9cec303ea Mon Sep 17 00:00:00 2001 From: Jarod Wilson Date: Wed, 1 Oct 2008 15:19:18 +0000 Subject: [PATCH 051/100] oops, update release field --- libraw1394.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index 09f839b..59a6266 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 2.0.0 -Release: 1%{?dist} +Release: 2%{?dist} License: LGPLv2+ Group: System Environment/Libraries Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz From b5eeebf7952aa2609f7a6d30c0d7be7439cd251a Mon Sep 17 00:00:00 2001 From: Jarod Wilson Date: Thu, 20 Nov 2008 17:43:25 +0000 Subject: [PATCH 052/100] - Address some compiler warnings - Reduce nesting depth in new_handle dispatches - Fix segfault in handle_arm_request --- libraw1394-2.0.0-git-fixes.patch | 200 +++++++++++++++++++++++++++++++ libraw1394.spec | 9 +- 2 files changed, 208 insertions(+), 1 deletion(-) create mode 100644 libraw1394-2.0.0-git-fixes.patch diff --git a/libraw1394-2.0.0-git-fixes.patch b/libraw1394-2.0.0-git-fixes.patch new file mode 100644 index 0000000..c5ba75f --- /dev/null +++ b/libraw1394-2.0.0-git-fixes.patch @@ -0,0 +1,200 @@ +diff -Naurp libraw1394-2.0.0/src/arm.c libraw1394-2.0.0.fix/src/arm.c +--- libraw1394-2.0.0/src/arm.c 2008-07-05 16:08:26.000000000 -0400 ++++ libraw1394-2.0.0.fix/src/arm.c 2008-11-20 12:37:05.136821199 -0500 +@@ -109,7 +109,6 @@ int ieee1394_arm_set_buf (struct ieee139 + size_t length, void *buf) + { + struct raw1394_request req; +- int status; + + CLEAR_REQ(&req); + +@@ -139,7 +138,6 @@ int ieee1394_arm_get_buf (struct ieee139 + size_t length, void *buf) + { + struct raw1394_request req; +- int status; + + CLEAR_REQ(&req); + +diff -Naurp libraw1394-2.0.0/src/dispatch.c libraw1394-2.0.0.fix/src/dispatch.c +--- libraw1394-2.0.0/src/dispatch.c 2008-11-20 12:36:00.918753368 -0500 ++++ libraw1394-2.0.0.fix/src/dispatch.c 2008-11-20 12:42:03.387817813 -0500 +@@ -24,36 +24,35 @@ int raw1394_errcode_to_errno(raw1394_err + + raw1394handle_t raw1394_new_handle(void) + { +- ieee1394handle_t ieee1394_handle = ieee1394_new_handle(); +- fw_handle_t fw_handle = NULL; +- raw1394handle_t handle = NULL; +- +- if (ieee1394_handle) { +- struct raw1394_portinfo port; +- if (ieee1394_get_port_info(ieee1394_handle, &port, 1) < 1) { +- ieee1394_destroy_handle(ieee1394_handle); +- ieee1394_handle = NULL; +- fw_handle = fw_new_handle(); +- } +- } +- else { +- fw_handle = fw_new_handle(); +- } +- if (ieee1394_handle || fw_handle) { +- handle = (raw1394handle_t) malloc(sizeof(struct raw1394_handle)); +- if (ieee1394_handle && handle) { +- handle->is_fw = 0; +- handle->mode.ieee1394 = ieee1394_handle; +- } +- else if (handle) { +- handle->is_fw = 1; +- handle->mode.fw = fw_handle; +- } else if (fw_handle) +- fw_destroy_handle(fw_handle); +- else if (ieee1394_handle) +- ieee1394_destroy_handle(ieee1394_handle); ++ ieee1394handle_t ieee1394_handle; ++ fw_handle_t fw_handle; ++ raw1394handle_t handle; ++ struct raw1394_portinfo port; ++ ++ handle = (raw1394handle_t) malloc(sizeof(struct raw1394_handle)); ++ if (!handle) ++ return NULL; ++ ++ ieee1394_handle = ieee1394_new_handle(); ++ if (!ieee1394_handle) ++ goto try_fw; ++ ++ if (ieee1394_get_port_info(ieee1394_handle, &port, 1) >= 1) { ++ handle->is_fw = 0; ++ handle->mode.ieee1394 = ieee1394_handle; ++ return handle; ++ } ++ ieee1394_destroy_handle(ieee1394_handle); ++try_fw: ++ fw_handle = fw_new_handle(); ++ if (fw_handle) { ++ handle->is_fw = 1; ++ handle->mode.fw = fw_handle; ++ return handle; + } +- return handle; ++ ++ free(handle); ++ return NULL; + } + + void raw1394_destroy_handle(raw1394handle_t handle) +@@ -69,27 +68,30 @@ void raw1394_destroy_handle(raw1394handl + + raw1394handle_t raw1394_new_handle_on_port(int port) + { +- ieee1394handle_t ieee1394_handle = ieee1394_new_handle_on_port(port); +- fw_handle_t fw_handle = NULL; +- raw1394handle_t handle = NULL; ++ ieee1394handle_t ieee1394_handle; ++ fw_handle_t fw_handle; ++ raw1394handle_t handle; ++ ++ handle = (raw1394handle_t) malloc(sizeof(struct raw1394_handle)); ++ if (!handle) ++ return NULL; + ++ ieee1394_handle = ieee1394_new_handle_on_port(port); + if (ieee1394_handle) { +- handle = (raw1394handle_t) malloc(sizeof(struct raw1394_handle)); +- if (handle) { +- handle->is_fw = 0; +- handle->mode.ieee1394 = ieee1394_handle; +- } else +- ieee1394_destroy_handle(ieee1394_handle); +- } +- else if (fw_handle = fw_new_handle_on_port(port)) { +- handle = (raw1394handle_t) malloc(sizeof(struct raw1394_handle)); +- if (handle) { +- handle->is_fw = 1; +- handle->mode.fw = fw_handle; +- } else +- fw_destroy_handle(fw_handle); ++ handle->is_fw = 0; ++ handle->mode.ieee1394 = ieee1394_handle; ++ return handle; + } +- return handle; ++ ++ fw_handle = fw_new_handle_on_port(port); ++ if (fw_handle) { ++ handle->is_fw = 1; ++ handle->mode.fw = fw_handle; ++ return handle; ++ } ++ ++ free(handle); ++ return NULL; + } + + int raw1394_busreset_notify (raw1394handle_t handle, int off_on_switch) +diff -Naurp libraw1394-2.0.0/src/eventloop.c libraw1394-2.0.0.fix/src/eventloop.c +--- libraw1394-2.0.0/src/eventloop.c 2008-07-06 14:41:48.000000000 -0400 ++++ libraw1394-2.0.0.fix/src/eventloop.c 2008-11-20 12:38:22.289816445 -0500 +@@ -32,7 +32,7 @@ int ieee1394_loop_iterate(struct raw1394 + { + struct raw1394_request req; + ieee1394handle_t ihandle = handle->mode.ieee1394; +- int retval = 0, channel; ++ int retval = 0; + + while (read(ihandle->fd, &req, sizeof(req)) < 0) { + if (errno != EINTR) return -1; +diff -Naurp libraw1394-2.0.0/src/fw.c libraw1394-2.0.0.fix/src/fw.c +--- libraw1394-2.0.0/src/fw.c 2008-11-20 12:36:00.920753360 -0500 ++++ libraw1394-2.0.0.fix/src/fw.c 2008-11-20 12:43:13.017816248 -0500 +@@ -773,10 +773,12 @@ handle_arm_request(raw1394handle_t handl + } + rrb->request.generation = fwhandle->reset.generation; + rrb->request.buffer_length = in_length; ++ rrb->request.buffer = rrb->data; + memcpy(rrb->request.buffer, request->data, in_length); + + rrb->response.response_code = response.rcode; + rrb->response.buffer_length = response.length; ++ rrb->request.buffer = rrb->data + in_length; + memcpy(rrb->response.buffer, + allocation->data + offset, response.length); + +diff -Naurp libraw1394-2.0.0/src/fw-iso.c libraw1394-2.0.0.fix/src/fw-iso.c +--- libraw1394-2.0.0/src/fw-iso.c 2008-11-20 12:36:00.921763895 -0500 ++++ libraw1394-2.0.0.fix/src/fw-iso.c 2008-11-20 12:39:35.003793770 -0500 +@@ -85,7 +85,8 @@ queue_xmit_packets(raw1394handle_t handl + fw_handle_t fwhandle = handle->mode.fw; + enum raw1394_iso_disposition d; + unsigned char tag, sy; +- int len, cycle = -1; ++ unsigned int len; ++ int cycle = -1; + unsigned int dropped = 0; + + if (fwhandle->iso.xmit_handler == NULL) +@@ -258,9 +259,7 @@ int fw_iso_xmit_write(raw1394handle_t ha + unsigned char sy) + { + fw_handle_t fwhandle = handle->mode.fw; +- struct fw_cdev_queue_iso queue_iso; + struct fw_cdev_start_iso start_iso; +- struct fw_cdev_iso_packet *p; + int retval; + + if (len > fwhandle->iso.max_packet_size) { +diff -Naurp libraw1394-2.0.0/src/main.c libraw1394-2.0.0.fix/src/main.c +--- libraw1394-2.0.0/src/main.c 2008-07-06 14:50:34.000000000 -0400 ++++ libraw1394-2.0.0.fix/src/main.c 2008-11-20 12:40:02.828816470 -0500 +@@ -253,9 +253,7 @@ void *raw1394_get_userdata(struct raw139 + int ieee1394_get_port_info(struct ieee1394_handle *handle, + struct raw1394_portinfo *pinf, int maxports) + { +- int num; + struct raw1394_request req; +- struct raw1394_khost_list *khl; + + CLEAR_REQ(&req); + req.type = RAW1394_REQ_LIST_CARDS; diff --git a/libraw1394.spec b/libraw1394.spec index 59a6266..3df6407 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,11 +1,12 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 2.0.0 -Release: 2%{?dist} +Release: 3%{?dist} License: LGPLv2+ Group: System Environment/Libraries Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz Patch0: libraw1394-2.0.0-coverity-prevent-fixes.patch +Patch1: libraw1394-2.0.0-git-fixes.patch URL: http://www.linux1394.org/ ExcludeArch: s390 s390x BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) @@ -29,6 +30,7 @@ Development libraries needed to build applications against libraw1394. %prep %setup -q %patch0 -p1 +%patch1 -p1 %build %configure --disable-static @@ -67,6 +69,11 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Thu Nov 20 2008 Jarod Wilson - 2.0.0-3 +- Address some compiler warnings +- Reduce nesting depth in new_handle dispatches +- Fix segfault in handle_arm_request + * Wed Oct 01 2008 Jarod Wilson - 2.0.0-2 - Misc fixes from Erik Hovland, based on coverity prevent analysis From 59efcebafbaffb5be645127e90f9566ed51685ca Mon Sep 17 00:00:00 2001 From: Jarod Wilson Date: Fri, 5 Dec 2008 17:05:54 +0000 Subject: [PATCH 053/100] - Fix channel modify code, should make iso reception work reliably now --- libraw1394.spec | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index 3df6407..f6918a9 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,12 +1,13 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 2.0.0 -Release: 3%{?dist} +Release: 4%{?dist} License: LGPLv2+ Group: System Environment/Libraries Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz Patch0: libraw1394-2.0.0-coverity-prevent-fixes.patch Patch1: libraw1394-2.0.0-git-fixes.patch +Patch2: libraw1394-2.0.0-fix-channel_modify.patch URL: http://www.linux1394.org/ ExcludeArch: s390 s390x BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) @@ -31,6 +32,7 @@ Development libraries needed to build applications against libraw1394. %setup -q %patch0 -p1 %patch1 -p1 +%patch2 -p1 %build %configure --disable-static @@ -69,6 +71,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Fri Dec 05 2008 Jarod Wilson - 2.0.0-4 +- Fix channel modify code, should make iso reception work reliably now + * Thu Nov 20 2008 Jarod Wilson - 2.0.0-3 - Address some compiler warnings - Reduce nesting depth in new_handle dispatches From 59659a8e6c00e477e35cca5ab21dca2d48477fe3 Mon Sep 17 00:00:00 2001 From: Jarod Wilson Date: Fri, 5 Dec 2008 17:14:32 +0000 Subject: [PATCH 054/100] oops, add patch --- libraw1394-2.0.0-fix-channel_modify.patch | 96 +++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 libraw1394-2.0.0-fix-channel_modify.patch diff --git a/libraw1394-2.0.0-fix-channel_modify.patch b/libraw1394-2.0.0-fix-channel_modify.patch new file mode 100644 index 0000000..be35149 --- /dev/null +++ b/libraw1394-2.0.0-fix-channel_modify.patch @@ -0,0 +1,96 @@ +diff -Naurp libraw1394-2.0.0.orig/src/dispatch.c libraw1394-2.0.0.fix/src/dispatch.c +--- libraw1394-2.0.0.orig/src/dispatch.c 2008-12-05 11:37:36.686557198 -0500 ++++ libraw1394-2.0.0.fix/src/dispatch.c 2008-12-05 11:38:57.117432534 -0500 +@@ -553,10 +553,7 @@ int raw1394_channel_modify (raw1394handl + errno = EINVAL; + return -1; + } +- if (handle->is_fw) +- return fw_channel_modify(handle, channel, mode); +- else +- return ieee1394_channel_modify(handle, channel, mode); ++ return ieee1394_channel_modify(handle, channel, mode); + } + + int raw1394_iso_xmit_init(raw1394handle_t handle, +diff -Naurp libraw1394-2.0.0.orig/src/fw.c libraw1394-2.0.0.fix/src/fw.c +--- libraw1394-2.0.0.orig/src/fw.c 2008-12-05 11:37:36.689432892 -0500 ++++ libraw1394-2.0.0.fix/src/fw.c 2008-12-05 11:39:44.830509943 -0500 +@@ -1342,52 +1342,3 @@ fw_bandwidth_modify (raw1394handle_t han + + return 0; + } +- +-int +-fw_channel_modify (raw1394handle_t handle, +- unsigned int channel, +- enum raw1394_modify_mode mode) +-{ +- quadlet_t buffer, compare, swap, bit; +- nodeaddr_t addr; +- int result; +- +- if (channel >= 64) +- return -1; +- addr = CSR_REGISTER_BASE + +- CSR_CHANNELS_AVAILABLE_HI + 4 * (channel / 32); +- /* Read currently available channels from IRM. */ +- result = raw1394_read(handle, raw1394_get_irm_id (handle), addr, +- sizeof buffer, &buffer); +- if (result < 0) +- return -1; +- +- /* IEEE numbers bits from MSB (0) to LSB (31). */ +- bit = 1 << (31 - (channel & 31)); +- compare = ntohl(buffer); +- switch (mode) { +- case RAW1394_MODIFY_ALLOC: +- if ((compare & bit) == 0) +- return -1; +- swap = buffer & ~bit; +- break; +- +- case RAW1394_MODIFY_FREE: +- if ((buffer & bit) != 0) +- return -1; +- swap = buffer | bit; +- break; +- +- default: +- return -1; +- } +- +- result = raw1394_lock (handle, raw1394_get_irm_id (handle), addr, +- RAW1394_EXTCODE_COMPARE_SWAP, +- htonl(swap), htonl(compare), &buffer); +- +- if (result < 0 || ntohl(buffer) != compare) +- return -1; +- +- return 0; +-} +diff -Naurp libraw1394-2.0.0.orig/src/fw.h libraw1394-2.0.0.fix/src/fw.h +--- libraw1394-2.0.0.orig/src/fw.h 2008-07-05 16:16:30.000000000 -0400 ++++ libraw1394-2.0.0.fix/src/fw.h 2008-12-05 11:40:02.062495475 -0500 +@@ -214,9 +214,6 @@ int fw_get_config_rom(fw_handle_t handle + int fw_bandwidth_modify (raw1394handle_t handle, + unsigned int bandwidth, + enum raw1394_modify_mode mode); +-int fw_channel_modify (raw1394handle_t handle, +- unsigned int channel, +- enum raw1394_modify_mode mode); + + int fw_iso_xmit_start(raw1394handle_t handle, int start_on_cycle, + int prebuffer_packets); +diff -Naurp libraw1394-2.0.0.orig/src/raw1394.h libraw1394-2.0.0.fix/src/raw1394.h +--- libraw1394-2.0.0.orig/src/raw1394.h 2008-07-06 15:03:31.000000000 -0400 ++++ libraw1394-2.0.0.fix/src/raw1394.h 2008-12-05 11:39:23.582432381 -0500 +@@ -1203,7 +1203,7 @@ raw1394_bandwidth_modify (raw1394handle_ + enum raw1394_modify_mode mode); + + /** +- * raw1394_bandwidth_modify - allocate or release isochronous channel ++ * raw1394_channel_modify - allocate or release isochronous channel + * @handle: a libraw1394 handle + * @channel: isochronous channel + * @mode: whether to allocate or free From 618497f20fbe4039ce7d351f062e17c1cb3c20f3 Mon Sep 17 00:00:00 2001 From: Jarod Wilson Date: Tue, 9 Dec 2008 15:40:49 +0000 Subject: [PATCH 055/100] - Fix up iso stop command so starting/stopping/starting iso reception works - Plug firewire handle leak --- libraw1394-2.0.0-coverity-prevent-fixes.patch | 298 ------ libraw1394-2.0.0-fix-channel_modify.patch | 96 -- libraw1394-2.0.0-git-fixes.patch | 200 ---- libraw1394-2.0.0-git-update.patch | 993 ++++++++++++++++++ libraw1394.spec | 12 +- 5 files changed, 999 insertions(+), 600 deletions(-) delete mode 100644 libraw1394-2.0.0-coverity-prevent-fixes.patch delete mode 100644 libraw1394-2.0.0-fix-channel_modify.patch delete mode 100644 libraw1394-2.0.0-git-fixes.patch create mode 100644 libraw1394-2.0.0-git-update.patch diff --git a/libraw1394-2.0.0-coverity-prevent-fixes.patch b/libraw1394-2.0.0-coverity-prevent-fixes.patch deleted file mode 100644 index b6ec3c3..0000000 --- a/libraw1394-2.0.0-coverity-prevent-fixes.patch +++ /dev/null @@ -1,298 +0,0 @@ -From: Erik Hovland - -Series of coverity prevent-inspired fixes. - --- -Makes extra sure strings are not overrun. - -When using strncpy with the exact size of the destination string the -string may end up lacking null termination because the source string is -bigger then the destination. - --- -Makes sure to check any return values - -The return value of any function should be checked if that function -uses the return value to provide some sort of status information. - --- -Makes sure a value is returned by the function. - -A function can compile without returning something always. - --- -Make sure that we have the right types. - -When an unsigned type is assigned a signed value, the -negatived value is never seen. - - --- -Compare unsigned values instead of subtracting them. - -Unsigned values do not return signed values when subtracted -and the right operand is larger then the left operand. - --- -Protect against resource leaks. - --- -Make sure variables are initialized before used. - - -Signed-off-by: Erik Hovland ---- - - src/dispatch.c | 11 ++++++++--- - src/fw-iso.c | 11 +++++++---- - src/fw.c | 49 +++++++++++++++++++++++++++++-------------------- - tools/testlibraw.c | 3 ++- - 4 files changed, 46 insertions(+), 28 deletions(-) - -diff -Naurp libraw1394-2.0.0.orig/src/dispatch.c libraw1394-2.0.0/src/dispatch.c ---- libraw1394-2.0.0.orig/src/dispatch.c 2008-07-06 14:48:17.000000000 -0400 -+++ libraw1394-2.0.0/src/dispatch.c 2008-10-01 10:58:16.000000000 -0400 -@@ -48,7 +48,10 @@ raw1394handle_t raw1394_new_handle(void) - else if (handle) { - handle->is_fw = 1; - handle->mode.fw = fw_handle; -- } -+ } else if (fw_handle) -+ fw_destroy_handle(fw_handle); -+ else if (ieee1394_handle) -+ ieee1394_destroy_handle(ieee1394_handle); - } - return handle; - } -@@ -75,14 +78,16 @@ raw1394handle_t raw1394_new_handle_on_po - if (handle) { - handle->is_fw = 0; - handle->mode.ieee1394 = ieee1394_handle; -- } -+ } else -+ ieee1394_destroy_handle(ieee1394_handle); - } - else if (fw_handle = fw_new_handle_on_port(port)) { - handle = (raw1394handle_t) malloc(sizeof(struct raw1394_handle)); - if (handle) { - handle->is_fw = 1; - handle->mode.fw = fw_handle; -- } -+ } else -+ fw_destroy_handle(fw_handle); - } - return handle; - } -diff -Naurp libraw1394-2.0.0.orig/src/fw.c libraw1394-2.0.0/src/fw.c ---- libraw1394-2.0.0.orig/src/fw.c 2008-07-05 16:09:29.000000000 -0400 -+++ libraw1394-2.0.0/src/fw.c 2008-10-01 10:58:16.000000000 -0400 -@@ -125,7 +125,7 @@ scan_devices(fw_handle_t handle) - char filename[32]; - struct fw_cdev_get_info get_info; - struct fw_cdev_event_bus_reset reset; -- int fd, err, i; -+ int fd, err, i, fname_str_sz; - struct port *ports; - - ports = handle->ports; -@@ -162,8 +162,9 @@ scan_devices(fw_handle_t handle) - continue; - - if (i < MAX_PORTS && reset.node_id == reset.local_node_id) { -- strncpy(ports[i].device_file, filename, -- sizeof ports[i].device_file); -+ fname_str_sz = sizeof(ports[i].device_file) - 1; -+ strncpy(ports[i].device_file, filename, fname_str_sz); -+ ports[i].device_file[fname_str_sz] = '\0'; - ports[i].node_count = (reset.root_node_id & 0x3f) + 1; - ports[i].card = get_info.card; - i++; -@@ -315,7 +316,7 @@ handle_inotify(raw1394handle_t handle, s - struct fw_cdev_get_info info; - struct fw_cdev_event_bus_reset reset; - struct epoll_event ep; -- int i, len, fd, phy_id; -+ int i, len, fd, phy_id, fname_str_sz; - - event = (struct inotify_event *) fwhandle->buffer; - len = read(fwhandle->inotify_fd, event, BUFFER_SIZE); -@@ -365,8 +366,9 @@ handle_inotify(raw1394handle_t handle, s - fwhandle->devices[i].node_id = reset.node_id; - fwhandle->devices[i].generation = reset.generation; - fwhandle->devices[i].fd = fd; -- strncpy(fwhandle->devices[i].filename, filename, -- sizeof fwhandle->devices[i].filename); -+ fname_str_sz = sizeof(fwhandle->devices[i].filename) - 1; -+ strncpy(fwhandle->devices[i].filename, filename, fname_str_sz); -+ fwhandle->devices[i].filename[fname_str_sz] = '\0'; - fwhandle->devices[i].closure.func = handle_device_event; - ep.events = EPOLLIN; - ep.data.ptr = &fwhandle->devices[i].closure; -@@ -501,8 +503,10 @@ fw_handle_t fw_new_handle_on_port(int po - if (handle == NULL) - return NULL; - -- if (fw_set_port(handle, port) < 0) -+ if (fw_set_port(handle, port) < 0) { -+ fw_destroy_handle(handle); - return NULL; -+ } - - return handle; - } -@@ -538,15 +542,17 @@ int fw_get_port_info(fw_handle_t handle, - struct raw1394_portinfo *pinf, - int maxports) - { -- int i; -+ int i, port_name_sz; - - if (maxports >= handle->port_count) - maxports = handle->port_count; - - for (i = 0; i < maxports; i++) { - pinf[i].nodes = handle->ports[i].node_count; -+ port_name_sz = sizeof(pinf[i].name) - 1; - strncpy(pinf[i].name, handle->ports[i].device_file, -- sizeof pinf[i].name); -+ port_name_sz); -+ pinf[i].name[port_name_sz] = '\0'; - } - - return handle->port_count; -@@ -560,7 +566,7 @@ int fw_set_port(fw_handle_t handle, int - struct dirent *de; - char filename[32]; - DIR *dir; -- int i, fd, phy_id; -+ int i, fd, phy_id, fname_str_sz; - - if (port >= handle->port_count) { - errno = EINVAL; -@@ -606,8 +612,9 @@ int fw_set_port(fw_handle_t handle, int - handle->devices[i].node_id = reset.node_id; - handle->devices[i].generation = reset.generation; - handle->devices[i].fd = fd; -- strncpy(handle->devices[i].filename, filename, -- sizeof handle->devices[i].filename); -+ fname_str_sz = sizeof(handle->devices[i].filename) -1; -+ strncpy(handle->devices[i].filename, filename, fname_str_sz); -+ handle->devices[i].filename[fname_str_sz] = '\0'; - - handle->devices[i].closure.func = handle_device_event; - memset(&ep, 0, sizeof(ep)); -@@ -623,8 +630,9 @@ int fw_set_port(fw_handle_t handle, int - if (reset.node_id == reset.local_node_id) { - memcpy(&handle->reset, &reset, sizeof handle->reset); - handle->local_fd = fd; -- strncpy(handle->local_filename, filename, -- sizeof handle->local_filename); -+ fname_str_sz = sizeof(handle->local_filename) -1; -+ strncpy(handle->local_filename, filename, fname_str_sz); -+ handle->local_filename[fname_str_sz] = '\0'; - } - - i++; -@@ -1174,14 +1182,14 @@ fw_lock(raw1394handle_t handle, nodeid_t - quadlet_t *result) - { - quadlet_t buffer[2]; -- size_t length; -+ ssize_t length; - - length = setup_lock(extcode, data, arg, buffer); - if (length < 0) - return length; - - return send_request_sync(handle, 16 + extcode, node, addr, -- length, buffer, result); -+ (size_t) length, buffer, result); - } - - int -@@ -1190,14 +1198,14 @@ fw_lock64(raw1394handle_t handle, nodeid - octlet_t *result) - { - octlet_t buffer[2]; -- size_t length; -+ ssize_t length; - - length = setup_lock64(extcode, data, arg, buffer); - if (length < 0) - return length; - - return send_request_sync(handle, 16 + extcode, node, addr, -- length, buffer, result); -+ (size_t) length, buffer, result); - } - - int -@@ -1308,9 +1316,10 @@ fw_bandwidth_modify (raw1394handle_t han - compare = ntohl (buffer); - switch (mode) { - case RAW1394_MODIFY_ALLOC: -- swap = compare - bandwidth; -- if (swap < 0) -+ if (compare < bandwidth) - return -1; -+ -+ swap = compare - bandwidth; - break; - - case RAW1394_MODIFY_FREE: -diff -Naurp libraw1394-2.0.0.orig/src/fw-iso.c libraw1394-2.0.0/src/fw-iso.c ---- libraw1394-2.0.0.orig/src/fw-iso.c 2008-07-05 16:16:30.000000000 -0400 -+++ libraw1394-2.0.0/src/fw-iso.c 2008-10-01 10:58:40.000000000 -0400 -@@ -76,6 +76,7 @@ queue_packet(fw_handle_t handle, - if (err < 0) - return -1; - } -+ return 0; - } - - static int -@@ -84,7 +85,8 @@ queue_xmit_packets(raw1394handle_t handl - fw_handle_t fwhandle = handle->mode.fw; - enum raw1394_iso_disposition d; - unsigned char tag, sy; -- int len, cycle, dropped; -+ int len, cycle = -1; -+ unsigned int dropped = 0; - - if (fwhandle->iso.xmit_handler == NULL) - return 0; -@@ -259,6 +261,7 @@ int fw_iso_xmit_write(raw1394handle_t ha - struct fw_cdev_queue_iso queue_iso; - struct fw_cdev_start_iso start_iso; - struct fw_cdev_iso_packet *p; -+ int retval; - - if (len > fwhandle->iso.max_packet_size) { - errno = EINVAL; -@@ -283,10 +286,10 @@ int fw_iso_xmit_write(raw1394handle_t ha - start_iso.cycle = fwhandle->iso.start_on_cycle; - start_iso.handle = 0; - -- len = ioctl(fwhandle->iso.fd, -+ retval = ioctl(fwhandle->iso.fd, - FW_CDEV_IOC_START_ISO, &start_iso); -- if (len < 0) -- return len; -+ if (retval < 0) -+ return retval; - } - - return 0; -diff -Naurp libraw1394-2.0.0.orig/tools/testlibraw.c libraw1394-2.0.0/tools/testlibraw.c ---- libraw1394-2.0.0.orig/tools/testlibraw.c 2008-07-05 16:09:29.000000000 -0400 -+++ libraw1394-2.0.0/tools/testlibraw.c 2008-10-01 10:58:02.000000000 -0400 -@@ -180,7 +180,8 @@ int main(int argc, char **argv) - perror("failed"); - continue; - } -- raw1394_loop_iterate(handle); -+ if (raw1394_loop_iterate(handle)) -+ perror("failed"); - } - - printf("\nusing standard tag handler and synchronous calls\n"); diff --git a/libraw1394-2.0.0-fix-channel_modify.patch b/libraw1394-2.0.0-fix-channel_modify.patch deleted file mode 100644 index be35149..0000000 --- a/libraw1394-2.0.0-fix-channel_modify.patch +++ /dev/null @@ -1,96 +0,0 @@ -diff -Naurp libraw1394-2.0.0.orig/src/dispatch.c libraw1394-2.0.0.fix/src/dispatch.c ---- libraw1394-2.0.0.orig/src/dispatch.c 2008-12-05 11:37:36.686557198 -0500 -+++ libraw1394-2.0.0.fix/src/dispatch.c 2008-12-05 11:38:57.117432534 -0500 -@@ -553,10 +553,7 @@ int raw1394_channel_modify (raw1394handl - errno = EINVAL; - return -1; - } -- if (handle->is_fw) -- return fw_channel_modify(handle, channel, mode); -- else -- return ieee1394_channel_modify(handle, channel, mode); -+ return ieee1394_channel_modify(handle, channel, mode); - } - - int raw1394_iso_xmit_init(raw1394handle_t handle, -diff -Naurp libraw1394-2.0.0.orig/src/fw.c libraw1394-2.0.0.fix/src/fw.c ---- libraw1394-2.0.0.orig/src/fw.c 2008-12-05 11:37:36.689432892 -0500 -+++ libraw1394-2.0.0.fix/src/fw.c 2008-12-05 11:39:44.830509943 -0500 -@@ -1342,52 +1342,3 @@ fw_bandwidth_modify (raw1394handle_t han - - return 0; - } -- --int --fw_channel_modify (raw1394handle_t handle, -- unsigned int channel, -- enum raw1394_modify_mode mode) --{ -- quadlet_t buffer, compare, swap, bit; -- nodeaddr_t addr; -- int result; -- -- if (channel >= 64) -- return -1; -- addr = CSR_REGISTER_BASE + -- CSR_CHANNELS_AVAILABLE_HI + 4 * (channel / 32); -- /* Read currently available channels from IRM. */ -- result = raw1394_read(handle, raw1394_get_irm_id (handle), addr, -- sizeof buffer, &buffer); -- if (result < 0) -- return -1; -- -- /* IEEE numbers bits from MSB (0) to LSB (31). */ -- bit = 1 << (31 - (channel & 31)); -- compare = ntohl(buffer); -- switch (mode) { -- case RAW1394_MODIFY_ALLOC: -- if ((compare & bit) == 0) -- return -1; -- swap = buffer & ~bit; -- break; -- -- case RAW1394_MODIFY_FREE: -- if ((buffer & bit) != 0) -- return -1; -- swap = buffer | bit; -- break; -- -- default: -- return -1; -- } -- -- result = raw1394_lock (handle, raw1394_get_irm_id (handle), addr, -- RAW1394_EXTCODE_COMPARE_SWAP, -- htonl(swap), htonl(compare), &buffer); -- -- if (result < 0 || ntohl(buffer) != compare) -- return -1; -- -- return 0; --} -diff -Naurp libraw1394-2.0.0.orig/src/fw.h libraw1394-2.0.0.fix/src/fw.h ---- libraw1394-2.0.0.orig/src/fw.h 2008-07-05 16:16:30.000000000 -0400 -+++ libraw1394-2.0.0.fix/src/fw.h 2008-12-05 11:40:02.062495475 -0500 -@@ -214,9 +214,6 @@ int fw_get_config_rom(fw_handle_t handle - int fw_bandwidth_modify (raw1394handle_t handle, - unsigned int bandwidth, - enum raw1394_modify_mode mode); --int fw_channel_modify (raw1394handle_t handle, -- unsigned int channel, -- enum raw1394_modify_mode mode); - - int fw_iso_xmit_start(raw1394handle_t handle, int start_on_cycle, - int prebuffer_packets); -diff -Naurp libraw1394-2.0.0.orig/src/raw1394.h libraw1394-2.0.0.fix/src/raw1394.h ---- libraw1394-2.0.0.orig/src/raw1394.h 2008-07-06 15:03:31.000000000 -0400 -+++ libraw1394-2.0.0.fix/src/raw1394.h 2008-12-05 11:39:23.582432381 -0500 -@@ -1203,7 +1203,7 @@ raw1394_bandwidth_modify (raw1394handle_ - enum raw1394_modify_mode mode); - - /** -- * raw1394_bandwidth_modify - allocate or release isochronous channel -+ * raw1394_channel_modify - allocate or release isochronous channel - * @handle: a libraw1394 handle - * @channel: isochronous channel - * @mode: whether to allocate or free diff --git a/libraw1394-2.0.0-git-fixes.patch b/libraw1394-2.0.0-git-fixes.patch deleted file mode 100644 index c5ba75f..0000000 --- a/libraw1394-2.0.0-git-fixes.patch +++ /dev/null @@ -1,200 +0,0 @@ -diff -Naurp libraw1394-2.0.0/src/arm.c libraw1394-2.0.0.fix/src/arm.c ---- libraw1394-2.0.0/src/arm.c 2008-07-05 16:08:26.000000000 -0400 -+++ libraw1394-2.0.0.fix/src/arm.c 2008-11-20 12:37:05.136821199 -0500 -@@ -109,7 +109,6 @@ int ieee1394_arm_set_buf (struct ieee139 - size_t length, void *buf) - { - struct raw1394_request req; -- int status; - - CLEAR_REQ(&req); - -@@ -139,7 +138,6 @@ int ieee1394_arm_get_buf (struct ieee139 - size_t length, void *buf) - { - struct raw1394_request req; -- int status; - - CLEAR_REQ(&req); - -diff -Naurp libraw1394-2.0.0/src/dispatch.c libraw1394-2.0.0.fix/src/dispatch.c ---- libraw1394-2.0.0/src/dispatch.c 2008-11-20 12:36:00.918753368 -0500 -+++ libraw1394-2.0.0.fix/src/dispatch.c 2008-11-20 12:42:03.387817813 -0500 -@@ -24,36 +24,35 @@ int raw1394_errcode_to_errno(raw1394_err - - raw1394handle_t raw1394_new_handle(void) - { -- ieee1394handle_t ieee1394_handle = ieee1394_new_handle(); -- fw_handle_t fw_handle = NULL; -- raw1394handle_t handle = NULL; -- -- if (ieee1394_handle) { -- struct raw1394_portinfo port; -- if (ieee1394_get_port_info(ieee1394_handle, &port, 1) < 1) { -- ieee1394_destroy_handle(ieee1394_handle); -- ieee1394_handle = NULL; -- fw_handle = fw_new_handle(); -- } -- } -- else { -- fw_handle = fw_new_handle(); -- } -- if (ieee1394_handle || fw_handle) { -- handle = (raw1394handle_t) malloc(sizeof(struct raw1394_handle)); -- if (ieee1394_handle && handle) { -- handle->is_fw = 0; -- handle->mode.ieee1394 = ieee1394_handle; -- } -- else if (handle) { -- handle->is_fw = 1; -- handle->mode.fw = fw_handle; -- } else if (fw_handle) -- fw_destroy_handle(fw_handle); -- else if (ieee1394_handle) -- ieee1394_destroy_handle(ieee1394_handle); -+ ieee1394handle_t ieee1394_handle; -+ fw_handle_t fw_handle; -+ raw1394handle_t handle; -+ struct raw1394_portinfo port; -+ -+ handle = (raw1394handle_t) malloc(sizeof(struct raw1394_handle)); -+ if (!handle) -+ return NULL; -+ -+ ieee1394_handle = ieee1394_new_handle(); -+ if (!ieee1394_handle) -+ goto try_fw; -+ -+ if (ieee1394_get_port_info(ieee1394_handle, &port, 1) >= 1) { -+ handle->is_fw = 0; -+ handle->mode.ieee1394 = ieee1394_handle; -+ return handle; -+ } -+ ieee1394_destroy_handle(ieee1394_handle); -+try_fw: -+ fw_handle = fw_new_handle(); -+ if (fw_handle) { -+ handle->is_fw = 1; -+ handle->mode.fw = fw_handle; -+ return handle; - } -- return handle; -+ -+ free(handle); -+ return NULL; - } - - void raw1394_destroy_handle(raw1394handle_t handle) -@@ -69,27 +68,30 @@ void raw1394_destroy_handle(raw1394handl - - raw1394handle_t raw1394_new_handle_on_port(int port) - { -- ieee1394handle_t ieee1394_handle = ieee1394_new_handle_on_port(port); -- fw_handle_t fw_handle = NULL; -- raw1394handle_t handle = NULL; -+ ieee1394handle_t ieee1394_handle; -+ fw_handle_t fw_handle; -+ raw1394handle_t handle; -+ -+ handle = (raw1394handle_t) malloc(sizeof(struct raw1394_handle)); -+ if (!handle) -+ return NULL; - -+ ieee1394_handle = ieee1394_new_handle_on_port(port); - if (ieee1394_handle) { -- handle = (raw1394handle_t) malloc(sizeof(struct raw1394_handle)); -- if (handle) { -- handle->is_fw = 0; -- handle->mode.ieee1394 = ieee1394_handle; -- } else -- ieee1394_destroy_handle(ieee1394_handle); -- } -- else if (fw_handle = fw_new_handle_on_port(port)) { -- handle = (raw1394handle_t) malloc(sizeof(struct raw1394_handle)); -- if (handle) { -- handle->is_fw = 1; -- handle->mode.fw = fw_handle; -- } else -- fw_destroy_handle(fw_handle); -+ handle->is_fw = 0; -+ handle->mode.ieee1394 = ieee1394_handle; -+ return handle; - } -- return handle; -+ -+ fw_handle = fw_new_handle_on_port(port); -+ if (fw_handle) { -+ handle->is_fw = 1; -+ handle->mode.fw = fw_handle; -+ return handle; -+ } -+ -+ free(handle); -+ return NULL; - } - - int raw1394_busreset_notify (raw1394handle_t handle, int off_on_switch) -diff -Naurp libraw1394-2.0.0/src/eventloop.c libraw1394-2.0.0.fix/src/eventloop.c ---- libraw1394-2.0.0/src/eventloop.c 2008-07-06 14:41:48.000000000 -0400 -+++ libraw1394-2.0.0.fix/src/eventloop.c 2008-11-20 12:38:22.289816445 -0500 -@@ -32,7 +32,7 @@ int ieee1394_loop_iterate(struct raw1394 - { - struct raw1394_request req; - ieee1394handle_t ihandle = handle->mode.ieee1394; -- int retval = 0, channel; -+ int retval = 0; - - while (read(ihandle->fd, &req, sizeof(req)) < 0) { - if (errno != EINTR) return -1; -diff -Naurp libraw1394-2.0.0/src/fw.c libraw1394-2.0.0.fix/src/fw.c ---- libraw1394-2.0.0/src/fw.c 2008-11-20 12:36:00.920753360 -0500 -+++ libraw1394-2.0.0.fix/src/fw.c 2008-11-20 12:43:13.017816248 -0500 -@@ -773,10 +773,12 @@ handle_arm_request(raw1394handle_t handl - } - rrb->request.generation = fwhandle->reset.generation; - rrb->request.buffer_length = in_length; -+ rrb->request.buffer = rrb->data; - memcpy(rrb->request.buffer, request->data, in_length); - - rrb->response.response_code = response.rcode; - rrb->response.buffer_length = response.length; -+ rrb->request.buffer = rrb->data + in_length; - memcpy(rrb->response.buffer, - allocation->data + offset, response.length); - -diff -Naurp libraw1394-2.0.0/src/fw-iso.c libraw1394-2.0.0.fix/src/fw-iso.c ---- libraw1394-2.0.0/src/fw-iso.c 2008-11-20 12:36:00.921763895 -0500 -+++ libraw1394-2.0.0.fix/src/fw-iso.c 2008-11-20 12:39:35.003793770 -0500 -@@ -85,7 +85,8 @@ queue_xmit_packets(raw1394handle_t handl - fw_handle_t fwhandle = handle->mode.fw; - enum raw1394_iso_disposition d; - unsigned char tag, sy; -- int len, cycle = -1; -+ unsigned int len; -+ int cycle = -1; - unsigned int dropped = 0; - - if (fwhandle->iso.xmit_handler == NULL) -@@ -258,9 +259,7 @@ int fw_iso_xmit_write(raw1394handle_t ha - unsigned char sy) - { - fw_handle_t fwhandle = handle->mode.fw; -- struct fw_cdev_queue_iso queue_iso; - struct fw_cdev_start_iso start_iso; -- struct fw_cdev_iso_packet *p; - int retval; - - if (len > fwhandle->iso.max_packet_size) { -diff -Naurp libraw1394-2.0.0/src/main.c libraw1394-2.0.0.fix/src/main.c ---- libraw1394-2.0.0/src/main.c 2008-07-06 14:50:34.000000000 -0400 -+++ libraw1394-2.0.0.fix/src/main.c 2008-11-20 12:40:02.828816470 -0500 -@@ -253,9 +253,7 @@ void *raw1394_get_userdata(struct raw139 - int ieee1394_get_port_info(struct ieee1394_handle *handle, - struct raw1394_portinfo *pinf, int maxports) - { -- int num; - struct raw1394_request req; -- struct raw1394_khost_list *khl; - - CLEAR_REQ(&req); - req.type = RAW1394_REQ_LIST_CARDS; diff --git a/libraw1394-2.0.0-git-update.patch b/libraw1394-2.0.0-git-update.patch new file mode 100644 index 0000000..9324063 --- /dev/null +++ b/libraw1394-2.0.0-git-update.patch @@ -0,0 +1,993 @@ + Makefile.am | 23 ---- + src/arm.c | 2 - + src/dispatch.c | 102 ++++++++++--------- + src/eventloop.c | 2 +- + src/fw-iso.c | 40 ++++++-- + src/fw.c | 143 +++++--------------------- + src/fw.h | 7 +- + src/main.c | 2 - + src/raw1394.h | 2 +- + tools/testlibraw.c | 285 ++++++++++++++++++++++++++++++---------------------- + 10 files changed, 279 insertions(+), 329 deletions(-) + +diff --git a/Makefile.am b/Makefile.am +index f48af74..bf094f0 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -23,28 +23,5 @@ htmldoc: + + .PHONY: doc psdoc pdfdoc htmldoc + +-# make required device file +-dev: +- mknod -m 600 /dev/raw1394 c 171 0 +- chown root.root /dev/raw1394 +- @echo +- @echo "/dev/raw1394 created" +- @echo "It is owned by root with permissions 600. You may want to fix" +- @echo "the group/permission to something appropriate for you." +- @echo "Note however that anyone who can open raw1394 can access all" +- @echo "devices on all connected 1394 buses unrestricted, including" +- @echo "harddisks and other probably sensitive devices." +- @echo +- +-install-exec-hook: +- @if [ ! -c /dev/raw1394 ]; then \ +- echo; \ +- echo "********************************************"; \ +- echo "Required /dev/raw1394 device file not found."; \ +- echo "Run 'make dev' to create it."; \ +- echo "********************************************"; \ +- echo; \ +- fi +- + dist-hook: + git log >$(distdir)/ChangeLog +diff --git a/src/arm.c b/src/arm.c +index c523c00..27ad762 100644 +--- a/src/arm.c ++++ b/src/arm.c +@@ -109,7 +109,6 @@ int ieee1394_arm_set_buf (struct ieee1394_handle *handle, nodeaddr_t start, + size_t length, void *buf) + { + struct raw1394_request req; +- int status; + + CLEAR_REQ(&req); + +@@ -139,7 +138,6 @@ int ieee1394_arm_get_buf (struct ieee1394_handle *handle, nodeaddr_t start, + size_t length, void *buf) + { + struct raw1394_request req; +- int status; + + CLEAR_REQ(&req); + +diff --git a/src/dispatch.c b/src/dispatch.c +index b15e8c5..49ceca2 100644 +--- a/src/dispatch.c ++++ b/src/dispatch.c +@@ -24,33 +24,35 @@ int raw1394_errcode_to_errno(raw1394_errcode_t errcode) + + raw1394handle_t raw1394_new_handle(void) + { +- ieee1394handle_t ieee1394_handle = ieee1394_new_handle(); +- fw_handle_t fw_handle = NULL; +- raw1394handle_t handle = NULL; ++ ieee1394handle_t ieee1394_handle; ++ fw_handle_t fw_handle; ++ raw1394handle_t handle; ++ struct raw1394_portinfo port; + +- if (ieee1394_handle) { +- struct raw1394_portinfo port; +- if (ieee1394_get_port_info(ieee1394_handle, &port, 1) < 1) { +- ieee1394_destroy_handle(ieee1394_handle); +- ieee1394_handle = NULL; +- fw_handle = fw_new_handle(); +- } +- } +- else { +- fw_handle = fw_new_handle(); +- } +- if (ieee1394_handle || fw_handle) { +- handle = (raw1394handle_t) malloc(sizeof(struct raw1394_handle)); +- if (ieee1394_handle && handle) { +- handle->is_fw = 0; +- handle->mode.ieee1394 = ieee1394_handle; +- } +- else if (handle) { +- handle->is_fw = 1; +- handle->mode.fw = fw_handle; +- } +- } +- return handle; ++ handle = (raw1394handle_t) malloc(sizeof(struct raw1394_handle)); ++ if (!handle) ++ return NULL; ++ ++ ieee1394_handle = ieee1394_new_handle(); ++ if (!ieee1394_handle) ++ goto try_fw; ++ ++ if (ieee1394_get_port_info(ieee1394_handle, &port, 1) >= 1) { ++ handle->is_fw = 0; ++ handle->mode.ieee1394 = ieee1394_handle; ++ return handle; ++ } ++ ieee1394_destroy_handle(ieee1394_handle); ++try_fw: ++ fw_handle = fw_new_handle(); ++ if (fw_handle) { ++ handle->is_fw = 1; ++ handle->mode.fw = fw_handle; ++ return handle; ++ } ++ ++ free(handle); ++ return NULL; + } + + void raw1394_destroy_handle(raw1394handle_t handle) +@@ -61,30 +63,36 @@ void raw1394_destroy_handle(raw1394handle_t handle) + if (handle->is_fw) + fw_destroy_handle(handle->mode.fw); + else +- ieee1394_destroy_handle(handle->mode.ieee1394);; ++ ieee1394_destroy_handle(handle->mode.ieee1394); ++ free(handle); + } + + raw1394handle_t raw1394_new_handle_on_port(int port) + { +- ieee1394handle_t ieee1394_handle = ieee1394_new_handle_on_port(port); +- fw_handle_t fw_handle = NULL; +- raw1394handle_t handle = NULL; ++ ieee1394handle_t ieee1394_handle; ++ fw_handle_t fw_handle; ++ raw1394handle_t handle; ++ ++ handle = (raw1394handle_t) malloc(sizeof(struct raw1394_handle)); ++ if (!handle) ++ return NULL; + ++ ieee1394_handle = ieee1394_new_handle_on_port(port); + if (ieee1394_handle) { +- handle = (raw1394handle_t) malloc(sizeof(struct raw1394_handle)); +- if (handle) { +- handle->is_fw = 0; +- handle->mode.ieee1394 = ieee1394_handle; +- } ++ handle->is_fw = 0; ++ handle->mode.ieee1394 = ieee1394_handle; ++ return handle; + } +- else if (fw_handle = fw_new_handle_on_port(port)) { +- handle = (raw1394handle_t) malloc(sizeof(struct raw1394_handle)); +- if (handle) { +- handle->is_fw = 1; +- handle->mode.fw = fw_handle; +- } ++ ++ fw_handle = fw_new_handle_on_port(port); ++ if (fw_handle) { ++ handle->is_fw = 1; ++ handle->mode.fw = fw_handle; ++ return handle; + } +- return handle; ++ ++ free(handle); ++ return NULL; + } + + int raw1394_busreset_notify (raw1394handle_t handle, int off_on_switch) +@@ -533,10 +541,7 @@ int raw1394_bandwidth_modify (raw1394handle_t handle, unsigned int bandwidth, + errno = EINVAL; + return -1; + } +- if (handle->is_fw) +- return fw_bandwidth_modify(handle, bandwidth, mode); +- else +- return ieee1394_bandwidth_modify(handle, bandwidth, mode); ++ return ieee1394_bandwidth_modify(handle, bandwidth, mode); + } + + int raw1394_channel_modify (raw1394handle_t handle, unsigned int channel, +@@ -546,10 +551,7 @@ int raw1394_channel_modify (raw1394handle_t handle, unsigned int channel, + errno = EINVAL; + return -1; + } +- if (handle->is_fw) +- return fw_channel_modify(handle, channel, mode); +- else +- return ieee1394_channel_modify(handle, channel, mode); ++ return ieee1394_channel_modify(handle, channel, mode); + } + + int raw1394_iso_xmit_init(raw1394handle_t handle, +diff --git a/src/eventloop.c b/src/eventloop.c +index 43a9519..81bb881 100644 +--- a/src/eventloop.c ++++ b/src/eventloop.c +@@ -32,7 +32,7 @@ int ieee1394_loop_iterate(struct raw1394_handle *handle) + { + struct raw1394_request req; + ieee1394handle_t ihandle = handle->mode.ieee1394; +- int retval = 0, channel; ++ int retval = 0; + + while (read(ihandle->fd, &req, sizeof(req)) < 0) { + if (errno != EINTR) return -1; +diff --git a/src/fw-iso.c b/src/fw-iso.c +index f493444..6a84662 100644 +--- a/src/fw-iso.c ++++ b/src/fw-iso.c +@@ -1,6 +1,6 @@ + /* -*- c-basic-offset: 8 -*- + * +- * raw1394-iso.c -- Emulation of the raw1394 rawiso API on the firewire stack ++ * fw-iso.c -- Emulation of the raw1394 rawiso API on the firewire stack + * + * Copyright (C) 2007 Kristian Hoegsberg + * +@@ -76,6 +76,7 @@ queue_packet(fw_handle_t handle, + if (err < 0) + return -1; + } ++ return 0; + } + + static int +@@ -84,7 +85,9 @@ queue_xmit_packets(raw1394handle_t handle, int limit) + fw_handle_t fwhandle = handle->mode.fw; + enum raw1394_iso_disposition d; + unsigned char tag, sy; +- int len, cycle, dropped; ++ unsigned int len; ++ int cycle = -1; ++ unsigned int dropped = 0; + + if (fwhandle->iso.xmit_handler == NULL) + return 0; +@@ -138,7 +141,14 @@ int fw_iso_xmit_start(raw1394handle_t handle, int start_on_cycle, + return retval; + } + +- return queue_xmit_packets(handle, fwhandle->iso.buf_packets); ++ retval = queue_xmit_packets(handle, fwhandle->iso.buf_packets); ++ ++ if (retval) ++ return -1; ++ else ++ fwhandle->iso.state = ISO_ACTIVE; ++ ++ return 0; + } + + static int +@@ -221,7 +231,12 @@ int fw_iso_recv_start(fw_handle_t handle, int start_on_cycle, + start_iso.sync = 0; + start_iso.handle = 0; + +- return ioctl(handle->iso.fd, FW_CDEV_IOC_START_ISO, &start_iso); ++ if (ioctl(handle->iso.fd, FW_CDEV_IOC_START_ISO, &start_iso)) ++ return -1; ++ else ++ handle->iso.state = ISO_ACTIVE; ++ ++ return 0; + } + + static int handle_iso_event(raw1394handle_t handle, +@@ -256,9 +271,8 @@ int fw_iso_xmit_write(raw1394handle_t handle, unsigned char *data, + unsigned char sy) + { + fw_handle_t fwhandle = handle->mode.fw; +- struct fw_cdev_queue_iso queue_iso; + struct fw_cdev_start_iso start_iso; +- struct fw_cdev_iso_packet *p; ++ int retval; + + if (len > fwhandle->iso.max_packet_size) { + errno = EINVAL; +@@ -283,10 +297,10 @@ int fw_iso_xmit_write(raw1394handle_t handle, unsigned char *data, + start_iso.cycle = fwhandle->iso.start_on_cycle; + start_iso.handle = 0; + +- len = ioctl(fwhandle->iso.fd, ++ retval = ioctl(fwhandle->iso.fd, + FW_CDEV_IOC_START_ISO, &start_iso); +- if (len < 0) +- return len; ++ if (retval < 0) ++ return retval; + } + + return 0; +@@ -443,6 +457,7 @@ iso_init(fw_handle_t handle, int type, + handle->iso.head = handle->iso.buffer; + handle->iso.tail = handle->iso.buffer; + handle->iso.first_payload = handle->iso.buffer; ++ handle->iso.state = ISO_STOPPED; + + return 0; + } +@@ -519,15 +534,20 @@ void fw_iso_stop(fw_handle_t handle) + handle->iso.first_payload = handle->iso.buffer; + handle->iso.packet_phase = 0; + handle->iso.packet_count = 0; ++ handle->iso.packet_index = 0; ++ handle->iso.state = ISO_STOPPED; + } + + void fw_iso_shutdown(fw_handle_t handle) + { + munmap(handle->iso.buffer, + handle->iso.buf_packets * handle->iso.max_packet_size); ++ if (handle->iso.state != ISO_STOPPED) ++ fw_iso_stop(handle); + close(handle->iso.fd); + free(handle->iso.packets); + handle->iso.packets = NULL; ++ handle->iso.fd = -1; + } + + int fw_read_cycle_timer(fw_handle_t handle, +@@ -537,7 +557,7 @@ int fw_read_cycle_timer(fw_handle_t handle, + int err; + struct fw_cdev_get_cycle_timer ctr = { 0 }; + +- err = ioctl(handle->iso.fd, FW_CDEV_IOC_GET_CYCLE_TIMER, &ctr); ++ err = ioctl(handle->local_fd, FW_CDEV_IOC_GET_CYCLE_TIMER, &ctr); + if (!err) { + *cycle_timer = ctr.cycle_timer; + *local_time = ctr.local_time; +diff --git a/src/fw.c b/src/fw.c +index 3c61385..03e34a7 100644 +--- a/src/fw.c ++++ b/src/fw.c +@@ -125,7 +125,7 @@ scan_devices(fw_handle_t handle) + char filename[32]; + struct fw_cdev_get_info get_info; + struct fw_cdev_event_bus_reset reset; +- int fd, err, i; ++ int fd, err, i, fname_str_sz; + struct port *ports; + + ports = handle->ports; +@@ -162,8 +162,9 @@ scan_devices(fw_handle_t handle) + continue; + + if (i < MAX_PORTS && reset.node_id == reset.local_node_id) { +- strncpy(ports[i].device_file, filename, +- sizeof ports[i].device_file); ++ fname_str_sz = sizeof(ports[i].device_file) - 1; ++ strncpy(ports[i].device_file, filename, fname_str_sz); ++ ports[i].device_file[fname_str_sz] = '\0'; + ports[i].node_count = (reset.root_node_id & 0x3f) + 1; + ports[i].card = get_info.card; + i++; +@@ -315,7 +316,7 @@ handle_inotify(raw1394handle_t handle, struct epoll_closure *ec, + struct fw_cdev_get_info info; + struct fw_cdev_event_bus_reset reset; + struct epoll_event ep; +- int i, len, fd, phy_id; ++ int i, len, fd, phy_id, fname_str_sz; + + event = (struct inotify_event *) fwhandle->buffer; + len = read(fwhandle->inotify_fd, event, BUFFER_SIZE); +@@ -365,8 +366,9 @@ handle_inotify(raw1394handle_t handle, struct epoll_closure *ec, + fwhandle->devices[i].node_id = reset.node_id; + fwhandle->devices[i].generation = reset.generation; + fwhandle->devices[i].fd = fd; +- strncpy(fwhandle->devices[i].filename, filename, +- sizeof fwhandle->devices[i].filename); ++ fname_str_sz = sizeof(fwhandle->devices[i].filename) - 1; ++ strncpy(fwhandle->devices[i].filename, filename, fname_str_sz); ++ fwhandle->devices[i].filename[fname_str_sz] = '\0'; + fwhandle->devices[i].closure.func = handle_device_event; + ep.events = EPOLLIN; + ep.data.ptr = &fwhandle->devices[i].closure; +@@ -501,8 +503,10 @@ fw_handle_t fw_new_handle_on_port(int port) + if (handle == NULL) + return NULL; + +- if (fw_set_port(handle, port) < 0) ++ if (fw_set_port(handle, port) < 0) { ++ fw_destroy_handle(handle); + return NULL; ++ } + + return handle; + } +@@ -538,15 +542,17 @@ int fw_get_port_info(fw_handle_t handle, + struct raw1394_portinfo *pinf, + int maxports) + { +- int i; ++ int i, port_name_sz; + + if (maxports >= handle->port_count) + maxports = handle->port_count; + + for (i = 0; i < maxports; i++) { + pinf[i].nodes = handle->ports[i].node_count; ++ port_name_sz = sizeof(pinf[i].name) - 1; + strncpy(pinf[i].name, handle->ports[i].device_file, +- sizeof pinf[i].name); ++ port_name_sz); ++ pinf[i].name[port_name_sz] = '\0'; + } + + return handle->port_count; +@@ -560,7 +566,7 @@ int fw_set_port(fw_handle_t handle, int port) + struct dirent *de; + char filename[32]; + DIR *dir; +- int i, fd, phy_id; ++ int i, fd, phy_id, fname_str_sz; + + if (port >= handle->port_count) { + errno = EINVAL; +@@ -606,8 +612,9 @@ int fw_set_port(fw_handle_t handle, int port) + handle->devices[i].node_id = reset.node_id; + handle->devices[i].generation = reset.generation; + handle->devices[i].fd = fd; +- strncpy(handle->devices[i].filename, filename, +- sizeof handle->devices[i].filename); ++ fname_str_sz = sizeof(handle->devices[i].filename) -1; ++ strncpy(handle->devices[i].filename, filename, fname_str_sz); ++ handle->devices[i].filename[fname_str_sz] = '\0'; + + handle->devices[i].closure.func = handle_device_event; + memset(&ep, 0, sizeof(ep)); +@@ -623,8 +630,9 @@ int fw_set_port(fw_handle_t handle, int port) + if (reset.node_id == reset.local_node_id) { + memcpy(&handle->reset, &reset, sizeof handle->reset); + handle->local_fd = fd; +- strncpy(handle->local_filename, filename, +- sizeof handle->local_filename); ++ fname_str_sz = sizeof(handle->local_filename) -1; ++ strncpy(handle->local_filename, filename, fname_str_sz); ++ handle->local_filename[fname_str_sz] = '\0'; + } + + i++; +@@ -765,10 +773,12 @@ handle_arm_request(raw1394handle_t handle, struct address_closure *ac, + } + rrb->request.generation = fwhandle->reset.generation; + rrb->request.buffer_length = in_length; ++ rrb->request.buffer = rrb->data; + memcpy(rrb->request.buffer, request->data, in_length); + + rrb->response.response_code = response.rcode; + rrb->response.buffer_length = response.length; ++ rrb->response.buffer = rrb->data + in_length; + memcpy(rrb->response.buffer, + allocation->data + offset, response.length); + +@@ -1174,14 +1184,14 @@ fw_lock(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, + quadlet_t *result) + { + quadlet_t buffer[2]; +- size_t length; ++ ssize_t length; + + length = setup_lock(extcode, data, arg, buffer); + if (length < 0) + return length; + + return send_request_sync(handle, 16 + extcode, node, addr, +- length, buffer, result); ++ (size_t) length, buffer, result); + } + + int +@@ -1190,14 +1200,14 @@ fw_lock64(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, + octlet_t *result) + { + octlet_t buffer[2]; +- size_t length; ++ ssize_t length; + + length = setup_lock64(extcode, data, arg, buffer); + if (length < 0) + return length; + + return send_request_sync(handle, 16 + extcode, node, addr, +- length, buffer, result); ++ (size_t) length, buffer, result); + } + + int +@@ -1283,100 +1293,3 @@ fw_get_config_rom(fw_handle_t handle, quadlet_t *buffer, + + return 0; + } +- +-#define MAXIMUM_BANDWIDTH 4915 +- +-int +-fw_bandwidth_modify (raw1394handle_t handle, +- unsigned int bandwidth, +- enum raw1394_modify_mode mode) +-{ +- quadlet_t buffer, compare, swap; +- nodeaddr_t addr; +- int result; +- +- if (bandwidth == 0) +- return 0; +- +- addr = CSR_REGISTER_BASE + CSR_BANDWIDTH_AVAILABLE; +- /* Read current bandwidth usage from IRM. */ +- result = raw1394_read (handle, raw1394_get_irm_id (handle), addr, +- sizeof buffer, &buffer); +- if (result < 0) +- return -1; +- +- compare = ntohl (buffer); +- switch (mode) { +- case RAW1394_MODIFY_ALLOC: +- swap = compare - bandwidth; +- if (swap < 0) +- return -1; +- break; +- +- case RAW1394_MODIFY_FREE: +- swap = compare + bandwidth; +- if (swap > MAXIMUM_BANDWIDTH) +- swap = MAXIMUM_BANDWIDTH; +- break; +- +- default: +- return -1; +- } +- +- result = raw1394_lock(handle, raw1394_get_irm_id (handle), addr, +- RAW1394_EXTCODE_COMPARE_SWAP, +- htonl(swap), htonl(compare), &buffer); +- if (result < 0 || ntohl(buffer) != compare) +- return -1; +- +- return 0; +-} +- +-int +-fw_channel_modify (raw1394handle_t handle, +- unsigned int channel, +- enum raw1394_modify_mode mode) +-{ +- quadlet_t buffer, compare, swap, bit; +- nodeaddr_t addr; +- int result; +- +- if (channel >= 64) +- return -1; +- addr = CSR_REGISTER_BASE + +- CSR_CHANNELS_AVAILABLE_HI + 4 * (channel / 32); +- /* Read currently available channels from IRM. */ +- result = raw1394_read(handle, raw1394_get_irm_id (handle), addr, +- sizeof buffer, &buffer); +- if (result < 0) +- return -1; +- +- /* IEEE numbers bits from MSB (0) to LSB (31). */ +- bit = 1 << (31 - (channel & 31)); +- compare = ntohl(buffer); +- switch (mode) { +- case RAW1394_MODIFY_ALLOC: +- if ((compare & bit) == 0) +- return -1; +- swap = buffer & ~bit; +- break; +- +- case RAW1394_MODIFY_FREE: +- if ((buffer & bit) != 0) +- return -1; +- swap = buffer | bit; +- break; +- +- default: +- return -1; +- } +- +- result = raw1394_lock (handle, raw1394_get_irm_id (handle), addr, +- RAW1394_EXTCODE_COMPARE_SWAP, +- htonl(swap), htonl(compare), &buffer); +- +- if (result < 0 || ntohl(buffer) != compare) +- return -1; +- +- return 0; +-} +diff --git a/src/fw.h b/src/fw.h +index 4ee9017..56b59d9 100644 +--- a/src/fw.h ++++ b/src/fw.h +@@ -129,6 +129,7 @@ struct fw_handle { + int prebuffer; + int start_on_cycle; + enum raw1394_iso_dma_recv_mode recv_mode; ++ enum { ISO_STOPPED, ISO_ACTIVE } state; + raw1394_iso_xmit_handler_t xmit_handler; + raw1394_iso_recv_handler_t recv_handler; + unsigned char *buffer, *buffer_end, *head; +@@ -211,12 +212,6 @@ int fw_update_config_rom(fw_handle_t handle, const quadlet_t *new_rom, + int fw_get_config_rom(fw_handle_t handle, quadlet_t *buffer, + size_t buffersize, size_t *rom_size, + unsigned char *rom_version); +-int fw_bandwidth_modify (raw1394handle_t handle, +- unsigned int bandwidth, +- enum raw1394_modify_mode mode); +-int fw_channel_modify (raw1394handle_t handle, +- unsigned int channel, +- enum raw1394_modify_mode mode); + + int fw_iso_xmit_start(raw1394handle_t handle, int start_on_cycle, + int prebuffer_packets); +diff --git a/src/main.c b/src/main.c +index 55b4fbc..d83256e 100644 +--- a/src/main.c ++++ b/src/main.c +@@ -253,9 +253,7 @@ void *raw1394_get_userdata(struct raw1394_handle *handle) + int ieee1394_get_port_info(struct ieee1394_handle *handle, + struct raw1394_portinfo *pinf, int maxports) + { +- int num; + struct raw1394_request req; +- struct raw1394_khost_list *khl; + + CLEAR_REQ(&req); + req.type = RAW1394_REQ_LIST_CARDS; +diff --git a/src/raw1394.h b/src/raw1394.h +index c489c20..7bfeb05 100644 +--- a/src/raw1394.h ++++ b/src/raw1394.h +@@ -1203,7 +1203,7 @@ raw1394_bandwidth_modify (raw1394handle_t handle, unsigned int bandwidth, + enum raw1394_modify_mode mode); + + /** +- * raw1394_bandwidth_modify - allocate or release isochronous channel ++ * raw1394_channel_modify - allocate or release isochronous channel + * @handle: a libraw1394 handle + * @channel: isochronous channel + * @mode: whether to allocate or free +diff --git a/tools/testlibraw.c b/tools/testlibraw.c +index efd87ad..82b8ee5 100644 +--- a/tools/testlibraw.c ++++ b/tools/testlibraw.c +@@ -14,6 +14,7 @@ + #include + #include + #include ++#include + #include + + #include "../src/raw1394.h" +@@ -53,8 +54,8 @@ static const unsigned char fcp_data[] = + int my_fcp_handler(raw1394handle_t handle, nodeid_t nodeid, int response, + size_t length, unsigned char *data) + { +- printf("got fcp %s from node %d of %d bytes:", +- (response ? "response" : "command"), nodeid & 0x3f, length); ++ printf(" got fcp %s from node %d of %d bytes:", ++ (response ? "response" : "command"), nodeid & 0x3f, length); + + if (memcmp(fcp_data, data, sizeof fcp_data) != 0) + printf("ERROR: fcp payload not correct\n"); +@@ -73,7 +74,7 @@ int my_fcp_handler(raw1394handle_t handle, nodeid_t nodeid, int response, + static void + test_fcp(raw1394handle_t handle) + { +- printf("\ntesting FCP monitoring on local node\n"); ++ printf("\n - testing FCP monitoring on local node\n"); + raw1394_set_fcp_handler(handle, my_fcp_handler); + raw1394_start_fcp_listen(handle); + raw1394_write(handle, raw1394_get_local_id(handle), +@@ -95,142 +96,188 @@ read_topology_map(raw1394handle_t handle) + + retval = raw1394_read(handle, local_id, + CSR_REGISTER_BASE + CSR_TOPOLOGY_MAP, 12, &map[0]); +- if (retval < 0) +- perror("topology map: raw1394_read failed with error"); +- ++ if (retval < 0) { ++ perror("\n - topology map: raw1394_read failed with error"); ++ return; ++ } ++ + self_id_count = ntohl(map[2]) & 0xffff; + node_count = ntohl(map[2]) >> 16; + retval = raw1394_read(handle, local_id, + CSR_REGISTER_BASE + CSR_TOPOLOGY_MAP + 12, + self_id_count * sizeof map[0], &map[3]); +- if (retval < 0) +- perror("topology map: raw1394_read failed with error"); ++ if (retval < 0) { ++ perror("\n - topology map: raw1394_read failed with error"); ++ return; ++ } + +- printf("topology map: %d nodes, %d self ids, generation %d\n", ++ printf("\n - topology map: %d nodes, %d self ids, generation %d\n", + node_count, self_id_count, ntohl(map[1])); + for (i = 0; i < self_id_count; i++) +- printf(" 0x%08x\n", ntohl(map[3 + i])); ++ printf(" 0x%08x\n", ntohl(map[3 + i])); + } + +-int main(int argc, char **argv) ++static void ++test_config_rom(raw1394handle_t handle) + { +- raw1394handle_t handle; +- int i, numcards; +- struct raw1394_portinfo pinf[16]; +- +- tag_handler_t std_handler; +- int retval; +- +- struct pollfd pfd; +- quadlet_t rom[0x100]; +- size_t rom_size; +- unsigned char rom_version; +- +- handle = raw1394_new_handle(); +- +- if (!handle) { +- if (!errno) { +- printf(not_compatible); +- } else { +- perror("couldn't get handle"); +- printf(not_loaded); +- } +- exit(1); +- } +- +- printf("successfully got handle\n"); +- printf("current generation number: %d\n", raw1394_get_generation(handle)); +- +- numcards = raw1394_get_port_info(handle, pinf, 16); +- if (numcards < 0) { +- perror("couldn't get card info"); +- exit(1); +- } else { +- printf("%d card(s) found\n", numcards); +- } +- +- if (!numcards) { +- exit(0); +- } +- +- for (i = 0; i < numcards; i++) { +- printf(" nodes on bus: %2d, card name: %s\n", pinf[i].nodes, +- pinf[i].name); +- } +- +- if (raw1394_set_port(handle, 0) < 0) { +- perror("couldn't set port"); +- exit(1); +- } ++ quadlet_t rom[0x100] = { 0, }; ++ size_t rom_size; ++ unsigned char rom_version; ++ int i, retval; ++ ++ printf("\n - testing config rom\n"); ++ retval = raw1394_get_config_rom(handle, rom, 0x100, ++ &rom_size, &rom_version); ++ printf(" get_config_rom returned %d, romsize %d, rom_version %d\n", ++ retval, rom_size, rom_version); ++ printf(" here are the first 10 quadlets:\n"); ++ for (i = 0; i < 10; i++) ++ printf(" 0x%08x\n", i, rom[i]); ++ ++ retval = raw1394_update_config_rom(handle, rom, rom_size, rom_version); ++ printf(" update_config_rom returned %d\n", retval); ++} + +- printf("using first card found: %d nodes on bus, local ID is %d, IRM is %d\n", +- raw1394_get_nodecount(handle), +- raw1394_get_local_id(handle) & 0x3f, +- raw1394_get_irm_id(handle) & 0x3f); +- +- printf("\ndoing transactions with custom tag handler\n"); +- std_handler = raw1394_set_tag_handler(handle, my_tag_handler); +- for (i = 0; i < pinf[0].nodes; i++) { +- printf("trying to send read request to node %d... ", i); +- fflush(stdout); +- buffer = 0; +- +- if (raw1394_start_read(handle, 0xffc0 | i, TESTADDR, 4, +- &buffer, 0) < 0) { +- perror("failed"); +- continue; +- } +- raw1394_loop_iterate(handle); +- } ++static void ++read_cycle_timer(raw1394handle_t handle) ++{ ++ u_int32_t ct; ++ u_int64_t local_time; ++ time_t seconds; ++ int retval; ++ ++ retval = raw1394_read_cycle_timer(handle, &ct, &local_time); ++ if (retval < 0) { ++ perror("\n - raw1394_read_cycle_timer failed with error"); ++ return; ++ } ++ ++ printf("\n - cycle timer: %d seconds, %d cycles, %d sub-cycles\n", ++ ct >> 25, (ct >> 12) & 0x1fff, ct & 0xfff); ++ seconds = local_time / 1000000; ++ printf(" local time: %lld us = %s", ++ (unsigned long long)local_time, ctime(&seconds)); ++} + +- printf("\nusing standard tag handler and synchronous calls\n"); +- raw1394_set_tag_handler(handle, std_handler); +- for (i = 0; i < pinf[0].nodes; i++) { +- printf("trying to read from node %d... ", i); +- fflush(stdout); +- buffer = 0; +- +- retval = raw1394_read(handle, 0xffc0 | i, TESTADDR, 4, &buffer); +- if (retval < 0) { +- perror("failed with error"); +- } else { +- printf("completed with value 0x%08x\n", buffer); +- } +- } ++int test_card(int card) ++{ ++ raw1394handle_t handle; ++ struct raw1394_portinfo pinf; ++ tag_handler_t std_handler; ++ struct pollfd pfd; ++ int i, n, numcards, retval; ++ ++ handle = raw1394_new_handle(); ++ ++ if (!handle) { ++ if (!errno) { ++ printf(not_compatible); ++ } else { ++ perror("couldn't get handle"); ++ printf(not_loaded); ++ } ++ return -1; ++ } ++ ++ if (card == 0) { ++ printf("successfully got handle\n"); ++ printf("current generation number: %d\n", ++ raw1394_get_generation(handle)); ++ } ++ ++ numcards = raw1394_get_port_info(handle, &pinf, 1); ++ if (numcards < card) ++ perror("couldn't get card info"); ++ else if (card == 0) ++ printf("%d card%s found\n", ++ numcards, numcards == 1 ? "" : "s"); ++ ++ if (numcards <= card) ++ goto out; ++ ++ printf("\ncard %d, name: %s\n", card, pinf.name); ++ ++ if (raw1394_set_port(handle, card) < 0) { ++ perror("couldn't set port"); ++ goto out; ++ } ++ ++ n = raw1394_get_nodecount(handle); ++ printf("%d nodes on bus, local ID is %d, IRM is %d\n", ++ n, ++ raw1394_get_local_id(handle) & 0x3f, ++ raw1394_get_irm_id(handle) & 0x3f); ++ ++ if (n > 0) { ++ printf("\n - doing transactions with custom tag handler\n"); ++ std_handler = raw1394_set_tag_handler(handle, my_tag_handler); ++ } ++ for (i = 0; i < n; i++) { ++ printf(" read from node %d... ", i); ++ fflush(stdout); ++ buffer = 0; ++ ++ if (raw1394_start_read(handle, 0xffc0 | i, TESTADDR, 4, ++ &buffer, 0) < 0) { ++ perror("failed"); ++ continue; ++ } ++ if (raw1394_loop_iterate(handle)) ++ perror("failed"); ++ } ++ ++ if (n > 0) { ++ printf("\n - using standard tag handler and synchronous calls\n"); ++ raw1394_set_tag_handler(handle, std_handler); ++ } ++ for (i = 0; i < n; i++) { ++ printf(" read from node %d... ", i); ++ fflush(stdout); ++ buffer = 0; ++ ++ retval = raw1394_read(handle, 0xffc0 | i, TESTADDR, 4, &buffer); ++ if (retval < 0) ++ perror("failed with error"); ++ else ++ printf("completed with value 0x%08x\n", buffer); ++ } + + test_fcp(handle); + read_topology_map(handle); ++ test_config_rom(handle); ++ read_cycle_timer(handle); + +- printf("testing config rom stuff\n"); +- memset(rom, 0, sizeof(rom)); +- retval=raw1394_get_config_rom(handle, rom, 0x100, &rom_size, &rom_version); +- printf("get_config_rom returned %d, romsize %d, rom_version %d\n",retval,rom_size,rom_version); +- printf("here are the first 10 quadlets:\n"); +- for (i = 0; i < 10; i++) +- printf("%d. quadlet: 0x%08x\n",i,rom[i]); +- +- /* some manipulation */ +-/* printf("incrementing 2nd quadlet\n"); +- rom[0x02/4]++; +-*/ +- retval=raw1394_update_config_rom(handle, rom, rom_size, rom_version); +- printf("update_config_rom returned %d\n",retval); +- +- printf("\nposting 0xdeadbeef as an echo request\n"); ++ printf("\n - posting 0xdeadbeef as an echo request\n"); + raw1394_echo_request(handle, 0xdeadbeef); + +- printf("polling for leftover messages\n"); +- pfd.fd = raw1394_get_fd(handle); +- pfd.events = POLLIN; +- pfd.revents = 0; +- while (1) { +- retval = poll(&pfd, 1, 10); +- if (retval < 1) break; ++ printf(" polling for leftover messages\n"); ++ pfd.fd = raw1394_get_fd(handle); ++ pfd.events = POLLIN; ++ pfd.revents = 0; ++ while (1) { ++ retval = poll(&pfd, 1, 10); ++ if (retval < 1) ++ break; + retval = raw1394_loop_iterate(handle); + if (retval != 0) +- printf("raw1394_loop_iterate() returned 0x%08x\n", retval); +- } ++ printf(" raw1394_loop_iterate() returned 0x%08x\n", ++ retval); ++ } ++ ++ if (retval < 0) ++ perror("poll failed"); ++out: ++ raw1394_destroy_handle(handle); ++ return numcards; ++} ++ ++int main(int argc, char **argv) ++{ ++ int card = 0, numcards; ++ ++ do ++ numcards = test_card(card); ++ while (++card < numcards); + +- if (retval < 0) perror("poll failed"); +- exit(0); ++ return numcards < 0; + } diff --git a/libraw1394.spec b/libraw1394.spec index f6918a9..8d6a948 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,13 +1,11 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 2.0.0 -Release: 4%{?dist} +Release: 5%{?dist} License: LGPLv2+ Group: System Environment/Libraries Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz -Patch0: libraw1394-2.0.0-coverity-prevent-fixes.patch -Patch1: libraw1394-2.0.0-git-fixes.patch -Patch2: libraw1394-2.0.0-fix-channel_modify.patch +Patch0: libraw1394-2.0.0-git-update.patch URL: http://www.linux1394.org/ ExcludeArch: s390 s390x BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) @@ -31,8 +29,6 @@ Development libraries needed to build applications against libraw1394. %prep %setup -q %patch0 -p1 -%patch1 -p1 -%patch2 -p1 %build %configure --disable-static @@ -71,6 +67,10 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Mon Dec 08 2008 Jarod Wilson - 2.0.0-5 +- Fix up iso stop command so starting/stopping/starting iso reception works +- Plug firewire handle leak + * Fri Dec 05 2008 Jarod Wilson - 2.0.0-4 - Fix channel modify code, should make iso reception work reliably now From 995f367082bfbd33b928344608b6c06a8b9ee4ca Mon Sep 17 00:00:00 2001 From: Jarod Wilson Date: Tue, 13 Jan 2009 15:10:26 +0000 Subject: [PATCH 056/100] - Set errno = ENOSYS for all unimplemented functions - Make dvgrab and friends work w/o requiring r/w on the local fw node (#441073) --- ...no-ENOSYS-in-unimplemented-functions.patch | 59 +++++ ...work-without-write-on-local-node-dev.patch | 245 ++++++++++++++++++ libraw1394.spec | 10 +- 3 files changed, 313 insertions(+), 1 deletion(-) create mode 100644 libraw1394-use-errno-ENOSYS-in-unimplemented-functions.patch create mode 100644 libraw1394-work-without-write-on-local-node-dev.patch diff --git a/libraw1394-use-errno-ENOSYS-in-unimplemented-functions.patch b/libraw1394-use-errno-ENOSYS-in-unimplemented-functions.patch new file mode 100644 index 0000000..741b78e --- /dev/null +++ b/libraw1394-use-errno-ENOSYS-in-unimplemented-functions.patch @@ -0,0 +1,59 @@ +Date: Sun, 11 Jan 2009 22:39:17 +0100 (CET) +From: Stefan Richter +Subject: [PATCH libraw1394 fix] Set errno = ENOSYS in unimplemented functions +To: Dan Dennedy +Cc: linux1394-devel@lists.sourceforge.net + +Most of them do this already, only a few missed it. + +Signed-off-by: Stefan Richter +--- + src/fw.c | 5 +++++ + 1 files changed, 5 insertions(+), 0 deletions(-) + +diff --git a/src/fw.c b/src/fw.c +index 3f5d806..ba3a807 100644 +--- a/src/fw.c ++++ b/src/fw.c +@@ -1104,6 +1104,7 @@ fw_start_async_stream(fw_handle_t handle, unsigned int channel, + unsigned long rawtag) + { + /* FIXME: implement this? */ ++ errno = ENOSYS; + return -1; + } + +@@ -1115,6 +1116,7 @@ fw_start_async_send(fw_handle_t handle, + quadlet_t *data, unsigned long rawtag) + { + /* FIXME: implement this? */ ++ errno = ENOSYS; + return -1; + } + +@@ -1233,6 +1235,7 @@ fw_async_stream(fw_handle_t handle, unsigned int channel, + size_t length, quadlet_t *data) + { + /* FIXME: implement this? */ ++ errno = ENOSYS; + return -1; + } + +@@ -1243,6 +1246,7 @@ fw_async_send(fw_handle_t handle, + quadlet_t *data) + { + /* FIXME: implement this? */ ++ errno = ENOSYS; + return -1; + } + +@@ -1284,6 +1288,7 @@ int + fw_update_config_rom(fw_handle_t handle, const quadlet_t *new_rom, + size_t size, unsigned char rom_version) + { ++ errno = ENOSYS; + return -1; + } + +-- +1.6.0.6 diff --git a/libraw1394-work-without-write-on-local-node-dev.patch b/libraw1394-work-without-write-on-local-node-dev.patch new file mode 100644 index 0000000..f0985c5 --- /dev/null +++ b/libraw1394-work-without-write-on-local-node-dev.patch @@ -0,0 +1,245 @@ +Date: Sat, 10 Jan 2009 21:14:50 +0100 (CET) +From: Stefan Richter +Subject: Re: [PATCH libraw1394] Work without permission to access local node's + /dev/fw* +To: Dan Dennedy +Cc: linux1394-devel@lists.sourceforge.net, + dcm@acm.org + +On 10 Jan, Stefan Richter wrote: +> --- a/src/fw.c +> +++ b/src/fw.c +> @@ -125,17 +125,19 @@ scan_devices(fw_handle_t handle) +> char filename[32]; +> struct fw_cdev_get_info get_info; +> struct fw_cdev_event_bus_reset reset; +> - int fd, err, i, fname_str_sz; +> + int fd, err, i, j, fname_str_sz; +> struct port *ports; +> +> ports = handle->ports; +> memset(ports, 0, sizeof handle->ports); +> + for (i = 0; i < MAX_PORTS; i++) +> + ports[i].card = -1; +> + + +The memset is not necessary. + + +From: Stefan Richter +Subject: [PATCH] Work without permission to access local node's /dev/fw* + +Fix for juju backend: + +libraw1394 required write permission to the character device file of +the local node(s) in order to enumerate cards and for a number of +other operations. This forced users to either run applications like +dvgrab and kino with elevated privileges, or to configure write +permission for all /dev/fw* or at least for local nodes' /dev/fw*. + +We now use the first accessible file which was found for each card +for as many tasks as possible, instead of the local node's file. + +This allows distributors or admins to implement stricter access +rights (default off, e.g. only on for AV/C and IIDC devices) +without sacrificing functionality of said class of applications. +Access to the local node is now only required by low-level tools +like gscanbus. + +Signed-off-by: Stefan Richter +--- + src/fw-iso.c | 4 ++-- + src/fw.c | 50 +++++++++++++++++++++++++++++++++----------------- + src/fw.h | 6 +++--- + 3 files changed, 38 insertions(+), 22 deletions(-) + +diff --git a/src/fw-iso.c b/src/fw-iso.c +index 6a84662..a87259b 100644 +--- a/src/fw-iso.c ++++ b/src/fw-iso.c +@@ -407,7 +407,7 @@ iso_init(fw_handle_t handle, int type, + if (handle->iso.packets == NULL) + return -1; + +- handle->iso.fd = open(handle->local_filename, O_RDWR); ++ handle->iso.fd = open(handle->iso.filename, O_RDWR); + if (handle->iso.fd < 0) { + free(handle->iso.packets); + handle->iso.packets = NULL; +@@ -557,7 +557,7 @@ int fw_read_cycle_timer(fw_handle_t handle, + int err; + struct fw_cdev_get_cycle_timer ctr = { 0 }; + +- err = ioctl(handle->local_fd, FW_CDEV_IOC_GET_CYCLE_TIMER, &ctr); ++ err = ioctl(handle->ioctl_fd, FW_CDEV_IOC_GET_CYCLE_TIMER, &ctr); + if (!err) { + *cycle_timer = ctr.cycle_timer; + *local_time = ctr.local_time; +diff --git a/src/fw.c b/src/fw.c +index e211b60..3f5d806 100644 +--- a/src/fw.c ++++ b/src/fw.c +@@ -125,17 +125,18 @@ scan_devices(fw_handle_t handle) + char filename[32]; + struct fw_cdev_get_info get_info; + struct fw_cdev_event_bus_reset reset; +- int fd, err, i, fname_str_sz; ++ int fd, err, i, j, fname_str_sz; + struct port *ports; + + ports = handle->ports; +- memset(ports, 0, sizeof handle->ports); ++ for (i = 0; i < MAX_PORTS; i++) ++ ports[i].card = -1; ++ + dir = opendir(FW_DEVICE_DIR); + if (dir == NULL) + return -1; + +- i = 0; +- while (1) { ++ for (i = 0; i < MAX_PORTS; ) { + de = readdir(dir); + if (de == NULL) + break; +@@ -161,7 +162,10 @@ scan_devices(fw_handle_t handle) + if (err < 0) + continue; + +- if (i < MAX_PORTS && reset.node_id == reset.local_node_id) { ++ for (j = 0; j < i; j++) ++ if (ports[j].card == get_info.card) ++ break; ++ if (j == i) { + fname_str_sz = sizeof(ports[i].device_file) - 1; + strncpy(ports[i].device_file, filename, fname_str_sz); + ports[i].device_file[fname_str_sz] = '\0'; +@@ -626,20 +630,27 @@ int fw_set_port(fw_handle_t handle, int port) + return -1; + } + +- handle->generation = reset.generation; +- if (reset.node_id == reset.local_node_id) { ++ if (handle->iso.filename == NULL) { + memcpy(&handle->reset, &reset, sizeof handle->reset); +- handle->local_fd = fd; +- fname_str_sz = sizeof(handle->local_filename) -1; +- strncpy(handle->local_filename, filename, fname_str_sz); +- handle->local_filename[fname_str_sz] = '\0'; ++ handle->iso.filename = handle->devices[i].filename; ++ handle->ioctl_fd = fd; + } + ++ if (reset.node_id == reset.local_node_id) ++ handle->local_device = &handle->devices[i]; ++ ++ handle->generation = reset.generation; ++ + i++; + } + + closedir(dir); + ++ if (i == 0) { ++ errno = ENODEV; ++ return -1; ++ } ++ + return 0; + } + +@@ -656,7 +667,7 @@ int fw_reset_bus_new(fw_handle_t handle, int type) + break; + } + +- return ioctl(handle->local_fd, ++ return ioctl(handle->ioctl_fd, + FW_CDEV_IOC_INITIATE_BUS_RESET, &initiate); + } + +@@ -817,7 +828,7 @@ fw_arm_register(fw_handle_t handle, nodeaddr_t start, + request.length = length; + request.closure = ptr_to_u64(&allocation->closure); + +- retval = ioctl(handle->local_fd, FW_CDEV_IOC_ALLOCATE, &request); ++ retval = ioctl(handle->ioctl_fd, FW_CDEV_IOC_ALLOCATE, &request); + if (retval < 0) { + free(allocation); + return -1; +@@ -863,7 +874,7 @@ fw_arm_unregister(fw_handle_t handle, nodeaddr_t start) + request.handle = allocation->handle; + free(allocation); + +- return ioctl(handle->local_fd, FW_CDEV_IOC_DEALLOCATE, &request); ++ return ioctl(handle->ioctl_fd, FW_CDEV_IOC_DEALLOCATE, &request); + } + + int +@@ -1251,7 +1262,7 @@ fw_start_fcp_listen(fw_handle_t handle) + request.offset = CSR_REGISTER_BASE + CSR_FCP_COMMAND; + request.length = CSR_FCP_END - CSR_FCP_COMMAND; + request.closure = ptr_to_u64(closure); +- if (ioctl(handle->local_fd, FW_CDEV_IOC_ALLOCATE, &request) < 0) ++ if (ioctl(handle->ioctl_fd, FW_CDEV_IOC_ALLOCATE, &request) < 0) + return -1; + + handle->fcp_allocation_handle = request.handle; +@@ -1266,7 +1277,7 @@ fw_stop_fcp_listen(fw_handle_t handle) + + request.handle = handle->fcp_allocation_handle; + +- return ioctl(handle->local_fd, FW_CDEV_IOC_DEALLOCATE, &request); ++ return ioctl(handle->ioctl_fd, FW_CDEV_IOC_DEALLOCATE, &request); + } + + int +@@ -1284,13 +1295,18 @@ fw_get_config_rom(fw_handle_t handle, quadlet_t *buffer, + struct fw_cdev_get_info get_info; + int err; + ++ if (handle->local_device == NULL) { ++ errno = EPERM; ++ return -1; ++ } ++ + memset(&get_info, 0, sizeof(get_info)); + get_info.version = FW_CDEV_VERSION; + get_info.rom = ptr_to_u64(buffer); + get_info.rom_length = buffersize; + get_info.bus_reset = 0; + +- err = ioctl(handle->local_fd, FW_CDEV_IOC_GET_INFO, &get_info); ++ err = ioctl(handle->local_device->fd, FW_CDEV_IOC_GET_INFO, &get_info); + if (err) + return err; + +diff --git a/src/fw.h b/src/fw.h +index 56b59d9..a5e3772 100644 +--- a/src/fw.h ++++ b/src/fw.h +@@ -101,6 +101,7 @@ struct fw_handle { + __u32 fcp_allocation_handle; + struct allocation *allocations; + ++ int ioctl_fd; + int epoll_fd; + int inotify_fd; + int inotify_watch; +@@ -110,13 +111,12 @@ struct fw_handle { + struct epoll_closure inotify_closure; + + struct device devices[MAX_DEVICES]; ++ struct device *local_device; + int nodes[MAX_DEVICES]; +- int local_fd; +- char local_filename[FILENAME_SIZE]; +- + struct fw_cdev_event_bus_reset reset; + + struct { ++ char *filename; + struct epoll_closure closure; + int fd; + int type; +-- +1.6.0.6 diff --git a/libraw1394.spec b/libraw1394.spec index 8d6a948..29dd0ea 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,11 +1,13 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 2.0.0 -Release: 5%{?dist} +Release: 6%{?dist} License: LGPLv2+ Group: System Environment/Libraries Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz Patch0: libraw1394-2.0.0-git-update.patch +Patch1: libraw1394-use-errno-ENOSYS-in-unimplemented-functions.patch +Patch2: libraw1394-work-without-write-on-local-node-dev.patch URL: http://www.linux1394.org/ ExcludeArch: s390 s390x BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) @@ -29,6 +31,8 @@ Development libraries needed to build applications against libraw1394. %prep %setup -q %patch0 -p1 +%patch1 -p1 +%patch2 -p1 %build %configure --disable-static @@ -67,6 +71,10 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Tue Jan 13 2009 Jarod Wilson - 2.0.0-6 +- Set errno = ENOSYS for all unimplemented functions +- Make dvgrab and friends work w/o requiring r/w on the local fw node (#441073) + * Mon Dec 08 2008 Jarod Wilson - 2.0.0-5 - Fix up iso stop command so starting/stopping/starting iso reception works - Plug firewire handle leak From 14d9587ed1a9c329ba4ab0aeadcc1c446348b130 Mon Sep 17 00:00:00 2001 From: Jarod Wilson Date: Thu, 15 Jan 2009 15:11:20 +0000 Subject: [PATCH 057/100] - Update to libraw1394 v2.0.1 release --- .cvsignore | 1 + libraw1394-2.0.0-git-update.patch | 993 ------------------ ...no-ENOSYS-in-unimplemented-functions.patch | 59 -- ...work-without-write-on-local-node-dev.patch | 245 ----- libraw1394.spec | 13 +- sources | 2 +- 6 files changed, 7 insertions(+), 1306 deletions(-) delete mode 100644 libraw1394-2.0.0-git-update.patch delete mode 100644 libraw1394-use-errno-ENOSYS-in-unimplemented-functions.patch delete mode 100644 libraw1394-work-without-write-on-local-node-dev.patch diff --git a/.cvsignore b/.cvsignore index 22da05b..1059d3a 100644 --- a/.cvsignore +++ b/.cvsignore @@ -4,3 +4,4 @@ fw-device-cdev.h libraw1394-1.3.0.tar.gz libraw1394-2.0.0-20080430_git.tar.bz2 libraw1394-2.0.0.tar.gz +libraw1394-2.0.1.tar.gz diff --git a/libraw1394-2.0.0-git-update.patch b/libraw1394-2.0.0-git-update.patch deleted file mode 100644 index 9324063..0000000 --- a/libraw1394-2.0.0-git-update.patch +++ /dev/null @@ -1,993 +0,0 @@ - Makefile.am | 23 ---- - src/arm.c | 2 - - src/dispatch.c | 102 ++++++++++--------- - src/eventloop.c | 2 +- - src/fw-iso.c | 40 ++++++-- - src/fw.c | 143 +++++--------------------- - src/fw.h | 7 +- - src/main.c | 2 - - src/raw1394.h | 2 +- - tools/testlibraw.c | 285 ++++++++++++++++++++++++++++++---------------------- - 10 files changed, 279 insertions(+), 329 deletions(-) - -diff --git a/Makefile.am b/Makefile.am -index f48af74..bf094f0 100644 ---- a/Makefile.am -+++ b/Makefile.am -@@ -23,28 +23,5 @@ htmldoc: - - .PHONY: doc psdoc pdfdoc htmldoc - --# make required device file --dev: -- mknod -m 600 /dev/raw1394 c 171 0 -- chown root.root /dev/raw1394 -- @echo -- @echo "/dev/raw1394 created" -- @echo "It is owned by root with permissions 600. You may want to fix" -- @echo "the group/permission to something appropriate for you." -- @echo "Note however that anyone who can open raw1394 can access all" -- @echo "devices on all connected 1394 buses unrestricted, including" -- @echo "harddisks and other probably sensitive devices." -- @echo -- --install-exec-hook: -- @if [ ! -c /dev/raw1394 ]; then \ -- echo; \ -- echo "********************************************"; \ -- echo "Required /dev/raw1394 device file not found."; \ -- echo "Run 'make dev' to create it."; \ -- echo "********************************************"; \ -- echo; \ -- fi -- - dist-hook: - git log >$(distdir)/ChangeLog -diff --git a/src/arm.c b/src/arm.c -index c523c00..27ad762 100644 ---- a/src/arm.c -+++ b/src/arm.c -@@ -109,7 +109,6 @@ int ieee1394_arm_set_buf (struct ieee1394_handle *handle, nodeaddr_t start, - size_t length, void *buf) - { - struct raw1394_request req; -- int status; - - CLEAR_REQ(&req); - -@@ -139,7 +138,6 @@ int ieee1394_arm_get_buf (struct ieee1394_handle *handle, nodeaddr_t start, - size_t length, void *buf) - { - struct raw1394_request req; -- int status; - - CLEAR_REQ(&req); - -diff --git a/src/dispatch.c b/src/dispatch.c -index b15e8c5..49ceca2 100644 ---- a/src/dispatch.c -+++ b/src/dispatch.c -@@ -24,33 +24,35 @@ int raw1394_errcode_to_errno(raw1394_errcode_t errcode) - - raw1394handle_t raw1394_new_handle(void) - { -- ieee1394handle_t ieee1394_handle = ieee1394_new_handle(); -- fw_handle_t fw_handle = NULL; -- raw1394handle_t handle = NULL; -+ ieee1394handle_t ieee1394_handle; -+ fw_handle_t fw_handle; -+ raw1394handle_t handle; -+ struct raw1394_portinfo port; - -- if (ieee1394_handle) { -- struct raw1394_portinfo port; -- if (ieee1394_get_port_info(ieee1394_handle, &port, 1) < 1) { -- ieee1394_destroy_handle(ieee1394_handle); -- ieee1394_handle = NULL; -- fw_handle = fw_new_handle(); -- } -- } -- else { -- fw_handle = fw_new_handle(); -- } -- if (ieee1394_handle || fw_handle) { -- handle = (raw1394handle_t) malloc(sizeof(struct raw1394_handle)); -- if (ieee1394_handle && handle) { -- handle->is_fw = 0; -- handle->mode.ieee1394 = ieee1394_handle; -- } -- else if (handle) { -- handle->is_fw = 1; -- handle->mode.fw = fw_handle; -- } -- } -- return handle; -+ handle = (raw1394handle_t) malloc(sizeof(struct raw1394_handle)); -+ if (!handle) -+ return NULL; -+ -+ ieee1394_handle = ieee1394_new_handle(); -+ if (!ieee1394_handle) -+ goto try_fw; -+ -+ if (ieee1394_get_port_info(ieee1394_handle, &port, 1) >= 1) { -+ handle->is_fw = 0; -+ handle->mode.ieee1394 = ieee1394_handle; -+ return handle; -+ } -+ ieee1394_destroy_handle(ieee1394_handle); -+try_fw: -+ fw_handle = fw_new_handle(); -+ if (fw_handle) { -+ handle->is_fw = 1; -+ handle->mode.fw = fw_handle; -+ return handle; -+ } -+ -+ free(handle); -+ return NULL; - } - - void raw1394_destroy_handle(raw1394handle_t handle) -@@ -61,30 +63,36 @@ void raw1394_destroy_handle(raw1394handle_t handle) - if (handle->is_fw) - fw_destroy_handle(handle->mode.fw); - else -- ieee1394_destroy_handle(handle->mode.ieee1394);; -+ ieee1394_destroy_handle(handle->mode.ieee1394); -+ free(handle); - } - - raw1394handle_t raw1394_new_handle_on_port(int port) - { -- ieee1394handle_t ieee1394_handle = ieee1394_new_handle_on_port(port); -- fw_handle_t fw_handle = NULL; -- raw1394handle_t handle = NULL; -+ ieee1394handle_t ieee1394_handle; -+ fw_handle_t fw_handle; -+ raw1394handle_t handle; -+ -+ handle = (raw1394handle_t) malloc(sizeof(struct raw1394_handle)); -+ if (!handle) -+ return NULL; - -+ ieee1394_handle = ieee1394_new_handle_on_port(port); - if (ieee1394_handle) { -- handle = (raw1394handle_t) malloc(sizeof(struct raw1394_handle)); -- if (handle) { -- handle->is_fw = 0; -- handle->mode.ieee1394 = ieee1394_handle; -- } -+ handle->is_fw = 0; -+ handle->mode.ieee1394 = ieee1394_handle; -+ return handle; - } -- else if (fw_handle = fw_new_handle_on_port(port)) { -- handle = (raw1394handle_t) malloc(sizeof(struct raw1394_handle)); -- if (handle) { -- handle->is_fw = 1; -- handle->mode.fw = fw_handle; -- } -+ -+ fw_handle = fw_new_handle_on_port(port); -+ if (fw_handle) { -+ handle->is_fw = 1; -+ handle->mode.fw = fw_handle; -+ return handle; - } -- return handle; -+ -+ free(handle); -+ return NULL; - } - - int raw1394_busreset_notify (raw1394handle_t handle, int off_on_switch) -@@ -533,10 +541,7 @@ int raw1394_bandwidth_modify (raw1394handle_t handle, unsigned int bandwidth, - errno = EINVAL; - return -1; - } -- if (handle->is_fw) -- return fw_bandwidth_modify(handle, bandwidth, mode); -- else -- return ieee1394_bandwidth_modify(handle, bandwidth, mode); -+ return ieee1394_bandwidth_modify(handle, bandwidth, mode); - } - - int raw1394_channel_modify (raw1394handle_t handle, unsigned int channel, -@@ -546,10 +551,7 @@ int raw1394_channel_modify (raw1394handle_t handle, unsigned int channel, - errno = EINVAL; - return -1; - } -- if (handle->is_fw) -- return fw_channel_modify(handle, channel, mode); -- else -- return ieee1394_channel_modify(handle, channel, mode); -+ return ieee1394_channel_modify(handle, channel, mode); - } - - int raw1394_iso_xmit_init(raw1394handle_t handle, -diff --git a/src/eventloop.c b/src/eventloop.c -index 43a9519..81bb881 100644 ---- a/src/eventloop.c -+++ b/src/eventloop.c -@@ -32,7 +32,7 @@ int ieee1394_loop_iterate(struct raw1394_handle *handle) - { - struct raw1394_request req; - ieee1394handle_t ihandle = handle->mode.ieee1394; -- int retval = 0, channel; -+ int retval = 0; - - while (read(ihandle->fd, &req, sizeof(req)) < 0) { - if (errno != EINTR) return -1; -diff --git a/src/fw-iso.c b/src/fw-iso.c -index f493444..6a84662 100644 ---- a/src/fw-iso.c -+++ b/src/fw-iso.c -@@ -1,6 +1,6 @@ - /* -*- c-basic-offset: 8 -*- - * -- * raw1394-iso.c -- Emulation of the raw1394 rawiso API on the firewire stack -+ * fw-iso.c -- Emulation of the raw1394 rawiso API on the firewire stack - * - * Copyright (C) 2007 Kristian Hoegsberg - * -@@ -76,6 +76,7 @@ queue_packet(fw_handle_t handle, - if (err < 0) - return -1; - } -+ return 0; - } - - static int -@@ -84,7 +85,9 @@ queue_xmit_packets(raw1394handle_t handle, int limit) - fw_handle_t fwhandle = handle->mode.fw; - enum raw1394_iso_disposition d; - unsigned char tag, sy; -- int len, cycle, dropped; -+ unsigned int len; -+ int cycle = -1; -+ unsigned int dropped = 0; - - if (fwhandle->iso.xmit_handler == NULL) - return 0; -@@ -138,7 +141,14 @@ int fw_iso_xmit_start(raw1394handle_t handle, int start_on_cycle, - return retval; - } - -- return queue_xmit_packets(handle, fwhandle->iso.buf_packets); -+ retval = queue_xmit_packets(handle, fwhandle->iso.buf_packets); -+ -+ if (retval) -+ return -1; -+ else -+ fwhandle->iso.state = ISO_ACTIVE; -+ -+ return 0; - } - - static int -@@ -221,7 +231,12 @@ int fw_iso_recv_start(fw_handle_t handle, int start_on_cycle, - start_iso.sync = 0; - start_iso.handle = 0; - -- return ioctl(handle->iso.fd, FW_CDEV_IOC_START_ISO, &start_iso); -+ if (ioctl(handle->iso.fd, FW_CDEV_IOC_START_ISO, &start_iso)) -+ return -1; -+ else -+ handle->iso.state = ISO_ACTIVE; -+ -+ return 0; - } - - static int handle_iso_event(raw1394handle_t handle, -@@ -256,9 +271,8 @@ int fw_iso_xmit_write(raw1394handle_t handle, unsigned char *data, - unsigned char sy) - { - fw_handle_t fwhandle = handle->mode.fw; -- struct fw_cdev_queue_iso queue_iso; - struct fw_cdev_start_iso start_iso; -- struct fw_cdev_iso_packet *p; -+ int retval; - - if (len > fwhandle->iso.max_packet_size) { - errno = EINVAL; -@@ -283,10 +297,10 @@ int fw_iso_xmit_write(raw1394handle_t handle, unsigned char *data, - start_iso.cycle = fwhandle->iso.start_on_cycle; - start_iso.handle = 0; - -- len = ioctl(fwhandle->iso.fd, -+ retval = ioctl(fwhandle->iso.fd, - FW_CDEV_IOC_START_ISO, &start_iso); -- if (len < 0) -- return len; -+ if (retval < 0) -+ return retval; - } - - return 0; -@@ -443,6 +457,7 @@ iso_init(fw_handle_t handle, int type, - handle->iso.head = handle->iso.buffer; - handle->iso.tail = handle->iso.buffer; - handle->iso.first_payload = handle->iso.buffer; -+ handle->iso.state = ISO_STOPPED; - - return 0; - } -@@ -519,15 +534,20 @@ void fw_iso_stop(fw_handle_t handle) - handle->iso.first_payload = handle->iso.buffer; - handle->iso.packet_phase = 0; - handle->iso.packet_count = 0; -+ handle->iso.packet_index = 0; -+ handle->iso.state = ISO_STOPPED; - } - - void fw_iso_shutdown(fw_handle_t handle) - { - munmap(handle->iso.buffer, - handle->iso.buf_packets * handle->iso.max_packet_size); -+ if (handle->iso.state != ISO_STOPPED) -+ fw_iso_stop(handle); - close(handle->iso.fd); - free(handle->iso.packets); - handle->iso.packets = NULL; -+ handle->iso.fd = -1; - } - - int fw_read_cycle_timer(fw_handle_t handle, -@@ -537,7 +557,7 @@ int fw_read_cycle_timer(fw_handle_t handle, - int err; - struct fw_cdev_get_cycle_timer ctr = { 0 }; - -- err = ioctl(handle->iso.fd, FW_CDEV_IOC_GET_CYCLE_TIMER, &ctr); -+ err = ioctl(handle->local_fd, FW_CDEV_IOC_GET_CYCLE_TIMER, &ctr); - if (!err) { - *cycle_timer = ctr.cycle_timer; - *local_time = ctr.local_time; -diff --git a/src/fw.c b/src/fw.c -index 3c61385..03e34a7 100644 ---- a/src/fw.c -+++ b/src/fw.c -@@ -125,7 +125,7 @@ scan_devices(fw_handle_t handle) - char filename[32]; - struct fw_cdev_get_info get_info; - struct fw_cdev_event_bus_reset reset; -- int fd, err, i; -+ int fd, err, i, fname_str_sz; - struct port *ports; - - ports = handle->ports; -@@ -162,8 +162,9 @@ scan_devices(fw_handle_t handle) - continue; - - if (i < MAX_PORTS && reset.node_id == reset.local_node_id) { -- strncpy(ports[i].device_file, filename, -- sizeof ports[i].device_file); -+ fname_str_sz = sizeof(ports[i].device_file) - 1; -+ strncpy(ports[i].device_file, filename, fname_str_sz); -+ ports[i].device_file[fname_str_sz] = '\0'; - ports[i].node_count = (reset.root_node_id & 0x3f) + 1; - ports[i].card = get_info.card; - i++; -@@ -315,7 +316,7 @@ handle_inotify(raw1394handle_t handle, struct epoll_closure *ec, - struct fw_cdev_get_info info; - struct fw_cdev_event_bus_reset reset; - struct epoll_event ep; -- int i, len, fd, phy_id; -+ int i, len, fd, phy_id, fname_str_sz; - - event = (struct inotify_event *) fwhandle->buffer; - len = read(fwhandle->inotify_fd, event, BUFFER_SIZE); -@@ -365,8 +366,9 @@ handle_inotify(raw1394handle_t handle, struct epoll_closure *ec, - fwhandle->devices[i].node_id = reset.node_id; - fwhandle->devices[i].generation = reset.generation; - fwhandle->devices[i].fd = fd; -- strncpy(fwhandle->devices[i].filename, filename, -- sizeof fwhandle->devices[i].filename); -+ fname_str_sz = sizeof(fwhandle->devices[i].filename) - 1; -+ strncpy(fwhandle->devices[i].filename, filename, fname_str_sz); -+ fwhandle->devices[i].filename[fname_str_sz] = '\0'; - fwhandle->devices[i].closure.func = handle_device_event; - ep.events = EPOLLIN; - ep.data.ptr = &fwhandle->devices[i].closure; -@@ -501,8 +503,10 @@ fw_handle_t fw_new_handle_on_port(int port) - if (handle == NULL) - return NULL; - -- if (fw_set_port(handle, port) < 0) -+ if (fw_set_port(handle, port) < 0) { -+ fw_destroy_handle(handle); - return NULL; -+ } - - return handle; - } -@@ -538,15 +542,17 @@ int fw_get_port_info(fw_handle_t handle, - struct raw1394_portinfo *pinf, - int maxports) - { -- int i; -+ int i, port_name_sz; - - if (maxports >= handle->port_count) - maxports = handle->port_count; - - for (i = 0; i < maxports; i++) { - pinf[i].nodes = handle->ports[i].node_count; -+ port_name_sz = sizeof(pinf[i].name) - 1; - strncpy(pinf[i].name, handle->ports[i].device_file, -- sizeof pinf[i].name); -+ port_name_sz); -+ pinf[i].name[port_name_sz] = '\0'; - } - - return handle->port_count; -@@ -560,7 +566,7 @@ int fw_set_port(fw_handle_t handle, int port) - struct dirent *de; - char filename[32]; - DIR *dir; -- int i, fd, phy_id; -+ int i, fd, phy_id, fname_str_sz; - - if (port >= handle->port_count) { - errno = EINVAL; -@@ -606,8 +612,9 @@ int fw_set_port(fw_handle_t handle, int port) - handle->devices[i].node_id = reset.node_id; - handle->devices[i].generation = reset.generation; - handle->devices[i].fd = fd; -- strncpy(handle->devices[i].filename, filename, -- sizeof handle->devices[i].filename); -+ fname_str_sz = sizeof(handle->devices[i].filename) -1; -+ strncpy(handle->devices[i].filename, filename, fname_str_sz); -+ handle->devices[i].filename[fname_str_sz] = '\0'; - - handle->devices[i].closure.func = handle_device_event; - memset(&ep, 0, sizeof(ep)); -@@ -623,8 +630,9 @@ int fw_set_port(fw_handle_t handle, int port) - if (reset.node_id == reset.local_node_id) { - memcpy(&handle->reset, &reset, sizeof handle->reset); - handle->local_fd = fd; -- strncpy(handle->local_filename, filename, -- sizeof handle->local_filename); -+ fname_str_sz = sizeof(handle->local_filename) -1; -+ strncpy(handle->local_filename, filename, fname_str_sz); -+ handle->local_filename[fname_str_sz] = '\0'; - } - - i++; -@@ -765,10 +773,12 @@ handle_arm_request(raw1394handle_t handle, struct address_closure *ac, - } - rrb->request.generation = fwhandle->reset.generation; - rrb->request.buffer_length = in_length; -+ rrb->request.buffer = rrb->data; - memcpy(rrb->request.buffer, request->data, in_length); - - rrb->response.response_code = response.rcode; - rrb->response.buffer_length = response.length; -+ rrb->response.buffer = rrb->data + in_length; - memcpy(rrb->response.buffer, - allocation->data + offset, response.length); - -@@ -1174,14 +1184,14 @@ fw_lock(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, - quadlet_t *result) - { - quadlet_t buffer[2]; -- size_t length; -+ ssize_t length; - - length = setup_lock(extcode, data, arg, buffer); - if (length < 0) - return length; - - return send_request_sync(handle, 16 + extcode, node, addr, -- length, buffer, result); -+ (size_t) length, buffer, result); - } - - int -@@ -1190,14 +1200,14 @@ fw_lock64(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, - octlet_t *result) - { - octlet_t buffer[2]; -- size_t length; -+ ssize_t length; - - length = setup_lock64(extcode, data, arg, buffer); - if (length < 0) - return length; - - return send_request_sync(handle, 16 + extcode, node, addr, -- length, buffer, result); -+ (size_t) length, buffer, result); - } - - int -@@ -1283,100 +1293,3 @@ fw_get_config_rom(fw_handle_t handle, quadlet_t *buffer, - - return 0; - } -- --#define MAXIMUM_BANDWIDTH 4915 -- --int --fw_bandwidth_modify (raw1394handle_t handle, -- unsigned int bandwidth, -- enum raw1394_modify_mode mode) --{ -- quadlet_t buffer, compare, swap; -- nodeaddr_t addr; -- int result; -- -- if (bandwidth == 0) -- return 0; -- -- addr = CSR_REGISTER_BASE + CSR_BANDWIDTH_AVAILABLE; -- /* Read current bandwidth usage from IRM. */ -- result = raw1394_read (handle, raw1394_get_irm_id (handle), addr, -- sizeof buffer, &buffer); -- if (result < 0) -- return -1; -- -- compare = ntohl (buffer); -- switch (mode) { -- case RAW1394_MODIFY_ALLOC: -- swap = compare - bandwidth; -- if (swap < 0) -- return -1; -- break; -- -- case RAW1394_MODIFY_FREE: -- swap = compare + bandwidth; -- if (swap > MAXIMUM_BANDWIDTH) -- swap = MAXIMUM_BANDWIDTH; -- break; -- -- default: -- return -1; -- } -- -- result = raw1394_lock(handle, raw1394_get_irm_id (handle), addr, -- RAW1394_EXTCODE_COMPARE_SWAP, -- htonl(swap), htonl(compare), &buffer); -- if (result < 0 || ntohl(buffer) != compare) -- return -1; -- -- return 0; --} -- --int --fw_channel_modify (raw1394handle_t handle, -- unsigned int channel, -- enum raw1394_modify_mode mode) --{ -- quadlet_t buffer, compare, swap, bit; -- nodeaddr_t addr; -- int result; -- -- if (channel >= 64) -- return -1; -- addr = CSR_REGISTER_BASE + -- CSR_CHANNELS_AVAILABLE_HI + 4 * (channel / 32); -- /* Read currently available channels from IRM. */ -- result = raw1394_read(handle, raw1394_get_irm_id (handle), addr, -- sizeof buffer, &buffer); -- if (result < 0) -- return -1; -- -- /* IEEE numbers bits from MSB (0) to LSB (31). */ -- bit = 1 << (31 - (channel & 31)); -- compare = ntohl(buffer); -- switch (mode) { -- case RAW1394_MODIFY_ALLOC: -- if ((compare & bit) == 0) -- return -1; -- swap = buffer & ~bit; -- break; -- -- case RAW1394_MODIFY_FREE: -- if ((buffer & bit) != 0) -- return -1; -- swap = buffer | bit; -- break; -- -- default: -- return -1; -- } -- -- result = raw1394_lock (handle, raw1394_get_irm_id (handle), addr, -- RAW1394_EXTCODE_COMPARE_SWAP, -- htonl(swap), htonl(compare), &buffer); -- -- if (result < 0 || ntohl(buffer) != compare) -- return -1; -- -- return 0; --} -diff --git a/src/fw.h b/src/fw.h -index 4ee9017..56b59d9 100644 ---- a/src/fw.h -+++ b/src/fw.h -@@ -129,6 +129,7 @@ struct fw_handle { - int prebuffer; - int start_on_cycle; - enum raw1394_iso_dma_recv_mode recv_mode; -+ enum { ISO_STOPPED, ISO_ACTIVE } state; - raw1394_iso_xmit_handler_t xmit_handler; - raw1394_iso_recv_handler_t recv_handler; - unsigned char *buffer, *buffer_end, *head; -@@ -211,12 +212,6 @@ int fw_update_config_rom(fw_handle_t handle, const quadlet_t *new_rom, - int fw_get_config_rom(fw_handle_t handle, quadlet_t *buffer, - size_t buffersize, size_t *rom_size, - unsigned char *rom_version); --int fw_bandwidth_modify (raw1394handle_t handle, -- unsigned int bandwidth, -- enum raw1394_modify_mode mode); --int fw_channel_modify (raw1394handle_t handle, -- unsigned int channel, -- enum raw1394_modify_mode mode); - - int fw_iso_xmit_start(raw1394handle_t handle, int start_on_cycle, - int prebuffer_packets); -diff --git a/src/main.c b/src/main.c -index 55b4fbc..d83256e 100644 ---- a/src/main.c -+++ b/src/main.c -@@ -253,9 +253,7 @@ void *raw1394_get_userdata(struct raw1394_handle *handle) - int ieee1394_get_port_info(struct ieee1394_handle *handle, - struct raw1394_portinfo *pinf, int maxports) - { -- int num; - struct raw1394_request req; -- struct raw1394_khost_list *khl; - - CLEAR_REQ(&req); - req.type = RAW1394_REQ_LIST_CARDS; -diff --git a/src/raw1394.h b/src/raw1394.h -index c489c20..7bfeb05 100644 ---- a/src/raw1394.h -+++ b/src/raw1394.h -@@ -1203,7 +1203,7 @@ raw1394_bandwidth_modify (raw1394handle_t handle, unsigned int bandwidth, - enum raw1394_modify_mode mode); - - /** -- * raw1394_bandwidth_modify - allocate or release isochronous channel -+ * raw1394_channel_modify - allocate or release isochronous channel - * @handle: a libraw1394 handle - * @channel: isochronous channel - * @mode: whether to allocate or free -diff --git a/tools/testlibraw.c b/tools/testlibraw.c -index efd87ad..82b8ee5 100644 ---- a/tools/testlibraw.c -+++ b/tools/testlibraw.c -@@ -14,6 +14,7 @@ - #include - #include - #include -+#include - #include - - #include "../src/raw1394.h" -@@ -53,8 +54,8 @@ static const unsigned char fcp_data[] = - int my_fcp_handler(raw1394handle_t handle, nodeid_t nodeid, int response, - size_t length, unsigned char *data) - { -- printf("got fcp %s from node %d of %d bytes:", -- (response ? "response" : "command"), nodeid & 0x3f, length); -+ printf(" got fcp %s from node %d of %d bytes:", -+ (response ? "response" : "command"), nodeid & 0x3f, length); - - if (memcmp(fcp_data, data, sizeof fcp_data) != 0) - printf("ERROR: fcp payload not correct\n"); -@@ -73,7 +74,7 @@ int my_fcp_handler(raw1394handle_t handle, nodeid_t nodeid, int response, - static void - test_fcp(raw1394handle_t handle) - { -- printf("\ntesting FCP monitoring on local node\n"); -+ printf("\n - testing FCP monitoring on local node\n"); - raw1394_set_fcp_handler(handle, my_fcp_handler); - raw1394_start_fcp_listen(handle); - raw1394_write(handle, raw1394_get_local_id(handle), -@@ -95,142 +96,188 @@ read_topology_map(raw1394handle_t handle) - - retval = raw1394_read(handle, local_id, - CSR_REGISTER_BASE + CSR_TOPOLOGY_MAP, 12, &map[0]); -- if (retval < 0) -- perror("topology map: raw1394_read failed with error"); -- -+ if (retval < 0) { -+ perror("\n - topology map: raw1394_read failed with error"); -+ return; -+ } -+ - self_id_count = ntohl(map[2]) & 0xffff; - node_count = ntohl(map[2]) >> 16; - retval = raw1394_read(handle, local_id, - CSR_REGISTER_BASE + CSR_TOPOLOGY_MAP + 12, - self_id_count * sizeof map[0], &map[3]); -- if (retval < 0) -- perror("topology map: raw1394_read failed with error"); -+ if (retval < 0) { -+ perror("\n - topology map: raw1394_read failed with error"); -+ return; -+ } - -- printf("topology map: %d nodes, %d self ids, generation %d\n", -+ printf("\n - topology map: %d nodes, %d self ids, generation %d\n", - node_count, self_id_count, ntohl(map[1])); - for (i = 0; i < self_id_count; i++) -- printf(" 0x%08x\n", ntohl(map[3 + i])); -+ printf(" 0x%08x\n", ntohl(map[3 + i])); - } - --int main(int argc, char **argv) -+static void -+test_config_rom(raw1394handle_t handle) - { -- raw1394handle_t handle; -- int i, numcards; -- struct raw1394_portinfo pinf[16]; -- -- tag_handler_t std_handler; -- int retval; -- -- struct pollfd pfd; -- quadlet_t rom[0x100]; -- size_t rom_size; -- unsigned char rom_version; -- -- handle = raw1394_new_handle(); -- -- if (!handle) { -- if (!errno) { -- printf(not_compatible); -- } else { -- perror("couldn't get handle"); -- printf(not_loaded); -- } -- exit(1); -- } -- -- printf("successfully got handle\n"); -- printf("current generation number: %d\n", raw1394_get_generation(handle)); -- -- numcards = raw1394_get_port_info(handle, pinf, 16); -- if (numcards < 0) { -- perror("couldn't get card info"); -- exit(1); -- } else { -- printf("%d card(s) found\n", numcards); -- } -- -- if (!numcards) { -- exit(0); -- } -- -- for (i = 0; i < numcards; i++) { -- printf(" nodes on bus: %2d, card name: %s\n", pinf[i].nodes, -- pinf[i].name); -- } -- -- if (raw1394_set_port(handle, 0) < 0) { -- perror("couldn't set port"); -- exit(1); -- } -+ quadlet_t rom[0x100] = { 0, }; -+ size_t rom_size; -+ unsigned char rom_version; -+ int i, retval; -+ -+ printf("\n - testing config rom\n"); -+ retval = raw1394_get_config_rom(handle, rom, 0x100, -+ &rom_size, &rom_version); -+ printf(" get_config_rom returned %d, romsize %d, rom_version %d\n", -+ retval, rom_size, rom_version); -+ printf(" here are the first 10 quadlets:\n"); -+ for (i = 0; i < 10; i++) -+ printf(" 0x%08x\n", i, rom[i]); -+ -+ retval = raw1394_update_config_rom(handle, rom, rom_size, rom_version); -+ printf(" update_config_rom returned %d\n", retval); -+} - -- printf("using first card found: %d nodes on bus, local ID is %d, IRM is %d\n", -- raw1394_get_nodecount(handle), -- raw1394_get_local_id(handle) & 0x3f, -- raw1394_get_irm_id(handle) & 0x3f); -- -- printf("\ndoing transactions with custom tag handler\n"); -- std_handler = raw1394_set_tag_handler(handle, my_tag_handler); -- for (i = 0; i < pinf[0].nodes; i++) { -- printf("trying to send read request to node %d... ", i); -- fflush(stdout); -- buffer = 0; -- -- if (raw1394_start_read(handle, 0xffc0 | i, TESTADDR, 4, -- &buffer, 0) < 0) { -- perror("failed"); -- continue; -- } -- raw1394_loop_iterate(handle); -- } -+static void -+read_cycle_timer(raw1394handle_t handle) -+{ -+ u_int32_t ct; -+ u_int64_t local_time; -+ time_t seconds; -+ int retval; -+ -+ retval = raw1394_read_cycle_timer(handle, &ct, &local_time); -+ if (retval < 0) { -+ perror("\n - raw1394_read_cycle_timer failed with error"); -+ return; -+ } -+ -+ printf("\n - cycle timer: %d seconds, %d cycles, %d sub-cycles\n", -+ ct >> 25, (ct >> 12) & 0x1fff, ct & 0xfff); -+ seconds = local_time / 1000000; -+ printf(" local time: %lld us = %s", -+ (unsigned long long)local_time, ctime(&seconds)); -+} - -- printf("\nusing standard tag handler and synchronous calls\n"); -- raw1394_set_tag_handler(handle, std_handler); -- for (i = 0; i < pinf[0].nodes; i++) { -- printf("trying to read from node %d... ", i); -- fflush(stdout); -- buffer = 0; -- -- retval = raw1394_read(handle, 0xffc0 | i, TESTADDR, 4, &buffer); -- if (retval < 0) { -- perror("failed with error"); -- } else { -- printf("completed with value 0x%08x\n", buffer); -- } -- } -+int test_card(int card) -+{ -+ raw1394handle_t handle; -+ struct raw1394_portinfo pinf; -+ tag_handler_t std_handler; -+ struct pollfd pfd; -+ int i, n, numcards, retval; -+ -+ handle = raw1394_new_handle(); -+ -+ if (!handle) { -+ if (!errno) { -+ printf(not_compatible); -+ } else { -+ perror("couldn't get handle"); -+ printf(not_loaded); -+ } -+ return -1; -+ } -+ -+ if (card == 0) { -+ printf("successfully got handle\n"); -+ printf("current generation number: %d\n", -+ raw1394_get_generation(handle)); -+ } -+ -+ numcards = raw1394_get_port_info(handle, &pinf, 1); -+ if (numcards < card) -+ perror("couldn't get card info"); -+ else if (card == 0) -+ printf("%d card%s found\n", -+ numcards, numcards == 1 ? "" : "s"); -+ -+ if (numcards <= card) -+ goto out; -+ -+ printf("\ncard %d, name: %s\n", card, pinf.name); -+ -+ if (raw1394_set_port(handle, card) < 0) { -+ perror("couldn't set port"); -+ goto out; -+ } -+ -+ n = raw1394_get_nodecount(handle); -+ printf("%d nodes on bus, local ID is %d, IRM is %d\n", -+ n, -+ raw1394_get_local_id(handle) & 0x3f, -+ raw1394_get_irm_id(handle) & 0x3f); -+ -+ if (n > 0) { -+ printf("\n - doing transactions with custom tag handler\n"); -+ std_handler = raw1394_set_tag_handler(handle, my_tag_handler); -+ } -+ for (i = 0; i < n; i++) { -+ printf(" read from node %d... ", i); -+ fflush(stdout); -+ buffer = 0; -+ -+ if (raw1394_start_read(handle, 0xffc0 | i, TESTADDR, 4, -+ &buffer, 0) < 0) { -+ perror("failed"); -+ continue; -+ } -+ if (raw1394_loop_iterate(handle)) -+ perror("failed"); -+ } -+ -+ if (n > 0) { -+ printf("\n - using standard tag handler and synchronous calls\n"); -+ raw1394_set_tag_handler(handle, std_handler); -+ } -+ for (i = 0; i < n; i++) { -+ printf(" read from node %d... ", i); -+ fflush(stdout); -+ buffer = 0; -+ -+ retval = raw1394_read(handle, 0xffc0 | i, TESTADDR, 4, &buffer); -+ if (retval < 0) -+ perror("failed with error"); -+ else -+ printf("completed with value 0x%08x\n", buffer); -+ } - - test_fcp(handle); - read_topology_map(handle); -+ test_config_rom(handle); -+ read_cycle_timer(handle); - -- printf("testing config rom stuff\n"); -- memset(rom, 0, sizeof(rom)); -- retval=raw1394_get_config_rom(handle, rom, 0x100, &rom_size, &rom_version); -- printf("get_config_rom returned %d, romsize %d, rom_version %d\n",retval,rom_size,rom_version); -- printf("here are the first 10 quadlets:\n"); -- for (i = 0; i < 10; i++) -- printf("%d. quadlet: 0x%08x\n",i,rom[i]); -- -- /* some manipulation */ --/* printf("incrementing 2nd quadlet\n"); -- rom[0x02/4]++; --*/ -- retval=raw1394_update_config_rom(handle, rom, rom_size, rom_version); -- printf("update_config_rom returned %d\n",retval); -- -- printf("\nposting 0xdeadbeef as an echo request\n"); -+ printf("\n - posting 0xdeadbeef as an echo request\n"); - raw1394_echo_request(handle, 0xdeadbeef); - -- printf("polling for leftover messages\n"); -- pfd.fd = raw1394_get_fd(handle); -- pfd.events = POLLIN; -- pfd.revents = 0; -- while (1) { -- retval = poll(&pfd, 1, 10); -- if (retval < 1) break; -+ printf(" polling for leftover messages\n"); -+ pfd.fd = raw1394_get_fd(handle); -+ pfd.events = POLLIN; -+ pfd.revents = 0; -+ while (1) { -+ retval = poll(&pfd, 1, 10); -+ if (retval < 1) -+ break; - retval = raw1394_loop_iterate(handle); - if (retval != 0) -- printf("raw1394_loop_iterate() returned 0x%08x\n", retval); -- } -+ printf(" raw1394_loop_iterate() returned 0x%08x\n", -+ retval); -+ } -+ -+ if (retval < 0) -+ perror("poll failed"); -+out: -+ raw1394_destroy_handle(handle); -+ return numcards; -+} -+ -+int main(int argc, char **argv) -+{ -+ int card = 0, numcards; -+ -+ do -+ numcards = test_card(card); -+ while (++card < numcards); - -- if (retval < 0) perror("poll failed"); -- exit(0); -+ return numcards < 0; - } diff --git a/libraw1394-use-errno-ENOSYS-in-unimplemented-functions.patch b/libraw1394-use-errno-ENOSYS-in-unimplemented-functions.patch deleted file mode 100644 index 741b78e..0000000 --- a/libraw1394-use-errno-ENOSYS-in-unimplemented-functions.patch +++ /dev/null @@ -1,59 +0,0 @@ -Date: Sun, 11 Jan 2009 22:39:17 +0100 (CET) -From: Stefan Richter -Subject: [PATCH libraw1394 fix] Set errno = ENOSYS in unimplemented functions -To: Dan Dennedy -Cc: linux1394-devel@lists.sourceforge.net - -Most of them do this already, only a few missed it. - -Signed-off-by: Stefan Richter ---- - src/fw.c | 5 +++++ - 1 files changed, 5 insertions(+), 0 deletions(-) - -diff --git a/src/fw.c b/src/fw.c -index 3f5d806..ba3a807 100644 ---- a/src/fw.c -+++ b/src/fw.c -@@ -1104,6 +1104,7 @@ fw_start_async_stream(fw_handle_t handle, unsigned int channel, - unsigned long rawtag) - { - /* FIXME: implement this? */ -+ errno = ENOSYS; - return -1; - } - -@@ -1115,6 +1116,7 @@ fw_start_async_send(fw_handle_t handle, - quadlet_t *data, unsigned long rawtag) - { - /* FIXME: implement this? */ -+ errno = ENOSYS; - return -1; - } - -@@ -1233,6 +1235,7 @@ fw_async_stream(fw_handle_t handle, unsigned int channel, - size_t length, quadlet_t *data) - { - /* FIXME: implement this? */ -+ errno = ENOSYS; - return -1; - } - -@@ -1243,6 +1246,7 @@ fw_async_send(fw_handle_t handle, - quadlet_t *data) - { - /* FIXME: implement this? */ -+ errno = ENOSYS; - return -1; - } - -@@ -1284,6 +1288,7 @@ int - fw_update_config_rom(fw_handle_t handle, const quadlet_t *new_rom, - size_t size, unsigned char rom_version) - { -+ errno = ENOSYS; - return -1; - } - --- -1.6.0.6 diff --git a/libraw1394-work-without-write-on-local-node-dev.patch b/libraw1394-work-without-write-on-local-node-dev.patch deleted file mode 100644 index f0985c5..0000000 --- a/libraw1394-work-without-write-on-local-node-dev.patch +++ /dev/null @@ -1,245 +0,0 @@ -Date: Sat, 10 Jan 2009 21:14:50 +0100 (CET) -From: Stefan Richter -Subject: Re: [PATCH libraw1394] Work without permission to access local node's - /dev/fw* -To: Dan Dennedy -Cc: linux1394-devel@lists.sourceforge.net, - dcm@acm.org - -On 10 Jan, Stefan Richter wrote: -> --- a/src/fw.c -> +++ b/src/fw.c -> @@ -125,17 +125,19 @@ scan_devices(fw_handle_t handle) -> char filename[32]; -> struct fw_cdev_get_info get_info; -> struct fw_cdev_event_bus_reset reset; -> - int fd, err, i, fname_str_sz; -> + int fd, err, i, j, fname_str_sz; -> struct port *ports; -> -> ports = handle->ports; -> memset(ports, 0, sizeof handle->ports); -> + for (i = 0; i < MAX_PORTS; i++) -> + ports[i].card = -1; -> + - -The memset is not necessary. - - -From: Stefan Richter -Subject: [PATCH] Work without permission to access local node's /dev/fw* - -Fix for juju backend: - -libraw1394 required write permission to the character device file of -the local node(s) in order to enumerate cards and for a number of -other operations. This forced users to either run applications like -dvgrab and kino with elevated privileges, or to configure write -permission for all /dev/fw* or at least for local nodes' /dev/fw*. - -We now use the first accessible file which was found for each card -for as many tasks as possible, instead of the local node's file. - -This allows distributors or admins to implement stricter access -rights (default off, e.g. only on for AV/C and IIDC devices) -without sacrificing functionality of said class of applications. -Access to the local node is now only required by low-level tools -like gscanbus. - -Signed-off-by: Stefan Richter ---- - src/fw-iso.c | 4 ++-- - src/fw.c | 50 +++++++++++++++++++++++++++++++++----------------- - src/fw.h | 6 +++--- - 3 files changed, 38 insertions(+), 22 deletions(-) - -diff --git a/src/fw-iso.c b/src/fw-iso.c -index 6a84662..a87259b 100644 ---- a/src/fw-iso.c -+++ b/src/fw-iso.c -@@ -407,7 +407,7 @@ iso_init(fw_handle_t handle, int type, - if (handle->iso.packets == NULL) - return -1; - -- handle->iso.fd = open(handle->local_filename, O_RDWR); -+ handle->iso.fd = open(handle->iso.filename, O_RDWR); - if (handle->iso.fd < 0) { - free(handle->iso.packets); - handle->iso.packets = NULL; -@@ -557,7 +557,7 @@ int fw_read_cycle_timer(fw_handle_t handle, - int err; - struct fw_cdev_get_cycle_timer ctr = { 0 }; - -- err = ioctl(handle->local_fd, FW_CDEV_IOC_GET_CYCLE_TIMER, &ctr); -+ err = ioctl(handle->ioctl_fd, FW_CDEV_IOC_GET_CYCLE_TIMER, &ctr); - if (!err) { - *cycle_timer = ctr.cycle_timer; - *local_time = ctr.local_time; -diff --git a/src/fw.c b/src/fw.c -index e211b60..3f5d806 100644 ---- a/src/fw.c -+++ b/src/fw.c -@@ -125,17 +125,18 @@ scan_devices(fw_handle_t handle) - char filename[32]; - struct fw_cdev_get_info get_info; - struct fw_cdev_event_bus_reset reset; -- int fd, err, i, fname_str_sz; -+ int fd, err, i, j, fname_str_sz; - struct port *ports; - - ports = handle->ports; -- memset(ports, 0, sizeof handle->ports); -+ for (i = 0; i < MAX_PORTS; i++) -+ ports[i].card = -1; -+ - dir = opendir(FW_DEVICE_DIR); - if (dir == NULL) - return -1; - -- i = 0; -- while (1) { -+ for (i = 0; i < MAX_PORTS; ) { - de = readdir(dir); - if (de == NULL) - break; -@@ -161,7 +162,10 @@ scan_devices(fw_handle_t handle) - if (err < 0) - continue; - -- if (i < MAX_PORTS && reset.node_id == reset.local_node_id) { -+ for (j = 0; j < i; j++) -+ if (ports[j].card == get_info.card) -+ break; -+ if (j == i) { - fname_str_sz = sizeof(ports[i].device_file) - 1; - strncpy(ports[i].device_file, filename, fname_str_sz); - ports[i].device_file[fname_str_sz] = '\0'; -@@ -626,20 +630,27 @@ int fw_set_port(fw_handle_t handle, int port) - return -1; - } - -- handle->generation = reset.generation; -- if (reset.node_id == reset.local_node_id) { -+ if (handle->iso.filename == NULL) { - memcpy(&handle->reset, &reset, sizeof handle->reset); -- handle->local_fd = fd; -- fname_str_sz = sizeof(handle->local_filename) -1; -- strncpy(handle->local_filename, filename, fname_str_sz); -- handle->local_filename[fname_str_sz] = '\0'; -+ handle->iso.filename = handle->devices[i].filename; -+ handle->ioctl_fd = fd; - } - -+ if (reset.node_id == reset.local_node_id) -+ handle->local_device = &handle->devices[i]; -+ -+ handle->generation = reset.generation; -+ - i++; - } - - closedir(dir); - -+ if (i == 0) { -+ errno = ENODEV; -+ return -1; -+ } -+ - return 0; - } - -@@ -656,7 +667,7 @@ int fw_reset_bus_new(fw_handle_t handle, int type) - break; - } - -- return ioctl(handle->local_fd, -+ return ioctl(handle->ioctl_fd, - FW_CDEV_IOC_INITIATE_BUS_RESET, &initiate); - } - -@@ -817,7 +828,7 @@ fw_arm_register(fw_handle_t handle, nodeaddr_t start, - request.length = length; - request.closure = ptr_to_u64(&allocation->closure); - -- retval = ioctl(handle->local_fd, FW_CDEV_IOC_ALLOCATE, &request); -+ retval = ioctl(handle->ioctl_fd, FW_CDEV_IOC_ALLOCATE, &request); - if (retval < 0) { - free(allocation); - return -1; -@@ -863,7 +874,7 @@ fw_arm_unregister(fw_handle_t handle, nodeaddr_t start) - request.handle = allocation->handle; - free(allocation); - -- return ioctl(handle->local_fd, FW_CDEV_IOC_DEALLOCATE, &request); -+ return ioctl(handle->ioctl_fd, FW_CDEV_IOC_DEALLOCATE, &request); - } - - int -@@ -1251,7 +1262,7 @@ fw_start_fcp_listen(fw_handle_t handle) - request.offset = CSR_REGISTER_BASE + CSR_FCP_COMMAND; - request.length = CSR_FCP_END - CSR_FCP_COMMAND; - request.closure = ptr_to_u64(closure); -- if (ioctl(handle->local_fd, FW_CDEV_IOC_ALLOCATE, &request) < 0) -+ if (ioctl(handle->ioctl_fd, FW_CDEV_IOC_ALLOCATE, &request) < 0) - return -1; - - handle->fcp_allocation_handle = request.handle; -@@ -1266,7 +1277,7 @@ fw_stop_fcp_listen(fw_handle_t handle) - - request.handle = handle->fcp_allocation_handle; - -- return ioctl(handle->local_fd, FW_CDEV_IOC_DEALLOCATE, &request); -+ return ioctl(handle->ioctl_fd, FW_CDEV_IOC_DEALLOCATE, &request); - } - - int -@@ -1284,13 +1295,18 @@ fw_get_config_rom(fw_handle_t handle, quadlet_t *buffer, - struct fw_cdev_get_info get_info; - int err; - -+ if (handle->local_device == NULL) { -+ errno = EPERM; -+ return -1; -+ } -+ - memset(&get_info, 0, sizeof(get_info)); - get_info.version = FW_CDEV_VERSION; - get_info.rom = ptr_to_u64(buffer); - get_info.rom_length = buffersize; - get_info.bus_reset = 0; - -- err = ioctl(handle->local_fd, FW_CDEV_IOC_GET_INFO, &get_info); -+ err = ioctl(handle->local_device->fd, FW_CDEV_IOC_GET_INFO, &get_info); - if (err) - return err; - -diff --git a/src/fw.h b/src/fw.h -index 56b59d9..a5e3772 100644 ---- a/src/fw.h -+++ b/src/fw.h -@@ -101,6 +101,7 @@ struct fw_handle { - __u32 fcp_allocation_handle; - struct allocation *allocations; - -+ int ioctl_fd; - int epoll_fd; - int inotify_fd; - int inotify_watch; -@@ -110,13 +111,12 @@ struct fw_handle { - struct epoll_closure inotify_closure; - - struct device devices[MAX_DEVICES]; -+ struct device *local_device; - int nodes[MAX_DEVICES]; -- int local_fd; -- char local_filename[FILENAME_SIZE]; -- - struct fw_cdev_event_bus_reset reset; - - struct { -+ char *filename; - struct epoll_closure closure; - int fd; - int type; --- -1.6.0.6 diff --git a/libraw1394.spec b/libraw1394.spec index 29dd0ea..99d9c7a 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,13 +1,10 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 -Version: 2.0.0 -Release: 6%{?dist} +Version: 2.0.1 +Release: 1%{?dist} License: LGPLv2+ Group: System Environment/Libraries Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz -Patch0: libraw1394-2.0.0-git-update.patch -Patch1: libraw1394-use-errno-ENOSYS-in-unimplemented-functions.patch -Patch2: libraw1394-work-without-write-on-local-node-dev.patch URL: http://www.linux1394.org/ ExcludeArch: s390 s390x BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) @@ -30,9 +27,6 @@ Development libraries needed to build applications against libraw1394. %prep %setup -q -%patch0 -p1 -%patch1 -p1 -%patch2 -p1 %build %configure --disable-static @@ -71,6 +65,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Thu Jan 15 2009 Jarod Wilson - 2.0.1-1 +- Update to libraw1394 v2.0.1 release + * Tue Jan 13 2009 Jarod Wilson - 2.0.0-6 - Set errno = ENOSYS for all unimplemented functions - Make dvgrab and friends work w/o requiring r/w on the local fw node (#441073) diff --git a/sources b/sources index 8f7dc98..8178728 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -f037629cc02509d4f24f6170bd656694 libraw1394-2.0.0.tar.gz +c2c2ead417f0cb4e65bb3513325e73a9 libraw1394-2.0.1.tar.gz From 778c475ef41cc88f481f003273231a480a7b79e6 Mon Sep 17 00:00:00 2001 From: Jesse Keating Date: Wed, 25 Feb 2009 17:42:11 +0000 Subject: [PATCH 058/100] - Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild --- libraw1394.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index 99d9c7a..142d877 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 2.0.1 -Release: 1%{?dist} +Release: 2%{?dist} License: LGPLv2+ Group: System Environment/Libraries Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz @@ -65,6 +65,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Wed Feb 25 2009 Fedora Release Engineering - 2.0.1-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild + * Thu Jan 15 2009 Jarod Wilson - 2.0.1-1 - Update to libraw1394 v2.0.1 release From 1f02ae34aeae6ac30a97f8b3c0c46bea7d03f1fc Mon Sep 17 00:00:00 2001 From: Jesse Keating Date: Sat, 25 Jul 2009 08:31:36 +0000 Subject: [PATCH 059/100] - Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild --- libraw1394.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index 142d877..c7615dd 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 2.0.1 -Release: 2%{?dist} +Release: 3%{?dist} License: LGPLv2+ Group: System Environment/Libraries Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz @@ -65,6 +65,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Sat Jul 25 2009 Fedora Release Engineering - 2.0.1-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild + * Wed Feb 25 2009 Fedora Release Engineering - 2.0.1-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild From e7775fda3b1fd72e7bee64d5001a887b37f65b7a Mon Sep 17 00:00:00 2001 From: Jarod Wilson Date: Thu, 17 Sep 2009 19:07:25 +0000 Subject: [PATCH 060/100] - Update to libraw1394 v2.0.4 release - Point to new download location and project page --- .cvsignore | 1 + libraw1394.spec | 12 ++++++++---- sources | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.cvsignore b/.cvsignore index 1059d3a..499fdc7 100644 --- a/.cvsignore +++ b/.cvsignore @@ -5,3 +5,4 @@ libraw1394-1.3.0.tar.gz libraw1394-2.0.0-20080430_git.tar.bz2 libraw1394-2.0.0.tar.gz libraw1394-2.0.1.tar.gz +libraw1394-2.0.4.tar.bz2 diff --git a/libraw1394.spec b/libraw1394.spec index c7615dd..a06cb28 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,11 +1,11 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 -Version: 2.0.1 -Release: 3%{?dist} +Version: 2.0.4 +Release: 1%{?dist} License: LGPLv2+ Group: System Environment/Libraries -Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz -URL: http://www.linux1394.org/ +Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.bz2 +URL: http://www.dennedy.org/libraw1394/ ExcludeArch: s390 s390x BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: autoconf automake libtool kernel-headers @@ -65,6 +65,10 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Thu Sep 17 2009 Jarod Wilson - 2.0.4-1 +- Update to libraw1394 v2.0.4 release +- Point to new download location and project page + * Sat Jul 25 2009 Fedora Release Engineering - 2.0.1-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild diff --git a/sources b/sources index 8178728..8035f79 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -c2c2ead417f0cb4e65bb3513325e73a9 libraw1394-2.0.1.tar.gz +aa5944d2a98cb86e395f0b9bd2b6224a libraw1394-2.0.4.tar.bz2 From 582049d1c6780dd8f25f2e857d5625d67e8551da Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Wed, 25 Nov 2009 23:51:15 +0000 Subject: [PATCH 061/100] Fix typo that causes a failure to update the common directory. (releng #2781) --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index ccec37c..2d0af1d 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,10 @@ # Makefile for source rpm: libraw1394 -# $Id: Makefile,v 1.1 2004/09/09 07:38:34 cvsdist Exp $ +# $Id: Makefile,v 1.2 2007/10/15 19:04:03 notting Exp $ NAME := libraw1394 SPECFILE = $(firstword $(wildcard *.spec)) define find-makefile-common -for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done +for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$d/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done endef MAKEFILE_COMMON := $(shell $(find-makefile-common)) From 8e7a77a0fec09fc19f29ab349a092ec5d56c24a5 Mon Sep 17 00:00:00 2001 From: Jay Fenlason Date: Thu, 7 Jan 2010 19:00:28 +0000 Subject: [PATCH 062/100] New upstream version --- libraw1394.spec | 7 +++++-- sources | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/libraw1394.spec b/libraw1394.spec index a06cb28..0b163cd 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,10 +1,10 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 -Version: 2.0.4 +Version: 2.0.5 Release: 1%{?dist} License: LGPLv2+ Group: System Environment/Libraries -Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.bz2 +Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.gz URL: http://www.dennedy.org/libraw1394/ ExcludeArch: s390 s390x BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) @@ -65,6 +65,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Thu Jan 7 2010 Jay Fenlason 2.0.5-1 +- New upstream version + * Thu Sep 17 2009 Jarod Wilson - 2.0.4-1 - Update to libraw1394 v2.0.4 release - Point to new download location and project page diff --git a/sources b/sources index 8035f79..fd25d58 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -aa5944d2a98cb86e395f0b9bd2b6224a libraw1394-2.0.4.tar.bz2 +1db64231c78540c32859b591cb8b40cf libraw1394-2.0.5.tar.gz From 1ba11da33e64d480186f6a07ecc1f4158d671d83 Mon Sep 17 00:00:00 2001 From: Jarod Wilson Date: Mon, 19 Apr 2010 17:51:34 +0000 Subject: [PATCH 063/100] - Fix overlooked device HUP using firewire driver stack --- libraw1394-fix-missed-hup-signal.patch | 36 ++++++++++++++++++++++++++ libraw1394.spec | 7 ++++- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 libraw1394-fix-missed-hup-signal.patch diff --git a/libraw1394-fix-missed-hup-signal.patch b/libraw1394-fix-missed-hup-signal.patch new file mode 100644 index 0000000..ab63f8e --- /dev/null +++ b/libraw1394-fix-missed-hup-signal.patch @@ -0,0 +1,36 @@ +From b15039ceb814ee4c685deec554f342480391b775 Mon Sep 17 00:00:00 2001 +From: Peter Hurley +Date: Fri, 16 Apr 2010 14:15:40 -0400 +Subject: [PATCH] Fix for overlooked device HUP with 'firewire' stack + +When EPOLLHUP event is received in fw_loop_iterate(), it is or'd +with EPOLLERR. The EPOLLHUP event was then overlooked in +handle_device_event() with unpredictable-but-generally bad results. + +This problem has been rediscovered several times. +http://thread.gmane.org/gmane.linux.kernel.firewire.devel/13330 +http://thread.gmane.org/gmane.linux.kernel.firewire.devel/13779 + +Reported-by: B.J. Buchalter +Reported-by: Michael Thireos +Signed-off-by: Stefan Richter +--- + src/fw.c | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/src/fw.c b/src/fw.c +index 7277253..d525ac9 100644 +--- a/src/fw.c ++++ b/src/fw.c +@@ -262,7 +262,7 @@ handle_device_event(raw1394handle_t handle, + int i; + + i = device - fwhandle->devices; +- if (events == EPOLLHUP) ++ if (events & EPOLLHUP) + return handle_lost_device(fwhandle, i); + + len = read(fwhandle->devices[i].fd, +-- +1.7.0.5 + diff --git a/libraw1394.spec b/libraw1394.spec index 0b163cd..4cf9263 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,11 +1,12 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 2.0.5 -Release: 1%{?dist} +Release: 2%{?dist} License: LGPLv2+ Group: System Environment/Libraries Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.gz URL: http://www.dennedy.org/libraw1394/ +Patch: libraw1394-fix-missed-hup-signal.patch ExcludeArch: s390 s390x BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: autoconf automake libtool kernel-headers @@ -27,6 +28,7 @@ Development libraries needed to build applications against libraw1394. %prep %setup -q +%patch -p1 %build %configure --disable-static @@ -65,6 +67,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Mon Apr 19 2010 Jarod Wilson 2.0.5-2 +- Fix overlooked device HUP using firewire driver stack + * Thu Jan 7 2010 Jay Fenlason 2.0.5-1 - New upstream version From d30491da83f82981fa7e7377652eeff24965e477 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Wed, 28 Jul 2010 21:31:30 +0000 Subject: [PATCH 064/100] dist-git conversion --- .cvsignore => .gitignore | 0 Makefile | 21 --------------------- 2 files changed, 21 deletions(-) rename .cvsignore => .gitignore (100%) delete mode 100644 Makefile diff --git a/.cvsignore b/.gitignore similarity index 100% rename from .cvsignore rename to .gitignore diff --git a/Makefile b/Makefile deleted file mode 100644 index 2d0af1d..0000000 --- a/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# Makefile for source rpm: libraw1394 -# $Id: Makefile,v 1.2 2007/10/15 19:04:03 notting Exp $ -NAME := libraw1394 -SPECFILE = $(firstword $(wildcard *.spec)) - -define find-makefile-common -for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$d/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done -endef - -MAKEFILE_COMMON := $(shell $(find-makefile-common)) - -ifeq ($(MAKEFILE_COMMON),) -# attempt a checkout -define checkout-makefile-common -test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2 -endef - -MAKEFILE_COMMON := $(shell $(checkout-makefile-common)) -endif - -include $(MAKEFILE_COMMON) From e57c9170bb19b47df7724857d69957a3189f577d Mon Sep 17 00:00:00 2001 From: Jay Fenlason Date: Mon, 13 Dec 2010 16:26:40 -0500 Subject: [PATCH 065/100] Upgrade to 2.0.6 --- .gitignore | 1 + libraw1394-fix-missed-hup-signal.patch | 36 -------------------------- libraw1394.spec | 11 ++++---- sources | 2 +- 4 files changed, 8 insertions(+), 42 deletions(-) delete mode 100644 libraw1394-fix-missed-hup-signal.patch diff --git a/.gitignore b/.gitignore index 499fdc7..a71f00a 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ libraw1394-2.0.0-20080430_git.tar.bz2 libraw1394-2.0.0.tar.gz libraw1394-2.0.1.tar.gz libraw1394-2.0.4.tar.bz2 +/libraw1394-2.0.6.tar.bz2 diff --git a/libraw1394-fix-missed-hup-signal.patch b/libraw1394-fix-missed-hup-signal.patch deleted file mode 100644 index ab63f8e..0000000 --- a/libraw1394-fix-missed-hup-signal.patch +++ /dev/null @@ -1,36 +0,0 @@ -From b15039ceb814ee4c685deec554f342480391b775 Mon Sep 17 00:00:00 2001 -From: Peter Hurley -Date: Fri, 16 Apr 2010 14:15:40 -0400 -Subject: [PATCH] Fix for overlooked device HUP with 'firewire' stack - -When EPOLLHUP event is received in fw_loop_iterate(), it is or'd -with EPOLLERR. The EPOLLHUP event was then overlooked in -handle_device_event() with unpredictable-but-generally bad results. - -This problem has been rediscovered several times. -http://thread.gmane.org/gmane.linux.kernel.firewire.devel/13330 -http://thread.gmane.org/gmane.linux.kernel.firewire.devel/13779 - -Reported-by: B.J. Buchalter -Reported-by: Michael Thireos -Signed-off-by: Stefan Richter ---- - src/fw.c | 2 +- - 1 files changed, 1 insertions(+), 1 deletions(-) - -diff --git a/src/fw.c b/src/fw.c -index 7277253..d525ac9 100644 ---- a/src/fw.c -+++ b/src/fw.c -@@ -262,7 +262,7 @@ handle_device_event(raw1394handle_t handle, - int i; - - i = device - fwhandle->devices; -- if (events == EPOLLHUP) -+ if (events & EPOLLHUP) - return handle_lost_device(fwhandle, i); - - len = read(fwhandle->devices[i].fd, --- -1.7.0.5 - diff --git a/libraw1394.spec b/libraw1394.spec index 4cf9263..be822a4 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,12 +1,11 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 -Version: 2.0.5 -Release: 2%{?dist} +Version: 2.0.6 +Release: 1%{?dist} License: LGPLv2+ Group: System Environment/Libraries -Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.gz +Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.bz2 URL: http://www.dennedy.org/libraw1394/ -Patch: libraw1394-fix-missed-hup-signal.patch ExcludeArch: s390 s390x BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: autoconf automake libtool kernel-headers @@ -28,7 +27,6 @@ Development libraries needed to build applications against libraw1394. %prep %setup -q -%patch -p1 %build %configure --disable-static @@ -67,6 +65,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Mon Dec 13 2010 Jay Fenlason 2.0.6-1 +- Upgrade to new upstream, which obsoletes the HUP patch. + * Mon Apr 19 2010 Jarod Wilson 2.0.5-2 - Fix overlooked device HUP using firewire driver stack diff --git a/sources b/sources index fd25d58..dbbcfb0 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -1db64231c78540c32859b591cb8b40cf libraw1394-2.0.5.tar.gz +cdc5b66c300058a1b776ed83397a7291 libraw1394-2.0.6.tar.bz2 From 2cde37d14a3341596d684729db3a919bc3a2360d Mon Sep 17 00:00:00 2001 From: Dennis Gilmore Date: Tue, 8 Feb 2011 05:09:52 -0600 Subject: [PATCH 066/100] - Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild --- libraw1394.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index be822a4..f465441 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 2.0.6 -Release: 1%{?dist} +Release: 2%{?dist} License: LGPLv2+ Group: System Environment/Libraries Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.bz2 @@ -65,6 +65,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Tue Feb 08 2011 Fedora Release Engineering - 2.0.6-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + * Mon Dec 13 2010 Jay Fenlason 2.0.6-1 - Upgrade to new upstream, which obsoletes the HUP patch. From 27225973bb99d4dc81cb71c55a2c31d1a515fee8 Mon Sep 17 00:00:00 2001 From: Jarod Wilson Date: Wed, 4 May 2011 11:38:05 -0400 Subject: [PATCH 067/100] Update to upstream release 2.0.7 Signed-off-by: Jarod Wilson --- .gitignore | 1 + libraw1394.spec | 7 +++++-- sources | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index a71f00a..c723e1e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ libraw1394-2.0.0.tar.gz libraw1394-2.0.1.tar.gz libraw1394-2.0.4.tar.bz2 /libraw1394-2.0.6.tar.bz2 +/libraw1394-2.0.7.tar.bz2 diff --git a/libraw1394.spec b/libraw1394.spec index f465441..ec3f894 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 -Version: 2.0.6 -Release: 2%{?dist} +Version: 2.0.7 +Release: 1%{?dist} License: LGPLv2+ Group: System Environment/Libraries Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.bz2 @@ -65,6 +65,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Wed May 04 2011 Jarod Wilson 2.0.7-1 +- New upstream release (#683413) + * Tue Feb 08 2011 Fedora Release Engineering - 2.0.6-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild diff --git a/sources b/sources index dbbcfb0..e0c062b 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -cdc5b66c300058a1b776ed83397a7291 libraw1394-2.0.6.tar.bz2 +997ef18ab8e2e21f3966dff00e92be28 libraw1394-2.0.7.tar.bz2 From b7cb5b5c0ec3680d67a1be6d15e4ec48c54390cb Mon Sep 17 00:00:00 2001 From: Dennis Gilmore Date: Fri, 13 Jan 2012 02:21:29 -0600 Subject: [PATCH 068/100] - Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild --- libraw1394.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index ec3f894..b18fb2f 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 2.0.7 -Release: 1%{?dist} +Release: 2%{?dist} License: LGPLv2+ Group: System Environment/Libraries Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.bz2 @@ -65,6 +65,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Fri Jan 13 2012 Fedora Release Engineering - 2.0.7-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + * Wed May 04 2011 Jarod Wilson 2.0.7-1 - New upstream release (#683413) From c939d1611e29fdd4d296c671325bec5e5a568233 Mon Sep 17 00:00:00 2001 From: Jay Fenlason Date: Mon, 20 Feb 2012 15:15:29 -0500 Subject: [PATCH 069/100] New upstream release (#795374) libraw1394-2.0.8 --- .gitignore | 1 + libraw1394.spec | 9 ++++++--- sources | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index c723e1e..0d4fd91 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ libraw1394-2.0.1.tar.gz libraw1394-2.0.4.tar.bz2 /libraw1394-2.0.6.tar.bz2 /libraw1394-2.0.7.tar.bz2 +/libraw1394-2.0.8.tar.xz diff --git a/libraw1394.spec b/libraw1394.spec index b18fb2f..a86ccbd 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,10 +1,10 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 -Version: 2.0.7 -Release: 2%{?dist} +Version: 2.0.8 +Release: 1%{?dist} License: LGPLv2+ Group: System Environment/Libraries -Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.bz2 +Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.xz URL: http://www.dennedy.org/libraw1394/ ExcludeArch: s390 s390x BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) @@ -65,6 +65,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Mon Feb 20 2012 Jay Fenlason 2.0.8-1 +- New upstream release (#795374) + * Fri Jan 13 2012 Fedora Release Engineering - 2.0.7-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild diff --git a/sources b/sources index e0c062b..3320c16 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -997ef18ab8e2e21f3966dff00e92be28 libraw1394-2.0.7.tar.bz2 +df808e85ebfdfd0485a9938fcfd2d1c6 libraw1394-2.0.8.tar.xz From e2b748c094c0ced2c192587dc7e17af685bce2d3 Mon Sep 17 00:00:00 2001 From: Jay Fenlason Date: Tue, 6 Mar 2012 13:00:10 -0500 Subject: [PATCH 070/100] Clean up description (#800438) --- libraw1394.spec | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libraw1394.spec b/libraw1394.spec index a86ccbd..e2743ad 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 2.0.8 -Release: 1%{?dist} +Release: 2%{?dist} License: LGPLv2+ Group: System Environment/Libraries Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.xz @@ -11,11 +11,9 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: autoconf automake libtool kernel-headers %description -The libraw1394 library provides direct access to the IEEE-1394 bus through -the Linux 1394 subsystem's raw1394 user space interface. Support for both -the classic ieee1394 and new firewire linux driver stacks is included, with -run-time detection of the active stack. Fedora comes with the firewire stack -by default. +The libraw1394 library provides direct access to the IEEE-1394 bus. +Support for both the obsolete ieee1394 interface and the new firewire +intererface are included, with run-time detection of the active stack. %package devel Summary: Development libs for libraw1394 @@ -65,6 +63,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Tue Mar 7 2012 Jay Fenlason 2.0.8-2 +- Clean up description (#800438) + * Mon Feb 20 2012 Jay Fenlason 2.0.8-1 - New upstream release (#795374) From 2524c39b9abe7e2b4b20edd6ec9b8bccc161dd77 Mon Sep 17 00:00:00 2001 From: Dennis Gilmore Date: Thu, 19 Jul 2012 16:01:07 -0500 Subject: [PATCH 071/100] - Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild --- libraw1394.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index e2743ad..296ebef 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 2.0.8 -Release: 2%{?dist} +Release: 3%{?dist} License: LGPLv2+ Group: System Environment/Libraries Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.xz @@ -63,6 +63,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Thu Jul 19 2012 Fedora Release Engineering - 2.0.8-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + * Tue Mar 7 2012 Jay Fenlason 2.0.8-2 - Clean up description (#800438) From 89e919642e4e4a34a7aa28e691d3854f9335b2f5 Mon Sep 17 00:00:00 2001 From: Dennis Gilmore Date: Wed, 13 Feb 2013 23:09:44 -0600 Subject: [PATCH 072/100] - Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild --- libraw1394.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index 296ebef..40ce2a2 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 2.0.8 -Release: 3%{?dist} +Release: 4%{?dist} License: LGPLv2+ Group: System Environment/Libraries Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.xz @@ -63,6 +63,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Thu Feb 14 2013 Fedora Release Engineering - 2.0.8-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + * Thu Jul 19 2012 Fedora Release Engineering - 2.0.8-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild From e35f863cf4deb45f243d8b2430208d5ba60eceeb Mon Sep 17 00:00:00 2001 From: Jay Fenlason Date: Tue, 26 Feb 2013 09:13:44 -0500 Subject: [PATCH 073/100] New upstream version. --- .gitignore | 1 + libraw1394.spec | 7 +++++-- sources | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 0d4fd91..fd0c9a4 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ libraw1394-2.0.4.tar.bz2 /libraw1394-2.0.6.tar.bz2 /libraw1394-2.0.7.tar.bz2 /libraw1394-2.0.8.tar.xz +/libraw1394-2.1.0.tar.xz diff --git a/libraw1394.spec b/libraw1394.spec index 40ce2a2..30458b3 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 -Version: 2.0.8 -Release: 4%{?dist} +Version: 2.1.0 +Release: 1%{?dist} License: LGPLv2+ Group: System Environment/Libraries Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.xz @@ -63,6 +63,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Mon Feb 25 2013 Jay Fenlason 2.1.0-1 +- New upstream vesion. + * Thu Feb 14 2013 Fedora Release Engineering - 2.0.8-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild diff --git a/sources b/sources index 3320c16..afa0fb5 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -df808e85ebfdfd0485a9938fcfd2d1c6 libraw1394-2.0.8.tar.xz +e43a3fba606a03fec1682fbff31e53f6 libraw1394-2.1.0.tar.xz From 82bc2734279ec141f92ddec1b2ed24cafdacaeea Mon Sep 17 00:00:00 2001 From: Dennis Gilmore Date: Sat, 3 Aug 2013 01:50:39 -0500 Subject: [PATCH 074/100] - Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild --- libraw1394.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index 30458b3..570de7d 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 2.1.0 -Release: 1%{?dist} +Release: 2%{?dist} License: LGPLv2+ Group: System Environment/Libraries Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.xz @@ -63,6 +63,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Sat Aug 03 2013 Fedora Release Engineering - 2.1.0-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild + * Mon Feb 25 2013 Jay Fenlason 2.1.0-1 - New upstream vesion. From 41c3039fc6400e981e251beee24883457f7bb5e9 Mon Sep 17 00:00:00 2001 From: Dennis Gilmore Date: Sat, 7 Jun 2014 00:12:20 -0500 Subject: [PATCH 075/100] - Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild --- libraw1394.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index 570de7d..03bc08d 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 2.1.0 -Release: 2%{?dist} +Release: 3%{?dist} License: LGPLv2+ Group: System Environment/Libraries Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.xz @@ -63,6 +63,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Sat Jun 07 2014 Fedora Release Engineering - 2.1.0-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild + * Sat Aug 03 2013 Fedora Release Engineering - 2.1.0-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild From 077e7810132090e0639ab28582036ec65c4478f5 Mon Sep 17 00:00:00 2001 From: Peter Robinson Date: Sun, 17 Aug 2014 05:40:14 +0000 Subject: [PATCH 076/100] - Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild --- libraw1394.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index 03bc08d..f59c2bd 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 2.1.0 -Release: 3%{?dist} +Release: 4%{?dist} License: LGPLv2+ Group: System Environment/Libraries Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.xz @@ -63,6 +63,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Sun Aug 17 2014 Fedora Release Engineering - 2.1.0-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild + * Sat Jun 07 2014 Fedora Release Engineering - 2.1.0-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild From 4717cfe1103aef2e801c016b1aa01e89d751dd4e Mon Sep 17 00:00:00 2001 From: Till Maas Date: Sat, 21 Feb 2015 22:24:30 +0100 Subject: [PATCH 077/100] Rebuilt for Fedora 23 Change https://fedoraproject.org/wiki/Changes/Harden_all_packages_with_position-independent_code --- libraw1394.spec | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index f59c2bd..acd59ec 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 2.1.0 -Release: 4%{?dist} +Release: 5%{?dist} License: LGPLv2+ Group: System Environment/Libraries Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.xz @@ -63,6 +63,10 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Sat Feb 21 2015 Till Maas - 2.1.0-5 +- Rebuilt for Fedora 23 Change + https://fedoraproject.org/wiki/Changes/Harden_all_packages_with_position-independent_code + * Sun Aug 17 2014 Fedora Release Engineering - 2.1.0-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild From 765553be6dcf54198ade34fd4802372bb5e74c7b Mon Sep 17 00:00:00 2001 From: Dennis Gilmore Date: Wed, 17 Jun 2015 16:28:29 +0000 Subject: [PATCH 078/100] - Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild --- libraw1394.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index acd59ec..a0557c4 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 2.1.0 -Release: 5%{?dist} +Release: 6%{?dist} License: LGPLv2+ Group: System Environment/Libraries Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.xz @@ -63,6 +63,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Wed Jun 17 2015 Fedora Release Engineering - 2.1.0-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild + * Sat Feb 21 2015 Till Maas - 2.1.0-5 - Rebuilt for Fedora 23 Change https://fedoraproject.org/wiki/Changes/Harden_all_packages_with_position-independent_code From fdd3eceb488c34f741ee4de207eff90d09e614db Mon Sep 17 00:00:00 2001 From: Dennis Gilmore Date: Thu, 4 Feb 2016 03:49:27 +0000 Subject: [PATCH 079/100] - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild --- libraw1394.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index a0557c4..fdaef7b 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 2.1.0 -Release: 6%{?dist} +Release: 7%{?dist} License: LGPLv2+ Group: System Environment/Libraries Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.xz @@ -63,6 +63,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Thu Feb 04 2016 Fedora Release Engineering - 2.1.0-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + * Wed Jun 17 2015 Fedora Release Engineering - 2.1.0-6 - Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild From 485e53196a157f90105dd782391f8a7b3e72cd56 Mon Sep 17 00:00:00 2001 From: Nils Philippsen Date: Wed, 26 Oct 2016 19:11:18 +0200 Subject: [PATCH 080/100] version 2.1.2 --- .gitignore | 1 + libraw1394.spec | 7 +++++-- sources | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index fd0c9a4..dc8c443 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ libraw1394-2.0.4.tar.bz2 /libraw1394-2.0.7.tar.bz2 /libraw1394-2.0.8.tar.xz /libraw1394-2.1.0.tar.xz +/libraw1394-2.1.2.tar.xz diff --git a/libraw1394.spec b/libraw1394.spec index fdaef7b..5a5134c 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 -Version: 2.1.0 -Release: 7%{?dist} +Version: 2.1.2 +Release: 1%{?dist} License: LGPLv2+ Group: System Environment/Libraries Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.xz @@ -63,6 +63,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Wed Oct 26 2016 Nils Philippsen - 2.1.2-1 +- version 2.1.2 + * Thu Feb 04 2016 Fedora Release Engineering - 2.1.0-7 - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild diff --git a/sources b/sources index afa0fb5..a06ba24 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -e43a3fba606a03fec1682fbff31e53f6 libraw1394-2.1.0.tar.xz +118060584c04f1aa5e29c4d22c1c235a libraw1394-2.1.2.tar.xz From 2a0349bd38c03c12b77123d76cb968eb7cf02593 Mon Sep 17 00:00:00 2001 From: Nils Philippsen Date: Wed, 26 Oct 2016 19:17:44 +0200 Subject: [PATCH 081/100] tidy up spec file --- libraw1394.spec | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/libraw1394.spec b/libraw1394.spec index 5a5134c..c560a95 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -3,12 +3,10 @@ Name: libraw1394 Version: 2.1.2 Release: 1%{?dist} License: LGPLv2+ -Group: System Environment/Libraries Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.xz URL: http://www.dennedy.org/libraw1394/ ExcludeArch: s390 s390x -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -BuildRequires: autoconf automake libtool kernel-headers +BuildRequires: kernel-headers %description The libraw1394 library provides direct access to the IEEE-1394 bus. @@ -16,9 +14,9 @@ Support for both the obsolete ieee1394 interface and the new firewire intererface are included, with run-time detection of the active stack. %package devel -Summary: Development libs for libraw1394 -Group: Development/Libraries -Requires: %{name} = %{version}-%{release}, pkgconfig +Summary: Development libs for libraw1394 +Requires: %{name} = %{version}-%{release} +Requires: pkgconfig %description devel Development libraries needed to build applications against libraw1394. @@ -31,19 +29,14 @@ Development libraries needed to build applications against libraw1394. make %{?_smp_mflags} %install -rm -rf $RPM_BUILD_ROOT -make install DESTDIR=$RPM_BUILD_ROOT -rm -f $RPM_BUILD_ROOT%{_libdir}/libraw1394.la - -%clean -rm -rf $RPM_BUILD_ROOT +make install DESTDIR=%{buildroot} +rm -f %{buildroot}%{_libdir}/libraw1394.la %post -p /sbin/ldconfig %postun -p /sbin/ldconfig %files -%defattr(-,root,root,0755) %doc COPYING.LIB README NEWS %{_bindir}/dumpiso %{_bindir}/sendiso @@ -55,7 +48,6 @@ rm -rf $RPM_BUILD_ROOT %{_mandir}/man5/isodump.5.gz %files devel -%defattr(-,root,root,0755) %doc doc/libraw1394.sgml %{_includedir}/libraw1394/ %{_libdir}/libraw1394.so @@ -65,6 +57,7 @@ rm -rf $RPM_BUILD_ROOT %changelog * Wed Oct 26 2016 Nils Philippsen - 2.1.2-1 - version 2.1.2 +- tidy up spec file * Thu Feb 04 2016 Fedora Release Engineering - 2.1.0-7 - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild From 06450ccbb7890a415f64b502ac2d756ef519ad99 Mon Sep 17 00:00:00 2001 From: Nils Philippsen Date: Wed, 26 Oct 2016 19:15:02 +0200 Subject: [PATCH 082/100] use %license for license file --- libraw1394.spec | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index c560a95..b29a680 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -37,7 +37,8 @@ rm -f %{buildroot}%{_libdir}/libraw1394.la %postun -p /sbin/ldconfig %files -%doc COPYING.LIB README NEWS +%license COPYING.LIB +%doc README NEWS %{_bindir}/dumpiso %{_bindir}/sendiso %{_bindir}/testlibraw @@ -58,6 +59,7 @@ rm -f %{buildroot}%{_libdir}/libraw1394.la * Wed Oct 26 2016 Nils Philippsen - 2.1.2-1 - version 2.1.2 - tidy up spec file +- use %%license for license file * Thu Feb 04 2016 Fedora Release Engineering - 2.1.0-7 - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild From 6a910390c32e5e01eed23e478ca2fbd9f349ca21 Mon Sep 17 00:00:00 2001 From: Nils Philippsen Date: Wed, 26 Oct 2016 19:17:21 +0200 Subject: [PATCH 083/100] require same arch main from devel package --- libraw1394.spec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index b29a680..b5e0c12 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -15,7 +15,7 @@ intererface are included, with run-time detection of the active stack. %package devel Summary: Development libs for libraw1394 -Requires: %{name} = %{version}-%{release} +Requires: %{name}%{?_isa} = %{version}-%{release} Requires: pkgconfig %description devel @@ -60,6 +60,7 @@ rm -f %{buildroot}%{_libdir}/libraw1394.la - version 2.1.2 - tidy up spec file - use %%license for license file +- require same arch main from devel package * Thu Feb 04 2016 Fedora Release Engineering - 2.1.0-7 - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild From a7178450c499aec71953601fd07bc3f579489420 Mon Sep 17 00:00:00 2001 From: Nils Philippsen Date: Thu, 27 Oct 2016 09:59:25 +0200 Subject: [PATCH 084/100] fix bogus changelog date --- libraw1394.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index b5e0c12..e60b514 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -56,6 +56,9 @@ rm -f %{buildroot}%{_libdir}/libraw1394.la %changelog +* Thu Oct 27 2016 Nils Philippsen - 2.1.2-1 +- fix bogus changelog date + * Wed Oct 26 2016 Nils Philippsen - 2.1.2-1 - version 2.1.2 - tidy up spec file @@ -90,7 +93,7 @@ rm -f %{buildroot}%{_libdir}/libraw1394.la * Thu Jul 19 2012 Fedora Release Engineering - 2.0.8-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild -* Tue Mar 7 2012 Jay Fenlason 2.0.8-2 +* Tue Mar 6 2012 Jay Fenlason 2.0.8-2 - Clean up description (#800438) * Mon Feb 20 2012 Jay Fenlason 2.0.8-1 From 3ba4748a0e15430f168d738be7dd1f9677026014 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Fri, 10 Feb 2017 19:21:09 +0000 Subject: [PATCH 085/100] - Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild --- libraw1394.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index e60b514..b6caddb 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 2.1.2 -Release: 1%{?dist} +Release: 2%{?dist} License: LGPLv2+ Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.xz URL: http://www.dennedy.org/libraw1394/ @@ -56,6 +56,9 @@ rm -f %{buildroot}%{_libdir}/libraw1394.la %changelog +* Fri Feb 10 2017 Fedora Release Engineering - 2.1.2-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + * Thu Oct 27 2016 Nils Philippsen - 2.1.2-1 - fix bogus changelog date From 431f5a8119c2879d5bd480950f5616784c1cc91a Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Wed, 26 Jul 2017 19:36:13 +0000 Subject: [PATCH 086/100] - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild --- libraw1394.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index b6caddb..6ef60f2 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 2.1.2 -Release: 2%{?dist} +Release: 3%{?dist} License: LGPLv2+ Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.xz URL: http://www.dennedy.org/libraw1394/ @@ -56,6 +56,9 @@ rm -f %{buildroot}%{_libdir}/libraw1394.la %changelog +* Wed Jul 26 2017 Fedora Release Engineering - 2.1.2-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + * Fri Feb 10 2017 Fedora Release Engineering - 2.1.2-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild From e3f99c95d1b2a62662854b10495eeb373acd2f68 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 3 Aug 2017 02:09:35 +0000 Subject: [PATCH 087/100] - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild --- libraw1394.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index 6ef60f2..ebf219f 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 2.1.2 -Release: 3%{?dist} +Release: 4%{?dist} License: LGPLv2+ Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.xz URL: http://www.dennedy.org/libraw1394/ @@ -56,6 +56,9 @@ rm -f %{buildroot}%{_libdir}/libraw1394.la %changelog +* Thu Aug 03 2017 Fedora Release Engineering - 2.1.2-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild + * Wed Jul 26 2017 Fedora Release Engineering - 2.1.2-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild From 4e7f34379ccd669657e81b992e4c3a102efdac7d Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Wed, 7 Feb 2018 23:09:49 +0000 Subject: [PATCH 088/100] - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- libraw1394.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index ebf219f..ad7ed64 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 2.1.2 -Release: 4%{?dist} +Release: 5%{?dist} License: LGPLv2+ Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.xz URL: http://www.dennedy.org/libraw1394/ @@ -56,6 +56,9 @@ rm -f %{buildroot}%{_libdir}/libraw1394.la %changelog +* Wed Feb 07 2018 Fedora Release Engineering - 2.1.2-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + * Thu Aug 03 2017 Fedora Release Engineering - 2.1.2-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild From 1665d013c121553624c90d81e7d2ec10bc8df734 Mon Sep 17 00:00:00 2001 From: Nils Philippsen Date: Tue, 20 Feb 2018 20:44:47 +0100 Subject: [PATCH 089/100] require gcc for building --- libraw1394.spec | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libraw1394.spec b/libraw1394.spec index ad7ed64..1774009 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,11 +1,12 @@ -Summary: Library providing low-level IEEE-1394 access +Summary: Library providing low-level IEEE-1394 access - 2.1.2- Name: libraw1394 Version: 2.1.2 -Release: 5%{?dist} +Release: 6%{?dist} License: LGPLv2+ Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.xz URL: http://www.dennedy.org/libraw1394/ ExcludeArch: s390 s390x +BuildRequires: gcc BuildRequires: kernel-headers %description @@ -56,6 +57,9 @@ rm -f %{buildroot}%{_libdir}/libraw1394.la %changelog +* Tue Feb 20 2018 Nils Philippsen - 2.1.2-6 +- require gcc for building + * Wed Feb 07 2018 Fedora Release Engineering - 2.1.2-5 - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild From 6fe76b210530d32d51b079c10340dcc2d815fbd9 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Fri, 13 Jul 2018 08:44:09 +0000 Subject: [PATCH 090/100] - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- libraw1394.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index 1774009..7f0dc83 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access - 2.1.2- Name: libraw1394 Version: 2.1.2 -Release: 6%{?dist} +Release: 7%{?dist} License: LGPLv2+ Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.xz URL: http://www.dennedy.org/libraw1394/ @@ -57,6 +57,9 @@ rm -f %{buildroot}%{_libdir}/libraw1394.la %changelog +* Fri Jul 13 2018 Fedora Release Engineering - 2.1.2-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild + * Tue Feb 20 2018 Nils Philippsen - 2.1.2-6 - require gcc for building From 86b05b238d51915f7a03e3d8d5d4af6c6ea1dda9 Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Wed, 26 Sep 2018 12:34:07 -0400 Subject: [PATCH 091/100] Handle both compressed and uncompressed man pages When rebuilding with prefix=/app to include into Flatpak, manpage compression doesn't currently happen, so this is needed. It's also considered more correct if the way Fedora compresses its man pages ever changes, resulting in a different suffix. --- libraw1394.spec | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libraw1394.spec b/libraw1394.spec index 7f0dc83..b5a586a 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access - 2.1.2- Name: libraw1394 Version: 2.1.2 -Release: 7%{?dist} +Release: 8%{?dist} License: LGPLv2+ Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.xz URL: http://www.dennedy.org/libraw1394/ @@ -44,10 +44,10 @@ rm -f %{buildroot}%{_libdir}/libraw1394.la %{_bindir}/sendiso %{_bindir}/testlibraw %{_libdir}/libraw1394.so.* -%{_mandir}/man1/dumpiso.1.gz -%{_mandir}/man1/sendiso.1.gz -%{_mandir}/man1/testlibraw.1.gz -%{_mandir}/man5/isodump.5.gz +%{_mandir}/man1/dumpiso.1* +%{_mandir}/man1/sendiso.1* +%{_mandir}/man1/testlibraw.1* +%{_mandir}/man5/isodump.5* %files devel %doc doc/libraw1394.sgml @@ -57,6 +57,9 @@ rm -f %{buildroot}%{_libdir}/libraw1394.la %changelog +* Wed Sep 26 2018 Owen Taylor - 2.1.2-8 +- Handle both compressed and uncompressed man pages + * Fri Jul 13 2018 Fedora Release Engineering - 2.1.2-7 - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild From 6af7a2f1c2cd12ec903a721054653e7cfde3fdc2 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Tue, 22 Jan 2019 18:40:04 +0100 Subject: [PATCH 092/100] Remove obsolete ldconfig scriptlets References: https://fedoraproject.org/wiki/Changes/RemoveObsoleteScriptlets Signed-off-by: Igor Gnatenko --- libraw1394.spec | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libraw1394.spec b/libraw1394.spec index b5a586a..8f2ea8b 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -33,9 +33,7 @@ make %{?_smp_mflags} make install DESTDIR=%{buildroot} rm -f %{buildroot}%{_libdir}/libraw1394.la -%post -p /sbin/ldconfig - -%postun -p /sbin/ldconfig +%ldconfig_scriptlets %files %license COPYING.LIB From fd302091179d477f03f5dcef1e77b37791a94e76 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Fri, 1 Feb 2019 08:04:41 +0000 Subject: [PATCH 093/100] - Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- libraw1394.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index 8f2ea8b..2f82fbc 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access - 2.1.2- Name: libraw1394 Version: 2.1.2 -Release: 8%{?dist} +Release: 9%{?dist} License: LGPLv2+ Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.xz URL: http://www.dennedy.org/libraw1394/ @@ -55,6 +55,9 @@ rm -f %{buildroot}%{_libdir}/libraw1394.la %changelog +* Fri Feb 01 2019 Fedora Release Engineering - 2.1.2-9 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + * Wed Sep 26 2018 Owen Taylor - 2.1.2-8 - Handle both compressed and uncompressed man pages From 58603c50806318f54841c85f38c6a4f9b7b264cb Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 25 Jul 2019 14:13:49 +0000 Subject: [PATCH 094/100] - Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- libraw1394.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index 2f82fbc..2788238 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access - 2.1.2- Name: libraw1394 Version: 2.1.2 -Release: 9%{?dist} +Release: 10%{?dist} License: LGPLv2+ Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.xz URL: http://www.dennedy.org/libraw1394/ @@ -55,6 +55,9 @@ rm -f %{buildroot}%{_libdir}/libraw1394.la %changelog +* Thu Jul 25 2019 Fedora Release Engineering - 2.1.2-10 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + * Fri Feb 01 2019 Fedora Release Engineering - 2.1.2-9 - Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild From 09f29ce8c6d92ff229f38fad26ec14f6f9ce4dcd Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Wed, 29 Jan 2020 10:10:37 +0000 Subject: [PATCH 095/100] - Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- libraw1394.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index 2788238..1c4449c 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access - 2.1.2- Name: libraw1394 Version: 2.1.2 -Release: 10%{?dist} +Release: 11%{?dist} License: LGPLv2+ Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.xz URL: http://www.dennedy.org/libraw1394/ @@ -55,6 +55,9 @@ rm -f %{buildroot}%{_libdir}/libraw1394.la %changelog +* Wed Jan 29 2020 Fedora Release Engineering - 2.1.2-11 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + * Thu Jul 25 2019 Fedora Release Engineering - 2.1.2-10 - Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild From aac54cb4935ecdbf2d685b69ea8f4c821ac2d579 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Tue, 28 Jul 2020 05:25:55 +0000 Subject: [PATCH 096/100] - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- libraw1394.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index 1c4449c..0657c09 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access - 2.1.2- Name: libraw1394 Version: 2.1.2 -Release: 11%{?dist} +Release: 12%{?dist} License: LGPLv2+ Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.xz URL: http://www.dennedy.org/libraw1394/ @@ -55,6 +55,9 @@ rm -f %{buildroot}%{_libdir}/libraw1394.la %changelog +* Tue Jul 28 2020 Fedora Release Engineering - 2.1.2-12 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + * Wed Jan 29 2020 Fedora Release Engineering - 2.1.2-11 - Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild From 0e93dbe2fcb967f10d64fe7f22c5a861addde63b Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 5 Jan 2021 02:35:30 +0000 Subject: [PATCH 097/100] Add BuildRequires: make https://fedoraproject.org/wiki/Changes/Remove_make_from_BuildRoot --- libraw1394.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/libraw1394.spec b/libraw1394.spec index 0657c09..0ced8b3 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -8,6 +8,7 @@ URL: http://www.dennedy.org/libraw1394/ ExcludeArch: s390 s390x BuildRequires: gcc BuildRequires: kernel-headers +BuildRequires: make %description The libraw1394 library provides direct access to the IEEE-1394 bus. From b31684bfad54bd9d55e325b6d4625143a194d610 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Tue, 26 Jan 2021 17:50:49 +0000 Subject: [PATCH 098/100] - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- libraw1394.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index 0ced8b3..d2325a6 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access - 2.1.2- Name: libraw1394 Version: 2.1.2 -Release: 12%{?dist} +Release: 13%{?dist} License: LGPLv2+ Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.xz URL: http://www.dennedy.org/libraw1394/ @@ -56,6 +56,9 @@ rm -f %{buildroot}%{_libdir}/libraw1394.la %changelog +* Tue Jan 26 2021 Fedora Release Engineering - 2.1.2-13 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + * Tue Jul 28 2020 Fedora Release Engineering - 2.1.2-12 - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild From b6654598e7c57f384195f2337331471c0eddddd5 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 22 Jul 2021 12:11:59 +0000 Subject: [PATCH 099/100] - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- libraw1394.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraw1394.spec b/libraw1394.spec index d2325a6..cc6c3a6 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access - 2.1.2- Name: libraw1394 Version: 2.1.2 -Release: 13%{?dist} +Release: 14%{?dist} License: LGPLv2+ Source: http://www.kernel.org/pub/linux/libs/ieee1394/%{name}-%{version}.tar.xz URL: http://www.dennedy.org/libraw1394/ @@ -56,6 +56,9 @@ rm -f %{buildroot}%{_libdir}/libraw1394.la %changelog +* Thu Jul 22 2021 Fedora Release Engineering - 2.1.2-14 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild + * Tue Jan 26 2021 Fedora Release Engineering - 2.1.2-13 - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild From 9f499eb69793871f4153066c734a0131c501cea1 Mon Sep 17 00:00:00 2001 From: MSVSphere Packaging Team Date: Mon, 30 Oct 2023 23:14:48 +0300 Subject: [PATCH 100/100] Remove unnecessary files --- sources | 1 - 1 file changed, 1 deletion(-) delete mode 100644 sources diff --git a/sources b/sources deleted file mode 100644 index a06ba24..0000000 --- a/sources +++ /dev/null @@ -1 +0,0 @@ -118060584c04f1aa5e29c4d22c1c235a libraw1394-2.1.2.tar.xz