|
1 | 1 | use super::{Error, Result};
|
2 | 2 | use core::fmt::Debug;
|
3 | 3 |
|
4 |
| -/// Bit indicating that an UEFI status code is an error |
5 |
| -const ERROR_BIT: usize = 1 << (core::mem::size_of::<usize>() * 8 - 1); |
6 |
| - |
7 |
| -newtype_enum! { |
8 |
| -/// UEFI uses status codes in order to report successes, errors, and warnings. |
9 |
| -/// |
10 |
| -/// The spec allows implementation-specific status codes, so the `Status` |
11 |
| -/// constants are not a comprehensive list of all possible values. |
12 |
| -/// |
13 |
| -/// For a convenient integration into the Rust ecosystem, there are several |
14 |
| -/// methods to convert a Status into a [`uefi::Result`]: |
15 |
| -/// - [`Status::to_result_with`] |
16 |
| -/// - [`Status::to_result_with_val`] |
17 |
| -/// - [`Status::to_result_with_err`] |
18 |
| -#[must_use] |
19 |
| -pub enum Status: usize => { |
20 |
| - /// The operation completed successfully. |
21 |
| - SUCCESS = 0, |
22 |
| - |
23 |
| - /// The string contained characters that could not be rendered and were skipped. |
24 |
| - WARN_UNKNOWN_GLYPH = 1, |
25 |
| - /// The handle was closed, but the file was not deleted. |
26 |
| - WARN_DELETE_FAILURE = 2, |
27 |
| - /// The handle was closed, but the data to the file was not flushed properly. |
28 |
| - WARN_WRITE_FAILURE = 3, |
29 |
| - /// The resulting buffer was too small, and the data was truncated. |
30 |
| - WARN_BUFFER_TOO_SMALL = 4, |
31 |
| - /// The data has not been updated within the timeframe set by local policy. |
32 |
| - WARN_STALE_DATA = 5, |
33 |
| - /// The resulting buffer contains UEFI-compliant file system. |
34 |
| - WARN_FILE_SYSTEM = 6, |
35 |
| - /// The operation will be processed across a system reset. |
36 |
| - WARN_RESET_REQUIRED = 7, |
37 |
| - |
38 |
| - /// The image failed to load. |
39 |
| - LOAD_ERROR = ERROR_BIT | 1, |
40 |
| - /// A parameter was incorrect. |
41 |
| - INVALID_PARAMETER = ERROR_BIT | 2, |
42 |
| - /// The operation is not supported. |
43 |
| - UNSUPPORTED = ERROR_BIT | 3, |
44 |
| - /// The buffer was not the proper size for the request. |
45 |
| - BAD_BUFFER_SIZE = ERROR_BIT | 4, |
46 |
| - /// The buffer is not large enough to hold the requested data. |
47 |
| - /// The required buffer size is returned in the appropriate parameter. |
48 |
| - BUFFER_TOO_SMALL = ERROR_BIT | 5, |
49 |
| - /// There is no data pending upon return. |
50 |
| - NOT_READY = ERROR_BIT | 6, |
51 |
| - /// The physical device reported an error while attempting the operation. |
52 |
| - DEVICE_ERROR = ERROR_BIT | 7, |
53 |
| - /// The device cannot be written to. |
54 |
| - WRITE_PROTECTED = ERROR_BIT | 8, |
55 |
| - /// A resource has run out. |
56 |
| - OUT_OF_RESOURCES = ERROR_BIT | 9, |
57 |
| - /// An inconstency was detected on the file system. |
58 |
| - VOLUME_CORRUPTED = ERROR_BIT | 10, |
59 |
| - /// There is no more space on the file system. |
60 |
| - VOLUME_FULL = ERROR_BIT | 11, |
61 |
| - /// The device does not contain any medium to perform the operation. |
62 |
| - NO_MEDIA = ERROR_BIT | 12, |
63 |
| - /// The medium in the device has changed since the last access. |
64 |
| - MEDIA_CHANGED = ERROR_BIT | 13, |
65 |
| - /// The item was not found. |
66 |
| - NOT_FOUND = ERROR_BIT | 14, |
67 |
| - /// Access was denied. |
68 |
| - ACCESS_DENIED = ERROR_BIT | 15, |
69 |
| - /// The server was not found or did not respond to the request. |
70 |
| - NO_RESPONSE = ERROR_BIT | 16, |
71 |
| - /// A mapping to a device does not exist. |
72 |
| - NO_MAPPING = ERROR_BIT | 17, |
73 |
| - /// The timeout time expired. |
74 |
| - TIMEOUT = ERROR_BIT | 18, |
75 |
| - /// The protocol has not been started. |
76 |
| - NOT_STARTED = ERROR_BIT | 19, |
77 |
| - /// The protocol has already been started. |
78 |
| - ALREADY_STARTED = ERROR_BIT | 20, |
79 |
| - /// The operation was aborted. |
80 |
| - ABORTED = ERROR_BIT | 21, |
81 |
| - /// An ICMP error occurred during the network operation. |
82 |
| - ICMP_ERROR = ERROR_BIT | 22, |
83 |
| - /// A TFTP error occurred during the network operation. |
84 |
| - TFTP_ERROR = ERROR_BIT | 23, |
85 |
| - /// A protocol error occurred during the network operation. |
86 |
| - PROTOCOL_ERROR = ERROR_BIT | 24, |
87 |
| - /// The function encountered an internal version that was |
88 |
| - /// incompatible with a version requested by the caller. |
89 |
| - INCOMPATIBLE_VERSION = ERROR_BIT | 25, |
90 |
| - /// The function was not performed due to a security violation. |
91 |
| - SECURITY_VIOLATION = ERROR_BIT | 26, |
92 |
| - /// A CRC error was detected. |
93 |
| - CRC_ERROR = ERROR_BIT | 27, |
94 |
| - /// Beginning or end of media was reached |
95 |
| - END_OF_MEDIA = ERROR_BIT | 28, |
96 |
| - /// The end of the file was reached. |
97 |
| - END_OF_FILE = ERROR_BIT | 31, |
98 |
| - /// The language specified was invalid. |
99 |
| - INVALID_LANGUAGE = ERROR_BIT | 32, |
100 |
| - /// The security status of the data is unknown or compromised and |
101 |
| - /// the data must be updated or replaced to restore a valid security status. |
102 |
| - COMPROMISED_DATA = ERROR_BIT | 33, |
103 |
| - /// There is an address conflict address allocation |
104 |
| - IP_ADDRESS_CONFLICT = ERROR_BIT | 34, |
105 |
| - /// A HTTP error occurred during the network operation. |
106 |
| - HTTP_ERROR = ERROR_BIT | 35, |
107 |
| -}} |
108 |
| - |
109 |
| -impl Status { |
110 |
| - /// Returns true if status code indicates success. |
111 |
| - #[inline] |
112 |
| - #[must_use] |
113 |
| - pub fn is_success(self) -> bool { |
114 |
| - self == Status::SUCCESS |
115 |
| - } |
116 |
| - |
117 |
| - /// Returns true if status code indicates a warning. |
118 |
| - #[inline] |
119 |
| - #[must_use] |
120 |
| - pub fn is_warning(self) -> bool { |
121 |
| - (self != Status::SUCCESS) && (self.0 & ERROR_BIT == 0) |
122 |
| - } |
123 |
| - |
124 |
| - /// Returns true if the status code indicates an error. |
125 |
| - #[inline] |
126 |
| - #[must_use] |
127 |
| - pub const fn is_error(self) -> bool { |
128 |
| - self.0 & ERROR_BIT != 0 |
129 |
| - } |
130 |
| -} |
| 4 | +pub use uefi_raw::Status; |
131 | 5 |
|
132 | 6 | /// Extension trait which provides some convenience methods for [`Status`].
|
133 | 7 | pub trait StatusExt {
|
@@ -208,12 +82,6 @@ impl StatusExt for Status {
|
208 | 82 | }
|
209 | 83 | }
|
210 | 84 |
|
211 |
| -impl core::fmt::Display for Status { |
212 |
| - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { |
213 |
| - Debug::fmt(self, f) |
214 |
| - } |
215 |
| -} |
216 |
| - |
217 | 85 | #[cfg(test)]
|
218 | 86 | mod tests {
|
219 | 87 | use super::*;
|
|
0 commit comments