8000 PR for Misc Issue #164 (#167) · rust-osdev/xhci@7d9eb7d · GitHub
[go: up one dir, main page]

Skip to content

Commit 7d9eb7d

Browse files
paulsohntoku-sa-n
andauthored
PR for Misc Issue #164 (#167)
* Clarify the exact behavior of RW1C setters * rename doorbell::Register to Doorbell * mark cap registers as read-only. * convention fix Co-authored-by: Hiroki Tokunaga <tokusan441@gmail.com> --------- Co-authored-by: Hiroki Tokunaga <tokusan441@gmail.com>
1 parent 94ae091 commit 7d9eb7d

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

src/registers/capability.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,25 @@ where
1111
M: Mapper + Clone,
1212
{
1313
/// Capability Registers Length
14-
pub caplength: single::ReadWrite<CapabilityRegistersLength, M>,
14+
pub caplength: single::ReadOnly<CapabilityRegistersLength, M>,
1515
/// Host Controller Interface Version Number
16-
pub hciversion: single::ReadWrite<InterfaceVersionNumber, M>,
16+
pub hciversion: single::ReadOnly<InterfaceVersionNumber, M>,
1717
/// Structural Parameters 1
18-
pub hcsparams1: single::ReadWrite<StructuralParameters1, M>,
18+
pub hcsparams1: single::ReadOnly<StructuralParameters1, M>,
1919
/// Structural Parameters 2
20-
pub hcsparams2: single::ReadWrite<StructuralParameters2, M>,
20+
pub hcsparams2: single::ReadOnly<StructuralParameters2, M>,
2121
/// Structural Parameters 3
22-
pub hcsparams3: single::ReadWrite<StructuralParameters3, M>,
22+
pub hcsparams3: single::ReadOnly<StructuralParameters3, M>,
2323
/// Capability Parameters 1
24-
pub hccparams1: single::ReadWrite<CapabilityParameters1, M>,
24+
pub hccparams1: single::ReadOnly<CapabilityParameters1, M>,
2525
/// Doorbell Offset
26-
pub dboff: single::ReadWrite<DoorbellOffset, M>,
26+
pub dboff: single::ReadOnly<DoorbellOffset, M>,
2727
/// Runtime Register Space Offset
28-
pub rtsoff: single::ReadWrite<RuntimeRegisterSpaceOffset, M>,
28+
pub rtsoff: single::ReadOnly<RuntimeRegisterSpaceOffset, M>,
2929
/// Capability Parameters 2
30-
pub hccparams2: single::ReadWrite<CapabilityParameters2, M>,
30+
pub hccparams2: single::ReadOnly<CapabilityParameters2, M>,
3131
/// Virtualization Based Trusted IO Register Space Offset
32-
pub vtiosoff: single::ReadWrite<VirtualizationBasedTrustedIoRegisterSpaceOffset, M>,
32+
pub vtiosoff: single::ReadOnly<VirtualizationBasedTrustedIoRegisterSpaceOffset, M>,
3333
}
3434
impl<M> Capability<M>
3535
where
@@ -51,7 +51,7 @@ where
5151
{
5252
macro_rules! m {
5353
($offset:expr) => {
54-
single::ReadWrite::new(mmio_base + $offset, mapper.clone())
54+
single::ReadOnly::new(mmio_base + $offset, mapper.clone())
5555
};
5656
}
5757

src/registers/doorbell.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ use accessor::array;
55
use accessor::Mapper;
66
use core::{convert::TryFrom, fmt};
77

8+
/// A type alias to [`Doorbell`] register for backward compability.
9+
#[deprecated = "Use `Doorbell` instead of `Register`."]
10+
pub type Register = Doorbell;
11+
812
/// The element of the Doorbell Array.
913
#[repr(transparent)]
1014
#[derive(Copy, Clone, Default)]
11-
pub struct Register(u32);
12-
impl Register {
15+
pub struct Doorbell(u32);
16+
impl Doorbell {
1317
/// Creates a new accessor to the Doorbell Array.
1418
///
1519
/// # Safety
@@ -44,7 +48,7 @@ impl Register {
4448
rw_field!(0..=7, doorbell_target, "Doorbell Target", u8);
4549
rw_field!(16..=31, doorbell_stream_id, "Doorbell Stream ID", u16);
4650
}
47-
impl fmt::Debug for Register {
51+
impl fmt::Debug for Doorbell {
4852
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4953
f.debug_struct("doorbell::Register")
5054
.field("doorbell_target", &self.doorbell_target())

src/registers/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ where
2222
/// Host Controller Capability Register
2323
pub capability: Capability<M>,
2424
/// Doorbell Array
25-
pub doorbell: array::ReadWrite<doorbell::Register, M>,
25+
pub doorbell: array::ReadWrite<doorbell::Doorbell, M>,
2626
/// Host Controller Operational Register
2727
pub operational: Operational<M>,
2828
/// Port Register Set Array
@@ -75,7 +75,7 @@ where
7575
/// ```
7676
pub unsafe fn new(mmio_base: usize, mapper: M) -> Self {
7777
let capability = Capability::new(mmio_base, &mapper);
78-
let doorbell = doorbell::Register::new(mmio_base, &capability, mapper.clone());
78+
let doorbell = doorbell::Doorbell::new(mmio_base, &capability, mapper.clone());
7979
let operational =
8080
Operational::new(mmio_base, capability.caplength.read_volatile(), &mapper);
8181
let port_register_set = PortRegisterSet::new(mmio_base, &capability, mapper.clone());

0 commit comments

Comments
 (0)
0