Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 28 Mar 2007 07:07:54 GMT
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 116720 for review
Message-ID:  <200703280707.l2S77sk2074249@repoman.freebsd.org>

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

Change 116720 by marcel@marcel_xcllnt on 2007/03/28 07:07:26

	IFC @116719

Affected files ...

.. //depot/projects/uart/Makefile#11 integrate
.. //depot/projects/uart/amd64/amd64/identcpu.c#13 integrate
.. //depot/projects/uart/amd64/amd64/prof_machdep.c#6 integrate
.. //depot/projects/uart/amd64/amd64/trap.c#17 integrate
.. //depot/projects/uart/amd64/amd64/tsc.c#6 integrate
.. //depot/projects/uart/arm/at91/at91_st.c#7 integrate
.. //depot/projects/uart/arm/at91/at91_twi.c#7 integrate
.. //depot/projects/uart/arm/at91/at91_twireg.h#2 integrate
.. //depot/projects/uart/arm/at91/kb920x_machdep.c#9 integrate
.. //depot/projects/uart/arm/conf/KB920X#7 integrate
.. //depot/projects/uart/arm/conf/KB920X.hints#1 branch
.. //depot/projects/uart/arm/xscale/i80321/i80321_wdog.c#3 integrate
.. //depot/projects/uart/arm/xscale/ixp425/ixp425_wdog.c#2 integrate
.. //depot/projects/uart/boot/ficl/ficl.h#3 integrate
.. //depot/projects/uart/boot/ficl/float.c#2 integrate
.. //depot/projects/uart/boot/ficl/softwords/fileaccess.fr#2 integrate
.. //depot/projects/uart/boot/ficl/softwords/jhlocal.fr#2 integrate
.. //depot/projects/uart/boot/ficl/softwords/oo.fr#2 integrate
.. //depot/projects/uart/boot/ficl/softwords/prefix.fr#2 integrate
.. //depot/projects/uart/boot/ficl/softwords/softcore.awk#2 integrate
.. //depot/projects/uart/boot/ficl/tools.c#2 integrate
.. //depot/projects/uart/boot/ficl/unix.c#2 integrate
.. //depot/projects/uart/boot/ficl/vm.c#2 integrate
.. //depot/projects/uart/boot/ficl/words.c#2 integrate
.. //depot/projects/uart/boot/i386/boot0/boot0.S#7 integrate
.. //depot/projects/uart/conf/NOTES#48 integrate
.. //depot/projects/uart/conf/files#80 integrate
.. //depot/projects/uart/conf/kern.post.mk#19 integrate
.. //depot/projects/uart/conf/options#45 integrate
.. //depot/projects/uart/contrib/altq/altq/altq_subr.c#4 integrate
.. //depot/projects/uart/dev/acpica/Osd/OsdSynch.c#9 integrate
.. //depot/projects/uart/dev/ce/if_ce.c#5 integrate
.. //depot/projects/uart/dev/cxgb/cxgb_adapter.h#2 integrate
.. //depot/projects/uart/dev/cxgb/cxgb_main.c#2 integrate
.. //depot/projects/uart/dev/cxgb/cxgb_sge.c#2 integrate
.. //depot/projects/uart/dev/exca/exca.c#14 integrate
.. //depot/projects/uart/dev/ichwd/ichwd.c#5 integrate
.. //depot/projects/uart/dev/iicbus/icee.c#1 branch
.. //depot/projects/uart/dev/iicbus/iic.c#9 integrate
.. //depot/projects/uart/dev/iicbus/iicbb.c#6 integrate
.. //depot/projects/uart/dev/iicbus/iicbus.c#7 integrate
.. //depot/projects/uart/dev/iicbus/iicbus.h#4 integrate
.. //depot/projects/uart/dev/iicbus/iiconf.c#5 integrate
.. //depot/projects/uart/dev/ipmi/ipmi.c#7 integrate
.. //depot/projects/uart/dev/ipw/if_ipw.c#9 integrate
.. //depot/projects/uart/dev/mk48txx/mk48txx.c#9 integrate
.. //depot/projects/uart/dev/mxge/if_mxge.c#7 integrate
.. //depot/projects/uart/dev/pci/pci.c#29 integrate
.. //depot/projects/uart/dev/pci/pcivar.h#12 integrate
.. //depot/projects/uart/dev/scc/scc_core.c#28 integrate
.. //depot/projects/uart/dev/snp/snp.c#10 integrate
.. //depot/projects/uart/dev/usb/uhci.c#20 integrate
.. //depot/projects/uart/dev/usb/uplcom.c#19 integrate
.. //depot/projects/uart/dev/usb/usb_quirks.c#12 integrate
.. //depot/projects/uart/dev/usb/usbdevs#30 integrate
.. //depot/projects/uart/dev/watchdog/watchdog.c#4 integrate
.. //depot/projects/uart/fs/devfs/devfs_vnops.c#20 integrate
.. //depot/projects/uart/fs/udf/udf_vnops.c#15 integrate
.. //depot/projects/uart/geom/geom_dev.c#14 integrate
.. //depot/projects/uart/i386/i386/elan-mmcr.c#8 integrate
.. //depot/projects/uart/i386/i386/geode.c#6 integrate
.. //depot/projects/uart/i386/i386/identcpu.c#24 integrate
.. //depot/projects/uart/i386/i386/locore.s#10 integrate
.. //depot/projects/uart/i386/i386/pmap.c#47 integrate
.. //depot/projects/uart/i386/i386/trap.c#18 integrate
.. //depot/projects/uart/i386/i386/tsc.c#8 integrate
.. //depot/projects/uart/i386/ibcs2/ibcs2_misc.c#12 integrate
.. //depot/projects/uart/i386/isa/prof_machdep.c#6 integrate
.. //depot/projects/uart/kern/init_main.c#19 integrate
.. //depot/projects/uart/kern/kern_cpu.c#6 integrate
.. //depot/projects/uart/kern/kern_exec.c#23 integrate
.. //depot/projects/uart/kern/kern_proc.c#19 integrate
.. //depot/projects/uart/kern/kern_thread.c#26 integrate
.. //depot/projects/uart/kern/sysv_sem.c#16 integrate
.. //depot/projects/uart/kern/uipc_sockbuf.c#4 integrate
.. //depot/projects/uart/kern/uipc_socket.c#26 integrate
.. //depot/projects/uart/kern/uipc_socket2.c#18 delete
.. //depot/projects/uart/kern/vfs_bio.c#28 integrate
.. //depot/projects/uart/kern/vfs_subr.c#38 integrate
.. //depot/projects/uart/modules/Makefile#46 integrate
.. //depot/projects/uart/modules/if_edsc/Makefile#1 branch
.. //depot/projects/uart/net/if.c#26 integrate
.. //depot/projects/uart/net/if_disc.c#10 integrate
.. //depot/projects/uart/net/if_edsc.c#1 branch
.. //depot/projects/uart/net/rtsock.c#16 integrate
.. //depot/projects/uart/netgraph/bluetooth/socket/ng_btsocket_l2cap.c#10 integrate
.. //depot/projects/uart/netinet/in_pcb.h#13 integrate
.. //depot/projects/uart/netinet/ip_input.c#21 integrate
.. //depot/projects/uart/netinet/ip_output.c#21 integrate
.. //depot/projects/uart/netinet/tcp_debug.h#4 integrate
.. //depot/projects/uart/netinet/tcp_input.c#30 integrate
.. //depot/projects/uart/netinet/tcp_sack.c#11 integrate
.. //depot/projects/uart/nfsclient/nfs_vfsops.c#18 integrate
.. //depot/projects/uart/nfsserver/nfs_serv.c#15 integrate
.. //depot/projects/uart/rpc/rpcclnt.c#6 integrate
.. //depot/projects/uart/sys/cpu.h#2 integrate
.. //depot/projects/uart/sys/eventhandler.h#6 integrate
.. //depot/projects/uart/sys/mbuf.h#17 integrate
.. //depot/projects/uart/sys/param.h#31 integrate
.. //depot/projects/uart/sys/rwlock.h#8 integrate
.. //depot/projects/uart/vm/vm_fault.c#21 integrate
.. //depot/projects/uart/vm/vm_map.c#26 integrate
.. //depot/projects/uart/vm/vm_object.c#27 integrate

