@@ -86,33 +86,8 @@ pub mod pmpcfg0 {
86
86
read_csr_as ! ( Pmpcsr , 0x3A0 , __read_pmpcfg0) ;
87
87
write_csr_as_usize ! ( 0x3A0 , __write_pmpcfg0) ;
88
88
89
- /// sets a configuration for the defined index in pmpcfg0
90
- pub unsafe fn set_pmp ( index : usize , range : Range , permission : Permission , locked : bool ) {
91
- #[ cfg( riscv32) ]
92
- assert ! ( index < 4 ) ;
93
-
94
- #[ cfg( riscv64) ]
95
- assert ! ( index < 8 ) ;
96
-
97
- let mut value = _read ( ) ;
98
- let byte = ( locked as usize ) << 7 | ( range as usize ) << 3 | ( permission as usize ) ;
99
- value. set_bits ( 8 * index..=8 * index + 7 , byte) ;
100
- _write ( value)
101
- }
102
-
103
- /// clears the configuration for the defined index in pmpcfg0
104
- /// cannot clear when pmp is locked
105
- pub unsafe fn clear_pmp ( index : usize ) {
106
- #[ cfg( riscv32) ]
107
- assert ! ( index < 4 ) ;
108
-
109
- #[ cfg( riscv64) ]
110
- assert ! ( index < 8 ) ;
111
-
112
- let mut value = _read ( ) ;
113
- value. set_bits ( 8 * index..=8 * index + 7 , 0 ) ;
114
- _write ( value) ;
115
- }
89
+ set_pmp ! ( Range , Permission ) ;
90
+ clear_pmp ! ( ) ;
116
91
}
117
92
118
93
/// Physical memory protection configuration
@@ -125,25 +100,8 @@ pub mod pmpcfg1 {
125
100
read_csr_as ! ( Pmpcsr , 0x3A1 , __read_pmpcfg1) ;
126
101
write_csr_as_usize_rv32 ! ( 0x3A1 , __write_pmpcfg1) ;
127
102
128
- /// sets a configuration for the defined index in pmpcfg1
129
- pub unsafe fn set_pmp ( index : usize , range : Range , permission : Permission , locked : bool ) {
130
- assert ! ( index < 4 ) ;
131
-
132
- let mut value = _read ( ) ;
133
- let byte = ( locked as usize ) << 7 | ( range as usize ) << 3 | ( permission as usize ) ;
134
- value. set_bits ( 8 * index..=8 * index + 7 , byte) ;
135
- _write ( value)
136
- }
137
-
138
- /// clears the configuration for the defined index in pmpcfg1
139
- /// cannot clear when pmp is locked
140
- pub unsafe fn clear_pmp ( index : usize ) {
141
- assert ! ( index < 4 ) ;
142
-
143
- let mut value = _read ( ) ;
144
- value. set_bits ( 8 * index..=8 * index + 7 , 0 ) ;
145
- _write ( value) ;
146
- }
103
+ set_pmp ! ( Range , Permission ) ;
104
+ clear_pmp ! ( ) ;
147
105
}
148
106
149
107
/// Physical memory protection configuration
@@ -155,33 +113,8 @@ pub mod pmpcfg2 {
155
113
read_csr_as ! ( Pmpcsr , 0x3A2 , __read_pmpcfg2) ;
156
114
write_csr_as_usize ! ( 0x3A2 , __write_pmpcfg2) ;
157
115
158
- /// sets a configuration for the defined index in pmpcfg2
159
- pub unsafe fn set_pmp ( index : usize , range : Range , permission : Permission , locked : bool ) {
160
- #[ cfg( riscv32) ]
161
- assert ! ( index < 4 ) ;
162
-
163
- #[ cfg( riscv64) ]
164
- assert ! ( index < 8 ) ;
165
-
166
- let mut value = _read ( ) ;
167
- let byte = ( locked as usize ) << 7 | ( range as usize ) << 3 | ( permission as usize ) ;
168
- value. set_bits ( 8 * index..=8 * index + 7 , byte) ;
169
- _write ( value)
170
- }
171
-
172
- /// clears the configuration for the defined index in pmpcfg2
173
- /// cannot clear when pmp is locked
174
- pub unsafe fn clear_pmp ( index : usize ) {
175
- #[ cfg( riscv32) ]
176
- assert ! ( index < 4 ) ;
177
-
178
- #[ cfg( riscv64) ]
179
- assert ! ( index < 8 ) ;
180
-
181
- let mut value = _read ( ) ;
182
- value. set_bits ( 8 * index..=8 * index + 7 , 0 ) ;
183
- _write ( value) ;
184
- }
116
+ set_pmp ! ( Range , Permission ) ;
117
+ clear_pmp ! ( ) ;
185
118
}
186
119
187
120
/// Physical memory protection configuration
@@ -194,26 +127,6 @@ pub mod pmpcfg3 {
194
127
read_csr_as ! ( Pmpcsr , 0x3A3 , __read_pmpcfg3) ;
195
128
write_csr_as_usize_rv32 ! ( 0x3A3 , __write_pmpcfg3) ;
196
129
197
- /// sets a configuration for the defined index in pmpcfg3
198
- pub unsafe fn set_pmp ( index : usize , range : Range , permission : Permission , locked : bool ) {
199
- assert ! ( index < 4 ) ;
200
-
201
- let mut value = _read ( ) ;
202
- let byte = ( locked as usize ) << 7 | ( range as usize ) << 3 | ( permission as usize ) ;
203
- value. set_bits ( 8 * index..=8 * index + 7 , byte) ;
204
- _write ( value)
205
- }
206
- /// clears the configuration for the defined index in pmpcfg3
207
- /// cannot clear when pmp is locked
208
- pub unsafe fn clear_pmp ( index : usize ) {
209
- #[ cfg( riscv32) ]
210
- assert ! ( index < 4 ) ;
211
-
212
- #[ cfg( riscv64) ]
213
- assert ! ( index < 8 ) ;
214
-
215
- let mut value = _read ( ) ;
216
- value. set_bits ( 8 * index..=8 * index + 7 , 0 ) ;
217
- _write ( value) ;
218
- }
130
+ set_pmp ! ( Range , Permission ) ;
131
+ clear_pmp ! ( ) ;
219
132
}
0 commit comments