From owner-freebsd-mobile Tue Jul 30 17:09:45 1996 Return-Path: owner-mobile Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id RAA19391 for mobile-outgoing; Tue, 30 Jul 1996 17:09:45 -0700 (PDT) Received: from frig.mt.cs.keio.ac.jp (frig.mt.cs.keio.ac.jp [131.113.32.7]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id RAA19377; Tue, 30 Jul 1996 17:09:38 -0700 (PDT) Received: (from hosokawa@localhost) by frig.mt.cs.keio.ac.jp (8.6.12+2.4W/3.4Wbeta3) id JAA26576; Wed, 31 Jul 1996 09:09:34 +0900 Date: Wed, 31 Jul 1996 09:09:34 +0900 Message-Id: <199607310009.JAA26576@frig.mt.cs.keio.ac.jp> To: announce@FreeBSD.org, mobile@FreeBSD.org, hackers@FreeBSD.org Cc: cyf00575@niftyserve.or.jp Reply-To: mobile@FreeBSD.org Subject: [PCMCIA] PAO-960731 is now available! From: hosokawa@mt.cs.keio.ac.jp (HOSOKAWA Tatsumi) X-Mailer: mnews [version 1.18PL3] 1994-08/01(Mon) Sender: owner-mobile@FreeBSD.org X-Loop: FreeBSD.org Precedence: bulk New version of PAO (FreeBSD PC-card and APM package) is now available! Important changes: o 2.1.5-RELEASE support I put it at ftp://ryukyu.mt.cs.keio.ac.jp/pub/FreeBSD/PAO-960731.tar.gz BTW, this ftp site will be down from today's evening :-) through August 8 and I'm away from net until August 8. So I also put this file at ftp://freefall.freebsd.org/incoming/PAO-960731.tar.gz If you have something to tell me urgently, please e-mail me at "cyf00575@niftyserve.or.jp". Enjoy! -- HOSOKAWA, Tatsumi E-mail: hosokawa@mt.cs.keio.ac.jp WWW homepage: http://www.mt.cs.keio.ac.jp/person/hosokawa.html Department of Computer Science, Keio University, Yokohama, Japan From owner-freebsd-mobile Thu Aug 1 12:39:54 1996 Return-Path: owner-mobile Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id MAA03117 for mobile-outgoing; Thu, 1 Aug 1996 12:39:54 -0700 (PDT) Received: from rocky.mt.sri.com (rocky.mt.sri.com [206.127.76.100]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id MAA03112 for ; Thu, 1 Aug 1996 12:39:51 -0700 (PDT) Received: (from nate@localhost) by rocky.mt.sri.com (8.7.5/8.7.3) id NAA08134; Thu, 1 Aug 1996 13:28:39 -0600 (MDT) Date: Thu, 1 Aug 1996 13:28:39 -0600 (MDT) Message-Id: <199608011928.NAA08134@rocky.mt.sri.com> From: Nate Williams To: mobile@freebsd.org, hosokawa@mt.cs.keio.ac.jp Subject: Pccardc diffs Sender: owner-mobile@freebsd.org X-Loop: FreeBSD.org Precedence: bulk The following shar file contains the 'useful' changes from the -current (as of 8/1/96) usr.sbin/pccard/pccardc sources to the 7/31-PAO release sources. Only the functional changes are supplied, white-space and other gratituious changes are not included. I hope to do the same with pccardd as well, but it's changed a bit more and trying to merge in the changes has been alot more work due to a whole bunch of changes I have difficulties accepting. IMHO there are *MUCH* betters ways of solving the problem, but since everyone involved has been so busy communication has been difficult. Note: The diffs provided introduce bugs, but I haven't spent time to look at them. The IRQ's listed by the old code are correct, and the code with these changes in them are wrong. Note also that these diffs will not compile on a FreeBSD-current system and require additional changes to the kernel tree which have not been (and may not be) integrated. In particular, I don't like the 'beep' functions as they currently exist in the Nomad implementation, and in my opinion the 'power' code is a kludge to work-around the non-ability of suspend/resume on the laptops. The primary intention of the below diff is to allow the Nomad's and other developers to 'sync' up their sources with the FreeBSD sources *completely*. They should be able grab a copy of FreeBSD-current sources today and apply these changes to pccardc, at which point in time they will have the *exact* same functional sources as before w/out any non-necessary work for the Nomad's and/or myself when intergration works. My secondary purpose is to have people review the PAO 'functional' diffs and fix the bugs it introduces, especially regarding the printing out of the IRQ's. The original code may have bugs in it, but at least the bugs aren't visible in my testing, so the PAO code may fix bugs and introduce new ones at the same time. If someone else wants to help out and do the pccardd merge I would certainly appreciate the help. My time is *very* limited to work on this, but I don't want any 'current' work to slip through the cracks. Finally, in regards to the new 'kernel' changes, it is my belief that you can completely throw out the PAO APM code since: 1) It doesn't follow the specification w/regards to apm_idel/busy 2) It adds *NO* functional changes but does complicate the readability of the code. I intend to integrate my APM BIOS changes posted a couple weeks earlier into the -current kernel, and then remove more of the complexity from the APM code soon. The patches I sent out for review went out at a bad time right after 2.1.5, so I'll ping the folks and see if I can get a response on them. My goals are: 1) Integrate the APM/BIOS changes posted earlier 2) Finish the usr.sbin/pccard/pccardd merges 3) Review the 'XT_KEYBOARD' change from the PAO release and run it by S'ren. I like the idea, but am unsure if the implementation is acceptable by S'ren. 4) Completely remove /sys/i386/include/laptop.h - It's an un-necessary kludge that I never should have brought in. 5) Integrate in some of the new drivers and upgrade the older ones with the newer code. We're getting closer to having a much closer 'merge' of the PAO sources and FreeBSD-current, and given that everyone's time is limited it will make it easier on both the users and the developers to have the sources more closely resemble one another. Nate From owner-freebsd-mobile Thu Aug 1 13:44:51 1996 Return-Path: owner-mobile Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id NAA25177 for mobile-outgoing; Thu, 1 Aug 1996 13:44:51 -0700 (PDT) Received: from rocky.mt.sri.com (rocky.mt.sri.com [206.127.76.100]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id NAA25089 for ; Thu, 1 Aug 1996 13:44:43 -0700 (PDT) Received: (from nate@localhost) by rocky.mt.sri.com (8.7.5/8.7.3) id OAA08646; Thu, 1 Aug 1996 14:33:33 -0600 (MDT) Date: Thu, 1 Aug 1996 14:33:33 -0600 (MDT) Message-Id: <199608012033.OAA08646@rocky.mt.sri.com> From: Nate Williams To: Nate Williams Cc: mobile@freebsd.org, hosokawa@mt.cs.keio.ac.jp Subject: Re: Pccardc diffs In-Reply-To: <199608011928.NAA08134@rocky.mt.sri.com> References: <199608011928.NAA08134@rocky.mt.sri.com> Sender: owner-mobile@freebsd.org X-Loop: FreeBSD.org Precedence: bulk Nate Williams writes: > The following shar file contains ... Absolutely nothing, since the idiot that posted it forgot to include the actual sharfile. Duh!! Thanks to 'Janick TAILLANDIER ' for pointing it out (turns out that I wasn't subscribed to th mobile list for some reason). Anyway, here's the shar file, and sorry about that! Nate ------ # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # diffs # beep.c # power.c # rdattr.c # echo x - diffs sed 's/^X//' >diffs << 'END-of-diffs' X? rdattr.c X? power.c X? beep.c X? dif X? bdif X? makefile X? diffs XIndex: Makefile X=================================================================== XRCS file: /home/CVS/src/usr.sbin/pccard/pccardc/Makefile,v Xretrieving revision 1.2 Xdiff -c -r1.2 Makefile X*** Makefile 1996/04/09 23:31:51 1.2 X--- Makefile 1996/08/01 19:05:28 X*************** X*** 5,12 **** X # X PROG= pccardc X NOMAN= noman X! SRCS= pccardc.c dumpcis.c readcis.c printcis.c enabler.c pccardmem.c \ X! rdmap.c rdreg.c wrattr.c wrreg.c X X CFLAGS+= -I. -I${.CURDIR}/../pccardd X X--- 5,12 ---- X # X PROG= pccardc X NOMAN= noman X! SRCS= beep.c dumpcis.c enabler.c pccardc.c pccardmem.c power.c printcis.c \ X! rdattr.c rdmap.c rdreg.c readcis.c wrattr.c wrreg.c X X CFLAGS+= -I. -I${.CURDIR}/../pccardd X XIndex: pccardc.c X=================================================================== XRCS file: /home/CVS/src/usr.sbin/pccard/pccardc/pccardc.c,v Xretrieving revision 1.3 Xdiff -c -r1.3 pccardc.c X*** pccardc.c 1996/04/18 04:24:54 1.3 X--- pccardc.c 1996/08/01 19:05:29 X*************** X*** 31,40 **** X--- 31,43 ---- X typedef int (*main_t)(int, char **); X X #define DECL(foo) int foo(int, char**); X+ DECL(beep_main); X DECL(dumpcis_main); X DECL(enabler_main); X DECL(help_main); X DECL(pccardmem_main); X+ DECL(power_main); X+ DECL(rdattr_main); X DECL(rdmap_main); X DECL(rdreg_main); X DECL(wrattr_main); X*************** X*** 45,54 **** X--- 48,60 ---- X main_t func; X char *help; X } subcommands[] = { X+ { "beep", beep_main, "Beep type" }, X { "dumpcis", dumpcis_main, "Prints CIS for all cards" }, X { "enabler", enabler_main, "Device driver enabler" }, X { "help", help_main, "Prints command summary" }, X { "pccardmem", pccardmem_main, "Allocate memory for pccard driver" }, X+ { "power", power_main, "Power on/off slots" }, X+ { "rdattr", rdattr_main, "Read attribute memory" }, X { "rdmap", rdmap_main, "Read pcic mappings" }, X { "rdreg", rdreg_main, "Read pcic register" }, X { "wrattr", wrattr_main, "Write byte to attribute memory" }, XIndex: printcis.c X=================================================================== XRCS file: /home/CVS/src/usr.sbin/pccard/pccardc/printcis.c,v Xretrieving revision 1.5 Xdiff -c -r1.5 printcis.c X*** printcis.c 1996/08/01 15:45:46 1.5 X--- printcis.c 1996/08/01 19:05:31 X*************** X*** 25,30 **** X--- 25,36 ---- X * X * $Id: printcis.c,v 1.5 1996/08/01 15:45:46 nate Exp $ X */ X+ X+ /* X+ * Code cleanup, bug-fix and extention X+ * by Tatsumi Hosokawa X+ */ X+ X #include X #include X #include X*************** X*** 236,242 **** X case 5: X case 6: X case 7: X- case 8: X printf("(custom)"); X break; X } X--- 242,247 ---- X*************** X*** 282,304 **** X break; X } X if (feat & CIS_FEAT_TIMING) { X! i = CIS_WAIT_SCALE(*p); X! j = CIS_READY_SCALE(*p); X! p++; X! if (i != 3) { X printf("\tWait scale "); X! print_ext_speed(*p, i); X! while (*p & 0x80) X! p++; X printf("\n"); X } X if (j != 7) { X printf("\tRDY/BSY scale "); X! print_ext_speed(*p, j); X! while (*p & 0x80) X! p++; X printf("\n"); X } X } X if (feat & CIS_FEAT_I_O) { X if (CIS_IO_ADDR(*p)) X--- 287,311 ---- X break; X } X if (feat & CIS_FEAT_TIMING) { X! i = *p++; X! j = CIS_WAIT_SCALE(i); X! if (j != 3) { X printf("\tWait scale "); X! print_ext_speed(*p++, j); X printf("\n"); X } X+ j = CIS_READY_SCALE(i); X if (j != 7) { X printf("\tRDY/BSY scale "); X! print_ext_speed(*p++, j); X printf("\n"); X } X+ j = CIS_RESERVED_SCALE(i); X+ if (j != 7) { X+ printf("\tExternal scale "); X+ print_ext_speed(*p++, j); X+ printf("\n"); X+ } X } X if (feat & CIS_FEAT_I_O) { X if (CIS_IO_ADDR(*p)) X*************** X*** 320,327 **** X break; X } X printf("\n"); X! if (*p & CIS_IO_RANGE) { X! p++; X c = *p++; X for (i = 0; i <= CIS_IO_BLKS(c); i++) { X printf("\t\tI/O address # %d: ", i + 1); X--- 327,333 ---- X break; X } X printf("\n"); X! if (*p++ & CIS_IO_RANGE) { X c = *p++; X for (i = 0; i <= CIS_IO_BLKS(c); i++) { X printf("\t\tI/O address # %d: ", i + 1); X*************** X*** 380,386 **** X printf("%c Shared", c); X printf("\n"); X if (*p & CIS_IRQ_MASK) { X! i = p[0] | (p[1] << 8); X printf("\t\tIRQs: "); X if (*p & 1) X printf(" NMI"); X--- 386,392 ---- X printf("%c Shared", c); X printf("\n"); X if (*p & CIS_IRQ_MASK) { X! i = p[1] | (p[2] << 8); X printf("\t\tIRQs: "); X if (*p & 1) X printf(" NMI"); X*************** X*** 589,595 **** X len--; X if (*p) { X printf("\t\t"); X! print_ext_speed(*p, 0); X while (*p & 0x80) { X p++; X len--; X--- 595,601 ---- X len--; X if (*p) { X printf("\t\t"); X! print_ext_speed(*p++, 0); X while (*p & 0x80) { X p++; X len--; END-of-diffs echo x - beep.c sed 's/^X//' >beep.c << 'END-of-beep.c' X/* X * Copyright (c) 1995 Andrew McRae. All rights reserved. X * X * Redistribution and use in source and binary forms, with or without X * modification, are permitted provided that the following conditions X * are met: X * 1. Redistributions of source code must retain the above copyright X * notice, this list of conditions and the following disclaimer. X * 2. Redistributions in binary form must reproduce the above copyright X * notice, this list of conditions and the following disclaimer in the X * documentation and/or other materials provided with the distribution. X * 3. The name of the author may not be used to endorse or promote products X * derived from this software without specific prior written permission. X * X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR X * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES X * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. X * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, X * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT X * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, X * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY X * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT X * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF X * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. X */ X X/* X * Code cleanup, bug-fix and extention X * by Tatsumi Hosokawa X */ X X#include X#include X#include X#include X#include X#include X#include X X#include X Xint Xbeep_main(argc, argv) X int argc; X char *argv[]; X{ X int fd, newstat, valid = 1; X char name[64], *p; X X if (argc != 2) X valid = 0; X if (valid) { X for (p = argv[1]; *p; p++) { X if (!isdigit(*p)) { X valid = 0; X break; X } X } X } X if (!valid) { X fprintf(stderr, "usage: %s power slot newstat\n", argv[0]); X exit(1); X } X sscanf(argv[1], "%d", &newstat); X sprintf(name, "/dev/card%d", 0); X fd = open(name, O_RDWR); X if (fd < 0) { X perror("/dev/card0"); X exit(1); X } X X if (ioctl(fd, PIOCSBEEP, &newstat) < 0) { X perror("beep"); X exit(1); X } X X return 0; X} END-of-beep.c echo x - power.c sed 's/^X//' >power.c << 'END-of-power.c' X/* X * Copyright (c) 1995 Andrew McRae. All rights reserved. X * X * Redistribution and use in source and binary forms, with or without X * modification, are permitted provided that the following conditions X * are met: X * 1. Redistributions of source code must retain the above copyright X * notice, this list of conditions and the following disclaimer. X * 2. Redistributions in binary form must reproduce the above copyright X * notice, this list of conditions and the following disclaimer in the X * documentation and/or other materials provided with the distribution. X * 3. The name of the author may not be used to endorse or promote products X * derived from this software without specific prior written permission. X * X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR X * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES X * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. X * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, X * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT X * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, X * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY X * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT X * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF X * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. X */ X X/* X * Code cleanup, bug-fix and extention X * by Tatsumi Hosokawa X */ X X#include X#include X#include X#include X#include X#include X#include X X#include X Xint Xpower_main(argc, argv) X int argc; X char *argv[]; X{ X int fd, i, newstat, valid = 1; X char name[64], *p; X X if (argc != 3) X valid = 0; X for (i = 1; i <= 2; i++) { X if (valid) { X for (p = argv[i]; *p; p++) { X if (!isdigit(*p)) { X valid = 0; X break; X } X } X } X } X if (!valid) { X fprintf(stderr, "usage: %s power slot newstat\n", argv[0]); X exit(1); X } X sscanf(argv[2], "%d", &newstat); X sprintf(name, CARD_DEVICE, atoi(argv[1])); X fd = open(name, O_RDWR); X if (fd < 0) { X perror(name); X exit(1); X } X X newstat = newstat ? 1 : 0; X if (ioctl(fd, PIOCSVIR, &newstat) < 0) { X perror("ioctl"); X exit(1); X } X X return 0; X} END-of-power.c echo x - rdattr.c sed 's/^X//' >rdattr.c << 'END-of-rdattr.c' X/* X * Copyright (c) 1995 Andrew McRae. All rights reserved. X * X * Redistribution and use in source and binary forms, with or without X * modification, are permitted provided that the following conditions X * are met: X * 1. Redistributions of source code must retain the above copyright X * notice, this list of conditions and the following disclaimer. X * 2. Redistributions in binary form must reproduce the above copyright X * notice, this list of conditions and the following disclaimer in the X * documentation and/or other materials provided with the distribution. X * 3. The name of the author may not be used to endorse or promote products X * derived from this software without specific prior written permission. X * X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR X * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES X * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. X * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, X * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT X * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, X * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY X * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT X * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF X * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. X */ X X/* X * Code cleanup, bug-fix and extention X * by Tatsumi Hosokawa X */ X X#include X#include X#include X#include X#include X#include X X#include X Xint Xrdattr_main(argc, argv) X int argc; X char *argv[]; X{ X int i, reg, length; X char name[64]; X u_char *buf; X int fd; X off_t offs; X X if (argc != 4) { X fprintf(stderr, "usage: %s rdattr slot offs length\n", argv[0]); X exit(1); X } X sprintf(name, CARD_DEVICE, atoi(argv[1])); X fd = open(name, 2); X if (fd < 0) { X perror(name); X exit(1); X } X reg = MDF_ATTR; X if (ioctl(fd, PIOCRWFLAG, ®)) { X perror("ioctl (PIOCRWFLAG)"); X exit(1); X } X if (sscanf(argv[2], "%x", ®) != 1 || X sscanf(argv[3], "%x", &length) != 1) { X fprintf(stderr, "arg error\n"); X exit(1); X } X offs = reg; X if ((buf = malloc(length)) == 0) { X perror(name); X exit(1); X } X lseek(fd, offs, SEEK_SET); X if (read(fd, buf, length) != length) { X perror(name); X exit(1); X } X for (i = 0; i < length; i++) { X if (i % 16 == 0) { X printf("%04x: ", (int) offs + i); X } X printf("%02x ", buf[i]); X if (i % 16 == 15) { X printf("\n"); X } X } X if (i % 16 != 0) { X printf("\n"); X } X return 0; X} END-of-rdattr.c exit From owner-freebsd-mobile Fri Aug 2 05:31:20 1996 Return-Path: owner-mobile Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id FAA05347 for mobile-outgoing; Fri, 2 Aug 1996 05:31:20 -0700 (PDT) Received: from vanuata.dcs.gla.ac.uk (vanuata.dcs.gla.ac.uk [130.209.240.50]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id FAA05342 for ; Fri, 2 Aug 1996 05:31:16 -0700 (PDT) Message-Id: <199608021231.FAA05342@freefall.freebsd.org> Received: from solander.dcs.gla.ac.uk by vanuata.dcs.gla.ac.uk with LOCAL SMTP (PP); Fri, 2 Aug 1996 13:31:09 +0100 To: mobile@freebsd.org Subject: Followup on IBM ethernet/II problems Date: Fri, 02 Aug 1996 13:31:07 +0100 From: Simon Marlow Sender: owner-mobile@freebsd.org X-Loop: FreeBSD.org Precedence: bulk Hi mobile people, You may remember I was having problems with an IBM creditcard ethernet adaptor running slowly; it seems this was caused by the driver accessing the memory on the card too fast, causing about 10% of packets to be corrupted. The Linux pccard driver has a 'mem_speed' setting to work around this, but I can't see anything similar in FreeBSD, so I've dumped the card and got hold of a 3c589 for now (which works properly after removing the contraversial '| 0x8000' from if_ep.c :-) Cheers, Simon -- Simon Marlow simonm@dcs.gla.ac.uk Research Assistant http://www.dcs.gla.ac.uk/~simonm/ finger for PGP public key From owner-freebsd-mobile Fri Aug 2 17:41:12 1996 Return-Path: owner-mobile Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id RAA13062 for mobile-outgoing; Fri, 2 Aug 1996 17:41:12 -0700 (PDT) Received: from rocky.mt.sri.com (rocky.mt.sri.com [206.127.76.100]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id RAA13046 for ; Fri, 2 Aug 1996 17:40:55 -0700 (PDT) Received: (from nate@localhost) by rocky.mt.sri.com (8.7.5/8.7.3) id SAA13976; Fri, 2 Aug 1996 18:40:43 -0600 (MDT) Date: Fri, 2 Aug 1996 18:40:43 -0600 (MDT) Message-Id: <199608030040.SAA13976@rocky.mt.sri.com> From: Nate Williams To: mobile@freebsd.org Cc: hosokawa@mt.cs.keio.ac.jp Subject: Pccardd partial diffs In-Reply-To: <199608011928.NAA08134@rocky.mt.sri.com> References: <199608011928.NAA08134@rocky.mt.sri.com> Sender: owner-mobile@freebsd.org X-Loop: FreeBSD.org Precedence: bulk OK, I spent some time merging in all of the changes I've made recently to the pccardd stuff, so what follows is *most* of the functional changes that are between the Nomad's PAO release and the FreeBSD release. I've merged in recent changes I and others have made in the FreeBSD sources, so this 'diff' and accompanying files are against -current as of 8/2/96. However, I've not yet merged the file 'cardd.c', which is quite large and a bit more complex. Some of the merge may be slightly incomplete, but I'd like folks to test them. Also, some of the changes I've made in these diffs to help out the Nomad SYSINSTALL changes are going to go into the FreeBSD sources, so I'll send out a new 'cdif' shar file again when I make those changes, since I suspect it won't be totally straightforward. You should be able to take the *STOCK* FreeBSD sources and apply the sharfile for pccardc (which includes diffs and new files supplied by the Nomads) and the shar file I'm appending below which contains similar files + the Nomad version of pccardd/cardd.c, and with minor tweaking get 'fully Nomad compliant' user-land code. As before, the work I'm doing does not mean that I've tested the changes, nor that I in any way agree that they are bug free, but it's an attempt to synchronize the Nomad and FreeBSD source trees, as I believe we can better minimze the 'SYSINSTALL' changes to one file, which would be acceptable to me where the current scheme of '#ifdef SYSINSTALL' all over the place is not. I'm not going to work on this stuff over the weekend, so if anyone feels like it feel free to convert 'pccard/cardd.c'. There is *ONE* change that will cause the PAO version of cardd.c to break, and that is the function 'readfile()' returns "void" in the FreeBSD sources, and "int" in the Nomad sources. I believe cardd.c calls readfile and expects and arguement back from it in sysinstall mode, but it should be an easy change. Finally, these changes aren't really applicable to a non-PAO release due to kernel changes they've made. So, if you've got a non-PAO system, stick with -current until I start merging in the 'tested' changes into the FreeBSD-current tree. Nate ps. Is this stuff helpful to the rest of the folks, or should I skip posting it to the list and only send it to the Nomads? I'd *really* like to get our source trees 'merged' and I need help from folks who are running the PAO release to help *me* do it by testing this stuff. --------- # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # cdif # pccardd.c # server.c # echo x - cdif sed 's/^X//' >cdif << 'END-of-cdif' XIndex: Makefile X=================================================================== XRCS file: /home/CVS/src/usr.sbin/pccard/pccardd/Makefile,v Xretrieving revision 1.3 Xdiff -c -r1.3 Makefile X*** Makefile 1996/06/18 22:54:25 1.3 X--- Makefile 1996/08/02 22:06:16 X*************** X*** 1,12 **** X # Makefile for pccardd X X PROG= pccardd X! SRCS= cardd.c file.c util.c readcis.c printcis.c X MAN8= pccardd.8 X MAN5= pccard.conf.5 X DPADD= ${LIBUTIL} X LDADD= -lutil X! CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../pccardc X X .include X .PATH: ${.CURDIR}/../pccardc X--- 1,15 ---- X # Makefile for pccardd X X PROG= pccardd X! SRCS= pccardd.c cardd.c file.c util.c readcis.c printcis.c server.c X MAN8= pccardd.8 X MAN5= pccard.conf.5 X DPADD= ${LIBUTIL} X LDADD= -lutil X! CFLAGS= -I${.CURDIR} -I${.CURDIR}/../pccardc -DSERVER X! X! # if you want to AT&T GIS WaveLAN or Digital RoamAbout/DS, uncomment this line. X! #CFLAGS+= -DWAVELAN X X .include X .PATH: ${.CURDIR}/../pccardc XIndex: cardd.h X=================================================================== XRCS file: /home/CVS/src/usr.sbin/pccard/pccardd/cardd.h,v Xretrieving revision 1.5 Xdiff -c -r1.5 cardd.h X*** cardd.h 1996/06/18 19:52:29 1.5 X--- cardd.h 1996/08/03 00:17:09 X*************** X*** 27,60 **** X * X * Common include file for PCMCIA daemon X */ X #include X X #include X #include X X #include "readcis.h" X X struct cmd { X struct cmd *next; X char *line; /* Command line */ X int macro; /* Contains macros */ X }; X X struct card_config { X struct card_config *next; X unsigned char index; X struct driver *driver; X int irq; X int flags; X char inuse; X }; X X struct card { X struct card *next; X char *manuf; X char *version; X! int ether; /* For net cards, ether at offset */ X int reset_time; /* Reset time */ X struct card_config *config; /* List of configs */ X struct cmd *insert; /* Insert commands */ X struct cmd *remove; /* Remove commands */ X--- 27,106 ---- X * X * Common include file for PCMCIA daemon X */ X+ X+ /* X+ * Code cleanup, bug-fix and extension X+ * by Tatsumi Hosokawa X+ */ X+ X #include X X #include X #include X+ #ifdef WAVELAN X+ #include X+ #endif X X #include "readcis.h" X X+ #ifndef EXTERN X+ #define EXTERN extern X+ #endif X+ X struct cmd { X struct cmd *next; X char *line; /* Command line */ X int macro; /* Contains macros */ X }; X X+ struct card_io { X+ struct card_io *next; X+ int addr; X+ int size; X+ }; X+ X+ struct card_mem { X+ struct card_mem *next; X+ int addr; X+ int cardaddr; X+ int size; X+ }; X+ X struct card_config { X struct card_config *next; X unsigned char index; X struct driver *driver; X+ struct card_io *card_io; X+ struct card_mem *card_mem; X int irq; X int flags; X char inuse; X }; X X+ /* ethernet MAC address check */ X+ struct ether_mac { X+ struct ether_mac *next; X+ u_char addr[3]; X+ }; X+ X+ struct ether { X+ struct ether *next; X+ int type; X+ int attr; X+ struct ether_mac *ether_mac; X+ }; X+ #define ETHTYPE_GENERIC 0 X+ #define ETHTYPE_MEGAHERTZ 1 X+ #define ETHTYPE_WAVELAN 2 X+ X struct card { X struct card *next; X char *manuf; X char *version; X! u_char func_id; X! int deftype; X int reset_time; /* Reset time */ X+ struct ether *ether; /* For net cards, ether at offset */ X struct card_config *config; /* List of configs */ X struct cmd *insert; /* Insert commands */ X struct cmd *remove; /* Remove commands */ X*************** X*** 86,91 **** X--- 132,138 ---- X int flags; /* Flags for block */ X int cardaddr; /* Card address */ X }; X+ X /* X * Slot structure - data held for each slot. X */ X*************** X*** 102,131 **** X struct cis_config *card_config; X char devname[16]; X unsigned char eaddr[6]; /* If any */ X struct allocblk io; /* I/O block spec */ X struct allocblk mem; /* Memory block spec */ X int irq; /* Irq value */ X }; X X! struct slot *slots, *current_slot; X X! struct allocblk *pool_ioblks; /* I/O blocks in the pool */ X! struct allocblk *pool_mem; /* Memory in the pool */ X! int pool_irq[16]; /* IRQ allocations */ X! struct driver *drivers; /* List of drivers */ X! struct card *cards; X! bitstr_t *mem_avail; X! bitstr_t *io_avail; X X! int verbose, do_log; X X char *newstr(); X void die(char *); X void *xmalloc(int); X! void log_1s(char *, char *); X void logerr(char *); X void reset_slot(struct slot *); X void execute(struct cmd *); X void readfile(char *); X int bit_fns(bitstr_t *, int, int); X unsigned long alloc_memory(int); X--- 149,192 ---- X struct cis_config *card_config; X char devname[16]; X unsigned char eaddr[6]; /* If any */ X+ int eaddr_conf; X struct allocblk io; /* I/O block spec */ X struct allocblk mem; /* Memory block spec */ X+ #ifdef WAVELAN X+ struct wavelan_conf wl; X+ int wl_conf; X+ #endif X int irq; /* Irq value */ X+ int use_irqpool; X+ int io_assigned; X }; X X! EXTERN struct slot *slots, *current_slot; X X! EXTERN struct allocblk *pool_ioblks; /* I/O blocks in the pool */ X! EXTERN struct allocblk *pool_mem; /* Memory in the pool */ X! EXTERN int pool_irq[16]; /* IRQ allocations */ X! EXTERN struct driver *drivers; /* List of drivers */ X! EXTERN struct card *cards; X! EXTERN struct card *last_card; X! EXTERN bitstr_t *mem_avail; X! EXTERN bitstr_t *io_avail; X X! EXTERN int verbose; X X char *newstr(); X void die(char *); X void *xmalloc(int); X! void log_setup(void); X! void log_1s(const char *, ...); X void logerr(char *); X void reset_slot(struct slot *); X void execute(struct cmd *); X+ void readslots(void); X+ void slot_change(struct slot *); X+ void set_socket(int); X+ void stat_changed(struct slot *); X+ void process_client(void); X void readfile(char *); X int bit_fns(bitstr_t *, int, int); X unsigned long alloc_memory(int); X*************** X*** 137,139 **** X--- 198,203 ---- X #define MEMBLKS ((MEMEND-MEMSTART)/MEMUNIT) X #define MEM2BIT(x) (((x)-MEMSTART)/MEMUNIT) X #define BIT2MEM(x) (((x)*MEMUNIT)+MEMSTART) X+ X+ #define DT_VERS 0 X+ #define DT_FUNC 1 XIndex: file.c X=================================================================== XRCS file: /home/CVS/src/usr.sbin/pccard/pccardd/file.c,v Xretrieving revision 1.8 Xdiff -c -r1.8 file.c X*** file.c 1996/07/11 15:04:43 1.8 X--- file.c 1996/08/03 00:19:55 X*************** X*** 25,33 **** X--- 25,40 ---- X * X * $Id: file.c,v 1.8 1996/07/11 15:04:43 nate Exp $ X */ X+ X+ /* X+ * Code cleanup, bug-fix and extension X+ * by Tatsumi Hosokawa X+ */ X+ X #include X #include X #include X+ #include X #include X #include "cardd.h" X X*************** X*** 50,55 **** X--- 57,65 ---- X "remove", /* 11 */ X "iosize", /* 12 */ X "memsize", /* 13 */ X+ "function", /* 14 */ X+ "cardio", /* 15 */ X+ "cardmem", /* 16 */ X 0 X }; X X*************** X*** 65,76 **** X static void error(char *); X static int keyword(char *); X static int irq_tok(int); X static struct allocblk *ioblk_tok(int); X static struct allocblk *memblk_tok(int); X static struct driver *new_driver(char *); X X! static void addcmd(struct cmd **cp); X! static void parse_card(void); X X /* X * Read a file and parse the pcmcia configuration data. X--- 75,89 ---- X static void error(char *); X static int keyword(char *); X static int irq_tok(int); X+ static int config_tok(void); X+ static int func_tok(void); X+ static int ether_mac_tok(struct ether_mac *); X static struct allocblk *ioblk_tok(int); X static struct allocblk *memblk_tok(int); X static struct driver *new_driver(char *); X X! static void addcmd(struct cmd **); X! static void parse_card(int); X X /* X * Read a file and parse the pcmcia configuration data. X*************** X*** 83,97 **** X X in = fopen(name, "r"); X if (in == 0) { X! perror(name); X! exit(1); X } X parsefile(); X for (cp = cards; cp; cp = cp->next) { X if (cp->config == 0) X! fprintf(stderr, X! "warning: card %s(%s) has no valid configuration\n", X! cp->manuf, cp->version); X } X } X X--- 96,109 ---- X X in = fopen(name, "r"); X if (in == 0) { X! logerr(name); X! die("readfile"); X } X parsefile(); X for (cp = cards; cp; cp = cp->next) { X if (cp->config == 0) X! log_1s("warning: card %s(%s) has no valid configuration\n", X! cp->manuf, cp->version); X } X } X X*************** X*** 144,151 **** X break; X case 5: X /* Card definition. */ X! parse_card(); X break; X default: X error("Syntax error"); X pusht = 0; X--- 156,167 ---- X break; X case 5: X /* Card definition. */ X! parse_card(DT_VERS); X break; X+ case 14: X+ /* Function definition. */ X+ parse_card(DT_FUNC); X+ break; X default: X error("Syntax error"); X pusht = 0; X*************** X*** 157,182 **** X * Parse a card definition. X */ X static void X! parse_card(void) X { X char *man, *vers; X struct card *cp; X int i; X struct card_config *confp, *lastp; X X! man = newstr(next_tok()); X! vers = newstr(next_tok()); X cp = xmalloc(sizeof(*cp)); X! cp->manuf = man; X! cp->version = vers; X! cp->reset_time = 50; X cp->next = cards; X cards = cp; X for (;;) { X switch (keyword(next_tok())) { X case 7: X /* config */ X! i = num_tok(); X if (i == -1) { X error("Illegal card config index"); X break; X--- 173,228 ---- X * Parse a card definition. X */ X static void X! parse_card(int deftype) X { X char *man, *vers; X struct card *cp; X int i; X struct card_config *confp, *lastp; X+ struct ether_mac ether_mac; X+ struct ether *ether; X+ struct card_io *card_io; X+ struct card_mem *card_mem; X X! confp = lastp = 0; X cp = xmalloc(sizeof(*cp)); X! cp->deftype = deftype; X! cp->ether = 0; X! switch (deftype) { X! case DT_VERS: X! man = newstr(next_tok()); X! vers = newstr(next_tok()); X! cp->manuf = man; X! cp->version = vers; X! cp->func_id = 0; X! break; X! case DT_FUNC: X! cp->manuf = ""; X! cp->version = ""; X! cp->func_id = (u_char) func_tok(); X! break; X! default: X! fprintf(stderr, "parse_card: unknown deftype %d\n", deftype); X! exit(1); X! } X! cp->reset_time = 100; X! #if 1 X! cp->next = 0; X! if (!last_card) X! cards = last_card = cp; X! else { X! last_card->next = cp; X! last_card = cp; X! } X! #else X cp->next = cards; X cards = cp; X+ #endif X for (;;) { X switch (keyword(next_tok())) { X case 7: X /* config */ X! i = config_tok(); X if (i == -1) { X error("Illegal card config index"); X break; X*************** X*** 190,196 **** X pusht = 1; X confp->flags = 0; X } X! if (confp->irq < 0 || confp->irq > 15) { X error("Illegal card IRQ value"); X break; X } X--- 236,248 ---- X pusht = 1; X confp->flags = 0; X } X! #if 0 X! if (confp->irq < 0 || confp->irq > 15) X! #else X! /* quick hack: irq == 16 means PIO mode (hosokawa) */ X! if (confp->irq < 0 || confp->irq > 16) X! #endif X! { X error("Illegal card IRQ value"); X break; X } X*************** X*** 222,232 **** X--- 274,316 ---- X break; X case 9: X /* ether */ X+ #ifdef orig X cp->ether = num_tok(); X if (cp->ether == -1) { X error("Illegal ether address offset"); X cp->ether = 0; X } X+ #else X+ ether = xmalloc(sizeof(*ether)); X+ ether->type = ETHTYPE_GENERIC; X+ if (strcmp("megahertz", next_tok()) == 0) X+ ether->type = ETHTYPE_MEGAHERTZ; X+ else { X+ pusht = 1; X+ if (strcmp("wavelan", next_tok()) == 0) X+ ether->type = ETHTYPE_WAVELAN; X+ else X+ pusht = 1; X+ } X+ if (ether->type == ETHTYPE_GENERIC) { X+ ether->attr = num_tok(); X+ if (ether->attr == -1) { X+ error("Illegal ether address offset"); X+ free(ether); X+ break; X+ } X+ } X+ while (ether_mac_tok(ðer_mac) == 0) { X+ struct ether_mac *em = xmalloc(sizeof(*em)); X+ for (i = 0; i < 3; i++) X+ em->addr[i] = ether_mac.addr[i]; X+ em->next = ether->ether_mac; X+ ether->ether_mac = em; X+ } X+ pusht = 1; X+ ether->next = cp->ether; X+ cp->ether = ether; X+ #endif X break; X case 10: X /* insert */ X*************** X*** 236,241 **** X--- 320,367 ---- X /* remove */ X addcmd(&cp->remove); X break; X+ case 15: X+ /* cardio */ X+ card_io = xmalloc(sizeof(*card_io)); X+ card_io->addr = num_tok(); X+ card_io->size = num_tok(); X+ #ifdef DEBUG X+ if (verbose) X+ printf("cardio:addr=%x size=%x\n", X+ card_io->addr, card_io->size); X+ #endif X+ if (!confp) { X+ error("No valid config index for cardio"); X+ free(card_io); X+ break; X+ } X+ #if 0 X+ card_io = confp->card_io; X+ #endif X+ confp->card_io = card_io; X+ break; X+ case 16: X+ /* cardmem */ X+ card_mem = xmalloc(sizeof(*card_mem)); X+ card_mem->addr = num_tok(); X+ card_mem->cardaddr = num_tok(); X+ card_mem->size = num_tok(); X+ #ifdef DEBUG X+ if (verbose) X+ printf("cardmem:addr=%x cardaddr=%x size=%x\n", X+ card_mem->addr, card_mem->cardaddr, X+ card_mem->size); X+ #endif X+ if (!confp) { X+ error("No valid config index for cardio"); X+ free(card_mem); X+ break; X+ } X+ #if 0 X+ card_mem = confp->card_mem; X+ #endif X+ confp->card_mem = card_mem; X+ break; X default: X pusht = 1; X return; X*************** X*** 351,356 **** X--- 477,488 ---- X if (strcmp("?", next_tok()) == 0 && force) X return (0); X pusht = 1; X+ if (strcmp("any", next_tok()) == 0 && force) X+ return (0); X+ pusht = 1; X+ if (strcmp("pio", next_tok()) == 0 && force) X+ return (16); X+ pusht = 1; X i = num_tok(); X if (i > 0 && i < 16) X return (i); X*************** X*** 360,365 **** X--- 492,547 ---- X } X X /* X+ * Config index token X+ */ X+ static int X+ config_tok(void) X+ { X+ if (strcmp("default", next_tok()) == 0) X+ return 0; X+ pusht = 1; X+ return num_tok(); X+ } X+ X+ /* X+ * Function ID token X+ */ X+ static int X+ func_tok(void) X+ { X+ if (strcmp("serial", next_tok()) == 0) X+ return 2; X+ pusht = 1; X+ if (strcmp("fixed_disk", next_tok()) == 0) X+ return 4; X+ pusht = 1; X+ return num_tok(); X+ } X+ X+ /* X+ * Ethernet address token X+ */ X+ static int X+ ether_mac_tok(struct ether_mac *ether_mac) X+ { X+ unsigned char *t; X+ int i, x; X+ static int hex[] = {1, 1, 0, 1, 1, 0, 1, 1}; X+ X+ t = next_tok(); X+ if (strlen(t) != 8) X+ return -1; X+ for (i = 0; i < 8; i++) X+ if (!(hex[i] ? isxdigit(t[i]) : (t[i] == ':'))) X+ return -1; X+ for (i = 0; i < 3; i++) { X+ sscanf(t + i * 3, "%x", &x); X+ ether_mac->addr[i] = x; X+ } X+ return 0; X+ } X+ X+ /* X * search the table for a match. X */ X static int X*************** X*** 398,405 **** X error(char *msg) X { X pusht = 1; X! fprintf(stderr, "%s: %s at line %d, near %s\n", X! filename, msg, lineno, next_tok()); X pusht = 1; X } X X--- 580,587 ---- X error(char *msg) X { X pusht = 1; X! log_1s("%s: %s at line %d, near %s\n", X! filename, msg, lineno, next_tok()); X pusht = 1; X } X XIndex: readcis.c X=================================================================== XRCS file: /home/CVS/src/usr.sbin/pccard/pccardd/readcis.c,v Xretrieving revision 1.6 Xdiff -c -r1.6 readcis.c X*** readcis.c 1996/06/18 21:58:51 1.6 X--- readcis.c 1996/08/02 23:15:11 X*************** X*** 25,35 **** X--- 25,44 ---- X * X * $Id: readcis.c,v 1.6 1996/06/18 21:58:51 nate Exp $ X */ X+ X+ /* X+ * Code cleanup, bug-fix and extension X+ * by Tatsumi Hosokawa X+ */ X+ X #include X #include X #include X #include X #include X+ #ifdef SYSINSTALL X+ #include X+ #endif X X #include X #include X*************** X*** 42,47 **** X--- 51,57 ---- X static void device_desc(unsigned char *, int, struct dev_mem *); X static void config_map(struct cis *, unsigned char *, int); X static void cis_config(struct cis *, unsigned char *, int); X+ static void cis_func_id(struct cis *, unsigned char *, int); X static struct tuple_list *read_one_tuplelist(int, int, off_t); X static struct tuple_list *read_tuples(int); X static struct tuple *find_tuple_in_list(struct tuple_list *, unsigned char); X*************** X*** 98,104 **** X X for (tl = cp->tlist; tl; tl = tl->next) X for (tp = tl->tuples; tp; tp = tp->next) { X! #if 0 X printf("tuple code = 0x%02x, data is\n", tp->code); X dump(tp->data, tp->length); X #endif X--- 108,114 ---- X X for (tl = cp->tlist; tl; tl = tl->next) X for (tp = tl->tuples; tp; tp = tp->next) { X! #if DEBUG X printf("tuple code = 0x%02x, data is\n", tp->code); X dump(tp->data, tp->length); X #endif X*************** X*** 118,123 **** X--- 128,136 ---- X case CIS_CONFIG: /* 0x1B */ X cis_config(cp, tp->data, tp->length); X break; X+ case CIS_FUNC_ID: /* 0x21 */ X+ cis_func_id(cp, tp->data, tp->length); X+ break; X } X } X return (cp); X*************** X*** 177,182 **** X--- 190,225 ---- X } X X /* X+ * Fills in CIS function ID. X+ */ X+ static void X+ cis_func_id(struct cis *cp, unsigned char *p, int len) X+ { X+ cp->func_id1 = *p++; X+ cp->func_id2 = *p++; X+ } X+ X+ /* X+ * "FUJITSU LAN Card (FMV-J182)" has broken CIS X+ */ X+ static int X+ fmvj182_check(unsigned char *p) X+ { X+ char manuf[BUFSIZ], vers[BUFSIZ]; X+ X+ p++; /* major version */ X+ p++; /* minor version */ X+ strncpy(manuf, p, CIS_MAXSTR - 1); X+ while (*p++); X+ strncpy(vers, p, CIS_MAXSTR - 1); X+ while (*p++); X+ if (!strcmp(manuf, "FUJITSU") && !strcmp(vers, "LAN Card(FMV-J182)")) X+ return 1; X+ else X+ return 0; X+ } X+ X+ /* X * device_desc - decode device descriptor. X */ X static void X*************** X*** 437,443 **** X last_tl->next = tl; X last_tl = tl; X } X! } X } while (tl); X X /* X--- 480,487 ---- X last_tl->next = tl; X last_tl = tl; X } X! } else X! tl = 0; X } while (tl); X X /* X*************** X*** 466,471 **** X--- 510,516 ---- X struct tuple_info *tinfo; X int total = 0; X unsigned char code, length; X+ int fmvj182 = 0; X X /* Check to see if this memory has already been scanned. */ X for (tl = tlist; tl; tl = tl->next) X*************** X*** 491,500 **** X break; X } X total++; X tp->length = length; X #ifdef DEBUG X! fprintf(stderr, "Tuple code = 0x%x, len = %d\n", X! code, length); X #endif X if (length == 0xFF) { X length = tp->length = 0; X--- 536,546 ---- X break; X } X total++; X+ if (fmvj182 && (code == 0x1b) && (length == 25)) X+ length = 31; X tp->length = length; X #ifdef DEBUG X! printf("Tuple code = 0x%x, len = %d\n", code, length); X #endif X if (length == 0xFF) { X length = tp->length = 0; X*************** X*** 514,519 **** X--- 560,568 ---- X * or the length is illegal. X */ X tinfo = get_tuple_info(code); X+ if (code == 0x15) X+ /* Hack for broken CIS of FMV-J182 Ethernet card */ X+ fmvj182 = fmvj182_check(tp->data); X if (tinfo == 0 || (tinfo->length != 255 && tinfo->length != length)) { X printf("code %s ignored\n", tuple_name(code)); X tp->code = CIS_NULL; XIndex: readcis.h X=================================================================== XRCS file: /home/CVS/src/usr.sbin/pccard/pccardd/readcis.h,v Xretrieving revision 1.6 Xdiff -c -r1.6 readcis.h X*** readcis.h 1996/06/18 21:58:55 1.6 X--- readcis.h 1996/08/02 22:18:15 X*************** X*** 119,124 **** X--- 119,125 ---- X unsigned char last_config; X unsigned char ccrs; X unsigned long reg_addr; X+ unsigned char func_id1, func_id2; X struct dev_mem attr_mem; X struct dev_mem common_mem; X struct cis_config *def_config; XIndex: util.c X=================================================================== XRCS file: /home/CVS/src/usr.sbin/pccard/pccardd/util.c,v Xretrieving revision 1.6 Xdiff -c -r1.6 util.c X*** util.c 1996/06/20 21:06:53 1.6 X--- util.c 1996/08/02 23:09:35 X*************** X*** 25,50 **** X * X * $Id: util.c,v 1.6 1996/06/20 21:06:53 nate Exp $ X */ X #include X #include X #include X #include X #include X #include X #include X #include X #include "cardd.h" X X X void X! log_1s(char *msg, char *arg) X { X if (do_log) X! syslog(LOG_ERR, msg, arg); X else { X! fprintf(stderr, "cardd: "); X! fprintf(stderr, msg, arg); X! fprintf(stderr, "\n"); X } X } X X--- 25,81 ---- X * X * $Id: util.c,v 1.6 1996/06/20 21:06:53 nate Exp $ X */ X+ X+ /* X+ * Code cleanup, bug-fix and extension X+ * by: X+ * Tatsumi Hosokawa X+ * Nate Williams X+ */ X+ X #include X #include X #include X #include X #include X+ #include X #include X #include X #include X+ #ifdef SYSINSTALL X+ #include X+ #endif X #include "cardd.h" X X+ static int do_log = 0; X+ X+ void X+ log_setup(void) X+ { X+ #ifndef SYSINSTALL X+ do_log = 1; X+ openlog("pccardd", LOG_PID, LOG_DAEMON); X+ #endif X+ } X X void X! log_1s(const char *fmt, ...) X { X+ va_list ap; X+ char s[100]; X+ X+ va_start(ap, fmt); X+ vsprintf(s, fmt, ap); X+ X if (do_log) X! syslog(LOG_ERR, s); X else { X! #ifdef SYSINSTALL X! dialog_clear(); X! msgConfirm(s); X! #else X! fprintf(stderr, "cardd: %s\n", s); X! #endif X } X } X X*************** X*** 53,60 **** X { X if (do_log) X syslog(LOG_ERR, "%s: %m", msg); X! else X perror(msg); X } X X /* X--- 84,97 ---- X { X if (do_log) X syslog(LOG_ERR, "%s: %m", msg); X! else { X! #ifdef SYSINSTALL X! dialog_clear(); X! msgConfirm(msg); X! #else X perror(msg); X+ #endif X+ } X } X X /* X*************** X*** 65,72 **** X { X if (do_log) X syslog(LOG_CRIT, "fatal error: %s", msg); X! else X fprintf(stderr, "cardd fatal error: %s\n", msg); X closelog(); X exit(1); X } X--- 102,118 ---- X { X if (do_log) X syslog(LOG_CRIT, "fatal error: %s", msg); X! else { X! #ifdef SYSINSTALL X! char s[100]; X! X! sprintf(s, "cardd fatal error: %s\n", msg); X! dialog_clear(); X! msgConfirm(s); X! #else X fprintf(stderr, "cardd fatal error: %s\n", msg); X+ #endif X+ } X closelog(); X exit(1); X } X*************** X*** 122,131 **** X { X int i; X X! i = bit_fns(mem_avail, MEMBLKS, size / MEMUNIT); X if (i < 0) X return (0); X! bit_nclear(mem_avail, i, size / MEMUNIT); X return (BIT2MEM(i)); X } X X--- 168,177 ---- X { X int i; X X! i = bit_fns(mem_avail, MEMBLKS, size / MEMUNIT + (size % MEMUNIT != 0)); X if (i < 0) X return (0); X! bit_nclear(mem_avail, i, i + size / MEMUNIT + (size % MEMUNIT != 0) - 1); X return (BIT2MEM(i)); X } X X*************** X*** 216,222 **** X continue; X #ifdef DEBUG X fprintf(stderr, "Executing [%s]\n", cmd); X! #endif /* DEBUG */ X system(cmd); X } X } X--- 262,268 ---- X continue; X #ifdef DEBUG X fprintf(stderr, "Executing [%s]\n", cmd); X! #endif X system(cmd); X } X } END-of-cdif echo x - pccardd.c sed 's/^X//' >pccardd.c << 'END-of-pccardd.c' X/* X * Copyright (c) 1995 Andrew McRae. All rights reserved. X * X * Redistribution and use in source and binary forms, with or without X * modification, are permitted provided that the following conditions X * are met: X * 1. Redistributions of source code must retain the above copyright X * notice, this list of conditions and the following disclaimer. X * 2. Redistributions in binary form must reproduce the above copyright X * notice, this list of conditions and the following disclaimer in the X * documentation and/or other materials provided with the distribution. X * 3. The name of the author may not be used to endorse or promote products X * derived from this software without specific prior written permission. X * X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR X * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES X * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. X * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, X * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT X * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, X * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY X * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT X * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF X * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. X */ X X/* X * Code cleanup, bug-fix and extension X * by Tatsumi Hosokawa X */ X X#ifndef SYSINSTALL X#define DEBUG 1 X#endif /* SYSINSTALL */ X X/* X * pccardd X */ X#include X#include X#include X#include X#include X#include X#include X#include X#include X#include X#include X#include X#define EXTERN X#include "cardd.h" X Xchar *config_file = "/etc/pccard.conf"; Xchar *stand_config_file = "/stand/etc/pccard.conf"; X X/* X * pathname of UNIX-domain socket X */ Xchar *socket_name = "/tmp/.pccardd"; X Xvoid dump_config_file(void); Xvoid readslots(void); Xvoid slot_change(struct slot *); X X/* X * mainline code for pccardd X */ Xint Xmain(int argc, char *argv[]) X{ X struct slot *sp; X int count, debug = 0; X int verbose = 0; X char *conf = 0; X FILE *fp; X int s, slen; X struct sockaddr_un sun; X extern char *optarg; X extern int optind, optopt; X#define COM_OPTS ":dvf:" X X cards = last_card = 0; X X while ((count = getopt(argc, argv, COM_OPTS)) != -1) { X switch (count) { X case 'd': X setbuf(stdout, 0); X setbuf(stderr, 0); X debug = 1; X break; X case 'v': X verbose = 1; X break; X case 'f': X conf = optarg; X break; X case ':': X die("No config file argument"); X break; X case '?': X die("Illegal option"); X break; X } X } X#ifdef DEBUG X debug = 1; X#endif X io_avail = bit_alloc(IOPORTS); /* Only supports ISA ports */ X X /* Mem allocation done in MEMUNIT units. */ X mem_avail = bit_alloc(MEMBLKS); X if (!conf) { X if ((fp = fopen(config_file, "r"))) { X conf = config_file; X fclose(fp); X } else if ((fp = fopen(stand_config_file, "r"))) { X conf = stand_config_file; X fclose(fp); X } X } X if (!conf) X die("can't open default config file"); X readfile(conf); X if (verbose) X dump_config_file(); X log_setup(); X if (!debug) X if (daemon(0, 0)) X die("fork failed"); X readslots(); X if (slots == 0) X die("No PC-CARD slots"); X log_1s("pccardd started", NULL); X#ifdef SERVER X if ((s = socket(PF_LOCAL, SOCK_DGRAM, 0)) < 0) X die("socket failed"); X bzero(&sun, sizeof(sun)); X sun.sun_family = AF_UNIX; X strcpy(sun.sun_path, socket_name); X slen = SUN_LEN(&sun); X unlink(socket_name); X if (bind(s, (struct sockaddr *) & sun, slen) < 0) X die("bind failed"); X chown(socket_name, 0, 5); /* XXX - root.operator */ X chmod(socket_name, 0660); X set_socket(s); X#endif /* SERVER */ X X for (;;) { X fd_set rmask, emask; X FD_ZERO(&emask); X#ifdef SERVER X FD_ZERO(&rmask); X#endif /* SERVER */ X for (sp = slots; sp; sp = sp->next) X FD_SET(sp->fd, &emask); X#ifdef SERVER X FD_SET(s, &rmask); X count = select(32, &rmask, 0, &emask, 0); X#else /* SERVER */ X count = select(32, 0, 0, &emask, 0); X#endif /* SERVER */ X if (count == -1) { X perror("Select"); X continue; X } X if (count) { X for (sp = slots; sp; sp = sp->next) X if (FD_ISSET(sp->fd, &emask)) X slot_change(sp); X#ifdef SERVER X if (FD_ISSET(s, &rmask)) X process_client(); X#endif /* SERVER */ X } X } X} END-of-pccardd.c echo x - server.c sed 's/^X//' >server.c << 'END-of-server.c' X/* X * pccardd UNIX-domain socket interface X * Copyright (C) 1996 by Tatsumi Hosokawa X */ X#include X#include X#include X#include X#include X#include X#include X#include X X#include "cardd.h" X Xstatic void Xcardnum(char *buf) X{ X int i = 0; X struct slot *sp; X X for (sp = slots; sp; sp = sp->next) X i++; X if (i > MAXSLOT) X i = MAXSLOT; X sprintf(buf, "%2d", i); X} X Xstatic struct slot * Xfind_slot(int slot) X{ X struct slot *sp; X X /* Search the list until we find the slot or get to the end */ X for (sp = slots; sp && sp->slot != slot; sp = sp->next) X continue; X X return ( sp ); X} X Xstatic void Xcardname(char *buf, int slot) X{ X struct slot *sp; X char *manuf, *vers, *drv, *stat; X X /* Look for the slot */ X if ( (sp = find_slot(slot)) == NULL) X return; X X /* Fill in the information in the buff */ X if (sp->cis) { X X manuf = sp->cis->manuf; X vers = sp->cis->vers; X if (sp->config && sp->config->driver && X sp->config->driver->name) X drv = sp->config->driver->name; X else X drv = ""; X } else X manuf = vers = drv = ""; X X switch (sp->state) { X case empty: X stat = "0"; X break; X case filled: X stat = "1"; X break; X#if 0 X case inactive: X stat = "2"; X break; X#endif X default: X stat = "9"; X } X sprintf(buf, "%d~%s~%s~%s~%s", slot, manuf, vers, drv, stat); X} X Xstatic void Xcardpwr(int slot, int pwon) X{ X struct slot *sp; X X /* Look for the slot */ X if ( (sp = find_slot(slot)) == NULL) X return; X X#if 0 X if (ioctl(sp->fd, PIOCSVIR, &pwon) < 0) X logerr("invaild arguments for cardpwr"); X#endif X} X Xstatic int sock = 0; Xstatic int slen = 0; Xstatic struct sockaddr_un sun; X Xvoid Xset_socket(int s) X{ X sock = s; X} X Xvoid Xstat_changed(struct slot *sp) X{ X int len; X char buf[512]; X X if (!slen) X return; X X cardname(buf, sp->slot); X len = strlen(buf); X if (sendto(sock, buf, len, 0, (struct sockaddr *) & sun, slen) != len) { X logerr("sendto failed"); X slen = 0; X } X} X Xvoid Xprocess_client(void) X{ X char buf[512], obuf[512]; X int len; X int snum; X X if (!sock) X return; X slen = sizeof(sun); X len = recvfrom(sock, buf, sizeof(buf), X 0, (struct sockaddr *)&sun, &slen); X if (len < 0) X logerr("recvfrom failed"); X obuf[0] = '\0'; X switch (buf[0]) { X case 'S': X cardnum(obuf); X break; X case 'N': X sscanf(buf + 1, "%d", &snum); X if (snum >= 0 && snum <= MAXSLOT) X cardname(obuf, snum); X else X logerr("Illegal slot requests for N command"); X break; X case 'P': X sscanf(buf + 1, "%d", &snum); X if (snum >= 0 && snum <= MAXSLOT) { X log_1s("slot %d: spring has come", snum); X cardpwr(snum, 1); X } else X logerr("Illegal slot requests for P command"); X break; X case 'Q': X sscanf(buf + 1, "%d", &snum); X if (snum >= 0 && snum <= MAXSLOT) { X log_1s("slot %d: hybernation", snum); X cardpwr(snum, 0); X } else X logerr("Illegal slot requests for Q command"); X break; X default: X logerr("Unknown control message from socket"); X break; X } X len = strlen(obuf); X if (len) { X if (sendto(sock, obuf, len, 0, (struct sockaddr *)&sun, slen) X != len) { X logerr("sendto failed"); X slen = 0; X } X } else if (sendto(sock, 0, 0, 0, (struct sockaddr *)&sun, slen) X != len) { X logerr("sendto failed"); X slen = 0; X } X} END-of-server.c exit