Differences ...

==== //depot/projects/uart/Makefile#11 (text+ko) ====

@@ -1,4 +1,4 @@
-# $FreeBSD: src/sys/Makefile,v 1.40 2006/11/26 18:27:16 maxim Exp $
+# $FreeBSD: src/sys/Makefile,v 1.41 2007/03/24 22:21:01 maxim Exp $
 
 .include <bsd.own.mk>
 
@@ -9,7 +9,7 @@
 
 # Directories to include in cscope name file and TAGS.
 CSCOPEDIRS=	cam coda compat conf contrib crypto ddb dev fs geom gnu i4b \
-		isa isofs kern libkern modules net net80211 netatalk netatm \
+		isa kern libkern modules net net80211 netatalk netatm \
 		netgraph netinet netinet6 netipx netkey netnatm netncp \
 		netsmb nfs nfsclient nfs4client rpc pccard pci sys \
 		ufs vm ${ARCHDIR}

==== //depot/projects/uart/amd64/amd64/identcpu.c#13 (text+ko) ====

@@ -39,12 +39,14 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/amd64/identcpu.c,v 1.152 2007/03/20 20:22:45 jkim Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/amd64/identcpu.c,v 1.153 2007/03/26 18:03:29 njl Exp $");
 
 #include "opt_cpu.h"
 
 #include <sys/param.h>
 #include <sys/bus.h>
+#include <sys/cpu.h>
+#include <sys/eventhandler.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
 #include <sys/sysctl.h>
@@ -404,6 +406,21 @@
 }
 
 
+/* Update TSC freq with the value indicated by the caller. */
+static void
+tsc_freq_changed(void *arg, const struct cf_level *level, int status)
+{
+	/* If there was an error during the transition, don't do anything. */
+	if (status != 0)
+		return;
+
+	/* Total setting for this level gives the new frequency in MHz. */
+	hw_clockrate = level->total_set.freq;
+}
+
+EVENTHANDLER_DEFINE(cpufreq_post_change, tsc_freq_changed, NULL,
+    EVENTHANDLER_PRI_ANY);
+
 /*
  * Final stage of CPU identification. -- Should I check TI?
  */

