From owner-freebsd-hackers Thu Apr 6 17: 5:40 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from mass.cdrom.com (mass.cdrom.com [204.216.28.184]) by hub.freebsd.org (Postfix) with ESMTP id 2182D37C332 for ; Thu, 6 Apr 2000 17:05:36 -0700 (PDT) (envelope-from msmith@mass.cdrom.com) Received: from mass.cdrom.com (localhost [127.0.0.1]) by mass.cdrom.com (8.9.3/8.9.3) with ESMTP id RAA01618; Thu, 6 Apr 2000 17:10:38 -0700 (PDT) (envelope-from msmith@mass.cdrom.com) Message-Id: <200004070010.RAA01618@mass.cdrom.com> X-Mailer: exmh version 2.1.1 10/15/1999 To: "Gary T. Corcoran" Cc: Warner Losh , freebsd-hackers@freebsd.org Subject: Re: How to get multiple PCI I/O base addresses in attach()? In-reply-to: Your message of "Thu, 06 Apr 2000 16:14:03 EDT." <38ECF00B.CA0AD45B@lucent.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 06 Apr 2000 17:10:38 -0700 From: Mike Smith Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > 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