Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Oct 2010 16:31:39 +0000 (UTC)
From:      Attilio Rao <attilio@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r214457 - in head/sys: amd64/amd64 conf i386/i386 x86/x86
Message-ID:  <201010281631.o9SGVdtZ014923@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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

Modified: head/sys/conf/files.amd64
==============================================================================
--- head/sys/conf/files.amd64	Thu Oct 28 16:23:25 2010	(r214456)
+++ head/sys/conf/files.amd64	Thu Oct 28 16:31:39 2010	(r214457)
@@ -121,7 +121,6 @@ amd64/amd64/minidump_machdep.c	standard
 amd64/amd64/mp_machdep.c	optional	smp
 amd64/amd64/mp_watchdog.c	optional	mp_watchdog smp
 amd64/amd64/mpboot.S		optional	smp
-amd64/amd64/nexus.c		standard
 amd64/amd64/pmap.c		standard
 amd64/amd64/prof_machdep.c	optional	profiling-routine
 amd64/amd64/sigtramp.S		standard
@@ -325,3 +324,4 @@ x86/x86/mca.c			standard
 x86/x86/mptable.c		optional	mptable
 x86/x86/mptable_pci.c		optional	mptable pci
 x86/x86/msi.c			optional	pci
+x86/x86/nexus.c			standard

Modified: head/sys/conf/files.i386
==============================================================================
--- head/sys/conf/files.i386	Thu Oct 28 16:23:25 2010	(r214456)
+++ head/sys/conf/files.i386	Thu Oct 28 16:31:39 2010	(r214457)
@@ -290,7 +290,6 @@ i386/xen/mp_machdep.c		optional xen smp
 i386/i386/mp_watchdog.c		optional mp_watchdog smp
 i386/i386/mpboot.s		optional smp native
 i386/xen/mptable.c		optional apic xen
-i386/i386/nexus.c		standard
 i386/i386/perfmon.c		optional perfmon
 i386/i386/pmap.c		optional native
 i386/xen/pmap.c			optional xen
@@ -399,3 +398,4 @@ x86/x86/mca.c			standard
 x86/x86/mptable.c		optional apic native
 x86/x86/mptable_pci.c		optional apic pci
 x86/x86/msi.c			optional apic pci
+x86/x86/nexus.c			standard

Modified: 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 <sys/param.h>
 #include <sys/systm.h>
 #include <sys/bus.h>
 #include <sys/kernel.h>
+#ifdef __amd64__
+#include <sys/linker.h>
+#endif
 #include <sys/malloc.h>
 #include <sys/module.h>
 #include <machine/bus.h>
@@ -60,6 +67,10 @@ __FBSDID("$FreeBSD$");
 #include <vm/pmap.h>
 #include <machine/pmap.h>
 
+#ifdef __amd64__
+#include <machine/metadata.h>
+#include <machine/pc/bios.h>
+#endif
 #include <machine/nexusvar.h>
 #include <machine/resource.h>
 
@@ -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
+
 static MALLOC_DEFINE(M_NEXUSDEV, "nexusdev", "Nexus device");
 
 #define DEVTONX(dev)	((struct nexus_device *)device_get_ivars(dev))
@@ -416,7 +435,7 @@ nexus_activate_resource(device_t bus, de
 #else
 		rman_set_bushandle(r, rman_get_start(r));
 #endif
-		rman_set_bustag(r, I386_BUS_SPACE_IO);
+		rman_set_bustag(r, RMAN_BUS_SPACE_IO);
 		break;
 	case SYS_RES_MEMORY:
 #ifdef PC98
@@ -427,7 +446,7 @@ nexus_activate_resource(device_t bus, de
 #endif
 		vaddr = pmap_mapdev(rman_get_start(r), rman_get_size(r));
 		rman_set_virtual(r, vaddr);
-		rman_set_bustag(r, I386_BUS_SPACE_MEM);
+		rman_set_bustag(r, RMAN_BUS_SPACE_MEM);
 #ifdef PC98
 		/* PC-98: the type of bus_space_handle_t is the structure. */
 		bh->bsh_base = (bus_addr_t) vaddr;
@@ -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
 
 static device_method_t ram_methods[] = {
 	/* Device interface */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201010281631.o9SGVdtZ014923>