From 3515506cddd7ae26ad45bfde634af1f41d5e85d6 Mon Sep 17 00:00:00 2001 From: dbydd <1992003927@qq.com> Date: Mon, 26 Aug 2024 11:03:50 +0800 Subject: [PATCH 1/5] make input context could clone device value from output ctx --- src/context/mod.rs | 6 ++++++ src/registers/mod.rs | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/context/mod.rs b/src/context/mod.rs index fda71065..dfbdf2de 100644 --- a/src/context/mod.rs +++ b/src/context/mod.rs @@ -77,6 +77,12 @@ impl Input { device: Device::new(), } } + + /// copy output ctx to input + /// refer linux code + pub fn copy_from_output(&mut self, out_ctx: &Device) { + self.device = out_ctx.clone() + } } impl InputHandler for Input { fn control(&self) -> &dyn InputControlHandler { diff --git a/src/registers/mod.rs b/src/registers/mod.rs index b192dbd7..53f436f3 100644 --- a/src/registers/mod.rs +++ b/src/registers/mod.rs @@ -76,7 +76,7 @@ where /// ``` pub unsafe fn new(mmio_base: usize, mapper: M) -> Self { let capability = Capability::new(mmio_base, &mapper); - let doorbell = doorbell::Doorbell::new(mmio_base, &capability, mapper.clone()); + let doorbell = Doorbell::new(mmio_base, &capability, mapper.clone()); let operational = Operational::new(mmio_base, capability.caplength.read_volatile(), &mapper); let port_register_set = PortRegisterSet::new(mmio_base, &capability, mapper.clone()); From fced957d204708fba2d69f50d3eba0380387bad2 Mon Sep 17 00:00:00 2001 From: dbydd <1992003927@qq.com> Date: Mon, 26 Aug 2024 15:33:15 +0800 Subject: [PATCH 2/5] make input context could clean all bits expect 0 of add flag --- src/context/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/context/mod.rs b/src/context/mod.rs index dfbdf2de..d0e91703 100644 --- a/src/context/mod.rs +++ b/src/context/mod.rs @@ -222,6 +222,11 @@ pub trait InputControlHandler: AsRef<[u32]> + AsMut<[u32]> { self.as_mut()[1].set_bit(i, false); } + /// clear all add flag expect ep 0 + fn clear_all_nonep0_add_flag(&mut self) { + self.as_mut()[1] = 1u32; + } + rw_field_cx!([7](0..=7), configuration_value, "Configuration Value", u8); rw_field_cx!([7](8..=15), interface_number, "Interface Number", u8); rw_field_cx!([7](16..=23), alternate_setting, "Alternate Setting", u8); From 393bf323b00c39bb9396cc22ba35a536811642c7 Mon Sep 17 00:00:00 2001 From: dbydd <1992003927@qq.com> Date: Mon, 26 Aug 2024 15:35:02 +0800 Subject: [PATCH 3/5] make input context could clean all bits expect 0 of add flag --- src/context/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/context/mod.rs b/src/context/mod.rs index d0e91703..db887291 100644 --- a/src/context/mod.rs +++ b/src/context/mod.rs @@ -227,6 +227,11 @@ pub trait InputControlHandler: AsRef<[u32]> + AsMut<[u32]> { self.as_mut()[1] = 1u32; } + /// clear all drop flag + fn clear_all_drop_flag(&mut self) { + self.as_mut()[0] = 0u32; + } + rw_field_cx!([7](0..=7), configuration_value, "Configuration Value", u8); rw_field_cx!([7](8..=15), interface_number, "Interface Number", u8); rw_field_cx!([7](16..=23), alternate_setting, "Alternate Setting", u8); From cfa82716d0e8ce5a89e60614d78502a8464d5180 Mon Sep 17 00:00:00 2001 From: dbydd <1992003927@qq.com> Date: Tue, 27 Aug 2024 16:39:12 +0800 Subject: [PATCH 4/5] i missed a bit --- src/context/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/context/mod.rs b/src/context/mod.rs index db887291..8c04fd3d 100644 --- a/src/context/mod.rs +++ b/src/context/mod.rs @@ -299,6 +299,10 @@ impl DeviceHandler for Device { &mut self.endpoints[dci - 1] } + + fn fill_endpoints_with_0(&mut self) { + self.endpoints.fill(Endpoint::new()) + } } /// A trait to handle Device Context. @@ -324,6 +328,9 @@ pub trait DeviceHandler { /// This method panics if `dci > 31 || dci == 0`. Call [`DeviceHandler::slot_mut`] if you want /// a mutable handler of Slot Context. fn endpoint_mut(&mut self, dci: usize) -> &mut dyn EndpointHandler; + + /// fill all endpoints with 0 + fn fill_endpoints_with_0(&mut self); } /// Slot Context. From 6c4f76787c473d11a915d889e15e850473ae79ba Mon Sep 17 00:00:00 2001 From: dbydd Date: Wed, 28 Aug 2024 22:14:19 +0800 Subject: [PATCH 5/5] fixed deprecated clippy option --- src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index a64afa08..bd8e4e98 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -55,7 +55,6 @@ unused_import_braces, unused_lifetimes, unused_qualifications, - pointer_structural_match, missing_debug_implementations )] #![allow(clippy::missing_panics_doc)]