From owner-svn-src-all@FreeBSD.ORG Tue Jun 17 21:48:05 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B287A18E; Tue, 17 Jun 2014 21:48:05 +0000 (UTC) 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)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 857FF20E4; Tue, 17 Jun 2014 21:48:05 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s5HLm5Pl020699; Tue, 17 Jun 2014 21:48:05 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s5HLm5mZ020696; Tue, 17 Jun 2014 21:48:05 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201406172148.s5HLm5mZ020696@svn.freebsd.org> From: Michael Tuexen Date: Tue, 17 Jun 2014 21:48:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r267597 - in head/sys/arm: arm include 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.18 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, 17 Jun 2014 21:48:05 -0000 Author: tuexen Date: Tue Jun 17 21:48:04 2014 New Revision: 267597 URL: http://svnweb.freebsd.org/changeset/base/267597 Log: Different versions of the ARM processor use different registers. Fix the code used on a Raspberry Pi. Reviewed by: markm@ Modified: head/sys/arm/arm/cpufunc.c head/sys/arm/include/cpu.h Modified: head/sys/arm/arm/cpufunc.c ============================================================================== --- head/sys/arm/arm/cpufunc.c Tue Jun 17 21:09:03 2014 (r267596) +++ head/sys/arm/arm/cpufunc.c Tue Jun 17 21:48:04 2014 (r267597) @@ -1410,12 +1410,27 @@ cpu_scc_setup_ccnt(void) * you want! */ #ifdef _PMC_USER_READ_WRITE_ +#if defined(CPU_ARM1136) || defined(CPU_ARM1176) + /* Use the Secure User and Non-secure Access Validation Control Register + * to allow userland access + */ + __asm volatile ("mcr p15, 0, %0, c15, c9, 0\n\t" + : + : "r"(0x00000001)); +#else /* Set PMUSERENR[0] to allow userland access */ __asm volatile ("mcr p15, 0, %0, c9, c14, 0\n\t" : : "r"(0x00000001)); #endif - /* Set up the PMCCNTR register as a cyclecounter: +#endif +#if defined(CPU_ARM1136) || defined(CPU_ARM1176) + /* Set PMCR[2,0] to enable counters and reset CCNT */ + __asm volatile ("mcr p15, 0, %0, c15, c12, 0\n\t" + : + : "r"(0x00000005)); +#else + /* Set up the PMCCNTR register as a cyclecounter: * Set PMINTENCLR to 0xFFFFFFFF to block interrupts * Set PMCR[2,0] to enable counters and reset CCNT * Set PMCNTENSET to 0x80000000 to enable CCNT */ @@ -1426,6 +1441,7 @@ cpu_scc_setup_ccnt(void) : "r"(0xFFFFFFFF), "r"(0x00000005), "r"(0x80000000)); +#endif } #endif Modified: head/sys/arm/include/cpu.h ============================================================================== --- head/sys/arm/include/cpu.h Tue Jun 17 21:09:03 2014 (r267596) +++ head/sys/arm/include/cpu.h Tue Jun 17 21:48:04 2014 (r267597) @@ -25,7 +25,16 @@ get_cyclecount(void) * Read PMCCNTR. Curses! Its only 32 bits. * TODO: Fix this by catching overflow with interrupt? */ +/* The ARMv6 vs ARMv7 divide is going to need a better way of + * distinguishing between them. + */ +#if defined(CPU_ARM1136) || defined(CPU_ARM1176) + /* ARMv6 - Earlier model SCCs */ + __asm __volatile("mrc p15, 0, %0, c15, c12, 1": "=r" (ccnt)); +#else + /* ARMv7 - Later model SCCs */ __asm __volatile("mrc p15, 0, %0, c9, c13, 0": "=r" (ccnt)); +#endif ccnt64 = (uint64_t)ccnt; return (ccnt64); #else /* No performance counters, so use binuptime(9). This is slooooow */