diff --git a/src/addr.rs b/src/addr.rs index 4c962e2b4..d796a0e35 100644 --- a/src/addr.rs +++ b/src/addr.rs @@ -17,7 +17,7 @@ use bit_field::BitField; /// On `x86_64`, only the 48 lower bits of a virtual address can be used. The top 16 bits need /// to be copies of bit 47, i.e. the most significant bit. Addresses that fulfil this criterium /// are called “canonical”. This type guarantees that it always represents a canonical address. -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[repr(transparent)] pub struct VirtAddr(u64); @@ -30,7 +30,7 @@ pub struct VirtAddr(u64); /// /// On `x86_64`, only the 52 lower bits of a physical address can be used. The top 12 bits need /// to be zero. This type guarantees that it always represents a valid physical address. -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[repr(transparent)] pub struct PhysAddr(u64); diff --git a/src/instructions/tlb.rs b/src/instructions/tlb.rs index 6e93f905d..008dfadff 100644 --- a/src/instructions/tlb.rs +++ b/src/instructions/tlb.rs @@ -49,7 +49,7 @@ struct InvpcidDescriptor { /// Structure of a PCID. A PCID has to be <= 4096 for x86_64. #[repr(transparent)] -#[derive(Debug)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Pcid(u16); impl Pcid { diff --git a/src/lib.rs b/src/lib.rs index 73a6c5061..652dd5130 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -67,7 +67,7 @@ pub mod registers; pub mod structures; /// Represents a protection ring level. -#[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] #[repr(u8)] pub enum PrivilegeLevel { /// Privilege-level 0 (most privilege): This level is used by critical system-software diff --git a/src/registers/segmentation.rs b/src/registers/segmentation.rs index c62fff281..be497d075 100644 --- a/src/registers/segmentation.rs +++ b/src/registers/segmentation.rs @@ -62,7 +62,7 @@ pub trait Segment64: Segment { /// with some additional flags). /// /// See Intel 3a, Section 3.4.2 "Segment Selectors" -#[derive(Clone, Copy, PartialEq, Eq)] +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[repr(transparent)] pub struct SegmentSelector(pub u16); diff --git a/src/structures/paging/frame.rs b/src/structures/paging/frame.rs index f125404fc..e95f82a17 100644 --- a/src/structures/paging/frame.rs +++ b/src/structures/paging/frame.rs @@ -8,7 +8,7 @@ use core::marker::PhantomData; use core::ops::{Add, AddAssign, Sub, SubAssign}; /// A physical memory frame. -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[repr(C)] pub struct PhysFrame { pub(crate) start_address: PhysAddr, // TODO: remove when start_address() is const @@ -133,7 +133,7 @@ impl Sub> for PhysFrame { } /// An range of physical memory frames, exclusive the upper bound. -#[derive(Clone, Copy, PartialEq, Eq)] +#[derive(Clone, Copy, PartialEq, Eq, Hash)] #[repr(C)] pub struct PhysFrameRange { /// The start of the range, inclusive. @@ -175,7 +175,7 @@ impl fmt::Debug for PhysFrameRange { } /// An range of physical memory frames, inclusive the upper bound. -#[derive(Clone, Copy, PartialEq, Eq)] +#[derive(Clone, Copy, PartialEq, Eq, Hash)] #[repr(C)] pub struct PhysFrameRangeInclusive { /// The start of the range, inclusive. diff --git a/src/structures/paging/page.rs b/src/structures/paging/page.rs index 0e9136dd0..4f7f62c76 100644 --- a/src/structures/paging/page.rs +++ b/src/structures/paging/page.rs @@ -53,7 +53,7 @@ impl PageSize for Size1GiB { } /// A virtual memory page. -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[repr(C)] pub struct Page { start_address: VirtAddr, @@ -279,7 +279,7 @@ impl Sub for Page { } /// A range of pages with exclusive upper bound. -#[derive(Clone, Copy, PartialEq, Eq)] +#[derive(Clone, Copy, PartialEq, Eq, Hash)] #[repr(C)] pub struct PageRange { /// The start of the range, inclusive. @@ -332,7 +332,7 @@ impl fmt::Debug for PageRange { } /// A range of pages with inclusive upper bound. -#[derive(Clone, Copy, PartialEq, Eq)] +#[derive(Clone, Copy, PartialEq, Eq, Hash)] #[repr(C)] pub struct PageRangeInclusive { /// The start of the range, inclusive. diff --git a/src/structures/paging/page_table.rs b/src/structures/paging/page_table.rs index 3481b184a..5ae35298e 100644 --- a/src/structures/paging/page_table.rs +++ b/src/structures/paging/page_table.rs @@ -268,7 +268,7 @@ impl fmt::Debug for PageTable { /// Can be used to select one of the 512 entries of a page table. /// /// Guaranteed to only ever contain 0..512. -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct PageTableIndex(u16); impl PageTableIndex { @@ -319,7 +319,7 @@ impl From for usize { /// This type is returned by the `VirtAddr::page_offset` method. /// /// Guaranteed to only ever contain 0..4096. -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct PageOffset(u16); impl PageOffset { @@ -365,7 +365,7 @@ impl From for usize { } } -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] /// A value between 1 and 4. pub enum PageTableLevel { /// Represents the level for a page table.