Skip to content

Add support for device path protocol and EFI_LOCATE_DEVICE_PATH - #187

Merged
GabrielMajeri merged 24 commits into
rust-osdev:masterfrom
zdivelbiss:device_path-dev
Dec 8, 2020
Merged

Add support for device path protocol and EFI_LOCATE_DEVICE_PATH#187
GabrielMajeri merged 24 commits into
rust-osdev:masterfrom
zdivelbiss:device_path-dev

Conversation

@zdivelbiss

@zdivelbiss zdivelbiss commented Dec 6, 2020

Copy link
Copy Markdown

Motivation

This PR adds support for the EFI_DEVICE_PATH_PROTOCOL, primarily for support with the EFI_LOCATE_DEVICE_PATH function, existing on the EFI_BOOT_SERVICES structure.

Changes

3 new types are added:

#[repr(C)]
#[unsafe_guid("09576e91-6d3f-11d2-8e39-00a0c969723b")]
#[derive(Protocol)]
pub struct DevicePath { /* members elided for brevity */ }
#[repr(u8)]
#[derive(Debug)]
pub enum DeviceType { /* members elided for brevity */ }
#[repr(u8)]
#[derive(Debug)]
pub enum DeviceSubType { /* members elided for brevity */ }

To facilitate usage of these types, and implementing the EFI_LOCATE_DEVICE_PATH function, I added the following function to the Handle struct:

impl Handle {
    pub(crate) unsafe fn uninitialized() -> Self {
        MaybeUninit::zeroed().assume_init()
    }
}

Additionally, I've broken LoadedImage out into its own loaded_image.rs file, for the sake of semantically expanding the types held within the module. The new module format is well expressed by the following:

use uefi::proto::loaded_image::{LoadedImage, DevicePath};

This is obviously not a breaking change, so I felt taking this liberty (given the corollary nature of EFI_DEVICE_PATH_PROTOCOL to EFI_LOADED_IMAGE_PROTOCOL) was acceptable.

The final change is to update the feature optin_builtin_traits to auto_traits, as the feature name has breaking-changed. There already exists a PR for this, but I was unaware of it at the time of the commit.

@GabrielMajeri

Copy link
Copy Markdown
Collaborator

Thanks for the contribution!

I've made a separate PR (#188) which fixed the remaining CI issues, if you rebase (and skip the commit with the unstable feature rename), it should be green.

@zdivelbiss

Copy link
Copy Markdown
Author

I believe (?) I rebased my pull branch, I'm not too familiar with doing PRs (or git in general, to be honest). I'm unsure why the Rust / Lints still fails.

@toku-sa-n

Copy link
Copy Markdown
Member

You can run rustfmt **/*.rs in the repository base directory.

@zdivelbiss

Copy link
Copy Markdown
Author

That doesn't seem to have made a difference. Running the command again results in no more formatting changes.

@toku-sa-n

Copy link
Copy Markdown
Member

See this: https://github.com/rust-osdev/uefi-rs/pull/187/checks?check_run_id=1511313923
Clippy complains about the module name. Try changing the name of loaded_image module which is inside loaded_image module. Or it may be better not to create a new loaded_image module.

@zdivelbiss

Copy link
Copy Markdown
Author

Should be good to go now!

@GabrielMajeri

Copy link
Copy Markdown
Collaborator

There are a few lint warnings about missing documentation. Would it be possible to add some short doc comments for the items which lack them?

@zdivelbiss

Copy link
Copy Markdown
Author

I don't believe the linter is complaining about anything anymore :)

@GabrielMajeri GabrielMajeri changed the title Add support for device path protocol and EFI_LOCATE_DEVICE_PATH (for EFI_BOOT_SERVICES/BootServices) Add support for device path protocol and EFI_LOCATE_DEVICE_PATH Dec 8, 2020
@GabrielMajeri
GabrielMajeri merged commit d29d30f into rust-osdev:master Dec 8, 2020
@zdivelbiss
zdivelbiss deleted the device_path-dev branch December 8, 2020 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants