Skip to content

Commit 2c2f798

Browse files
uefi: Derive Debug on many protocols
Note that this requires rust>=1.70 for deriving `Debug` on `efiapi` function pointers.
1 parent 6dd4e99 commit 2c2f798

File tree

23 files changed

+26
-7
lines changed

23 files changed

+26
-7
lines changed

uefi-macros/src/lib.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,6 @@ pub fn unsafe_protocol(args: TokenStream, input: TokenStream) -> TokenStream {
8282
let (impl_generics, ty_generics, where_clause) = item_struct.generics.split_for_impl();
8383

8484
quote! {
85-
// Disable this lint for now. It doesn't account for the fact that
86-
// currently it doesn't work to `derive(Debug)` on structs that have
87-
// `extern "efiapi" fn` fields, which most protocol structs have. The
88-
// derive _does_ work in current nightly (1.70.0) though, so hopefully
89-
// in a couple Rust releases we can drop this.
90-
#[allow(missing_debug_implementations)]
9185
#item_struct
9286

9387
unsafe impl #impl_generics ::uefi::Identify for #ident #ty_generics #where_clause {

uefi/src/proto/console/gop.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ pub use uefi_raw::protocol::console::PixelBitmask;
6767
///
6868
/// The GOP can be used to set the properties of the frame buffer,
6969
/// and also allows the app to access the in-memory buffer.
70+
#[derive(Debug)]
7071
#[repr(transparent)]
7172
#[unsafe_protocol(GraphicsOutputProtocol::GUID)]
7273
pub struct GraphicsOutput(GraphicsOutputProtocol);

uefi/src/proto/console/pointer/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::{Event, Result, Status, StatusExt};
55
use uefi_raw::protocol::console::SimplePointerProtocol;
66

77
/// Provides information about a pointer device.
8+
#[derive(Debug)]
89
#[repr(transparent)]
910
#[unsafe_protocol(SimplePointerProtocol::GUID)]
1011
pub struct Pointer(SimplePointerProtocol);

uefi/src/proto/console/serial.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub use uefi_raw::protocol::console::serial::{ControlBits, Parity, StopBits};
1515
///
1616
/// Since UEFI drivers are implemented through polling, if you fail to regularly
1717
/// check for input/output, some data might be lost.
18+
#[derive(Debug)]
1819
#[repr(transparent)]
1920
#[unsafe_protocol(SerialIoProtocol::GUID)]
2021
pub struct Serial(SerialIoProtocol);

uefi/src/proto/console/text/input.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use core::mem::MaybeUninit;
44
use uefi_raw::protocol::console::{InputKey, SimpleTextInputProtocol};
55

66
/// Interface for text-based input devices.
7+
#[derive(Debug)]
78
#[repr(transparent)]
89
#[unsafe_protocol(SimpleTextInputProtocol::GUID)]
910
pub struct Input(SimpleTextInputProtocol);

uefi/src/proto/debug/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ mod exception;
2929
/// one for any given instruction set.
3030
///
3131
/// NOTE: OVMF only implements this protocol interface for the virtual EBC processor
32+
#[derive(Debug)]
3233
#[repr(C)]
3334
#[unsafe_protocol("2755590c-6f3c-42fa-9ea4-a3ba543cda25")]
3435
pub struct DebugSupport {
@@ -174,6 +175,7 @@ pub enum ProcessorArch: u32 => {
174175

175176
/// The debug port protocol abstracts the underlying debug port
176177
/// hardware, whether it is a regular Serial port or something else.
178+
#[derive(Debug)]
177179
#[repr(C)]
178180
#[unsafe_protocol("eba4e8d2-3858-41ec-a281-2647ba9660d0")]
179181
pub struct DebugPort {

uefi/src/proto/device_path/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ pub enum NodeConversionError {
754754
/// [`load_image`]: crate::table::boot::BootServices::load_image
755755
#[repr(transparent)]
756756
#[unsafe_protocol("bc62157e-3e33-4fec-9920-2d3b36d750df")]
757-
#[derive(Pointee)]
757+
#[derive(Debug, Pointee)]
758758
pub struct LoadedImageDevicePath(DevicePath);
759759

760760
impl ProtocolPointer for LoadedImageDevicePath {

uefi/src/proto/device_path/text.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ impl Drop for PoolString<'_> {
8080
///
8181
/// This protocol provides common utility functions for converting device
8282
/// nodes and device paths to a text representation.
83+
#[derive(Debug)]
8384
#[repr(C)]
8485
#[unsafe_protocol("8b843e20-8132-4852-90cc-551a4e4a7f1c")]
8586
pub struct DevicePathToText {
@@ -147,6 +148,7 @@ impl DevicePathToText {
147148
///
148149
/// This protocol provides common utilities for converting text to
149150
/// device paths and device nodes.
151+
#[derive(Debug)]
150152
#[repr(C)]
151153
#[unsafe_protocol("05c99a21-c70f-4ad2-8a5f-35df3343f51e")]
152154
pub struct DevicePathFromText {

uefi/src/proto/driver/component_name.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use uefi_raw::protocol::driver::ComponentName2Protocol;
2727
/// [RFC 4646]: https://www.rfc-editor.org/rfc/rfc4646
2828
#[deprecated = "deprecated in UEFI 2.1; use ComponentName2 where possible"]
2929
#[unsafe_protocol(ComponentName2Protocol::DEPRECATED_COMPONENT_NAME_GUID)]
30+
#[derive(Debug)]
3031
#[repr(transparent)]
3132
pub struct ComponentName1(
3233
// The layout of the protocol is the same as ComponentName2, only the format
@@ -97,6 +98,7 @@ impl ComponentName1 {
9798
/// [ISO 639-2]: https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes
9899
/// [RFC 4646]: https://www.rfc-editor.org/rfc/rfc4646
99100
#[unsafe_protocol(ComponentName2Protocol::GUID)]
101+
#[derive(Debug)]
100102
#[repr(transparent)]
101103
pub struct ComponentName2(ComponentName2Protocol);
102104

uefi/src/proto/loaded_image.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use core::{mem, slice};
1111
use uefi_raw::protocol::loaded_image::LoadedImageProtocol;
1212

1313
/// The LoadedImage protocol. This can be opened on any image handle using the `HandleProtocol` boot service.
14+
#[derive(Debug)]
1415
#[repr(transparent)]
1516
#[unsafe_protocol(LoadedImageProtocol::GUID)]
1617
pub struct LoadedImage(LoadedImageProtocol);

0 commit comments

Comments
 (0)