From owner-freebsd-hackers Wed Apr 5 22:54:55 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from rover.village.org (rover.village.org [204.144.255.49]) by hub.freebsd.org (Postfix) with ESMTP id E4BD037BAA7 for ; Wed, 5 Apr 2000 22:54:51 -0700 (PDT) (envelope-from imp@harmony.village.org) Received: from harmony.village.org (harmony.village.org [10.0.0.6]) by rover.village.org (8.9.3/8.9.3) with ESMTP id XAA99562; Wed, 5 Apr 2000 23:54:49 -0600 (MDT) (envelope-from imp@harmony.village.org) Received: from harmony.village.org (localhost.village.org [127.0.0.1]) by harmony.village.org (8.9.3/8.8.3) with ESMTP id XAA88923; Wed, 5 Apr 2000 23:54:02 -0600 (MDT) Message-Id: <200004060554.XAA88923@harmony.village.org> To: "Gary T. Corcoran" Subject: Re: How to get multiple PCI I/O base addresses in attach()? Cc: freebsd-hackers@FreeBSD.ORG In-reply-to: Your message of "Wed, 05 Apr 2000 23:07:57 EDT." <38EBFF8D.56BB4841@home.com> References: <38EBFF8D.56BB4841@home.com> Date: Wed, 05 Apr 2000 23:54:02 -0600 From: Warner Losh Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In message <38EBFF8D.56BB4841@home.com> "Gary T. Corcoran" writes: : I installed FreeBSD 4.0 and I'm trying to write the attach() routine : for my device driver, to be compiled as a loadable module. In 4.0 : the attach routine only gets passed a dev pointer, not a PCI configuration : pointer. My PCI device has up to 6 I/O ranges, and I need to get the : base addresses for those ranges. : : So how does one get multiple I/O base addresses from a dev pointer : for a PCI device in FreeBSD 4.x ? rid = 0x10; res1 = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, 0, ~0, 1, RF_ACTIVE); rid = 0x14; res2 = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, 0, ~0, 1, RF_ACTIVE); rid = 0x18; res3 = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, 0, ~0, 1, RF_ACTIVE); rid = 0x1c; res4 = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, 0, ~0, 1, RF_ACTIVE); rid = 0x20; res5 = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, 0, ~0, 1, RF_ACTIVE); rid = 0x24; res6 = 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. Warner To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message