==== //depot/projects/uart/amd64/amd64/prof_machdep.c#6 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/amd64/prof_machdep.c,v 1.28 2006/10/29 09:48:44 bde Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/amd64/prof_machdep.c,v 1.29 2007/03/26 18:03:29 njl Exp $");
 
 #ifdef GUPROF
 #if 0
@@ -35,6 +35,9 @@
 
 #include <sys/param.h>
 #include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/cpu.h>
+#include <sys/eventhandler.h>
 #include <sys/gmon.h>
 #include <sys/kernel.h>
 #include <sys/smp.h>
@@ -60,6 +63,9 @@
 static int	cputime_clock_pmc_init;
 static struct gmonparam saved_gmp;
 #endif
+#if defined(I586_CPU) || defined(I686_CPU)
+static int	cputime_prof_active;
+#endif
 #endif /* GUPROF */
 
 #ifdef __GNUCLIKE_ASM
@@ -205,6 +211,7 @@
 	u_char high, low;
 	static u_int prev_count;
 
+#if defined(I586_CPU) || defined(I686_CPU)
 	if (cputime_clock == CPUTIME_CLOCK_TSC) {
 		/*
 		 * Scale the TSC a little to make cputime()'s frequency
@@ -233,6 +240,7 @@
 		return (delta);
 	}
 #endif /* PERFMON && I586_PMC_GUPROF && !SMP */
+#endif /* I586_CPU || I686_CPU */
 
 	/*
 	 * Read the current value of the 8254 timer counter 0.
@@ -314,12 +322,17 @@
 {
 	if (cputime_clock == CPUTIME_CLOCK_UNINITIALIZED) {
 		cputime_clock = CPUTIME_CLOCK_I8254;
-		if (tsc_freq != 0 && !tsc_is_broken && mp_ncpus < 2)
+#if defined(I586_CPU) || defined(I686_CPU)
+		if (tsc_freq != 0 && !tsc_is_broken && mp_ncpus == 1)
 			cputime_clock = CPUTIME_CLOCK_TSC;
+#endif
 	}
 	gp->profrate = timer_freq << CPUTIME_CLOCK_I8254_SHIFT;
-	if (cputime_clock == CPUTIME_CLOCK_TSC)
+#if defined(I586_CPU) || defined(I686_CPU)
+	if (cputime_clock == CPUTIME_CLOCK_TSC) {
 		gp->profrate = tsc_freq >> 1;
+		cputime_prof_active = 1;
+	}
 #if defined(PERFMON) && defined(I586_PMC_GUPROF)
 	else if (cputime_clock == CPUTIME_CLOCK_I586_PMC) {
 		if (perfmon_avail() &&
@@ -346,6 +359,7 @@
 		}
 	}
 #endif /* PERFMON && I586_PMC_GUPROF */
+#endif /* I586_CPU || I686_CPU */
 	cputime_bias = 0;
 	cputime();
 }
@@ -361,5 +375,27 @@
 		cputime_clock_pmc_init = FALSE;
 	}
 #endif
+#if defined(I586_CPU) || defined(I686_CPU)
+	if (cputime_clock == CPUTIME_CLOCK_TSC)
+		cputime_prof_active = 0;
+#endif
 }
+
+#if defined(I586_CPU) || defined(I686_CPU)
+/* If the cpu frequency changed while profiling, report a warning. */
+static void
+tsc_freq_changed(void *arg, const struct cf_level *level, int status)
+{
+
+	/* If there was an error during the transition, don't do anything. */
+	if (status != 0)
+		return;
+	if (cputime_prof_active && cputime_clock == CPUTIME_CLOCK_TSC)
+		printf("warning: cpu freq changed while profiling active\n");
+}
+
+EVENTHANDLER_DEFINE(cpufreq_post_change, tsc_freq_changed, NULL,
+    EVENTHANDLER_PRI_ANY);
+#endif /* I586_CPU || I686_CPU */
+
 #endif /* GUPROF */

==== //depot/projects/uart/amd64/amd64/trap.c#17 (text+ko) ====

@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/amd64/trap.c,v 1.314 2007/03/09 04:02:36 mohans Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/amd64/trap.c,v 1.315 2007/03/26 21:45:44 kris Exp $");
 
 /*
  * AMD64 Trap and System call handling
@@ -745,10 +745,8 @@
 
 #ifdef DIAGNOSTIC
 	if (ISPL(frame->tf_cs) != SEL_UPL) {
-		mtx_lock(&Giant);	/* try to stabilize the system XXX */
 		panic("syscall");
 		/* NOT REACHED */
-		mtx_unlock(&Giant);
 	}
 #endif
 

==== //depot/projects/uart/amd64/amd64/tsc.c#6 (text+ko) ====

@@ -25,11 +25,14 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/amd64/tsc.c,v 1.206 2006/02/11 09:33:05 phk Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/amd64/tsc.c,v 1.207 2007/03/26 18:03:29 njl Exp $");
 
 #include "opt_clock.h"
 
 #include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/cpu.h>
+#include <sys/malloc.h>
 #include <sys/systm.h>
 #include <sys/sysctl.h>
 #include <sys/time.h>
