From owner-svn-src-all@FreeBSD.ORG Tue Jul 13 06:57:27 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C0F0A106566B; Tue, 13 Jul 2010 06:57:27 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AE0038FC13; Tue, 13 Jul 2010 06:57:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o6D6vRf7048548; Tue, 13 Jul 2010 06:57:27 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o6D6vR2e048544; Tue, 13 Jul 2010 06:57:27 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201007130657.o6D6vR2e048544@svn.freebsd.org> From: Alexander Motin Date: Tue, 13 Jul 2010 06:57:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r209979 - in head/sys: conf pc98/cbus pc98/conf x86/isa X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Jul 2010 06:57:27 -0000 Author: mav Date: Tue Jul 13 06:57:27 2010 New Revision: 209979 URL: http://svn.freebsd.org/changeset/base/209979 Log: Unify pc98 event timer code with the rest of x86. Reviewed by: nyan@ Deleted: head/sys/pc98/cbus/clock.c Modified: head/sys/conf/files.pc98 head/sys/pc98/conf/GENERIC.hints head/sys/x86/isa/clock.c Modified: head/sys/conf/files.pc98 ============================================================================== --- head/sys/conf/files.pc98 Tue Jul 13 06:49:34 2010 (r209978) +++ head/sys/conf/files.pc98 Tue Jul 13 06:57:27 2010 (r209979) @@ -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,10 @@ 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 Modified: head/sys/pc98/conf/GENERIC.hints ============================================================================== --- head/sys/pc98/conf/GENERIC.hints Tue Jul 13 06:49:34 2010 (r209978) +++ head/sys/pc98/conf/GENERIC.hints Tue Jul 13 06:57:27 2010 (r209979) @@ -42,6 +42,10 @@ hint.ct.0.at="isa" #hint.ct.0.at="isa" #hint.ct.0.flags="0x50000" +hint.attimer.0.at="isa" +hint.attimer.0.port="0x71" +hint.attimer.0.irq="0" + hint.pcrtc.0.at="isa" hint.pckbd.0.at="isa" Modified: head/sys/x86/isa/clock.c ============================================================================== --- head/sys/x86/isa/clock.c Tue Jul 13 06:49:34 2010 (r209978) +++ head/sys/x86/isa/clock.c Tue Jul 13 06:57:27 2010 (r209979) @@ -66,9 +66,17 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef PC98 +#include +#else #include +#endif #ifdef DEV_ISA +#ifdef PC98 +#include +#else #include +#endif #include #endif @@ -78,8 +86,12 @@ __FBSDID("$FreeBSD$"); 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; @@ -97,6 +109,10 @@ struct attimer_softc { int port_rid, intr_rid; struct resource *port_res; struct resource *intr_res; +#ifdef PC98 + int port_rid2; + struct resource *port_res2; +#endif void *intr_handler; struct timecounter tc; struct eventtimer et; @@ -150,7 +166,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); @@ -163,7 +183,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 +199,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); } @@ -186,8 +214,13 @@ timer_spkr_setfreq(int freq) freq = i8254_freq / freq; mtx_lock_spin(&clock_lock); +#ifdef PC98 + outb(TIMER_CNTR1, freq & 0xff); + outb(TIMER_CNTR1, freq >> 8); +#else outb(TIMER_CNTR2, freq & 0xff); outb(TIMER_CNTR2, freq >> 8); +#endif mtx_unlock_spin(&clock_lock); } @@ -293,7 +326,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 +414,9 @@ timer_restore(void) { i8254_restore(); /* restore i8254_freq and hz */ +#ifndef PC98 atrtc_restore(); /* reenable RTC interrupts */ +#endif } #endif @@ -387,6 +426,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); } @@ -506,6 +549,51 @@ static struct isa_pnp_id attimer_ids[] = { 0 } }; +#ifdef PC98 +static void +pc98_alloc_resource(device_t dev) +{ + static bus_addr_t iat1[] = {0, 2, 4, 6}; + static bus_addr_t iat2[] = {0, 4}; + struct attimer_softc *sc; + + sc = device_get_softc(dev); + + sc->port_rid = 0; + bus_set_resource(dev, SYS_RES_IOPORT, sc->port_rid, IO_TIMER1, 1); + sc->port_res = isa_alloc_resourcev(dev, SYS_RES_IOPORT, + &sc->port_rid, iat1, 4, RF_ACTIVE); + if (sc->port_res == NULL) + device_printf(dev, "Warning: Couldn't map I/O.\n"); + else + isa_load_resourcev(sc->port_res, iat1, 4); + + sc->port_rid2 = 4; + bus_set_resource(dev, SYS_RES_IOPORT, sc->port_rid2, TIMER_CNTR1, 1); + sc->port_res2 = isa_alloc_resourcev(dev, SYS_RES_IOPORT, + &sc->port_rid2, iat2, 2, RF_ACTIVE); + if (sc->port_res2 == NULL) + device_printf(dev, "Warning: Couldn't map I/O.\n"); + else + isa_load_resourcev(sc->port_res2, iat2, 2); +} + +static void +pc98_release_resource(device_t dev) +{ + struct attimer_softc *sc; + + sc = device_get_softc(dev); + + if (sc->port_res) + bus_release_resource(dev, SYS_RES_IOPORT, sc->port_rid, + sc->port_res); + if (sc->port_res2) + bus_release_resource(dev, SYS_RES_IOPORT, sc->port_rid2, + sc->port_res2); +} +#endif + static int attimer_probe(device_t dev) { @@ -515,6 +603,11 @@ attimer_probe(device_t dev) /* ENOENT means no PnP-ID, device is hinted. */ if (result == ENOENT) { device_set_desc(dev, "AT timer"); +#ifdef PC98 + /* To print resources correctly. */ + pc98_alloc_resource(dev); + pc98_release_resource(dev); +#endif return (BUS_PROBE_LOW_PRIORITY); } return (result); @@ -529,9 +622,13 @@ attimer_attach(device_t dev) attimer_sc = sc = device_get_softc(dev); bzero(sc, sizeof(struct attimer_softc)); +#ifdef PC98 + pc98_alloc_resource(dev); +#else if (!(sc->port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->port_rid, IO_TIMER1, IO_TIMER1 + 3, 4, RF_ACTIVE))) device_printf(dev,"Warning: Couldn't map I/O.\n"); +#endif i8254_intsrc = intr_lookup_source(0); if (i8254_intsrc != NULL) i8254_pending = i8254_intsrc->is_pic->pic_source_pending;