diff --git a/src/context/mod.rs b/src/context/mod.rs index fda71065..8c04fd3d 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 { @@ -216,6 +222,16 @@ 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; + } + + /// 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); @@ -283,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. @@ -308,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. 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)] 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());