Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Jun 2014 18:36:06 +0100
From:      Mark R V Murray <markm@FreeBSD.org>
To:        Michael Tuexen <tuexen@FreeBSD.org>
Cc:        Hans Petter Selasky <hps@selasky.org>, svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r266083 - in head/sys/arm: arm include
Message-ID:  <5F36DFA5-C5B1-4E5D-88EE-9D60240B40FD@FreeBSD.org>
In-Reply-To: <3664DBD3-7CEA-43E8-9757-E835BB21FE9E@freebsd.org>
References:  <201405141911.s4EJBFZZ097826@svn.freebsd.org> <537D0952.2040001@selasky.org> <7610C8E6-3F01-4317-BC1A-67645A162CD7@FreeBSD.org> <53871493.2010502@selasky.org> <EE7E19AA-BE18-4740-A636-4DA3023A5392@FreeBSD.org> <9412A358-EBCB-4A5A-B728-2A15C50FC217@fh-muenster.de> <D118F546-0F32-429F-86F2-69BEE0EC2D2F@FreeBSD.org> <CC36082E-1DFD-4576-9653-970F93A3699C@fh-muenster.de> <FD5DF228-1B2B-48F9-8445-54BF5959FEDA@FreeBSD.org> <9B438991-C970-46A7-8116-A490E02D7139@fh-muenster.de> <3841D090-5973-40B0-B61C-F15E8C1978C9@FreeBSD.org> <3664DBD3-7CEA-43E8-9757-E835BB21FE9E@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

On 16 Jun 2014, at 08:28, Michael Tuexen <tuexen@FreeBSD.org> 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 <sys/types.h>

#include <stdio.h>

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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5F36DFA5-C5B1-4E5D-88EE-9D60240B40FD>