Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 06 Apr 2000 20:50:45 -0400
From:      "Gary T. Corcoran" <gcorcoran@lucent.com>
To:        Mike Smith <msmith@freebsd.org>
Cc:        Warner Losh <imp@village.org>, freebsd-hackers@freebsd.org
Subject:   Re: How to get multiple PCI I/O base addresses in attach()?
Message-ID:  <38ED30E5.CA9D9578@lucent.com>
References:  <200004070010.RAA01618@mass.cdrom.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?38ED30E5.CA9D9578>