@@ -131,6 +131,8 @@ enum sbi_ext_pmu_fid {
131131 SBI_EXT_PMU_COUNTER_START ,
132132 SBI_EXT_PMU_COUNTER_STOP ,
133133 SBI_EXT_PMU_COUNTER_FW_READ ,
134+ SBI_EXT_PMU_COUNTER_FW_READ_HI ,
135+ SBI_EXT_PMU_SNAPSHOT_SET_SHMEM ,
134136};
135137
136138union sbi_pmu_ctr_info {
@@ -147,6 +149,13 @@ union sbi_pmu_ctr_info {
147149 };
148150};
149151
152+ /* Data structure to contain the pmu snapshot data */
153+ struct riscv_pmu_snapshot_data {
154+ u64 ctr_overflow_mask ;
155+ u64 ctr_values [64 ];
156+ u64 reserved [447 ];
157+ };
158+
150159#define RISCV_PMU_RAW_EVENT_MASK GENMASK_ULL(47, 0)
151160#define RISCV_PMU_RAW_EVENT_IDX 0x20000
152161
@@ -232,20 +241,22 @@ enum sbi_pmu_ctr_type {
232241#define SBI_PMU_EVENT_IDX_INVALID 0xFFFFFFFF
233242
234243/* Flags defined for config matching function */
235- #define SBI_PMU_CFG_FLAG_SKIP_MATCH (1 << 0)
236- #define SBI_PMU_CFG_FLAG_CLEAR_VALUE (1 << 1)
237- #define SBI_PMU_CFG_FLAG_AUTO_START (1 << 2)
238- #define SBI_PMU_CFG_FLAG_SET_VUINH (1 << 3)
239- #define SBI_PMU_CFG_FLAG_SET_VSINH (1 << 4)
240- #define SBI_PMU_CFG_FLAG_SET_UINH (1 << 5)
241- #define SBI_PMU_CFG_FLAG_SET_SINH (1 << 6)
242- #define SBI_PMU_CFG_FLAG_SET_MINH (1 << 7)
244+ #define SBI_PMU_CFG_FLAG_SKIP_MATCH BIT( 0)
245+ #define SBI_PMU_CFG_FLAG_CLEAR_VALUE BIT( 1)
246+ #define SBI_PMU_CFG_FLAG_AUTO_START BIT( 2)
247+ #define SBI_PMU_CFG_FLAG_SET_VUINH BIT( 3)
248+ #define SBI_PMU_CFG_FLAG_SET_VSINH BIT( 4)
249+ #define SBI_PMU_CFG_FLAG_SET_UINH BIT( 5)
250+ #define SBI_PMU_CFG_FLAG_SET_SINH BIT( 6)
251+ #define SBI_PMU_CFG_FLAG_SET_MINH BIT( 7)
243252
244253/* Flags defined for counter start function */
245- #define SBI_PMU_START_FLAG_SET_INIT_VALUE (1 << 0)
254+ #define SBI_PMU_START_FLAG_SET_INIT_VALUE BIT(0)
255+ #define SBI_PMU_START_FLAG_INIT_SNAPSHOT BIT(1)
246256
247257/* Flags defined for counter stop function */
248- #define SBI_PMU_STOP_FLAG_RESET (1 << 0)
258+ #define SBI_PMU_STOP_FLAG_RESET BIT(0)
259+ #define SBI_PMU_STOP_FLAG_TAKE_SNAPSHOT BIT(1)
249260
250261enum sbi_ext_dbcn_fid {
251262 SBI_EXT_DBCN_CONSOLE_WRITE = 0 ,
@@ -266,7 +277,7 @@ struct sbi_sta_struct {
266277 u8 pad [47 ];
267278} __packed ;
268279
269- #define SBI_STA_SHMEM_DISABLE -1
280+ #define SBI_SHMEM_DISABLE -1
270281
271282/* SBI spec version fields */
272283#define SBI_SPEC_VERSION_DEFAULT 0x1
@@ -284,6 +295,7 @@ struct sbi_sta_struct {
284295#define SBI_ERR_ALREADY_AVAILABLE -6
285296#define SBI_ERR_ALREADY_STARTED -7
286297#define SBI_ERR_ALREADY_STOPPED -8
298+ #define SBI_ERR_NO_SHMEM -9
287299
288300extern unsigned long sbi_spec_version ;
289301struct sbiret {
@@ -355,8 +367,8 @@ static inline unsigned long sbi_minor_version(void)
355367static inline unsigned long sbi_mk_version (unsigned long major ,
356368 unsigned long minor )
357369{
358- return ((major & SBI_SPEC_VERSION_MAJOR_MASK ) <<
359- SBI_SPEC_VERSION_MAJOR_SHIFT ) | minor ;
370+ return ((major & SBI_SPEC_VERSION_MAJOR_MASK ) << SBI_SPEC_VERSION_MAJOR_SHIFT )
371+ | ( minor & SBI_SPEC_VERSION_MINOR_MASK ) ;
360372}
361373
362374int sbi_err_map_linux_errno (int err );
0 commit comments