[patch] Clocks on PC98
Alexander Motin
mav at FreeBSD.org
Mon Jul 12 08:40:01 UTC 2010
Hi.
I've made a patch to unify PC98 event timer code with the rest of x86.
Could somebody test it on that hardware, as all I can say now is that it
builds.
I have no idea about ISA PNP on PC98, so if it doesn't report timer
presence, it may be needed to add to device.hints lines like:
hint.attimer.0.at="isa"
hint.attimer.0.port="0x71"
hint.attimer.0.irq="0"
--
Alexander Motin
-------------- next part --------------
diff -ruNp --exclude .svn --exclude compile /storage/head/sys/conf/files.pc98 sys/conf/files.pc98
--- /storage/head/sys/conf/files.pc98 2010-06-09 08:33:25.000000000 +0300
+++ sys/conf/files.pc98 2010-07-12 11:02:29.000000000 +0300
@@ -227,7 +227,6 @@ libkern/udivdi3.c standard
libkern/umoddi3.c standard
pc98/apm/apm_bioscall.S optional apm
pc98/cbus/cbus_dma.c optional isa
-pc98/cbus/clock.c standard
pc98/cbus/fdc.c optional fdc
pc98/cbus/fdc_cbus.c optional fdc isa
pc98/cbus/gdc.c optional gdc
@@ -253,8 +252,11 @@ pc98/pc98/pc98_machdep.c standard
# x86 shared code between IA32, AMD64 and PC98 architectures
#
x86/isa/atpic.c optional atpic
+x86/isa/clock.c standard
x86/isa/isa.c optional isa
x86/x86/io_apic.c optional apic
x86/x86/local_apic.c optional apic
x86/x86/mca.c standard
x86/x86/msi.c optional apic pci
+x86/x86/timeevents.c standard
+
diff -ruNp --exclude .svn --exclude compile /storage/head/sys/x86/isa/clock.c sys/x86/isa/clock.c
--- /storage/head/sys/x86/isa/clock.c 2010-07-12 09:46:16.000000000 +0300
+++ sys/x86/isa/clock.c 2010-07-12 11:16:37.000000000 +0300
@@ -66,9 +66,17 @@ __FBSDID("$FreeBSD: head/sys/x86/isa/clo
#include <machine/ppireg.h>
#include <machine/timerreg.h>
+#ifdef PC98
+#include <pc98/pc98/pc98_machdep.h>
+#else
#include <isa/rtc.h>
+#endif
#ifdef DEV_ISA
+#ifdef PC98
+#include <pc98/cbus/cbus.h>
+#else
#include <isa/isareg.h>
+#endif
#include <isa/isavar.h>
#endif
@@ -78,8 +86,12 @@ __FBSDID("$FreeBSD: head/sys/x86/isa/clo
int clkintr_pending;
#ifndef TIMER_FREQ
+#ifdef PC98
+#define TIMER_FREQ 2457600
+#else
#define TIMER_FREQ 1193182
#endif
+#endif
u_int i8254_freq = TIMER_FREQ;
TUNABLE_INT("hw.i8254.freq", &i8254_freq);
int i8254_max_count;
@@ -150,8 +162,11 @@ timer_spkr_acquire(void)
{
int mode;
+#ifdef PC98
+ mode = TIMER_SEL1 | TIMER_SQWAVE | TIMER_16BIT;
+#else
mode = TIMER_SEL2 | TIMER_SQWAVE | TIMER_16BIT;
-
+#endif
if (timer2_state != RELEASED)
return (-1);
timer2_state = ACQUIRED;
@@ -163,7 +178,11 @@ timer_spkr_acquire(void)
* and this is probably good enough for timer2, so we aren't as
* careful with it as with timer0.
*/
+#ifdef PC98
+ outb(TIMER_MODE, TIMER_SEL1 | (mode & 0x3f));
+#else
outb(TIMER_MODE, TIMER_SEL2 | (mode & 0x3f));
+#endif
ppi_spkr_on(); /* enable counter2 output to speaker */
return (0);
}
@@ -175,7 +194,11 @@ timer_spkr_release(void)
if (timer2_state != ACQUIRED)
return (-1);
timer2_state = RELEASED;
+#ifdef PC98
+ outb(TIMER_MODE, TIMER_SEL1 | TIMER_SQWAVE | TIMER_16BIT);
+#else
outb(TIMER_MODE, TIMER_SEL2 | TIMER_SQWAVE | TIMER_16BIT);
+#endif
ppi_spkr_off(); /* disable counter2 output to speaker */
return (0);
}
@@ -293,7 +316,11 @@ DELAY(int n)
while (ticks_left > 0) {
#ifdef KDB
if (kdb_active) {
+#ifdef PC98
+ outb(0x5f, 0);
+#else
inb(0x84);
+#endif
tick = prev_tick - 1;
if (tick <= 0)
tick = i8254_max_count;
@@ -377,7 +404,9 @@ timer_restore(void)
{
i8254_restore(); /* restore i8254_freq and hz */
+#ifndef PC98
atrtc_restore(); /* reenable RTC interrupts */
+#endif
}
#endif
@@ -387,6 +416,10 @@ i8254_init(void)
{
mtx_init(&clock_lock, "clk", NULL, MTX_SPIN | MTX_NOPROFILE);
+#ifdef PC98
+ if (pc98_machine_type & M_8M)
+ i8254_freq = 1996800L; /* 1.9968 MHz */
+#endif
set_i8254_freq(i8254_freq, 0);
}
More information about the freebsd-current
mailing list