PERFORCE change 132757 for review
Oleksandr Tymoshenko
gonzo at FreeBSD.org
Mon Jan 7 15:32:42 PST 2008
http://perforce.freebsd.org/chv.cgi?CH=132757
Change 132757 by gonzo at gonzo_jeeves on 2008/01/07 23:31:51
o Retire old tick.c in favor of J! clock.c
o Move all clock-related stuff from machdep.c to clock.c
o Clean out onsoleted functions from clock.c
o All platforms should use mips_timer_init_params to initialize
CPU frequency (obtained in a platform-dependent fashion) and
frequency divisor. Fixed it for MALTA stuff only on the moment.
o Some style(9) fixes.
Affected files ...
.. //depot/projects/mips2-jnpr/src/sys/conf/files.mips#7 edit
.. //depot/projects/mips2-jnpr/src/sys/mips/include/clock.h#7 edit
.. //depot/projects/mips2-jnpr/src/sys/mips/mips/clock.c#4 edit
.. //depot/projects/mips2-jnpr/src/sys/mips/mips/machdep.c#11 edit
.. //depot/projects/mips2-jnpr/src/sys/mips/mips32/malta/malta_machdep.c#4 edit
Differences ...
==== //depot/projects/mips2-jnpr/src/sys/conf/files.mips#7 (text+ko) ====
@@ -56,7 +56,7 @@
# Phase 4
# ----------------------------------------------------------------------
#
-#mips/mips/clock.c standard
+mips/mips/clock.c standard
#mips/mips/queue.c standard
# ----------------------------------------------------------------------
# Phase 5
@@ -82,7 +82,7 @@
mips/mips/stack_machdep.c optional ddb | stack
mips/mips/support.S standard
mips/mips/swtch.S standard
-mips/mips/tick.c standard
+# mips/mips/tick.c standard
mips/mips/uio_machdep.c standard
geom/geom_bsd.c standard
geom/geom_bsd_enc.c standard
==== //depot/projects/mips2-jnpr/src/sys/mips/include/clock.h#7 (text+ko) ====
@@ -17,19 +17,6 @@
extern int cpu_clock;
-/*
- * count register is incremented as function of cpu
- * pipeline frequency.
- */
-/*
- * FREEBSD_DEVELOPERS_FIXME:
- * MIPS_COUNT_DIVIDER is CPU specific. There are some CPUs for which
- * the count register runs at the same frequency as the CPU pipeline frequency
- */
-
-/* Standard MIPS Processors - count runs at 1/2 of the CPU pipeline frequency */
-#define MIPS_COUNT_DIVIDER 2
-
extern uint32_t clockintr(uint32_t, struct clockframe *);
#define wall_cmos_clock 0
@@ -41,8 +28,7 @@
*/
#define MIPS_DEFAULT_HZ (100 * 1000 * 1000)
-void tick_init_params(uint64_t, int);
-void tick_init(void);
+void mips_timer_init_params(uint64_t, int);
int sysbeep(int pitch, int period);
extern uint64_t counter_freq;
==== //depot/projects/mips2-jnpr/src/sys/mips/mips/clock.c#4 (text+ko) ====
@@ -68,27 +68,13 @@
int clock_started = 0;
static u_long mips_timer_hz;
-u_int32_t cpu_counter_interval;
-
-struct timespec time;
-
-#define SECMIN (60) /* seconds per minute */
-#define SECHOUR (60*SECMIN) /* seconds per hour */
-#define SECDAY (24*SECHOUR) /* seconds per day */
-#define SECYR (365*SECDAY) /* seconds per common year */
+uint32_t cpu_counter_interval;
+uint32_t mips_count_divider = 2;
-#define YEARDAYS(year) ((((year) % 4) == 0 && \
- ((year % 100) != 0 || (year % 400) == 0)) ? 366 : 365)
-
-#define RTC_NOPROFRATE 128
-#define RTC_PROFRATE 1024
-#define R7K_TIMER_FREQ 33000000
-
#if 0
#define DEBUG_CLOCK 1
#endif
-static int get_todtime(struct tod_time *);
static unsigned mips_get_timecount(struct timecounter *tc);
static void mips_timer_init(void);
@@ -109,7 +95,7 @@
unsigned int c, current_dly = 0, dly, p;
p = Mips_GetCOUNT();
- dly = (cpu_clock / 1000000 / MIPS_COUNT_DIVIDER) * n;
+ dly = (cpu_clock / 1000000 / mips_count_divider) * n;
while(current_dly < dly ) {
c = Mips_GetCOUNT();
current_dly += c - p;
@@ -135,7 +121,7 @@
printf("cpu_initclocks(): stathz = 0x%x, profhz = 0x%x\n",
stathz, profhz);
- mips_timecounter.tc_frequency = cpu_clock / MIPS_COUNT_DIVIDER;
+ mips_timecounter.tc_frequency = cpu_clock / mips_count_divider;
tc_init(&mips_timecounter);
mips_timer_init();
@@ -144,14 +130,37 @@
}
}
-void mips_start_timer(void);
+static void
+mips_start_timer(void)
+{
+
+ Mips_SetCOMPARE(Mips_GetCOUNT() + cpu_counter_interval);
+}
+
+static uint64_t
+mips_ticker(void)
+{
+
+ return ((uint64_t)Mips_GetCOUNT());
+}
-void mips_start_timer(void)
+void
+mips_timer_init_params(uint64_t platform_counter_freq, int double_count)
{
- Mips_SetCOMPARE(Mips_GetCOUNT() + cpu_counter_interval);
+ cpu_clock = platform_counter_freq;
+
+ if (double_count != 0)
+ mips_count_divider = 2;
+ else
+ mips_count_divider = 1;
+
+ /* XXX: should divider be taken into account */
+ set_cputicker(mips_ticker, cpu_clock, 1);
}
+
+
/*
* Clock interrupt code for machines using the on cpu chip
* counter register. This register counts at half the pipeline
@@ -180,15 +189,15 @@
* The counter register acts like timer which is incremented as
* function of the CPU pipeline frequency.
*/
- cpu_counter_interval = (cpu_clock / MIPS_COUNT_DIVIDER) / mips_timer_hz ;
+ cpu_counter_interval = (cpu_clock / mips_count_divider) / mips_timer_hz ;
mips_start_timer();
printf("mips_timer_init: cpu_counter_interval = 0x%x\n",
cpu_counter_interval);
}
-intrmask_t
-clockintr(intrmask_t mask, struct clockframe *frame)
+uint32_t
+clockintr(uint32_t mask, struct clockframe *frame)
{
struct clk_ticks *cpu_ticks;
@@ -203,16 +212,16 @@
if (cpu_ticks->hard_ticks >= mips_timer_hz) {
cpu_ticks->hard_ticks -= mips_timer_hz;
if (PCPU_GET(cpuid) == 0)
- hardclock(frame);
+ hardclock(USERMODE(frame->sr), frame->pc);
else
- hardclock_process(frame);
+ hardclock_cpu(USERMODE(frame->sr));
}
/* Fire statclock at stathz. */
cpu_ticks->stat_ticks += stathz;
if (cpu_ticks->stat_ticks >= mips_timer_hz) {
cpu_ticks->stat_ticks -= mips_timer_hz;
- statclock(frame);
+ statclock(USERMODE(frame->sr));
}
/* Fire profclock at profhz, but only when needed. */
@@ -220,11 +229,10 @@
if (cpu_ticks->prof_ticks >= mips_timer_hz) {
cpu_ticks->prof_ticks -= mips_timer_hz;
if (profprocs != 0)
- profclock(frame);
+ profclock(USERMODE(frame->sr), frame->pc);
}
critical_exit();
done:
- atomic_add_int((int *)&intrcnt[INTRCNT_HARDCLOCK], 1);
/* restart timer */
mips_start_timer();
/*
@@ -237,34 +245,6 @@
return CR_INT_CLOCK;
}
-/*
- * We assume newhz is either stathz or profhz, and that neither will
- * change after being set up above. Could recalculate intervals here
- * but that would be a drag.
- */
-void
-setstatclockrate(int newhz)
-{
-
- /* nothing we can do */
-}
-
-static int
-get_todtime(struct tod_time *tod)
-{
-
- /*
- * Read RTC chip registers NOTE: Read routines are responsible
- * for sanity checking clock. Dates after 19991231 should be
- * returned as year >= 100.
- */
-
- /*
- * NO hardware tod clock.
- */
- return (0);
-}
-
void
cpu_startprofclock(void)
{
@@ -277,128 +257,9 @@
/* nothing to do */
}
-/*
- * This code is defunct after 2099. Will Unix still be here then??
- */
-static short dayyr[12] = {
- 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
-};
-
-/*
- * Initialize the time of day register, based on the time base which
- * is, e.g. from a filesystem.
- */
-void
-inittodr(time_t base)
-{
- struct tod_time c;
- long deltat;
- int days, yr, s;
-
- if (base < 15*SECYR) {
- printf("WARNING: preposterous time in file system\n");
- /* read the system clock anyway */
- base = 17*SECYR + 186*SECDAY + SECDAY/2;
- }
-
- if (base) {
- s = splclock();
- time.tv_sec = base;
- time.tv_nsec = 0;
- splx(s);
- }
-
- if (!get_todtime(&c)) {
- printf("WARNING: No TOD clock, believing file system.\n");
- s = splclock();
- tc_setclock(&time);
- splx(s);
- clockinitted = 1;
- return;
- }
-
- days = 0;
- for (yr = 1970; yr < c.year; yr++) {
- days += YEARDAYS(yr);
- }
- days += dayyr[c.mon - 1] + c.day - 1;
- if (YEARDAYS(c.year) == 366 && c.mon > 2)
- days++;
- /* now have days since Jan 1, 1970; the rest is easy... */
- s = splclock();
- time.tv_sec = days * SECDAY + c.hour * 3600 + c.min * 60 + c.sec;
- time.tv_nsec = 0;
- tc_setclock(&time);
- splx(s);
- clockinitted = 1;
-
- /*
- * See if we gained/lost time.
- */
- deltat = time.tv_sec - base;
- if (deltat > 5*SECYR) {
- printf("WARNING: clock %d days greater than file system time\n",
- deltat / SECDAY);
- return;
- } else if (deltat < -SECDAY) {
- printf("WARNING: clock %d days less than file system time\n",
- deltat / -SECDAY);
- } else {
- return;
- }
-}
-
-/*
- * Reset the TOD clock. This is done when the system is halted or
- * when the time is reset by the stime system call.
- */
-void
-resettodr(void)
-{
- struct tod_time c;
- register int t = 0, t2 = 0;
-
- /*
- * Don't reset clock if time has not been set!
- */
- if(!clockinitted) {
- return;
- }
-
- /* compute the day of week. 1 is Sunday*/
- t2 = time.tv_sec / SECDAY;
- c.dow = (t2 + 5) % 7; /* 1/1/1970 was thursday */
-
- /* compute the year */
- t2 = time.tv_sec / SECDAY;
- c.year = 69;
- while (t2 >= 0) { /* whittle off years */
- t = t2;
- c.year++;
- t2 -= YEARDAYS(c.year);
- }
-
- /* t = month + day; separate */
- t2 = YEARDAYS(c.year);
- for (c.mon = 1; c.mon < 12; c.mon++) {
- if (t < dayyr[c.mon] + (t2 == 366 && c.mon > 1))
- break;
- }
-
- c.day = t - dayyr[c.mon - 1] + 1;
- if (t2 == 366 && c.mon > 2) {
- c.day--;
- }
-
- t = time.tv_sec % SECDAY;
- c.hour = t / 3600;
- t %= 3600;
- c.min = t / 60;
- c.sec = t % 60;
-}
-
static unsigned
mips_get_timecount(struct timecounter *tc)
{
+
return(Mips_GetCOUNT());
}
==== //depot/projects/mips2-jnpr/src/sys/mips/mips/machdep.c#11 (text+ko) ====
@@ -119,7 +119,7 @@
int cold = 1;
int Maxmem;
long realmem = 0;
-int cpu_clock;
+int cpu_clock = MIPS_DEFAULT_HZ;
SYSCTL_INT(_hw, OID_AUTO, clockrate, CTLFLAG_RD,
&cpu_clock, 0, "CPU instruction clock rate");
int clocks_running = 0;
@@ -675,22 +675,3 @@
printf("Kernel dumps not implemented on this architecture\n");
}
-
-void
-cpu_initclocks()
-{
- tick_init();
- clocks_running = 1;
-}
-
-void
-cpu_startprofclock(void)
-{
-
-}
-
-void
-cpu_stopprofclock(void)
-{
-
-}
==== //depot/projects/mips2-jnpr/src/sys/mips/mips32/malta/malta_machdep.c#4 (text+ko) ====
@@ -314,5 +314,5 @@
#endif
} while(0);
- tick_init_params(platform_counter_freq, 0);
+ mips_timer_init_params(platform_counter_freq, 0);
}
More information about the p4-projects
mailing list