From owner-svn-src-all@FreeBSD.ORG Sun Oct 20 16:37:04 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id D6CD2ECA; Sun, 20 Oct 2013 16:37:04 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id C234921D6; Sun, 20 Oct 2013 16:37:04 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9KGb433026663; Sun, 20 Oct 2013 16:37:04 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9KGb4qw026660; Sun, 20 Oct 2013 16:37:04 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201310201637.r9KGb4qw026660@svn.freebsd.org> From: Nathan Whitehorn Date: Sun, 20 Oct 2013 16:37:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r256793 - in head/sys: conf powerpc/aim powerpc/booke powerpc/powerpc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 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: Sun, 20 Oct 2013 16:37:04 -0000 Author: nwhitehorn Date: Sun Oct 20 16:37:03 2013 New Revision: 256793 URL: http://svnweb.freebsd.org/changeset/base/256793 Log: Replace the two almost-exactly-identical AIM and Book-E clock.c implementations with a single one after the application of a very small amount of #ifdef. Added: head/sys/powerpc/powerpc/clock.c - copied, changed from r256769, head/sys/powerpc/aim/clock.c Deleted: head/sys/powerpc/aim/clock.c head/sys/powerpc/booke/clock.c Modified: head/sys/conf/files.powerpc head/sys/powerpc/aim/machdep.c Modified: head/sys/conf/files.powerpc ============================================================================== --- head/sys/conf/files.powerpc Sun Oct 20 16:14:03 2013 (r256792) +++ head/sys/conf/files.powerpc Sun Oct 20 16:37:03 2013 (r256793) @@ -85,7 +85,6 @@ libkern/qdivrem.c optional powerpc libkern/ucmpdi2.c optional powerpc libkern/udivdi3.c optional powerpc libkern/umoddi3.c optional powerpc -powerpc/aim/clock.c optional aim powerpc/aim/copyinout.c optional aim powerpc/aim/interrupt.c optional aim powerpc/aim/locore.S optional aim no-obj @@ -101,7 +100,6 @@ powerpc/aim/swtch32.S optional aim powe powerpc/aim/swtch64.S optional aim powerpc64 powerpc/aim/trap.c optional aim powerpc/aim/uma_machdep.c optional aim -powerpc/booke/clock.c optional booke powerpc/booke/copyinout.c optional booke powerpc/booke/interrupt.c optional booke powerpc/booke/locore.S optional booke no-obj @@ -178,6 +176,7 @@ powerpc/powerpc/autoconf.c standard powerpc/powerpc/bcopy.c standard powerpc/powerpc/bus_machdep.c standard powerpc/powerpc/busdma_machdep.c standard +powerpc/powerpc/clock.c standard powerpc/powerpc/copystr.c standard powerpc/powerpc/cpu.c standard powerpc/powerpc/db_disasm.c optional ddb Modified: head/sys/powerpc/aim/machdep.c ============================================================================== --- head/sys/powerpc/aim/machdep.c Sun Oct 20 16:14:03 2013 (r256792) +++ head/sys/powerpc/aim/machdep.c Sun Oct 20 16:37:03 2013 (r256793) @@ -646,14 +646,6 @@ cpu_flush_dcache(void *ptr, size_t len) /* TBD */ } -void -cpu_initclocks(void) -{ - - decr_tc_init(); - cpu_initclocks_bsp(); -} - /* * Shutdown the CPU as much as possible. */ Copied and modified: head/sys/powerpc/powerpc/clock.c (from r256769, head/sys/powerpc/aim/clock.c) ============================================================================== --- head/sys/powerpc/aim/clock.c Sat Oct 19 10:00:51 2013 (r256769, copy source) +++ head/sys/powerpc/powerpc/clock.c Sun Oct 20 16:37:03 2013 (r256793) @@ -119,6 +119,14 @@ decr_intr(struct trapframe *frame) (*decr_counts[curcpu])++; +#ifdef BOOKE + /* + * Interrupt handler must reset DIS to avoid getting another + * interrupt once EE is enabled. + */ + mtspr(SPR_TSR, TSR_DIS); +#endif + if (s->mode == 1) { /* * Based on the actual time delay since the last decrementer @@ -141,6 +149,14 @@ decr_intr(struct trapframe *frame) } } +void +cpu_initclocks(void) +{ + + decr_tc_init(); + cpu_initclocks_bsp(); +} + /* * BSP early initialization. */ @@ -207,11 +223,13 @@ decr_tc_init(void) * Event timer start method. */ static int -decr_et_start(struct eventtimer *et, - sbintime_t first, sbintime_t period) +decr_et_start(struct eventtimer *et, sbintime_t first, sbintime_t period) { struct decr_state *s = DPCPU_PTR(decr_state); uint32_t fdiv; +#ifdef BOOKE + uint32_t tcr; +#endif if (period != 0) { s->mode = 1; @@ -220,12 +238,25 @@ decr_et_start(struct eventtimer *et, s->mode = 2; s->div = 0; } - if (first != 0) { + if (first != 0) fdiv = (decr_et.et_frequency * first) >> 32; - } else + else fdiv = s->div; +#ifdef BOOKE + tcr = mfspr(SPR_TCR); + tcr |= TCR_DIE; + if (s->mode == 1) { + mtspr(SPR_DECAR, s->div); + tcr |= TCR_ARE; + } else + tcr &= ~TCR_ARE; mtdec(fdiv); + mtspr(SPR_TCR, tcr); +#else + mtdec(fdiv); +#endif + return (0); } @@ -236,10 +267,19 @@ static int decr_et_stop(struct eventtimer *et) { struct decr_state *s = DPCPU_PTR(decr_state); +#ifdef BOOKE + uint32_t tcr; +#endif s->mode = 0; s->div = 0x7fffffff; +#ifdef BOOKE + tcr = mfspr(SPR_TCR); + tcr &= ~(TCR_DIE | TCR_ARE); + mtspr(SPR_TCR, tcr); +#else mtdec(s->div); +#endif return (0); } @@ -249,10 +289,7 @@ decr_et_stop(struct eventtimer *et) static unsigned decr_get_timecount(struct timecounter *tc) { - register_t tb; - - __asm __volatile("mftb %0" : "=r"(tb)); - return (tb); + return (mftb()); } /*