@@ -41,8 +44,11 @@
 #include <machine/md_var.h>
 #include <machine/specialreg.h>
 
+#include "cpufreq_if.h"
+
 uint64_t	tsc_freq;
 int		tsc_is_broken;
+static eventhandler_tag tsc_levels_tag, tsc_pre_tag, tsc_post_tag;
 
 #ifdef SMP
 static int	smp_tsc;
@@ -51,14 +57,19 @@
 TUNABLE_INT("kern.timecounter.smp_tsc", &smp_tsc);
 #endif
 
+static void tsc_freq_changed(void *arg, const struct cf_level *level,
+    int status);
+static void tsc_freq_changing(void *arg, const struct cf_level *level,
+    int *status);
 static	unsigned tsc_get_timecount(struct timecounter *tc);
+static void tsc_levels_changed(void *arg, int unit);
 
 static struct timecounter tsc_timecounter = {
 	tsc_get_timecount,	/* get_timecount */
 	0,			/* no poll_pps */
- 	~0u,			/* counter_mask */
+	~0u,			/* counter_mask */
 	0,			/* frequency */
-	 "TSC",			/* name */
+	"TSC",			/* name */
 	800,			/* quality (adjusted in code) */
 };
 
@@ -77,10 +88,24 @@
 	tsc_freq = tscval[1] - tscval[0];
 	if (bootverbose)
 		printf("TSC clock: %lu Hz\n", tsc_freq);
+
+	/*
+	 * Inform CPU accounting about our boot-time clock rate.  Once the
+	 * system is finished booting, we will get the real max clock rate
+	 * via tsc_freq_max().  This also will be updated if someone loads
+	 * a cpufreq driver after boot that discovers a new max frequency.
+	 */
 	set_cputicker(rdtsc, tsc_freq, 1);
+
+	/* Register to find out about changes in CPU frequency. */
+	tsc_pre_tag = EVENTHANDLER_REGISTER(cpufreq_pre_change,
+	    tsc_freq_changing, NULL, EVENTHANDLER_PRI_FIRST);
+	tsc_post_tag = EVENTHANDLER_REGISTER(cpufreq_post_change,
+	    tsc_freq_changed, NULL, EVENTHANDLER_PRI_FIRST);
+	tsc_levels_tag = EVENTHANDLER_REGISTER(cpufreq_levels_changed,
+	    tsc_levels_changed, NULL, EVENTHANDLER_PRI_ANY);
 }
 
-
 void
 init_TSC_tc(void)
 {
@@ -104,6 +129,72 @@
 	}
 }
 
