From owner-freebsd-audit Sun Sep 23 2:17:54 2001 Delivered-To: freebsd-audit@freebsd.org Received: from mao.stokely.org (mao.stokely.org [65.84.64.228]) by hub.freebsd.org (Postfix) with ESMTP id 5E53837B403 for ; Sun, 23 Sep 2001 02:17:52 -0700 (PDT) Received: by mao.stokely.org (Postfix, from userid 2074) id A5E864B667; Sun, 23 Sep 2001 02:17:51 -0700 (PDT) Date: Sun, 23 Sep 2001 02:17:51 -0700 From: murray@stokely.org To: Bruce Evans Cc: freebsd-audit@FreeBSD.org Subject: Re: cvs commit: src/usr.sbin/sysinstall command.c config.c Message-ID: <20010923021751.A6105@windriver.com> References: <200109222234.f8MMYE643596@freefall.freebsd.org> <20010923180124.I13390-100000@delplex.bde.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010923180124.I13390-100000@delplex.bde.org>; from bde@zeta.org.au on Sun, Sep 23, 2001 at 06:06:02PM +1000 X-GPG-Key-ID: 1024D/0E451F7D X-GPG-Key-Fingerprint: E2CA 411D DD44 53FD BB4B 3CB5 B4D7 10A2 0E45 1F7D Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sun, Sep 23, 2001 at 06:06:02PM +1000, Bruce Evans wrote: > > Silence warnings on alpha : > > > > Use '%p' when printing out the address of a function. > > sizeof(int) != sizeof(long) > > %p is for printing pointers of type "void *". It is unsuitable for > printing arbitrary pointers to objects. It is especially unsuitable > for printing pointers to functions. Hmm. What should be used instead? - Murray To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sun Sep 23 5:27:41 2001 Delivered-To: freebsd-audit@freebsd.org Received: from salmon.maths.tcd.ie (salmon.maths.tcd.ie [134.226.81.11]) by hub.freebsd.org (Postfix) with SMTP id 8F98237B406 for ; Sun, 23 Sep 2001 05:27:30 -0700 (PDT) Received: from walton.maths.tcd.ie by salmon.maths.tcd.ie with SMTP id ; 23 Sep 2001 13:27:29 +0100 (BST) To: freebsd-audit@freebsd.org Subject: ping -A Date: Sun, 23 Sep 2001 13:27:29 +0100 From: Ian Dowse Message-ID: <200109231327.aa81352@salmon.maths.tcd.ie> Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Some time ago, a '-A' (audible beep when packets are dropped) option was added to ping in -current only. The logic in its implementation isn't quite right; once one packet is dropped, it beeps after every transmission. Here is a patch that should make it work in a more useful way. It only outputs a bell when there is an increase in the maximum number of unreceived packets. This has the benefit that for very long round-trip times, ping -A will do the right thing after a few inital false-positives. Any comments? Ian Index: ping.8 =================================================================== RCS file: /dump/FreeBSD-CVS/src/sbin/ping/ping.8,v retrieving revision 1.32 diff -u -r1.32 ping.8 --- ping.8 7 Aug 2001 15:48:36 -0000 1.32 +++ ping.8 23 Sep 2001 12:11:37 -0000 @@ -32,7 +32,7 @@ .\" @(#)ping.8 8.2 (Berkeley) 12/11/93 .\" $FreeBSD: src/sbin/ping/ping.8,v 1.32 2001/08/07 15:48:36 ru Exp $ .\" -.Dd March 1, 1997 +.Dd September 23, 2001 .Dt PING 8 .Os .Sh NAME @@ -81,11 +81,14 @@ .Bl -tag -width indent .It Fl A Audible. -Include a bell +Output a bell .Tn ( ASCII 0x07) -character in the output when no packet is received before the next packet +character when no packet is received before the next packet is transmitted. +To cater for round-trip times that are longer than the transmitting +interval, further missing packets cause a bell only if the maximum +number of unreceived packets has increased. .It Fl a Audible. Include a bell Index: ping.c =================================================================== RCS file: /dump/FreeBSD-CVS/src/sbin/ping/ping.c,v retrieving revision 1.59 diff -u -r1.59 ping.c --- ping.c 7 Jul 2001 19:09:21 -0000 1.59 +++ ping.c 23 Sep 2001 11:12:05 -0000 @@ -163,6 +163,7 @@ long nreceived; /* # of packets we got back */ long nrepeats; /* number of duplicates */ long ntransmitted; /* sequence # for outbound packets = #sent */ +long nmissedmax; /* max value of ntransmitted - nreceived - 1 */ int interval = 1000; /* interval between packets, ms */ /* timing */ @@ -706,8 +707,11 @@ } (void)gettimeofday(&last, NULL); - if (ntransmitted != nreceived+1 && options & F_MISSED) - (void)write(STDOUT_FILENO, &BBELL, 1); + if (ntransmitted - nreceived - 1 > nmissedmax) { + nmissedmax = ntransmitted - nreceived - 1; + if (options & F_MISSED) + (void)write(STDOUT_FILENO, &BBELL, 1); + } } } finish(); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sun Sep 23 14:30:23 2001 Delivered-To: freebsd-audit@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 4E17637B416 for ; Sun, 23 Sep 2001 14:30:18 -0700 (PDT) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id HAA32581; Mon, 24 Sep 2001 07:30:10 +1000 Date: Mon, 24 Sep 2001 07:29:39 +1000 (EST) From: Bruce Evans X-X-Sender: To: Cc: Subject: Re: cvs commit: src/usr.sbin/sysinstall command.c config.c In-Reply-To: <20010923021751.A6105@windriver.com> Message-ID: <20010924072107.K17957-100000@delplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sun, 23 Sep 2001 murray@stokely.org wrote: > On Sun, Sep 23, 2001 at 06:06:02PM +1000, Bruce Evans wrote: > > > Silence warnings on alpha : > > > > > > Use '%p' when printing out the address of a function. > > > sizeof(int) != sizeof(long) > > > > %p is for printing pointers of type "void *". It is unsuitable for > > printing arbitrary pointers to objects. It is especially unsuitable > > for printing pointers to functions. > > Hmm. What should be used instead? There is no portable way. Unportable ways: 1) Any object can be printed by treating it as an array of bytes. 2) Program profiling in FreeBSD assumes that there is an integral type uintfptr_t that can represent function pointers in the same way that the standard type uintptr_t can represent "void *"'s (if it exists). It's interesting that tcc (Tendra C) permits casting pointers to functions to int but not to "void *". Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sun Sep 23 20:13: 2 2001 Delivered-To: freebsd-audit@freebsd.org Received: from mail.rpi.edu (mail.rpi.edu [128.113.22.40]) by hub.freebsd.org (Postfix) with ESMTP id 1768637B417 for ; Sun, 23 Sep 2001 20:12:54 -0700 (PDT) Received: from [128.113.24.47] (gilead.acs.rpi.edu [128.113.24.47]) by mail.rpi.edu (8.11.3/8.11.3) with ESMTP id f8O3Cei56082; Sun, 23 Sep 2001 23:12:40 -0400 Mime-Version: 1.0 X-Sender: drosih@mail.rpi.edu Message-Id: Date: Sun, 23 Sep 2001 23:12:38 -0400 To: freebsd-audit@freebsd.org From: Garance A Drosihn Subject: Patch to sort rtn of 'lpc clean' Content-Type: text/plain; charset="us-ascii" ; format="flowed" Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG The 'lpc clean' command has a routine to sort filenames which it finds in a spool directory, which it calls when deciding which datafiles do not have a matching control-file. That sort routine makes a number of assumptions about the filenames it will see, assumptions which are usually safe to make. However, if one turns on 'LEAVE_TMPCF_FILES' in common_source/ctlinfo.c (because you're interested in debugging *that*), then the assumptions in this sort routine go haywire and 'lpc clean' can end up removing some valid user jobs. This is not good. So, here's a new improved 'sortq' routine for lpc. This does not include all the testing code that I had in here while testing it at RPI, but that testing showed that this version gets the same results as the old version, except for the cases where the old version was getting the wrong result. I did leave in the new debugging function of 'lpc tclean -d all', so you can see what the result of the sort is. While I'm pretty sure it works correctly, I thought I'd post it here in case there are any major style mixups, or subtle security issues (lpc is running as 'root' while this routine is being executed). The patch is also available at: http://people.freebsd.org/~gad/lpr/lpc-clean-sort.diff (in case it doesn't get formatted correctly here...) Index: lpc/cmds.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/lpr/lpc/cmds.c,v retrieving revision 1.19 diff -r1.19 cmds.c 335,336c335,342 < * Comparison routine for scandir. Sort by job number and machine, then < * by `cf', `tf', or `df', then by the sequence letter A-Z, a-z. --- > * Comparison routine that clean_q() uses for scandir. > * > * The purpose of this sort is to have all `df' files end up immediately > * after the matching `cf' file. For files matching `cf', `df', or `tf', > * it sorts by job number and machine, then by `cf', `df', or `tf', then > * by the sequence letter A-Z, a-z. This routine may also see filenames > * which do not start with `cf', `df', or `tf' (such as `errs.*'), and > * those are simply sorted by the full filename. 341,342c347,349 < const struct dirent **d1, **d2; < int c1, c2; --- > const int a_lt_b = -1, a_gt_b = 1, cat_other = 10; > const char *fname_a, *fname_b, *jnum_a, *jnum_b; > int cat_a, cat_b, ch, res; 344,356c351,424 < d1 = (const struct dirent **)a; < d2 = (const struct dirent **)b; < if ((c1 = strcmp((*d1)->d_name + 3, (*d2)->d_name + 3))) < return(c1); < c1 = (*d1)->d_name[0]; < c2 = (*d2)->d_name[0]; < if (c1 == c2) < return((*d1)->d_name[2] - (*d2)->d_name[2]); < if (c1 == 'c') < return(-1); < if (c1 == 'd' || c2 == 'c') < return(1); < return(-1); --- > fname_a = (*(const struct dirent **)a)->d_name; > fname_b = (*(const struct dirent **)b)->d_name; > > /* > * First separate filenames into cagatories. Catagories are > * legitimate `cf', `df', & `tf' filenames, and "other" - in > * that order. It is critical that the mapping be exactly > * the same for 'a' vs 'b', so define a macro for the job. > * > * [aside: the standard `cf' file has the jobnumber start in > * in position 4, but some implementations have that as an > * extra letter, and start the job number in position 5.] > */ > #define MAP_TO_CAT(fname_X,jnum_X,cat_X) do { \ > cat_X = cat_other; \ > ch = *(fname_X + 2); \ > jnum_X = fname_X + 3; \ > if ((*(fname_X + 1) == 'f') && (isalpha(ch))) { \ > if (*fname_X == 'c') \ > cat_X = 1; \ > else if (*fname_X == 'd') \ > cat_X = 2; \ > else if (*fname_X == 't') \ > cat_X = 3; \ > if (cat_X != cat_other) { \ > ch = *jnum_X; \ > if (!isdigit(ch)) { \ > if (isalpha(ch)) { \ > jnum_X++; \ > ch = *jnum_X; \ > } \ > if (!isdigit(ch)) \ > cat_X = cat_other; \ > } \ > } \ > } \ > } while (0) > > MAP_TO_CAT(fname_a, jnum_a, cat_a); > MAP_TO_CAT(fname_b, jnum_b, cat_b); > > #undef MAP_TO_CAT > > /* First handle all cases with "other" files */ > if ((cat_a >= cat_other) || (cat_b >= cat_other)) { > /* for two "other" files, just compare the full name */ > if (cat_a == cat_b) > res = strcmp(fname_a, fname_b); > else if (cat_a < cat_b) > res = a_lt_b; > else > res = a_gt_b; > goto have_res; > } > > /* > * At this point, we know both files are legitimate `cf', `df', > * or `tf' files. Compare them by job-number and machine name. > */ > res = strcmp(jnum_a, jnum_b); > if (res != 0) > goto have_res; > > /* > * We have two files which belong to the same job. Sort based > * on the catagory of file. > */ > if (cat_a < cat_b) > res = a_lt_b; > else > res = a_gt_b; > > have_res: > return res; 386c454 < cln_debug = 1; --- > cln_debug++; 456a525,533 > if (cln_debug) { > printf("\t** ----- Sorted list of files being checked:\n"); > i = 0; > do { > cp = queue[i]->d_name; > printf("\t** [%3d] = %s\n", i, cp); > } while (++i < nitems); > printf("\t** ----- end of sorted list\n"); > } 549c626 < if (cln_debug) { --- > if (cln_debug > 1) { -- Garance Alistair Drosehn = gad@eclipse.acs.rpi.edu Senior Systems Programmer or gad@freebsd.org Rensselaer Polytechnic Institute or drosih@rpi.edu To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Mon Sep 24 4:43:37 2001 Delivered-To: freebsd-audit@freebsd.org Received: from whale.sunbay.crimea.ua (whale.sunbay.crimea.ua [212.110.138.65]) by hub.freebsd.org (Postfix) with ESMTP id C9C8E37B405 for ; Mon, 24 Sep 2001 04:42:49 -0700 (PDT) Received: (from ru@localhost) by whale.sunbay.crimea.ua (8.11.2/8.11.2) id f8OBgMa60546; Mon, 24 Sep 2001 14:42:22 +0300 (EEST) (envelope-from ru) Date: Mon, 24 Sep 2001 14:42:22 +0300 From: Ruslan Ermilov To: Ian Dowse Cc: freebsd-audit@FreeBSD.ORG Subject: Re: ping -A Message-ID: <20010924144222.H50028@sunbay.com> References: <200109231327.aa81352@salmon.maths.tcd.ie> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200109231327.aa81352@salmon.maths.tcd.ie>; from iedowse@maths.tcd.ie on Sun, Sep 23, 2001 at 01:27:29PM +0100 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Looks like a winner to me. On Sun, Sep 23, 2001 at 01:27:29PM +0100, Ian Dowse wrote: > > Some time ago, a '-A' (audible beep when packets are dropped) option > was added to ping in -current only. The logic in its implementation > isn't quite right; once one packet is dropped, it beeps after every > transmission. > > Here is a patch that should make it work in a more useful way. It > only outputs a bell when there is an increase in the maximum number > of unreceived packets. This has the benefit that for very long > round-trip times, ping -A will do the right thing after a few > inital false-positives. > > Any comments? > > Ian -- Ruslan Ermilov Oracle Developer/DBA, ru@sunbay.com Sunbay Software AG, ru@FreeBSD.org FreeBSD committer, +380.652.512.251 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Sep 27 10:24: 2 2001 Delivered-To: freebsd-audit@freebsd.org Received: from mail.rpi.edu (mail.rpi.edu [128.113.22.40]) by hub.freebsd.org (Postfix) with ESMTP id BB20137B41C for ; Thu, 27 Sep 2001 10:23:55 -0700 (PDT) Received: from [128.113.24.47] (gilead.acs.rpi.edu [128.113.24.47]) by mail.rpi.edu (8.11.3/8.11.3) with ESMTP id f8RHNrx54568 for ; Thu, 27 Sep 2001 13:23:54 -0400 Mime-Version: 1.0 X-Sender: drosih@mail.rpi.edu Message-Id: In-Reply-To: References: Date: Thu, 27 Sep 2001 13:23:51 -0400 To: freebsd-audit@FreeBSD.ORG From: Garance A Drosihn Subject: Re: Patch to sort rtn of 'lpc clean' Content-Type: text/plain; charset="us-ascii" ; format="flowed" Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG At 11:12 PM -0400 9/23/01, Garance A Drosihn wrote: >So, here's a new improved 'sortq' routine for lpc. This does not >include all the testing code that I had in here while testing it at >RPI, but that testing showed that this version gets the same results >as the old version, except for the cases where the old version was >getting the wrong result. I did leave in the new debugging function >of 'lpc tclean -d all', so you can see what the result of the sort is. In case anyone's curious, this change was just committed to 'lpc' in the freebsd-current branch. But as I read my earlier message a little closer, I see that I had included an early version of the patch, and that one DID have one bug in the sorting... But the version I did commit has been running in production at RPI for awhile now, and has been doing the right things. (at RPI, an 'lpc clean all' command is run every night, on all our print servers, and the output is emailed to me...) -- Garance Alistair Drosehn = gad@eclipse.acs.rpi.edu Senior Systems Programmer or gad@freebsd.org Rensselaer Polytechnic Institute or drosih@rpi.edu To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Sep 27 10:56:31 2001 Delivered-To: freebsd-audit@freebsd.org Received: from mail.rpi.edu (mail.rpi.edu [128.113.22.40]) by hub.freebsd.org (Postfix) with ESMTP id C692F37B43B for ; Thu, 27 Sep 2001 10:56:28 -0700 (PDT) Received: from [128.113.24.47] (gilead.acs.rpi.edu [128.113.24.47]) by mail.rpi.edu (8.11.3/8.11.3) with ESMTP id f8RHuQx25784; Thu, 27 Sep 2001 13:56:27 -0400 Mime-Version: 1.0 X-Sender: drosih@mail.rpi.edu Message-Id: In-Reply-To: References: <20010718145258.1d829df6.david@phobia.ms> Date: Thu, 27 Sep 2001 13:56:23 -0400 To: audit@FreeBSD.ORG From: Garance A Drosihn Subject: Re: strlcpy patches Cc: David Hill Content-Type: text/plain; charset="us-ascii" ; format="flowed" Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG People with good memories might remember that back on July 22/2001, I (Garance A Drosihn) wrote: >At 2:52 PM -0400 7/18/01, David Hill wrote: >>Greetings. >>I have patched some source files replacing: >> >> strncpy(dst, src, sizeof(dst) - 1); >> dst[sizeof(dst)-1] = '\0'; >>with >> strlcpy(dst, src, sizeof dst); >> >>They are located at http://www.phobia.ms/patches > >I have committed changes with similar intent to current for the >files under usr.sbin/lpr, and will MFC them next weekend. I >then intend to do almost no work in freebsd for the month of >August (partially due to 4.4, and partially because I'll be too >busy here at work). If no one else has picked up your strlcpy >changes by the time I get back to making changes, I'll see about >applying these patches to other source files. Well, it looks like I'm finally getting to a "less busy" time, so I'm going to go thru these and commit them. I intend to break up the commits into "a program's worth at a time", instead of doing them all in one big massive commit. Should I post each of those here for a second review, or just go ahead and make the commits to -current? [it'll probably be a week or so before the commits start showing up, as I want to run with the changes for a little while before commits] -- Garance Alistair Drosehn = gad@eclipse.acs.rpi.edu Senior Systems Programmer or gad@freebsd.org Rensselaer Polytechnic Institute or drosih@rpi.edu To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Sep 27 11:58:41 2001 Delivered-To: freebsd-audit@freebsd.org Received: from freebsd.org.ru (sweet.etrust.ru [194.84.67.5]) by hub.freebsd.org (Postfix) with ESMTP id 51DE537B419 for ; Thu, 27 Sep 2001 11:58:22 -0700 (PDT) Received: by freebsd.org.ru (Postfix, from userid 1000) id B7DC6269; Thu, 27 Sep 2001 22:58:14 +0400 (MSD) Date: Thu, 27 Sep 2001 22:58:14 +0400 From: "Sergey A. Osokin" To: audit@FreeBSD.org Subject: iostat(8) WARNS=2 cleanup Message-ID: <20010927225814.A46080@freebsd.org.ru> Reply-To: osa@FreeBSD.org.ru Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="vkogqOf2sHV7VnPd" Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.3.22.1i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --vkogqOf2sHV7VnPd Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: 8bit Hello. Please review patch. Thanks. -- Rgdz, /"\ Sergey Osokin aka oZZ, \ / ASCII RIBBON CAMPAIGN osa@freebsd.org.ru X AGAINST HTML MAIL http://freebsd.org.ru/~osa/ / \ --vkogqOf2sHV7VnPd Content-Type: text/plain; charset=koi8-r Content-Disposition: attachment; filename=patch-iostat Content-Transfer-Encoding: 8bit diff -ruN iostat.orig/Makefile iostat/Makefile --- iostat.orig/Makefile Mon Sep 24 13:20:34 2001 +++ iostat/Makefile Mon Sep 24 12:58:56 2001 @@ -8,4 +8,6 @@ LDADD= -lkvm -ldevstat -lm MAN= iostat.8 +WARNS?= 2 + .include diff -ruN iostat.orig/iostat.c iostat/iostat.c --- iostat.orig/iostat.c Mon Sep 24 13:20:34 2001 +++ iostat/iostat.c Mon Sep 24 13:19:01 2001 @@ -118,19 +118,13 @@ #include #include -struct nlist namelist[] = { #define X_TK_NIN 0 - { "_tk_nin" }, #define X_TK_NOUT 1 - { "_tk_nout" }, #define X_CP_TIME 2 - { "_cp_time" }, #define X_BOOTTIME 3 - { "_boottime" }, #define X_END 3 - { NULL }, -}; +struct nlist namelist[5]; struct statinfo cur, last; int num_devices; struct device_selection *dev_select; @@ -141,7 +135,7 @@ /* local function declarations */ static void usage(void); static void phdr(int signo); -static void do_phdr(); +static void do_phdr(void); static void devstats(int perf_select, long double etime, int havelast); static void cpustats(void); static int readvar(kvm_t *kd, const char *name, int nlid, void *ptr, @@ -185,6 +179,12 @@ matches = NULL; maxshowdevs = 3; + (const char *)namelist[X_TK_NIN].n_name = "_tk_nin"; + (const char *)namelist[X_TK_NOUT].n_name = "_tk_nout"; + (const char *)namelist[X_CP_TIME].n_name = "_cp_time"; + (const char *)namelist[X_BOOTTIME].n_name = "_boottime"; + namelist[4].n_name = NULL; + while ((c = getopt(argc, argv, "c:CdhIKM:n:N:ot:Tw:?")) != -1) { switch(c) { case 'c': @@ -580,12 +580,12 @@ static void phdr(int signo) { - - phdr_flag = 1; + if (signo == SIGCONT) + phdr_flag = 1; } static void -do_phdr() +do_phdr(void) { register int i; int printed; @@ -722,22 +722,22 @@ cpustats(void) { register int state; - double time; + double ttime; - time = 0.0; + ttime = 0.0; for (state = 0; state < CPUSTATES; ++state) - time += cur.cp_time[state]; + ttime += cur.cp_time[state]; for (state = 0; state < CPUSTATES; ++state) printf("%3.0f", - rint(100. * cur.cp_time[state] / (time ? time : 1))); + rint(100. * cur.cp_time[state] / (ttime ? ttime : 1))); } static int readvar(kvm_t *kd, const char *name, int nlid, void *ptr, size_t len) { if (kd != NULL) { - ssize_t nbytes; + size_t nbytes; nbytes = kvm_read(kd, nlid, ptr, len); --vkogqOf2sHV7VnPd-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Sep 27 18:39:12 2001 Delivered-To: freebsd-audit@freebsd.org Received: from odin.ac.hmc.edu (Odin.AC.HMC.Edu [134.173.32.75]) by hub.freebsd.org (Postfix) with ESMTP id 6B2BA37B40D; Thu, 27 Sep 2001 18:38:07 -0700 (PDT) Received: (from brdavis@localhost) by odin.ac.hmc.edu (8.11.0/8.11.0) id f8S1c2h17216; Thu, 27 Sep 2001 18:38:02 -0700 Date: Thu, 27 Sep 2001 18:38:02 -0700 From: Brooks Davis To: mobile@freebsd.org, audit@freebsd.org Subject: call for review/test: wi probe/attach split Message-ID: <20010927183802.A16104@Odin.AC.HMC.Edu> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="jI8keyz6grp/JLjh" Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --jI8keyz6grp/JLjh Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable I've modified the wi driver to split the pccard and pci probe/attach code into seperate files to eliminate the current icky NPCI hack. I've been able to compile it with both non-pccard and non-pci kernel configs, but I don't actually have any card supported by wi at the moment so I can't test it. I've attached the patch against current and will also update a copy at: http://people.freebsd.org/~brooks/patches/wi.diff -- Brooks Index: sys/conf/files =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /usr/cvs/src/sys/conf/files,v retrieving revision 1.571 diff -u -r1.571 files --- sys/conf/files 27 Sep 2001 21:54:26 -0000 1.571 +++ sys/conf/files 28 Sep 2001 01:27:51 -0000 @@ -601,6 +601,9 @@ dev/wds/wd7000.c optional wds isa dev/wi/if_wi.c optional wi dev/wi/if_wi.c optional wi pccard +dev/wi/if_wi_pccard.c optional wi card +dev/wi/if_wi_pccard.c optional wi pccard +dev/wi/if_wi_pci.c optional wi pci dev/wl/if_wl.c optional wl isa dev/xe/if_xe.c optional xe card fs/deadfs/dead_vnops.c standard Index: sys/dev/wi/if_wi.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /usr/cvs/src/sys/dev/wi/if_wi.c,v retrieving revision 1.61 diff -u -r1.61 if_wi.c --- sys/dev/wi/if_wi.c 12 Sep 2001 08:37:16 -0000 1.61 +++ sys/dev/wi/if_wi.c 27 Sep 2001 23:25:51 -0000 @@ -66,55 +66,35 @@ #define WI_HERMES_STATS_WAR /* Work around stats counter bug. */ #define WICACHE /* turn on signal strength cache code */ =20 =20 -#include "pci.h" - #include -#include #include -#include #include #include #include -#include #include #include #include =20 #include #include -#include -#include #include =20 -#if NPCI > 0 -#include -#include -#endif - #include #include #include #include #include -#include #include =20 #include #include -#include #include -#include =20 #include =20 -#include -#include - #include #include =20 -#include "card_if.h" - #if !defined(lint) static const char rcsid[] =3D "$FreeBSD: src/sys/dev/wi/if_wi.c,v 1.61 2001/09/12 08:37:16 julian Exp = $"; @@ -155,144 +135,14 @@ struct mbuf *, unsigned short)); #endif =20 -static int wi_generic_attach __P((device_t)); -static int wi_pccard_match __P((device_t)); -static int wi_pccard_probe __P((device_t)); -static int wi_pccard_attach __P((device_t)); -#if NPCI > 0 -static int wi_pci_probe __P((device_t)); -static int wi_pci_attach __P((device_t)); -#endif -static int wi_pccard_detach __P((device_t)); -static void wi_shutdown __P((device_t)); - -static int wi_alloc __P((device_t, int)); -static void wi_free __P((device_t)); - static int wi_get_cur_ssid __P((struct wi_softc *, char *, int *)); static int wi_media_change __P((struct ifnet *)); static void wi_media_status __P((struct ifnet *, struct ifmediareq *)); =20 -static device_method_t wi_pccard_methods[] =3D { - /* Device interface */ - DEVMETHOD(device_probe, pccard_compat_probe), - DEVMETHOD(device_attach, pccard_compat_attach), - DEVMETHOD(device_detach, wi_pccard_detach), - DEVMETHOD(device_shutdown, wi_shutdown), - - /* Card interface */ - DEVMETHOD(card_compat_match, wi_pccard_match), - DEVMETHOD(card_compat_probe, wi_pccard_probe), - DEVMETHOD(card_compat_attach, wi_pccard_attach), - - { 0, 0 } -}; - -#if NPCI > 0 -static device_method_t wi_pci_methods[] =3D { - /* Device interface */ - DEVMETHOD(device_probe, wi_pci_probe), - DEVMETHOD(device_attach, wi_pci_attach), - DEVMETHOD(device_detach, wi_pccard_detach), - DEVMETHOD(device_shutdown, wi_shutdown), - - { 0, 0 } -}; -#endif - -static driver_t wi_pccard_driver =3D { - "wi", - wi_pccard_methods, - sizeof(struct wi_softc) -}; - -#if NPCI > 0 -static driver_t wi_pci_driver =3D { - "wi", - wi_pci_methods, - sizeof(struct wi_softc) -}; - -static struct { - unsigned int vendor,device; - char *desc; -} pci_ids[] =3D { - {0x1638, 0x1100, "PRISM2STA PCI WaveLAN/IEEE 802.11"}, - {0x1385, 0x4100, "Netgear MA301 PCI IEEE 802.11b"}, - {0, 0, NULL} -}; -#endif - -static devclass_t wi_devclass; - -DRIVER_MODULE(if_wi, pccard, wi_pccard_driver, wi_devclass, 0, 0); -#if NPCI > 0 -DRIVER_MODULE(if_wi, pci, wi_pci_driver, wi_devclass, 0, 0); -#endif - -static const struct pccard_product wi_pccard_products[] =3D { - { PCCARD_STR_LUCENT_WAVELAN_IEEE, PCCARD_VENDOR_LUCENT, - PCCARD_PRODUCT_LUCENT_WAVELAN_IEEE, 0,=20 - PCCARD_CIS_LUCENT_WAVELAN_IEEE }, -}; - -static int wi_pccard_match(dev) - device_t dev; -{ - const struct pccard_product *pp; - - if ((pp =3D pccard_product_lookup(dev, wi_pccard_products, - sizeof(wi_pccard_products[0]), NULL)) !=3D NULL) { - device_set_desc(dev, pp->pp_name); - return 0; - } - return ENXIO; -} - -static int wi_pccard_probe(dev) - device_t dev; -{ - struct wi_softc *sc; - int error; +devclass_t wi_devclass; =20 - sc =3D device_get_softc(dev); - sc->wi_gone =3D 0; - - error =3D wi_alloc(dev, 0); - if (error) - return (error); - - wi_free(dev); - - /* Make sure interrupts are disabled. */ - CSR_WRITE_2(sc, WI_INT_EN, 0); - CSR_WRITE_2(sc, WI_EVENT_ACK, 0xFFFF); - - return (0); -} - -#if NPCI > 0 -static int -wi_pci_probe(dev) - device_t dev; -{ - struct wi_softc *sc; - int i; - - sc =3D device_get_softc(dev); - for(i=3D0; pci_ids[i].vendor !=3D 0; i++) { - if ((pci_get_vendor(dev) =3D=3D pci_ids[i].vendor) && - (pci_get_device(dev) =3D=3D pci_ids[i].device)) { - sc->wi_prism2 =3D 1; - device_set_desc(dev, pci_ids[i].desc); - return (0); - } - } - return(ENXIO); -} -#endif - -static int wi_pccard_detach(dev) +int +wi_detach(dev) device_t dev; { struct wi_softc *sc; @@ -324,127 +174,7 @@ return(0); } =20 -static int wi_pccard_attach(device_t dev) -{ - struct wi_softc *sc; - int error; - u_int32_t flags; - - sc =3D device_get_softc(dev); - - /* - * XXX: quick hack to support Prism II chip. - * Currently, we need to set a flags in pccard.conf to specify - * which type chip is used. - * - * We need to replace this code in a future. - * It is better to use CIS than using a flag. - */ - flags =3D device_get_flags(dev); -#define WI_FLAGS_PRISM2 0x10000 - if (flags & WI_FLAGS_PRISM2) { - sc->wi_prism2 =3D 1; - if (bootverbose) { - device_printf(dev, "found PrismII chip\n"); - } - } - else { - sc->wi_prism2 =3D 0; - if (bootverbose) { - device_printf(dev, "found Lucent chip\n"); - } - } - - error =3D wi_alloc(dev, 0); - if (error) { - device_printf(dev, "wi_alloc() failed! (%d)\n", error); - return (error); - } - return (wi_generic_attach(dev)); -} - -#if NPCI > 0 -static int -wi_pci_attach(device_t dev) -{ - struct wi_softc *sc; - u_int32_t command, wanted; - u_int16_t reg; - int error; - - sc =3D device_get_softc(dev); - - command =3D pci_read_config(dev, PCIR_COMMAND, 4); - wanted =3D PCIM_CMD_PORTEN|PCIM_CMD_MEMEN; - command |=3D wanted; - pci_write_config(dev, PCIR_COMMAND, command, 4); - command =3D pci_read_config(dev, PCIR_COMMAND, 4); - if ((command & wanted) !=3D wanted) { - device_printf(dev, "wi_pci_attach() failed to enable pci!\n"); - return (ENXIO); - } - - error =3D wi_alloc(dev, WI_PCI_IORES); - if (error) - return (error); - - /* Make sure interrupts are disabled. */ - CSR_WRITE_2(sc, WI_INT_EN, 0); - CSR_WRITE_2(sc, WI_EVENT_ACK, 0xFFFF); - - /* We have to do a magic PLX poke to enable interrupts */ - sc->local_rid =3D WI_PCI_LOCALRES; - sc->local =3D bus_alloc_resource(dev, SYS_RES_IOPORT, - &sc->local_rid, 0, ~0, 1, RF_ACTIVE); - sc->wi_localtag =3D rman_get_bustag(sc->local); - sc->wi_localhandle =3D rman_get_bushandle(sc->local); - command =3D bus_space_read_4(sc->wi_localtag, sc->wi_localhandle, - WI_LOCAL_INTCSR); - command |=3D WI_LOCAL_INTEN; - bus_space_write_4(sc->wi_localtag, sc->wi_localhandle, - WI_LOCAL_INTCSR, command); - bus_release_resource(dev, SYS_RES_IOPORT, sc->local_rid, sc->local); - sc->local =3D NULL; - - sc->mem_rid =3D WI_PCI_MEMRES; - sc->mem =3D bus_alloc_resource(dev, SYS_RES_MEMORY, &sc->mem_rid, - 0, ~0, 1, RF_ACTIVE); - if (sc->mem =3D=3D NULL) { - device_printf(dev, "couldn't allocate memory\n"); - wi_free(dev); - return (ENXIO); - } - sc->wi_bmemtag =3D rman_get_bustag(sc->mem); - sc->wi_bmemhandle =3D rman_get_bushandle(sc->mem); - - /* - * From Linux driver: - * Write COR to enable PC card - * This is a subset of the protocol that the pccard bus code - * would do. - */ - CSM_WRITE_1(sc, WI_COR_OFFSET, WI_COR_VALUE);=20 - reg =3D CSM_READ_1(sc, WI_COR_OFFSET); - - CSR_WRITE_2(sc, WI_HFA384X_SWSUPPORT0_OFF, WI_PRISM2STA_MAGIC); - reg =3D CSR_READ_2(sc, WI_HFA384X_SWSUPPORT0_OFF); - if (reg !=3D WI_PRISM2STA_MAGIC) { - device_printf(dev, - "CSR_READ_2(WI_HFA384X_SWSUPPORT0_OFF) " - "wanted %d, got %d\n", WI_PRISM2STA_MAGIC, reg); - wi_free(dev); - return (ENXIO); - } - - error =3D wi_generic_attach(dev); - if (error !=3D 0) - return (error); - - return (0); -} -#endif - -static int +int wi_generic_attach(device_t dev) { struct wi_softc *sc; @@ -1968,7 +1698,7 @@ return; } =20 -static int +int wi_alloc(dev, io_rid) device_t dev; int io_rid; @@ -2002,7 +1732,8 @@ return (0); } =20 -static void wi_free(dev) +void +wi_free(dev) device_t dev; { struct wi_softc *sc =3D device_get_softc(dev); @@ -2023,7 +1754,8 @@ return; } =20 -static void wi_shutdown(dev) +void +wi_shutdown(dev) device_t dev; { struct wi_softc *sc; Index: sys/dev/wi/if_wireg.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /usr/cvs/src/sys/dev/wi/if_wireg.h,v retrieving revision 1.16 diff -u -r1.16 if_wireg.h --- sys/dev/wi/if_wireg.h 24 Aug 2001 02:14:26 -0000 1.16 +++ sys/dev/wi/if_wireg.h 28 Sep 2001 00:24:56 -0000 @@ -675,3 +675,11 @@ #define WI_SNAP_WORD0 (WI_SNAP_K1 | (WI_SNAP_K1 << 8)) #define WI_SNAP_WORD1 (WI_SNAP_K2 | (WI_SNAP_CONTROL << 8)) #define WI_SNAPHDR_LEN 0x6 + +int wi_generic_attach __P((device_t)); +int wi_detach __P((device_t)); +void wi_shutdown __P((device_t)); +int wi_alloc __P((device_t, int)); +void wi_free __P((device_t)); + +extern devclass_t wi_devclass; Index: sys/modules/wi/Makefile =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /usr/cvs/src/sys/modules/wi/Makefile,v retrieving revision 1.11 diff -u -r1.11 Makefile --- sys/modules/wi/Makefile 28 Aug 2001 05:28:40 -0000 1.11 +++ sys/modules/wi/Makefile 27 Sep 2001 22:34:12 -0000 @@ -3,9 +3,7 @@ .PATH: ${.CURDIR}/../../dev/wi =20 KMOD=3D if_wi -SRCS=3D if_wi.c card_if.h device_if.h bus_if.h pci_if.h pci.h - -pci.h: - echo "#define NPCI 1" > $@ +SRCS=3D if_wi.c if_wi_pccard.c if_wi_pci.c \ + card_if.h device_if.h bus_if.h pci_if.h =20 .include --- sys/dev/wi/if_wi_pccard.c.orig Thu Sep 27 16:40:05 2001 +++ sys/dev/wi/if_wi_pccard.c Thu Sep 27 16:19:50 2001 @@ -0,0 +1,172 @@ +/* + * Copyright (c) 1997, 1998, 1999 + * Bill Paul . All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Bill Paul. + * 4. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURP= OSE + * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Lucent WaveLAN/IEEE 802.11 PCMCIA driver for FreeBSD. + * + * Written by Bill Paul + * Electrical Engineering Department + * Columbia University, New York City + */ + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include + +#if !defined(lint) +static const char rcsid[] =3D + "$FreeBSD$"; +#endif + +static int wi_pccard_match __P((device_t)); +static int wi_pccard_probe __P((device_t)); +static int wi_pccard_attach __P((device_t)); + +static device_method_t wi_pccard_methods[] =3D { + /* Device interface */ + DEVMETHOD(device_probe, pccard_compat_probe), + DEVMETHOD(device_attach, pccard_compat_attach), + DEVMETHOD(device_detach, wi_detach), + DEVMETHOD(device_shutdown, wi_shutdown), + + /* Card interface */ + DEVMETHOD(card_compat_match, wi_pccard_match), + DEVMETHOD(card_compat_probe, wi_pccard_probe), + DEVMETHOD(card_compat_attach, wi_pccard_attach), + + { 0, 0 } +}; + +static driver_t wi_pccard_driver =3D { + "wi", + wi_pccard_methods, + sizeof(struct wi_softc) +}; + +DRIVER_MODULE(if_wi, pccard, wi_pccard_driver, wi_devclass, 0, 0); + +static const struct pccard_product wi_pccard_products[] =3D { + { PCCARD_STR_LUCENT_WAVELAN_IEEE, PCCARD_VENDOR_LUCENT, + PCCARD_PRODUCT_LUCENT_WAVELAN_IEEE, 0,=20 + PCCARD_CIS_LUCENT_WAVELAN_IEEE }, +}; + +static int wi_pccard_match(dev) + device_t dev; +{ + const struct pccard_product *pp; + + if ((pp =3D pccard_product_lookup(dev, wi_pccard_products, + sizeof(wi_pccard_products[0]), NULL)) !=3D NULL) { + device_set_desc(dev, pp->pp_name); + return 0; + } + return ENXIO; +} + +static int wi_pccard_probe(dev) + device_t dev; +{ + struct wi_softc *sc; + int error; + + sc =3D device_get_softc(dev); + sc->wi_gone =3D 0; + + error =3D wi_alloc(dev, 0); + if (error) + return (error); + + wi_free(dev); + + /* Make sure interrupts are disabled. */ + CSR_WRITE_2(sc, WI_INT_EN, 0); + CSR_WRITE_2(sc, WI_EVENT_ACK, 0xFFFF); + + return (0); +} + +static int wi_pccard_attach(device_t dev) +{ + struct wi_softc *sc; + int error; + u_int32_t flags; + + sc =3D device_get_softc(dev); + + /* + * XXX: quick hack to support Prism II chip. + * Currently, we need to set a flags in pccard.conf to specify + * which type chip is used. + * + * We need to replace this code in a future. + * It is better to use CIS than using a flag. + */ + flags =3D device_get_flags(dev); +#define WI_FLAGS_PRISM2 0x10000 + if (flags & WI_FLAGS_PRISM2) { + sc->wi_prism2 =3D 1; + if (bootverbose) { + device_printf(dev, "found PrismII chip\n"); + } + } + else { + sc->wi_prism2 =3D 0; + if (bootverbose) { + device_printf(dev, "found Lucent chip\n"); + } + } + + error =3D wi_alloc(dev, 0); + if (error) { + device_printf(dev, "wi_alloc() failed! (%d)\n", error); + return (error); + } + return (wi_generic_attach(dev)); +} --- sys/dev/wi/if_wi_pci.c.orig Thu Sep 27 16:40:02 2001 +++ sys/dev/wi/if_wi_pci.c Thu Sep 27 16:22:58 2001 @@ -0,0 +1,194 @@ +/* + * Copyright (c) 1997, 1998, 1999 + * Bill Paul . All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Bill Paul. + * 4. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURP= OSE + * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Lucent WaveLAN/IEEE 802.11 PCMCIA driver for FreeBSD. + * + * Written by Bill Paul + * Electrical Engineering Department + * Columbia University, New York City + */ + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include + +#if !defined(lint) +static const char rcsid[] =3D + "$FreeBSD$"; +#endif + +static int wi_pci_probe __P((device_t)); +static int wi_pci_attach __P((device_t)); + +static device_method_t wi_pci_methods[] =3D { + /* Device interface */ + DEVMETHOD(device_probe, wi_pci_probe), + DEVMETHOD(device_attach, wi_pci_attach), + DEVMETHOD(device_detach, wi_detach), + DEVMETHOD(device_shutdown, wi_shutdown), + + { 0, 0 } +}; + +static driver_t wi_pci_driver =3D { + "wi", + wi_pci_methods, + sizeof(struct wi_softc) +}; + +static struct { + unsigned int vendor,device; + char *desc; +} pci_ids[] =3D { + {0x1638, 0x1100, "PRISM2STA PCI WaveLAN/IEEE 802.11"}, + {0x1385, 0x4100, "Netgear MA301 PCI IEEE 802.11b"}, + {0, 0, NULL} +}; + +DRIVER_MODULE(if_wi, pci, wi_pci_driver, wi_devclass, 0, 0); + +static int +wi_pci_probe(dev) + device_t dev; +{ + struct wi_softc *sc; + int i; + + sc =3D device_get_softc(dev); + for(i=3D0; pci_ids[i].vendor !=3D 0; i++) { + if ((pci_get_vendor(dev) =3D=3D pci_ids[i].vendor) && + (pci_get_device(dev) =3D=3D pci_ids[i].device)) { + sc->wi_prism2 =3D 1; + device_set_desc(dev, pci_ids[i].desc); + return (0); + } + } + return(ENXIO); +} + +static int +wi_pci_attach(device_t dev) +{ + struct wi_softc *sc; + u_int32_t command, wanted; + u_int16_t reg; + int error; + + sc =3D device_get_softc(dev); + + command =3D pci_read_config(dev, PCIR_COMMAND, 4); + wanted =3D PCIM_CMD_PORTEN|PCIM_CMD_MEMEN; + command |=3D wanted; + pci_write_config(dev, PCIR_COMMAND, command, 4); + command =3D pci_read_config(dev, PCIR_COMMAND, 4); + if ((command & wanted) !=3D wanted) { + device_printf(dev, "wi_pci_attach() failed to enable pci!\n"); + return (ENXIO); + } + + error =3D wi_alloc(dev, WI_PCI_IORES); + if (error) + return (error); + + /* Make sure interrupts are disabled. */ + CSR_WRITE_2(sc, WI_INT_EN, 0); + CSR_WRITE_2(sc, WI_EVENT_ACK, 0xFFFF); + + /* We have to do a magic PLX poke to enable interrupts */ + sc->local_rid =3D WI_PCI_LOCALRES; + sc->local =3D bus_alloc_resource(dev, SYS_RES_IOPORT, + &sc->local_rid, 0, ~0, 1, RF_ACTIVE); + sc->wi_localtag =3D rman_get_bustag(sc->local); + sc->wi_localhandle =3D rman_get_bushandle(sc->local); + command =3D bus_space_read_4(sc->wi_localtag, sc->wi_localhandle, + WI_LOCAL_INTCSR); + command |=3D WI_LOCAL_INTEN; + bus_space_write_4(sc->wi_localtag, sc->wi_localhandle, + WI_LOCAL_INTCSR, command); + bus_release_resource(dev, SYS_RES_IOPORT, sc->local_rid, sc->local); + sc->local =3D NULL; + + sc->mem_rid =3D WI_PCI_MEMRES; + sc->mem =3D bus_alloc_resource(dev, SYS_RES_MEMORY, &sc->mem_rid, + 0, ~0, 1, RF_ACTIVE); + if (sc->mem =3D=3D NULL) { + device_printf(dev, "couldn't allocate memory\n"); + wi_free(dev); + return (ENXIO); + } + sc->wi_bmemtag =3D rman_get_bustag(sc->mem); + sc->wi_bmemhandle =3D rman_get_bushandle(sc->mem); + + /* + * From Linux driver: + * Write COR to enable PC card + * This is a subset of the protocol that the pccard bus code + * would do. + */ + CSM_WRITE_1(sc, WI_COR_OFFSET, WI_COR_VALUE);=20 + reg =3D CSM_READ_1(sc, WI_COR_OFFSET); + + CSR_WRITE_2(sc, WI_HFA384X_SWSUPPORT0_OFF, WI_PRISM2STA_MAGIC); + reg =3D CSR_READ_2(sc, WI_HFA384X_SWSUPPORT0_OFF); + if (reg !=3D WI_PRISM2STA_MAGIC) { + device_printf(dev, + "CSR_READ_2(WI_HFA384X_SWSUPPORT0_OFF) " + "wanted %d, got %d\n", WI_PRISM2STA_MAGIC, reg); + wi_free(dev); + return (ENXIO); + } + + error =3D wi_generic_attach(dev); + if (error !=3D 0) + return (error); + + return (0); +} --=20 Any statement of the form "X is the one, true Y" is FALSE. PGP fingerprint 655D 519C 26A7 82E7 2529 9BF0 5D8E 8BE9 F238 1AD4 --jI8keyz6grp/JLjh Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE7s9R5XY6L6fI4GtQRAsbKAKCUefITfjJ7c6UAXjKIyMoTuj2R7gCfT78I ITY6usXcZHnt7ArBTCgqJbU= =eqlr -----END PGP SIGNATURE----- --jI8keyz6grp/JLjh-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Fri Sep 28 0:52:43 2001 Delivered-To: freebsd-audit@freebsd.org Received: from whale.sunbay.crimea.ua (whale.sunbay.crimea.ua [212.110.138.65]) by hub.freebsd.org (Postfix) with ESMTP id 3D07E37B40A for ; Fri, 28 Sep 2001 00:52:37 -0700 (PDT) Received: (from ru@localhost) by whale.sunbay.crimea.ua (8.11.6/8.11.2) id f8S7pEd34327; Fri, 28 Sep 2001 10:51:14 +0300 (EEST) (envelope-from ru) Date: Fri, 28 Sep 2001 10:51:14 +0300 From: Ruslan Ermilov To: "Sergey A. Osokin" Cc: audit@FreeBSD.ORG Subject: Re: iostat(8) WARNS=2 cleanup Message-ID: <20010928105114.E30062@sunbay.com> References: <20010927225814.A46080@freebsd.org.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010927225814.A46080@freebsd.org.ru>; from osa@freebsd.org.ru on Thu, Sep 27, 2001 at 10:58:14PM +0400 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, Sep 27, 2001 at 10:58:14PM +0400, Sergey A. Osokin wrote: > Hello. > Please review patch. > Thanks. > Revision 1.23 has been committed. Please resubmit. > --- iostat.orig/iostat.c Mon Sep 24 13:20:34 2001 > +++ iostat/iostat.c Mon Sep 24 13:19:01 2001 > > + (const char *)namelist[X_TK_NIN].n_name = "_tk_nin"; > + (const char *)namelist[X_TK_NOUT].n_name = "_tk_nout"; > + (const char *)namelist[X_CP_TIME].n_name = "_cp_time"; > + (const char *)namelist[X_BOOTTIME].n_name = "_boottime"; > + namelist[4].n_name = NULL; > I don't like this. We need to fix the "struct nlist" definition in instead. > @@ -580,12 +580,12 @@ > static void > phdr(int signo) > { > - > - phdr_flag = 1; > + if (signo == SIGCONT) > + phdr_flag = 1; > } > This is not something that qualifies like WARNS cleanup. > static int > readvar(kvm_t *kd, const char *name, int nlid, void *ptr, size_t len) > { > if (kd != NULL) { > - ssize_t nbytes; > + size_t nbytes; > > nbytes = kvm_read(kd, nlid, ptr, len); > Why? kvm_read(3) returns ``ssize_t''. -- Ruslan Ermilov Oracle Developer/DBA, ru@sunbay.com Sunbay Software AG, ru@FreeBSD.org FreeBSD committer, +380.652.512.251 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Fri Sep 28 3:31:19 2001 Delivered-To: freebsd-audit@freebsd.org Received: from axl.seasidesoftware.co.za (axl.seasidesoftware.co.za [196.31.7.201]) by hub.freebsd.org (Postfix) with ESMTP id 5B0F637B40A for ; Fri, 28 Sep 2001 03:31:17 -0700 (PDT) Received: from sheldonh (helo=axl.seasidesoftware.co.za) by axl.seasidesoftware.co.za with local-esmtp (Exim 3.33 #1) id 15muv3-000Pq2-00; Fri, 28 Sep 2001 12:30:57 +0200 From: Sheldon Hearn To: osa@FreeBSD.org.ru Cc: audit@FreeBSD.org Subject: Re: iostat(8) WARNS=2 cleanup In-reply-to: Your message of "Thu, 27 Sep 2001 22:58:14 +0400." <20010927225814.A46080@freebsd.org.ru> Date: Fri, 28 Sep 2001 12:30:57 +0200 Message-ID: <99325.1001673057@axl.seasidesoftware.co.za> Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, 27 Sep 2001 22:58:14 +0400, "Sergey A. Osokin" wrote: > + namelist[4].n_name = NULL; I think X_END exists to obviate the need for a literal numeric index. Perhaps you should use namelist[X_END + 1].n_name? Ciao, Sheldon. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Fri Sep 28 9:41:23 2001 Delivered-To: freebsd-audit@freebsd.org Received: from coffee.q9media.com (coffee.q9media.com [216.94.229.19]) by hub.freebsd.org (Postfix) with ESMTP id 9D6DC37B408 for ; Fri, 28 Sep 2001 09:41:19 -0700 (PDT) Received: (from mike@localhost) by coffee.q9media.com (8.11.6/8.11.6) id f8SGflK14443; Fri, 28 Sep 2001 12:41:47 -0400 (EDT) (envelope-from mike) Date: Fri, 28 Sep 2001 12:41:47 -0400 From: Mike Barcroft To: "Sergey A. Osokin" Cc: audit@FreeBSD.ORG Subject: Re: iostat(8) WARNS=2 cleanup Message-ID: <20010928124147.E12254@coffee.q9media.com> References: <20010927225814.A46080@freebsd.org.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20010927225814.A46080@freebsd.org.ru>; from osa@freebsd.org.ru on Thu, Sep 27, 2001 at 10:58:14PM +0400 Organization: The FreeBSD Project Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Ruslan identified all of the problems, expect this one: Sergey A. Osokin writes: > diff -ruN iostat.orig/Makefile iostat/Makefile > --- iostat.orig/Makefile Mon Sep 24 13:20:34 2001 > +++ iostat/Makefile Mon Sep 24 12:58:56 2001 > @@ -8,4 +8,6 @@ > LDADD= -lkvm -ldevstat -lm > MAN= iostat.8 > > +WARNS?= 2 > + > .include WARNS?= belongs directly below PROG= in this case. Best regards, Mike Barcroft To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message