git: 6849950da7d7 - main - arm64/machdep: Add parameter to the EFI table walking code

From: Warner Losh <imp_at_FreeBSD.org>
Date: Wed, 30 Nov 2022 23:31:59 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=6849950da7d770fa6531b915922799c20e960d42

commit 6849950da7d770fa6531b915922799c20e960d42
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2022-11-30 23:28:01 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2022-11-30 23:31:14 +0000

    arm64/machdep: Add parameter to the EFI table walking code
    
    It would be nice to be able to pass an arbitrary pointer to the callback
    code. Add one, and pass NULL in all the places that we do that today.
    As noted by andrew@, we should likely refactor this into MI code and use
    it here and amd64, but for the future.
    
    Sponsored by:           Netflix
    Reviewed by:            rpokala
    Differential Revision:  https://reviews.freebsd.org/D37439
---
 sys/arm64/arm64/machdep.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c
index c48f2ff037c9..33635f732cac 100644
--- a/sys/arm64/arm64/machdep.c
+++ b/sys/arm64/arm64/machdep.c
@@ -421,10 +421,10 @@ arm64_get_writable_addr(vm_offset_t addr, vm_offset_t *out)
 	return (false);
 }
 
-typedef void (*efi_map_entry_cb)(struct efi_md *);
+typedef void (*efi_map_entry_cb)(struct efi_md *, void *argp);
 
 static void
-foreach_efi_map_entry(struct efi_map_header *efihdr, efi_map_entry_cb cb)
+foreach_efi_map_entry(struct efi_map_header *efihdr, efi_map_entry_cb cb, void *argp)
 {
 	struct efi_md *map, *p;
 	size_t efisz;
@@ -443,12 +443,12 @@ foreach_efi_map_entry(struct efi_map_header *efihdr, efi_map_entry_cb cb)
 
 	for (i = 0, p = map; i < ndesc; i++,
 	    p = efi_next_descriptor(p, efihdr->descriptor_size)) {
-		cb(p);
+		cb(p, argp);
 	}
 }
 
 static void
-exclude_efi_map_entry(struct efi_md *p)
+exclude_efi_map_entry(struct efi_md *p, void *argp __unused)
 {
 
 	switch (p->md_type) {
@@ -471,11 +471,11 @@ static void
 exclude_efi_map_entries(struct efi_map_header *efihdr)
 {
 
-	foreach_efi_map_entry(efihdr, exclude_efi_map_entry);
+	foreach_efi_map_entry(efihdr, exclude_efi_map_entry, NULL);
 }
 
 static void
-add_efi_map_entry(struct efi_md *p)
+add_efi_map_entry(struct efi_md *p, void *argp __unused)
 {
 
 	switch (p->md_type) {
@@ -513,12 +513,11 @@ add_efi_map_entry(struct efi_md *p)
 static void
 add_efi_map_entries(struct efi_map_header *efihdr)
 {
-
-	foreach_efi_map_entry(efihdr, add_efi_map_entry);
+	foreach_efi_map_entry(efihdr, add_efi_map_entry, NULL);
 }
 
 static void
-print_efi_map_entry(struct efi_md *p)
+print_efi_map_entry(struct efi_md *p, void *argp __unused)
 {
 	const char *type;
 	static const char *types[] = {
@@ -578,7 +577,7 @@ print_efi_map_entries(struct efi_map_header *efihdr)
 
 	printf("%23s %12s %12s %8s %4s\n",
 	    "Type", "Physical", "Virtual", "#Pages", "Attr");
-	foreach_efi_map_entry(efihdr, print_efi_map_entry);
+	foreach_efi_map_entry(efihdr, print_efi_map_entry, NULL);
 }
 
 #ifdef FDT