Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add uefi::system module#1237

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

nicholasbishop
Copy link
Member

@nicholasbishopnicholasbishop commentedJul 9, 2024
edited
Loading

This is similar to existing methods ofSystemTable, but as freestanding functions that use the global system table pointer.

Splitting this out from#905, thesystem module provides a good starting point to get a sense of whatuefi::{system,boot,runtime} will look like.

#893

Checklist

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

phip1611 reacted with rocket emoji
@phip1611
Copy link
Member

Could you please add a usage in the test-runner as well?

nicholasbishop reacted with thumbs up emoji

@nicholasbishopnicholasbishopforce-pushed thebishop-system-freestanding branch fromf8ce0bd to7f08f5cCompareJuly 13, 2024 17:06
@nicholasbishop
Copy link
MemberAuthor

Added tests (one of which requiredPartialEq onConfigTableEntry, so I went ahead and added all the usual derives there).

/// # Panics
///
/// Panics if the global system table pointer is null.
pub(crate) fn system_table_raw() -> NonNull<uefi_raw::table::system::SystemTable> {
Copy link
Member

Choose a reason for hiding this comment

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

I'm sorry for postponing this further, but I'm unsure regarding the API. Here, we panic and return aNonNull.system_table_boot() and system_table_runtime() below returnOptions. Is this consistent? Or is it fine to have this difference between internal and public API?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

No worries, happy to discuss API decisions. I think having both panicking and non-panicking variants is useful, depending on the circumstances. The function that gets the raw system table should essentially never fail -- the panic can only be reached if the table pointer is null, which means the user isn't using theentry macro, or has anunsafe call toset_system_table(null).

In the high-level API, we could (for example) changesystem::firmware_vendor to return aResult, with an error if the system table is null. But in practice, I think it's likely that users would simplyunwrap the result anyway.

If we accept the above argument, that means will have a decent number of places where we want to panic internally if the system table isn't set. And for each of those places we want to useexpect with a clear error message rather thanunwrap, so if that panic is ever hit it's clear why. And since we don't want to write out.expect("global system table pointer is not set") in multiple places, we end up with this shared function.

I'll also note that I see thesystem_table_boot andsystem_table_runtime functions as transitional APIs. Once thesystem,boot, andruntime modules are in place, I want to markSystemTable,BootServices, andRuntimeServices as deprecated, and then after a release or two we can remove those deprecated APIs entirely.

Now, with all that said, we might want a non-panicking variant in the future as well (e.g. for functions that already return aResult), so I've pushed a change to rename it tosystem_table_raw_panicking.

Copy link
Member

Choose a reason for hiding this comment

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

But in practice, I think it's likely that users would simply unwrap the result anyway.

Agree

I'll also note that I see the system_table_boot and system_table_runtime functions as transitional API

got it

I want to mark SystemTable, BootServices, and RuntimeServices as deprecated, and then after a release or two we can remove those deprecated APIs entirely.

Is there already a todo anywhere for that?


Generally, I think panicking at a core function is perfectly fine. Especially, as this will never fail, if people properly use the#[entry] macro.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Is there already a todo anywhere for that?

Added a new summary comment here:#893 (comment)

@nicholasbishopnicholasbishopforce-pushed thebishop-system-freestanding branch from7f08f5c toa969517CompareJuly 15, 2024 00:36
This is `pub(crate)`, not part of the public API currently.
This is similar to existing methods of `SystemTable`, but as freestandingfunctions that use the global system table pointer.
@nicholasbishopnicholasbishopforce-pushed thebishop-system-freestanding branch froma969517 to46e47c7CompareJuly 15, 2024 00:39
@@ -1,5 +1,10 @@
# uefi - [Unreleased]

## Added
- `uefi::system` is a new module that provides freestanding functions for
Copy link
Member

Choose a reason for hiding this comment

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

nit: In a follow-up: We might should add a[new api] "tag" for that in the changelog - this might ease consumers to understand what's going on

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Agreed, I was thinking maybe just add a short paragraph between# uefi and## Added .

@phip1611phip1611 added this pull request to themerge queueJul 15, 2024
Merged via the queue intorust-osdev:main with commit7a0a8eeJul 15, 2024
12 checks passed
@nicholasbishopnicholasbishop deleted the bishop-system-freestanding branchJuly 15, 2024 15:37
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@phip1611phip1611phip1611 approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@nicholasbishop@phip1611

[8]ページ先頭

©2009-2025 Movatter.jp