Skip to content

Commit

Permalink
Fix wrong calculation of data_buffer_pointer of transfer::Normal (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
lemolatoon authored Jul 19, 2023
1 parent 4c84664 commit 6098779
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- CI now uses `giraffate/clippy-action@` instead of `actions-rs/clippy-check` for Clippy check.

### Fixed
- `transfer::Normal`'s data_buffer_pointer calculation is fixed.
- The path to the workflow status is fixed.
- Removed an outdated lint `unaligned_references`.

Expand Down
25 changes: 24 additions & 1 deletion src/ring/trb/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl Normal {
let l: u64 = self.0[0].into();
let u: u64 = self.0[1].into();

(l << 32) | u
(u << 32) | l
}

rw_field!([2](0..=16), trb_transfer_length, "TRB Transfer Length", u32);
Expand Down Expand Up @@ -527,3 +527,26 @@ pub enum TransferType {
/// In Data Stage.
In = 3,
}

#[cfg(test)]
mod test {
use super::*;

#[test]
fn normal_data_buffer_pointer() {
let mut normal = Normal::new();
let pointer = 0x12345678_9abcdef0;
normal.set_data_buffer_pointer(pointer);
let pointer_read = normal.data_buffer_pointer();
assert_eq!(pointer, pointer_read);
}

#[test]
fn isoch_data_buffer_pointer() {
let mut isoch = Isoch::new();
let pointer = 0xabcd1234_567890ef;
isoch.set_data_buffer_pointer(pointer);
let pointer_read = isoch.data_buffer_pointer();
assert_eq!(pointer, pointer_read);
}
}

0 comments on commit 6098779

Please sign in to comment.