efiio.h revision 1.1 1 /* $NetBSD: efiio.h,v 1.1 2025/02/24 13:47:56 christos Exp $ */
2
3 /*
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
14 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 * SUCH DAMAGE.
24 */
25
26 #ifndef _EFIIO_H_
27 #define _EFIIO_H_
28
29 #ifndef lint
30 __RCSID("$NetBSD: efiio.h,v 1.1 2025/02/24 13:47:56 christos Exp $");
31 #endif /* not lint */
32
33 #include <sys/efiio.h>
34 #include <stdbool.h>
35
36 #include "utils.h"
37
38 /*
39 * {Get,Set}Variable() attribute bits: See sys/efiio.h
40 */
41 #define EFI_VAR_ATTR_BITS \
42 "\177\020" \
43 "b\x0""nvmem\0" \
44 "b\x1""BSAcc\0" \
45 "b\x2""RTAcc\0" \
46 "b\x3""HWErr\0" \
47 "b\x4""WrAcc\0" \
48 "b\x5""TmAuthWr\0" \
49 "b\x6""AppWr\0" \
50 "b\x7""AuthAcc\0"
51
52 typedef struct efi_var_ioc efi_var_ioc_t;
53
54 typedef struct efi_var {
55 efi_var_ioc_t ev;
56 char *name; /* asciiz name string */
57 } efi_var_t;
58
59 static inline void
60 efi_var_init(efi_var_ioc_t *ev, const char *name,
61 uuid_t *vendor, uint32_t attrib)
62 {
63 size_t isz = strlen(name) + 1;
64
65 memset(ev, 0, sizeof(*ev));
66 ev->name = utf8_to_ucs2(name, isz, NULL, &ev->namesize);
67 ev->attrib = attrib;
68 memcpy(&ev->vendor, vendor, sizeof(ev->vendor));
69 }
70
71 int set_variable(int, struct efi_var_ioc *);
72 struct efi_var_ioc get_variable(int, const char *, struct uuid *, uint32_t);
73 struct efi_var_ioc *get_next_variable(int, struct efi_var_ioc *);
74 void *get_table(int, struct uuid *, size_t *);
75 size_t get_variable_info(int, bool (*)(struct efi_var_ioc *, void *),
76 int (*)(struct efi_var_ioc *ev, void *), void *);
77
78 #endif /* _EFIIO_H_ */
79