Re: svn commit: r266083 - in head/sys/arm: arm include

看板FB_svn作者時間11年前 (2014/06/17 02:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串17/28 (看更多)
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": "=r" (ccnt)); tsc = (uint64_t)ccnt; return (tsc); } #define N 100000 int main(int argc, char *argv[]) { int i; uint64_t ccnt[N]; for (i = 0; i < N; i++) ccnt[i] = get_cyclecount(); for (i = 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 -- Mark R V Murray _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
文章代碼(AID): #1Jdp3VCG (FB_svn)
討論串 (同標題文章)
文章代碼(AID): #1Jdp3VCG (FB_svn)