From owner-svn-src-all@FreeBSD.ORG Mon Jun 16 17:35:06 2014 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 ESMTPS id B988163D; Mon, 16 Jun 2014 17:35:06 +0000 (UTC) Received: from gromit.grondar.org (grandfather.grondar.org [IPv6:2a01:348:0:15:5d59:5c20:0:2]) (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 796FF29BC; Mon, 16 Jun 2014 17:35:06 +0000 (UTC) Received: from graveyard.grondar.org ([88.96.155.33] helo=gronkulator.grondar.org) by gromit.grondar.org with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.80.1 (FreeBSD)) (envelope-from ) id 1Wwao3-000JAv-7S; Mon, 16 Jun 2014 18:35:03 +0100 Subject: Re: svn commit: r266083 - in head/sys/arm: arm include Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.2\)) Content-Type: text/plain; charset=windows-1252 From: Mark R V Murray In-Reply-To: <3664DBD3-7CEA-43E8-9757-E835BB21FE9E@freebsd.org> Date: Mon, 16 Jun 2014 18:36:06 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <5F36DFA5-C5B1-4E5D-88EE-9D60240B40FD@FreeBSD.org> References: <201405141911.s4EJBFZZ097826@svn.freebsd.org> <537D0952.2040001@selasky.org> <7610C8E6-3F01-4317-BC1A-67645A162CD7@FreeBSD.org> <53871493.2010502@selasky.org> <9412A358-EBCB-4A5A-B728-2A15C50FC217@fh-muenster.de> <9B438991-C970-46A7-8116-A490E02D7139@fh-muenster.de> <3841D090-5973-40B0-B61C-F15E8C1978C9@FreeBSD.org> <3664DBD3-7CEA-43E8-9757-E835BB21FE9E@freebsd.org> To: Michael Tuexen X-Mailer: Apple Mail (2.1878.2) X-SA-Score: -1.0 Cc: Hans Petter Selasky , svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org 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: Mon, 16 Jun 2014 17:35:06 -0000 On 16 Jun 2014, at 08:28, Michael Tuexen wrote: > your patch for accessing the value is correct. However, the = initialisation code also > needs to be adopted to the platform. So in addition to your patch, you = also need: Thanks! > Is there an easy test to see if the code actually works as expected = and not that it just > allows the system to boot? Yes. :-) #include #include static __inline uint64_t get_cyclecount(void) { uint32_t ccnt; uint64_t tsc; /* Read CCNT. */ __asm __volatile("mrc p15, 0, %0, c15, c12, 1": "=3Dr" (ccnt)); tsc =3D (uint64_t)ccnt; return (tsc); } #define N 100000 int main(int argc, char *argv[]) { int i; uint64_t ccnt[N]; for (i =3D 0; i < N; i++) ccnt[i] =3D get_cyclecount(); for (i =3D 1; i < N; i++) printf("%6d %016llX %16llu\n", i, ccnt[i], ccnt[i] - = ccnt[i - 1]); return (0); } Should print a whole lotta numbers, incrementing, unless you hit the = wraparound. > Regarding the 32-bit limitation: Do we want to increment the register = only every > 64 clock cycle? Definitely not! The value is in the low bits; wrap is of little = consequence. M --=20 Mark R V Murray