Skip to content

Commit f232228

Browse files
authored
Merge pull request #253 from rust-osdev/lint
Minor lint fixes
2 parents 98bd3c6 + 6dfc218 commit f232228

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

Changelog.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Unreleased
22

3+
- Add `Debug` implementation for `InterruptDescriptorTable` ([#253](https://github.com/rust-osdev/x86_64/pull/253))
4+
- Improve `Debug` implementations for `Entry` and `EntryOptions`
5+
36
# 0.14.2 – 2021-05-13
47

58
- Multiple improvements to assembly code ([#251](https://github.com/rust-osdev/x86_64/pull/251))

src/structures/idt.rs

+18-8
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ use volatile::Volatile;
3333
/// The field descriptions are taken from the
3434
/// [AMD64 manual volume 2](https://support.amd.com/TechDocs/24593.pdf)
3535
/// (with slight modifications).
36-
#[allow(missing_debug_implementations)]
37-
#[derive(Clone)]
36+
#[derive(Clone, Debug)]
3837
#[repr(C)]
3938
#[repr(align(16))]
4039
pub struct InterruptDescriptorTable {
@@ -575,12 +574,9 @@ pub struct Entry<F> {
575574
impl<T> fmt::Debug for Entry<T> {
576575
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
577576
f.debug_struct("Entry")
578-
.field("pointer_low", &self.pointer_low)
577+
.field("handler_addr", &format_args!("{:#x}", self.handler_addr()))
579578
.field("gdt_selector", &self.gdt_selector)
580579
.field("options", &self.options)
581-
.field("pointer_middle", &self.pointer_middle)
582-
.field("pointer_high", &self.pointer_high)
583-
.field("reserved", &self.reserved)
584580
.finish()
585581
}
586582
}
@@ -645,6 +641,13 @@ impl<F> Entry<F> {
645641
self.options.set_present(true);
646642
&mut self.options
647643
}
644+
645+
#[inline]
646+
fn handler_addr(&self) -> u64 {
647+
self.pointer_low as u64
648+
| (self.pointer_middle as u64) << 16
649+
| (self.pointer_high as u64) << 32
650+
}
648651
}
649652

650653
macro_rules! impl_set_handler_fn {
@@ -674,9 +677,17 @@ impl_set_handler_fn!(DivergingHandlerFuncWithErrCode);
674677

675678
/// Represents the options field of an IDT entry.
676679
#[repr(transparent)]
677-
#[derive(Debug, Clone, Copy, PartialEq)]
680+
#[derive(Clone, Copy, PartialEq)]
678681
pub struct EntryOptions(u16);
679682

683+
impl fmt::Debug for EntryOptions {
684+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
685+
f.debug_tuple("EntryOptions")
686+
.field(&format_args!("{:#06x}", self.0))
687+
.finish()
688+
}
689+
}
690+
680691
impl EntryOptions {
681692
/// Creates a minimal options field with all the must-be-one bits set.
682693
#[inline]
@@ -757,7 +768,6 @@ impl InterruptStackFrame {
757768
///
758769
/// Also, it is not fully clear yet whether modifications of the interrupt stack frame are
759770
/// officially supported by LLVM's x86 interrupt calling convention.
760-
#[allow(clippy::should_implement_trait)]
761771
#[inline]
762772
pub unsafe fn as_mut(&mut self) -> Volatile<&mut InterruptStackFrameValue> {
763773
Volatile::new(&mut self.value)

0 commit comments

Comments
 (0)