Skip to content

Commit 7cbfacf

Browse files
committed
Rename x86_64 module to port and make submodules private
Also: Add docs annotation on docs.rs that `SerialPort` is only available on `x86_64`.
1 parent 35688fe commit 7cbfacf

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ pre-release-replacements = [
2424
{ file="Changelog.md", search="# Unreleased", replace="# Unreleased\n\n# {{version}} – {{date}}", exactly=1 },
2525
]
2626
pre-release-commit-message = "Release version {{version}}"
27+
28+
[package.metadata.docs.rs]
29+
rustdoc-args = ["--cfg", "docsrs"]

src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,11 @@
5757
//! // To receive a byte:
5858
//! let data = serial_port.receive();
5959
//! ```
60+
6061
#![no_std]
6162
#![warn(missing_docs)]
6263
#![cfg_attr(feature = "nightly", feature(const_ptr_offset))]
64+
#![cfg_attr(docsrs, feature(doc_cfg))]
6365

6466
#[cfg(not(any(feature = "stable", feature = "nightly")))]
6567
compile_error!("Either the `stable` or `nightly` feature must be enabled");
@@ -75,14 +77,14 @@ macro_rules! wait_for {
7577
}
7678

7779
/// Memory mapped implementation
78-
pub mod mmio;
80+
mod mmio;
7981
#[cfg(target_arch = "x86_64")]
8082
/// Port asm commands implementation
81-
pub mod x86_64;
83+
mod port;
8284

8385
pub use crate::mmio::MmioSerialPort;
8486
#[cfg(target_arch = "x86_64")]
85-
pub use crate::x86_64::SerialPort;
87+
pub use crate::port::SerialPort;
8688

8789
bitflags! {
8890
/// Interrupt enable flags

src/mmio.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use core::{
55

66
use crate::LineStsFlags;
77

8-
/// An interface to a serial port that allows sending out individual bytes.
8+
/// A memory-mapped UART.
99
pub struct MmioSerialPort {
1010
data: AtomicPtr<u8>,
1111
int_en: AtomicPtr<u8>,
@@ -16,7 +16,7 @@ pub struct MmioSerialPort {
1616
}
1717

1818
impl MmioSerialPort {
19-
/// Creates a new serial port interface on the given memory mapped address.
19+
/// Creates a new UART interface on the given memory mapped address.
2020
///
2121
/// This function is unsafe because the caller must ensure that the given base address
2222
/// really points to a serial port device.
@@ -46,7 +46,7 @@ impl MmioSerialPort {
4646
}
4747
}
4848

49-
/// Initializes the serial port.
49+
/// Initializes the memory-mapped UART.
5050
///
5151
/// The default configuration of [38400/8-N-1](https://en.wikipedia.org/wiki/8-N-1) is used.
5252
pub fn init(&mut self) {

src/x86_64.rs renamed to src/port.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ use x86_64::instructions::port::{Port, PortReadOnly, PortWriteOnly};
44

55
use crate::LineStsFlags;
66

7-
/// An interface to a serial port that allows sending out individual bytes.
7+
/// A port-mapped UART.
8+
#[cfg_attr(docsrs, doc(cfg(target_arch = "x86_64")))]
89
pub struct SerialPort {
910
data: Port<u8>,
1011
int_en: PortWriteOnly<u8>,

0 commit comments

Comments
 (0)