efi_loader: separate UEFI variable API from implemementation
[platform/kernel/u-boot.git] / include / efi_variable.h
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright (c) 2020, Heinrich Schuchardt <xypron.glpk@gmx.de>
4  */
5
6 #ifndef _EFI_VARIABLE_H
7 #define _EFI_VARIABLE_H
8
9 #include <linux/bitops.h>
10
11 #define EFI_VARIABLE_READ_ONLY BIT(31)
12
13 /**
14  * efi_get_variable() - retrieve value of a UEFI variable
15  *
16  * @variable_name:      name of the variable
17  * @vendor:             vendor GUID
18  * @attributes:         attributes of the variable
19  * @data_size:          size of the buffer to which the variable value is copied
20  * @data:               buffer to which the variable value is copied
21  * @timep:              authentication time (seconds since start of epoch)
22  * Return:              status code
23  */
24 efi_status_t efi_get_variable_int(u16 *variable_name, const efi_guid_t *vendor,
25                                   u32 *attributes, efi_uintn_t *data_size,
26                                   void *data, u64 *timep);
27
28 /**
29  * efi_set_variable() - set value of a UEFI variable
30  *
31  * @variable_name:      name of the variable
32  * @vendor:             vendor GUID
33  * @attributes:         attributes of the variable
34  * @data_size:          size of the buffer with the variable value
35  * @data:               buffer with the variable value
36  * @ro_check:           check the read only read only bit in attributes
37  * Return:              status code
38  */
39 efi_status_t efi_set_variable_int(u16 *variable_name, const efi_guid_t *vendor,
40                                   u32 attributes, efi_uintn_t data_size,
41                                   const void *data, bool ro_check);
42
43 /**
44  * efi_get_next_variable_name_int() - enumerate the current variable names
45  *
46  * @variable_name_size: size of variable_name buffer in byte
47  * @variable_name:      name of uefi variable's name in u16
48  * @vendor:             vendor's guid
49  *
50  * See the Unified Extensible Firmware Interface (UEFI) specification for
51  * details.
52  *
53  * Return: status code
54  */
55 efi_status_t efi_get_next_variable_name_int(efi_uintn_t *variable_name_size,
56                                             u16 *variable_name,
57                                             efi_guid_t *vendor);
58
59 /**
60  * efi_query_variable_info_int() - get information about EFI variables
61  *
62  * This function implements the QueryVariableInfo() runtime service.
63  *
64  * See the Unified Extensible Firmware Interface (UEFI) specification for
65  * details.
66  *
67  * @attributes:                         bitmask to select variables to be
68  *                                      queried
69  * @maximum_variable_storage_size:      maximum size of storage area for the
70  *                                      selected variable types
71  * @remaining_variable_storage_size:    remaining size of storage are for the
72  *                                      selected variable types
73  * @maximum_variable_size:              maximum size of a variable of the
74  *                                      selected type
75  * Returns:                             status code
76  */
77 efi_status_t efi_query_variable_info_int(u32 attributes,
78                                          u64 *maximum_variable_storage_size,
79                                          u64 *remaining_variable_storage_size,
80                                          u64 *maximum_variable_size);
81
82 #endif