]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/basic/efivars.h
Merge pull request #13246 from keszybz/add-SystemdOptions-efi-variable
[thirdparty/systemd.git] / src / basic / efivars.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 #if !ENABLE_EFI
5 # include <errno.h>
6 #endif
7 #include <stdbool.h>
8 #include <stddef.h>
9 #include <stdint.h>
10
11 #include "sd-id128.h"
12
13 #include "efi/loader-features.h"
14 #include "time-util.h"
15
16 #define EFI_VENDOR_LOADER SD_ID128_MAKE(4a,67,b0,82,0a,4c,41,cf,b6,c7,44,0b,29,bb,8c,4f)
17 #define EFI_VENDOR_GLOBAL SD_ID128_MAKE(8b,e4,df,61,93,ca,11,d2,aa,0d,00,e0,98,03,2b,8c)
18 #define EFI_VENDOR_SYSTEMD SD_ID128_MAKE(8c,f2,64,4b,4b,0b,42,8f,93,87,6d,87,60,50,dc,67)
19 #define EFI_VARIABLE_NON_VOLATILE 0x0000000000000001
20 #define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x0000000000000002
21 #define EFI_VARIABLE_RUNTIME_ACCESS 0x0000000000000004
22
23 #if ENABLE_EFI
24
25 char* efi_variable_path(sd_id128_t vendor, const char *name);
26 int efi_get_variable(sd_id128_t vendor, const char *name, uint32_t *attribute, void **value, size_t *size);
27 int efi_get_variable_string(sd_id128_t vendor, const char *name, char **p);
28 int efi_set_variable(sd_id128_t vendor, const char *name, const void *value, size_t size);
29 int efi_set_variable_string(sd_id128_t vendor, const char *name, const char *p);
30
31 int efi_systemd_options_variable(char **line);
32
33 #else
34
35 static inline char* efi_variable_path(sd_id128_t vendor, const char *name) {
36 return NULL;
37 }
38
39 static inline int efi_get_variable(sd_id128_t vendor, const char *name, uint32_t *attribute, void **value, size_t *size) {
40 return -EOPNOTSUPP;
41 }
42
43 static inline int efi_get_variable_string(sd_id128_t vendor, const char *name, char **p) {
44 return -EOPNOTSUPP;
45 }
46
47 static inline int efi_set_variable(sd_id128_t vendor, const char *name, const void *value, size_t size) {
48 return -EOPNOTSUPP;
49 }
50
51 static inline int efi_set_variable_string(sd_id128_t vendor, const char *name, const char *p) {
52 return -EOPNOTSUPP;
53 }
54
55 static inline int efi_systemd_options_variable(char **line) {
56 return -ENODATA;
57 }
58
59 #endif