From b5e118516224d3823c943915f6def4a21f8b6c81 Mon Sep 17 00:00:00 2001 From: M Farkas-Dyck Date: Thu, 4 Oct 2018 15:52:09 -0800 Subject: [PATCH] impl Debug --- src/instructions/port.rs | 1 + src/instructions/tables.rs | 1 + src/lib.rs | 2 ++ src/registers/control.rs | 2 ++ src/registers/model_specific.rs | 2 ++ src/structures/gdt.rs | 2 ++ src/structures/idt.rs | 3 ++- src/structures/paging/mod.rs | 6 +++--- src/structures/paging/recursive.rs | 2 ++ src/structures/tss.rs | 1 + 10 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/instructions/port.rs b/src/instructions/port.rs index 273d311e5..9bf5d5029 100644 --- a/src/instructions/port.rs +++ b/src/instructions/port.rs @@ -63,6 +63,7 @@ impl PortReadWrite for u32 { } /// An I/O port. +#[derive(Debug)] pub struct Port { port: u16, phantom: PhantomData, diff --git a/src/instructions/tables.rs b/src/instructions/tables.rs index 82d0e3b81..b6e694a3e 100644 --- a/src/instructions/tables.rs +++ b/src/instructions/tables.rs @@ -4,6 +4,7 @@ use structures::gdt::SegmentSelector; /// A struct describing a pointer to a descriptor table (GDT / IDT). /// This is in a format suitable for giving to 'lgdt' or 'lidt'. +#[derive(Debug, Clone, Copy)] #[repr(C, packed)] pub struct DescriptorTablePointer { /// Size of the DT. diff --git a/src/lib.rs b/src/lib.rs index 0e2ee97cd..e14b94848 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,6 +11,8 @@ #![cfg_attr(feature = "deny-warnings", deny(missing_docs))] #![cfg_attr(not(feature = "deny-warnings"), warn(missing_docs))] +#![deny(missing_debug_implementations)] + #[cfg(test)] #[macro_use] extern crate std; diff --git a/src/registers/control.rs b/src/registers/control.rs index ccd63d16c..ad6c17227 100644 --- a/src/registers/control.rs +++ b/src/registers/control.rs @@ -6,6 +6,7 @@ use structures::paging::PhysFrame; use PhysAddr; /// Various control flags modifying the basic operation of the CPU. +#[derive(Debug)] pub struct Cr0; impl Cr0 { @@ -91,6 +92,7 @@ bitflags! { } /// Contains the physical address of the level 4 page table. +#[derive(Debug)] pub struct Cr3; impl Cr3 { diff --git a/src/registers/model_specific.rs b/src/registers/model_specific.rs index def1fc5b5..f496af598 100644 --- a/src/registers/model_specific.rs +++ b/src/registers/model_specific.rs @@ -1,6 +1,7 @@ //! Functions to read and write control registers. /// A model specific register. +#[derive(Debug)] pub struct Msr(u32); impl Msr { @@ -25,6 +26,7 @@ impl Msr { } /// The Extended Feature Enable Register. +#[derive(Debug)] pub struct Efer; impl Efer { diff --git a/src/structures/gdt.rs b/src/structures/gdt.rs index 313049768..97386fd19 100644 --- a/src/structures/gdt.rs +++ b/src/structures/gdt.rs @@ -50,6 +50,7 @@ impl fmt::Debug for SegmentSelector { /// switching between user and kernel mode or for loading a TSS. /// /// The GDT has a fixed size of 8 entries, trying to add more entries will panic. +#[derive(Debug)] pub struct GlobalDescriptorTable { table: [u64; 8], next_free: usize, @@ -108,6 +109,7 @@ impl GlobalDescriptorTable { /// /// Segmentation is no longer supported in 64-bit mode, so most of the descriptor /// contents are ignored. +#[derive(Debug)] pub enum Descriptor { /// Descriptor for a code or data segment. /// diff --git a/src/structures/idt.rs b/src/structures/idt.rs index 61c6adcf8..4ae4c1120 100644 --- a/src/structures/idt.rs +++ b/src/structures/idt.rs @@ -30,6 +30,7 @@ use {PrivilegeLevel, VirtAddr}; /// 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)] #[repr(C)] pub struct InterruptDescriptorTable { /// A divide by zero exception (`#DE`) occurs when the denominator of a DIV instruction or @@ -505,7 +506,7 @@ impl IndexMut for InterruptDescriptorTable { /// /// The generic parameter can either be `HandlerFunc` or `HandlerFuncWithErrCode`, depending /// on the interrupt vector. -#[derive(Clone, Copy)] +#[derive(Debug, Clone, Copy)] #[repr(C)] pub struct Entry { pointer_low: u16, diff --git a/src/structures/paging/mod.rs b/src/structures/paging/mod.rs index e6516ef1e..085a77324 100644 --- a/src/structures/paging/mod.rs +++ b/src/structures/paging/mod.rs @@ -31,17 +31,17 @@ pub trait PageSize: Copy + Eq + PartialOrd + Ord { pub trait NotGiantPageSize: PageSize {} /// A standard 4KiB page. -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] pub enum Size4KiB {} /// A “huge” 2MiB page. -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] pub enum Size2MiB {} /// A “giant” 1GiB page. /// /// (Only available on newer x86_64 CPUs.) -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] pub enum Size1GiB {} impl PageSize for Size4KiB { diff --git a/src/structures/paging/recursive.rs b/src/structures/paging/recursive.rs index 86a505b4d..21e34d0ef 100644 --- a/src/structures/paging/recursive.rs +++ b/src/structures/paging/recursive.rs @@ -15,6 +15,7 @@ use {PhysAddr, VirtAddr}; /// The old mapping might be still cached in the translation lookaside buffer (TLB), so it needs /// to be flushed from the TLB before it's accessed. This type is returned from function that /// change the mapping of a page to ensure that the TLB flush is not forgotten. +#[derive(Debug)] #[must_use = "Page Table changes must be flushed or ignored."] pub struct MapperFlush(Page); @@ -94,6 +95,7 @@ pub trait Mapper { /// level 3 index, then the level 2 index. /// /// This struct implements the `Mapper` trait. +#[derive(Debug)] pub struct RecursivePageTable<'a> { p4: &'a mut PageTable, recursive_index: u9, diff --git a/src/structures/tss.rs b/src/structures/tss.rs index f8eb43fc7..1c2a76ebc 100644 --- a/src/structures/tss.rs +++ b/src/structures/tss.rs @@ -6,6 +6,7 @@ use VirtAddr; /// directly related to the task-switch mechanism, /// but is used for finding kernel level stack /// if interrupts arrive while in kernel mode. +#[derive(Debug, Clone, Copy)] #[repr(C, packed)] pub struct TaskStateSegment { reserved_1: u32,