From owner-freebsd-hackers Tue Oct 24 15:11:23 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from MIT.EDU (SOUTH-STATION-ANNEX.MIT.EDU [18.72.1.2]) by hub.freebsd.org (Postfix) with SMTP id A5FA737B479; Tue, 24 Oct 2000 15:11:17 -0700 (PDT) Received: from GRAND-CENTRAL-STATION.MIT.EDU by MIT.EDU with SMTP id AA11896; Tue, 24 Oct 00 18:11:00 EDT Received: from melbourne-city-street.MIT.EDU (MELBOURNE-CITY-STREET.MIT.EDU [18.69.0.45]) by grand-central-station.MIT.EDU (8.9.2/8.9.2) with ESMTP id SAA20476; Tue, 24 Oct 2000 18:08:46 -0400 (EDT) Received: from contents-vnder-pressvre.mit.edu (CONTENTS-VNDER-PRESSVRE.MIT.EDU [18.184.0.40]) by melbourne-city-street.MIT.EDU (8.9.3/8.9.2) with ESMTP id SAA29217; Tue, 24 Oct 2000 18:08:45 -0400 (EDT) Received: (from daveg@localhost) by contents-vnder-pressvre.mit.edu (8.9.3) id SAA13482; Tue, 24 Oct 2000 18:08:45 -0400 (EDT) To: Mike Smith Cc: freebsd-hackers@freebsd.org Subject: Re: PCI Device Remapping References: <200010242118.e9OLIXh02243@mass.osd.bsdi.com> From: David D Golombek Date: 24 Oct 2000 18:08:45 -0400 In-Reply-To: Mike Smith's message of "Tue, 24 Oct 2000 14:18:33 -0700" Message-Id: Lines: 63 User-Agent: Gnus/5.0803 (Gnus v5.8.3) Emacs/20.3 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Mike Smith writes: > If you're working on a single, fixed platform, this should be pretty > simple; they just lop the top bit off the base address they use for PCI > address allocation. > > Here's an evil trick you can pull though, if you're *really* desperate > and if you're *certain* that you're in control of your platform, and > *certain* that you'll never have more than ~1.9GB of physical memory. > > In sys/pci/pci.c:pci_readmaps(), fix the loop that reads maps to knock the > high bit off memory ranges and write them back: > > for (i = 0; i < maxmaps; i++) { > int reg = PCIR_MAPS + i*4; > u_int32_t base; > u_int32_t ln2range; > > base = pci_cfgread(cfg, reg, 4); > ln2range = pci_maprange(base); > > if (base == 0 || ln2range == 0 || base == 0xffffffff) > continue; /* skip invalid entry */ > else { > /* remap below 2GB */ > if (pci_maptype(base) == PCI_MAPMEM) { > base &= ~0x80000000; > pci_cfgwrite(cfg, reg, base, 4); > ln2range = pci_maprange(base); > } > j++; > if (ln2range > 32) { > i++; > j++; > } > } > } > > This is, of course, only a solution if you have total control over the > system as well; if you plan to ship the product for inclusion in general > FreeBSD systems, you're prettymuch hosed. This is actually only needed for an internal use project, and this hack is exactly what I was looking for! It works wonderfully, although I had to change the code slightly: if ((pci_maptype(base) & PCI_MAPMEM) == PCI_MAPMEM) { base &= ~0x80000000; printf("0x%x)\n", base); pci_cfgwrite(cfg, reg, base, 4); ln2range = pci_maprange(base); } to handle prefetchable memory as well. Thank you very much for the suggestion -- I'd read through that code, but didn't think about the simple fix you've suggested! DaveG o_, o, o_ o_ o' Programmer )-' /|' ),` ) ' (\ ^o Gymnast Dancer >\ / > >\ >^' >\ >>' Hiker daveg@mit.edu www.mit.edu/~daveg/ (617)216-4705 dave.golombek@conexant.com www.conexant.com (508)621-0658 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message