]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/blob - pasdk/test_arm/application/board_utils.c
PASDK-516:First version of ASOT refactoring
[processor-sdk/performance-audio-sr.git] / pasdk / test_arm / application / board_utils.c
1 #include <xdc/std.h>
2 #define uint32_t UInt32
4 /** ============================================================================
5  *   @n@b BOARD_initPerfCounters
6  *
7  *   @b Description
8  *   @n  This function enables the A15 performance counters.
9  *
10  *
11  *   @b Arguments
13  *   <b> Return Value </b>
14  *   @n None
15  *
16  *   <b> Pre Condition </b>
17  *   @n  None
18  *
19  *   <b> Post Condition </b>
20  *   @n   None
21  *
22  *   @b Affects
23  *   @n None.
24  *
25  *   @b Example
26  *   @verbatim
27         BOARD_initPerfCounters();
28     @endverbatim
29  * ===========================================================================
30  */
31 void BOARD_initPerfCounters()
32 {
33 #if defined (_TMS320C6X) || defined(__TI_ARM_V7M4__)
34     // Do nothing for C6x and M4 cores
35 #else
36     /* PMCR
37     31......24 23......16 15....11 10.....6  5 4 3 2 1 0
38         IMP      IDCODE       N       Res   DP X D C P E
39     [31:24] IMP: Implementer code; read-only
40     [23:16] IDCODE: Identification code; read-only
41     [15:11] N: Number of event counters; read-only
42     [10:6] Reserved
43     [5] DP: Disable cycle counter in prohibited regions; r/w
44     [4] X: Export enable; r/w
45     [3] D: Clock divider - PMCCNTR counts every 64 clock cycles when enabled; r/w
46     [2] C: Clock counter reset; write-only
47     [1] P: Event counter reset; write-only
48     [0] E: Enable all counters; r/w
49     */
50     __asm__ __volatile__ ("MCR p15, 0, %0, c9, c12, 0\t\n" :: "r"(0x17));
52     /* PMCNTENSET - Count Enable Set Register */
53     __asm__ __volatile__ ("MCR p15, 0, %0, c9, c12, 1\t\n" :: "r"(0x8000000f));
55     /* PMOVSR - Overflow Flag Status Register */
56     __asm__ __volatile__ ("MCR p15, 0, %0, c9, c12, 3\t\n" :: "r"(0x8000000f));
57 #endif
58 }
60 uint32_t readTime32(void)
61 {
62     uint32_t timeVal;
64 #if defined (_TMS320C6X)
65     timeVal = TSCL;
66 #else
67     __asm__ __volatile__ ("MRC p15, 0, %0, c9, c13, 0\t\n": "=r"(timeVal));
68 #endif
69     return timeVal;
70 }