Skip to content

unsafe_protocol is not necessary? #1573

Closed
@WhyNotHugo

Description

@WhyNotHugo

I wrote a little stub loader for the Linux kernel which exposes an initrd for it.

I had to implement the EFI_LOAD_FILE2_PROTOCOL protocol with a struct as follows:

/// Implementation of the `EFI_LOAD_FILE2_PROTOCOL` protocol
///
/// Used to obtain files from arbitrary devices that are not boot options.
#[repr(C)]
#[uefi::proto::unsafe_protocol(EFI_LOADFILE2_PROTOCOL)] // XXX: Not needed?
pub struct LoadFile2Protocol {
    pub load_file: LoadFile2,
    initrd: &'static [u8],
}

It was not clear to me why unsafe_protocol was required, and inspecting the source in uefi-rs didn't reveal this being used. This GUID is unused, and the actual one that is used is the one passed to install_protocol_interface.

I deleted the line and my service still compiles and runs perfectly. Is this macro no longer required? Is it only for specific situations? The documentation indicates that it implements a couple of Traits, but the documentation for these traits doesn't specify when they are required either. Protocols work fine without them too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions