Skip to content

Commit b760a3c

Browse files
Merge pull request #1714 from rust-osdev/bishop-status-cleanup
uefi/test-runner: Remove `crate::` and `uefi::` prefix from Status
2 parents 1fcf4d8 + c3df136 commit b760a3c

File tree

9 files changed

+111
-97
lines changed

9 files changed

+111
-97
lines changed

uefi-test-runner/src/proto/media.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ fn test_raw_disk_io2(handle: Handle) {
316316
let mut task = DiskIoTask {
317317
token: DiskIo2Token {
318318
event: Some(event.unsafe_clone()),
319-
transaction_status: uefi::Status::NOT_READY,
319+
transaction_status: Status::NOT_READY,
320320
},
321321
buffer: [0; 512],
322322
};
@@ -337,7 +337,7 @@ fn test_raw_disk_io2(handle: Handle) {
337337
.expect("Failed to wait on completion event");
338338

339339
// Verify that the disk's MBR signature is correct
340-
assert_eq!(task.token.transaction_status, uefi::Status::SUCCESS);
340+
assert_eq!(task.token.transaction_status, Status::SUCCESS);
341341
assert_eq!(task.buffer[510], 0x55);
342342
assert_eq!(task.buffer[511], 0xaa);
343343

uefi/src/proto/media/block.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl BlockIO {
2929
/// exhaustive verification operation of the device during reset.
3030
///
3131
/// # Errors
32-
/// * `uefi::Status::DEVICE_ERROR` The block device is not functioning
32+
/// * `Status::DEVICE_ERROR` The block device is not functioning
3333
/// correctly and could not be reset.
3434
pub fn reset(&mut self, extended_verification: bool) -> Result {
3535
unsafe { (self.0.reset)(&mut self.0, extended_verification.into()) }.to_result()
@@ -43,13 +43,13 @@ impl BlockIO {
4343
/// * `buffer` - The target buffer of the read operation
4444
///
4545
/// # Errors
46-
/// * `uefi::Status::DEVICE_ERROR` The device reported an error while attempting to perform the read
46+
/// * `Status::DEVICE_ERROR` The device reported an error while attempting to perform the read
4747
/// operation.
48-
/// * `uefi::Status::NO_MEDIA` There is no media in the device.
49-
/// * `uefi::Status::MEDIA_CHANGED` The `media_id` is not for the current media.
50-
/// * `uefi::Status::BAD_BUFFER_SIZE` The buffer size parameter is not a multiple of the intrinsic block size of
48+
/// * `Status::NO_MEDIA` There is no media in the device.
49+
/// * `Status::MEDIA_CHANGED` The `media_id` is not for the current media.
50+
/// * `Status::BAD_BUFFER_SIZE` The buffer size parameter is not a multiple of the intrinsic block size of
5151
/// the device.
52-
/// * `uefi::Status::INVALID_PARAMETER` The read request contains LBAs that are not valid, or the buffer is not on
52+
/// * `Status::INVALID_PARAMETER` The read request contains LBAs that are not valid, or the buffer is not on
5353
/// proper alignment.
5454
pub fn read_blocks(&self, media_id: u32, lba: Lba, buffer: &mut [u8]) -> Result {
5555
let buffer_size = buffer.len();
@@ -73,14 +73,14 @@ impl BlockIO {
7373
/// * `buffer` Buffer to be written
7474
///
7575
/// # Errors
76-
/// * `uefi::Status::WRITE_PROTECTED` The device cannot be written to.
77-
/// * `uefi::Status::NO_MEDIA` There is no media in the device.
78-
/// * `uefi::Status::MEDIA_CHANGED` The `media_id` is not for the current media.
79-
/// * `uefi::Status::DEVICE_ERROR` The device reported an error while attempting to perform the write
76+
/// * `Status::WRITE_PROTECTED` The device cannot be written to.
77+
/// * `Status::NO_MEDIA` There is no media in the device.
78+
/// * `Status::MEDIA_CHANGED` The `media_id` is not for the current media.
79+
/// * `Status::DEVICE_ERROR` The device reported an error while attempting to perform the write
8080
/// operation.
81-
/// * `uefi::Status::BAD_BUFFER_SIZE` The buffer size parameter is not a multiple of the intrinsic block size
81+
/// * `Status::BAD_BUFFER_SIZE` The buffer size parameter is not a multiple of the intrinsic block size
8282
/// of the device.
83-
/// * `uefi::Status::INVALID_PARAMETER` The write request contains LBAs that are not valid, or the buffer is not
83+
/// * `Status::INVALID_PARAMETER` The write request contains LBAs that are not valid, or the buffer is not
8484
/// on proper alignment.
8585
pub fn write_blocks(&mut self, media_id: u32, lba: Lba, buffer: &[u8]) -> Result {
8686
let buffer_size = buffer.len();
@@ -99,8 +99,8 @@ impl BlockIO {
9999
/// Flushes all modified data to a physical block device.
100100
///
101101
/// # Errors
102-
/// * `uefi::Status::DEVICE_ERROR` The device reported an error while attempting to write data.
103-
/// * `uefi::Status::NO_MEDIA` There is no media in the device.
102+
/// * `Status::DEVICE_ERROR` The device reported an error while attempting to write data.
103+
/// * `Status::NO_MEDIA` There is no media in the device.
104104
pub fn flush_blocks(&mut self) -> Result {
105105
unsafe { (self.0.flush_blocks)(&mut self.0) }.to_result()
106106
}

uefi/src/proto/media/disk_info.rs

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ use crate::StatusExt;
66
use uefi_macros::unsafe_protocol;
77
use uefi_raw::protocol::disk::DiskInfoProtocol;
88

9+
#[cfg(doc)]
10+
use crate::Status;
11+
912
/// Enum representing the interface type of the disk.
1013
///
1114
/// This protocol abstracts various disk interfaces, including IDE, USB, AHCI, NVME, and more.
@@ -60,7 +63,7 @@ pub struct DeviceLocationInfo {
6063
///
6164
/// Not all operations are supported by all interface types!
6265
/// Either use [`DiskInfo::interface`] to determine what should be possible, or simply
63-
/// try and handle the [`crate::Status::UNSUPPORTED`] error return value.
66+
/// try and handle the [`Status::UNSUPPORTED`] error return value.
6467
///
6568
/// # UEFI Spec Description
6669
/// Provides the basic interfaces to abstract platform information regarding an IDE controller.
@@ -99,10 +102,10 @@ impl DiskInfo {
99102
/// Length of the response (amount of bytes that were written to the given buffer).
100103
///
101104
/// # Errors
102-
/// - [`crate::Status::SUCCESS`] The command was accepted without any errors.
103-
/// - [`crate::Status::NOT_FOUND`] The device does not support this data class.
104-
/// - [`crate::Status::DEVICE_ERROR`] An error occurred while reading the InquiryData from the device.
105-
/// - [`crate::Status::BUFFER_TOO_SMALL`] The provided InquiryDataSize buffer is not large enough to store the required data.
105+
/// - [`Status::SUCCESS`] The command was accepted without any errors.
106+
/// - [`Status::NOT_FOUND`] The device does not support this data class.
107+
/// - [`Status::DEVICE_ERROR`] An error occurred while reading the InquiryData from the device.
108+
/// - [`Status::BUFFER_TOO_SMALL`] The provided InquiryDataSize buffer is not large enough to store the required data.
106109
pub fn inquiry(&self, bfr: &mut [u8]) -> crate::Result<usize> {
107110
let mut len: u32 = bfr.len() as u32;
108111
unsafe {
@@ -120,10 +123,10 @@ impl DiskInfo {
120123
/// Length of the response (amount of bytes that were written to the given buffer).
121124
///
122125
/// # Errors
123-
/// - [`crate::Status::SUCCESS`] The command was accepted without any errors.
124-
/// - [`crate::Status::NOT_FOUND`] The device does not support this data class.
125-
/// - [`crate::Status::DEVICE_ERROR`] An error occurred while reading the IdentifyData from the device.
126-
/// - [`crate::Status::BUFFER_TOO_SMALL`] The provided IdentifyDataSize buffer is not large enough to store the required data.
126+
/// - [`Status::SUCCESS`] The command was accepted without any errors.
127+
/// - [`Status::NOT_FOUND`] The device does not support this data class.
128+
/// - [`Status::DEVICE_ERROR`] An error occurred while reading the IdentifyData from the device.
129+
/// - [`Status::BUFFER_TOO_SMALL`] The provided IdentifyDataSize buffer is not large enough to store the required data.
127130
pub fn identify(&self, bfr: &mut [u8]) -> crate::Result<usize> {
128131
let mut len: u32 = bfr.len() as u32;
129132
unsafe {
@@ -141,10 +144,10 @@ impl DiskInfo {
141144
/// [`SenseDataInfo`] struct containing the number of bytes of sense data and the number of sense data structures.
142145
///
143146
/// # Errors
144-
/// - [`crate::Status::SUCCESS`] The command was accepted without any errors.
145-
/// - [`crate::Status::NOT_FOUND`] The device does not support this data class.
146-
/// - [`crate::Status::DEVICE_ERROR`] An error occurred while reading the SenseData from the device.
147-
/// - [`crate::Status::BUFFER_TOO_SMALL`] The provided SenseDataSize buffer is not large enough to store the required data.
147+
/// - [`Status::SUCCESS`] The command was accepted without any errors.
148+
/// - [`Status::NOT_FOUND`] The device does not support this data class.
149+
/// - [`Status::DEVICE_ERROR`] An error occurred while reading the SenseData from the device.
150+
/// - [`Status::BUFFER_TOO_SMALL`] The provided SenseDataSize buffer is not large enough to store the required data.
148151
pub fn sense_data(&self, bfr: &mut [u8]) -> crate::Result<SenseDataInfo> {
149152
let mut len: u32 = bfr.len() as u32;
150153
let mut number: u8 = 0;
@@ -166,8 +169,8 @@ impl DiskInfo {
166169
/// [`DeviceLocationInfo`] struct containing the channel and device numbers.
167170
///
168171
/// # Errors
169-
/// - [`crate::Status::SUCCESS`] The `IdeChannel` and `IdeDevice` values are valid.
170-
/// - [`crate::Status::UNSUPPORTED`] Not supported by this disk's interface type.
172+
/// - [`Status::SUCCESS`] The `IdeChannel` and `IdeDevice` values are valid.
173+
/// - [`Status::UNSUPPORTED`] Not supported by this disk's interface type.
171174
pub fn bus_location(&self) -> crate::Result<DeviceLocationInfo> {
172175
let mut ide_channel: u32 = 0; // called ide, but also useful for other interfaces
173176
let mut ide_device: u32 = 0;

uefi/src/proto/media/file/mod.rs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,18 @@ pub trait File: Sized {
5555
/// errors returned by this function, but some implementations (such as EDK2) perform
5656
/// additional validation and may return that status for invalid inputs.
5757
///
58-
/// [`INVALID_PARAMETER`]: uefi::Status::INVALID_PARAMETER
58+
/// [`INVALID_PARAMETER`]: Status::INVALID_PARAMETER
5959
///
60-
/// * [`uefi::Status::INVALID_PARAMETER`]
61-
/// * [`uefi::Status::NOT_FOUND`]
62-
/// * [`uefi::Status::NO_MEDIA`]
63-
/// * [`uefi::Status::MEDIA_CHANGED`]
64-
/// * [`uefi::Status::DEVICE_ERROR`]
65-
/// * [`uefi::Status::VOLUME_CORRUPTED`]
66-
/// * [`uefi::Status::WRITE_PROTECTED`]
67-
/// * [`uefi::Status::ACCESS_DENIED`]
68-
/// * [`uefi::Status::OUT_OF_RESOURCES`]
69-
/// * [`uefi::Status::VOLUME_FULL`]
60+
/// * [`Status::INVALID_PARAMETER`]
61+
/// * [`Status::NOT_FOUND`]
62+
/// * [`Status::NO_MEDIA`]
63+
/// * [`Status::MEDIA_CHANGED`]
64+
/// * [`Status::DEVICE_ERROR`]
65+
/// * [`Status::VOLUME_CORRUPTED`]
66+
/// * [`Status::WRITE_PROTECTED`]
67+
/// * [`Status::ACCESS_DENIED`]
68+
/// * [`Status::OUT_OF_RESOURCES`]
69+
/// * [`Status::VOLUME_FULL`]
7070
fn open(
7171
&mut self,
7272
filename: &CStr16,
@@ -96,7 +96,7 @@ pub trait File: Sized {
9696
///
9797
/// See section `EFI_FILE_PROTOCOL.Delete()` in the UEFI Specification for more details.
9898
///
99-
/// * [`uefi::Status::WARN_DELETE_FAILURE`]
99+
/// * [`Status::WARN_DELETE_FAILURE`]
100100
fn delete(mut self) -> Result {
101101
let result = unsafe { (self.imp().delete)(self.imp()) }.to_result();
102102
mem::forget(self);
@@ -117,11 +117,11 @@ pub trait File: Sized {
117117
///
118118
/// See section `EFI_FILE_PROTOCOL.GetInfo()` in the UEFI Specification for more details.
119119
///
120-
/// * [`uefi::Status::UNSUPPORTED`]
121-
/// * [`uefi::Status::NO_MEDIA`]
122-
/// * [`uefi::Status::DEVICE_ERROR`]
123-
/// * [`uefi::Status::VOLUME_CORRUPTED`]
124-
/// * [`uefi::Status::BUFFER_TOO_SMALL`]
120+
/// * [`Status::UNSUPPORTED`]
121+
/// * [`Status::NO_MEDIA`]
122+
/// * [`Status::DEVICE_ERROR`]
123+
/// * [`Status::VOLUME_CORRUPTED`]
124+
/// * [`Status::BUFFER_TOO_SMALL`]
125125
fn get_info<'buf, Info: FileProtocolInfo + ?Sized>(
126126
&mut self,
127127
buffer: &'buf mut [u8],
@@ -162,14 +162,14 @@ pub trait File: Sized {
162162
///
163163
/// See section `EFI_FILE_PROTOCOL.SetInfo()` in the UEFI Specification for more details.
164164
///
165-
/// * [`uefi::Status::UNSUPPORTED`]
166-
/// * [`uefi::Status::NO_MEDIA`]
167-
/// * [`uefi::Status::DEVICE_ERROR`]
168-
/// * [`uefi::Status::VOLUME_CORRUPTED`]
169-
/// * [`uefi::Status::WRITE_PROTECTED`]
170-
/// * [`uefi::Status::ACCESS_DENIED`]
171-
/// * [`uefi::Status::VOLUME_FULL`]
172-
/// * [`uefi::Status::BAD_BUFFER_SIZE`]
165+
/// * [`Status::UNSUPPORTED`]
166+
/// * [`Status::NO_MEDIA`]
167+
/// * [`Status::DEVICE_ERROR`]
168+
/// * [`Status::VOLUME_CORRUPTED`]
169+
/// * [`Status::WRITE_PROTECTED`]
170+
/// * [`Status::ACCESS_DENIED`]
171+
/// * [`Status::VOLUME_FULL`]
172+
/// * [`Status::BAD_BUFFER_SIZE`]
173173
fn set_info<Info: FileProtocolInfo + ?Sized>(&mut self, info: &Info) -> Result {
174174
let info_ptr = ptr::from_ref(info).cast::<c_void>();
175175
let info_size = size_of_val(info);
@@ -182,12 +182,12 @@ pub trait File: Sized {
182182
///
183183
/// See section `EFI_FILE_PROTOCOL.Flush()` in the UEFI Specification for more details.
184184
///
185-
/// * [`uefi::Status::NO_MEDIA`]
186-
/// * [`uefi::Status::DEVICE_ERROR`]
187-
/// * [`uefi::Status::VOLUME_CORRUPTED`]
188-
/// * [`uefi::Status::WRITE_PROTECTED`]
189-
/// * [`uefi::Status::ACCESS_DENIED`]
190-
/// * [`uefi::Status::VOLUME_FULL`]
185+
/// * [`Status::NO_MEDIA`]
186+
/// * [`Status::DEVICE_ERROR`]
187+
/// * [`Status::VOLUME_CORRUPTED`]
188+
/// * [`Status::WRITE_PROTECTED`]
189+
/// * [`Status::ACCESS_DENIED`]
190+
/// * [`Status::VOLUME_FULL`]
191191
fn flush(&mut self) -> Result {
192192
unsafe { (self.imp().flush)(self.imp()) }.to_result()
193193
}

uefi/src/proto/media/file/regular.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ impl RegularFile {
3737
///
3838
/// See section `EFI_FILE_PROTOCOL.Read()` in the UEFI Specification for more details.
3939
///
40-
/// * [`uefi::Status::NO_MEDIA`]
41-
/// * [`uefi::Status::DEVICE_ERROR`]
42-
/// * [`uefi::Status::VOLUME_CORRUPTED`]
40+
/// * [`Status::NO_MEDIA`]
41+
/// * [`Status::DEVICE_ERROR`]
42+
/// * [`Status::VOLUME_CORRUPTED`]
4343
///
4444
/// # Quirks
4545
///
@@ -91,12 +91,12 @@ impl RegularFile {
9191
///
9292
/// See section `EFI_FILE_PROTOCOL.Write()` in the UEFI Specification for more details.
9393
///
94-
/// * [`uefi::Status::NO_MEDIA`]
95-
/// * [`uefi::Status::DEVICE_ERROR`]
96-
/// * [`uefi::Status::VOLUME_CORRUPTED`]
97-
/// * [`uefi::Status::WRITE_PROTECTED`]
98-
/// * [`uefi::Status::ACCESS_DENIED`]
99-
/// * [`uefi::Status::VOLUME_FULL`]
94+
/// * [`Status::NO_MEDIA`]
95+
/// * [`Status::DEVICE_ERROR`]
96+
/// * [`Status::VOLUME_CORRUPTED`]
97+
/// * [`Status::WRITE_PROTECTED`]
98+
/// * [`Status::ACCESS_DENIED`]
99+
/// * [`Status::VOLUME_FULL`]
100100
pub fn write(&mut self, buffer: &[u8]) -> Result<(), usize> {
101101
let mut buffer_size = buffer.len();
102102
unsafe { (self.imp().write)(self.imp(), &mut buffer_size, buffer.as_ptr().cast()) }
@@ -109,7 +109,7 @@ impl RegularFile {
109109
///
110110
/// See section `EFI_FILE_PROTOCOL.GetPosition()` in the UEFI Specification for more details.
111111
///
112-
/// * [`uefi::Status::DEVICE_ERROR`]
112+
/// * [`Status::DEVICE_ERROR`]
113113
pub fn get_position(&mut self) -> Result<u64> {
114114
let mut pos = 0u64;
115115
unsafe { (self.imp().get_position)(self.imp(), &mut pos) }.to_result_with_val(|| pos)
@@ -129,7 +129,7 @@ impl RegularFile {
129129
///
130130
/// See section `EFI_FILE_PROTOCOL.SetPosition()` in the UEFI Specification for more details.
131131
///
132-
/// * [`uefi::Status::DEVICE_ERROR`]
132+
/// * [`Status::DEVICE_ERROR`]
133133
pub fn set_position(&mut self, position: u64) -> Result {
134134
unsafe { (self.imp().set_position)(self.imp(), position) }.to_result()
135135
}

uefi/src/proto/media/fs.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ use crate::{Result, StatusExt};
88
use core::ptr;
99
use uefi_raw::protocol::file_system::SimpleFileSystemProtocol;
1010

11+
#[cfg(doc)]
12+
use crate::Status;
13+
1114
/// Simple File System [`Protocol`]. Allows access to a FAT-12/16/32 file
1215
/// system.
1316
///
@@ -41,13 +44,13 @@ impl SimpleFileSystem {
4144
/// `EFI_SIMPLE_FILE SYSTEM_PROTOCOL.OpenVolume()` (this has a space in between FILE and
4245
/// SYSTEM; it could be a typo in the UEFI spec).
4346
///
44-
/// * [`uefi::Status::UNSUPPORTED`]
45-
/// * [`uefi::Status::NO_MEDIA`]
46-
/// * [`uefi::Status::DEVICE_ERROR`]
47-
/// * [`uefi::Status::VOLUME_CORRUPTED`]
48-
/// * [`uefi::Status::ACCESS_DENIED`]
49-
/// * [`uefi::Status::OUT_OF_RESOURCES`]
50-
/// * [`uefi::Status::MEDIA_CHANGED`]
47+
/// * [`Status::UNSUPPORTED`]
48+
/// * [`Status::NO_MEDIA`]
49+
/// * [`Status::DEVICE_ERROR`]
50+
/// * [`Status::VOLUME_CORRUPTED`]
51+
/// * [`Status::ACCESS_DENIED`]
52+
/// * [`Status::OUT_OF_RESOURCES`]
53+
/// * [`Status::MEDIA_CHANGED`]
5154
pub fn open_volume(&mut self) -> Result<Directory> {
5255
let mut ptr = ptr::null_mut();
5356
unsafe { (self.0.open_volume)(&mut self.0, &mut ptr) }

0 commit comments

Comments
 (0)