更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
perf_pmu_pri.h
浏览该文件的文档.
1/*
2 * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
3 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice, this list of
9 * conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 * of conditions and the following disclaimer in the documentation and/or other materials
13 * provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its contributors may be used
16 * to endorse or promote products derived from this software without specific prior written
17 * permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _PERF_PMU_PRI_H
33#define _PERF_PMU_PRI_H
34
35#include "los_perf_pri.h"
36
37#ifdef LOSCFG_HRTIMER_ENABLE
38#include "linux/hrtimer.h"
39#endif
40
41#ifdef __cplusplus
42#if __cplusplus
43extern "C" {
44#endif /* __cplusplus */
45#endif /* __cplusplus */
46
47typedef struct {
51 VOID (*enable)(Event *event);
52 VOID (*disable)(Event *event);
53 VOID (*start)(VOID);
54 VOID (*stop)(VOID);
55 VOID (*clear)(VOID);
56 VOID (*setPeriod)(Event *event);
57 UINTPTR (*readCnt)(Event *event);
58 UINT32 (*mapEvent)(UINT32 eventType, BOOL reverse);
59} HwPmu;
60
61typedef struct {
63 union {
64 struct { /* trace event */
66 };
67#ifdef LOSCFG_HRTIMER_ENABLE
68 struct { /* timer event */
69 struct hrtimer hrtimer;
70 union ktime time;
71 union ktime cfgTime;
72 };
73#endif
74 };
75} SwPmu;
76
77#define GET_HW_PMU(item) LOS_DL_LIST_ENTRY(item, HwPmu, pmu)
78
79#define TIMER_PERIOD_LOWER_BOUND_US 100
80
81#define CCNT_FULL 0xFFFFFFFF
82#define CCNT_PERIOD_LOWER_BOUND 0x00000000
83#define CCNT_PERIOD_UPPER_BOUND 0xFFFFFF00
84#define PERIOD_CALC(p) (CCNT_FULL - (p))
85#define VALID_PERIOD(p) ((PERIOD_CALC(p) > CCNT_PERIOD_LOWER_BOUND) \
86 && (PERIOD_CALC(p) < CCNT_PERIOD_UPPER_BOUND))
87
88#define PERF_HW_INVALID_EVENT_TYPE 0xFFFFFFFF
89
90#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
91
92#define PMU_LABEL_INT_1 \
93 NUM_HAL_INTERRUPT_PMU_0,
94#define PMU_LABEL_INT_2 \
95 PMU_LABEL_INT_1 \
96 NUM_HAL_INTERRUPT_PMU_1,
97#define PMU_LABEL_INT_3 \
98 PMU_LABEL_INT_2 \
99 NUM_HAL_INTERRUPT_PMU_2,
100#define PMU_LABEL_INT_4 \
101 PMU_LABEL_INT_3 \
102 NUM_HAL_INTERRUPT_PMU_3,
103
104#define PMU_INT(_num) PMU_LABEL_INT_##_num
105
106#define OS_PMU_INTS(_num, _list) \
107 STATIC UINT32 _list [_num] = { \
108 PMU_INT(_num) \
109 }
110
111extern UINT32 OsPerfPmuRegister(Pmu *pmu);
112extern VOID OsPerfPmuRm(UINT32 type);
113extern Pmu *OsPerfPmuGet(UINT32 type);
114
115extern UINT32 OsHwPmuInit(VOID);
116extern UINT32 OsSwPmuInit(VOID);
117extern UINT32 OsTimedPmuInit(VOID);
118
119extern UINT32 OsGetPmuCounter0(VOID);
120extern UINT32 OsGetPmuMaxCounter(VOID);
121extern UINT32 OsGetPmuCycleCounter(VOID);
122extern UINT32 OsPerfHwInit(HwPmu *hwPmu);
123
124#ifdef __cplusplus
125#if __cplusplus
126}
127#endif /* __cplusplus */
128#endif /* __cplusplus */
129
130#endif /* _PERF_PMU_PRI_H */
unsigned long UINTPTR
Definition: los_typedef.h:68
unsigned int UINT32
Definition: los_typedef.h:57
size_t BOOL
Definition: los_typedef.h:88
Pmu * OsPerfPmuGet(UINT32 type)
Definition: perf_pmu.c:52
UINT32 OsPerfPmuRegister(Pmu *pmu)
Definition: perf_pmu.c:36
UINT32 OsGetPmuMaxCounter(VOID)
Definition: armv7_pmu.c:329
UINT32 OsPerfHwInit(HwPmu *hwPmu)
Definition: perf_hw_pmu.c:169
UINT32 OsGetPmuCounter0(VOID)
Definition: armv7_pmu.c:339
UINT32 OsGetPmuCycleCounter(VOID)
Definition: armv7_pmu.c:334
UINT32 OsSwPmuInit(VOID)
Definition: perf_sw_pmu.c:153
UINT32 OsTimedPmuInit(VOID)
VOID OsPerfPmuRm(UINT32 type)
Definition: perf_pmu.c:64
UINT32 OsHwPmuInit(VOID)
Definition: armv7_pmu.c:356
BOOL canDivided
Definition: perf_pmu_pri.h:49
UINT32 cntDivided
Definition: perf_pmu_pri.h:50
Pmu pmu
Definition: perf_pmu_pri.h:48
Pmu pmu
Definition: perf_pmu_pri.h:62
BOOL enable
Definition: perf_pmu_pri.h:65
time_t time(time_t *t)
Definition: time.c:1224