+/*
+ * When cpufreq levels change, find out about the (new) max frequency.  We
+ * use this to update CPU accounting in case it got a lower estimate at boot.
+ */
+static void
+tsc_levels_changed(void *arg, int unit)
+{
+	device_t cf_dev;
+	struct cf_level *levels;
+	int count, error;
+	uint64_t max_freq;
+
+	/* Only use values from the first CPU, assuming all are equal. */
+	if (unit != 0)
+		return;
+
+	/* Find the appropriate cpufreq device instance. */
+	cf_dev = devclass_get_device(devclass_find("cpufreq"), unit);
+	if (cf_dev == NULL) {
+		printf("tsc_levels_changed() called but no cpufreq device?\n");
+		return;
+	}
+
+	/* Get settings from the device and find the max frequency. */
+	count = 64;
+	levels = malloc(count * sizeof(*levels), M_TEMP, M_NOWAIT);
+	if (levels == NULL)
+		return;
+	error = CPUFREQ_LEVELS(cf_dev, levels, &count);
+	if (error == 0 && count != 0) {
+		max_freq = (uint64_t)levels[0].total_set.freq * 1000000;
+		set_cputicker(rdtsc, max_freq, 1);
+	} else
+		printf("tsc_levels_changed: no max freq found\n");
+	free(levels, M_TEMP);
+}
+
+/*
+ * If the TSC timecounter is in use, veto the pending change.  It may be
+ * possible in the future to handle a dynamically-changing timecounter rate.
+ */
+static void
+tsc_freq_changing(void *arg, const struct cf_level *level, int *status)
+{
+
+	if (*status != 0 || timecounter != &tsc_timecounter)
+		return;
+
+	printf("timecounter TSC must not be in use when "
+	     "changing frequencies; change denied\n");
+	*status = EBUSY;
+}
+
+/* Update TSC freq with the value indicated by the caller. */
+static void
+tsc_freq_changed(void *arg, const struct cf_level *level, int status)
+{
+	/* If there was an error during the transition, don't do anything. */
+	if (status != 0)
+		return;
+
+	/* Total setting for this level gives the new frequency in MHz. */
+	tsc_freq = (uint64_t)level->total_set.freq * 1000000;
+	tsc_timecounter.tc_frequency = tsc_freq;
+}
+
 static int
 sysctl_machdep_tsc_freq(SYSCTL_HANDLER_ARGS)
 {

==== //depot/projects/uart/arm/at91/at91_st.c#7 (text) ====

@@ -23,7 +23,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/arm/at91/at91_st.c,v 1.8 2007/02/23 12:18:27 piso Exp $");
+__FBSDID("$FreeBSD: src/sys/arm/at91/at91_st.c,v 1.9 2007/03/27 21:03:35 n_hibma Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -171,13 +171,11 @@
 	int t;
 
 	t = cmd & WD_INTERVAL;
-	if (cmd > 0 && t >= 22 && t <= 37) {
+	if (t >= 22 && t <= 37) {
 		wdog = (1 << (t - 22)) | ST_WDMR_RSTEN;
 		*error = 0;
 	} else {
 		wdog = 0;
-		if (cmd > 0)
-			*error = EINVAL;
 	}
 	WR4(ST_WDMR, wdog);
 	WR4(ST_CR, ST_CR_WDRST);

==== //depot/projects/uart/arm/at91/at91_twi.c#7 (text) ====

@@ -23,7 +23,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/arm/at91/at91_twi.c,v 1.9 2007/02/23 12:18:27 piso Exp $");
+__FBSDID("$FreeBSD: src/sys/arm/at91/at91_twi.c,v 1.10 2007/03/23 22:57:24 imp Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -45,6 +45,10 @@
 #include <dev/iicbus/iicbus.h>
 #include "iicbus_if.h"
 
+#define TWI_SLOW_CLOCK		 1500
+#define TWI_FAST_CLOCK 		45000
+#define TWI_FASTEST_CLOCK	90000
+
 struct at91_twi_softc
 {
 	device_t dev;			/* Myself */
@@ -123,7 +127,7 @@
 		AT91_TWI_LOCK_DESTROY(sc);
 		goto out;
 	}
-	sc->cwgr = TWI_CWGR_CKDIV(8 * AT91C_MASTER_CLOCK / 90000) |
+	sc->cwgr = TWI_CWGR_CKDIV(8 * AT91C_MASTER_CLOCK / TWI_FASTEST_CLOCK) |
 	    TWI_CWGR_CHDIV(TWI_CWGR_DIV(TWI_DEF_CLK)) |
 	    TWI_CWGR_CLDIV(TWI_CWGR_DIV(TWI_DEF_CLK));
 	WR4(sc, TWI_CR, TWI_CR_SWRST);
@@ -226,14 +230,13 @@
 	int counter = 100000;
 	uint32_t sr;
 
-	while (!((sr = RD4(sc, TWI_SR)) & bit) && counter-- > 0)
+	while (!((sr = RD4(sc, TWI_SR)) & bit) && counter-- > 0 &&
+	    !(sr & TWI_SR_NACK))
 		continue;
 	if (counter <= 0)
 		err = EBUSY;
 	else if (sr & TWI_SR_NACK)
-		err = EADDRNOTAVAIL;
-	if (sr & ~bit)
-		printf("status is %x\n", sr);
+		err = ENXIO;		// iic nack convention
 	return (err);
 }
 
@@ -253,17 +256,17 @@
 	 */
 	switch (speed) {
 	case IIC_SLOW:
-		clk = 1500;
+		clk = TWI_SLOW_CLOCK;
 		break;
 
 	case IIC_FAST:
-		clk = 45000;
+		clk = TWI_FAST_CLOCK;
 		break;
 
 	case IIC_UNKNOWN:
 	case IIC_FASTEST:
 	default:
-		clk = 90000;
+		clk = TWI_FASTEST_CLOCK;
 		break;
 	}
 	sc->cwgr = TWI_CWGR_CKDIV(1) | TWI_CWGR_CHDIV(TWI_CWGR_DIV(clk)) |
@@ -302,6 +305,7 @@
 	int i, len, err;
 	uint32_t rdwr;
 	uint8_t *buf;
+	uint32_t sr;
 
 	sc = device_get_softc(dev);
 	err = 0;
@@ -320,26 +324,36 @@
 		WR4(sc, TWI_MMR, TWI_MMR_DADR(msgs[i].slave) | rdwr);
 		len = msgs[i].len;
 		buf = msgs[i].buf;
-		if (len != 0 && buf == NULL)
-			return (EINVAL);
-		WR4(sc, TWI_CR, TWI_CR_START);
+		/* zero byte transfers aren't allowed */
+		if (len == 0 || buf == NULL) {
+			err = EINVAL;
+			goto out;
+		}
+		if (len == 1)
+			WR4(sc, TWI_CR, TWI_CR_START | TWI_CR_STOP);
+		else
+			WR4(sc, TWI_CR, TWI_CR_START);
 		if (msgs[i].flags & IIC_M_RD) {
-			while (len--) {
-				if (len == 0)
-					WR4(sc, TWI_CR, TWI_CR_STOP);
-				if ((err = at91_twi_wait(sc, TWI_SR_RXRDY)))
-					goto out;
-				*buf++ = RD4(sc, TWI_RHR) & 0xff;
+			sr = RD4(sc, TWI_SR);
+			while (!(sr & TWI_SR_TXCOMP)) {
+				if ((sr = RD4(sc, TWI_SR)) & TWI_SR_RXRDY) {
+					len--;
+					*buf++ = RD4(sc, TWI_RHR) & 0xff;
+					if (len == 0 && msgs[i].len != 1)
+						WR4(sc, TWI_CR, TWI_CR_STOP);
+				}
+			}
+			if (len > 0 || (sr & TWI_SR_NACK)) {
+				err = ENXIO;		// iic nack convention
+				goto out;
 			}
 		} else {
 			while (len--) {
-				WR4(sc, TWI_THR, *buf++);
-				if (len == 0)
+				if (len == 0 && msgs[i].len != 1)
 					WR4(sc, TWI_CR, TWI_CR_STOP);
-				if ((err = at91_twi_wait(sc, TWI_SR_TXRDY))) {
-					printf("Len %d\n", len);
+				if ((err = at91_twi_wait(sc, TWI_SR_TXRDY)))
 					goto out;
-				}
+				WR4(sc, TWI_THR, *buf++);
 			}
 		}
 		if ((err = at91_twi_wait(sc, TWI_SR_TXCOMP)))
@@ -347,8 +361,9 @@
 	}
 out:;
 	if (err) {
-		WR4(sc, TWI_CR, TWI_CR_STOP);
-		printf("Err is %d\n", err);
+		WR4(sc, TWI_CR, TWI_CR_SWRST);
+		WR4(sc, TWI_CR, TWI_CR_MSEN | TWI_CR_SVDIS);
+		WR4(sc, TWI_CWGR, sc->cwgr);
 	}
 	AT91_TWI_UNLOCK(sc);
 	return (err);

==== //depot/projects/uart/arm/at91/at91_twireg.h#2 (text) ====

@@ -22,7 +22,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-/* $FreeBSD: src/sys/arm/at91/at91_twireg.h,v 1.1 2006/02/04 23:32:13 imp Exp $ */
+/* $FreeBSD: src/sys/arm/at91/at91_twireg.h,v 1.2 2007/03/23 22:57:24 imp Exp $ */
 
 #ifndef ARM_AT91_AT91_TWIREG_H
 #define ARM_AT91_AT91_TWIREG_H
@@ -56,7 +56,7 @@
 #define TWI_MMR_IADRSZ(n) ((n) << 8)	/* Set size of transfer */
 #define TWI_MMR_MWRITE	0U		/* Master Read Direction */
 #define TWI_MMR_MREAD	(1U << 12)	/* Master Read Direction */
-#define TWI_MMR_DADR(n)	((n) << 16)	/* Device Address */
+#define TWI_MMR_DADR(n)	((n) << 15)	/* Device Address */
 
 /* TWI_CWGR */
 #define TWI_CWGR_CKDIV(x) ((x) << 16)	/* Clock Divider */

==== //depot/projects/uart/arm/at91/kb920x_machdep.c#9 (text) ====

@@ -48,7 +48,7 @@
 #include "opt_at91.h"
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/arm/at91/kb920x_machdep.c,v 1.20 2006/12/06 06:34:53 julian Exp $");
+__FBSDID("$FreeBSD: src/sys/arm/at91/kb920x_machdep.c,v 1.21 2007/03/27 06:29:19 kevlo Exp $");
 
 #define _ARM32_BUS_DMA_PRIVATE
 #include <sys/param.h>
@@ -136,7 +136,6 @@
 struct pv_addr undstack;
 struct pv_addr abtstack;
 struct pv_addr kernelstack;
-struct pv_addr minidataclean;
 
 static struct trapframe proc0_tf;
 
@@ -355,7 +354,6 @@
 	valloc_pages(abtstack, ABT_STACK_SIZE);
 	valloc_pages(undstack, UND_STACK_SIZE);
 	valloc_pages(kernelstack, KSTACK_PAGES);
-	alloc_pages(minidataclean.pv_pa, 1);
 	valloc_pages(msgbufpv, round_page(MSGBUF_SIZE) / PAGE_SIZE);
 	/*
 	 * Now we start construction of the L1 page table
@@ -379,9 +377,6 @@
 		pmap_link_l2pt(l1pagetable, afterkern + i * 0x00100000,
 		    &kernel_pt_table[KERNEL_PT_AFKERNEL + i]);
 	}
-	pmap_map_entry(l1pagetable, afterkern, minidataclean.pv_pa, 
-	    VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
-	
 
 	/* Map the vector page. */
 	pmap_map_entry(l1pagetable, ARM_VECTORS_HIGH, systempage.pv_pa,

==== //depot/projects/uart/arm/conf/KB920X#7 (text) ====

@@ -16,7 +16,7 @@
 # If you are in doubt as to the purpose or necessity of a line, check first 
 # in NOTES.
 #
-# $FreeBSD: src/sys/arm/conf/KB920X,v 1.11 2006/10/26 22:11:35 jb Exp $
+# $FreeBSD: src/sys/arm/conf/KB920X,v 1.12 2007/03/23 23:47:59 imp Exp $
 
 machine		arm
 ident		KB920X
@@ -24,6 +24,7 @@
 include		"../at91/std.kb920x"
 #To statically compile in device wiring instead of /boot/device.hints
 #hints		"GENERIC.hints"		#Default places to look for devices.
+hints		"KB920X.hints"
 
 makeoptions	DEBUG=-g		#Build kernel with gdb(1) debug symbols
 options		DDB
@@ -38,12 +39,12 @@
 #options 	UFS_DIRHASH		#Improve performance on big directories
 #options 	MD_ROOT			#MD is a potential root device
 #options		MD_ROOT_SIZE=4096	# 3MB ram disk
-#options 	ROOTDEVNAME=\"ufs:md0\"
+options 	ROOTDEVNAME=\"ufs:/dev/mmcsd0s1a\"
 options 	NFSCLIENT		#Network Filesystem Client
 #options 	NFSSERVER		#Network Filesystem Server
-options 	NFS_ROOT		#NFS usable as /, requires NFSCLIENT
-options		BOOTP_NFSROOT
-options		BOOTP
+#options 	NFS_ROOT		#NFS usable as /, requires NFSCLIENT
+#options	BOOTP_NFSROOT
+#options	BOOTP
 
 #options 	MSDOSFS			#MSDOS Filesystem
 #options 	CD9660			#ISO 9660 Filesystem
@@ -79,6 +80,16 @@
 
 device		mem			# Memory and kernel memory devices
 device		md
-# device	at91_twi		# TWI: Two Wire Interface
+device		at91_twi		# TWI: Two Wire Interface
 device		at91_spi		# SPI:
 device		spibus
+# MMC/SD
+device		at91_mci
+device		mmc
+device		mmcsd
+# iic
+device		iic
+device		iicbus
+device		icee
+
+device		bpf

==== //depot/projects/uart/arm/xscale/i80321/i80321_wdog.c#3 (text+ko) ====

@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/arm/xscale/i80321/i80321_wdog.c,v 1.3 2006/12/15 21:44:48 n_hibma Exp $");
+__FBSDID("$FreeBSD: src/sys/arm/xscale/i80321/i80321_wdog.c,v 1.4 2007/03/27 21:03:35 n_hibma Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -111,18 +111,15 @@
 
 	cmd &= WD_INTERVAL;
 	if (cmd > 0 && cmd <= 63
-	    && (uint64_t)1 << (cmd & WD_INTERVAL) <=
-	       (uint64_t)sc->wdog_period * 1000000000) {
+	    && (uint64_t)1<<cmd <= (uint64_t)sc->wdog_period * 1000000000) {
 		/* Valid value -> Enable watchdog */
 		iopwdog_tickle(sc);
 		sc->armed = 1;
 		*error = 0;
 	} else {
-		/* XXX Can't disable this watchdog? */
+		/* Can't disable this watchdog! */
 		if (sc->armed)
 			*error = EOPNOTSUPP;
-		else if (cmd > 0)
-			*error = EINVAL;
 	}
 }
 

==== //depot/projects/uart/arm/xscale/ixp425/ixp425_wdog.c#2 (text+ko) ====

@@ -22,7 +22,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/arm/xscale/ixp425/ixp425_wdog.c,v 1.1 2006/11/19 23:55:23 sam Exp $");
+__FBSDID("$FreeBSD: src/sys/arm/xscale/ixp425/ixp425_wdog.c,v 1.2 2007/03/27 21:03:36 n_hibma Exp $");
 
 /*
  * IXP425 Watchdog Timer Support.
@@ -70,7 +70,7 @@
 	u_int u = cmd & WD_INTERVAL;
 
 	WR4(sc, IXP425_OST_WDOG_KEY, OST_WDOG_KEY_MAJICK);
-	if (cmd && 4 <= u && u <= 35) {
+	if (4 <= u && u <= 35) {
 		WR4(sc, IXP425_OST_WDOG_ENAB, 0);
 		/* approximate 66.66MHz cycles */
 		WR4(sc, IXP425_OST_WDOG, 2<<(u - 4));

==== //depot/projects/uart/boot/ficl/ficl.h#3 (text+ko) ====

@@ -41,7 +41,7 @@
 ** SUCH DAMAGE.
 */
 
-/* $FreeBSD: src/sys/boot/ficl/ficl.h,v 1.21 2004/11/30 11:35:30 scottl Exp $ */
+/* $FreeBSD: src/sys/boot/ficl/ficl.h,v 1.22 2007/03/23 22:26:01 jkim Exp $ */
 
 #if !defined (__FICL_H__)
 #define __FICL_H__
@@ -237,9 +237,9 @@
 /* 
 ** the Good Stuff starts here...
 */
-#define FICL_VER        "3.02"
+#define FICL_VER        "3.03"
 #define FICL_VER_MAJOR  3
-#define FICL_VER_MINOR  2
+#define FICL_VER_MINOR  3
 #if !defined (FICL_PROMPT)
 #define FICL_PROMPT "ok> "
 #endif
@@ -857,7 +857,7 @@
 	FICL_WORD *pDoesParen;
 	FICL_WORD *pExitInner;
 	FICL_WORD *pExitParen;
-	FICL_WORD *pIfParen;
+	FICL_WORD *pBranch0;
 	FICL_WORD *pInterpret;
 	FICL_WORD *pLitParen;
 	FICL_WORD *pTwoLitParen;
@@ -865,7 +865,9 @@
 	FICL_WORD *pPLoopParen;
 	FICL_WORD *pQDoParen;
 	FICL_WORD *pSemiParen;
+	FICL_WORD *pOfParen;
 	FICL_WORD *pStore;
+	FICL_WORD *pDrop;
 	FICL_WORD *pCStringLit;
 	FICL_WORD *pStringLit;
 
@@ -1086,6 +1088,7 @@
     IF,
     LITERAL,
     LOOP,
+    OF,
     PLOOP,
     PRIMITIVE,
     QDO,

==== //depot/projects/uart/boot/ficl/float.c#2 (text+ko) ====

@@ -41,7 +41,7 @@
 ** SUCH DAMAGE.
 */
 
-/* $FreeBSD: src/sys/boot/ficl/float.c,v 1.1 2002/04/09 17:45:11 dcs Exp $ */
+/* $FreeBSD: src/sys/boot/ficl/float.c,v 1.2 2007/03/23 22:26:01 jkim Exp $ */
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -977,6 +977,8 @@
     }
 
     PUSHFLOAT(accum);
+    if (pVM->state == COMPILE)
+        fliteralIm(pVM);
 
     return(1);
 }
@@ -1062,3 +1064,4 @@
 #endif
     return;
 }
+

==== //depot/projects/uart/boot/ficl/softwords/fileaccess.fr#2 (text+ko) ====

@@ -4,7 +4,7 @@
 \ ** submitted by Larry Hastings, larry@hastings.org
 \ **
 \
-\ $FreeBSD: src/sys/boot/ficl/softwords/fileaccess.fr,v 1.1 2002/04/09 17:45:27 dcs Exp $
+\ $FreeBSD: src/sys/boot/ficl/softwords/fileaccess.fr,v 1.2 2007/03/23 22:26:01 jkim Exp $
 
 : r/o 1 ;
 : r/w 3 ; 
@@ -15,12 +15,11 @@
     r/o bin open-file 0= if
         locals| f | end-locals
         f include-file
-        f close-file drop
     else
         drop
     endif
     ;
 
-: include parse-word included ; immediate
+: include parse-word included ;
 
 \ #endif

==== //depot/projects/uart/boot/ficl/softwords/jhlocal.fr#2 (text+ko) ====

@@ -14,11 +14,13 @@
 \
 \ revised 2 June 2000 - { | a -- } now works correctly
 \
-\ $FreeBSD: src/sys/boot/ficl/softwords/jhlocal.fr,v 1.4 2001/04/29 02:36:36 dcs Exp $
+\ $FreeBSD: src/sys/boot/ficl/softwords/jhlocal.fr,v 1.5 2007/03/23 22:26:01 jkim Exp $
 
 hide
+
 0 constant zero
 
+
 : ?--   ( c-addr u -- c-addr u flag )
     2dup s" --" compare 0= ;
 : ?}    ( c-addr u -- c-addr u flag )
