Date: Tue, 1 May 2007 19:33:33 GMT From: Bruce M Simpson <bms@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 119115 for review Message-ID: <200705011933.l41JXX2a056647@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=119115 Change 119115 by bms@bms_anglepoise on 2007/05/01 19:32:39 Move the hack which sets a default clock frequency under a compile-time kernel option. Create a separate include file for things relating to the YAMON boot monitor API. Affected files ... .. //depot/projects/mips2/src/sys/conf/options.mips#3 edit .. //depot/projects/mips2/src/sys/mips/conf/MALTA#12 edit .. //depot/projects/mips2/src/sys/mips/mips/tick.c#7 edit .. //depot/projects/mips2/src/sys/mips/mips4k/malta/yamon.c#2 edit .. //depot/projects/mips2/src/sys/mips/mips4k/malta/yamon.h#1 add Differences ... ==== //depot/projects/mips2/src/sys/conf/options.mips#3 (text+ko) ==== @@ -6,3 +6,4 @@ KERNPHYSADDR opt_global.h KERNVIRTADDR opt_global.h PHYSADDR opt_global.h +TICK_USE_YAMON_FREQ opt_global.h ==== //depot/projects/mips2/src/sys/mips/conf/MALTA#12 (text+ko) ==== @@ -28,6 +28,7 @@ makeoptions MODULES_OVERRIDE="" options KERNVIRTADDR=0x80100000 +options TICK_USE_YAMON_FREQ=defined include "../mips4k/malta/std.malta" hints "MALTA.hints" #Default places to look for devices. ==== //depot/projects/mips2/src/sys/mips/mips/tick.c#7 (text+ko) ==== @@ -28,8 +28,6 @@ /* * Simple driver for the 32-bit interval counter built in to all * MIPS32 CPUs. - * XXX: For calibration this either needs an external clock, or - * to be explicitly told what the frequency is. */ #include <sys/cdefs.h> @@ -51,6 +49,10 @@ #include <machine/locore.h> #include <machine/md_var.h> +#ifdef TICK_USE_YAMON_FREQ +#include <mips/mips4k/malta/yamon.h> +#endif + uint64_t counter_freq; uint64_t counts_per_hz; uint32_t counts_per_usec; @@ -77,40 +79,45 @@ static uint64_t tick_ticker(void) { + return ((uint64_t)mips_rd_count()); } -#if 1 -extern char *yamon_getenv(char *); -#endif - void tick_init_params(void) { -#ifdef notyet - u_int64_t counterval[2]; -#endif if (bootverbose) printf("Calibrating MIPS32 clock ... "); -#ifdef notyet - counterval[0] = mips_rd_count(); - DELAY(1000000); - counterval[1] = mips_rd_count(); - counter_freq = counterval[1] - counterval[0]; -#else - /* XXX: The boot monitor told us the CPU frequency. */ - { + do { +#ifdef TICK_USE_YAMON_FREQ + /* + * Use the clock frequency specified in the environment + * variables providied to us by the YAMON monitor. + */ char *cp = yamon_getenv("khz"); - printf("cp: %s\n", cp); + if (cp == NULL) { - printf("cannot determine clock frequency, defaulting to 10MHz\n"); + printf("cannot determine clock frequency, " + "defaulting to 10MHz\n"); counter_freq = 10000000; - } else + } else { counter_freq = strtol(cp, (char **)NULL, 10) * 1000 ; - } + } +#else + /* + * Determine clock frequency from hardware. + * XXX: Requires a working DELAY() macro. + */ + u_int64_t counterval[2]; + + counterval[0] = mips_rd_count(); + DELAY(1000000); + counterval[1] = mips_rd_count(); + counter_freq = counterval[1] - counterval[0]; #endif + } while (0); counts_per_hz = counter_freq / hz; counts_per_usec = counter_freq / 1000000; @@ -190,7 +197,7 @@ /* * Device section of file below - */ + */ static int clock_intr(void *arg) { ==== //depot/projects/mips2/src/sys/mips/mips4k/malta/yamon.c#2 (text+ko) ==== @@ -31,14 +31,7 @@ #include <sys/param.h> #include <sys/systm.h> -char* yamon_getenv(char *name); - -typedef struct { - char *name; - char *value; -} yamon_env_t; - -extern yamon_env_t *fenvp[]; +#include <mips/mips4k/malta/yamon.h> char * yamon_getenv(char *name)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200705011933.l41JXX2a056647>