Skip to content

Commit 176d71f

Browse files
authored
Merge pull request #1814 from seijikun/mr-atapassthru-pio
AtaPassThru: Add read_pio method for AtaRequestBuilder
2 parents 14e4882 + e40477a commit 176d71f

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

uefi/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# uefi - [Unreleased]
22

33
## Added
4+
- Added `proto::ata::AtaRequestBuilder::read_pio()`.
45

56
## Changed
67

uefi/src/proto/ata/mod.rs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ pub mod pass_thru;
1616

1717
/// Represents the protocol for ATA Pass Thru command handling.
1818
///
19-
/// This type defines the protocols supported for passing commands through the ATA controller.
19+
/// This type defines the protocols supported for passing ATA commands through to an
20+
/// ATA compliant controller. Over time, multiple possible transports for ATA commands
21+
/// have evolved. The UEFI spec generically abstracts all of these transports below
22+
/// this one protocol, so old PATA drives and controllers, as well as modern AHCI-only
23+
/// SATA controllers are supported with the same set of APIs.
24+
/// see: <https://uefi.org/specs/PI/1.8/V5_IDE_Controller.html>
2025
pub use uefi_raw::protocol::ata::AtaPassThruCommandProtocol;
2126

2227
/// Represents an ATA request built for execution on an ATA controller.
@@ -87,6 +92,35 @@ impl<'a> AtaRequestBuilder<'a> {
8792
})
8893
}
8994

95+
// # PIO
96+
// ########################################################################
97+
98+
/// Creates a builder for a PIO write operation.
99+
///
100+
/// Since the ATA specification mandates the support for PIO mode for all
101+
/// compliant drives and controllers, this is the protocol variant with the
102+
/// highest compatibility in the field.
103+
/// So probing, (sending ATA IDENTIFY commands to device ports to find out
104+
/// whether there is actually a device connected to it) should probably be
105+
/// done using this method most of the time.
106+
/// If this errors with Status "UNSUPPORTED", try UDMA next.
107+
///
108+
/// # Arguments
109+
/// - `io_align`: The I/O buffer alignment required for the ATA controller.
110+
/// - `command`: The ATA command byte specifying the write operation.
111+
///
112+
/// # Returns
113+
/// `Result<Self, LayoutError>` indicating success or memory allocation failure.
114+
///
115+
/// # Errors
116+
/// This method can fail due to alignment or memory allocation issues.
117+
pub fn read_pio(io_align: u32, command: u8) -> Result<Self, LayoutError> {
118+
Self::new(io_align, command, AtaPassThruCommandProtocol::PIO_DATA_IN)
119+
}
120+
121+
// # UDMA
122+
// ########################################################################
123+
90124
/// Creates a builder for a UDMA read operation.
91125
///
92126
/// # Arguments

0 commit comments

Comments
 (0)