Skip to content

Commit 09fd4ce

Browse files
authored
Merge pull request #147 from rust-osdev/dev2
tree-wide: streamline default derives (also Hash everywhere)
2 parents 310b103 + 85b1d83 commit 09fd4ce

24 files changed

+37
-37
lines changed

multiboot2-header/src/address.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use core::mem::size_of;
55
/// format, but it must be provided if the image is in a.out format or in some
66
/// other format. Required for legacy boot (BIOS).
77
/// Determines load addresses.
8-
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
8+
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
99
#[repr(C)]
1010
pub struct AddressHeaderTag {
1111
typ: HeaderTagType,

multiboot2-header/src/console.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub enum ConsoleHeaderTagFlags {
1313

1414
/// Tells that a console must be available in MBI.
1515
/// Only relevant for legacy BIOS.
16-
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
16+
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
1717
#[repr(C)]
1818
pub struct ConsoleHeaderTag {
1919
typ: HeaderTagType,

multiboot2-header/src/end.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::{HeaderTagFlag, HeaderTagType};
22
use core::mem::size_of;
33

44
/// Terminates a list of optional tags in a Multiboot2 header.
5-
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
5+
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
66
#[repr(C)]
77
pub struct EndHeaderTag {
88
// u16 value

multiboot2-header/src/entry_address.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use core::mem::size_of;
55

66
/// Specifies the physical address to which the boot loader should jump in
77
/// order to start running the operating system. Not needed for ELF files.
8-
#[derive(Copy, Clone, PartialEq, Eq)]
8+
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
99
#[repr(C)]
1010
pub struct EntryAddressHeaderTag {
1111
typ: HeaderTagType,

multiboot2-header/src/entry_efi_32.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use core::mem::size_of;
99
///
1010
/// Technically, this is equivalent to the [`crate::EntryAddressHeaderTag`] but with a different
1111
/// [`crate::HeaderTagType`].
12-
#[derive(Copy, Clone, PartialEq, Eq)]
12+
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
1313
#[repr(C)]
1414
pub struct EntryEfi32HeaderTag {
1515
typ: HeaderTagType,

multiboot2-header/src/entry_efi_64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use core::mem::size_of;
99
///
1010
/// Technically, this is equivalent to the [`crate::EntryAddressHeaderTag`] but with a different
1111
/// [`crate::HeaderTagType`].
12-
#[derive(Copy, Clone, PartialEq, Eq)]
12+
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
1313
#[repr(C)]
1414
pub struct EntryEfi64HeaderTag {
1515
typ: HeaderTagType,

multiboot2-header/src/framebuffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use core::mem::size_of;
55
/// is present the bootloader assumes that the payload
66
/// has framebuffer support. Note: This is only a
77
/// recommended mode. Only relevant on legacy BIOS.
8-
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
8+
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
99
#[repr(C)]
1010
pub struct FramebufferHeaderTag {
1111
typ: HeaderTagType,

multiboot2-header/src/header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ impl core::error::Error for LoadError {}
226226
///
227227
/// The "basic" Multiboot2 header. This means only the properties, that are known during
228228
/// compile time. All other information are derived during runtime from the size property.
229-
#[derive(Copy, Clone, PartialEq, Eq)]
229+
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
230230
#[repr(C)]
231231
pub struct Multiboot2BasicHeader {
232232
/// Must be the value of [`MULTIBOOT2_HEADER_MAGIC`].

multiboot2-header/src/information_request.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use multiboot2::TagType;
88

99
/// Specifies what specific tag types the bootloader should provide
1010
/// inside the mbi.
11-
#[derive(Copy, Clone, PartialEq, Eq)]
11+
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
1212
#[repr(C)]
1313
pub struct InformationRequestHeaderTag<const N: usize> {
1414
typ: HeaderTagType,

multiboot2-header/src/module_align.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::{HeaderTagFlag, HeaderTagType};
22
use core::mem::size_of;
33

44
/// If this tag is present, provided boot modules must be page aligned.
5-
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
5+
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
66
#[repr(C)]
77
pub struct ModuleAlignHeaderTag {
88
typ: HeaderTagType,

multiboot2-header/src/relocatable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub enum RelocatableHeaderTagPreference {
1919
}
2020

2121
/// This tag indicates that the image is relocatable.
22-
#[derive(Copy, Clone, PartialEq, Eq)]
22+
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
2323
#[repr(C)]
2424
pub struct RelocatableHeaderTag {
2525
typ: HeaderTagType,

multiboot2-header/src/tags.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub enum HeaderTagFlag {
6363
/// Common properties for all header tags. Other tags may have additional fields
6464
/// that depend on the `typ` and the `size` field. All tags share the same beginning of the
6565
/// struct.
66-
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
66+
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
6767
#[repr(C)]
6868
pub struct HeaderTag {
6969
// u16 value

multiboot2-header/src/uefi_bs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use core::mem::size_of;
33

44
/// This tag indicates that payload supports starting without terminating UEFI boot services.
55
/// Or in other words: The payload wants to use UEFI boot services.
6-
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
6+
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
77
#[repr(C)]
88
pub struct EfiBootServiceHeaderTag {
99
typ: HeaderTagType,

multiboot2/src/boot_loader_name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use {
1212
const METADATA_SIZE: usize = size_of::<TagTypeId>() + size_of::<u32>();
1313

1414
/// The bootloader name tag.
15-
#[derive(ptr_meta::Pointee, PartialEq, Eq)]
15+
#[derive(ptr_meta::Pointee, PartialEq, Eq, PartialOrd, Ord, Hash)]
1616
#[repr(C)]
1717
pub struct BootLoaderNameTag {
1818
typ: TagTypeId,

multiboot2/src/command_line.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub(crate) const METADATA_SIZE: usize = mem::size_of::<TagTypeId>() + mem::size_
1818
///
1919
/// The string is a normal C-style UTF-8 zero-terminated string that can be
2020
/// obtained via the `command_line` method.
21-
#[derive(ptr_meta::Pointee, PartialEq, Eq)]
21+
#[derive(ptr_meta::Pointee, PartialEq, Eq, PartialOrd, Ord, Hash)]
2222
#[repr(C)]
2323
pub struct CommandLineTag {
2424
typ: TagTypeId,

multiboot2/src/efi.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use core::mem::size_of;
99
use crate::builder::traits::StructAsBytes;
1010

1111
/// EFI system table in 32 bit mode
12-
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
12+
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
1313
#[repr(C)]
1414
pub struct EFISdt32 {
1515
typ: TagTypeId,
@@ -41,7 +41,7 @@ impl StructAsBytes for EFISdt32 {
4141
}
4242

4343
/// EFI system table in 64 bit mode
44-
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
44+
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
4545
#[repr(C)]
4646
pub struct EFISdt64 {
4747
typ: TagTypeId,
@@ -73,7 +73,7 @@ impl StructAsBytes for EFISdt64 {
7373
}
7474

7575
/// Contains pointer to boot loader image handle.
76-
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
76+
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
7777
#[repr(C)]
7878
pub struct EFIImageHandle32 {
7979
typ: TagTypeId,
@@ -105,7 +105,7 @@ impl StructAsBytes for EFIImageHandle32 {
105105
}
106106

107107
/// Contains pointer to boot loader image handle.
108-
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
108+
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
109109
#[repr(C)]
110110
pub struct EFIImageHandle64 {
111111
typ: TagTypeId,

multiboot2/src/elf_sections.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl Default for ElfSectionIter {
142142
}
143143

144144
/// A single generic ELF Section.
145-
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
145+
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
146146
pub struct ElfSection {
147147
inner: *const u8,
148148
string_section: *const u8,

multiboot2/src/framebuffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ impl PartialEq for FramebufferTag {
220220
}
221221

222222
/// Helper struct for [`FramebufferType`].
223-
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
223+
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
224224
#[repr(u8)]
225225
#[allow(clippy::upper_case_acronyms)]
226226
enum FramebufferTypeId {

multiboot2/src/image_load_addr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use {
77

88
/// If the image has relocatable header tag, this tag contains the image's
99
/// base physical address.
10-
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
10+
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
1111
#[repr(C)]
1212
pub struct ImageLoadPhysAddr {
1313
typ: TagTypeId,

multiboot2/src/memory_map.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl StructAsBytes for MemoryMapTag {
8080
}
8181

8282
/// A memory area entry descriptor.
83-
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
83+
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
8484
#[repr(C)]
8585
pub struct MemoryArea {
8686
base_addr: u64,
@@ -190,7 +190,7 @@ impl<'a> Iterator for MemoryAreaIter<'a> {
190190
/// (which had a 24-bit address bus) could use, historically.
191191
/// Nowadays, much bigger chunks of continuous memory are available at higher
192192
/// addresses, but the Multiboot standard still references those two terms.
193-
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
193+
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
194194
#[repr(C)]
195195
pub struct BasicMemoryInfoTag {
196196
typ: TagTypeId,
@@ -298,7 +298,7 @@ impl StructAsBytes for EFIMemoryDesc {
298298
}
299299

300300
/// EFI ExitBootServices was not called
301-
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
301+
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
302302
#[repr(C)]
303303
pub struct EFIBootServicesNotExited {
304304
typ: TagTypeId,

multiboot2/src/module.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const METADATA_SIZE: usize = size_of::<TagTypeId>() + 3 * size_of::<u32>();
1414

1515
/// This tag indicates to the kernel what boot module was loaded along with
1616
/// the kernel image, and where it can be found.
17-
#[derive(ptr_meta::Pointee, PartialEq, Eq)]
17+
#[derive(ptr_meta::Pointee, PartialEq, Eq, PartialOrd, Ord, Hash)]
1818
#[repr(C)]
1919
pub struct ModuleTag {
2020
typ: TagTypeId,

multiboot2/src/rsdp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use {
2323
const RSDPV1_LENGTH: usize = 20;
2424

2525
/// This tag contains a copy of RSDP as defined per ACPI 1.0 specification.
26-
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
26+
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
2727
#[repr(C)]
2828
pub struct RsdpV1Tag {
2929
typ: TagTypeId,
@@ -96,7 +96,7 @@ impl StructAsBytes for RsdpV1Tag {
9696
}
9797

9898
/// This tag contains a copy of RSDP as defined per ACPI 2.0 or later specification.
99-
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
99+
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
100100
#[repr(C)]
101101
pub struct RsdpV2Tag {
102102
typ: TagTypeId,

multiboot2/src/smbios.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const METADATA_SIZE: usize = core::mem::size_of::<TagTypeId>()
1111
+ core::mem::size_of::<u8>() * 8;
1212

1313
/// This tag contains a copy of SMBIOS tables as well as their version.
14-
#[derive(ptr_meta::Pointee, PartialEq, Eq)]
14+
#[derive(ptr_meta::Pointee, PartialEq, Eq, PartialOrd, Ord, Hash)]
1515
#[repr(C)]
1616
pub struct SmbiosTag {
1717
typ: TagTypeId,

multiboot2/src/vbe_info.rs

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

44
/// This tag contains VBE metadata, VBE controller information returned by the
55
/// VBE Function 00h and VBE mode information returned by the VBE Function 01h.
6-
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
6+
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
77
#[repr(C)]
88
pub struct VBEInfoTag {
99
typ: TagTypeId,
@@ -45,7 +45,7 @@ pub struct VBEInfoTag {
4545
///
4646
/// The purpose of this struct is to provide information to the kernel about the general
4747
/// capabilities of the installed VBE software and hardware.
48-
#[derive(Copy, Clone, PartialEq, Eq)]
48+
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
4949
#[repr(C, packed)]
5050
pub struct VBEControlInfo {
5151
/// VBE Signature aka "VESA".
@@ -106,7 +106,7 @@ impl fmt::Debug for VBEControlInfo {
106106

107107
/// Extended information about a specific VBE display mode from the
108108
/// mode list returned by `VBEControlInfo` (VBE Function `00h`).
109-
#[derive(Copy, Clone, PartialEq, Eq)]
109+
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
110110
#[repr(C, packed)]
111111
pub struct VBEModeInfo {
112112
/// Mode attributes.
@@ -234,7 +234,7 @@ impl fmt::Debug for VBEModeInfo {
234234
/// A VBE colour field.
235235
///
236236
/// Describes the size and position of some colour capability.
237-
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
237+
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
238238
#[repr(C, packed)]
239239
pub struct VBEField {
240240
/// The size, in bits, of the color components of a direct color pixel.
@@ -247,7 +247,7 @@ pub struct VBEField {
247247

248248
bitflags! {
249249
/// The Capabilities field indicates the support of specific features in the graphics environment.
250-
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
250+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
251251
#[repr(transparent)]
252252
pub struct VBECapabilities: u32 {
253253
/// Can the DAC be switched between 6 and 8 bit modes.
@@ -265,7 +265,7 @@ bitflags! {
265265

266266
bitflags! {
267267
/// A Mode attributes bitfield.
268-
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
268+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
269269
#[repr(transparent)]
270270
pub struct VBEModeAttributes: u16 {
271271
/// Mode supported by hardware configuration.
@@ -298,7 +298,7 @@ bitflags! {
298298
bitflags! {
299299
/// The WindowAttributes describe the characteristics of the CPU windowing
300300
/// scheme such as whether the windows exist and are read/writeable, as follows:
301-
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
301+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
302302
#[repr(transparent)]
303303
pub struct VBEWindowAttributes: u8 {
304304
/// Relocatable window(s) supported?
@@ -323,7 +323,7 @@ bitflags! {
323323
/// (it is assumed all color ramp data is 8 bits per primary).
324324
/// Bit D1 specifies whether the bits in the Rsvd field of the direct color
325325
/// pixel can be used by the application or are reserved, and thus unusable.
326-
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
326+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
327327
#[repr(transparent)]
328328
pub struct VBEDirectColorAttributes: u8 {
329329
/// Color ramp is fixed when cleared and programmable when set.

0 commit comments

Comments
 (0)