Skip to content

Commit

Permalink
Support 64-bit values for CP0 Context. Correct write masking for Cont…
Browse files Browse the repository at this point in the history
…ext and XContext.
  • Loading branch information
jlippitt committed May 14, 2024
1 parent 14185d2 commit a7aed06
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions system/src/cpu/cp0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl Cp0 {
1 => self.regs.random as i32 as i64,
2 => u32::from(self.regs.entry_lo0) as i32 as i64,
3 => u32::from(self.regs.entry_lo1) as i32 as i64,
4 => u32::from(self.regs.context) as i32 as i64,
4 => u64::from(self.regs.context) as i64,
5 => u32::from(self.regs.page_mask) as i32 as i64,
6 => self.regs.wired as i32 as i64,
8 => self.regs.bad_vaddr as i32 as i64,
Expand Down Expand Up @@ -101,7 +101,7 @@ impl Cp0 {
trace!(" EntryLo1: {:?}", self.regs.entry_lo1);
}
4 => {
self.regs.context = (value as u32).into();
self.regs.context = (value as u64 & 0xffff_ffff_ff80_0000).into();
trace!(" Context: {:?}", self.regs.context);
}
5 => {
Expand Down Expand Up @@ -185,7 +185,7 @@ impl Cp0 {
trace!(" WatchHi: {:?}", self.regs.watch_hi);
}
20 => {
self.regs.x_context = (value as u64).into();
self.regs.x_context = (value as u64 & 0xffff_fffe_0000_0000).into();
trace!(" XContext: {:?}", self.regs.x_context);
}
// TOOD: This register has special behaviour when read back
Expand Down
3 changes: 2 additions & 1 deletion system/src/cpu/cp0/regs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,15 @@ pub struct EntryLo {
__: u32,
}

#[bitfield(u32)]
#[bitfield(u64)]
pub struct Context {
#[bits(4)]
__: u32,
#[bits(19)]
pub bad_vpn2: u32,
#[bits(9)]
pub pte_base: u32,
pub __: u32,
}

#[bitfield(u32)]
Expand Down

0 comments on commit a7aed06

Please sign in to comment.