Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Aug 2008 09:26:53 +0100
From:      Dieter <freebsd@sopwith.solgatos.com>
To:        Sean Bruno <sbruno@miralink.com>
Cc:        freebsd-firewire@freebsd.org
Subject:   Re: This is where I'm going with fwcontrol 
Message-ID:  <200808291626.QAA13259@sopwith.solgatos.com>
In-Reply-To: Your message of "Thu, 28 Aug 2008 16:49:05 PDT." <48B73971.90706@miralink.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
I looked at the changes NetBSD made to fwcontrol.c
with the idea of tweaking FreeBSD's version so it would
compile on both OSes.  Below is a patch that might be enough.
They made more changes than this.  Some are clearly not essential
(whitespace, putting the usage message into alphabetical order, ...),
some I'm not sure about so I left them out for now.  The full set
of changes they did can be viewed by diffing FreeBSD cvs 1.23
with NetBSD cvs 1.7.  It still compiles fine on FreeBSD 7.0 amd64,
(and the getprogname() thing works) I haven't tried NetBSD yet.

===================================================================
RCS file: RCS/fwcontrol.c,v
retrieving revision 1.2.2.2
diff -u -r1.2.2.2 fwcontrol.c
--- fwcontrol.c	2008/08/29 15:50:16	1.2.2.2
+++ fwcontrol.c	2008/08/29 16:00:48
@@ -32,8 +32,10 @@
  * SUCH DAMAGE.
  */
 
+#if defined(__FreeBSD__)
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/usr.sbin/fwcontrol/fwcontrol.c,v 1.23.2.1 2008/05/02 06:15:58 simokawa Exp $");
+#endif
 
 #include <sys/param.h>
 #include <sys/malloc.h>
@@ -42,11 +44,22 @@
 #include <sys/socket.h>
 #include <sys/ioctl.h>
 #include <sys/errno.h>
+#if defined(__FreeBSD__)
 #include <sys/eui64.h>
 #include <dev/firewire/firewire.h>
 #include <dev/firewire/iec13213.h>
 #include <dev/firewire/fwphyreg.h>
 #include <dev/firewire/iec68113.h>
+#elif defined(__NetBSD__)
+#include "eui64.h"
+#include <dev/ieee1394/firewire.h>
+#include <dev/ieee1394/iec13213.h>
+#include <dev/ieee1394/fwphyreg.h>
+#include <dev/ieee1394/iec68113.h>
+#else
+#warning "You need to add support for your OS"
+#endif
+
 
 #include <netinet/in.h>
 #include <fcntl.h>
@@ -66,7 +79,7 @@
 usage(void)
 {
 	fprintf(stderr,
-		"fwcontrol [-u bus_num] [-prt] [-c node] [-d node] [-o node] [-s node]\n"
+		"%s [-u bus_num] [-prt] [-c node] [-d node] [-o node] [-s node]\n"
 		"\t  [-l file] [-g gap_count] [-f force_root ] [-b pri_req]\n"
 		"\t  [-M mode] [-R filename] [-S filename] [-m EUI64 | hostname]\n"
 		"\t-u: specify bus number\n"
@@ -84,7 +97,8 @@
 		"\t-M: specify dv or mpeg\n"
 		"\t-R: Receive DV or MPEG TS stream\n"
 		"\t-S: Send DV stream\n"
-		"\t-m: set fwmem target\n");
+		"\t-m: set fwmem target\n"
+		, getprogname() );
 	exit(EX_USAGE);
 }
 
@@ -981,8 +995,16 @@
 	if (set_fwmem_target) {
 		eui.hi = ntohl(*(u_int32_t*)&(target.octet[0]));
 		eui.lo = ntohl(*(u_int32_t*)&(target.octet[4]));
+#if defined(__FreeBSD__)
 		sysctl_set_int("hw.firewire.fwmem.eui64_hi", eui.hi);
 		sysctl_set_int("hw.firewire.fwmem.eui64_lo", eui.lo);
+#elif defined(__NetBSD__)
+		sysctl_set_int("hw.fwmem.eui64_hi", eui.hi);
+		sysctl_set_int("hw.fwmem.eui64_lo", eui.lo);
+#else
+#warning "You need to add support for your OS"
+#endif
+
 	}
 
 	/*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200808291626.QAA13259>