From owner-freebsd-hackers Sat Jul 10 8:28: 3 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from mail5.svr.pol.co.uk (mail5.svr.pol.co.uk [195.92.193.20]) by hub.freebsd.org (Postfix) with ESMTP id 196EA1530B; Sat, 10 Jul 1999 08:27:46 -0700 (PDT) (envelope-from s.mitchell@computer.org) Received: from modem-101.tellurium.dialup.pol.co.uk ([62.136.25.229] helo=valis.goatsucker.org) by mail5.svr.pol.co.uk with esmtp (Exim 2.12 #1) id 112z2X-0006t2-00; Sat, 10 Jul 1999 16:27:45 +0100 Received: (from scott@localhost) by valis.goatsucker.org (8.8.8/8.8.7) id QAA02148; Sat, 10 Jul 1999 16:27:31 +0100 (BST) (envelope-from scott) Message-ID: <19990710162730.60563@goatsucker.org> Date: Sat, 10 Jul 1999 16:27:30 +0100 From: Scott Mitchell To: Poul-Henning Kamp , freebsd-xircom@lovett.com Cc: hackers@FreeBSD.ORG, mobile@FreeBSD.ORG, "David O'Brien" Subject: Reading CIS from kernel? Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.89i X-Operating-System: FreeBSD 2.2.6-RELEASE i386 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hi all, The Xircom ethernet driver needs to read/write PCCARD attribute memory from its probe routine, in order to identify the type of card and to beat brain-damaged CEM56 cards into shape :-) Currently this is done by way of 'fake' calls to read() and write() on the appropriate /dev/cardXX device. However, if we look at the version of the driver that David O'Brien has kindly committed to the repository (http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/dev/pccard/if_xe.c) we see: =================================================================== RCS file: /home/ncvs/src/sys/dev/pccard/if_xe.c,v retrieving revision 1.2 retrieving revision 1.3 diff -p -u -r1.2 -r1.3 --- src/sys/dev/pccard/if_xe.c 1999/05/14 04:18:24 1.2 +++ /home/ncvs/src/sys/dev/pccard/if_xe.c 1999/05/31 11:24:51 1.3 @@ -352,7 +352,11 @@ xe_memwrite(struct pccard_devinfo *devi, uios.uio_rw = UIO_WRITE; uios.uio_procp = 0; +#if 0 /* THIS IS BOGUS */ return cdevsw[CARD_MAJOR]->d_write(makedev(CARD_MAJOR, devi->slt->slotnum), &uios, 0); +#else + return (-1); +#endif } @@ -373,7 +377,11 @@ xe_memread(struct pccard_devinfo *devi, uios.uio_rw = UIO_READ; uios.uio_procp = 0; +#if 0 /* THIS IS BOGUS */ return cdevsw[CARD_MAJOR]->d_read(makedev(CARD_MAJOR, devi->slt->slotnum), &uios, 0); +#else + return (-1); +#endif } Now I'll grant you that it probably *is* bogus, but when I first started writing the driver it was the least ugly solution proposed. So, since I can't do it that way anymore, are there any suggestions for an 'approved' way of reading/writing PCCARD attribute memory from inside the kernel? If it's just the use of cdevsw[] that's problematic, then making crdread() and crdwrite() (in /sys/pccard/pccard.c) non-static and calling them directly from the driver code would be an easy workaround. Alternatively, I could export pccard_mem and pccard_kmem from the same file and do the reads and writes myself, but that seems a bit dangerous. Any other approach would seem to involve duplicating more of the PCCARD code than I care to, expecially considering that it's all being redone in the newbus-ification of -CURRENT. I'd appreciate some advice from the powers-that-be as to what will and won't get stomped on here, as both David and I would like to see a *working* version of this code in the tree... Cheers, Scott -- =========================================================================== Scott Mitchell | PGP Key ID | "Eagles may soar, but weasels London, England | 0x54B171B9 | don't get sucked into jet engines" s.mitchell@computer.org | 0xAA775B8B | -- Anon To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message