@@ -74,23 +76,24 @@
             parse-word
             ?delim dup to locstate
         0= while
-		    ?2loc if 
-			    postpone zero postpone zero  (2local)
-			else
-                postpone zero  (local)
-		    endif
+            ?2loc if
+                postpone zero postpone zero (2local)
+            else
+                postpone zero (local)
+            endif
         repeat
     endif
 
     0 0 (local)
 
     \ toss words until }
+    \ (explicitly allow | and -- in the comment)
     locstate 2 = if
         begin
             parse-word
-            ?delim dup to locstate
-        0= while
-            2drop
+            ?delim dup  to locstate
+        3 < while
+            locstate 0=  if 2drop endif
         repeat
     endif
 

==== //depot/projects/uart/boot/ficl/softwords/oo.fr#2 (text+ko) ====

@@ -3,7 +3,7 @@
 \ ** F I C L   O - O   E X T E N S I O N S
 \ ** john sadler aug 1998
 \
-\ $FreeBSD: src/sys/boot/ficl/softwords/oo.fr,v 1.4 2002/04/09 17:45:28 dcs Exp $
+\ $FreeBSD: src/sys/boot/ficl/softwords/oo.fr,v 1.5 2007/03/23 22:26:01 jkim Exp $
 
 17 ficl-vocabulary oop
 also oop definitions
