Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

treewide: derive Debug everywhere #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions rust-toolchain.toml

This file was deleted.

5 changes: 3 additions & 2 deletions src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use core::net::{Ipv4Addr, SocketAddrV4};
/// A UUID. With the `uuid` feature, this can be converted directly to
/// [`uuid::Uuid`] via [`Into`], and the reverse via [`From`].
#[repr(C)]
#[derive(PartialEq, Eq, Clone, Copy)]
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub struct Uuid {
/// The first 32 bits of the UUID.
pub a: u32,
Expand Down Expand Up @@ -47,7 +47,7 @@ impl From<Uuid> for uuid::Uuid {
}

/// A media type for a file.
#[derive(PartialEq, Eq, Clone, Copy)]
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
#[repr(transparent)]
pub struct MediaType(u32);
impl MediaType {
Expand All @@ -63,6 +63,7 @@ impl MediaType {
/// [`KernelFileRequest`](crate::request::KernelFileRequest) and
/// [`ModuleRequest`](crate::request::ModuleRequest).
#[repr(C)]
#[derive(Debug)]
pub struct File {
revision: u64,
addr: *mut c_void,
Expand Down
16 changes: 13 additions & 3 deletions src/framebuffer.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//! Auxiliary types for the [framebuffer request](crate::request::FramebufferRequest)

use core::{ffi::c_void, ptr::NonNull};
use core::fmt::{Debug, Formatter};

#[derive(Clone, Copy)]
#[derive(Debug, Clone, Copy)]
#[repr(C)]
pub(crate) struct RawFramebufferV0 {
addr: *mut c_void,
Expand All @@ -22,7 +23,7 @@ pub(crate) struct RawFramebufferV0 {
edid: Option<NonNull<u8>>,
}

#[derive(Clone, Copy)]
#[derive(Debug, Clone, Copy)]
#[repr(C)]
pub(crate) struct RawFramebufferV1 {
_v0: RawFramebufferV0,
Expand All @@ -36,10 +37,17 @@ pub(crate) union RawFramebuffer {
v1: RawFramebufferV1,
}

impl Debug for RawFramebuffer {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
// v0 is common for both versions
unsafe { self.v0 }.fmt(f)
}
}

/// A memory model used by a framebuffer. Currently only
/// [`MemoryModel::RGB`](Self::RGB) is defined.
#[repr(transparent)]
#[derive(PartialEq, Eq, Clone, Copy)]
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub struct MemoryModel(u8);
impl MemoryModel {
/// This is an RGB framebuffer.
Expand All @@ -48,6 +56,7 @@ impl MemoryModel {

/// A mode supported by the current framebuffer.
#[repr(C)]
#[derive(Debug)]
pub struct VideoMode {
/// The pitch (distance between rows, in bytes). This is not always the same
/// as `(width * bpp) / 8`, as padding bytes may be added to achieve a
Expand Down Expand Up @@ -88,6 +97,7 @@ pub struct VideoMode {
/// Two revisions currently exist of the framebuffer type. However, the type
/// itself has no revision field. In order to keep this type safe, we wrap the
/// pointer with its associated revision taken from the response.
#[derive(Debug)]
pub struct Framebuffer<'a> {
revision: u64,
inner: &'a RawFramebuffer,
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![no_std]
#![deny(missing_docs)]
#![deny(missing_debug_implementations)]

//! Rust Bindings for the limine boot protocol.
//!
Expand Down Expand Up @@ -73,6 +74,7 @@ pub mod smp;
///
/// The latest revision is 1.
#[repr(C)]
#[derive(Debug)]
pub struct BaseRevision {
_id: [u64; 2],
revision: UnsafeCell<u64>,
Expand Down
3 changes: 2 additions & 1 deletion src/memory_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/// A type of entry within the memory map.
#[repr(transparent)]
#[derive(PartialEq, Eq, Clone, Copy)]
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub struct EntryType(u64);
impl EntryType {
/// The memory region is freely usable.
Expand Down Expand Up @@ -34,6 +34,7 @@ impl From<u64> for EntryType {

/// A memory map entry.
#[repr(C)]
#[derive(Debug)]
pub struct Entry {
/// The base of the memory region, in *physical space*.
pub base: u64,
Expand Down
3 changes: 2 additions & 1 deletion src/modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use bitflags::bitflags;

bitflags! {
/// Flags for internal modules
#[derive(PartialEq, Eq, Clone, Copy)]
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub struct ModuleFlags: u64 {
/// The module is required. If it is not found, the bootloader will
/// refuse to boot.
Expand All @@ -31,6 +31,7 @@ macro_rules! cstr {
/// An internal module that the kernel requests from the bootloader. Only
/// available with request revision 1 and greater.
#[repr(C)]
#[derive(Debug)]
pub struct InternalModule {
path: *const c_char,
cmdline: *const c_char,
Expand Down
4 changes: 2 additions & 2 deletions src/paging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ use bitflags::bitflags;

bitflags! {
/// Paging mode flags. None are currently specified.
#[derive(Default, Clone, Copy)]
#[derive(Debug, Default, Clone, Copy)]
pub struct Flags: u64 {}
}

/// A paging mode.
#[repr(transparent)]
#[derive(PartialEq, Eq, Clone, Copy)]
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub struct Mode(u64);
impl From<u64> for Mode {
fn from(value: u64) -> Self {
Expand Down
19 changes: 19 additions & 0 deletions src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ macro_rules! magic {
};
}

#[derive(Debug)]
struct Response<T> {
inner: UnsafeCell<Option<NonNull<T>>>,
}
Expand Down Expand Up @@ -112,6 +113,7 @@ impl<T> Response<T> {
/// # }
/// ```
#[repr(C)]
#[derive(Debug)]
pub struct BootloaderInfoRequest {
id: [u64; 4],
revision: u64,
Expand Down Expand Up @@ -142,6 +144,7 @@ impl BootloaderInfoRequest {
/// # }
/// ```
#[repr(C)]
#[derive(Debug)]
pub struct StackSizeRequest {
id: [u64; 4],
revision: u64,
Expand Down Expand Up @@ -188,6 +191,7 @@ impl StackSizeRequest {
/// # }
/// ```
#[repr(C)]
#[derive(Debug)]
pub struct HhdmRequest {
id: [u64; 4],
revision: u64,
Expand Down Expand Up @@ -217,6 +221,7 @@ impl HhdmRequest {
/// FRAMEBUFFER_REQUEST.get_response() // ...
/// # }
#[repr(C)]
#[derive(Debug)]
pub struct FramebufferRequest {
id: [u64; 4],
revision: u64,
Expand Down Expand Up @@ -250,6 +255,7 @@ impl FramebufferRequest {
/// PAGING_MODE_REQUEST.get_response() // ...
/// # }
#[repr(C)]
#[derive(Debug)]
pub struct PagingModeRequest {
id: [u64; 4],
revision: u64,
Expand Down Expand Up @@ -319,6 +325,7 @@ impl PagingModeRequest {
/// # }
/// ```
#[repr(C)]
#[derive(Debug)]
#[deprecated(note = "use `PagingModeRequest` instead")]
pub struct FiveLevelPagingRequest {
id: [u64; 4],
Expand Down Expand Up @@ -352,6 +359,7 @@ impl FiveLevelPagingRequest {
/// # }
/// ```
#[repr(C)]
#[derive(Debug)]
pub struct SmpRequest {
id: [u64; 4],
revision: u64,
Expand Down Expand Up @@ -405,6 +413,7 @@ impl SmpRequest {
/// # }
/// ```
#[repr(C)]
#[derive(Debug)]
pub struct MemoryMapRequest {
id: [u64; 4],
revision: u64,
Expand All @@ -422,6 +431,7 @@ impl MemoryMapRequest {
/// Requests limine to use a specific function as the kernel entry point,
/// instead of the one specified in the ELF.
#[repr(C)]
#[derive(Debug)]
pub struct EntryPointRequest {
id: [u64; 4],
revision: u64,
Expand Down Expand Up @@ -476,6 +486,7 @@ impl EntryPointRequest {
/// # }
/// ```
#[repr(C)]
#[derive(Debug)]
pub struct KernelFileRequest {
id: [u64; 4],
revision: u64,
Expand Down Expand Up @@ -518,6 +529,7 @@ impl KernelFileRequest {
/// # }
/// ```
#[repr(C)]
#[derive(Debug)]
pub struct ModuleRequest {
id: [u64; 4],
revision: u64,
Expand Down Expand Up @@ -591,6 +603,7 @@ impl ModuleRequest {
/// # }
/// ```
#[repr(C)]
#[derive(Debug)]
pub struct RsdpRequest {
id: [u64; 4],
revision: u64,
Expand Down Expand Up @@ -621,6 +634,7 @@ impl RsdpRequest {
/// # }
/// ```
#[repr(C)]
#[derive(Debug)]
pub struct SmbiosRequest {
id: [u64; 4],
revision: u64,
Expand Down Expand Up @@ -651,6 +665,7 @@ impl SmbiosRequest {
/// # }
/// ```
#[repr(C)]
#[derive(Debug)]
pub struct EfiSystemTableRequest {
id: [u64; 4],
revision: u64,
Expand Down Expand Up @@ -681,6 +696,7 @@ impl EfiSystemTableRequest {
/// # }
/// ```
#[repr(C)]
#[derive(Debug)]
pub struct EfiMemoryMapRequest {
id: [u64; 4],
revision: u64,
Expand Down Expand Up @@ -711,6 +727,7 @@ impl EfiMemoryMapRequest {
/// # }
/// ```
#[repr(C)]
#[derive(Debug)]
pub struct BootTimeRequest {
id: [u64; 4],
revision: u64,
Expand Down Expand Up @@ -741,6 +758,7 @@ impl BootTimeRequest {
/// # }
/// ```
#[repr(C)]
#[derive(Debug)]
pub struct KernelAddressRequest {
id: [u64; 4],
revision: u64,
Expand Down Expand Up @@ -771,6 +789,7 @@ impl KernelAddressRequest {
/// # }
/// ```
#[repr(C)]
#[derive(Debug)]
pub struct DeviceTreeBlobRequest {
id: [u64; 4],
revision: u64,
Expand Down
Loading