From cbb4749a12d755ce0b7668e6e40590eb7d09dd18 Mon Sep 17 00:00:00 2001 From: simokawa Date: Fri, 2 May 2008 06:17:16 +0000 Subject: [PATCH] MFC: add -f option and other small fixes firewire.8 rev 1.22 firewire.c rev 1.24 --- usr.sbin/fwcontrol/fwcontrol.8 | 7 ++++++- usr.sbin/fwcontrol/fwcontrol.c | 24 +++++++++++++++++------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/usr.sbin/fwcontrol/fwcontrol.8 b/usr.sbin/fwcontrol/fwcontrol.8 index 36926ab88898..c26b3c9b66e2 100644 --- a/usr.sbin/fwcontrol/fwcontrol.8 +++ b/usr.sbin/fwcontrol/fwcontrol.8 @@ -39,6 +39,7 @@ .Op Fl o Ar node .Op Fl s Ar node .Op Fl l Ar file +.Op Fl f Ar node .Op Fl g Ar gap_count .Op Fl b Ar pri_req .Op Fl M Ar mode @@ -77,6 +78,10 @@ Write to the register on the node. .It Fl l Ar file Load hex dump file of the configuration ROM and parse it. +.It Fl f Ar node +Force specified +.Ar node +to be the root node on the next bus reset. .It Fl g Ar gap_count Broadcast .Ar gap_count @@ -98,7 +103,7 @@ an error complaining about "format 0x20", try to force the "mpeg" mode. .It Fl R Ar filename Receive DV or MPEG TS stream and dump it to a file. Use Ctrl-C to stop the receiving. -Some DV cameras seem not to send the stream if a bus manager exits. +Some DV cameras seem not to send the stream if a bus manager exists. If you cannot get the stream, try the following commands: .Bd -literal -offset indent sysctl hw.firewire.try_bmr=0 diff --git a/usr.sbin/fwcontrol/fwcontrol.c b/usr.sbin/fwcontrol/fwcontrol.c index de4206e01254..d7c5288de068 100644 --- a/usr.sbin/fwcontrol/fwcontrol.c +++ b/usr.sbin/fwcontrol/fwcontrol.c @@ -64,10 +64,12 @@ static void usage(void) { fprintf(stderr, - "fwcontrol [-u bus_num] [-rt] [-g gap_count] [-o node] " + "fwcontrol [-u bus_num] [-rt] [-f node] [-g gap_count] " + "[-o node] " "[-b pri_req] [-c node] [-d node] [-l file] " "[-R file] [-S file] [-m target]\n" "\t-u: specify bus number\n" + "\t-f: broadcast force_root by phy_config packet\n" "\t-g: broadcast gap_count by phy_config packet\n" "\t-o: send link-on packet to the node\n" "\t-s: write RESET_START register on the node\n" @@ -153,20 +155,23 @@ list_dev(int fd) struct fw_devlstreq *data; struct fw_devinfo *devinfo; struct eui64 eui; - char addr[EUI64_SIZ]; + char addr[EUI64_SIZ], hostname[40]; int i; data = get_dev(fd); printf("%d devices (info_len=%d)\n", data->n, data->info_len); - printf("node EUI64 status\n"); + printf("node EUI64 status hostname\n"); for (i = 0; i < data->info_len; i++) { devinfo = &data->dev[i]; fweui2eui64(&devinfo->eui, &eui); eui64_ntoa(&eui, addr, sizeof(addr)); - printf("%4d %s %6d\n", + if (eui64_ntohost(hostname, sizeof(hostname), &eui)) + hostname[0] = 0; + printf("%4d %s %6d %s\n", (devinfo->status || i == 0) ? devinfo->dst : -1, addr, - devinfo->status + devinfo->status, + hostname ); } free((void *)data); @@ -198,7 +203,7 @@ read_write_quad(int fd, struct fw_eui64 eui, u_int32_t addr_lo, int readmode, u_ qld = (u_int32_t *)&asyreq->pkt; if (!readmode) - asyreq->pkt.mode.wreqq.data = data; + asyreq->pkt.mode.wreqq.data = htonl(data); if (ioctl(fd, FW_ASYREQ, asyreq) < 0) { err(1, "ioctl"); @@ -676,7 +681,7 @@ main(int argc, char **argv) list_dev(fd); } - while ((ch = getopt(argc, argv, "M:g:m:o:s:b:prtc:d:l:u:R:S:")) != -1) + while ((ch = getopt(argc, argv, "M:f:g:m:o:s:b:prtc:d:l:u:R:S:")) != -1) switch(ch) { case 'b': tmp = strtol(optarg, NULL, 0); @@ -697,6 +702,11 @@ main(int argc, char **argv) get_crom(fd, tmp, crom_buf, len); dump_crom(crom_buf); break; + case 'f': + tmp = strtol(optarg, NULL, 0); + open_dev(&fd, devbase); + send_phy_config(fd, tmp, -1); + break; case 'g': tmp = strtol(optarg, NULL, 0); open_dev(&fd, devbase);