]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/efivars.h
050649bce2de79266927b78ce95071ca50353ad1
[thirdparty/systemd.git] / src / shared / efivars.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 /***
5 This file is part of systemd.
6
7 Copyright 2013 Lennart Poettering
8 ***/
9
10 #if ! ENABLE_EFI
11 #include <errno.h>
12 #endif
13 #include <stdbool.h>
14 #include <stddef.h>
15 #include <stdint.h>
16
17 #include "sd-id128.h"
18
19 #include "time-util.h"
20
21 #define EFI_VENDOR_LOADER SD_ID128_MAKE(4a,67,b0,82,0a,4c,41,cf,b6,c7,44,0b,29,bb,8c,4f)
22 #define EFI_VENDOR_GLOBAL SD_ID128_MAKE(8b,e4,df,61,93,ca,11,d2,aa,0d,00,e0,98,03,2b,8c)
23 #define EFI_VARIABLE_NON_VOLATILE 0x0000000000000001
24 #define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x0000000000000002
25 #define EFI_VARIABLE_RUNTIME_ACCESS 0x0000000000000004
26
27 #if ENABLE_EFI
28
29 bool is_efi_boot(void);
30 bool is_efi_secure_boot(void);
31 bool is_efi_secure_boot_setup_mode(void);
32 int efi_reboot_to_firmware_supported(void);
33 int efi_get_reboot_to_firmware(void);
34 int efi_set_reboot_to_firmware(bool value);
35
36 int efi_get_variable(sd_id128_t vendor, const char *name, uint32_t *attribute, void **value, size_t *size);
37 int efi_set_variable(sd_id128_t vendor, const char *name, const void *value, size_t size);
38 int efi_get_variable_string(sd_id128_t vendor, const char *name, char **p);
39
40 int efi_get_boot_option(uint16_t nr, char **title, sd_id128_t *part_uuid, char **path, bool *active);
41 int efi_add_boot_option(uint16_t id, const char *title, uint32_t part, uint64_t pstart, uint64_t psize, sd_id128_t part_uuid, const char *path);
42 int efi_remove_boot_option(uint16_t id);
43 int efi_get_boot_order(uint16_t **order);
44 int efi_set_boot_order(uint16_t *order, size_t n);
45 int efi_get_boot_options(uint16_t **options);
46
47 int efi_loader_get_device_part_uuid(sd_id128_t *u);
48 int efi_loader_get_boot_usec(usec_t *firmware, usec_t *loader);
49
50 #else
51
52 static inline bool is_efi_boot(void) {
53 return false;
54 }
55
56 static inline bool is_efi_secure_boot(void) {
57 return false;
58 }
59
60 static inline bool is_efi_secure_boot_setup_mode(void) {
61 return false;
62 }
63
64 static inline int efi_reboot_to_firmware_supported(void) {
65 return -EOPNOTSUPP;
66 }
67
68 static inline int efi_get_reboot_to_firmware(void) {
69 return -EOPNOTSUPP;
70 }
71
72 static inline int efi_set_reboot_to_firmware(bool value) {
73 return -EOPNOTSUPP;
74 }
75
76 static inline int efi_get_variable(sd_id128_t vendor, const char *name, uint32_t *attribute, void **value, size_t *size) {
77 return -EOPNOTSUPP;
78 }
79
80 static inline int efi_set_variable(sd_id128_t vendor, const char *name, const void *value, size_t size) {
81 return -EOPNOTSUPP;
82 }
83
84 static inline int efi_get_variable_string(sd_id128_t vendor, const char *name, char **p) {
85 return -EOPNOTSUPP;
86 }
87
88 static inline int efi_get_boot_option(uint16_t nr, char **title, sd_id128_t *part_uuid, char **path, bool *active) {
89 return -EOPNOTSUPP;
90 }
91
92 static inline int efi_add_boot_option(uint16_t id, const char *title, uint32_t part, uint64_t pstart, uint64_t psize, sd_id128_t part_uuid, const char *path) {
93 return -EOPNOTSUPP;
94 }
95
96 static inline int efi_remove_boot_option(uint16_t id) {
97 return -EOPNOTSUPP;
98 }
99
100 static inline int efi_get_boot_order(uint16_t **order) {
101 return -EOPNOTSUPP;
102 }
103
104 static inline int efi_set_boot_order(uint16_t *order, size_t n) {
105 return -EOPNOTSUPP;
106 }
107
108 static inline int efi_get_boot_options(uint16_t **options) {
109 return -EOPNOTSUPP;
110 }
111
112 static inline int efi_loader_get_device_part_uuid(sd_id128_t *u) {
113 return -EOPNOTSUPP;
114 }
115
116 static inline int efi_loader_get_boot_usec(usec_t *firmware, usec_t *loader) {
117 return -EOPNOTSUPP;
118 }
119
120 #endif
121
122 char *efi_tilt_backslashes(char *s);