@@ -86,8 +86,6 @@
 \ execute it at run-time...
 \
 
-hide
-
 \ p a r s e - m e t h o d
 \ compiles a method name so that it pushes
 \ the string base address and count at run-time.
@@ -97,6 +95,13 @@
     postpone sliteral
 ; compile-only
 
+
+
+: (lookup-method)  { class 2:name -- class 0 | class xt 1 | class xt -1  }
+    class  name class cell+ @  ( class c-addr u wid )
+    search-wordlist
+;
+
 \ l o o k u p - m e t h o d
 \ takes a counted string method name from the stack (as compiled
 \ by parse-method) and attempts to look this method up in the method list of 
@@ -104,22 +109,18 @@
 \ and pushes the xt of the method. If not, it aborts with an error message.
 
 : lookup-method  { class 2:name -- class xt }
-    name class cell+ @  ( c-addr u wid )
-    search-wordlist     ( 0 | xt 1 | xt -1 )
+    class name (lookup-method)    ( 0 | xt 1 | xt -1 )
     0= if
         name type ."  not found in " 
         class body> >name type
         cr abort 
     endif 
-    class swap
 ;
 
 : find-method-xt   \ name ( class -- class xt )
     parse-word lookup-method
 ;
 
-set-current  ( stop hiding definitions )
-
 : catch-method  ( instance class c-addr u -- <method-signature> exc-flag )
     lookup-method catch
 ;


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



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