summaryrefslogtreecommitdiffstats
path: root/src/interface/efi/efi_path.c
diff options
context:
space:
mode:
authorMichael Brown2020-10-16 16:09:52 +0200
committerMichael Brown2020-10-16 16:37:03 +0200
commit2091288eaa5b3b6144afba193f44cce985705e79 (patch)
treea46ac2cefef58f6ad6f6e1936e20167c322e105e /src/interface/efi/efi_path.c
parent[efi] Split device path functions out to efi_path.c (diff)
downloadipxe-2091288eaa5b3b6144afba193f44cce985705e79.tar.gz
ipxe-2091288eaa5b3b6144afba193f44cce985705e79.tar.xz
ipxe-2091288eaa5b3b6144afba193f44cce985705e79.zip
[efi] Define an interface operation to describe using an EFI device path
Allow arbitrary objects to support describing themselves using an EFI device path. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/interface/efi/efi_path.c')
-rw-r--r--src/interface/efi/efi_path.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/interface/efi/efi_path.c b/src/interface/efi/efi_path.c
index 1b297567..fa430602 100644
--- a/src/interface/efi/efi_path.c
+++ b/src/interface/efi/efi_path.c
@@ -55,3 +55,29 @@ size_t efi_path_len ( EFI_DEVICE_PATH_PROTOCOL *path ) {
return ( ( ( void * ) end ) - ( ( void * ) path ) );
}
+
+/**
+ * Describe object as an EFI device path
+ *
+ * @v intf Interface
+ * @ret path EFI device path, or NULL
+ *
+ * The caller is responsible for eventually calling free() on the
+ * allocated device path.
+ */
+EFI_DEVICE_PATH_PROTOCOL * efi_describe ( struct interface *intf ) {
+ struct interface *dest;
+ efi_describe_TYPE ( void * ) *op =
+ intf_get_dest_op ( intf, efi_describe, &dest );
+ void *object = intf_object ( dest );
+ EFI_DEVICE_PATH_PROTOCOL *path;
+
+ if ( op ) {
+ path = op ( object );
+ } else {
+ path = NULL;
+ }
+
+ intf_put ( dest );
+ return path;
+}