Skip to content

Commit ed80edf

Browse files
committed
deps: update bitflags to 2.1.0
We skip 2.0.0 as it has a bug and "cargo doc" doesn't include generated documentation.
1 parent 023b08d commit ed80edf

File tree

19 files changed

+119
-37
lines changed

19 files changed

+119
-37
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@
5252
- Renamed `CStr8::to_bytes` to `CStr8::as_bytes` and changed the semantics:
5353
The trailing null character is now always included in the returned slice.
5454
- `DevicePathBuilder::with_vec` now clears the `Vec` before use.
55+
- `bitflags` bumped from `1.3` to `2.1`
56+
- `GptPartitionAttributes::RESERVED_FOR_PARTITION_TYPE` replaced by 16
57+
`TYPE_SPECIFIC_BIT_<N>` constants.
5558

5659
## uefi-macros - [Unreleased]
5760

Cargo.lock

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

uefi-raw/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ license = "MPL-2.0"
1212
rust-version = "1.68"
1313

1414
[dependencies]
15-
bitflags = "1.3.1"
15+
bitflags = "2.1"
1616
ptr_meta = { version = "0.2.0", default-features = false }
1717
uefi-macros = "0.11.0"
1818
uguid = "2.0.0"

uefi-raw/src/table/boot.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use bitflags::bitflags;
66
bitflags! {
77
/// Flags describing the capabilities of a memory range.
88
#[repr(transparent)]
9+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
910
pub struct MemoryAttribute: u64 {
1011
/// Supports marking as uncacheable.
1112
const UNCACHEABLE = 0x1;

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: 64 additions & 12 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,86 @@ 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;
9493

9594
/// Mask for bits `48..=63`. The meaning of these bits depends
9695
/// on the partition type.
9796
const RESERVED_FOR_PARTITION_TYPE = 0xffff_0000_0000_0000;
97+
98+
/// The meaning of this bit depends on the partition type.
99+
const TYPE_SPECIFIC_BIT_0 = 1 << 47;
100+
101+
/// The meaning of this bit depends on the partition type.
102+
const TYPE_SPECIFIC_BIT_1 = 1 << 48;
103+
104+
/// The meaning of this bit depends on the partition type.
105+
const TYPE_SPECIFIC_BIT_2 = 1 << 49;
106+
107+
/// The meaning of this bit depends on the partition type.
108+
const TYPE_SPECIFIC_BIT_3 = 1 << 50;
109+
110+
/// The meaning of this bit depends on the partition type.
111+
const TYPE_SPECIFIC_BIT_4 = 1 << 51;
112+
113+
/// The meaning of this bit depends on the partition type.
114+
const TYPE_SPECIFIC_BIT_5 = 1 << 52;
115+
116+
/// The meaning of this bit depends on the partition type.
117+
const TYPE_SPECIFIC_BIT_6 = 1 << 53;
118+
119+
/// The meaning of this bit depends on the partition type.
120+
const TYPE_SPECIFIC_BIT_7 = 1 << 54;
121+
122+
/// The meaning of this bit depends on the partition type.
123+
const TYPE_SPECIFIC_BIT_8 = 1 << 55;
124+
125+
/// The meaning of this bit depends on the partition type.
126+
const TYPE_SPECIFIC_BIT_9 = 1 << 56;
127+
128+
/// The meaning of this bit depends on the partition type.
129+
const TYPE_SPECIFIC_BIT_10 = 1 << 57;
130+
131+
/// The meaning of this bit depends on the partition type.
132+
const TYPE_SPECIFIC_BIT_11 = 1 << 58;
133+
134+
/// The meaning of this bit depends on the partition type.
135+
const TYPE_SPECIFIC_BIT_12 = 1 << 59;
136+
137+
/// The meaning of this bit depends on the partition type.
138+
const TYPE_SPECIFIC_BIT_13 = 1 << 60;
139+
140+
/// The meaning of this bit depends on the partition type.
141+
const TYPE_SPECIFIC_BIT_14 = 1 << 61;
142+
143+
/// The meaning of this bit depends on the partition type.
144+
const TYPE_SPECIFIC_BIT_15 = 1 << 62;
98145
}
99146
}
100147

101148
impl GptPartitionAttributes {
149+
/// Mask for bits `48..=63`. The meaning of these bits depends on the
150+
/// partition type.
151+
pub const PARTITION_TYPE_MASK: u64 = 0xffff_0000_0000_0000;
152+
102153
/// Get bits `48..=63` as a [`u16`]. The meaning of these bits depends
103154
/// on the partition's type (see [`GptPartitionEntry::partition_type_guid`]).
104155
#[must_use]
105156
pub const fn type_specific_bits(&self) -> u16 {
106-
(self.bits >> 48) as u16
157+
(self.0.bits() >> 48) as u16
107158
}
108159
}
109160

@@ -232,7 +283,8 @@ mod tests {
232283

233284
#[test]
234285
fn test_partition_attributes() {
235-
let attr = GptPartitionAttributes::from_bits(0xabcd_0000_0000_0007).unwrap();
286+
let attr: GptPartitionAttributes =
287+
GptPartitionAttributes::from_bits_retain(0xabcd_0000_0000_0007);
236288
assert_eq!(attr.type_specific_bits(), 0xabcd);
237289
}
238290
}

uefi/src/proto/network/pxe.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,7 @@ pub struct MtftpInfo {
829829
// No corresponding type in the UEFI spec, it just uses UINT16.
830830
bitflags! {
831831
/// Flags for UDP read and write operations.
832+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
832833
#[repr(transparent)]
833834
pub struct UdpOpFlags: u16 {
834835
/// Receive a packet sent from any IP address in UDP read operations.
@@ -893,6 +894,7 @@ impl IpFilter {
893894

894895
bitflags! {
895896
/// IP receive filters.
897+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
896898
#[repr(transparent)]
897899
pub struct IpFilters: u8 {
898900
/// Enable the Station IP address.
@@ -1009,6 +1011,7 @@ impl DhcpV4Packet {
10091011
bitflags! {
10101012
/// Represents the 'flags' field for a [`DhcpV4Packet`].
10111013
#[repr(transparent)]
1014+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
10121015
pub struct DhcpV4Flags: u16 {
10131016
/// Should be set when the client cannot receive unicast IP datagrams
10141017
/// 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
.to_result()
134134
} else {
135-
(self.receive_filters)(self, enable.bits, disable.bits, reset_mcast_filter, 0, None)
136-
.to_result()
135+
(self.receive_filters)(
136+
self,
137+
enable.bits(),
138+
disable.bits(),
139+
reset_mcast_filter,
140+
0,
141+
None,
142+
)
143+
.to_result()
137144
}
138145
}
139146

@@ -267,6 +274,7 @@ impl SimpleNetwork {
267274
bitflags! {
268275
/// Flags to pass to receive_filters to enable/disable reception of some kinds of packets.
269276
#[repr(transparent)]
277+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
270278
pub struct ReceiveFlags : u32 {
271279
/// Receive unicast packets.
272280
const UNICAST = 0x01;
@@ -285,6 +293,7 @@ bitflags! {
285293
/// Flags returned by get_interrupt_status to indicate which interrupts have fired on the
286294
/// interface since the last call.
287295
#[repr(transparent)]
296+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
288297
pub struct InterruptStatus : u32 {
289298
/// Packet received.
290299
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.

0 commit comments

Comments
 (0)