xref: /freebsd/sys/contrib/edk2/Include/Protocol/DevicePathUtilities.h (revision 580fcf642ea2d5a1e60f24947d1c2e97007e44e9)
10d1ba665SWarner Losh /** @file
20d1ba665SWarner Losh   EFI_DEVICE_PATH_UTILITIES_PROTOCOL as defined in UEFI 2.0.
30d1ba665SWarner Losh   Use to create and manipulate device paths and device nodes.
40d1ba665SWarner Losh 
5*3245fa21SMitchell Horne   Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
6*3245fa21SMitchell Horne   SPDX-License-Identifier: BSD-2-Clause-Patent
70d1ba665SWarner Losh 
80d1ba665SWarner Losh **/
90d1ba665SWarner Losh 
100d1ba665SWarner Losh #ifndef __DEVICE_PATH_UTILITIES_PROTOCOL_H__
110d1ba665SWarner Losh #define __DEVICE_PATH_UTILITIES_PROTOCOL_H__
120d1ba665SWarner Losh 
130d1ba665SWarner Losh ///
140d1ba665SWarner Losh /// Device Path Utilities protocol
150d1ba665SWarner Losh ///
160d1ba665SWarner Losh #define EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID \
170d1ba665SWarner Losh   { \
180d1ba665SWarner Losh     0x379be4e, 0xd706, 0x437d, {0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4 } \
190d1ba665SWarner Losh   }
200d1ba665SWarner Losh 
210d1ba665SWarner Losh /**
220d1ba665SWarner Losh   Returns the size of the device path, in bytes.
230d1ba665SWarner Losh 
240d1ba665SWarner Losh   @param  DevicePath Points to the start of the EFI device path.
250d1ba665SWarner Losh 
260d1ba665SWarner Losh   @return Size  Size of the specified device path, in bytes, including the end-of-path tag.
270d1ba665SWarner Losh   @retval 0     DevicePath is NULL
280d1ba665SWarner Losh 
290d1ba665SWarner Losh **/
300d1ba665SWarner Losh typedef
310d1ba665SWarner Losh UINTN
320d1ba665SWarner Losh (EFIAPI *EFI_DEVICE_PATH_UTILS_GET_DEVICE_PATH_SIZE)(
330d1ba665SWarner Losh   IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
340d1ba665SWarner Losh   );
350d1ba665SWarner Losh 
360d1ba665SWarner Losh /**
370d1ba665SWarner Losh   Create a duplicate of the specified path.
380d1ba665SWarner Losh 
390d1ba665SWarner Losh   @param  DevicePath Points to the source EFI device path.
400d1ba665SWarner Losh 
410d1ba665SWarner Losh   @retval Pointer    A pointer to the duplicate device path.
420d1ba665SWarner Losh   @retval NULL       insufficient memory or DevicePath is NULL
430d1ba665SWarner Losh 
440d1ba665SWarner Losh **/
450d1ba665SWarner Losh typedef
460d1ba665SWarner Losh EFI_DEVICE_PATH_PROTOCOL *
470d1ba665SWarner Losh (EFIAPI *EFI_DEVICE_PATH_UTILS_DUP_DEVICE_PATH)(
480d1ba665SWarner Losh   IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
490d1ba665SWarner Losh   );
500d1ba665SWarner Losh 
510d1ba665SWarner Losh /**
520d1ba665SWarner Losh   Create a new path by appending the second device path to the first.
530d1ba665SWarner Losh   If Src1 is NULL and Src2 is non-NULL, then a duplicate of Src2 is returned.
540d1ba665SWarner Losh   If Src1 is non-NULL and Src2 is NULL, then a duplicate of Src1 is returned.
550d1ba665SWarner Losh   If Src1 and Src2 are both NULL, then a copy of an end-of-device-path is returned.
560d1ba665SWarner Losh 
570d1ba665SWarner Losh   @param  Src1 Points to the first device path.
580d1ba665SWarner Losh   @param  Src2 Points to the second device path.
590d1ba665SWarner Losh 
600d1ba665SWarner Losh   @retval Pointer  A pointer to the newly created device path.
610d1ba665SWarner Losh   @retval NULL     Memory could not be allocated
620d1ba665SWarner Losh 
630d1ba665SWarner Losh **/
640d1ba665SWarner Losh typedef
650d1ba665SWarner Losh EFI_DEVICE_PATH_PROTOCOL *
660d1ba665SWarner Losh (EFIAPI *EFI_DEVICE_PATH_UTILS_APPEND_PATH)(
670d1ba665SWarner Losh   IN CONST EFI_DEVICE_PATH_PROTOCOL *Src1,
680d1ba665SWarner Losh   IN CONST EFI_DEVICE_PATH_PROTOCOL *Src2
690d1ba665SWarner Losh   );
700d1ba665SWarner Losh 
710d1ba665SWarner Losh /**
720d1ba665SWarner Losh   Creates a new path by appending the device node to the device path.
730d1ba665SWarner Losh   If DeviceNode is NULL then a copy of DevicePath is returned.
740d1ba665SWarner Losh   If DevicePath is NULL then a copy of DeviceNode, followed by an end-of-device path device node is returned.
750d1ba665SWarner Losh   If both DeviceNode and DevicePath are NULL then a copy of an end-of-device-path device node is returned.
760d1ba665SWarner Losh 
770d1ba665SWarner Losh   @param  DevicePath Points to the device path.
780d1ba665SWarner Losh   @param  DeviceNode Points to the device node.
790d1ba665SWarner Losh 
800d1ba665SWarner Losh   @retval Pointer    A pointer to the allocated device node.
810d1ba665SWarner Losh   @retval NULL       There was insufficient memory.
820d1ba665SWarner Losh 
830d1ba665SWarner Losh **/
840d1ba665SWarner Losh typedef
850d1ba665SWarner Losh EFI_DEVICE_PATH_PROTOCOL *
860d1ba665SWarner Losh (EFIAPI *EFI_DEVICE_PATH_UTILS_APPEND_NODE)(
870d1ba665SWarner Losh   IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
880d1ba665SWarner Losh   IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode
890d1ba665SWarner Losh   );
900d1ba665SWarner Losh 
910d1ba665SWarner Losh /**
920d1ba665SWarner Losh   Creates a new path by appending the specified device path instance to the specified device path.
930d1ba665SWarner Losh 
940d1ba665SWarner Losh   @param  DevicePath         Points to the device path. If NULL, then ignored.
950d1ba665SWarner Losh   @param  DevicePathInstance Points to the device path instance.
960d1ba665SWarner Losh 
970d1ba665SWarner Losh   @retval Pointer            A pointer to the newly created device path
980d1ba665SWarner Losh   @retval NULL               Memory could not be allocated or DevicePathInstance is NULL.
990d1ba665SWarner Losh 
1000d1ba665SWarner Losh **/
1010d1ba665SWarner Losh typedef
1020d1ba665SWarner Losh EFI_DEVICE_PATH_PROTOCOL *
1030d1ba665SWarner Losh (EFIAPI *EFI_DEVICE_PATH_UTILS_APPEND_INSTANCE)(
1040d1ba665SWarner Losh   IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
1050d1ba665SWarner Losh   IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance
1060d1ba665SWarner Losh   );
1070d1ba665SWarner Losh 
1080d1ba665SWarner Losh /**
1090d1ba665SWarner Losh   Creates a copy of the current device path instance and returns a pointer to the next device path
1100d1ba665SWarner Losh   instance.
1110d1ba665SWarner Losh 
1120d1ba665SWarner Losh   @param  DevicePathInstance     On input, this holds the pointer to the current device path
1130d1ba665SWarner Losh                                  instance. On output, this holds the pointer to the next
1140d1ba665SWarner Losh                                  device path instance or NULL if there are no more device
1150d1ba665SWarner Losh                                  path instances in the device path.
1160d1ba665SWarner Losh   @param  DevicePathInstanceSize On output, this holds the size of the device path instance,
1170d1ba665SWarner Losh                                  in bytes or zero, if DevicePathInstance is NULL.
1180d1ba665SWarner Losh                                  If NULL, then the instance size is not output.
1190d1ba665SWarner Losh 
1200d1ba665SWarner Losh   @retval Pointer                A pointer to the copy of the current device path instance.
1210d1ba665SWarner Losh   @retval NULL                   DevicePathInstace was NULL on entry or there was insufficient memory.
1220d1ba665SWarner Losh 
1230d1ba665SWarner Losh **/
1240d1ba665SWarner Losh typedef
1250d1ba665SWarner Losh EFI_DEVICE_PATH_PROTOCOL *
1260d1ba665SWarner Losh (EFIAPI *EFI_DEVICE_PATH_UTILS_GET_NEXT_INSTANCE)(
1270d1ba665SWarner Losh   IN  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathInstance,
1280d1ba665SWarner Losh   OUT UINTN                         *DevicePathInstanceSize
1290d1ba665SWarner Losh   );
1300d1ba665SWarner Losh 
1310d1ba665SWarner Losh /**
1320d1ba665SWarner Losh   Creates a device node
1330d1ba665SWarner Losh 
1340d1ba665SWarner Losh   @param  NodeType    NodeType is the device node type (EFI_DEVICE_PATH.Type) for
1350d1ba665SWarner Losh                       the new device node.
1360d1ba665SWarner Losh   @param  NodeSubType NodeSubType is the device node sub-type
1370d1ba665SWarner Losh                       EFI_DEVICE_PATH.SubType) for the new device node.
1380d1ba665SWarner Losh   @param  NodeLength  NodeLength is the length of the device node
1390d1ba665SWarner Losh                       (EFI_DEVICE_PATH.Length) for the new device node.
1400d1ba665SWarner Losh 
1410d1ba665SWarner Losh   @retval Pointer     A pointer to the newly created device node.
1420d1ba665SWarner Losh   @retval NULL        NodeLength is less than
1430d1ba665SWarner Losh                       the size of the header or there was insufficient memory.
1440d1ba665SWarner Losh 
1450d1ba665SWarner Losh **/
1460d1ba665SWarner Losh typedef
1470d1ba665SWarner Losh EFI_DEVICE_PATH_PROTOCOL *
1480d1ba665SWarner Losh (EFIAPI *EFI_DEVICE_PATH_UTILS_CREATE_NODE)(
1490d1ba665SWarner Losh   IN UINT8                          NodeType,
1500d1ba665SWarner Losh   IN UINT8                          NodeSubType,
1510d1ba665SWarner Losh   IN UINT16                         NodeLength
1520d1ba665SWarner Losh   );
1530d1ba665SWarner Losh 
1540d1ba665SWarner Losh /**
1550d1ba665SWarner Losh   Returns whether a device path is multi-instance.
1560d1ba665SWarner Losh 
1570d1ba665SWarner Losh   @param  DevicePath Points to the device path. If NULL, then ignored.
1580d1ba665SWarner Losh 
1590d1ba665SWarner Losh   @retval TRUE       The device path has more than one instance
1600d1ba665SWarner Losh   @retval FALSE      The device path is empty or contains only a single instance.
1610d1ba665SWarner Losh 
1620d1ba665SWarner Losh **/
1630d1ba665SWarner Losh typedef
1640d1ba665SWarner Losh BOOLEAN
1650d1ba665SWarner Losh (EFIAPI *EFI_DEVICE_PATH_UTILS_IS_MULTI_INSTANCE)(
1660d1ba665SWarner Losh   IN CONST EFI_DEVICE_PATH_PROTOCOL         *DevicePath
1670d1ba665SWarner Losh   );
1680d1ba665SWarner Losh 
1690d1ba665SWarner Losh ///
1700d1ba665SWarner Losh /// This protocol is used to creates and manipulates device paths and device nodes.
1710d1ba665SWarner Losh ///
1720d1ba665SWarner Losh typedef struct {
1730d1ba665SWarner Losh   EFI_DEVICE_PATH_UTILS_GET_DEVICE_PATH_SIZE    GetDevicePathSize;
1740d1ba665SWarner Losh   EFI_DEVICE_PATH_UTILS_DUP_DEVICE_PATH         DuplicateDevicePath;
1750d1ba665SWarner Losh   EFI_DEVICE_PATH_UTILS_APPEND_PATH             AppendDevicePath;
1760d1ba665SWarner Losh   EFI_DEVICE_PATH_UTILS_APPEND_NODE             AppendDeviceNode;
1770d1ba665SWarner Losh   EFI_DEVICE_PATH_UTILS_APPEND_INSTANCE         AppendDevicePathInstance;
1780d1ba665SWarner Losh   EFI_DEVICE_PATH_UTILS_GET_NEXT_INSTANCE       GetNextDevicePathInstance;
1790d1ba665SWarner Losh   EFI_DEVICE_PATH_UTILS_IS_MULTI_INSTANCE       IsDevicePathMultiInstance;
1800d1ba665SWarner Losh   EFI_DEVICE_PATH_UTILS_CREATE_NODE             CreateDeviceNode;
1810d1ba665SWarner Losh } EFI_DEVICE_PATH_UTILITIES_PROTOCOL;
1820d1ba665SWarner Losh 
1830d1ba665SWarner Losh extern EFI_GUID  gEfiDevicePathUtilitiesProtocolGuid;
1840d1ba665SWarner Losh 
1850d1ba665SWarner Losh #endif
186