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 <sys/rtprio.h>
+#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 <machine/bus.h>
% #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 <machine/bus.h>
% + #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
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"