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

proto/media: add LoadFile2Protocol #945

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

RaitoBezarius
Copy link
Contributor

The idea is to provide the LoadFile(2)Protocol family in uefi-rs with nice alloc helpers.

My goal is to use them as an alternative to the SimpleFilesystemProtocol when my bootloader is chained via PXE, which means that the SFS protocol is not available on the booted image handle, but… LoadFile(2)Protocol should, which enable me to continue downloading things like an initrd or a kernel as long as I know their exact paths.

This is a draft to open the discussion on the design.

https://uefi.org/specs/UEFI/2.10/13_Protocols_Media_Access.html#load-file-2-protocol

Checklist

  • Sensible git history (for example, squash "typo" or "fix" commits). See the Rewriting History guide for help.
  • Update the changelog (if necessary)

Copy link
Contributor

@nicholasbishop nicholasbishop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks like a good addition to me. I've added a few comments.

uefi/src/proto/media/load_file.rs Outdated Show resolved Hide resolved
uefi/src/proto/media/load_file.rs Outdated Show resolved Hide resolved
uefi/src/proto/media/load_file.rs Outdated Show resolved Hide resolved
uefi/src/proto/media/load_file.rs Outdated Show resolved Hide resolved
@RaitoBezarius
Copy link
Contributor Author

LoadFile(2)Protocol should, which enable me to continue downloading things like an initrd or a kernel as long as I know their exact paths.

Plot twist, after testing it for a while and reading the EDK2 source code, you will discover that the handle put on the thing responsible for an EFI PXE boot, which do have a LoadFileProtocol (and not a LoadFile2Protocol BTW), ignores completely the file path and calling LoadFile on it is restarting the PXE boot process.

So, it seems like the only reasonable way to download additional files yourself is to use the (M)TFTP services present on the EFI PXE base code protocol…

@RaitoBezarius
Copy link
Contributor Author

Thanks for the review @nicholasbishop — I will work on it!

@phip1611
Copy link
Contributor

phip1611 commented Nov 3, 2023

Thanks for the review @nicholasbishop — I will work on it!

Any update here, @RaitoBezarius ?

@RaitoBezarius
Copy link
Contributor Author

Thanks for the review @nicholasbishop — I will work on it!

Any update here, @RaitoBezarius ?

To be frank, I am a bit confused / blocked by the DevicePathProtocol API that seems different from the Ffi stuff I had and I don't think I can get it back in uefi-raw, so it is taking me time. If you want to finish it, please go for it, I may have too much on my plate right now…

@RaitoBezarius
Copy link
Contributor Author

Right now, I am stuck on fixing some compilation issues, if anyone is interested to take over and I don't complete it in time, please go for it.

@phip1611
Copy link
Contributor

phip1611 commented Nov 7, 2023

Right now, I am stuck on fixing some compilation issues, if anyone is interested to take over and I don't complete it in time, please go for it.

...
#[unsafe_protocol(uefi_raw::protocol::media::LoadFile2::GUID)]
pub struct LoadFile2(uefi_raw::protocol::media::LoadFile2);
...

There is no uefi_raw::protocol::media::LoadFile2::GUID. If you add a new protocol, you need to add it at both places. uefi_raw for the low-level part and uefi for the high-level part. Similar to what happened here: https://github.com/rust-osdev/uefi-rs/pull/991/files

@RaitoBezarius
Copy link
Contributor Author

Right now, I am stuck on fixing some compilation issues, if anyone is interested to take over and I don't complete it in time, please go for it.

...
#[unsafe_protocol(uefi_raw::protocol::media::LoadFile2::GUID)]
pub struct LoadFile2(uefi_raw::protocol::media::LoadFile2);
...

There is no uefi_raw::protocol::media::LoadFile2::GUID. If you add a new protocol, you need to add it at both places. uefi_raw for the low-level part and uefi for the high-level part. Similar to what happened here: #991 (files)

Yep, I just forgot to include the file, done.

@phip1611
Copy link
Contributor

Any update here? We'd love to merge this

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.

None yet

3 participants