Date: Thu, 06 Apr 2000 17:10:38 -0700 From: Mike Smith <msmith@freebsd.org> To: "Gary T. Corcoran" <gcorcoran@lucent.com> 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: <200004070010.RAA01618@mass.cdrom.com> In-Reply-To: Your message of "Thu, 06 Apr 2000 16:14:03 EDT." <38ECF00B.CA0AD45B@lucent.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> Warner, > > > rid = 0x10; > > res1 = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, 0, ~0, 1, RF_ACTIVE); > ... > > should do the trick. Change SYS_RES_MEMORY to SYS_RES_IOPORT if it is > > I/O mapped rather than memory mapped. > > > > In case it wasn't clear, the rid is the offset into the config space > > where the BAR register that you want to use is. Multiples of 4 only > > need apply. > > Thanks, that helps. BUT... > At first I thought "res1" would be the base address I was looking for. > However, it appears (boy I wish this stuff was documented!) that > bus_alloc_resource returns a "struct resource *". But I looked and > looked and I can't find the definition of what a "struct resource" is. > So I'm still in the dark as to how to get my I/O base address from > the pointer returned by the bus_alloc_resource. How do I do that? You don't. You use rman_get_bustag() and rman_get_bushandle() to get the bus tag and bus handle for the region, and then pass these to the bus_space_read_? and bus_space_write_? functions when you want to perform your I/O. You're probably looking at code that thinks it can do "inb" and so forth; 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). 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. -- \\ Give a man a fish, and you feed him for a day. \\ Mike Smith \\ Tell him he should learn how to fish himself, \\ msmith@freebsd.org \\ and he'll hate you for a lifetime. \\ msmith@cdrom.com 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?200004070010.RAA01618>