(&mut self, _base: u64, offset: u64, data: &mut [u8])
| 543 | |
| 544 | impl BusDevice for MemoryManager { |
| 545 | fn read(&mut self, _base: u64, offset: u64, data: &mut [u8]) { |
| 546 | if self.selected_slot < self.hotplug_slots.len() { |
| 547 | let state = &self.hotplug_slots[self.selected_slot]; |
| 548 | match offset { |
| 549 | BASE_OFFSET_LOW => { |
| 550 | data.copy_from_slice(&state.base.to_le_bytes()[..4]); |
| 551 | } |
| 552 | BASE_OFFSET_HIGH => { |
| 553 | data.copy_from_slice(&state.base.to_le_bytes()[4..]); |
| 554 | } |
| 555 | LENGTH_OFFSET_LOW => { |
| 556 | data.copy_from_slice(&state.length.to_le_bytes()[..4]); |
| 557 | } |
| 558 | LENGTH_OFFSET_HIGH => { |
| 559 | data.copy_from_slice(&state.length.to_le_bytes()[4..]); |
| 560 | } |
| 561 | STATUS_OFFSET => { |
| 562 | // The Linux kernel, quite reasonably, doesn't zero the memory it gives us. |
| 563 | data.fill(0); |
| 564 | if state.active { |
| 565 | data[0] |= 1 << ENABLE_FLAG; |
| 566 | } |
| 567 | if state.inserting { |
| 568 | data[0] |= 1 << INSERTING_FLAG; |
| 569 | } |
| 570 | if state.removing { |
| 571 | data[0] |= 1 << REMOVING_FLAG; |
| 572 | } |
| 573 | } |
| 574 | _ => { |
| 575 | warn!("Unexpected offset for accessing memory manager device: {offset:#}"); |
| 576 | } |
| 577 | } |
| 578 | } else { |
| 579 | warn!("Out of range memory slot: {}", self.selected_slot); |
| 580 | } |
| 581 | } |
| 582 | |
| 583 | fn write(&mut self, _base: u64, offset: u64, data: &[u8]) -> Option<Arc<Barrier>> { |
| 584 | match offset { |
no test coverage detected