Skip to content

Commit f6590ff

Browse files
committed
deps: update bitflags to 2.1.0
We skiped 2.0.0 as due to a bug "cargo doc" didn't include generated documentation.
1 parent 9777fd4 commit f6590ff

File tree

17 files changed

+91
-58
lines changed

17 files changed

+91
-58
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
- `Image::get_image_file_system` now returns a `fs::FileSystem` instead of the
3131
protocol.
3232
- `CString16::default` now always contains a null character.
33+
- `bitflags` updated to from `1.3` to `2.1`
34+
- `GptPartitionAttributes` is now longer constructed by `bitflags` but uses
35+
custom implementation
3336

3437
## uefi-macros - [Unreleased]
3538

Cargo.lock

Lines changed: 12 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

uefi/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ panic-on-logger-errors = []
2424
unstable = []
2525

2626
[dependencies]
27-
bitflags = "1.3.1"
27+
bitflags = "2.1.0"
2828
derive_more = { version = "0.99.17", features = ["display"] }
2929
log = { version = "0.4.5", default-features = false }
3030
ptr_meta = { version = "0.2.0", default-features = false }

uefi/src/proto/console/serial.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ bitflags! {
157157
///
158158
/// [RS-232]: https://en.wikipedia.org/wiki/RS-232
159159
#[repr(transparent)]
160+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
161+
160162
pub struct ControlBits: u32 {
161163
/// Clear to send
162164
const CLEAR_TO_SEND = 0x10;
@@ -186,11 +188,11 @@ bitflags! {
186188
///
187189
/// Up to date as of UEFI 2.7 / Serial protocol v1
188190
const SETTABLE =
189-
ControlBits::DATA_TERMINAL_READY.bits
190-
| ControlBits::REQUEST_TO_SEND.bits
191-
| ControlBits::HARDWARE_LOOPBACK_ENABLE.bits
192-
| ControlBits::SOFTWARE_LOOPBACK_ENABLE.bits
193-
| ControlBits::HARDWARE_FLOW_CONTROL_ENABLE.bits;
191+
ControlBits::DATA_TERMINAL_READY.bits()
192+
| ControlBits::REQUEST_TO_SEND.bits()
193+
| ControlBits::HARDWARE_LOOPBACK_ENABLE.bits()
194+
| ControlBits::SOFTWARE_LOOPBACK_ENABLE.bits()
195+
| ControlBits::HARDWARE_FLOW_CONTROL_ENABLE.bits();
194196
}
195197
}
196198

uefi/src/proto/device_path/device_path_gen.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2401,7 +2401,7 @@ pub mod messaging {
24012401

24022402
}
24032403

2404-
bitflags! { # [doc = " Flags to identify/manage InfiniBand elements."] # [repr (transparent)] pub struct InfinibandResourceFlags : u32 { # [doc = " Set = service, unset = IOC."] const SERVICE = 0x0000_0001 ; # [doc = " Extended boot environment."] const EXTENDED_BOOT_ENVIRONMENT = 0x0000_0002 ; # [doc = " Console protocol."] const CONSOLE_PROTOCOL = 0x0000_0004 ; # [doc = " Storage protocol."] const STORAGE_PROTOCOL = 0x0000_0008 ; # [doc = " Network protocol."] const NETWORK_PROTOCOL = 0x0000_0010 ; }
2404+
bitflags! { # [doc = " Flags to identify/manage InfiniBand elements."] # [derive (Clone , Copy , Debug , Default , PartialEq , Eq , PartialOrd , Ord)] # [repr (transparent)] pub struct InfinibandResourceFlags : u32 { # [doc = " Set = service, unset = IOC."] const SERVICE = 0x0000_0001 ; # [doc = " Extended boot environment."] const EXTENDED_BOOT_ENVIRONMENT = 0x0000_0002 ; # [doc = " Console protocol."] const CONSOLE_PROTOCOL = 0x0000_0004 ; # [doc = " Storage protocol."] const STORAGE_PROTOCOL = 0x0000_0008 ; # [doc = " Network protocol."] const NETWORK_PROTOCOL = 0x0000_0010 ; }
24052405

24062406
}
24072407

@@ -2417,7 +2417,7 @@ pub mod messaging {
24172417

24182418
}
24192419

2420-
bitflags! { # [doc = " iSCSI login options."] # [repr (transparent)] pub struct IscsiLoginOptions : u16 { # [doc = " Header digest using CRC32. If not set, no header digest."] const HEADER_DIGEST_USING_CRC32 = 0x0002 ; # [doc = " Data digest using CRC32. If not set, no data digest."] const DATA_DIGEST_USING_CRC32 = 0x0008 ; # [doc = " Auth method none. If not set, auth method CHAP."] const AUTH_METHOD_NONE = 0x0800 ; # [doc = " CHAP UNI. If not set, CHAP BI."] const CHAP_UNI = 0x1000 ; }
2420+
bitflags! { # [doc = " iSCSI login options."] # [derive (Clone , Copy , Debug , Default , PartialEq , Eq , PartialOrd , Ord)] # [repr (transparent)] pub struct IscsiLoginOptions : u16 { # [doc = " Header digest using CRC32. If not set, no header digest."] const HEADER_DIGEST_USING_CRC32 = 0x0002 ; # [doc = " Data digest using CRC32. If not set, no data digest."] const DATA_DIGEST_USING_CRC32 = 0x0008 ; # [doc = " Auth method none. If not set, auth method CHAP."] const AUTH_METHOD_NONE = 0x0800 ; # [doc = " CHAP UNI. If not set, CHAP BI."] const CHAP_UNI = 0x1000 ; }
24212421

24222422
}
24232423

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ pub enum FileMode {
394394

395395
bitflags! {
396396
/// Attributes describing the properties of a file on the file system.
397+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
397398
#[repr(transparent)]
398399
pub struct FileAttribute: u64 {
399400
/// File can only be opened in [`FileMode::READ`] mode.

uefi/src/proto/media/partition.rs

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
33
use crate::proto::unsafe_protocol;
44
use crate::{guid, Char16, Guid};
5-
use bitflags::bitflags;
65

76
newtype_enum! {
87
/// MBR OS type.
@@ -66,44 +65,47 @@ newtype_enum! {
6665
}
6766
}
6867

69-
bitflags! {
70-
/// Attributes describing a GPT partition.
71-
///
72-
/// * Bit 0: [`REQUIRED_PARTITION`][Self::REQUIRED_PARTITION]
73-
/// * Bit 1: [`NO_BLOCK_IO_PROTOCOL`][Self::NO_BLOCK_IO_PROTOCOL]
74-
/// * Bit 2: [`LEGACY_BIOS_BOOTABLE`][Self::LEGACY_BIOS_BOOTABLE]
75-
/// * Bits `3..=47`: reserved for future use and must be zero.
76-
/// * Bits `48..=63`: See
77-
/// [`type_specific_bits`][Self::type_specific_bits] and
78-
/// [`RESERVED_FOR_PARTITION_TYPE`][Self::RESERVED_FOR_PARTITION_TYPE].
79-
#[derive(Default)]
80-
#[repr(transparent)]
81-
pub struct GptPartitionAttributes: u64 {
82-
/// Partition is required for the platform to function.
83-
const REQUIRED_PARTITION = 1 << 0;
84-
85-
/// No [`BlockIO`] protocol will be created for this partition.
86-
///
87-
/// [`BlockIO`]: uefi::proto::media::block::BlockIO
88-
const NO_BLOCK_IO_PROTOCOL = 1 << 1;
89-
90-
/// Indicates that special software on a legacy BIOS system may
91-
/// treat this partition as bootable. UEFI boot managers must
92-
/// ignore the partition.
93-
const LEGACY_BIOS_BOOTABLE = 1 << 2;
94-
95-
/// Mask for bits `48..=63`. The meaning of these bits depends
96-
/// on the partition type.
97-
const RESERVED_FOR_PARTITION_TYPE = 0xffff_0000_0000_0000;
68+
/// Attributes describing a GPT partition.
69+
///
70+
/// * Bit 0: [`REQUIRED_PARTITION`][Self::REQUIRED_PARTITION]
71+
/// * Bit 1: [`NO_BLOCK_IO_PROTOCOL`][Self::NO_BLOCK_IO_PROTOCOL]
72+
/// * Bit 2: [`LEGACY_BIOS_BOOTABLE`][Self::LEGACY_BIOS_BOOTABLE]
73+
/// * Bits `3..=47`: reserved for future use and must be zero.
74+
/// * Bits `48..=63`: See
75+
/// [`type_specific_bits`][Self::type_specific_bits] and
76+
/// [`PARTITION_TYPE_MASK`][Self::PARTITION_TYPE_MASK].
77+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
78+
#[repr(transparent)]
79+
pub struct GptPartitionAttributes(u64);
80+
81+
impl From<u64> for GptPartitionAttributes {
82+
fn from(value: u64) -> Self {
83+
Self(value)
9884
}
9985
}
10086

10187
impl GptPartitionAttributes {
88+
/// Bit: Partition is required for the platform to function.
89+
pub const REQUIRED_PARTITION: u64 = 1;
90+
/// Bit: No [`BlockIO`] protocol will be created for this partition.
91+
///
92+
/// [`BlockIO`]: uefi::proto::media::block::BlockIO
93+
pub const NO_BLOCK_IO_PROTOCOL: u64 = 1 << 1;
94+
95+
/// Bit: Indicates that special software on a legacy BIOS system may
96+
/// treat this partition as bootable. UEFI boot managers must
97+
/// ignore the partition.
98+
pub const LEGACY_BIOS_BOOTABLE: u64 = 2 << 1;
99+
100+
/// Bit: Mask for bits `48..=63`. The meaning of these bits depends
101+
/// on the partition type.
102+
pub const PARTITION_TYPE_MASK: u64 = 0xffff_0000_0000_0000;
103+
102104
/// Get bits `48..=63` as a [`u16`]. The meaning of these bits depends
103105
/// on the partition's type (see [`GptPartitionEntry::partition_type_guid`]).
104106
#[must_use]
105-
pub const fn type_specific_bits(&self) -> u16 {
106-
(self.bits >> 48) as u16
107+
pub const fn partition_type(&self) -> u16 {
108+
(self.0 >> 48) as u16
107109
}
108110
}
109111

@@ -232,7 +234,7 @@ mod tests {
232234

233235
#[test]
234236
fn test_partition_attributes() {
235-
let attr = GptPartitionAttributes::from_bits(0xabcd_0000_0000_0007).unwrap();
236-
assert_eq!(attr.type_specific_bits(), 0xabcd);
237+
let attr = GptPartitionAttributes::from(0xabcd_0000_0000_0007);
238+
assert_eq!(attr.partition_type(), 0xabcd);
237239
}
238240
}

uefi/src/proto/network/pxe.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,7 @@ pub struct MtftpInfo {
839839
// No corresponding type in the UEFI spec, it just uses UINT16.
840840
bitflags! {
841841
/// Flags for UDP read and write operations.
842+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
842843
#[repr(transparent)]
843844
pub struct UdpOpFlags: u16 {
844845
/// Receive a packet sent from any IP address in UDP read operations.
@@ -903,6 +904,7 @@ impl IpFilter {
903904

904905
bitflags! {
905906
/// IP receive filters.
907+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
906908
#[repr(transparent)]
907909
pub struct IpFilters: u8 {
908910
/// Enable the Station IP address.
@@ -1019,6 +1021,7 @@ impl DhcpV4Packet {
10191021
bitflags! {
10201022
/// Represents the 'flags' field for a [`DhcpV4Packet`].
10211023
#[repr(transparent)]
1024+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
10221025
pub struct DhcpV4Flags: u16 {
10231026
/// Should be set when the client cannot receive unicast IP datagrams
10241027
/// until its protocol software has been configured with an IP address.

uefi/src/proto/network/snp.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,23 @@ impl SimpleNetwork {
124124
if let Some(mcast_filter) = mcast_filter {
125125
(self.receive_filters)(
126126
self,
127-
enable.bits,
128-
disable.bits,
127+
enable.bits(),
128+
disable.bits(),
129129
reset_mcast_filter,
130130
mcast_filter.len(),
131131
NonNull::new(mcast_filter.as_ptr() as *mut _),
132132
)
133133
.into()
134134
} else {
135-
(self.receive_filters)(self, enable.bits, disable.bits, reset_mcast_filter, 0, None)
136-
.into()
135+
(self.receive_filters)(
136+
self,
137+
enable.bits(),
138+
disable.bits(),
139+
reset_mcast_filter,
140+
0,
141+
None,
142+
)
143+
.into()
137144
}
138145
}
139146

@@ -272,6 +279,7 @@ impl SimpleNetwork {
272279
bitflags! {
273280
/// Flags to pass to receive_filters to enable/disable reception of some kinds of packets.
274281
#[repr(transparent)]
282+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
275283
pub struct ReceiveFlags : u32 {
276284
/// Receive unicast packets.
277285
const UNICAST = 0x01;
@@ -290,6 +298,7 @@ bitflags! {
290298
/// Flags returned by get_interrupt_status to indicate which interrupts have fired on the
291299
/// interface since the last call.
292300
#[repr(transparent)]
301+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
293302
pub struct InterruptStatus : u32 {
294303
/// Packet received.
295304
const RECEIVE = 0x01;

uefi/src/proto/pi/mp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ bitflags! {
2525
/// Flags indicating if the processor is BSP or AP,
2626
/// if the processor is enabled or disabled, and if
2727
/// the processor is healthy.
28-
#[derive(Default)]
2928
#[repr(transparent)]
29+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
3030
struct StatusFlag: u32 {
3131
/// Processor is playing the role of BSP.
3232
const PROCESSOR_AS_BSP_BIT = 1;

uefi/src/proto/tcg/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ bitflags! {
2828
/// Hash algorithms the protocol can provide.
2929
///
3030
/// The [`v1`] protocol only supports SHA1.
31-
#[derive(Default)]
31+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
3232
#[repr(transparent)]
3333
pub struct HashAlgorithm: u32 {
3434
/// SHA-1 hash.

uefi/src/proto/tcg/v1.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::util::{ptr_write_unaligned_and_add, usize_from_u32};
1616
use crate::{Error, Result, Status};
1717
use core::fmt::{self, Debug, Formatter};
1818
use core::marker::PhantomData;
19-
use core::mem::{self, MaybeUninit};
19+
use core::mem::{self, transmute, MaybeUninit};
2020
use core::ptr;
2121
use ptr_meta::Pointee;
2222

@@ -60,7 +60,7 @@ impl BootServiceCapability {
6060
pub fn hash_algorithm(&self) -> HashAlgorithm {
6161
// Safety: the value should always be 0x1 (indicating SHA-1), but
6262
// we don't care if it's some unexpected value.
63-
unsafe { HashAlgorithm::from_bits_unchecked(u32::from(self.hash_algorithm_bitmap)) }
63+
unsafe { transmute(self.hash_algorithm_bitmap as u32) }
6464
}
6565

6666
/// Whether the TPM device is present.

uefi/src/proto/tcg/v2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ bitflags! {
3838
/// Event log formats supported by the firmware.
3939
///
4040
/// Corresponds to the C typedef `EFI_TCG2_EVENT_ALGORITHM_BITMAP`.
41-
#[derive(Default)]
41+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
4242
#[repr(transparent)]
4343
pub struct EventLogFormat: u32 {
4444
/// Firmware supports the SHA-1 log format.
@@ -125,7 +125,7 @@ impl BootServiceCapability {
125125

126126
bitflags! {
127127
/// Flags for the [`Tcg::hash_log_extend_event`] function.
128-
#[derive(Default)]
128+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
129129
#[repr(transparent)]
130130
pub struct HashLogExtendEventFlags: u64 {
131131
/// Extend an event but don't log it.

uefi/src/table/boot.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1932,6 +1932,7 @@ impl Align for MemoryDescriptor {
19321932
bitflags! {
19331933
/// Flags describing the capabilities of a memory range.
19341934
#[repr(transparent)]
1935+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
19351936
pub struct MemoryAttribute: u64 {
19361937
/// Supports marking as uncacheable.
19371938
const UNCACHEABLE = 0x1;
@@ -2169,6 +2170,7 @@ impl<'guid> SearchType<'guid> {
21692170
bitflags! {
21702171
/// Flags describing the type of an UEFI event and its attributes.
21712172
#[repr(transparent)]
2173+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
21722174
pub struct EventType: u32 {
21732175
/// The event is a timer event and may be passed to `BootServices::set_timer()`
21742176
/// Note that timers only function during boot services time.

uefi/src/table/cfg.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ pub struct PropertiesTable {
6464
bitflags! {
6565
/// Flags describing memory protection.
6666
#[repr(transparent)]
67+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
6768
pub struct MemoryProtectionAttribute: usize {
6869
/// If this bit is set, then the UEFI implementation will mark pages
6970
/// containing data as non-executable.

uefi/src/table/runtime.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ pub struct TimeParams {
369369
bitflags! {
370370
/// A bitmask containing daylight savings time information.
371371
#[repr(transparent)]
372+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
372373
pub struct Daylight: u8 {
373374
/// Time is affected by daylight savings time.
374375
const ADJUST_DAYLIGHT = 0x01;
@@ -586,6 +587,7 @@ pub struct TimeCapabilities {
586587
bitflags! {
587588
/// Flags describing the attributes of a variable.
588589
#[repr(transparent)]
590+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
589591
pub struct VariableAttributes: u32 {
590592
/// Variable is maintained across a power cycle.
591593
const NON_VOLATILE = 0x01;

0 commit comments

Comments
 (0)