From owner-freebsd-firewire@FreeBSD.ORG Mon Dec 8 11:06:55 2008 Return-Path: Delivered-To: freebsd-firewire@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2C4F71065673 for ; Mon, 8 Dec 2008 11:06:55 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 0048C8FC0C for ; Mon, 8 Dec 2008 11:06:54 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id mB8B6sTa014240 for ; Mon, 8 Dec 2008 11:06:54 GMT (envelope-from owner-bugmaster@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id mB8B6s9U014236 for freebsd-firewire@FreeBSD.org; Mon, 8 Dec 2008 11:06:54 GMT (envelope-from owner-bugmaster@FreeBSD.org) Date: Mon, 8 Dec 2008 11:06:54 GMT Message-Id: <200812081106.mB8B6s9U014236@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: gnats set sender to owner-bugmaster@FreeBSD.org using -f From: FreeBSD bugmaster To: freebsd-firewire@FreeBSD.org Cc: Subject: Current problem reports assigned to freebsd-firewire@FreeBSD.org X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Dec 2008 11:06:55 -0000 Note: to view an individual PR, use: http://www.freebsd.org/cgi/query-pr.cgi?pr=(number). The following is a listing of current problems submitted by FreeBSD users. These represent problem reports covering all versions including experimental development code and obsolete releases. S Tracker Resp. Description -------------------------------------------------------------------------------- o kern/113785 firewire [firewire] dropouts when playing DV on firewire o kern/74238 firewire [firewire] fw_rcv: unknown response; firewire ad-hoc w 2 problems total. From owner-freebsd-firewire@FreeBSD.ORG Thu Dec 11 21:28:38 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0E91D1065670 for ; Thu, 11 Dec 2008 21:28:38 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from plato.miralink.com (mail.miralink.com [70.103.185.20]) by mx1.freebsd.org (Postfix) with ESMTP id D91278FC13 for ; Thu, 11 Dec 2008 21:28:37 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from localhost (localhost.localdomain [127.0.0.1]) by plato.miralink.com (Postfix) with ESMTP id 65B5B1A90FB; Thu, 11 Dec 2008 13:18:29 -0800 (PST) X-Virus-Scanned: amavisd-new at X-Spam-Flag: NO X-Spam-Score: -4.399 X-Spam-Level: X-Spam-Status: No, score=-4.399 tagged_above=-10 required=6.6 tests=[ALL_TRUSTED=-1.8, AWL=0.000, BAYES_00=-2.599] Received: from plato.miralink.com ([127.0.0.1]) by localhost (plato.miralink.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id j0QifiWBK6pv; Thu, 11 Dec 2008 13:18:28 -0800 (PST) Received: from [10.0.0.40] (iago.office.miralink.com [10.0.0.40]) by plato.miralink.com (Postfix) with ESMTP id A27631A90CB; Thu, 11 Dec 2008 13:18:28 -0800 (PST) Message-ID: <494183A4.8060608@miralink.com> Date: Thu, 11 Dec 2008 13:18:28 -0800 From: Sean Bruno User-Agent: Thunderbird 2.0.0.18 (X11/20081119) MIME-Version: 1.0 To: Dieter References: <200811101717.RAA12234@sopwith.solgatos.com> In-Reply-To: <200811101717.RAA12234@sopwith.solgatos.com> Content-Type: multipart/mixed; boundary="------------090501050008050703000409" Cc: Scott Long , freebsd-firewire@freebsd.org Subject: Re: patch for fwcontrol X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Dec 2008 21:28:38 -0000 This is a multi-part message in MIME format. --------------090501050008050703000409 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Dieter wrote: > In message <4905EE3A.1050506@miralink.com>, Sean Bruno writes: > > >> Dieter wrote: >> >>> The patch below: >>> >>> Fixes several err() vs errx() errors >>> Improves some range checks >>> Improves some messages >>> Supports NetBSD in addition to FreeBSD >>> >>> >> Ok, slightly reworked patch. Seems to work fine for me. Comments? >> > > Sean, > > Sorry for the delay, my normal outgoing email is hosed at > the moment due to some problems upstream, so I'm trying workarounds > with varying success. Incoming email is fine. > > Your version of the patch looks fine, although leaving out > the ".0" of the device name will keep it from working on NetBSD. > > What do you think of something like > > #if defined(__FreeBSD__) > snprintf(devbase, sizeof(devbase), "%s%d", device_string, current_board); > #elif defined(__NetBSD__) > snprintf(devbase, sizeof(devbase), "%s%d.0", device_string, current_board); > #else > #warning "You need to add support for your OS" > #endif > > > This make the code a bit messier, and FreeBSD works fine with the extra ".0" > which is why I just added the ".0". I still don't know what the ".0" was/is for. > > So I see three options: > > 1) Check your patch in as is. NetBSDers will have to modify something. > > 2) Add the ".0". Obviously you don't like this option. > > 3) Put in the #if stuff as above. > > I'd prefer #2 or #3, but if you prefer #1 that's ok. > > thanks, > Dieter > Dieter: It's been a while, but I've finally found some time to revisit this code. I've looked over the firewire driver in FreeBSD and see no reason to use /dev/fw0.0 as the device as /dev/fw0 is just an alias for it. So, with a little more verbose error reporting with regards to permissions(non root opens) here is an updated patch. -- Sean Bruno MiraLink Corporation 6015 NE 80th Ave, Ste 100 Portland, OR 97218 Phone 503-621-5143 Fax 503-621-5199 MSN: sbruno@miralink.com Google: seanwbruno@gmail.com Yahoo: sean_bruno@yahoo.com --------------090501050008050703000409 Content-Type: text/plain; name="fwcontrol.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="fwcontrol.diff" Index: fwmpegts.c =================================================================== --- fwmpegts.c (revision 185940) +++ fwmpegts.c (working copy) @@ -52,9 +52,17 @@ #include #include +#if defined(__FreeBSD__) #include #include +#elif defined(__NetBSD__) +#include +#include +#else +#warning "You need to add support for your OS" +#endif + #include "fwmethods.h" #define DEBUG 0 Index: fwcontrol.c =================================================================== --- fwcontrol.c (revision 185940) +++ fwcontrol.c (working copy) @@ -32,8 +32,10 @@ * SUCH DAMAGE. */ +#if defined(__FreeBSD__) #include __FBSDID("$FreeBSD$"); +#endif #include #include @@ -42,12 +44,23 @@ #include #include #include +#if defined(__FreeBSD__) #include #include #include #include #include +#elif defined(__NetBSD__) +#include "eui64.h" +#include +#include +#include +#include +#else +#warning "You need to add support for your OS" +#endif + #include #include #include @@ -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" @@ -78,14 +91,15 @@ "\t-o: send link-on packet to the node\n" "\t-s: write RESET_START register on the node\n" "\t-l: load and parse hex dump file of configuration ROM\n" - "\t-g: broadcast gap_count by phy_config packet\n" - "\t-f: broadcast force_root by phy_config packet\n" + "\t-g: set gap count\n" + "\t-f: force root node\n" "\t-b: set PRIORITY_BUDGET register on all supported nodes\n" "\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"); - exit(EX_USAGE); + "\t-m: set fwmem target\n" + , getprogname() ); + fprintf(stderr, "\n"); } static void @@ -488,7 +502,7 @@ int len=1024, i; if ((file = fopen(filename, "r")) == NULL) - err(1, "load_crom"); + err(1, "load_crom %s", filename); for (i = 0; i < len/(4*8); i ++) { fscanf(file, DUMP_FORMAT, p, p+1, p+2, p+3, p+4, p+5, p+6, p+7); @@ -691,7 +705,7 @@ */ len = read(fd, buf, RECV_NUM_PACKET * RECV_PACKET_SZ); if (len < 0) - err(EX_IOERR, "%s: error reading from device\n", __func__); + err(EX_IOERR, "%s: error reading from device", __func__); ptr = (u_int32_t *) buf; ciph = (struct ciphdr *)(ptr + 1); @@ -757,10 +771,12 @@ if (argc < 2) { for (current_board = 0; current_board < MAX_BOARDS; current_board++) { - snprintf(devbase, sizeof(devbase), "%s%d", device_string, current_board); + snprintf(devbase, sizeof(devbase), "%s%d.0", device_string, current_board); if (open_dev(&fd, devbase) < 0) { if (current_board == 0) { usage(); + err(EX_IOERR, "%s: Error opening firewire controller #%d %s", + __func__, current_board, devbase); } return(EIO); } @@ -777,7 +793,7 @@ case 'b': priority_budget = strtol(optarg, NULL, 0); if (priority_budget < 0 || priority_budget > INT32_MAX) - errx(EX_USAGE, "%s: invalid number: %s", __func__, optarg); + errx(EX_USAGE, "%s: priority_budget out of range: %s", __func__, optarg); command_set = true; open_needed = true; display_board_only = false; @@ -787,7 +803,7 @@ if (crom_string == NULL) err(EX_SOFTWARE, "%s:crom_string malloc", __func__); if ( (strtol(crom_string, NULL, 0) < 0) || strtol(crom_string, NULL, 0) > MAX_BOARDS) - err(EX_USAGE, "%s:Invalid value for node", __func__); + errx(EX_USAGE, "%s:Invalid value for node", __func__); strcpy(crom_string, optarg); display_crom = 1; open_needed = true; @@ -808,7 +824,7 @@ #define MAX_PHY_CONFIG 0x3f set_root_node = strtol(optarg, NULL, 0); if ( (set_root_node < 0) || (set_root_node > MAX_PHY_CONFIG) ) - err(EX_USAGE, "%s:set_root_node out of range", __func__); + errx(EX_USAGE, "%s:set_root_node out of range", __func__); open_needed = true; command_set = true; display_board_only = false; @@ -816,7 +832,7 @@ case 'g': set_gap_count = strtol(optarg, NULL, 0); if ( (set_gap_count < 0) || (set_gap_count > MAX_PHY_CONFIG) ) - err(EX_USAGE, "%s:set_gap_count out of range", __func__); + errx(EX_USAGE, "%s:set_gap_count out of range", __func__); open_needed = true; command_set = true; display_board_only = false; @@ -834,12 +850,12 @@ display_board_only = false; if (eui64_hostton(optarg, &target) != 0 && eui64_aton(optarg, &target) != 0) - err(EX_USAGE, "%s: invalid target: %s", __func__, optarg); + errx(EX_USAGE, "%s: invalid target: %s", __func__, optarg); break; case 'o': send_link_on = str2node(fd, optarg); - if ( (send_link_on < 0) || (send_link_on > INT32_MAX) ) - err(EX_USAGE, "%s: node out of range: %s\n",__func__, optarg); + if ( (send_link_on < 0) || (send_link_on > MAX_PHY_CONFIG) ) + errx(EX_USAGE, "%s: node out of range: %s\n",__func__, optarg); open_needed = true; command_set = true; display_board_only = false; @@ -858,8 +874,8 @@ break; case 's': send_reset_start = str2node(fd, optarg); - if ( (send_reset_start < 0) || (send_reset_start > INT32_MAX) ) - err(EX_USAGE, "%s: node out of range: %s\n", __func__, optarg); + if ( (send_reset_start < 0) || (send_reset_start > MAX_PHY_CONFIG) ) + errx(EX_USAGE, "%s: node out of range: %s\n", __func__, optarg); open_needed = true; command_set = true; display_board_only = false; @@ -924,9 +940,9 @@ * */ if(open_needed){ - snprintf(devbase, sizeof(devbase), "%s%d", device_string, current_board); + snprintf(devbase, sizeof(devbase), "%s%d.0", device_string, current_board); if (open_dev(&fd, devbase) < 0) { - errx(EX_IOERR, "%s: Error opening board #%d\n", __func__, current_board); + err(EX_IOERR, "%s: Error opening firewire controller #%d %s", __func__, current_board, devbase); } } /* @@ -996,8 +1012,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 + } /* @@ -1028,9 +1052,9 @@ recvfn = detect_recv_fn(fd, TAG | CHANNEL); close(fd); } - snprintf(devbase, sizeof(devbase), "%s%d", device_string, current_board); + snprintf(devbase, sizeof(devbase), "%s%d.0", device_string, current_board); if (open_dev(&fd, devbase) < 0) - errx(EX_IOERR, "%s: Error opening board #%d in recv_data\n", __func__, current_board); + err(EX_IOERR, "%s: Error opening firewire controller #%d %s in recv_data\n", __func__, current_board, devbase); (*recvfn)(fd, recv_data, TAG | CHANNEL, -1); free(recv_data); } --------------090501050008050703000409-- From owner-freebsd-firewire@FreeBSD.ORG Thu Dec 11 23:10:20 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9C7B3106564A for ; Thu, 11 Dec 2008 23:10:20 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from plato.miralink.com (mail.miralink.com [70.103.185.20]) by mx1.freebsd.org (Postfix) with ESMTP id 5760A8FC19 for ; Thu, 11 Dec 2008 23:10:20 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from localhost (localhost.localdomain [127.0.0.1]) by plato.miralink.com (Postfix) with ESMTP id 1457E890013; Thu, 11 Dec 2008 15:10:20 -0800 (PST) X-Virus-Scanned: amavisd-new at X-Spam-Flag: NO X-Spam-Score: -4.399 X-Spam-Level: X-Spam-Status: No, score=-4.399 tagged_above=-10 required=6.6 tests=[ALL_TRUSTED=-1.8, BAYES_00=-2.599] Received: from plato.miralink.com ([127.0.0.1]) by localhost (plato.miralink.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id heau72Fypo1F; Thu, 11 Dec 2008 15:10:19 -0800 (PST) Received: from [10.0.0.40] (iago.office.miralink.com [10.0.0.40]) by plato.miralink.com (Postfix) with ESMTP id 238681A90C7; Thu, 11 Dec 2008 15:10:19 -0800 (PST) Message-ID: <49419DDB.3080900@miralink.com> Date: Thu, 11 Dec 2008 15:10:19 -0800 From: Sean Bruno User-Agent: Thunderbird 2.0.0.18 (X11/20081119) MIME-Version: 1.0 To: Dieter References: <200811101717.RAA12234@sopwith.solgatos.com> <494183A4.8060608@miralink.com> In-Reply-To: <494183A4.8060608@miralink.com> Content-Type: multipart/mixed; boundary="------------060505030505030501040100" Cc: Scott Long , freebsd-firewire@freebsd.org Subject: Re: patch for fwcontrol X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Dec 2008 23:10:20 -0000 This is a multi-part message in MIME format. --------------060505030505030501040100 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sean Bruno wrote: > Dieter wrote: >> In message <4905EE3A.1050506@miralink.com>, Sean Bruno writes: >> >> >>> Dieter wrote: >>> >>>> The patch below: >>>> >>>> Fixes several err() vs errx() errors >>>> Improves some range checks >>>> Improves some messages >>>> Supports NetBSD in addition to FreeBSD >>>> >>> Ok, slightly reworked patch. Seems to work fine for me. Comments? >>> >> >> Sean, >> >> Sorry for the delay, my normal outgoing email is hosed at >> the moment due to some problems upstream, so I'm trying workarounds >> with varying success. Incoming email is fine. >> >> Your version of the patch looks fine, although leaving out >> the ".0" of the device name will keep it from working on NetBSD. >> >> What do you think of something like >> >> #if defined(__FreeBSD__) >> snprintf(devbase, sizeof(devbase), "%s%d", device_string, >> current_board); >> #elif defined(__NetBSD__) >> snprintf(devbase, sizeof(devbase), "%s%d.0", device_string, >> current_board); >> #else >> #warning "You need to add support for your OS" >> #endif >> >> >> This make the code a bit messier, and FreeBSD works fine with the >> extra ".0" >> which is why I just added the ".0". I still don't know what the ".0" >> was/is for. >> >> So I see three options: >> >> 1) Check your patch in as is. NetBSDers will have to modify >> something. >> >> 2) Add the ".0". Obviously you don't like this option. >> >> 3) Put in the #if stuff as above. >> >> I'd prefer #2 or #3, but if you prefer #1 that's ok. >> >> thanks, >> Dieter >> > Dieter: > > It's been a while, but I've finally found some time to revisit this > code. I've looked over the firewire driver > in FreeBSD and see no reason to use /dev/fw0.0 as the device as > /dev/fw0 is just an alias for it. > > So, with a little more verbose error reporting with regards to > permissions(non root opens) here is an updated > patch. > > Ah, and then I go and start changing stuff. This patch adds some useful error output to indicate to the user that the command line args are wrong. This should apply against HEAD. -- Sean Bruno MiraLink Corporation 6015 NE 80th Ave, Ste 100 Portland, OR 97218 Phone 503-621-5143 Fax 503-621-5199 MSN: sbruno@miralink.com Google: seanwbruno@gmail.com Yahoo: sean_bruno@yahoo.com --------------060505030505030501040100 Content-Type: text/plain; name="fwcontrol.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="fwcontrol.diff" Index: fwmpegts.c =================================================================== --- fwmpegts.c (revision 185940) +++ fwmpegts.c (working copy) @@ -52,9 +52,17 @@ #include #include +#if defined(__FreeBSD__) #include #include +#elif defined(__NetBSD__) +#include +#include +#else +#warning "You need to add support for your OS" +#endif + #include "fwmethods.h" #define DEBUG 0 Index: fwcontrol.c =================================================================== --- fwcontrol.c (revision 185940) +++ fwcontrol.c (working copy) @@ -32,8 +32,10 @@ * SUCH DAMAGE. */ +#if defined(__FreeBSD__) #include __FBSDID("$FreeBSD$"); +#endif #include #include @@ -42,12 +44,23 @@ #include #include #include +#if defined(__FreeBSD__) #include #include #include #include #include +#elif defined(__NetBSD__) +#include "eui64.h" +#include +#include +#include +#include +#else +#warning "You need to add support for your OS" +#endif + #include #include #include @@ -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" @@ -78,14 +91,15 @@ "\t-o: send link-on packet to the node\n" "\t-s: write RESET_START register on the node\n" "\t-l: load and parse hex dump file of configuration ROM\n" - "\t-g: broadcast gap_count by phy_config packet\n" - "\t-f: broadcast force_root by phy_config packet\n" + "\t-g: set gap count\n" + "\t-f: force root node\n" "\t-b: set PRIORITY_BUDGET register on all supported nodes\n" "\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"); - exit(EX_USAGE); + "\t-m: set fwmem target\n" + , getprogname() ); + fprintf(stderr, "\n"); } static void @@ -488,7 +502,7 @@ int len=1024, i; if ((file = fopen(filename, "r")) == NULL) - err(1, "load_crom"); + err(1, "load_crom %s", filename); for (i = 0; i < len/(4*8); i ++) { fscanf(file, DUMP_FORMAT, p, p+1, p+2, p+3, p+4, p+5, p+6, p+7); @@ -691,7 +705,7 @@ */ len = read(fd, buf, RECV_NUM_PACKET * RECV_PACKET_SZ); if (len < 0) - err(EX_IOERR, "%s: error reading from device\n", __func__); + err(EX_IOERR, "%s: error reading from device", __func__); ptr = (u_int32_t *) buf; ciph = (struct ciphdr *)(ptr + 1); @@ -757,10 +771,12 @@ if (argc < 2) { for (current_board = 0; current_board < MAX_BOARDS; current_board++) { - snprintf(devbase, sizeof(devbase), "%s%d", device_string, current_board); + snprintf(devbase, sizeof(devbase), "%s%d.0", device_string, current_board); if (open_dev(&fd, devbase) < 0) { if (current_board == 0) { usage(); + err(EX_IOERR, "%s: Error opening firewire controller #%d %s", + __func__, current_board, devbase); } return(EIO); } @@ -777,7 +793,7 @@ case 'b': priority_budget = strtol(optarg, NULL, 0); if (priority_budget < 0 || priority_budget > INT32_MAX) - errx(EX_USAGE, "%s: invalid number: %s", __func__, optarg); + errx(EX_USAGE, "%s: priority_budget out of range: %s", __func__, optarg); command_set = true; open_needed = true; display_board_only = false; @@ -787,7 +803,7 @@ if (crom_string == NULL) err(EX_SOFTWARE, "%s:crom_string malloc", __func__); if ( (strtol(crom_string, NULL, 0) < 0) || strtol(crom_string, NULL, 0) > MAX_BOARDS) - err(EX_USAGE, "%s:Invalid value for node", __func__); + errx(EX_USAGE, "%s:Invalid value for node", __func__); strcpy(crom_string, optarg); display_crom = 1; open_needed = true; @@ -808,7 +824,7 @@ #define MAX_PHY_CONFIG 0x3f set_root_node = strtol(optarg, NULL, 0); if ( (set_root_node < 0) || (set_root_node > MAX_PHY_CONFIG) ) - err(EX_USAGE, "%s:set_root_node out of range", __func__); + errx(EX_USAGE, "%s:set_root_node out of range", __func__); open_needed = true; command_set = true; display_board_only = false; @@ -816,7 +832,7 @@ case 'g': set_gap_count = strtol(optarg, NULL, 0); if ( (set_gap_count < 0) || (set_gap_count > MAX_PHY_CONFIG) ) - err(EX_USAGE, "%s:set_gap_count out of range", __func__); + errx(EX_USAGE, "%s:set_gap_count out of range", __func__); open_needed = true; command_set = true; display_board_only = false; @@ -834,12 +850,12 @@ display_board_only = false; if (eui64_hostton(optarg, &target) != 0 && eui64_aton(optarg, &target) != 0) - err(EX_USAGE, "%s: invalid target: %s", __func__, optarg); + errx(EX_USAGE, "%s: invalid target: %s", __func__, optarg); break; case 'o': send_link_on = str2node(fd, optarg); - if ( (send_link_on < 0) || (send_link_on > INT32_MAX) ) - err(EX_USAGE, "%s: node out of range: %s\n",__func__, optarg); + if ( (send_link_on < 0) || (send_link_on > MAX_PHY_CONFIG) ) + errx(EX_USAGE, "%s: node out of range: %s\n",__func__, optarg); open_needed = true; command_set = true; display_board_only = false; @@ -858,8 +874,8 @@ break; case 's': send_reset_start = str2node(fd, optarg); - if ( (send_reset_start < 0) || (send_reset_start > INT32_MAX) ) - err(EX_USAGE, "%s: node out of range: %s\n", __func__, optarg); + if ( (send_reset_start < 0) || (send_reset_start > MAX_PHY_CONFIG) ) + errx(EX_USAGE, "%s: node out of range: %s\n", __func__, optarg); open_needed = true; command_set = true; display_board_only = false; @@ -909,13 +925,27 @@ command_set = true; display_board_only = false; break; + case '?': default: usage(); + warnc(EINVAL, "%s: Unknown command line arguments", __func__); return 0; } } /* end while */ /* + * Catch the error case when the user + * executes the command with non ''-'' + * delimited arguments. + * Generate the usage() display and exit. + */ + if (!command_set && !display_board_only) { + usage(); + warnc(EINVAL, "%s: Unknown command line arguments", __func__); + return 0; + } + + /* * If -u is passed, execute * command for that card only. * @@ -924,9 +954,9 @@ * */ if(open_needed){ - snprintf(devbase, sizeof(devbase), "%s%d", device_string, current_board); + snprintf(devbase, sizeof(devbase), "%s%d.0", device_string, current_board); if (open_dev(&fd, devbase) < 0) { - errx(EX_IOERR, "%s: Error opening board #%d\n", __func__, current_board); + err(EX_IOERR, "%s: Error opening firewire controller #%d %s", __func__, current_board, devbase); } } /* @@ -947,7 +977,7 @@ */ if (send_bus_reset) { if(ioctl(fd, FW_IBUSRST, &tmp) < 0) - err(EX_IOERR, "%s: ioctl", __func__); + err(EX_IOERR, "%s: Ioctl of bus reset failed for %s", __func__, devbase); } /* * Print out the CROM for this node "-c" @@ -996,8 +1026,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 + } /* @@ -1028,9 +1066,9 @@ recvfn = detect_recv_fn(fd, TAG | CHANNEL); close(fd); } - snprintf(devbase, sizeof(devbase), "%s%d", device_string, current_board); + snprintf(devbase, sizeof(devbase), "%s%d.0", device_string, current_board); if (open_dev(&fd, devbase) < 0) - errx(EX_IOERR, "%s: Error opening board #%d in recv_data\n", __func__, current_board); + err(EX_IOERR, "%s: Error opening firewire controller #%d %s in recv_data\n", __func__, current_board, devbase); (*recvfn)(fd, recv_data, TAG | CHANNEL, -1); free(recv_data); } --------------060505030505030501040100-- From owner-freebsd-firewire@FreeBSD.ORG Fri Dec 12 05:08:06 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 12FD91065670 for ; Fri, 12 Dec 2008 05:08:06 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from sopwith.solgatos.com (pool-71-182-69-106.ptldor.fios.verizon.net [71.182.69.106]) by mx1.freebsd.org (Postfix) with ESMTP id 931F28FC16 for ; Fri, 12 Dec 2008 05:08:05 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: by sopwith.solgatos.com (Postfix, from userid 66) id 8E4E33F4E; Thu, 11 Dec 2008 21:01:34 -0800 (PST) Received: from localhost by sopwith.solgatos.com (8.8.8/6.24) id AAA09682; Fri, 12 Dec 2008 00:50:14 GMT Message-Id: <200812120050.AAA09682@sopwith.solgatos.com> To: Sean Bruno , freebsd-firewire@freebsd.org In-reply-to: Your message of "Thu, 11 Dec 2008 15:10:19 PST." <49419DDB.3080900@miralink.com> Date: Thu, 11 Dec 2008 16:50:14 +0000 From: Dieter Cc: Subject: Re: patch for fwcontrol X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Dec 2008 05:08:06 -0000 > Ah, and then I go and start changing stuff. Quick! Check it in before one of us gets another idea of something to change! :-)