From owner-svn-src-all@FreeBSD.ORG Thu Oct 28 17:44:26 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 E62C11065781; Thu, 28 Oct 2010 17:44:26 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail09.syd.optusnet.com.au (mail09.syd.optusnet.com.au [211.29.132.190]) by mx1.freebsd.org (Postfix) with ESMTP id 611478FC17; Thu, 28 Oct 2010 17:44:25 +0000 (UTC) Received: from c122-106-146-165.carlnfd1.nsw.optusnet.com.au (c122-106-146-165.carlnfd1.nsw.optusnet.com.au [122.106.146.165]) by mail09.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id o9SHiKYD027722 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 29 Oct 2010 04:44:23 +1100 Date: Fri, 29 Oct 2010 04:44:20 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: John Baldwin In-Reply-To: <201010281257.05481.jhb@freebsd.org> Message-ID: <20101029042046.L899@besplex.bde.org> References: <201010281631.o9SGVdtZ014923@svn.freebsd.org> <201010281257.05481.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: Attilio Rao , 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:44:27 -0000 On Thu, 28 Oct 2010, John Baldwin wrote: > On Thursday, October 28, 2010 12:31:39 pm Attilio Rao wrote: >> Log: >> Merge nexus.c from amd64 and i386 to x86 subtree. >> ... > ============================================================================== >> --- head/sys/i386/i386/nexus.c Thu Oct 28 07:58:06 2010 (r214446, copy > source) >> ... >> @@ -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? Why not just BUS_SPACE_*? The semantics are in the suffix. You would only need the prefix if an arch supported both its own bus spaces and another arch's bus spaces. I use the following horribleness in one tree partly to work around gratuitously different spellings of BUS_SPACE_MEM. The memory bus space is currently used only for ia64, but works for amd64 and ia64 and might work for all arches; there are massive ifdefs to avoid using it, and less-meassive ifdefs would be needed to use different spellings of it. % diff -c2 ./dev/fb/fbreg.h~ ./dev/fb/fbreg.h % *** ./dev/fb/fbreg.h~ Wed Jun 3 09:29:27 2009 % --- ./dev/fb/fbreg.h Wed Jun 17 02:23:39 2009 % *************** % *** 35,75 **** % % /* some macros */ % ! #ifdef __i386__ % ! #define bcopy_io(s, d, c) generic_bcopy((void *)(s), (void *)(d), (c)) % ! #define bcopy_toio(s, d, c) generic_bcopy((void *)(s), (void *)(d), (c)) % ! #define bcopy_fromio(s, d, c) generic_bcopy((void *)(s), (void *)(d), (c)) % ! #define bzero_io(d, c) generic_bzero((void *)(d), (c)) % ! #define fill_io(p, d, c) fill((p), (void *)(d), (c)) % ! #define fillw_io(p, d, c) fillw((p), (void *)(d), (c)) % ! void generic_bcopy(const void *s, void *d, size_t c); % ! void generic_bzero(void *d, size_t c); % ! #elif defined(__amd64__) % ! #define bcopy_io(s, d, c) bcopy((void *)(s), (void *)(d), (c)) % ! #define bcopy_toio(s, d, c) bcopy((void *)(s), (void *)(d), (c)) % ! #define bcopy_fromio(s, d, c) bcopy((void *)(s), (void *)(d), (c)) % ! #define bzero_io(d, c) bzero((void *)(d), (c)) % ! #define fill_io(p, d, c) fill((p), (void *)(d), (c)) % ! #define fillw_io(p, d, c) fillw((p), (void *)(d), (c)) % ! #elif defined(__ia64__) || defined(__sparc64__) % ! #if defined(__ia64__) % #include % #define bcopy_fromio(s, d, c) \ % ! bus_space_read_region_1(IA64_BUS_SPACE_MEM, s, 0, (void*)(d), c) % #define bcopy_io(s, d, c) \ % ! bus_space_copy_region_1(IA64_BUS_SPACE_MEM, s, 0, d, 0, c) % #define bcopy_toio(s, d, c) \ % ! bus_space_write_region_1(IA64_BUS_SPACE_MEM, d, 0, (void*)(s), c) % #define bzero_io(d, c) \ % ! bus_space_set_region_1(IA64_BUS_SPACE_MEM, (intptr_t)(d), 0, 0, c) % #define fill_io(p, d, c) \ % ! bus_space_set_region_1(IA64_BUS_SPACE_MEM, (intptr_t)(d), 0, p, c) % #define fillw_io(p, d, c) \ % ! bus_space_set_region_2(IA64_BUS_SPACE_MEM, (intptr_t)(d), 0, p, c) % ! #define readb(a) bus_space_read_1(IA64_BUS_SPACE_MEM, a, 0) % ! #define readw(a) bus_space_read_2(IA64_BUS_SPACE_MEM, a, 0) % ! #define writeb(a, v) bus_space_write_1(IA64_BUS_SPACE_MEM, a, 0, v) % ! #define writew(a, v) bus_space_write_2(IA64_BUS_SPACE_MEM, a, 0, v) % ! #define writel(a, v) bus_space_write_4(IA64_BUS_SPACE_MEM, a, 0, v) % ! #endif /* __ia64__ */ % static __inline void % fillw(int val, uint16_t *buf, size_t size) % --- 35,74 ---- % % /* some macros */ % ! #if defined(__amd64__) || defined(__i386__) || defined(__ia64__) || \ % ! defined(__sparc64__) % ! /* XXX __sparc64__ doesn't seem to belong here. */ % ! #if defined(__amd64__) || defined(__i386__) || defined(__ia64__) % #include % + #endif % + /* XXX fix gratuitous MD spelling: */ % + #ifdef __amd64__ % + #define BUS_SPACE_MEM AMD64_BUS_SPACE_MEM % + #endif % + #ifdef __i386__ % + #define BUS_SPACE_MEM I386_BUS_SPACE_MEM % + #endif % + #ifdef __ia64__ % + #define BUS_SPACE_MEM IA64_BUS_SPACE_MEM % + #endif % + #if defined(__amd64__) || defined(__i386__) || defined(__ia64__) % #define bcopy_fromio(s, d, c) \ % ! bus_space_read_region_1(BUS_SPACE_MEM, s, 0, (void*)(d), c) % #define bcopy_io(s, d, c) \ % ! bus_space_copy_region_1(BUS_SPACE_MEM, s, 0, d, 0, c) % #define bcopy_toio(s, d, c) \ % ! bus_space_write_region_1(BUS_SPACE_MEM, d, 0, (void*)(s), c) % #define bzero_io(d, c) \ % ! bus_space_set_region_1(BUS_SPACE_MEM, (intptr_t)(d), 0, 0, c) % #define fill_io(p, d, c) \ % ! bus_space_set_region_1(BUS_SPACE_MEM, (intptr_t)(d), 0, p, c) % #define fillw_io(p, d, c) \ % ! bus_space_set_region_2(BUS_SPACE_MEM, (intptr_t)(d), 0, p, c) % ! #define readb(a) bus_space_read_1(BUS_SPACE_MEM, a, 0) % ! #define readw(a) bus_space_read_2(BUS_SPACE_MEM, a, 0) % ! #define writeb(a, v) bus_space_write_1(BUS_SPACE_MEM, a, 0, v) % ! #define writew(a, v) bus_space_write_2(BUS_SPACE_MEM, a, 0, v) % ! #define writel(a, v) bus_space_write_4(BUS_SPACE_MEM, a, 0, v) % ! #endif /* __amd64__ || __i386__ || __ia64__ */ % ! /* fillw for __amd64__ || __i386__ || __ia64__ and || __sparc64__ too, ugh. */ % static __inline void % fillw(int val, uint16_t *buf, size_t size) % *************** % *** 102,106 **** % #define fillw(p, d, c) memsetw((d), (p), (c)) % #define fillw_io(p, d, c) memsetw_io((d), (p), (c)) % ! #endif /* !__i386__ */ % % /* video function table */ % --- 101,105 ---- % #define fillw(p, d, c) memsetw((d), (p), (c)) % #define fillw_io(p, d, c) memsetw_io((d), (p), (c)) % ! #endif % % /* video function table */ >> @@ -649,6 +668,42 @@ ram_probe(device_t dev) >> return (0); >> } >> >> +#ifdef __amd64__ >> +static int >> +ram_attach(device_t dev) >> ... >> +#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. Or if it is MD, it doesn't belong under x86. Bruce