MCPcopy Index your code
hub / github.com/cloud-hypervisor/cloud-hypervisor / write_byte_internal

Method write_byte_internal

pci/src/configuration.rs:705–721  ·  view source on GitHub ↗

Writes a byte to `offset`, optionally enforcing read-only bits.

(&mut self, offset: usize, value: u8, apply_writable_mask: bool)

Source from the content-addressed store, hash-verified

703
704 /// Writes a byte to `offset`, optionally enforcing read-only bits.
705 fn write_byte_internal(&mut self, offset: usize, value: u8, apply_writable_mask: bool) {
706 let shift = (offset % 4) * 8;
707 let reg_idx = offset / 4;
708
709 if let Some(r) = self.registers.get_mut(reg_idx) {
710 let writable_mask = if apply_writable_mask {
711 self.writable_bits[reg_idx]
712 } else {
713 0xffff_ffff
714 };
715 let mask = (0xffu32 << shift) & writable_mask;
716 let shifted_value = (u32::from(value) << shift) & writable_mask;
717 *r = *r & !mask | shifted_value;
718 } else {
719 warn!("bad PCI config write offset {offset}");
720 }
721 }
722
723 /// Adds a region specified by `config`. Configures the specified BAR(s) to
724 /// report this region and size to the guest kernel. Enforces a few constraints

Callers 2

write_byteMethod · 0.80
add_capabilityMethod · 0.80

Calls 1

get_mutMethod · 0.45

Tested by

no test coverage detected