Skip to content

Commit

Permalink
vendorcode/dasharo: add function to wipe options
Browse files Browse the repository at this point in the history
Signed-off-by: Michał Kopeć <[email protected]>
  • Loading branch information
mkopec committed Oct 23, 2023
1 parent 9dac2d9 commit 12bd29e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/vendorcode/dasharo/include/dasharo/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ struct battery_config {
uint8_t stop_threshold;
} __packed;

/* Attempts to wipe the SMMSTORE region in order to reset EFI options.
* UEFIPayload will populate it with default values upon boot.
*
* Result:
* - CB_SUCCESS - Success
* - CB_ERR - Failure, including partial wipe
*/
enum cb_err dasharo_reset_options(void);

/* Looks up "power_on_after_fail" option and Dasharo/"PowerFailureState"
* variable.
*
Expand Down
15 changes: 15 additions & 0 deletions src/vendorcode/dasharo/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,21 @@ static enum cb_err read_bool_var(const char *var_name, bool *var)
return CB_ERR;
}

enum cb_err dasharo_reset_options(void)
{
struct region_device rdev;
ssize_t res;

if (smmstore_lookup_region(&rdev))
return CB_ERR;

res = rdev_eraseat(&rdev, 0, region_device_sz(&rdev));
if (res != region_device_sz(&rdev))
return CB_ERR;

return CB_SUCCESS;
}

uint8_t dasharo_get_power_on_after_fail(void)
{
uint8_t power_status;
Expand Down

0 comments on commit 12bd29e

Please sign in to comment.