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 set_watchdog_timer implementation and test #27

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

Merged
GabrielMajeri merged 1 commit into rust-osdev:master from gil0mendes:feature/watchdog
Sep 22, 2018

Conversation

Copy link
Contributor

@gil0mendes gil0mendes commented Sep 22, 2018

This implements the set_watchdog_timer function and correspondent test.

Copy link
Collaborator

Thanks for your contribution

@GabrielMajeri GabrielMajeri merged commit b7d9f26 into rust-osdev:master Sep 22, 2018
@@ -236,6 +236,11 @@ impl BootServices {
assert_eq!((self.stall)(time), Status::Success);
}

/// Set the watchdog timer.
pub fn set_watchdog_timer(&self, timeout: usize, watchdog_code: u64, data_size: usize, watchdog_data: *mut u16) {
assert_eq!((self.set_watchdog_timer)(timeout, watchdog_code, data_size, watchdog_data), Status::Success);
Copy link
Contributor

@HadrienG2 HadrienG2 Sep 22, 2018
edited
Loading

Choose a reason for hiding this comment

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

This method can return status codes other than Success if the wrong parameters are passed in or the system does not have a watchdog timer, therefore a Result should be propagated.

Copy link
Contributor Author

@gil0mendes gil0mendes Sep 22, 2018

Choose a reason for hiding this comment

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

@GabrielMajeri Already applied some changes on master :)

Copy link
Contributor

@HadrienG2 HadrienG2 Sep 22, 2018

Choose a reason for hiding this comment

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

Gotta go fast! 😄

gil0mendes reacted with laugh emoji
@@ -236,6 +236,11 @@ impl BootServices {
assert_eq!((self.stall)(time), Status::Success);
}

/// Set the watchdog timer.
pub fn set_watchdog_timer(&self, timeout: usize, watchdog_code: u64, data_size: usize, watchdog_data: *mut u16) {
Copy link
Contributor

@HadrienG2 HadrienG2 Sep 22, 2018
edited
Loading

Choose a reason for hiding this comment

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

This method should probably be unsafe since 1/it takes an unchecked pointer as a parameter and 2/data_size is not related in any way to the watchdog_data pointer so safety-critical caller mistakes can happen here as well.

Copy link
Contributor

@HadrienG2 HadrienG2 Sep 22, 2018
edited
Loading

Choose a reason for hiding this comment

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

A safe alternative would be to pass in a slice of u16s.

}

fn test_watchdog(bt: &BootServices) {
bt.set_watchdog_timer(0, 0, 0, ptr::null_mut());
Copy link
Contributor

@HadrienG2 HadrienG2 Sep 22, 2018

Choose a reason for hiding this comment

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

This is a more minor point, but I'm not sure if the UEFI spec allows you to use 0 as a watchdog code. It does say that codes from 0 to 0xffff are reserved by the implementation...

Copy link
Contributor Author

@gil0mendes gil0mendes Sep 22, 2018

Choose a reason for hiding this comment

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

Firmware is required to set a 5-minute watchdog timer before running an image, setting the code 0 to 0 disables it.

Copy link
Contributor Author

@gil0mendes gil0mendes Sep 22, 2018

Choose a reason for hiding this comment

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

Copy link
Contributor

@HadrienG2 HadrienG2 Sep 22, 2018

Choose a reason for hiding this comment

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

According to the UEFI spec, it is the timeout parameter that must be set to zero to disable the watchdog timer. The WatchdogCode is something that will be logged on a timeout event. Now, since we're disabling the timeout, that will never happen, but an UEFI implementation that carefully validates its inputs could still complain about our use of a reserved code.

Copy link
Contributor

@HadrienG2 HadrienG2 Sep 22, 2018

Choose a reason for hiding this comment

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

The rather hypothetical nature of an UEFI implementation that checks its inputs so carefully is why I classified this as a less pressing issue 😄

Copy link
Contributor

@HadrienG2 HadrienG2 Sep 22, 2018
edited
Loading

Choose a reason for hiding this comment

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

I opened #28 to resolve this.

@gil0mendes gil0mendes deleted the feature/watchdog branch September 23, 2018 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
1 more reviewer

@HadrienG2 HadrienG2 HadrienG2 left review comments

Reviewers whose approvals may not affect merge requirements
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /