Skip to content

Commit f637bc5

Browse files
Add Revision constants
Add constants for all the EFI versions (from section 4.3 "EFI System Table").
1 parent d2f0b3d commit f637bc5

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/table/revision.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,27 @@ use core::fmt;
99
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
1010
pub struct Revision(u32);
1111

12+
// Allow missing docs, there's nothing useful to document about these
13+
// constants.
14+
#[allow(missing_docs)]
15+
// Allow consistent formatting of the values.
16+
#[allow(clippy::identity_op)]
17+
impl Revision {
18+
pub const EFI_1_02: Self = Self((1 << 16) | (2));
19+
pub const EFI_1_10: Self = Self((1 << 16) | (10));
20+
pub const EFI_2_00: Self = Self((2 << 16) | (00));
21+
pub const EFI_2_10: Self = Self((2 << 16) | (10));
22+
pub const EFI_2_20: Self = Self((2 << 16) | (20));
23+
pub const EFI_2_30: Self = Self((2 << 16) | (30));
24+
pub const EFI_2_31: Self = Self((2 << 16) | (31));
25+
pub const EFI_2_40: Self = Self((2 << 16) | (40));
26+
pub const EFI_2_50: Self = Self((2 << 16) | (50));
27+
pub const EFI_2_60: Self = Self((2 << 16) | (60));
28+
pub const EFI_2_70: Self = Self((2 << 16) | (70));
29+
pub const EFI_2_80: Self = Self((2 << 16) | (80));
30+
pub const EFI_2_90: Self = Self((2 << 16) | (90));
31+
}
32+
1233
impl Revision {
1334
/// Creates a new revision.
1435
pub fn new(major: u16, minor: u16) -> Self {
@@ -35,3 +56,17 @@ impl fmt::Debug for Revision {
3556
write!(f, "{}.{}.{}", major, minor / 10, minor % 10)
3657
}
3758
}
59+
60+
#[cfg(test)]
61+
mod tests {
62+
use super::*;
63+
64+
#[test]
65+
fn test_revision() {
66+
let rev = Revision::EFI_2_31;
67+
assert_eq!(rev.major(), 2);
68+
assert_eq!(rev.minor(), 31);
69+
70+
assert!(Revision::EFI_1_10 < Revision::EFI_2_00);
71+
}
72+
}

0 commit comments

Comments
 (0)