[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v8 01/10] efi: Add grub_efi_set_variable_with_attributes()
From: |
Oliver Steffen |
Subject: |
[PATCH v8 01/10] efi: Add grub_efi_set_variable_with_attributes() |
Date: |
Wed, 24 May 2023 16:55:49 +0200 |
Add a function to the EFI module that allows setting EFI variables
with specific attributes.
This is useful for marking variables as volatile, for example.
Signed-off-by: Oliver Steffen <osteffen@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
---
grub-core/kern/efi/efi.c | 19 +++++++++++++------
include/grub/efi/efi.h | 6 ++++++
2 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c
index cf49d6357..03abf5531 100644
--- a/grub-core/kern/efi/efi.c
+++ b/grub-core/kern/efi/efi.c
@@ -201,8 +201,8 @@ grub_efi_set_virtual_address_map (grub_efi_uintn_t
memory_map_size,
}
grub_err_t
-grub_efi_set_variable(const char *var, const grub_efi_guid_t *guid,
- void *data, grub_size_t datasize)
+grub_efi_set_variable_with_attributes (const char *var, const grub_efi_guid_t
*guid,
+ void *data, grub_size_t datasize, grub_efi_uint32_t
attributes)
{
grub_efi_status_t status;
grub_efi_runtime_services_t *r;
@@ -219,10 +219,7 @@ grub_efi_set_variable(const char *var, const
grub_efi_guid_t *guid,
r = grub_efi_system_table->runtime_services;
- status = efi_call_5 (r->set_variable, var16, guid,
- (GRUB_EFI_VARIABLE_NON_VOLATILE
- | GRUB_EFI_VARIABLE_BOOTSERVICE_ACCESS
- | GRUB_EFI_VARIABLE_RUNTIME_ACCESS),
+ status = efi_call_5 (r->set_variable, var16, guid, attributes,
datasize, data);
grub_free (var16);
if (status == GRUB_EFI_SUCCESS)
@@ -231,6 +228,16 @@ grub_efi_set_variable(const char *var, const
grub_efi_guid_t *guid,
return grub_error (GRUB_ERR_IO, "could not set EFI variable `%s'", var);
}
+grub_err_t
+grub_efi_set_variable (const char *var, const grub_efi_guid_t *guid,
+ void *data, grub_size_t datasize)
+{
+ return grub_efi_set_variable_with_attributes (var, guid, data, datasize,
+ GRUB_EFI_VARIABLE_NON_VOLATILE
+ | GRUB_EFI_VARIABLE_BOOTSERVICE_ACCESS
+ | GRUB_EFI_VARIABLE_RUNTIME_ACCESS);
+}
+
grub_efi_status_t
grub_efi_get_variable_with_attributes (const char *var,
const grub_efi_guid_t *guid,
diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h
index 7c12cb9aa..74e242194 100644
--- a/include/grub/efi/efi.h
+++ b/include/grub/efi/efi.h
@@ -98,6 +98,12 @@ grub_efi_status_t EXPORT_FUNC (grub_efi_get_variable) (const
char *variable,
grub_size_t
*datasize_out,
void **data_out);
grub_err_t
+EXPORT_FUNC (grub_efi_set_variable_with_attributes) (const char *var,
+ const grub_efi_guid_t *guid,
+ void *data,
+ grub_size_t datasize,
+ grub_efi_uint32_t attributes);
+grub_err_t
EXPORT_FUNC (grub_efi_set_variable) (const char *var,
const grub_efi_guid_t *guid,
void *data,
--
2.40.1
- [PATCH v8 00/10] Add basic Boot Loader Interface support, Oliver Steffen, 2023/05/24
- [PATCH v8 04/10] grub-core: Make use of guid printf format specifier, Oliver Steffen, 2023/05/24
- [PATCH v8 03/10] kern/misc: Add a format specifier GUIDs, Oliver Steffen, 2023/05/24
- [PATCH v8 02/10] Unify GUID types, Oliver Steffen, 2023/05/24
- [PATCH v8 01/10] efi: Add grub_efi_set_variable_with_attributes(),
Oliver Steffen <=
- [PATCH v8 06/10] kern/misc, kern/efi: Extract UTF-8 to UTF-16 code, Oliver Steffen, 2023/05/24
- [PATCH v8 07/10] efi: Add grub_efi_set_variable_to_string(), Oliver Steffen, 2023/05/24
- [PATCH v8 05/10] types.h: Add GRUB_SSIZE_MAX, Oliver Steffen, 2023/05/24
- [PATCH v8 08/10] docs: Reword section headings, Oliver Steffen, 2023/05/24
- [PATCH v8 10/10] util/grub.d: Activate bli module on EFI, Oliver Steffen, 2023/05/24
- [PATCH v8 09/10] Add a module for the Boot Loader Interface, Oliver Steffen, 2023/05/24
- Re: [PATCH v8 00/10] Add basic Boot Loader Interface support, Daniel Kiper, 2023/05/25