From 9ab2f3f5a3d09f91cd9c9bb88f2d533a295b89e5 Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Thu, 6 May 2021 14:25:24 -0700 Subject: [PATCH 1/3] Remove unnecessary Clippy allow() This method signature no longer triggers a false positive Signed-off-by: Joe Richey --- src/structures/idt.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/structures/idt.rs b/src/structures/idt.rs index 2e3ead278..6f9524d8c 100644 --- a/src/structures/idt.rs +++ b/src/structures/idt.rs @@ -757,7 +757,6 @@ impl InterruptStackFrame { /// /// Also, it is not fully clear yet whether modifications of the interrupt stack frame are /// officially supported by LLVM's x86 interrupt calling convention. - #[allow(clippy::should_implement_trait)] #[inline] pub unsafe fn as_mut(&mut self) -> Volatile<&mut InterruptStackFrameValue> { Volatile::new(&mut self.value) From df48ba946258d6a6794967fb149aba764aa9590b Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Thu, 13 May 2021 23:50:37 -0700 Subject: [PATCH 2/3] Add Debug implementation for `InterruptDescriptorTable` This commit also improves the debug implementations for `Entry` and `EntryOptions` so that code like: ```rust println!("{:#?}", InterruptDescriptorTable::new()); ``` doesn't produce complete garbage. Signed-off-by: Joe Richey --- src/structures/idt.rs | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/structures/idt.rs b/src/structures/idt.rs index 6f9524d8c..e24aa3623 100644 --- a/src/structures/idt.rs +++ b/src/structures/idt.rs @@ -33,8 +33,7 @@ use volatile::Volatile; /// The field descriptions are taken from the /// [AMD64 manual volume 2](https://support.amd.com/TechDocs/24593.pdf) /// (with slight modifications). -#[allow(missing_debug_implementations)] -#[derive(Clone)] +#[derive(Clone, Debug)] #[repr(C)] #[repr(align(16))] pub struct InterruptDescriptorTable { @@ -575,12 +574,9 @@ pub struct Entry { impl fmt::Debug for Entry { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Entry") - .field("pointer_low", &self.pointer_low) + .field("handler_addr", &format_args!("{:#x}", self.handler_addr())) .field("gdt_selector", &self.gdt_selector) .field("options", &self.options) - .field("pointer_middle", &self.pointer_middle) - .field("pointer_high", &self.pointer_high) - .field("reserved", &self.reserved) .finish() } } @@ -645,6 +641,13 @@ impl Entry { self.options.set_present(true); &mut self.options } + + #[inline] + fn handler_addr(&self) -> u64 { + self.pointer_low as u64 + | (self.pointer_middle as u64) << 16 + | (self.pointer_high as u64) << 32 + } } macro_rules! impl_set_handler_fn { @@ -674,9 +677,17 @@ impl_set_handler_fn!(DivergingHandlerFuncWithErrCode); /// Represents the options field of an IDT entry. #[repr(transparent)] -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Clone, Copy, PartialEq)] pub struct EntryOptions(u16); +impl fmt::Debug for EntryOptions { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_tuple("EntryOptions") + .field(&format_args!("{:#06x}", self.0)) + .finish() + } +} + impl EntryOptions { /// Creates a minimal options field with all the must-be-one bits set. #[inline] From 6dfc21833465c8f299b9a0c8f270e60078b7f80a Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Thu, 13 May 2021 23:59:38 -0700 Subject: [PATCH 3/3] Update changelog Signed-off-by: Joe Richey --- Changelog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Changelog.md b/Changelog.md index 26b1b5bb3..291807462 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,8 @@ # Unreleased +- Add `Debug` implementation for `InterruptDescriptorTable` ([#253](https://github.com/rust-osdev/x86_64/pull/253)) + - Improve `Debug` implementations for `Entry` and `EntryOptions` + # 0.14.2 – 2021-05-13 - Multiple improvements to assembly code ([#251](https://github.com/rust-osdev/x86_64/pull/251))