Skip to content

Commit 38f2c3a

Browse files
phip1611nicholasbishop
authored andcommitted
uefi-raw: derive all the things
1 parent ac46bf0 commit 38f2c3a

File tree

6 files changed

+13
-10
lines changed

6 files changed

+13
-10
lines changed

uefi-raw/src/capsule.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use bitflags::bitflags;
88

99
/// Descriptor that defines a scatter-gather list for passing a set of capsules
1010
/// to the firmware.
11-
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
11+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
1212
#[repr(C)]
1313
pub struct CapsuleBlockDescriptor {
1414
/// Size in bytes of the data block. If zero, the block is treated as a
@@ -30,7 +30,7 @@ bitflags! {
3030
/// Capsule update flags.
3131
///
3232
/// The meaning of bits `0..=15` are defined by the capsule GUID.
33-
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
33+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
3434
#[repr(transparent)]
3535
pub struct CapsuleFlags: u32 {
3636
/// The meaning of this bit depends on the capsule GUID.
@@ -104,7 +104,7 @@ bitflags! {
104104
}
105105

106106
/// Common header at the start of a capsule.
107-
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
107+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
108108
#[repr(C)]
109109
pub struct CapsuleHeader {
110110
/// GUID that defines the type of data in the capsule.

uefi-raw/src/protocol/device_path.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ use crate::{guid, Guid};
77
///
88
/// Note that the fields in this struct define the header at the start of each
99
/// node; a device path is typically larger than these four bytes.
10+
#[derive(Debug)]
1011
#[repr(C)]
1112
pub struct DevicePathProtocol {
1213
pub major_type: u8,
1314
pub sub_type: u8,
1415
pub length: [u8; 2],
16+
// followed by payload (dynamically sized)
1517
}
1618

1719
impl DevicePathProtocol {

uefi-raw/src/table/boot.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,8 @@ pub struct BootServices {
214214

215215
bitflags! {
216216
/// Flags describing the type of an UEFI event and its attributes.
217+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
217218
#[repr(transparent)]
218-
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
219219
pub struct EventType: u32 {
220220
/// The event is a timer event and may be passed to `BootServices::set_timer()`
221221
/// Note that timers only function during boot services time.
@@ -260,7 +260,7 @@ pub type EventNotifyFn = unsafe extern "efiapi" fn(event: Event, context: *mut c
260260
bitflags! {
261261
/// Flags describing the capabilities of a memory range.
262262
#[repr(transparent)]
263-
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
263+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
264264
pub struct MemoryAttribute: u64 {
265265
/// Supports marking as uncacheable.
266266
const UNCACHEABLE = 0x1;
@@ -309,7 +309,7 @@ bitflags! {
309309
}
310310

311311
/// A structure describing a region of memory.
312-
#[derive(Debug, Copy, Clone)]
312+
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
313313
#[repr(C)]
314314
pub struct MemoryDescriptor {
315315
/// Type of memory occupying this range.
@@ -348,6 +348,7 @@ newtype_enum! {
348348
/// in the 0x70000000..0xFFFFFFFF range. Therefore, we don't know the full set
349349
/// of memory types at compile time, and it is _not_ safe to model this C enum
350350
/// as a Rust enum.
351+
#[derive(PartialOrd, Ord, Hash)]
351352
pub enum MemoryType: u32 => {
352353
/// This enum variant is not used.
353354
RESERVED = 0,

uefi-raw/src/table/header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use super::Revision;
22

33
/// The common header that all UEFI tables begin with.
4-
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
4+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
55
#[repr(C)]
66
pub struct Header {
77
/// Unique identifier for this table.

uefi-raw/src/table/revision.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use core::fmt;
3030
/// assert_eq!(Revision::EFI_2_31.to_string(), "2.3.1");
3131
/// assert_eq!(Revision::EFI_2_100.to_string(), "2.10");
3232
/// ```
33-
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, Ord, PartialOrd)]
33+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
3434
#[repr(transparent)]
3535
pub struct Revision(pub u32);
3636

uefi-raw/src/table/runtime.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ newtype_enum! {
101101
}
102102

103103
/// Real time clock capabilities.
104-
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
104+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
105105
#[repr(C)]
106106
pub struct TimeCapabilities {
107107
/// Reporting resolution of the clock in counts per second. 1 for a normal
@@ -119,7 +119,7 @@ pub struct TimeCapabilities {
119119
bitflags! {
120120
/// Flags describing the attributes of a variable.
121121
#[repr(transparent)]
122-
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
122+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
123123
pub struct VariableAttributes: u32 {
124124
/// Variable is maintained across a power cycle.
125125
const NON_VOLATILE = 0x01;

0 commit comments

Comments
 (0)