Blob Blame History Raw
From 2117a21fed77fc4cb66da7fc4441af4c871f2ccf Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Mon, 3 Feb 2020 13:24:30 -0500
Subject: [PATCH 79/86] efivar: Split types and guids out into a different
 header.

Signed-off-by: Peter Jones <pjones@redhat.com>
---
 src/export.c                      |  8 ----
 src/include/efivar/efivar-types.h | 64 +++++++++++++++++++++++++++++++
 src/include/efivar/efivar.h       | 44 +--------------------
 src/lib.h                         |  8 ++++
 src/libefivar.map.in              |  1 +
 5 files changed, 74 insertions(+), 51 deletions(-)
 create mode 100644 src/include/efivar/efivar-types.h

diff --git a/src/export.c b/src/export.c
index 30f706484ab..c65002cd100 100644
--- a/src/export.c
+++ b/src/export.c
@@ -18,14 +18,6 @@
 #define ATTRS_UNSET 0xa5a5a5a5a5a5a5a5
 #define ATTRS_MASK 0xffffffff
 
-struct efi_variable {
-	uint64_t attrs;
-	efi_guid_t *guid;
-	unsigned char *name;
-	uint8_t *data;
-	size_t data_size;
-};
-
 /* The exported structure is:
  * struct {
  *	uint32_t magic;
diff --git a/src/include/efivar/efivar-types.h b/src/include/efivar/efivar-types.h
new file mode 100644
index 00000000000..6fca8a495f4
--- /dev/null
+++ b/src/include/efivar/efivar-types.h
@@ -0,0 +1,64 @@
+// SPDX-License-Identifier: LGPL-2.1
+/*
+ * Copyright 2012-2020 Red Hat, Inc.
+ * Copyright 2012-2020 Peter M. Jones <pjones@redhat.com>
+ *
+ * Author(s): Peter Jones <pjones@redhat.com>
+ */
+#ifndef EFI_TYPES_H
+#define EFI_TYPES_H 1
+
+#include <stdint.h>
+
+typedef struct {
+	uint32_t	a;
+	uint16_t	b;
+	uint16_t	c;
+	uint16_t	d;
+	uint8_t		e[6];
+} efi_guid_t __attribute__((__aligned__(1)));
+
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define EFI_GUID(a,b,c,d,e0,e1,e2,e3,e4,e5) \
+((efi_guid_t) {(a), (b), (c), __builtin_bswap16(d), { (e0), (e1), (e2), (e3), (e4), (e5) }})
+#else
+#define EFI_GUID(a,b,c,d,e0,e1,e2,e3,e4,e5) \
+((efi_guid_t) {(a), (b), (c), (d), { (e0), (e1), (e2), (e3), (e4), (e5) }})
+#endif
+
+#define EFI_GLOBAL_GUID EFI_GUID(0x8be4df61,0x93ca,0x11d2,0xaa0d,0x00,0xe0,0x98,0x03,0x2b,0x8c)
+
+typedef struct {
+	uint8_t		addr[4];
+} efi_ipv4_addr_t;
+
+typedef struct {
+	uint8_t		addr[16];
+} efi_ipv6_addr_t;
+
+typedef union {
+	uint32_t	addr[4];
+	efi_ipv4_addr_t	v4;
+	efi_ipv6_addr_t	v6;
+} efi_ip_addr_t;
+
+typedef struct {
+	uint8_t		addr[32];
+} efi_mac_addr_t;
+
+typedef unsigned long efi_status_t;
+typedef uint16_t efi_char16_t;
+typedef unsigned long uintn_t;
+typedef long intn_t;
+
+#define EFI_VARIABLE_NON_VOLATILE				((uint64_t)0x0000000000000001)
+#define EFI_VARIABLE_BOOTSERVICE_ACCESS				((uint64_t)0x0000000000000002)
+#define EFI_VARIABLE_RUNTIME_ACCESS				((uint64_t)0x0000000000000004)
+#define EFI_VARIABLE_HARDWARE_ERROR_RECORD			((uint64_t)0x0000000000000008)
+#define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS			((uint64_t)0x0000000000000010)
+#define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS	((uint64_t)0x0000000000000020)
+#define EFI_VARIABLE_APPEND_WRITE				((uint64_t)0x0000000000000040)
+#define EFI_VARIABLE_ENHANCED_AUTHENTICATED_ACCESS		((uint64_t)0x0000000000000080)
+
+#endif /* EFI_TYPES_H */
+// vim:fenc=utf-8:tw=75:noet
diff --git a/src/include/efivar/efivar.h b/src/include/efivar/efivar.h
index cc5dcc5657a..6b38ce8faf4 100644
--- a/src/include/efivar/efivar.h
+++ b/src/include/efivar/efivar.h
@@ -17,54 +17,12 @@
 #include <unistd.h>
 #include <byteswap.h>
 
