PERFORCE change 55024 for review

Juli Mallett jmallett at FreeBSD.org
Tue Jun 15 14:03:21 GMT 2004


http://perforce.freebsd.org/chv.cgi?CH=55024

Change 55024 by jmallett at jmallett_oingo on 2004/06/15 14:02:35

	Hang an r4k clock off the cpu bus, and have it handle the setup of
	the timecounter.  XXX I still left ownership of cpu_initclocks to
	the platform, and in fact, it still sets clocks_running.  This gives
	it a chance to do its thing, or establish an alternate clock.  Really
	I don't like this, but I don't see an easy way to message the clock
	to start running :/  In the end I expect this will all just become a
	property of the cpu port and whatever devices and timecounters attach.
	At that point, would be nice to push this down to the timecounter layer
	and make it disable the timecounter and device, so we can free up irq
	5, if it chooses a higher quality timecounter.
	
	For now, do it this way, cause I must needs get the r4k clock into
	newbus, so I can do bad things to interrupts.

Affected files ...

.. //depot/projects/mips/sys/conf/files.mips#39 edit
.. //depot/projects/mips/sys/mips/include/clock.h#3 edit
.. //depot/projects/mips/sys/mips/mips/clock_r4k.c#1 add
.. //depot/projects/mips/sys/mips/mips/cpu.c#4 edit
.. //depot/projects/mips/sys/mips/mips/machdep.c#47 edit
.. //depot/projects/mips/sys/mips/sgimips/clock.c#11 edit

Differences ...

==== //depot/projects/mips/sys/conf/files.mips#39 (text+ko) ====

@@ -13,6 +13,7 @@
 mips/mips/autoconf.c		standard
 mips/mips/bus_machdep.c		standard
 mips/mips/busdma_machdep.c	standard
+mips/mips/clock_r4k.c		standard
 mips/mips/cpu.c			standard
 mips/mips/critical.c		standard
 mips/mips/elf_machdep.c		standard

==== //depot/projects/mips/sys/mips/include/clock.h#3 (text+ko) ====

@@ -28,12 +28,14 @@
 #ifndef _MACHINE_CLOCK_H_
 #define	_MACHINE_CLOCK_H_
 
-#ifdef KERNEL
+#ifdef _KERNEL
 
 /*
  * Nothing to see here.
  */
 
-#endif /* KERNEL */
+extern int clocks_running;
+
+#endif /* _KERNEL */
 
 #endif /* !_MACHINE_CLOCK_H_ */

==== //depot/projects/mips/sys/mips/mips/cpu.c#4 (text+ko) ====

@@ -215,12 +215,24 @@
 cpu_probe(device_t dev)
 {
 	struct wtf wtf;
+	device_t clock;
 
 	if (device_get_unit(dev) != 0)
 		panic("can't attach more cpus");
 
 	mips_wtf(&wtf);
 	device_set_desc(dev, wtf.wtf_type);
+
+	switch (wtf.wtf_class) {
+	case MIPS_R4000:
+		clock = device_add_child(dev, "r4k_clock", device_get_unit(dev));
+		if (clock == NULL)
+			device_printf(dev, "r4k_clock failed to attach");
+		break;
+	default:
+		device_printf(dev, "clock not available");
+		break;
+	}
 	return (0);
 }
 DRIVER_MODULE(cpu, root, cpu_driver, cpu_devclass, 0, 0);

==== //depot/projects/mips/sys/mips/mips/machdep.c#47 (text+ko) ====

@@ -63,6 +63,7 @@
 #endif
 
 int cold = 1;
+int clocks_running;
 
 static struct pcpu pcpu0;
 struct pcpu *pcpup = &pcpu0;

==== //depot/projects/mips/sys/mips/sgimips/clock.c#11 (text+ko) ====

@@ -25,71 +25,22 @@
  * $FreeBSD$
  */
 
-/*
- * XXX have a generic int5 clock in the mips/ code, and just use some
- * per-platform callbacks to get the freq.  Obviously this should be an
- * optional device.
- */
-
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/proc.h>
 #include <sys/time.h>
 #include <sys/timetc.h>
 
+#include <machine/clock.h>
 #include <machine/cpu.h>
 #include <machine/cpuinfo.h>
 #include <platform/intr.h>
 #include <platform/models.h>
 
-static unsigned
-sgimips_get_timecount(struct timecounter *tc)
-{
-	return (mips_rd_count());
-}
-
-static struct timecounter sgimips_timecounter = {
-	sgimips_get_timecount,
-	NULL,
-	~0,
-	0,
-	"Uninitialized SGIMIPS",
-	800
-};
-
-static void
-sgimips_clock5_intr(void *arg)
-{
-	struct clockframe cf;
-	struct trapframe *tf;
-
-	if (curthread == NULL)
-		return;
-
-	/*
-	 * Set next clock edge.
-	 */
-	tf = curthread->td_frame;
-	cf.sr = tf->tf_regs[TF_SR];
-	cf.pc = tf->tf_regs[TF_EPC];
-	hardclock(&cf);
-	mips_wr_compare(mips_rd_count() + curcpu()->ci_cycles_per_hz);
-}
-
 void
 cpu_initclocks(void)
 {
-	switch (mach_type) {
-	case MACH_SGI_IP22:
-		sgimips_timecounter.tc_frequency = curcpu()->ci_cpu_freq;
-		sgimips_timecounter.tc_name = "SGI IP22";
-		break;
-	default:
-		panic("cannot init clock for type %d", mach_type);
-	}
-	tc_init(&sgimips_timecounter);
-	platform_establish_hardintr(5, sgimips_clock5_intr, NULL);
-	mips_wr_compare(mips_rd_count() + curcpu()->ci_cycles_per_hz);
+	clocks_running = 1;
 }
 
 void


More information about the p4-projects mailing list