Skip to content

Commit 7bcba86

Browse files
mkroeningIsaacWoods
authored andcommitted
feat: don't truncate reserved bits in CommandRegister
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
1 parent 5e2db41 commit 7bcba86

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,15 @@ impl PciHeader {
162162

163163
pub fn command(&self, access: &impl ConfigRegionAccess) -> CommandRegister {
164164
let data = unsafe { access.read(self.0, 0x4).get_bits(0..16) };
165-
CommandRegister::from_bits_truncate(data as u16)
165+
CommandRegister::from_bits_retain(data as u16)
166166
}
167167

168168
pub fn update_command<F>(&self, access: &impl ConfigRegionAccess, f: F)
169169
where
170170
F: FnOnce(CommandRegister) -> CommandRegister,
171171
{
172172
let mut data = unsafe { access.read(self.0, 0x4) };
173-
let new_command = f(CommandRegister::from_bits_truncate(data.get_bits(0..16) as u16));
173+
let new_command = f(CommandRegister::from_bits_retain(data.get_bits(0..16) as u16));
174174
data.set_bits(0..16, new_command.bits() as u32);
175175
unsafe {
176176
access.write(self.0, 0x4, data);

src/register.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,5 +139,6 @@ bitflags::bitflags! {
139139
const SERR_ENABLE = 1 << 8;
140140
const FAST_BACK_TO_BACK_ENABLE = 1 << 9;
141141
const INTERRUPT_DISABLE = 1 << 10;
142+
const _ = !0;
142143
}
143144
}

0 commit comments

Comments
 (0)