Changeset View
Changeset View
Standalone View
Standalone View
sys/boot/efi/libefi/handles.c
Show All 29 Lines | |||||
#include <efi.h> | #include <efi.h> | ||||
#include <efilib.h> | #include <efilib.h> | ||||
struct entry { | struct entry { | ||||
EFI_HANDLE handle; | EFI_HANDLE handle; | ||||
EFI_HANDLE alias; | EFI_HANDLE alias; | ||||
struct devsw *dev; | struct devsw *dev; | ||||
int unit; | int unit; | ||||
uint64_t extra; | |||||
}; | }; | ||||
struct entry *entry; | struct entry *entry; | ||||
int nentries; | int nentries; | ||||
int | int | ||||
efi_register_handles(struct devsw *sw, EFI_HANDLE *handles, | efi_register_handles(struct devsw *sw, EFI_HANDLE *handles, | ||||
EFI_HANDLE *aliases, int count) | EFI_HANDLE *aliases, int count) | ||||
Show All 28 Lines | for (idx = 0; idx < nentries; idx++) { | ||||
if (entry[idx].unit != unit) | if (entry[idx].unit != unit) | ||||
continue; | continue; | ||||
return (entry[idx].handle); | return (entry[idx].handle); | ||||
} | } | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
int | int | ||||
efi_handle_lookup(EFI_HANDLE h, struct devsw **dev, int *unit) | efi_handle_lookup(EFI_HANDLE h, struct devsw **dev, int *unit, uint64_t *extra) | ||||
{ | { | ||||
int idx; | int idx; | ||||
for (idx = 0; idx < nentries; idx++) { | for (idx = 0; idx < nentries; idx++) { | ||||
if (entry[idx].handle != h && entry[idx].alias != h) | if (entry[idx].handle != h && entry[idx].alias != h) | ||||
continue; | continue; | ||||
if (dev != NULL) | if (dev != NULL) | ||||
*dev = entry[idx].dev; | *dev = entry[idx].dev; | ||||
if (unit != NULL) | if (unit != NULL) | ||||
*unit = entry[idx].unit; | *unit = entry[idx].unit; | ||||
if (extra != NULL) | |||||
*extra = entry[idx].extra; | |||||
return (0); | return (0); | ||||
} | } | ||||
return (ENOENT); | |||||
} | |||||
int | |||||
efi_handle_update_dev(EFI_HANDLE h, struct devsw *dev, int unit, | |||||
uint64_t guid) | |||||
{ | |||||
int idx; | |||||
for (idx = 0; idx < nentries; idx++) { | |||||
if (entry[idx].handle != h) | |||||
continue; | |||||
entry[idx].dev = dev; | |||||
entry[idx].unit = unit; | |||||
entry[idx].alias = NULL; | |||||
entry[idx].extra = guid; | |||||
return (0); | |||||
} | |||||
return (ENOENT); | return (ENOENT); | ||||
} | } |