[patch] Clocks on PC98

From: Alexander Motin <mav_at_FreeBSD.org>
Date: Mon, 12 Jul 2010 11:39:04 +0300
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

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
_at__at_ -227,7 +227,6 _at__at_ 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
_at__at_ -253,8 +252,11 _at__at_ 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
_at__at_ -66,9 +66,17 _at__at_ __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
 
_at__at_ -78,8 +86,12 _at__at_ __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;
_at__at_ -150,8 +162,11 _at__at_ 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;
_at__at_ -163,7 +178,11 _at__at_ 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);
 }
_at__at_ -175,7 +194,11 _at__at_ 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);
 }
_at__at_ -293,7 +316,11 _at__at_ 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;
_at__at_ -377,7 +404,9 _at__at_ timer_restore(void)
 {
 
 	i8254_restore();		/* restore i8254_freq and hz */
+#ifndef PC98
 	atrtc_restore();		/* reenable RTC interrupts */
+#endif
 }
 #endif
 
_at__at_ -387,6 +416,10 _at__at_ 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);
 }
 
Received on Mon Jul 12 2010 - 06:40:00 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:05 UTC