Fix pci config errors caused by expression precedence

This commit is contained in:
Qingsong Chen 2024-11-04 03:45:11 +00:00 committed by Tate, Hongliang Tian
parent 2c6cbee92f
commit b3d30f7ac3
2 changed files with 3 additions and 3 deletions

View File

@ -237,7 +237,7 @@ impl MemoryBar {
}
};
// length
let size = !(len_encoded & !0xF).wrapping_add(1);
let size = (!(len_encoded & !0xF)).wrapping_add(1);
let prefetchable = raw & 0b1000 != 0;
// The BAR is located in I/O memory region
Ok(MemoryBar {

View File

@ -137,7 +137,7 @@ impl PciDeviceLocation {
pub(super) fn write8(&self, offset: u16, val: u8) {
let old = self.read32(offset & Self::BIT32_ALIGN_MASK);
let dest = offset as usize & 0b11 << 3;
let dest = (offset as usize & 0b11) << 3;
let mask = (0xFF << dest) as u32;
self.write32(
offset & Self::BIT32_ALIGN_MASK,
@ -147,7 +147,7 @@ impl PciDeviceLocation {
pub(super) fn write16(&self, offset: u16, val: u16) {
let old = self.read32(offset & Self::BIT32_ALIGN_MASK);
let dest = offset as usize & 0b10 << 3;
let dest = (offset as usize & 0b10) << 3;
let mask = (0xFFFF << dest) as u32;
self.write32(
offset & Self::BIT32_ALIGN_MASK,