-typedef struct {
-	uint32_t	a;
-	uint16_t	b;
-	uint16_t	c;
-	uint16_t	d;
-	uint8_t		e[6];
-} efi_guid_t __attribute__((__aligned__(1)));
-
-typedef struct {
-	uint8_t		addr[4];
-} efi_ipv4_addr_t;
-
-typedef struct {
-	uint8_t		addr[16];
-} efi_ipv6_addr_t;
-
-typedef union {
-	uint32_t	addr[4];
-	efi_ipv4_addr_t	v4;
-	efi_ipv6_addr_t	v6;
-} efi_ip_addr_t;
-
-typedef struct {
-	uint8_t		addr[32];
-} efi_mac_addr_t;
+#include <efivar/efivar-types.h>
 
 #ifndef EFIVAR_BUILD_ENVIRONMENT
 #include <efivar/efivar-guids.h>
 #endif
 
-#if BYTE_ORDER == LITTLE_ENDIAN
-#define EFI_GUID(a,b,c,d,e0,e1,e2,e3,e4,e5) \
-((efi_guid_t) {(a), (b), (c), __builtin_bswap16(d), { (e0), (e1), (e2), (e3), (e4), (e5) }})
-#else
-#define EFI_GUID(a,b,c,d,e0,e1,e2,e3,e4,e5) \
-((efi_guid_t) {(a), (b), (c), (d), { (e0), (e1), (e2), (e3), (e4), (e5) }})
-#endif
-
-#define EFI_GLOBAL_GUID EFI_GUID(0x8be4df61,0x93ca,0x11d2,0xaa0d,0x00,0xe0,0x98,0x03,0x2b,0x8c)
-
-#define EFI_VARIABLE_NON_VOLATILE	0x0000000000000001
-#define EFI_VARIABLE_BOOTSERVICE_ACCESS	0x0000000000000002
-#define EFI_VARIABLE_RUNTIME_ACCESS	0x0000000000000004
-#define EFI_VARIABLE_HARDWARE_ERROR_RECORD	0x0000000000000008
-#define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS	0x0000000000000010
-#define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS 0x0000000000000020
-#define EFI_VARIABLE_APPEND_WRITE	0x0000000000000040
-
 #define EFI_VARIABLE_HAS_AUTH_HEADER	0x0000000100000000
 #define EFI_VARIABLE_HAS_SIGNATURE	0x0000000200000000
 
diff --git a/src/lib.h b/src/lib.h
index 26e0f169bd1..21ebc9a818a 100644
--- a/src/lib.h
+++ b/src/lib.h
@@ -12,6 +12,14 @@
 
 #define GUID_FORMAT "%08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x"
 
+struct efi_variable {
+	uint64_t attrs;
+	efi_guid_t *guid;
+	unsigned char *name;
+	uint8_t *data;
+	size_t data_size;
+};
+
 struct efi_var_operations {
 	char name[NAME_MAX];
 	int (*probe)(void);
diff --git a/src/libefivar.map.in b/src/libefivar.map.in
index 54bfb765998..f2505134c63 100644
--- a/src/libefivar.map.in
+++ b/src/libefivar.map.in
@@ -136,6 +136,7 @@ LIBEFIVAR_1.38 {
 		efi_set_loglevel;
 		efi_get_libefivar_version;
 		efi_guid_grub;
+		efi_guid_external_management;
 		efi_variable_alloc;
 		efi_variable_export_dmpstore;
 } LIBEFIVAR_1.37;
-- 
2.24.1