(
msg_ctl: u16,
interrupt_source_group: Arc<dyn InterruptSourceGroup>,
state: Option<MsiConfigState>,
)
| 187 | |
| 188 | impl MsiConfig { |
| 189 | pub fn new( |
| 190 | msg_ctl: u16, |
| 191 | interrupt_source_group: Arc<dyn InterruptSourceGroup>, |
| 192 | state: Option<MsiConfigState>, |
| 193 | ) -> Result<Self, Error> { |
| 194 | let cap = if let Some(state) = state { |
| 195 | if state.cap.enabled() { |
| 196 | for idx in 0..state.cap.num_enabled_vectors() { |
| 197 | let config = MsiIrqSourceConfig { |
| 198 | high_addr: state.cap.msg_addr_hi, |
| 199 | low_addr: state.cap.msg_addr_lo, |
| 200 | data: state.cap.msg_data as u32, |
| 201 | devid: 0, |
| 202 | }; |
| 203 | |
| 204 | interrupt_source_group |
| 205 | .update( |
| 206 | idx as InterruptIndex, |
| 207 | InterruptSourceConfig::MsiIrq(config), |
| 208 | state.cap.vector_masked(idx), |
| 209 | false, |
| 210 | ) |
| 211 | .map_err(Error::UpdateInterruptRoute)?; |
| 212 | } |
| 213 | |
| 214 | interrupt_source_group |
| 215 | .set_gsi() |
| 216 | .map_err(Error::EnableInterruptRoute)?; |
| 217 | |
| 218 | interrupt_source_group |
| 219 | .enable() |
| 220 | .map_err(Error::EnableInterruptRoute)?; |
| 221 | } |
| 222 | |
| 223 | state.cap |
| 224 | } else { |
| 225 | MsiCap { |
| 226 | msg_ctl, |
| 227 | ..Default::default() |
| 228 | } |
| 229 | }; |
| 230 | |
| 231 | Ok(MsiConfig { |
| 232 | cap, |
| 233 | interrupt_source_group, |
| 234 | }) |
| 235 | } |
| 236 | |
| 237 | fn state(&self) -> MsiConfigState { |
| 238 | MsiConfigState { cap: self.cap } |
nothing calls this directly
no test coverage detected