Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions uefi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

## Changed
- Changed ordering of `proto::pci::PciIoAddress` to (bus -> dev -> fun -> reg -> ext_reg).
- Return request with status as error data object for `proto::ata::pass_thru::AtaDevice`.

# uefi - v0.36.1 (2025-11-05)

Expand Down
11 changes: 11 additions & 0 deletions uefi/src/proto/ata/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,20 +161,24 @@ impl<'a> AtaRequestBuilder<'a> {
}

/// Configure the `features` field.
/// FEATURES (7:0)
#[must_use]
pub const fn with_features(mut self, features: u8) -> Self {
self.req.acb.features = features;
self
}

/// Configure the `sector_number` field.
/// LBA (7:0)
#[must_use]
pub const fn with_sector_number(mut self, sector_number: u8) -> Self {
self.req.acb.sector_number = sector_number;
self
}

/// Configure the `cylinder` fields (low and high combined).
/// low: LBA (15:8)
/// high: LBA (23:16)
#[must_use]
pub const fn with_cylinder(mut self, low: u8, high: u8) -> Self {
self.req.acb.cylinder_low = low;
Expand All @@ -183,20 +187,24 @@ impl<'a> AtaRequestBuilder<'a> {
}

/// Configure the `device_head` field.
/// DEVICE
#[must_use]
pub const fn with_device_head(mut self, device_head: u8) -> Self {
self.req.acb.device_head = device_head;
self
}

/// Configure the `sector_number_exp` field.
/// LBA (31:24)
#[must_use]
pub const fn with_sector_number_exp(mut self, sector_number_exp: u8) -> Self {
self.req.acb.sector_number_exp = sector_number_exp;
self
}

/// Configure the `cylinder_exp` fields (low and high combined).
/// low_exp: LBA (39:32)
/// high_exp: LBA (47:40)
#[must_use]
pub const fn with_cylinder_exp(mut self, low_exp: u8, high_exp: u8) -> Self {
self.req.acb.cylinder_low_exp = low_exp;
Expand All @@ -205,20 +213,23 @@ impl<'a> AtaRequestBuilder<'a> {
}

/// Configure the `features_exp` field.
/// FEATURES (15:8)
#[must_use]
pub const fn with_features_exp(mut self, features_exp: u8) -> Self {
self.req.acb.features_exp = features_exp;
self
}

/// Configure the `sector_count` field.
/// COUNT (7:0)
#[must_use]
pub const fn with_sector_count(mut self, sector_count: u8) -> Self {
self.req.acb.sector_count = sector_count;
self
}

/// Configure the `sector_count_exp` field.
/// COUNT (15:8)
#[must_use]
pub const fn with_sector_count_exp(mut self, sector_count_exp: u8) -> Self {
self.req.acb.sector_count_exp = sector_count_exp;
Expand Down
11 changes: 8 additions & 3 deletions uefi/src/proto/ata/pass_thru.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,20 +182,25 @@ impl AtaDevice<'_> {
/// - [`Status::UNSUPPORTED`] The host adapter does not support the command described by the ATA command.
/// The command was not sent, and no additional status information is available.
/// - [`Status::TIMEOUT`] A timeout occurred while waiting for the ATA command to execute. Refer to `Asb` for additional status details.
#[allow(clippy::result_large_err)]
pub fn execute_command<'req>(
&mut self,
mut req: AtaRequest<'req>,
) -> crate::Result<AtaResponse<'req>> {
) -> crate::Result<AtaResponse<'req>, AtaResponse<'req>> {
req.packet.acb = &req.acb;
unsafe {
let result = unsafe {
((*self.proto.get()).pass_thru)(
self.proto.get(),
self.port,
self.pmp,
&mut req.packet,
ptr::null_mut(),
)
.to_result_with_val(|| AtaResponse { req })
.to_result()
};
match result {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit. I think that .map() and .map_err(). But I don't have a strong opinion on that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't work unfortunately, because both lambdas (map(..) and map_err(...)) would try to move/capture req. The match is ugly ... but it's the only way I found. :(

Ok(_) => Ok(AtaResponse { req }),
Err(s) => Err(crate::Error::new(s.status(), AtaResponse { req })),
}
}
}
Expand Down
Loading