xref: /netbsd-src/sys/sys/efiio.h (revision 007aafd79d7bf49fb0445342715c73e5f333318c)
1 /* $NetBSD: efiio.h,v 1.3 2023/05/22 16:27:58 riastradh Exp $ */
2 
3 /*-
4  * Copyright (c) 2021 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Jared McNeill <jmcneill@invisible.ca>.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef _SYS_EFIIO_H
33 #define _SYS_EFIIO_H
34 
35 #include <sys/types.h>
36 #include <sys/ioccom.h>
37 #include <sys/uuid.h>
38 
39 /*
40  * Variable attributes
41  */
42 #define	EFI_VARIABLE_NON_VOLATILE				0x00000001
43 #define	EFI_VARIABLE_BOOTSERVICE_ACCESS				0x00000002
44 #define	EFI_VARIABLE_RUNTIME_ACCESS				0x00000004
45 #define	EFI_VARIABLE_HARDWARE_ERROR_RECORD			0x00000008
46 #define	EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS			0x00000010
47 #define	EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS	0x00000020
48 #define	EFI_VARIABLE_APPEND_WRITE				0x00000040
49 #define	EFI_VARIABLE_ENHANCED_AUTHENTICATED_ACCESS		0x00000080
50 
51 struct efi_get_table_ioc {
52 	void *		buf;
53 	struct uuid	uuid;
54 	size_t		table_len;
55 	size_t		buf_len;
56 };
57 
58 struct efi_var_ioc {
59 	uint16_t *	name;		/* vendor's variable name */
60 	size_t		namesize;	/* size in bytes of the name buffer */
61 	struct uuid	vendor;		/* unique identifier for vendor */
62 	uint32_t	attrib;		/* variable attribute bitmask */
63 	void *		data;		/* buffer containing variable data */
64 	size_t		datasize;	/* size in bytes of the data buffer */
65 };
66 
67 #define	EFIIOC_GET_TABLE	_IOWR('e', 1, struct efi_get_table_ioc)
68 #define	EFIIOC_VAR_GET		_IOWR('e', 4, struct efi_var_ioc)
69 #define	EFIIOC_VAR_NEXT		_IOWR('e', 5, struct efi_var_ioc)
70 #define	EFIIOC_VAR_SET		_IOWR('e', 7, struct efi_var_ioc)
71 
72 #endif /* _SYS_EFIIO_H */
73