MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / write_word

Method write_word

pci/src/configuration.rs:678–697  ·  view source on GitHub ↗

Writes a 16bit word to `offset`. `offset` must be 16bit aligned.

(&mut self, offset: usize, value: u16)

Source from the content-addressed store, hash-verified

676
677 /// Writes a 16bit word to `offset`. `offset` must be 16bit aligned.
678 pub fn write_word(&mut self, offset: usize, value: u16) {
679 let shift = match offset % 4 {
680 0 => 0,
681 2 => 16,
682 _ => {
683 warn!("bad PCI config write offset {offset}");
684 return;
685 }
686 };
687 let reg_idx = offset / 4;
688
689 if let Some(r) = self.registers.get_mut(reg_idx) {
690 let writable_mask = self.writable_bits[reg_idx];
691 let mask = (0xffffu32 << shift) & writable_mask;
692 let shifted_value = (u32::from(value) << shift) & writable_mask;
693 *r = *r & !mask | shifted_value;
694 } else {
695 warn!("bad PCI config write offset {offset}");
696 }
697 }
698
699 /// Writes a byte to `offset`.
700 pub fn write_byte(&mut self, offset: usize, value: u8) {

Callers 1

write_config_registerMethod · 0.80

Calls 1

get_mutMethod · 0.45

Tested by

no test coverage detected