]> git.ozlabs.org Git - petitboot/blob - lib/efi/efivar.h
lib/crypt: Add helpers for operating on /etc/shadow
[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 <stdbool.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 #define EFI_DEFALT_ATTRIBUTES ( \
34         EFI_VARIABLE_NON_VOLATILE | \
35         EFI_VARIABLE_RUNTIME_ACCESS | \
36         EFI_VARIABLE_BOOTSERVICE_ACCESS \
37 )
38
39 struct efi_data {
40         uint32_t attributes;
41         size_t data_size;
42         void *data;
43         uint8_t fill[0];
44 };
45
46 struct efi_mount {
47         const char *path;
48         const char *guid;
49 };
50
51 void efi_init_mount(struct efi_mount *efi_mount, const char *path,
52         const char *guid);
53 bool efi_check_mount_magic(const struct efi_mount *efi_mount, bool check_magic);
54 static inline bool efi_check_mount(const struct efi_mount *efi_mount)
55 {
56         return efi_check_mount_magic(efi_mount, true);
57 }
58
59 int efi_get_variable(void *ctx, const struct efi_mount *efi_mount,
60         const char *name, struct efi_data **efi_data);
61 int efi_set_variable(const struct efi_mount *efi_mount, const char *name,
62         const struct efi_data *efi_data);
63 int efi_del_variable(const struct efi_mount *efi_mount, const char *name);
64
65 #endif /* EFIVAR_H */