2009ǯ08��14��
ARM11�Υѥե����ޥ󥹥�˥������Ѥ�����ñ�ʼ¹Ի��֤η�¬��ˡ
ARM11��CP15�˥ѥե����ޥ󥹥�˥������ꡢ���Υ������륫���󥿤����Ѥ��ƴ�ñ�˥ץ�������2���֤λ��֤��¬���뤳�Ȥ��Ǥ��ޤ���
��¬�Ѥδؿ����ڤ˻Ȥ���褦�˥����������ɤ��ĤΥإå��ե�����ˤޤȤ�Ƥߤޤ�����
����ؿ���ʣ������ˡ�Ǽ������ơ��ɤ��餬®��������Ӥ�����������Ǥ���
������������
�����󥿤��ɤ߽Ф��λ��Υ����С��إåɤ򾯤ʤ����뤿�ᥤ��饤��ؿ��ˤ��Ƥ��ޤ���
gcc�γ�ĥ��ˡ����Ѥ��Ƥ��ޤ���
#ifndef __KMC_PMON_ARM11_H #define __KMC_PMON_ARM11_H /* Performance Monitor Control Register of ARM1136*/ #define CMCR_ECC 6 #define CMCR_D 3 #define CMCR_C 2 #define CMCR_E 0 volatile __inline__ static unsigned long __attribute__((always_inline)) pmon_start_cycle_counter() { unsigned long x; asm volatile("mrc p15, 0, %0, c15, c12, 0" : "=r" (x)); x |= ((1 << CMCR_D) | (1 << CMCR_C) | (1 << CMCR_E)); x &= ~(1 << CMCR_ECC); asm volatile("mcr p15, 0, %0, c15, c12, 0" :: "r" (x)); asm volatile("mrc p15, 0, %0, c15, c12, 1" : "=r" (x)); return x; } volatile __inline__ static unsigned long __attribute__((always_inline)) pmon_read_cycle_counter() { unsigned long x; asm volatile ("mrc p15, 0, %0, c15, c12, 1": "=r" (x)); return x; } #endif /* __KMC_PMON_ARM11_H */
������ˡ
pmon_arm1136.h �򥤥󥯥롼�ɤ���(#include "pmon_arm11.h")
�ǽ��pmon_start_cycle_counter()��Ƥ�ǥ�����Ȥ򥹥����Ȥ����ޤ���
���θ��Ǥ�դΤȤ�����pmon_read_cycle_counter()�ǥ������륫���󥿤��ɤ߽Ф������κ�ʬ�ǻ��֤�פ�ޤ���
�饤�֥��ʤɤ��ɲä���ɬ�פ��ʤ��Τǡ�Makefile�����ѹ������פǤ���
��¬��������ʬ�Υ������ե�����������ѹ��ǻȤ��ޤ���
������
#include <stdio.h> #include "pmon_arm11.h" int func(int x) { int sum = 0; int i; for (i = 1; i <= x; i++) { sum += i; } return sum; } int main() { unsigned long start, end; int x; start = pmon_start_cycle_counter(); x = func(1000); end = pmon_read_cycle_counter(); printf("time = %ld, x = %d\n", end - start, x); return x; }
���ջ���
- ARM1136�Ǥ��ø��⡼�ɤǤ������ѤǤ��ޤ��󡣤���ϥ������륫���󥿤Υ쥸�������ø��⡼�ɤǤʤ��ȸƤӽñ¤¤Ç¤ï¿½ï¿½Ê¤ï¿½ï¿½ï¿½ï¿½ï¿½Ç¤ï¿½ï¿½ï¿½ARM1176�Ǥ�Secure User and Non-secure Access Validation Control Register ������ǥ桼�����⡼�ɤǤ���ѤǤ���褦�ˤʤ�ޤ���
- CortexA8,A9�Ǥ�Performance Monitor Control Register�ΰ��֤��㤦�Τ�mrc, mcr̿��ν�����ɬ�ס�
- 64ʬ������⡼�ɤǥ����󥿤���Ѥ��Ƥ��ޤ���������Ǥ���8ʬȾ�ۤɤ�32bit�Υ����󥿤ϰ�����Ƥ��ޤ��ޤ���(KZM-ARM11�ܡ����ξ��)