Date: Sun, 20 Oct 2013 16:37:04 +0000 (UTC) From: Nathan Whitehorn <nwhitehorn@FreeBSD.org> 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 Message-ID: <201310201637.r9KGb4qw026660@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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()); } /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201310201637.r9KGb4qw026660>