From owner-svn-src-all@FreeBSD.ORG Thu Oct 28 16:57:48 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BDCD5106566B; Thu, 28 Oct 2010 16:57:48 +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 8E18F8FC1F; Thu, 28 Oct 2010 16:57:48 +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 3DA5346B49; Thu, 28 Oct 2010 12:57:48 -0400 (EDT) Received: from jhbbsd.localnet (smtp.hudson-trading.com [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 20B3E8A009; Thu, 28 Oct 2010 12:57:47 -0400 (EDT) From: John Baldwin To: Attilio Rao Date: Thu, 28 Oct 2010 12:57:05 -0400 User-Agent: KMail/1.13.5 (FreeBSD/7.3-CBSD-20100819; KDE/4.4.5; amd64; ; ) References: <201010281631.o9SGVdtZ014923@svn.freebsd.org> In-Reply-To: <201010281631.o9SGVdtZ014923@svn.freebsd.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201010281257.05481.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Thu, 28 Oct 2010 12:57:47 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.96.3 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-1.9 required=4.2 tests=BAYES_00 autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on bigwig.baldwin.cx Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r214457 - in head/sys: amd64/amd64 conf i386/i386 x86/x86 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Oct 2010 16:57:48 -0000 On Thursday, October 28, 2010 12:31:39 pm Attilio Rao wrote: > Author: attilio > Date: Thu Oct 28 16:31:39 2010 > New Revision: 214457 > URL: http://svn.freebsd.org/changeset/base/214457 > > Log: > Merge nexus.c from amd64 and i386 to x86 subtree. > > Sponsored by: Sandvine Incorporated > Tested by: gianni > > Added: > head/sys/x86/x86/nexus.c > - copied, changed from r214446, head/sys/i386/i386/nexus.c > Deleted: > head/sys/amd64/amd64/nexus.c > head/sys/i386/i386/nexus.c > Modified: > head/sys/conf/files.amd64 > head/sys/conf/files.i386 > head/sys/conf/files.pc98 > ============================================================================== > --- head/sys/conf/files.pc98 Thu Oct 28 16:23:25 2010 (r214456) > +++ head/sys/conf/files.pc98 Thu Oct 28 16:31:39 2010 (r214457) > @@ -156,7 +156,6 @@ i386/i386/mp_clock.c optional smp > i386/i386/mp_machdep.c optional smp > i386/i386/mp_watchdog.c optional mp_watchdog smp > i386/i386/mpboot.s optional smp > -i386/i386/nexus.c standard > i386/i386/perfmon.c optional perfmon > i386/i386/pmap.c standard > i386/i386/ptrace_machdep.c standard > @@ -259,3 +258,4 @@ x86/x86/mca.c standard > x86/x86/mptable.c optional apic > x86/x86/mptable_pci.c optional apic pci > x86/x86/msi.c optional apic pci > +x86/x86/nexus.c standard > > Copied and modified: head/sys/x86/x86/nexus.c (from r214446, head/sys/i386/i386/nexus.c) > ============================================================================== > --- head/sys/i386/i386/nexus.c Thu Oct 28 07:58:06 2010 (r214446, copy source) > +++ head/sys/x86/x86/nexus.c Thu Oct 28 16:31:39 2010 (r214457) > @@ -41,13 +41,20 @@ __FBSDID("$FreeBSD$"); > * and I/O memory address space. > */ > > +#ifdef __amd64__ > +#define DEV_APIC > +#else > #include "opt_apic.h" > +#endif > #include "opt_isa.h" > > #include > #include > #include > #include > +#ifdef __amd64__ > +#include > +#endif > #include > #include > #include > @@ -60,6 +67,10 @@ __FBSDID("$FreeBSD$"); > #include > #include > > +#ifdef __amd64__ > +#include > +#include > +#endif > #include > #include > > @@ -77,6 +88,14 @@ __FBSDID("$FreeBSD$"); > #endif > #include > > +#ifdef __amd64__ > +#define RMAN_BUS_SPACE_IO AMD64_BUS_SPACE_IO > +#define RMAN_BUS_SPACE_MEM AMD64_BUS_SPACE_MEM > +#else > +#define RMAN_BUS_SPACE_IO I386_BUS_SPACE_IO > +#define RMAN_BUS_SPACE_MEM I386_BUS_SPACE_MEM > +#endif > + Perhaps we should be using X86_BUS_SPACE_* instead? > @@ -649,6 +668,42 @@ ram_probe(device_t dev) > return (0); > } > > +#ifdef __amd64__ > +static int > +ram_attach(device_t dev) > +{ > + struct bios_smap *smapbase, *smap, *smapend; > + struct resource *res; > + caddr_t kmdp; > + uint32_t smapsize; > + int error, rid; > + > + /* Retrieve the system memory map from the loader. */ > + kmdp = preload_search_by_type("elf kernel"); > + if (kmdp == NULL) > + kmdp = preload_search_by_type("elf64 kernel"); > + smapbase = (struct bios_smap *)preload_search_info(kmdp, > + MODINFO_METADATA | MODINFOMD_SMAP); > + smapsize = *((u_int32_t *)smapbase - 1); > + smapend = (struct bios_smap *)((uintptr_t)smapbase + smapsize); > + > + rid = 0; > + for (smap = smapbase; smap < smapend; smap++) { > + if (smap->type != SMAP_TYPE_MEMORY || smap->length == 0) > + continue; > + error = bus_set_resource(dev, SYS_RES_MEMORY, rid, smap->base, > + smap->length); > + if (error) > + panic("ram_attach: resource %d failed set with %d", rid, > + error); > + res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, 0); > + if (res == NULL) > + panic("ram_attach: resource %d failed to attach", rid); > + rid++; > + } > + return (0); > +} > +#else > static int > ram_attach(device_t dev) > { > @@ -688,6 +743,7 @@ ram_attach(device_t dev) > } > return (0); > } > +#endif It would be better to merge these two routines. The loader now passes the smap to i386 kernels as well, so ram_attach() should probably be changed to try the amd64 approach first and if that fails fall back to using the phys_avail[] array instead. -- John Baldwin