From owner-svn-src-all@FreeBSD.ORG Thu Oct 28 17:21:36 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 373E3106566B; Thu, 28 Oct 2010 17:21:36 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from mail-qy0-f175.google.com (mail-qy0-f175.google.com [209.85.216.175]) by mx1.freebsd.org (Postfix) with ESMTP id 91A8A8FC14; Thu, 28 Oct 2010 17:21:35 +0000 (UTC) Received: by qyk7 with SMTP id 7so5061610qyk.13 for ; Thu, 28 Oct 2010 10:21:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=gX9IMByX9I62+n02gzEiommMKBInxX3WrdwXyVPFuGE=; b=gxPP30vkMuBkR5/uKaw1UbZIGORv5PcjPBsOrd06WIh/5tYcz3vVPLXmW9AnmHiDcd xatMinmNpBN6tRFh7nRW38ezueW6P+mpXkbdCaGxmWDWrWUA40P1oIwEdHaXSuk5IfU7 xSKd9/gA2QeGeLvg9+kMVlA8WimuhA5WedFZ4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=qk8eD4pZ/ZWsOHXcnLQpPTTy2G2rHL1Ev+23HJ6yz1oX92V9v3nqCCY/0Y/YU2O9NK IxvFKax5I/iK4COJcGzGtx3tWS1VGiiU3TIoY03dzcR5f7tHiCcwiC7FjRJoxK4I4t+5 YnV4djAV3WDBRDDTanv+k9JJgTGhVR43Y+POA= MIME-Version: 1.0 Received: by 10.229.224.81 with SMTP id in17mr5845671qcb.81.1288286494550; Thu, 28 Oct 2010 10:21:34 -0700 (PDT) Sender: asmrookie@gmail.com Received: by 10.229.237.9 with HTTP; Thu, 28 Oct 2010 10:21:34 -0700 (PDT) In-Reply-To: <201010281257.05481.jhb@freebsd.org> References: <201010281631.o9SGVdtZ014923@svn.freebsd.org> <201010281257.05481.jhb@freebsd.org> Date: Thu, 28 Oct 2010 19:21:34 +0200 X-Google-Sender-Auth: DourtyZ_MWrdNLSDgB4fz5-583Q Message-ID: From: Attilio Rao To: John Baldwin Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 17:21:36 -0000 2010/10/28 John Baldwin : > 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: >> =C2=A0 Merge nexus.c from amd64 and i386 to x86 subtree. >> >> =C2=A0 Sponsored by: =C2=A0 =C2=A0 =C2=A0 Sandvine Incorporated >> =C2=A0 Tested by: =C2=A0gianni >> > > It would be better to merge these two routines. =C2=A0The loader now pass= es 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. What do you think about this patch?: Index: nexus.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- nexus.c (revision 214457) +++ nexus.c (working copy) @@ -52,9 +52,7 @@ #include #include #include -#ifdef __amd64__ #include -#endif #include #include #include @@ -67,12 +65,10 @@ #include #include -#ifdef __amd64__ #include -#include -#endif #include #include +#include #ifdef DEV_APIC #include "pcib_if.h" @@ -89,11 +85,13 @@ #include #ifdef __amd64__ -#define RMAN_BUS_SPACE_IO AMD64_BUS_SPACE_IO -#define RMAN_BUS_SPACE_MEM AMD64_BUS_SPACE_MEM +#define X86_BUS_SPACE_IO AMD64_BUS_SPACE_IO +#define X86_BUS_SPACE_MEM AMD64_BUS_SPACE_MEM +#define ELF_KERN_STR "elf64 kernel" #else -#define RMAN_BUS_SPACE_IO I386_BUS_SPACE_IO -#define RMAN_BUS_SPACE_MEM I386_BUS_SPACE_MEM +#define X86_BUS_SPACE_IO I386_BUS_SPACE_IO +#define X86_BUS_SPACE_MEM I386_BUS_SPACE_MEM +#define ELF_KERN_STR "elf32 kernel" #endif static MALLOC_DEFINE(M_NEXUSDEV, "nexusdev", "Nexus device"); @@ -435,7 +433,7 @@ #else rman_set_bushandle(r, rman_get_start(r)); #endif - rman_set_bustag(r, RMAN_BUS_SPACE_IO); + rman_set_bustag(r, X86_BUS_SPACE_IO); break; case SYS_RES_MEMORY: #ifdef PC98 @@ -446,7 +444,7 @@ #endif vaddr =3D pmap_mapdev(rman_get_start(r), rman_get_size(r)); rman_set_virtual(r, vaddr); - rman_set_bustag(r, RMAN_BUS_SPACE_MEM); + rman_set_bustag(r, X86_BUS_SPACE_MEM); #ifdef PC98 /* PC-98: the type of bus_space_handle_t is the structure. = */ bh->bsh_base =3D (bus_addr_t) vaddr; @@ -668,20 +666,20 @@ return (0); } -#ifdef __amd64__ static int ram_attach(device_t dev) { struct bios_smap *smapbase, *smap, *smapend; struct resource *res; + vm_paddr_t *p; caddr_t kmdp; uint32_t smapsize; - int error, rid; + int error, i, rid; /* Retrieve the system memory map from the loader. */ kmdp =3D preload_search_by_type("elf kernel"); if (kmdp =3D=3D NULL) - kmdp =3D preload_search_by_type("elf64 kernel"); + kmdp =3D preload_search_by_type(ELF_KERN_STR); smapbase =3D (struct bios_smap *)preload_search_info(kmdp, MODINFO_METADATA | MODINFOMD_SMAP); smapsize =3D *((u_int32_t *)smapbase - 1); @@ -701,16 +699,11 @@ panic("ram_attach: resource %d failed to attach", r= id); rid++; } - return (0); -} -#else -static int -ram_attach(device_t dev) -{ - struct resource *res; - vm_paddr_t *p; - int error, i, rid; + /* If at least one smap attached, return. */ + if (rid !=3D 0) + return (0); + /* * We use the dump_avail[] array rather than phys_avail[] for * the memory map as phys_avail[] contains holes for kernel @@ -724,7 +717,7 @@ */ for (i =3D 0, p =3D dump_avail; p[1] !=3D 0; i++, p +=3D 2) { rid =3D i; -#ifdef PAE +#if !defined(__amd64__) && defined(PAE) /* * Resources use long's to track resources, so we can't * include memory regions above 4GB. @@ -743,7 +736,6 @@ } return (0); } -#endif static device_method_t ram_methods[] =3D { /* Device interface */