From owner-freebsd-hackers@FreeBSD.ORG Tue Aug 30 12:16:55 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 899DA106566C for ; Tue, 30 Aug 2011 12:16:55 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 6275E8FC12 for ; Tue, 30 Aug 2011 12:16:55 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 00ABE46B17; Tue, 30 Aug 2011 08:16:55 -0400 (EDT) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 8F40B8A02E; Tue, 30 Aug 2011 08:16:54 -0400 (EDT) From: John Baldwin To: freebsd-hackers@freebsd.org Date: Tue, 30 Aug 2011 08:16:53 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110617; KDE/4.5.5; amd64; ; ) References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201108300816.54198.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Tue, 30 Aug 2011 08:16:54 -0400 (EDT) Cc: hilfi alkaff Subject: Re: pcie initialization with acpi X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Aug 2011 12:16:55 -0000 On Friday, August 26, 2011 9:02:34 pm hilfi alkaff wrote: > Hi, > > I would like to learn more of the above matter. After the MCFG table gets > discovered with acpi, what does the address given by the > ACPI_MCFG_ALLOCATION* tells you? Does that tell you the address of the > extended configuration space of pci express? No, it tells you about a memory-mapped region you can use for all PCI config access. The region is defined to give the full config space access per device (so the lower N bits in the address are used to address a given config register within a single device). This macro details how the address mapping works: #define PCIE_VADDR(base, reg, bus, slot, func) \ ((base) + \ ((((bus) & 0xff) << 20) | \ (((slot) & 0x1f) << 15) | \ (((func) & 0x7) << 12) | \ ((reg) & 0xfff))) So the lower 12 bits select the register and the next 16 bits specify the device's bus/slot/function. > Also, is BSD distinguishing between reading from pcie config & pci config? > Because there's this pciereg_cfgread() function that seem to do that. I > thought pcie config space is just at the offset of 0x100 from pci config > space? BSD only distinguishes in that it refuses to access registers above 0x100 if MCFG is not in use on x86. If MCFG is in use, it is used for all config access (both "standard" and "extended"). See this routine for an example: /* * Write configuration space register */ void pci_cfgregwrite(int bus, int slot, int func, int reg, u_int32_t data, int bytes) { if (cfgmech == CFGMECH_PCIE && (bus >= pcie_minbus && bus <= pcie_maxbus) && (bus != 0 || !(1 << slot & pcie_badslots))) pciereg_cfgwrite(bus, slot, func, reg, data, bytes); else pcireg_cfgwrite(bus, slot, func, reg, data, bytes); } If the device is on a bus managed by MCFG (pcie_minbus <= bus <= pcie_maxbus) and it's not subject to a quirk we use for some broken HT chipsets (the pcie_badslots that lists known "broken" slots on bus 0 for the broken chipsets), then MCFG is used for all config access. -- John Baldwin