]> git.ozlabs.org Git - petitboot/blob - lib/efi/efivar.h
lib/efi: Cleanup read/write routines
[petitboot] / lib / efi / efivar.h
1 /*
2  *  This program is free software; you can redistribute it and/or modify
3  *  it under the terms of the GNU General Public License as published by
4  *  the Free Software Foundation; version 2 of the License.
5  *
6  *  This program is distributed in the hope that it will be useful,
7  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
8  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9  *  GNU General Public License for more details.
10  *
11  *  You should have received a copy of the GNU General Public License
12  *  along with this program; if not, write to the Free Software
13  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
14  *
15  *  Copyright (C) 2018 Huaxintong Semiconductor Technology Co.,Ltd. All rights
16  *  reserved.
17  *  Author: Ge Song <ge.song@hxt-semitech.com>
18  */
19 #ifndef EFIVAR_H
20 #define EFIVAR_H
21
22 #include <linux/magic.h>
23 #include <stdint.h>
24
25 #define EFI_VARIABLE_NON_VOLATILE                           0x00000001
26 #define EFI_VARIABLE_BOOTSERVICE_ACCESS                     0x00000002
27 #define EFI_VARIABLE_RUNTIME_ACCESS                         0x00000004
28 #define EFI_VARIABLE_HARDWARE_ERROR_RECORD                  0x00000008
29 #define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS             0x00000010
30 #define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS  0x00000020
31 #define EFI_VARIABLE_APPEND_WRITE                           0x00000040
32
33 #ifndef EFIVARFS_MAGIC
34 #define EFIVARFS_MAGIC 0xde5e81e4
35 #endif
36
37 struct efi_data {
38         uint32_t attributes;
39         size_t data_size;
40         void *data;
41         uint8_t fill[0];
42 };
43
44 void set_efivarfs_path(const char *path);
45 const char *get_efivarfs_path(void);
46
47 int efi_get_variable(void *ctx, const char *guidstr, const char *name,
48                 struct efi_data **efi_data);
49 int efi_set_variable(const char *guidstr, const char *name,
50                 const struct efi_data *efi_data);
51 int efi_del_variable(const char *guidstr, const char *name);
52
53 #endif /* EFIVAR_H */