acpi: Add IORT helper functions
[coreboot2.git] / src / drivers / efi / option.c
blobd634c963545dec2c9e578ba9d6af6c1c78bd50bd
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <option.h>
4 #include <smmstore.h>
6 #include <Uefi/UefiBaseType.h>
8 #include "efivars.h"
10 static const EFI_GUID EficorebootNvDataGuid = {
11 0xceae4c1d, 0x335b, 0x4685, { 0xa4, 0xa0, 0xfc, 0x4a, 0x94, 0xee, 0xa0, 0x85 } };
13 unsigned int get_uint_option(const char *name, const unsigned int fallback)
15 struct region_device rdev;
16 enum cb_err ret;
17 uint32_t var;
18 uint32_t size;
20 if (smmstore_lookup_region(&rdev))
21 return fallback;
23 var = 0;
24 size = sizeof(var);
25 ret = efi_fv_get_option(&rdev, &EficorebootNvDataGuid, name, &var, &size);
26 if (ret != CB_SUCCESS)
27 return fallback;
29 return var;
32 enum cb_err set_uint_option(const char *name, unsigned int value)
34 struct region_device rdev;
35 uint32_t var = value;
37 if (smmstore_lookup_region(&rdev))
38 return CB_CMOS_OTABLE_DISABLED;
40 return efi_fv_set_option(&rdev, &EficorebootNvDataGuid, name, &var, sizeof(var));