From owner-freebsd-hackers Thu Apr 6 17:46:45 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from alemail1.firewall.lucent.com (alemail1.lucent.com [192.11.221.161]) by hub.freebsd.org (Postfix) with ESMTP id E878837C1FC; Thu, 6 Apr 2000 17:46:35 -0700 (PDT) (envelope-from gcorcoran@lucent.com) Received: from alemail1.firewall.lucent.com (localhost [127.0.0.1]) by alemail1.firewall.lucent.com (Pro-8.9.3/8.9.3) with ESMTP id UAA04240; Thu, 6 Apr 2000 20:46:34 -0400 (EDT) Received: from mhmail.mh.lucent.com (h135-3-115-8.lucent.com [135.3.115.8]) by alemail1.firewall.lucent.com (Pro-8.9.3/8.9.3) with ESMTP id UAA04236; Thu, 6 Apr 2000 20:46:34 -0400 (EDT) Received: from lucent.com by mhmail.mh.lucent.com (8.8.8+Sun/EMS-1.5 sol2) id UAA20644; Thu, 6 Apr 2000 20:46:31 -0400 (EDT) Message-ID: <38ED30E5.CA9D9578@lucent.com> Date: Thu, 06 Apr 2000 20:50:45 -0400 From: "Gary T. Corcoran" Organization: Lucent Microelectronics - Modem and Multimedia Systems X-Mailer: Mozilla 4.06 [en] (Win98; U) MIME-Version: 1.0 To: Mike Smith Cc: Warner Losh , freebsd-hackers@freebsd.org Subject: Re: How to get multiple PCI I/O base addresses in attach()? References: <200004070010.RAA01618@mass.cdrom.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Mike Smith wrote: > You're probably looking at code that thinks it can do "inb" and so forth; Yep, more or less. That is, sprinkled throughout the code, there are things of the form (just to give 1 example): NdisRawReadPortUchar( (OneOfTheBaseAddresses + SomeOffset), &variable); > sorry, we don't do that anymore (and if you want this code to work on > anything other than an x86 system, you need to come to grips with this). I kinda figured that. However, since I don't have anything but x86 systems in my lab, and this FreeBSD support is (so far) only a one-man-show, and we won't be releasing the source code for this, I'm willing to special-case it if need be... > If you're fighting a legacy codebase, you've got an interesting time > ahead of you with six separate regions; just hacking around this with > preprocessor macros isn't going to be terribly easy. Yes, I'm trying to port our driver by supplying "glue" in the form of macros and small translating C routines (plus FreeBSD-only initialization code). And I see you understand the problem -- I was hoping to do something like: #define NdisRawReadPortUchar( _port, _ptr) *(_ptr) = inb((_port)) But for this scheme to work, I need to have the base addresses defined correctly, since when I get an NdisRawReadPort*(), I don't know from which of the base addresses they offset. Now I can come up with a kluge, and assign arbitrary but defined addresses to the base addresses, and then write a little glue subroutine to see if the port address is within a certain range it must have been an offset from that certain bus resource, subtract the then-known base address to get the offset, and then do the bus_space_read. But you can see that that is a kluge which adds a few cycles of overhead for every access (and is more suited to a small routine than a macro :). So I was about to ask for help in getting the real I/O base addresses, when I went looking through the system header files and found that, for x86 machines, the "handle" is, effectively, really the I/O base address. So, since I'm only targeting x86 machines anyway, I decided to "cheat" and take the return values from rman_get_bushandle() and assign them to my base addresses. Then I *can* use the simple macros like the one above. As long as I stick to x86 machines, do you see any problem in doing this? [Side note: now that I wiped FreeBSD 3.4 and installed 4.0, I'm getting random spontaneous reboots of my machine, 2 or 3 times per day (just running X, terminals, and either vi or a screensaver). It's *very* annoying! :) :-( (and I haven't even *tried* to load *my* driver yet) Nothing shows up in /var/log/messages, but I guess that's not too surprising.] Thanks, Gary To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message