xhci/lib.rs
1//! A library to handle xHCI.
2//!
3//! This crate provides types of the xHCI structures, such as the Registers and Contexts.
4//! Users can use this library to implement a USB device deriver on your own OS.
5//!
6//! This crate is `#![no_std]` compatible.
7//!
8//! # Examples
9//!
10//! ```no_run
11//! # use core::num::NonZeroUsize;
12//! # use xhci::accessor::Mapper;
13//! #
14//! # const MMIO_BASE: usize = 0x1000;
15//! #
16//! # #[derive(Clone)]
17//! # struct MemoryMapper;
18//! # impl Mapper for MemoryMapper {
19//! # unsafe fn map(&mut self, phys_base: usize, bytes: usize) -> NonZeroUsize {
20//! # unimplemented!()
21//! # }
22//! #
23//! # fn unmap(&mut self, virt_base: usize, bytes: usize) {
24//! # unimplemented!()
25//! # }
26//! # }
27//! #
28//! # let mapper = MemoryMapper;
29//! #
30//! let mut r = unsafe { xhci::Registers::new(MMIO_BASE, mapper) };
31//! let o = &mut r.operational;
32//!
33//! o.usbcmd.update(|u| {
34//! u.set_run_stop();
35//! });
36//! while o.usbsts.read().hc_halted() {}
37//! ```
38
39#![no_std]
40#![deny(
41 rustdoc::all,
42 missing_docs,
43 elided_lifetimes_in_paths,
44 explicit_outlives_requirements,
45 macro_use_extern_crate,
46 missing_copy_implementations,
47 meta_variable_misuse,
48 non_ascii_idents,
49 private_doc_tests,
50 single_use_lifetimes,
51 unreachable_pub,
52 unused_crate_dependencies,
53 unused_extern_crates,
54 trivial_casts,
55 unused_import_braces,
56 unused_lifetimes,
57 unused_qualifications,
58 pointer_structural_match,
59 missing_debug_implementations
60)]
61#![allow(clippy::missing_panics_doc)]
62
63pub use accessor;
64pub use extended_capabilities::ExtendedCapability;
65pub use registers::Registers;
66
67#[macro_use]
68mod macros;
69
70pub mod context;
71pub mod extended_capabilities;
72pub mod registers;
73pub mod ring;