Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 13 Aug 2006 13:34:16 GMT
From:      Roman Divacky <rdivacky@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 103762 for review
Message-ID:  <200608131334.k7DDYGuY022173@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=103762

Change 103762 by rdivacky@rdivacky_witten on 2006/08/13 13:34:05

	IFC

Affected files ...

.. //depot/projects/soc2006/rdivacky_linuxolator/amd64/acpica/madt.c#2 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/amd64/amd64/pmap.c#7 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/amd64/include/pmap.h#3 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/conf/files#8 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/contrib/dev/acpica/acfreebsd.h#2 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/dev/acpica/Osd/OsdMemory.c#2 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/dev/acpica/acpi_hpet.c#3 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/dev/ata/ata-chipset.c#6 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/dev/ata/ata-pci.h#5 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/dev/exca/excareg.h#2 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/dev/hme/if_hme.c#2 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/dev/mii/rgephy.c#4 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/dev/pccbb/pccbb.c#3 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/dev/pccbb/pccbb_pci.c#3 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/dev/pccbb/pccbbreg.h#2 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/dev/sk/if_sk.c#7 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/dev/stge/if_stge.c#2 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/dev/ti/if_ti.c#2 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/geom/eli/g_eli.c#5 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/geom/eli/g_eli.h#4 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/geom/label/g_label.c#2 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/geom/label/g_label_msdosfs.c#2 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/geom/label/g_label_msdosfs.h#1 branch
.. //depot/projects/soc2006/rdivacky_linuxolator/i386/acpica/acpi_machdep.c#3 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/i386/acpica/madt.c#2 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/i386/i386/pmap.c#7 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/i386/include/pmap.h#2 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/ia64/include/pmap.h#2 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/kern/kern_subr.c#2 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/kern/uipc_socket.c#6 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/libkern/strstr.c#1 branch
.. //depot/projects/soc2006/rdivacky_linuxolator/net/bridgestp.c#4 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/net/if_vlan.c#6 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/netinet/tcp_input.c#5 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/netinet/tcp_subr.c#4 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/netinet/tcp_timer.c#3 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/netinet/tcp_timer.h#2 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/pci/agp.c#2 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/pci/if_xl.c#2 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/sys/libkern.h#3 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/sys/sysctl.h#4 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/vm/device_pager.c#2 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/vm/vm_fault.c#5 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/vm/vm_object.c#6 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/vm/vm_page.c#7 integrate
.. //depot/projects/soc2006/rdivacky_linuxolator/vm/vm_page.h#3 integrate

Differences ...

==== //depot/projects/soc2006/rdivacky_linuxolator/amd64/acpica/madt.c#2 (text+ko) ====

@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/acpica/madt.c,v 1.20 2006/03/27 15:59:48 jhb Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/acpica/madt.c,v 1.21 2006/08/11 19:22:55 jhb Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -203,15 +203,15 @@
 
 	/*
 	 * Map in the RSDP.  Since ACPI uses AcpiOsMapMemory() which in turn
-	 * calls pmap_mapdev() to find the RSDP, we assume that we can use
-	 * pmap_mapdev() to map the RSDP.
+	 * calls pmap_mapbios() to find the RSDP, we assume that we can use
+	 * pmap_mapbios() to map the RSDP.
 	 */
 	if (AcpiOsGetRootPointer(ACPI_LOGICAL_ADDRESSING, &rsdp_ptr) != AE_OK)
 		return (ENXIO);
 #ifdef __i386__
 	KASSERT(rsdp_ptr.Pointer.Physical < KERNLOAD, ("RSDP too high"));
 #endif
-	rsdp = pmap_mapdev(rsdp_ptr.Pointer.Physical, sizeof(RSDP_DESCRIPTOR));
+	rsdp = pmap_mapbios(rsdp_ptr.Pointer.Physical, sizeof(RSDP_DESCRIPTOR));
 	if (rsdp == NULL) {
 		if (bootverbose)
 			printf("MADT: Failed to map RSDP\n");
@@ -261,7 +261,7 @@
 				break;
 		madt_unmap_table(rsdt);
 	}
