1
+ /// This module implement prop value described in
2
+ /// https://www.kernel.org/doc/Documentation/devicetree/bindings/perf/riscv%2Cpmu.yaml
1
3
use crate :: buildin:: * ;
2
4
3
5
use serde:: { Deserialize , Serialize } ;
@@ -20,63 +22,76 @@ pub struct EventToMhpmcounters<'a>(Matrix<'a, 3>);
20
22
pub struct RawEventToMhpcounters < ' a > ( Matrix < ' a , 5 > ) ;
21
23
22
24
impl EventToMhpmevent < ' _ > {
25
+ #[ inline( always) ]
23
26
pub fn len ( & self ) -> usize {
24
27
self . 0 . len ( )
25
28
}
26
29
30
+ #[ inline( always) ]
27
31
pub fn is_empty ( & self ) -> bool {
28
32
self . 0 . is_empty ( )
29
33
}
30
34
35
+ #[ inline( always) ]
31
36
pub fn get_event_id ( & self , i : usize ) -> u32 {
32
37
u32:: from_be ( self . 0 . get ( i) [ 0 ] )
33
38
}
34
39
40
+ #[ inline( always) ]
35
41
pub fn get_selector_value ( & self , i : usize ) -> u64 {
36
42
let current = self . 0 . get ( i) ;
37
43
( ( u32:: from_be ( current[ 1 ] ) as u64 ) << 32 ) | ( u32:: from_be ( current[ 2 ] ) as u64 )
38
44
}
39
45
}
40
46
41
47
impl EventToMhpmcounters < ' _ > {
48
+ #[ inline( always) ]
42
49
pub fn len ( & self ) -> usize {
43
50
self . 0 . len ( )
44
51
}
45
52
53
+ #[ inline( always) ]
46
54
pub fn is_empty ( & self ) -> bool {
47
55
self . 0 . is_empty ( )
48
56
}
49
57
58
+ #[ inline( always) ]
50
59
pub fn get_event_idx_range ( & self , i : usize ) -> RangeInclusive < u32 > {
51
60
let current = self . 0 . get ( i) ;
52
61
u32:: from_be ( current[ 0 ] ) ..=u32:: from_be ( current[ 1 ] )
53
62
}
54
63
64
+ #[ inline( always) ]
55
65
pub fn get_counter_bitmap ( & self , i : usize ) -> u32 {
56
66
let current = self . 0 . get ( i) ;
57
67
u32:: from_be ( current[ 2 ] )
58
68
}
59
69
}
60
70
61
71
impl RawEventToMhpcounters < ' _ > {
72
+ #[ inline( always) ]
62
73
pub fn len ( & self ) -> usize {
63
74
self . 0 . len ( )
64
75
}
65
76
77
+ #[ inline( always) ]
66
78
pub fn is_empty ( & self ) -> bool {
67
79
self . 0 . is_empty ( )
68
80
}
69
81
82
+ #[ inline( always) ]
70
83
pub fn get_event_idx_base ( & self , i : usize ) -> u64 {
71
84
let current = self . 0 . get ( i) ;
72
85
( ( u32:: from_be ( current[ 0 ] ) as u64 ) << 32 ) | ( u32:: from_be ( current[ 1 ] ) as u64 )
73
86
}
74
87
88
+ #[ inline( always) ]
75
89
pub fn get_event_idx_mask ( & self , i : usize ) -> u64 {
76
90
let current = self . 0 . get ( i) ;
77
91
( ( u32:: from_be ( current[ 2 ] ) as u64 ) << 32 ) | ( u32:: from_be ( current[ 3 ] ) as u64 )
78
92
}
79
93
94
+ #[ inline( always) ]
80
95
pub fn get_counter_bitmap ( & self , i : usize ) -> u32 {
81
96
let current = self . 0 . get ( i) ;
82
97
u32:: from_be ( current[ 4 ] )
0 commit comments