Skip to content

Commit f7c9aa7

Browse files
committed
deps: update bitflags to 2.1.0
We skipped 2.0.0 as due to a bug "cargo doc" didn't include generated documentation.
1 parent 3e5240d commit f7c9aa7

File tree

17 files changed

+116
-38
lines changed

17 files changed

+116
-38
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` bumped from `1.3` to `2.1`
34+
- `GptPartitionAttributes::RESERVED_FOR_PARTITION_TYPE` replaced by 16
35+
`TYPE_SPECIFIC_BIT_<N>` constants.
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: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ 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)]
160161
pub struct ControlBits: u32 {
161162
/// Clear to send
162163
const CLEAR_TO_SEND = 0x10;
@@ -186,11 +187,11 @@ bitflags! {
186187
///
187188
/// Up to date as of UEFI 2.7 / Serial protocol v1
188189
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;
190+
ControlBits::DATA_TERMINAL_READY.bits()
191+
| ControlBits::REQUEST_TO_SEND.bits()
192+
| ControlBits::HARDWARE_LOOPBACK_ENABLE.bits()
193+
| ControlBits::SOFTWARE_LOOPBACK_ENABLE.bits()
194+
| ControlBits::HARDWARE_FLOW_CONTROL_ENABLE.bits();
194195
}
195196
}
196197

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: 63 additions & 15 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,7 +65,8 @@ newtype_enum! {
6665
}
6766
}
6867

69-
bitflags! {
68+
bitflags::bitflags! {
69+
7070
/// Attributes describing a GPT partition.
7171
///
7272
/// * Bit 0: [`REQUIRED_PARTITION`][Self::REQUIRED_PARTITION]
@@ -75,35 +75,82 @@ bitflags! {
7575
/// * Bits `3..=47`: reserved for future use and must be zero.
7676
/// * Bits `48..=63`: See
7777
/// [`type_specific_bits`][Self::type_specific_bits] and
78-
/// [`RESERVED_FOR_PARTITION_TYPE`][Self::RESERVED_FOR_PARTITION_TYPE].
79-
#[derive(Default)]
78+
/// [`PARTITION_TYPE_MASK`][Self::PARTITION_TYPE_MASK].
79+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
8080
#[repr(transparent)]
8181
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.
82+
/// Bit: Partition is required for the platform to function.
83+
const REQUIRED_PARTITION = 1;
84+
/// Bit: No [`BlockIO`] protocol will be created for this partition.
8685
///
8786
/// [`BlockIO`]: uefi::proto::media::block::BlockIO
8887
const NO_BLOCK_IO_PROTOCOL = 1 << 1;
8988

90-
/// Indicates that special software on a legacy BIOS system may
89+
/// Bit: Indicates that special software on a legacy BIOS system may
9190
/// treat this partition as bootable. UEFI boot managers must
9291
/// ignore the partition.
93-
const LEGACY_BIOS_BOOTABLE = 1 << 2;
92+
const LEGACY_BIOS_BOOTABLE = 2 << 1;
93+
94+
/// The meaning of this bit depends on the partition type.
95+
const TYPE_SPECIFIC_BIT_1 = 1 << 48;
96+
97+
/// The meaning of this bit depends on the partition type.
98+
const TYPE_SPECIFIC_BIT_2 = 1 << 49;
99+
100+
/// The meaning of this bit depends on the partition type.
101+
const TYPE_SPECIFIC_BIT_3 = 1 << 50;
102+
103+
/// The meaning of this bit depends on the partition type.
104+
const TYPE_SPECIFIC_BIT_4 = 1 << 51;
105+
106+
/// The meaning of this bit depends on the partition type.
107+
const TYPE_SPECIFIC_BIT_5 = 1 << 52;
108+
109+
/// The meaning of this bit depends on the partition type.
110+
const TYPE_SPECIFIC_BIT_6 = 1 << 53;
111+
112+
/// The meaning of this bit depends on the partition type.
113+
const TYPE_SPECIFIC_BIT_7 = 1 << 54;
94114

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;
115+
/// The meaning of this bit depends on the partition type.
116+
const TYPE_SPECIFIC_BIT_8 = 1 << 55;
117+
118+
/// The meaning of this bit depends on the partition type.
119+
const TYPE_SPECIFIC_BIT_9 = 1 << 56;
120+
121+
/// The meaning of this bit depends on the partition type.
122+
const TYPE_SPECIFIC_BIT_10 = 1 << 57;
123+
124+
/// The meaning of this bit depends on the partition type.
125+
const TYPE_SPECIFIC_BIT_11 = 1 << 58;
126+
127+
/// The meaning of this bit depends on the partition type.
128+
const TYPE_SPECIFIC_BIT_12 = 1 << 59;
129+
130+
/// The meaning of this bit depends on the partition type.
131+
const TYPE_SPECIFIC_BIT_13 = 1 << 60;
132+
133+
/// The meaning of this bit depends on the partition type.
134+
const TYPE_SPECIFIC_BIT_14 = 1 << 61;
135+
136+
/// The meaning of this bit depends on the partition type.
137+
const TYPE_SPECIFIC_BIT_15 = 1 << 62;
138+
139+
/// The meaning of this bit depends on the partition type.
140+
const TYPE_SPECIFIC_BIT_16 = 1 << 63;
98141
}
99142
}
100143

101144
impl GptPartitionAttributes {
145+
/// Mask for bits `48..=63`. The meaning of these bits depends on the
146+
/// partition type.
147+
pub const PARTITION_TYPE_MASK: u64 = 0xffff_0000_0000_0000;
148+
102149
/// Get bits `48..=63` as a [`u16`]. The meaning of these bits depends
103150
/// on the partition's type (see [`GptPartitionEntry::partition_type_guid`]).
104151
#[must_use]
105152
pub const fn type_specific_bits(&self) -> u16 {
106-
(self.bits >> 48) as u16
153+
(self.0.bits() >> 48) as u16
107154
}
108155
}
109156

@@ -232,7 +279,8 @@ mod tests {
232279

233280
#[test]
234281
fn test_partition_attributes() {
235-
let attr = GptPartitionAttributes::from_bits(0xabcd_0000_0000_0007).unwrap();
282+
let attr: GptPartitionAttributes =
283+
GptPartitionAttributes::from_bits(0xabcd_0000_0000_0007).unwrap();
236284
assert_eq!(attr.type_specific_bits(), 0xabcd);
237285
}
238286
}

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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+
HashAlgorithm::from_bits_retain(u32::from(self.hash_algorithm_bitmap))
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.

0 commit comments

Comments
 (0)