-	pmap_unmapdev((vm_offset_t)rsdp, sizeof(RSDP_DESCRIPTOR));
+	pmap_unmapbios((vm_offset_t)rsdp, sizeof(RSDP_DESCRIPTOR));
 	if (madt_physaddr == 0) {
 		if (bootverbose)
 			printf("MADT: No MADT table found\n");
@@ -335,7 +335,7 @@
 madt_setup_local(void)
 {
 
-	madt = pmap_mapdev(madt_physaddr, madt_length);
+	madt = pmap_mapbios(madt_physaddr, madt_length);
 	lapic_init((uintptr_t)madt->LocalApicAddress);
 	printf("ACPI APIC Table: <%.*s %.*s>\n",
 	    (int)sizeof(madt->OemId), madt->OemId,

==== //depot/projects/soc2006/rdivacky_linuxolator/amd64/amd64/pmap.c#7 (text+ko) ====

@@ -77,7 +77,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/amd64/pmap.c,v 1.569 2006/08/06 06:29:16 alc Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/amd64/pmap.c,v 1.570 2006/08/11 19:22:55 jhb Exp $");
 
 /*
  *	Manages physical address maps.
@@ -665,6 +665,84 @@
  * Low level helper routines.....
  ***************************************************/
 
+/*
+ * Determine the appropriate bits to set in a PTE or PDE for a specified
+ * caching mode.
+ */
+static int
+pmap_cache_bits(int mode, boolean_t is_pde)
+{
+	int pat_flag, pat_index, cache_bits;
+
+	/* The PAT bit is different for PTE's and PDE's. */
+	pat_flag = is_pde ? PG_PDE_PAT : PG_PTE_PAT;
+
+	/* If we don't support PAT, map extended modes to older ones. */
+	if (!(cpu_feature & CPUID_PAT)) {
+		switch (mode) {
+		case PAT_UNCACHEABLE:
+		case PAT_WRITE_THROUGH:
+		case PAT_WRITE_BACK:
+			break;
+		case PAT_UNCACHED:
+		case PAT_WRITE_COMBINING:
+		case PAT_WRITE_PROTECTED:
+			mode = PAT_UNCACHEABLE;
+			break;
+		}
+	}
+	
+	/* Map the caching mode to a PAT index. */
+	switch (mode) {
+#ifdef PAT_WORKS
+	case PAT_UNCACHEABLE:
+		pat_index = 3;
+		break;
+	case PAT_WRITE_THROUGH:
+		pat_index = 1;
+		break;
+	case PAT_WRITE_BACK:
+		pat_index = 0;
+		break;
+	case PAT_UNCACHED:
+		pat_index = 2;
+		break;
+	case PAT_WRITE_COMBINING:
+		pat_index = 5;
+		break;
+	case PAT_WRITE_PROTECTED:
+		pat_index = 4;
+		break;
+#else
+	case PAT_UNCACHED:
+	case PAT_UNCACHEABLE:
+	case PAT_WRITE_PROTECTED:
+		pat_index = 3;
+		break;
+	case PAT_WRITE_THROUGH:
+		pat_index = 1;
+		break;
+	case PAT_WRITE_BACK:
+		pat_index = 0;
+		break;
+	case PAT_WRITE_COMBINING:
+		pat_index = 2;
+		break;
+#endif
+	default:
+		panic("Unknown caching mode %d\n", mode);
+	}	
+
+	/* Map the 3-bit index value into the PAT, PCD, and PWT bits. */
+	cache_bits = 0;
+	if (pat_index & 0x4)
+		cache_bits |= pat_flag;
+	if (pat_index & 0x2)
+		cache_bits |= PG_NC_PCD;
+	if (pat_index & 0x1)
+		cache_bits |= PG_NC_PWT;
+	return (cache_bits);
+}
 #ifdef SMP
 /*
  * For SMP, these functions have to use the IPI mechanism for coherence.
@@ -962,6 +1040,15 @@
 	pte_store(pte, pa | PG_RW | PG_V | PG_G);
 }
 
+PMAP_INLINE void 
+pmap_kenter_attr(vm_offset_t va, vm_paddr_t pa, int mode)
+{
+	pt_entry_t *pte;
+
+	pte = vtopte(va);
+	pte_store(pte, pa | PG_RW | PG_V | PG_G | pmap_cache_bits(mode, 0));
+}
+
 /*
  * Remove a page from the kernel pagetables.
  * Note: not SMP coherent.
@@ -2281,6 +2368,10 @@
 	if (pmap == kernel_pmap)
 		newpte |= PG_G;
 
+	/* Preserve any caching attributes. */
+	/* XXX: Should this be conditional on something? */
+	newpte |= (origpte & (PG_PTE_PAT | PG_NC_PCD | PG_NC_PWT));
+	
 	/*
 	 * if the mapping or permission bits are different, we need
 	 * to update the pte.
@@ -3101,6 +3192,46 @@
  * Miscellaneous support routines follow
  */
 
+/* Adjust the cache mode for a 4KB page mapped via a PTE. */
+static __inline void
+pmap_pte_attr(vm_offset_t va, int mode)
+{
+	pt_entry_t *pte;
+	u_int opte, npte;
+
+	pte = vtopte(va);
+
+	/*
+	 * The cache mode bits are all in the low 32-bits of the
+	 * PTE, so we can just spin on updating the low 32-bits.
+	 */
+	do {
+		opte = *(u_int *)pte;
+		npte = opte & ~(PG_PTE_PAT | PG_NC_PCD | PG_NC_PWT);
+		npte |= pmap_cache_bits(mode, 0);
+	} while (npte != opte && !atomic_cmpset_int((u_int *)pte, opte, npte));
+}
+
+/* Adjust the cache mode for a 2MB page mapped via a PDE. */
+static __inline void
+pmap_pde_attr(vm_offset_t va, int mode)
+{
+	pd_entry_t *pde;
+	u_int opde, npde;
+
+	pde = pmap_pde(kernel_pmap, va);
+
+	/*
+	 * The cache mode bits are all in the low 32-bits of the
+	 * PDE, so we can just spin on updating the low 32-bits.
+	 */
+	do {
+		opde = *(u_int *)pde;
+		npde = opde & ~(PG_PDE_PAT | PG_NC_PCD | PG_NC_PWT);
+		npde |= pmap_cache_bits(mode, 1);
+	} while (npde != opde && !atomic_cmpset_int((u_int *)pde, opde, npde));
+}
+
 /*
  * Map a set of physical memory pages into the kernel virtual
  * address space. Return a pointer to where it is mapped. This
@@ -3108,12 +3239,15 @@
  * NOT real memory.
  */
 void *
-pmap_mapdev(vm_paddr_t pa, vm_size_t size)
+pmap_mapdev_attr(vm_paddr_t pa, vm_size_t size, int mode)
 {
 	vm_offset_t va, tmpva, offset;
 
-	/* If this fits within the direct map window, use it */
-	if (pa < dmaplimit && (pa + size) < dmaplimit)
+	/*
+	 * If this fits within the direct map window and use WB caching
+	 * mode, use the direct map.
+	 */
+	if (pa < dmaplimit && (pa + size) < dmaplimit && mode == PAT_WRITE_BACK)
 		return ((void *)PHYS_TO_DMAP(pa));
 	offset = pa & PAGE_MASK;
 	size = roundup(offset + size, PAGE_SIZE);
@@ -3122,15 +3256,30 @@
 		panic("pmap_mapdev: Couldn't alloc kernel virtual memory");
 	pa = trunc_page(pa);
 	for (tmpva = va; size > 0; ) {
-		pmap_kenter(tmpva, pa);
+		pmap_kenter_attr(tmpva, pa, mode);
 		size -= PAGE_SIZE;
 		tmpva += PAGE_SIZE;
 		pa += PAGE_SIZE;
 	}
 	pmap_invalidate_range(kernel_pmap, va, tmpva);
+	pmap_invalidate_cache();
 	return ((void *)(va + offset));
 }
 
+void *
+pmap_mapdev(vm_paddr_t pa, vm_size_t size)
+{
+
+	return (pmap_mapdev_attr(pa, size, PAT_UNCACHEABLE));
+}
+
+void *
+pmap_mapbios(vm_paddr_t pa, vm_size_t size)
+{
+
+	return (pmap_mapdev_attr(pa, size, PAT_WRITE_BACK));
+}
+
 void
 pmap_unmapdev(vm_offset_t va, vm_size_t size)
 {
@@ -3148,6 +3297,73 @@
 	kmem_free(kernel_map, base, size);
 }
 
+int
+pmap_change_attr(va, size, mode)
+	vm_offset_t va;
+	vm_size_t size;
+	int mode;
+{
+	vm_offset_t base, offset, tmpva;
+	pd_entry_t *pde;
+	pt_entry_t *pte;
+
+	base = va & PG_FRAME;
+	offset = va & PAGE_MASK;
+	size = roundup(offset + size, PAGE_SIZE);
+
+	/* Only supported on kernel virtual addresses. */
+	if (base <= VM_MAXUSER_ADDRESS)
+		return (EINVAL);
+
+	/*
+	 * XXX: We have to support tearing 2MB pages down into 4k pages if
+	 * needed here.
+	 */
+	/* Pages that aren't mapped aren't supported. */
+	for (tmpva = base; tmpva < (base + size); ) {
+		pde = pmap_pde(kernel_pmap, tmpva);
+		if (*pde == 0)
+			return (EINVAL);
+		if (*pde & PG_PS) {
+			/* Handle 2MB pages that are completely contained. */
+			if (size >= NBPDR) {
+				tmpva += NBPDR;
+				continue;
+			}
+			return (EINVAL);
+		}
+		pte = vtopte(va);
+		if (*pte == 0)
+			return (EINVAL);
+		tmpva += PAGE_SIZE;
+	}
+
+	/*
+	 * Ok, all the pages exist, so run through them updating their
+	 * cache mode.
+	 */
+	for (tmpva = base; size > 0; ) {
+		pde = pmap_pde(kernel_pmap, tmpva);
+		if (*pde & PG_PS) {
+			pmap_pde_attr(tmpva, mode);
+			tmpva += NBPDR;
+			size -= NBPDR;
+		} else {
+			pmap_pte_attr(tmpva, mode);
+			tmpva += PAGE_SIZE;
+			size -= PAGE_SIZE;
+		}
+	}
+
+	/*
+	 * Flush CPU caches to make sure any data isn't cached that shouldn't
+	 * be, etc.
+	 */    
+	pmap_invalidate_range(kernel_pmap, base, tmpva);
+	pmap_invalidate_cache();
+	return (0);
+}
+
 /*
  * perform the pmap work for mincore
  */

==== //depot/projects/soc2006/rdivacky_linuxolator/amd64/include/pmap.h#3 (text+ko) ====

@@ -39,7 +39,7 @@
  *
  *	from: hp300: @(#)pmap.h	7.2 (Berkeley) 12/16/90
  *	from: @(#)pmap.h	7.4 (Berkeley) 5/12/91
- * $FreeBSD: src/sys/amd64/include/pmap.h,v 1.133 2006/08/02 16:24:23 alc Exp $
+ * $FreeBSD: src/sys/amd64/include/pmap.h,v 1.134 2006/08/11 19:22:56 jhb Exp $
  */
 
 #ifndef _MACHINE_PMAP_H_
@@ -302,14 +302,19 @@
 extern vm_offset_t virtual_end;
 
 #define	pmap_page_is_mapped(m)	(!TAILQ_EMPTY(&(m)->md.pv_list))
+#define	pmap_unmapbios(va, sz)	pmap_unmapdev((va), (sz))
 
 void	pmap_bootstrap(vm_paddr_t *);
+int	pmap_change_attr(vm_offset_t, vm_size_t, int);
 void	pmap_init_pat(void);
 void	pmap_kenter(vm_offset_t va, vm_paddr_t pa);
+void	pmap_kenter_attr(vm_offset_t va, vm_paddr_t pa, int mode);
 void	*pmap_kenter_temporary(vm_paddr_t pa, int i);
 vm_paddr_t pmap_kextract(vm_offset_t);
 void	pmap_kremove(vm_offset_t);
+void	*pmap_mapbios(vm_paddr_t, vm_size_t);
 void	*pmap_mapdev(vm_paddr_t, vm_size_t);
+void	*pmap_mapdev_attr(vm_paddr_t, vm_size_t, int);
 void	pmap_unmapdev(vm_offset_t, vm_size_t);
 void	pmap_invalidate_page(pmap_t, vm_offset_t);
 void	pmap_invalidate_range(pmap_t, vm_offset_t, vm_offset_t);

==== //depot/projects/soc2006/rdivacky_linuxolator/conf/files#8 (text+ko) ====

@@ -1,4 +1,4 @@
-# $FreeBSD: src/sys/conf/files,v 1.1137 2006/08/07 12:02:42 rwatson Exp $
+# $FreeBSD: src/sys/conf/files,v 1.1139 2006/08/12 18:29:49 pjd Exp $
 #
 # The long compile-with and dependency lines are required because of
 # limitations in config: backslash-newline doesn't work in strings, and
@@ -1477,6 +1477,7 @@
 libkern/strncpy.c		standard
 libkern/strsep.c		standard
 libkern/strspn.c		standard
+libkern/strstr.c		standard
 libkern/strtol.c		standard
 libkern/strtoq.c		standard
 libkern/strtoul.c		standard

==== //depot/projects/soc2006/rdivacky_linuxolator/contrib/dev/acpica/acfreebsd.h#2 (text+ko) ====

@@ -169,26 +169,4 @@
 /* Always use FreeBSD code over our local versions */
 #define ACPI_USE_SYSTEM_CLIBRARY
 
-#ifdef _KERNEL
-/* Or strstr (used in debugging mode, also move to libkern) */
-static __inline char *
-strstr(char *s, char *find)
-{
-    char c, sc;
-    size_t len;
-
-    if ((c = *find++) != 0) {
-    len = strlen(find);
-    do {
-        do {
-        if ((sc = *s++) == 0)
-            return (NULL);
-        } while (sc != c);
-    } while (strncmp(s, find, len) != 0);
-    s--;
-    }
-    return ((char *)s);
-}
-#endif /* _KERNEL */
-
 #endif /* __ACFREEBSD_H__ */

==== //depot/projects/soc2006/rdivacky_linuxolator/dev/acpica/Osd/OsdMemory.c#2 (text+ko) ====

@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/acpica/Osd/OsdMemory.c,v 1.13 2005/09/11 18:39:02 obrien Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/acpica/Osd/OsdMemory.c,v 1.14 2006/08/11 19:22:56 jhb Exp $");
 
 #include <contrib/dev/acpica/acpi.h>
 
@@ -58,7 +58,7 @@
 AcpiOsMapMemory(ACPI_PHYSICAL_ADDRESS PhysicalAddress, ACPI_SIZE Length,
     void **LogicalAddress)
 {
-    *LogicalAddress = pmap_mapdev((vm_offset_t)PhysicalAddress, Length);
+    *LogicalAddress = pmap_mapbios((vm_offset_t)PhysicalAddress, Length);
     if (*LogicalAddress == NULL)
 	return (AE_BAD_ADDRESS);
     return (AE_OK);
@@ -67,7 +67,7 @@
 void
 AcpiOsUnmapMemory(void *LogicalAddress, ACPI_SIZE Length)
 {
-    pmap_unmapdev((vm_offset_t)LogicalAddress, Length);
+    pmap_unmapbios((vm_offset_t)LogicalAddress, Length);
 }
 
 ACPI_STATUS

==== //depot/projects/soc2006/rdivacky_linuxolator/dev/acpica/acpi_hpet.c#3 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_hpet.c,v 1.4 2006/06/04 08:04:19 njl Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_hpet.c,v 1.5 2006/08/11 17:12:16 des Exp $");
 
 #include "opt_acpi.h"
 #include <sys/param.h>
@@ -66,7 +66,7 @@
 	.tc_get_timecount =	hpet_get_timecount,
 	.tc_counter_mask =	~0u,
 	.tc_name =		"HPET",
-	.tc_quality =		-200,
+	.tc_quality =		2000,
 };
 
 static u_int

==== //depot/projects/soc2006/rdivacky_linuxolator/dev/ata/ata-chipset.c#6 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/ata/ata-chipset.c,v 1.167 2006/08/05 11:41:46 sos Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/ata/ata-chipset.c,v 1.168 2006/08/11 21:19:29 sos Exp $");
 
 #include "opt_ata.h"
 #include <sys/param.h>
@@ -2778,11 +2778,11 @@
      { ATA_NFORCE_CK804_S1, 0, 0,         NV4,     ATA_SA300, "nForce CK804" },
      { ATA_NFORCE_CK804_S2, 0, 0,         NV4,     ATA_SA300, "nForce CK804" },
      { ATA_NFORCE_MCP51,    0, AMDNVIDIA, NVIDIA,  ATA_UDMA6, "nForce MCP51" },
-     { ATA_NFORCE_MCP51_S1, 0, 0,         NV4LONG, ATA_SA300, "nForce MCP51" },
-     { ATA_NFORCE_MCP51_S2, 0, 0,         NV4LONG, ATA_SA300, "nForce MCP51" },
+     { ATA_NFORCE_MCP51_S1, 0, 0,         NV4|NVQ, ATA_SA300, "nForce MCP51" },
+     { ATA_NFORCE_MCP51_S2, 0, 0,         NV4|NVQ, ATA_SA300, "nForce MCP51" },
      { ATA_NFORCE_MCP55,    0, AMDNVIDIA, NVIDIA,  ATA_UDMA6, "nForce MCP55" },
-     { ATA_NFORCE_MCP55_S1, 0, 0,         NV4LONG, ATA_SA300, "nForce MCP55" },
-     { ATA_NFORCE_MCP55_S2, 0, 0,         NV4LONG, ATA_SA300, "nForce MCP55" },
+     { ATA_NFORCE_MCP55_S1, 0, 0,         NV4|NVQ, ATA_SA300, "nForce MCP55" },
+     { ATA_NFORCE_MCP55_S2, 0, 0,         NV4|NVQ, ATA_SA300, "nForce MCP55" },
      { 0, 0, 0, 0, 0, 0}} ;
     char buffer[64] ;
 
@@ -2821,7 +2821,7 @@
 	    /* enable control access */
 	    pci_write_config(dev, 0x50, pci_read_config(dev, 0x50, 1) | 0x04,1);
 
-	    if (ctlr->chip->cfg2 & NV4LONG) {
+	    if (ctlr->chip->cfg2 & NVQ) {
 		/* clear interrupt status */
 		ATA_OUTL(ctlr->r_res2, offset, 0x00ff00ff);
 
@@ -2881,11 +2881,11 @@
     struct ata_channel *ch = device_get_softc(dev);
     int offset = ctlr->chip->cfg2 & NV4 ? 0x0440 : 0x0010;
     struct ata_connect_task *tp;
-    int shift = ch->unit << (ctlr->chip->cfg2 & NV4LONG ? 4 : 2);
+    int shift = ch->unit << (ctlr->chip->cfg2 & NVQ ? 4 : 2);
     u_int32_t status;
 
     /* get and clear interrupt status */
-    if (ctlr->chip->cfg2 & NV4LONG) {
+    if (ctlr->chip->cfg2 & NVQ) {
 	status = ATA_INL(ctlr->r_res2, offset);
 	ATA_OUTL(ctlr->r_res2, offset, (0x0f << shift));
     }

==== //depot/projects/soc2006/rdivacky_linuxolator/dev/ata/ata-pci.h#5 (text+ko) ====

@@ -23,7 +23,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/dev/ata/ata-pci.h,v 1.67 2006/08/05 11:41:46 sos Exp $
+ * $FreeBSD: src/sys/dev/ata/ata-pci.h,v 1.68 2006/08/11 21:19:29 sos Exp $
  */
 
 /* structure holding chipset config info */
@@ -392,7 +392,7 @@
 #define AMDBUG          0x0002
 #define NVIDIA          0x0004
 #define NV4             0x0010
-#define NV4LONG         0x0030
+#define NVQ             0x0020
 #define VIACLK          0x0100
 #define VIABUG          0x0200
 #define VIABAR          0x0400

==== //depot/projects/soc2006/rdivacky_linuxolator/dev/exca/excareg.h#2 (text+ko) ====

@@ -1,5 +1,5 @@
 /*	$NetBSD: i82365reg.h,v 1.3 1998/12/20 17:53:28 nathanw Exp $	*/
-/* $FreeBSD: src/sys/dev/exca/excareg.h,v 1.5 2005/01/06 01:42:40 imp Exp $ */
+/* $FreeBSD: src/sys/dev/exca/excareg.h,v 1.6 2006/08/12 08:53:54 imp Exp $ */
 
 /*-
  * Copyright (c) 2002 M Warner Losh.  All rights reserved.
@@ -402,6 +402,12 @@
 #define EXCA_O2CC_IREQ_INTC			0x80
 #define EXCA_O2CC_STSCHG_INTC			0x20
 
+/*
+ * TOPIC specific registers
+ */
+#define EXCA_TOPIC97_CTRL			0x3e
+#define EXCA_TOPIC97_CTRL_LV_MASK		0x03
+
 /* Plug and play */
 #define EXCA_PNP_ACTIONTEC	0x1802A904	/* AEI0218 */
 #define EXCA_PNP_IBM3765	0x65374d24	/* IBM3765 */

==== //depot/projects/soc2006/rdivacky_linuxolator/dev/hme/if_hme.c#2 (text+ko) ====

@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/hme/if_hme.c,v 1.48 2006/05/27 09:28:59 simon Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/hme/if_hme.c,v 1.49 2006/08/12 01:19:37 yongari Exp $");
 
 /*
  * HME Ethernet module driver.
@@ -936,7 +936,6 @@
 hme_load_txmbuf(struct hme_softc *sc, struct mbuf **m0)
 {
 	struct hme_txdesc *htx;
-	struct mbuf *m, *n;
 	caddr_t txd;
 	int i, pci, si, ri, nseg;
 	u_int32_t flags, cflags = 0;
@@ -944,31 +943,30 @@
 
 	if ((htx = STAILQ_FIRST(&sc->sc_rb.rb_txfreeq)) == NULL)
 		return (-1);
-	m = *m0;
-	if ((m->m_pkthdr.csum_flags & sc->sc_csum_features) != 0)
-		hme_txcksum(m, &cflags);
 	error = bus_dmamap_load_mbuf_sg(sc->sc_tdmatag, htx->htx_dmamap,
-	    m, sc->sc_rb.rb_txsegs, &nseg, 0);
+	    *m0, sc->sc_rb.rb_txsegs, &nseg, 0);
 	if (error == EFBIG) {
-		n = m_defrag(m, M_DONTWAIT);
-		if (n == NULL) {
-			m_freem(m);
-			m = NULL;
+		struct mbuf *m;
+
+		m = m_defrag(*m0, M_DONTWAIT);
+		if (m == NULL) {
+			m_freem(*m0);
+			*m0 = NULL;
 			return (ENOMEM);
 		}
-		m = n;
+		*m0 = m;
 		error = bus_dmamap_load_mbuf_sg(sc->sc_tdmatag, htx->htx_dmamap,
-		    m, sc->sc_rb.rb_txsegs, &nseg, 0);
+		    *m0, sc->sc_rb.rb_txsegs, &nseg, 0);
 		if (error != 0) {
-			m_freem(m);
-			m = NULL;
+			m_freem(*m0);
+			*m0 = NULL;
 			return (error);
 		}
 	} else if (error != 0)
 		return (error);
 	if (nseg == 0) {
-		m_freem(m);
-		m = NULL;
+		m_freem(*m0);
+		*m0 = NULL;
 		return (EIO);
 	}
 	if (sc->sc_rb.rb_td_nbusy + nseg >= HME_NTXDESC) {
@@ -976,6 +974,8 @@
 		/* retry with m_defrag(9)? */
 		return (-2);
 	}
+	if (((*m0)->m_pkthdr.csum_flags & sc->sc_csum_features) != 0)
+		hme_txcksum(*m0, &cflags);
 	bus_dmamap_sync(sc->sc_tdmatag, htx->htx_dmamap, BUS_DMASYNC_PREWRITE);
 
 	si = ri = sc->sc_rb.rb_tdhead;
@@ -1017,7 +1017,7 @@
 
 	STAILQ_REMOVE_HEAD(&sc->sc_rb.rb_txfreeq, htx_q);
 	STAILQ_INSERT_TAIL(&sc->sc_rb.rb_txbusyq, htx, htx_q);
-	htx->htx_m = m;
+	htx->htx_m = *m0;
 
 	/* start the transmission. */
 	HME_ETX_WRITE_4(sc, HME_ETXI_PENDING, HME_ETX_TP_DMAWAKEUP);

==== //depot/projects/soc2006/rdivacky_linuxolator/dev/mii/rgephy.c#4 (text+ko) ====

@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/mii/rgephy.c,v 1.10 2006/07/03 02:53:39 yongari Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/mii/rgephy.c,v 1.11 2006/08/12 01:38:49 yongari Exp $");
 
 /*
  * Driver for the RealTek 8169S/8110S internal 10/100/1000 PHY.
@@ -166,7 +166,7 @@
 rgephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
 {
 	struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
-	int reg, speed, gig;
+	int reg, speed, gig, anar;
 
 	switch (cmd) {
 	case MII_POLLSTAT:
@@ -196,6 +196,10 @@
 
 		rgephy_reset(sc);	/* XXX hardware bug work-around */
 
+		anar = PHY_READ(sc, RGEPHY_MII_ANAR);
+		anar &= ~(RGEPHY_ANAR_TX_FD | RGEPHY_ANAR_TX |
+		    RGEPHY_ANAR_10_FD | RGEPHY_ANAR_10);
+
 		switch (IFM_SUBTYPE(ife->ifm_media)) {
 		case IFM_AUTO:
 #ifdef foo
@@ -212,29 +216,31 @@
 			goto setit;
 		case IFM_100_TX:
 			speed = RGEPHY_S100;
+			anar |= RGEPHY_ANAR_TX_FD | RGEPHY_ANAR_TX;
 			goto setit;
 		case IFM_10_T:
 			speed = RGEPHY_S10;
+			anar |= RGEPHY_ANAR_10_FD | RGEPHY_ANAR_10;
 setit:
 			rgephy_loop(sc);
 			if ((ife->ifm_media & IFM_GMASK) == IFM_FDX) {
 				speed |= RGEPHY_BMCR_FDX;
 				gig = RGEPHY_1000CTL_AFD;
+				anar &= ~(RGEPHY_ANAR_TX | RGEPHY_ANAR_10);
 			} else {
 				gig = RGEPHY_1000CTL_AHD;
+				anar &=
+				    ~(RGEPHY_ANAR_TX_FD | RGEPHY_ANAR_10_FD);
 			}
 
-			PHY_WRITE(sc, RGEPHY_MII_1000CTL, 0);
-			PHY_WRITE(sc, RGEPHY_MII_BMCR, speed);
-			PHY_WRITE(sc, RGEPHY_MII_ANAR, RGEPHY_SEL_TYPE);
-
-			if (IFM_SUBTYPE(ife->ifm_media) != IFM_1000_T) 
+			if (IFM_SUBTYPE(ife->ifm_media) != IFM_1000_T) {
+				PHY_WRITE(sc, RGEPHY_MII_1000CTL, 0);
+				PHY_WRITE(sc, RGEPHY_MII_ANAR, anar);
+				PHY_WRITE(sc, RGEPHY_MII_BMCR, speed |
+				    RGEPHY_BMCR_AUTOEN | RGEPHY_BMCR_STARTNEG);
 				break;
+			}
 
-			PHY_WRITE(sc, RGEPHY_MII_1000CTL, gig);
-			PHY_WRITE(sc, RGEPHY_MII_BMCR,
-			    speed|RGEPHY_BMCR_AUTOEN|RGEPHY_BMCR_STARTNEG);
-
 			/*
 			 * When settning the link manually, one side must
 			 * be the master and the other the slave. However
@@ -250,6 +256,8 @@
 				PHY_WRITE(sc, RGEPHY_MII_1000CTL,
 				    gig|RGEPHY_1000CTL_MSE);
 			}
+			PHY_WRITE(sc, RGEPHY_MII_BMCR, speed |
+			    RGEPHY_BMCR_AUTOEN | RGEPHY_BMCR_STARTNEG);
 			break;
 #ifdef foo
 		case IFM_NONE:

==== //depot/projects/soc2006/rdivacky_linuxolator/dev/pccbb/pccbb.c#3 (text+ko) ====

@@ -75,7 +75,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/pccbb/pccbb.c,v 1.150 2006/06/03 21:05:36 imp Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/pccbb/pccbb.c,v 1.151 2006/08/12 09:06:55 imp Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -700,7 +700,7 @@
 int
 cbb_power(device_t brdev, int volts)
 {
-	uint32_t status, sock_ctrl, mask;
+	uint32_t status, sock_ctrl, reg_ctrl, mask;
 	struct cbb_softc *sc = device_get_softc(brdev);
 	int cnt, sane;
 	int retval = 0;
@@ -744,14 +744,15 @@
 		reg = cbb_o2micro_power_hack(sc);
 
 	/*
-	 * We have to mask the card change detect interrupt while we're
-	 * messing with the power.  It is allowed to bounce while we're
-	 * messing with power as things settle down.  In addition, we mask off
-	 * the card's function interrupt by routing it via the ISA bus.  This
-	 * bit generally only affects 16bit cards.  Some bridges allow one to
-	 * set another bit to have it also affect 32bit cards.  Since 32bit
-	 * cards are required to be better behaved, we don't bother to get
-	 * into those bridge specific features.
+	 * We have to mask the card change detect interrupt while
+	 * we're messing with the power.  It is allowed to bounce
+	 * while we're messing with power as things settle down.  In
+	 * addition, we mask off the card's function interrupt by
+	 * routing it via the ISA bus.  This bit generally only
+	 * affects 16-bit cards.  Some bridges allow one to set
+	 * another bit to have it also affect 32-bit cards.  Since
+	 * 32-bit cards are required to be better behaved, we don't
+	 * bother to get into those bridge specific features.
 	 */
 	mask = cbb_get(sc, CBB_SOCKET_MASK);
 	mask |= CBB_SOCKET_MASK_POWER;
@@ -763,13 +764,29 @@
 	if (on) {
 		mtx_lock(&sc->mtx);
 		cnt = sc->powerintr;
-		sane = 200;
+		/*
+		 * We have a shortish timeout of 500ms here.  Some
+		 * bridges do not generate a POWER_CYCLE event for
+		 * 16-bit cards.  In those cases, we have to cope the
+		 * best we can, and having only a short delay is
+		 * better than the alternatives.
+		 */
+		sane = 10;
 		while (!(cbb_get(sc, CBB_SOCKET_STATE) & CBB_STATE_POWER_CYCLE) &&
 		    cnt == sc->powerintr && sane-- > 0)
-			cv_timedwait(&sc->powercv, &sc->mtx, hz / 10);
+			cv_timedwait(&sc->powercv, &sc->mtx, hz / 20);
 		mtx_unlock(&sc->mtx);
-		if (sane <= 0)
+		/*
+		 * The TOPIC95B requires a little bit extra time to get
+		 * its act together, so delay for an additional 100ms.  Also
+		 * as documented below, it doesn't seem to set the POWER_CYCLE
+		 * bit, so don't whine if it never came on.
+		 */
+		if (sc->chipset == CB_TOPIC95) {
+			tsleep(sc, PZERO, "cbb95B", hz / 10);
+		} else if (sane <= 0) {
 			device_printf(sc->dev, "power timeout, doom?\n");
+		}
 	}
 
 	/*
@@ -782,10 +799,13 @@
 	 * we're called from the card insertion code, in which case the cbb
 	 * thread will turn it on for us before it waits to be woken by a
 	 * change event.
+	 *
+	 * NB: Topic95B doesn't set the power cycle bit.  we assume that
+	 * both it and the TOPIC95 behave the same.
 	 */
 	cbb_clrb(sc, CBB_SOCKET_MASK, CBB_SOCKET_MASK_POWER);
 	status = cbb_get(sc, CBB_SOCKET_STATE);
-	if (on) {
+	if (on && sc->chipset != CB_TOPIC95) {
 		if ((status & CBB_STATE_POWER_CYCLE) == 0)
 			device_printf(sc->dev, "Power not on?\n");
 	}
@@ -794,6 +814,15 @@
 		/* XXX Do we want to do something to mitigate things here? */
 		goto done;
 	}
+	if (sc->chipset == CB_TOPIC97) {
+		reg_ctrl = pci_read_config(sc->dev, TOPIC_REG_CTRL, 4);
+		reg_ctrl &= ~TOPIC97_REG_CTRL_TESTMODE;
+		if (on)
+			reg_ctrl |= TOPIC97_REG_CTRL_CLKRUN_ENA;
+		else
+			reg_ctrl &= ~TOPIC97_REG_CTRL_CLKRUN_ENA;
+		pci_write_config(sc->dev, TOPIC_REG_CTRL, reg_ctrl, 4);
+	}
 	PCI_MASK_CONFIG(brdev, CBBR_BRIDGECTRL,
 	    & ~CBBM_BRIDGECTRL_INTR_IREQ_ISA_EN, 2);
 	retval = 1;

==== //depot/projects/soc2006/rdivacky_linuxolator/dev/pccbb/pccbb_pci.c#3 (text+ko) ====

@@ -72,7 +72,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/pccbb/pccbb_pci.c,v 1.21 2006/06/03 19:16:45 imp Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/pccbb/pccbb_pci.c,v 1.22 2006/08/12 09:06:55 imp Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -302,10 +302,11 @@
 {
 	static int curr_bus_number = 2; /* XXX EVILE BAD (see below) */
 	struct cbb_softc *sc = (struct cbb_softc *)device_get_softc(brdev);
+	struct sysctl_ctx_list *sctx;
+	struct sysctl_oid *soid;
 	int rid;
 	device_t parent;
-	struct sysctl_ctx_list *sctx;
-	struct sysctl_oid *soid;
+	uint32_t pribus;
 
 	parent = device_get_parent(brdev);
 	mtx_init(&sc->mtx, device_get_nameunit(brdev), "cbb", MTX_DEF);
@@ -317,7 +318,7 @@
 	sc->exca[0].pccarddev = NULL;
 	sc->secbus = pci_read_config(brdev, PCIR_SECBUS_2, 1);
 	sc->subbus = pci_read_config(brdev, PCIR_SUBBUS_2, 1);
-	sc->pribus = pci_read_config(brdev, PCIR_PRIBUS_2, 1);
+	sc->pribus = pcib_get_bus(parent);
 	SLIST_INIT(&sc->rl);
 	cbb_powerstate_d0(brdev);
 
@@ -359,10 +360,11 @@
 	 * are in an appropriate range.
 	 */
 	DEVPRINTF((brdev, "Secondary bus is %d\n", sc->secbus));
-	if (sc->secbus == 0) {
+	pribus = pci_read_config(brdev, PCIR_PRIBUS_2, 1);
+	if (sc->secbus == 0 || sc->pribus != pribus) {
 		if (curr_bus_number <= sc->pribus)
 			curr_bus_number = sc->pribus + 1;
-		if (pci_read_config(brdev, PCIR_PRIBUS_2, 1) != sc->pribus) {
+		if (pribus != sc->pribus) {
 			DEVPRINTF((brdev, "Setting primary bus to %d\n",
 			    sc->pribus));
 			pci_write_config(brdev, PCIR_PRIBUS_2, sc->pribus, 1);
@@ -553,27 +555,32 @@
 		reg = (reg & 0x0f) |
 		    EXCA_O2CC_IREQ_INTC | EXCA_O2CC_STSCHG_INTC;
 		exca_putb(&sc->exca[0], EXCA_O2MICRO_CTRL_C, reg);
-
 		break;
 	case CB_TOPIC97:
 		/*
 		 * Disable Zoom Video, ToPIC 97, 100.
 		 */
-		pci_write_config(sc->dev, CBBR_TOPIC_ZV_CONTROL, 0, 1);
+		pci_write_config(sc->dev, TOPIC97_ZV_CONTROL, 0, 1);
 		/*
 		 * ToPIC 97, 100
 		 * At offset 0xa1: INTERRUPT CONTROL register
 		 * 0x1: Turn on INT interrupts.
 		 */
-		PCI_MASK_CONFIG(sc->dev, CBBR_TOPIC_INTCTRL,
-		    | CBBM_TOPIC_INTCTRL_INTIRQSEL, 1);
+		PCI_MASK_CONFIG(sc->dev, TOPIC_INTCTRL,
+		    | TOPIC97_INTCTRL_INTIRQSEL, 1);
+		/*
+		 * ToPIC97, 100
+		 * Need to assert support for low voltage cards
+		 */
+		exca_setb(&sc->exca[0], EXCA_TOPIC97_CTRL,
+		    EXCA_TOPIC97_CTRL_LV_MASK);
 		goto topic_common;
 	case CB_TOPIC95:
 		/*
 		 * SOCKETCTRL appears to be TOPIC 95/B specific
 		 */
-		PCI_MASK_CONFIG(sc->dev, CBBR_TOPIC_SOCKETCTRL,
-		    | CBBM_TOPIC_SOCKETCTRL_SCR_IRQSEL, 4);
+		PCI_MASK_CONFIG(sc->dev, TOPIC95_SOCKETCTRL,
+		    | TOPIC95_SOCKETCTRL_SCR_IRQSEL, 4);
 
 	topic_common:;
 		/*
@@ -586,20 +593,19 @@
 		 * in legacy mode to 0x3e0 and offset 0. (legacy
 		 * mode is determined elsewhere)
 		 */
-		pci_write_config(sc->dev, CBBR_TOPIC_SLOTCTRL,
-		    CBBM_TOPIC_SLOTCTRL_SLOTON |
-		    CBBM_TOPIC_SLOTCTRL_SLOTEN |
-		    CBBM_TOPIC_SLOTCTRL_ID_LOCK |
-		    CBBM_TOPIC_SLOTCTRL_ID_WP, 1);
+		pci_write_config(sc->dev, TOPIC_SLOTCTRL,
+		    TOPIC_SLOTCTRL_SLOTON |
+		    TOPIC_SLOTCTRL_SLOTEN |
+		    TOPIC_SLOTCTRL_ID_LOCK |
+		    TOPIC_SLOTCTRL_ID_WP, 1);

>>> TRUNCATED FOR MAIL (1000 lines) <<<



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