[efi] Split device path functions out to efi_path.c

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2020-10-16 14:12:56 +01:00
parent bcf858c56d
commit 2bf0fd39ca
14 changed files with 99 additions and 54 deletions

View File

@@ -32,36 +32,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
*
*/
/**
* Find end of device path
*
* @v path Path to device
* @ret path_end End of device path
*/
EFI_DEVICE_PATH_PROTOCOL * efi_devpath_end ( EFI_DEVICE_PATH_PROTOCOL *path ) {
while ( path->Type != END_DEVICE_PATH_TYPE ) {
path = ( ( ( void * ) path ) +
/* There's this amazing new-fangled thing known as
* a UINT16, but who wants to use one of those? */
( ( path->Length[1] << 8 ) | path->Length[0] ) );
}
return path;
}
/**
* Find length of device path (excluding terminator)
*
* @v path Path to device
* @ret path_len Length of device path
*/
size_t efi_devpath_len ( EFI_DEVICE_PATH_PROTOCOL *path ) {
EFI_DEVICE_PATH_PROTOCOL *end = efi_devpath_end ( path );
return ( ( ( void * ) end ) - ( ( void * ) path ) );
}
/**
* Locate parent device supporting a given protocol
*