Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add BootServices::load_image#383

Merged
GabrielMajeri merged 1 commit into
rust-osdev:mainfrom
nicholasbishop:bishop-load-image-2
Mar 7, 2022
Merged

Add BootServices::load_image#383
GabrielMajeri merged 1 commit into
rust-osdev:mainfrom
nicholasbishop:bishop-load-image-2

Conversation

@nicholasbishop
Copy link
Copy Markdown
Member

This replaces BootServices::load_image_from_buffer with a single
method that can load from either a [u8] buffer or a file path via
SimpleFileSystem.

The source is modeled with the LoadImageSource enum. That helps make
it clear that the buffer input isn't needed when specifying a file path,
but the reverse isn't necessarily true since the file path can be added
as metadata when loading from a buffer. Additionally, the boot_policy
flag (called from_boot_manager in LoadImageSource) is only used when
loading from a file path.

This replaces `BootServices::load_image_from_buffer` with a single
method that can load from either a `[u8]` buffer or a file path via
`SimpleFileSystem`.

The source is modeled with the `LoadImageSource` enum. That helps make
it clear that the buffer input isn't needed when specifying a file path,
but the reverse isn't necessarily true since the file path can be added
as metadata when loading from a buffer. Additionally, the `boot_policy`
flag (called `from_boot_manager` in `LoadImageSource`) is only used when
loading from a file path.
@nicholasbishop
Copy link
Copy Markdown
Member Author

This supersedes #313.

The EFI_BOOT_SERVICES.LoadImage is fairly complex, supporting two pretty different ways of loading an image, so there are a number of different ways the Rust API could look like. Initially I liked the idea of having two separate functions, load_image_from_buffer and load_image_from_path, but then they'd end up duplicating a lot of the docstring. Instead I went with an enum that separates out the possible inputs. It uses named fields, so the call sites can be quite clear.

@GabrielMajeri
Copy link
Copy Markdown
Collaborator

Looks good, agreed that a single function with an enum parameter makes more sense.

@GabrielMajeri GabrielMajeri merged commit e344273 into rust-osdev:main Mar 7, 2022
@nicholasbishop nicholasbishop deleted the bishop-load-image-2 branch March 7, 2022 14:44
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.

2 participants