Port-playstation2 archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
untested timecounter & todr support for playstation2
Attached is my attempt to provide timecounters and generic todr (get
only, no set) support for the playstation2 port. I don't have a
playstation2 that can run NetBSD (no dev kit), and I don't have the
cross-tools installed, so I have not even compile-tested this. But it
should be a big help if anyone wants to take it as a starting off point
-- in the best case it will Just Work (maybe 55% chance of that), most
likely there will be some compile nits that I've busted (40% chance),
and worst case is its totally wrong and needs to be redesigned. (5%).
Anyway, the diffs are attached. If anyone can compile, test, and
commit them, I'd be grateful.
--
Garrett D'Amore, Principal Software Engineer
Tadpole Computer / Computing Technologies Division,
General Dynamics C4 Systems
http://www.tadpolecomputer.com/
Phone: 951 325-2134 Fax: 951 325-2191
Index: sys/arch/playstation2/conf/files.playstation2
===================================================================
RCS file: /cvsroot/src/sys/arch/playstation2/conf/files.playstation2,v
retrieving revision 1.15
diff -d -p -u -r1.15 files.playstation2
--- sys/arch/playstation2/conf/files.playstation2 11 Dec 2005 12:18:34
-0000 1.15
+++ sys/arch/playstation2/conf/files.playstation2 13 Sep 2006 21:15:44
-0000
@@ -23,6 +23,7 @@ file arch/playstation2/playstation2/cloc
file arch/playstation2/playstation2/disksubr.c disk
file arch/playstation2/playstation2/machdep.c
file arch/playstation2/playstation2/sifbios.c
+file arch/mips/mips/mips3_clock.c
file dev/kloader.c kloader
Index: sys/arch/playstation2/include/types.h
===================================================================
RCS file: /cvsroot/src/sys/arch/playstation2/include/types.h,v
retrieving revision 1.2
diff -d -p -u -r1.2 types.h
--- sys/arch/playstation2/include/types.h 2 Jan 2002 12:38:46 -0000
1.2
+++ sys/arch/playstation2/include/types.h 13 Sep 2006 21:15:44 -0000
@@ -3,6 +3,8 @@
#include <mips/types.h>
#define __HAVE_GENERIC_SOFT_INTERRUPTS
+#define __HAVE_GENERIC_TODR
+#define __HAVE_TIMECOUNTER
#if defined(_KERNEL) && defined(MIPS3_5900)
typedef int int128_t __attribute__((__mode__(TI)));
Index: sys/arch/playstation2/playstation2/clock.c
===================================================================
RCS file: /cvsroot/src/sys/arch/playstation2/playstation2/clock.c,v
retrieving revision 1.4
diff -d -p -u -r1.4 clock.c
--- sys/arch/playstation2/playstation2/clock.c 8 Mar 2006 23:46:24 -0000
1.4
+++ sys/arch/playstation2/playstation2/clock.c 13 Sep 2006 21:15:44 -0000
@@ -49,61 +49,28 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.
#include <playstation2/ee/timervar.h>
-#define MINYEAR 2001 /* "today" */
-
-static void get_bootinfo_tod(struct clock_ymdhms *);
+static int get_bootinfo_tod(todr_chip_handle_t, struct clock_ymdhms *);
void
cpu_initclocks()
{
+ struct todr_chip_handle todr = {
+ .todr_gettime_ymdhms = get_bootinfo_tod;
+ };
+
+ /*
+ * PS2 R5900 CPU clock is 294.912 MHz = (1 << 15) * 9 * 1000
+ */
+ curcpu()->ci_cpu_freq = 294912000;
hz = 100;
/* Install clock interrupt */
timer_clock_init();
-}
-
-void
-inittodr(time_t base)
-{
- struct clock_ymdhms dt;
- time_t rtc;
- int s;
-
- get_bootinfo_tod(&dt);
-
- rtc = clock_ymdhms_to_secs(&dt);
- if (rtc < base ||
- dt.dt_year < MINYEAR || dt.dt_year > 2037 ||
- dt.dt_mon < 1 || dt.dt_mon > 12 ||
- dt.dt_wday > 6 ||
- dt.dt_day < 1 || dt.dt_day > 31 ||
- dt.dt_hour > 23 || dt.dt_min > 59 || dt.dt_sec > 59) {
- /*
- * Believe the time in the file system for lack of
- * anything better, resetting the RTC.
- */
- s = splclock();
- time.tv_sec = base;
- time.tv_usec = 0;
- splx(s);
- printf("WARNING: preposterous clock chip time\n");
- resettodr();
- printf(" -- CHECK AND RESET THE DATE!\n");
- return;
- }
-
- s = splclock();
- time.tv_sec = rtc + rtc_offset * 60;
- time.tv_usec = 0;
- splx(s);
-}
+ todr_attach(&todr);
-void
-resettodr()
-{
- /* NetBSD kernel can't access PS2 RTC module. nothing to do */
+ mips3_init_tc();
}
void
@@ -112,65 +79,8 @@ setstatclockrate(int arg)
/* not yet */
}
-/*
- * Return the best possible estimate of the time in the timeval to
- * which tv points.
- */
-void
-microtime(struct timeval *tvp)
-{
- int s = splclock();
- static struct timeval lasttime;
-
- *tvp = time;
-
- if (tvp->tv_usec >= 1000000) {
- tvp->tv_usec -= 1000000;
- tvp->tv_sec++;
- }
-
- if (tvp->tv_sec == lasttime.tv_sec &&
- tvp->tv_usec <= lasttime.tv_usec &&
- (tvp->tv_usec = lasttime.tv_usec + 1) >= 1000000) {
- tvp->tv_sec++;
- tvp->tv_usec -= 1000000;
- }
- lasttime = *tvp;
- splx(s);
-}
-
-/*
- * Wait at least `n' usec. (max 15 sec)
- * PS2 R5900 CPU clock is 294.912 MHz = (1 << 15) * 9 * 1000
- */
-void
-delay(unsigned usec)
-{
- u_int32_t r0, r1, r2;
- u_int64_t n;
- int overlap;
-
- r0 = mips3_cp0_count_read();
- n = (((u_int64_t)usec * 294912) / 1000) + (u_int64_t)r0;
-
- overlap = n > 0xffffffff;
- r2 = (u_int32_t)(overlap ? 0xffffffff : n);
-
- do {
- r1 = mips3_cp0_count_read();
- } while (r1 < r2 && r1 > r0);
-
- if (overlap) {
- r0 = r1;
- r2 = (u_int32_t)(n - 0xffffffff);
- do {
- r1 = mips3_cp0_count_read();
- } while (r1 < r2 && r1 > r0);
- }
-}
-
-static void
-get_bootinfo_tod(struct clock_ymdhms *dt)
+static int
+get_bootinfo_tod(todr_chip_handle_t tch, struct clock_ymdhms *dt)
{
time_t utc;
struct bootinfo_rtc *rtc =
@@ -192,4 +102,5 @@ get_bootinfo_tod(struct clock_ymdhms *dt
dt->dt_mon, dt->dt_day, dt->dt_hour, dt->dt_min, dt->dt_sec,
rtc_offset);
#endif
+ return 0;
}
Home |
Main Index |
Thread Index |
Old Index