10499b37cSWarner Losh /** @file 20499b37cSWarner Losh Provides library functions to construct and parse UEFI Device Paths. 30499b37cSWarner Losh 40499b37cSWarner Losh This library provides defines, macros, and functions to help create and parse 50499b37cSWarner Losh EFI_DEVICE_PATH_PROTOCOL structures. 60499b37cSWarner Losh 74a14dfccSMitchell Horne Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR> 84a14dfccSMitchell Horne SPDX-License-Identifier: BSD-2-Clause-Patent 90499b37cSWarner Losh 100499b37cSWarner Losh **/ 110499b37cSWarner Losh 120499b37cSWarner Losh #ifndef __DEVICE_PATH_LIB_H__ 130499b37cSWarner Losh #define __DEVICE_PATH_LIB_H__ 140499b37cSWarner Losh 150499b37cSWarner Losh #define END_DEVICE_PATH_LENGTH (sizeof (EFI_DEVICE_PATH_PROTOCOL)) 160499b37cSWarner Losh 170499b37cSWarner Losh /** 180499b37cSWarner Losh Determine whether a given device path is valid. 190499b37cSWarner Losh 200499b37cSWarner Losh @param DevicePath A pointer to a device path data structure. 210499b37cSWarner Losh @param MaxSize The maximum size of the device path data structure. 220499b37cSWarner Losh 230499b37cSWarner Losh @retval TRUE DevicePath is valid. 244a14dfccSMitchell Horne @retval FALSE DevicePath is NULL. 254a14dfccSMitchell Horne @retval FALSE Maxsize is less than sizeof(EFI_DEVICE_PATH_PROTOCOL). 260499b37cSWarner Losh @retval FALSE The length of any node node in the DevicePath is less 270499b37cSWarner Losh than sizeof (EFI_DEVICE_PATH_PROTOCOL). 280499b37cSWarner Losh @retval FALSE If MaxSize is not zero, the size of the DevicePath 290499b37cSWarner Losh exceeds MaxSize. 300499b37cSWarner Losh @retval FALSE If PcdMaximumDevicePathNodeCount is not zero, the node 310499b37cSWarner Losh count of the DevicePath exceeds PcdMaximumDevicePathNodeCount. 320499b37cSWarner Losh **/ 330499b37cSWarner Losh BOOLEAN 340499b37cSWarner Losh EFIAPI 350499b37cSWarner Losh IsDevicePathValid ( 360499b37cSWarner Losh IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, 370499b37cSWarner Losh IN UINTN MaxSize 380499b37cSWarner Losh ); 390499b37cSWarner Losh 400499b37cSWarner Losh /** 410499b37cSWarner Losh Returns the Type field of a device path node. 420499b37cSWarner Losh 430499b37cSWarner Losh Returns the Type field of the device path node specified by Node. 440499b37cSWarner Losh 450499b37cSWarner Losh If Node is NULL, then ASSERT(). 460499b37cSWarner Losh 470499b37cSWarner Losh @param Node A pointer to a device path node data structure. 480499b37cSWarner Losh 490499b37cSWarner Losh @return The Type field of the device path node specified by Node. 500499b37cSWarner Losh 510499b37cSWarner Losh **/ 520499b37cSWarner Losh UINT8 530499b37cSWarner Losh EFIAPI 540499b37cSWarner Losh DevicePathType ( 550499b37cSWarner Losh IN CONST VOID *Node 560499b37cSWarner Losh ); 570499b37cSWarner Losh 580499b37cSWarner Losh /** 590499b37cSWarner Losh Returns the SubType field of a device path node. 600499b37cSWarner Losh 610499b37cSWarner Losh Returns the SubType field of the device path node specified by Node. 620499b37cSWarner Losh 630499b37cSWarner Losh If Node is NULL, then ASSERT(). 640499b37cSWarner Losh 650499b37cSWarner Losh @param Node A pointer to a device path node data structure. 660499b37cSWarner Losh 670499b37cSWarner Losh @return The SubType field of the device path node specified by Node. 680499b37cSWarner Losh 690499b37cSWarner Losh **/ 700499b37cSWarner Losh UINT8 710499b37cSWarner Losh EFIAPI 720499b37cSWarner Losh DevicePathSubType ( 730499b37cSWarner Losh IN CONST VOID *Node 740499b37cSWarner Losh ); 750499b37cSWarner Losh 760499b37cSWarner Losh /** 770499b37cSWarner Losh Returns the 16-bit Length field of a device path node. 780499b37cSWarner Losh 790499b37cSWarner Losh Returns the 16-bit Length field of the device path node specified by Node. 800499b37cSWarner Losh Node is not required to be aligned on a 16-bit boundary, so it is recommended 810499b37cSWarner Losh that a function such as ReadUnaligned16() be used to extract the contents of 820499b37cSWarner Losh the Length field. 830499b37cSWarner Losh 840499b37cSWarner Losh If Node is NULL, then ASSERT(). 850499b37cSWarner Losh 860499b37cSWarner Losh @param Node A pointer to a device path node data structure. 870499b37cSWarner Losh 880499b37cSWarner Losh @return The 16-bit Length field of the device path node specified by Node. 890499b37cSWarner Losh 900499b37cSWarner Losh **/ 910499b37cSWarner Losh UINTN 920499b37cSWarner Losh EFIAPI 930499b37cSWarner Losh DevicePathNodeLength ( 940499b37cSWarner Losh IN CONST VOID *Node 950499b37cSWarner Losh ); 960499b37cSWarner Losh 970499b37cSWarner Losh /** 980499b37cSWarner Losh Returns a pointer to the next node in a device path. 990499b37cSWarner Losh 1000499b37cSWarner Losh Returns a pointer to the device path node that follows the device path node specified by Node. 1010499b37cSWarner Losh 1020499b37cSWarner Losh If Node is NULL, then ASSERT(). 1030499b37cSWarner Losh 1040499b37cSWarner Losh @param Node A pointer to a device path node data structure. 1050499b37cSWarner Losh 1060499b37cSWarner Losh @return a pointer to the device path node that follows the device path node specified by Node. 1070499b37cSWarner Losh 1080499b37cSWarner Losh **/ 1090499b37cSWarner Losh EFI_DEVICE_PATH_PROTOCOL * 1100499b37cSWarner Losh EFIAPI 1110499b37cSWarner Losh NextDevicePathNode ( 1120499b37cSWarner Losh IN CONST VOID *Node 1130499b37cSWarner Losh ); 1140499b37cSWarner Losh 1150499b37cSWarner Losh /** 1160499b37cSWarner Losh Determines if a device path node is an end node of a device path. 1170499b37cSWarner Losh This includes nodes that are the end of a device path instance and nodes that 1180499b37cSWarner Losh are the end of an entire device path. 1190499b37cSWarner Losh 1200499b37cSWarner Losh Determines if the device path node specified by Node is an end node of a device path. 1210499b37cSWarner Losh This includes nodes that are the end of a device path instance and nodes that are the 1220499b37cSWarner Losh end of an entire device path. If Node represents an end node of a device path, 1230499b37cSWarner Losh then TRUE is returned. Otherwise, FALSE is returned. 1240499b37cSWarner Losh 1250499b37cSWarner Losh If Node is NULL, then ASSERT(). 1260499b37cSWarner Losh 1270499b37cSWarner Losh @param Node A pointer to a device path node data structure. 1280499b37cSWarner Losh 1290499b37cSWarner Losh @retval TRUE The device path node specified by Node is an end node of a device path. 1300499b37cSWarner Losh @retval FALSE The device path node specified by Node is not an end node of a device path. 1310499b37cSWarner Losh 1320499b37cSWarner Losh **/ 1330499b37cSWarner Losh BOOLEAN 1340499b37cSWarner Losh EFIAPI 1350499b37cSWarner Losh IsDevicePathEndType ( 1360499b37cSWarner Losh IN CONST VOID *Node 1370499b37cSWarner Losh ); 1380499b37cSWarner Losh 1390499b37cSWarner Losh /** 1400499b37cSWarner Losh Determines if a device path node is an end node of an entire device path. 1410499b37cSWarner Losh 1420499b37cSWarner Losh Determines if a device path node specified by Node is an end node of an entire device path. 1430499b37cSWarner Losh If Node represents the end of an entire device path, then TRUE is returned. 1440499b37cSWarner Losh Otherwise, FALSE is returned. 1450499b37cSWarner Losh 1460499b37cSWarner Losh If Node is NULL, then ASSERT(). 1470499b37cSWarner Losh 1480499b37cSWarner Losh @param Node A pointer to a device path node data structure. 1490499b37cSWarner Losh 1500499b37cSWarner Losh @retval TRUE The device path node specified by Node is the end of an entire device path. 1510499b37cSWarner Losh @retval FALSE The device path node specified by Node is not the end of an entire device path. 1520499b37cSWarner Losh 1530499b37cSWarner Losh **/ 1540499b37cSWarner Losh BOOLEAN 1550499b37cSWarner Losh EFIAPI 1560499b37cSWarner Losh IsDevicePathEnd ( 1570499b37cSWarner Losh IN CONST VOID *Node 1580499b37cSWarner Losh ); 1590499b37cSWarner Losh 1600499b37cSWarner Losh /** 1610499b37cSWarner Losh Determines if a device path node is an end node of a device path instance. 1620499b37cSWarner Losh 1630499b37cSWarner Losh Determines if a device path node specified by Node is an end node of a device path instance. 1640499b37cSWarner Losh If Node represents the end of a device path instance, then TRUE is returned. 1650499b37cSWarner Losh Otherwise, FALSE is returned. 1660499b37cSWarner Losh 1670499b37cSWarner Losh If Node is NULL, then ASSERT(). 1680499b37cSWarner Losh 1690499b37cSWarner Losh @param Node A pointer to a device path node data structure. 1700499b37cSWarner Losh 1710499b37cSWarner Losh @retval TRUE The device path node specified by Node is the end of a device path instance. 1720499b37cSWarner Losh @retval FALSE The device path node specified by Node is not the end of a device path instance. 1730499b37cSWarner Losh 1740499b37cSWarner Losh **/ 1750499b37cSWarner Losh BOOLEAN 1760499b37cSWarner Losh EFIAPI 1770499b37cSWarner Losh IsDevicePathEndInstance ( 1780499b37cSWarner Losh IN CONST VOID *Node 1790499b37cSWarner Losh ); 1800499b37cSWarner Losh 1810499b37cSWarner Losh /** 1820499b37cSWarner Losh Sets the length, in bytes, of a device path node. 1830499b37cSWarner Losh 1840499b37cSWarner Losh Sets the length of the device path node specified by Node to the value specified 1850499b37cSWarner Losh by NodeLength. NodeLength is returned. Node is not required to be aligned on 1860499b37cSWarner Losh a 16-bit boundary, so it is recommended that a function such as WriteUnaligned16() 1870499b37cSWarner Losh be used to set the contents of the Length field. 1880499b37cSWarner Losh 1890499b37cSWarner Losh If Node is NULL, then ASSERT(). 1900499b37cSWarner Losh If NodeLength >= 0x10000, then ASSERT(). 1910499b37cSWarner Losh If NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL), then ASSERT(). 1920499b37cSWarner Losh 1930499b37cSWarner Losh @param Node A pointer to a device path node data structure. 1940499b37cSWarner Losh @param Length The length, in bytes, of the device path node. 1950499b37cSWarner Losh 1960499b37cSWarner Losh @return Length 1970499b37cSWarner Losh 1980499b37cSWarner Losh **/ 1990499b37cSWarner Losh UINT16 2000499b37cSWarner Losh EFIAPI 2010499b37cSWarner Losh SetDevicePathNodeLength ( 2020499b37cSWarner Losh IN OUT VOID *Node, 2030499b37cSWarner Losh IN UINTN Length 2040499b37cSWarner Losh ); 2050499b37cSWarner Losh 2060499b37cSWarner Losh /** 2070499b37cSWarner Losh Fills in all the fields of a device path node that is the end of an entire device path. 2080499b37cSWarner Losh 2090499b37cSWarner Losh Fills in all the fields of a device path node specified by Node so Node represents 2100499b37cSWarner Losh the end of an entire device path. The Type field of Node is set to 2110499b37cSWarner Losh END_DEVICE_PATH_TYPE, the SubType field of Node is set to 2120499b37cSWarner Losh END_ENTIRE_DEVICE_PATH_SUBTYPE, and the Length field of Node is set to 2130499b37cSWarner Losh END_DEVICE_PATH_LENGTH. Node is not required to be aligned on a 16-bit boundary, 2140499b37cSWarner Losh so it is recommended that a function such as WriteUnaligned16() be used to set 2150499b37cSWarner Losh the contents of the Length field. 2160499b37cSWarner Losh 2170499b37cSWarner Losh If Node is NULL, then ASSERT(). 2180499b37cSWarner Losh 2190499b37cSWarner Losh @param Node A pointer to a device path node data structure. 2200499b37cSWarner Losh 2210499b37cSWarner Losh **/ 2220499b37cSWarner Losh VOID 2230499b37cSWarner Losh EFIAPI 2240499b37cSWarner Losh SetDevicePathEndNode ( 2250499b37cSWarner Losh OUT VOID *Node 2260499b37cSWarner Losh ); 2270499b37cSWarner Losh 2280499b37cSWarner Losh /** 2290499b37cSWarner Losh Returns the size of a device path in bytes. 2300499b37cSWarner Losh 2310499b37cSWarner Losh This function returns the size, in bytes, of the device path data structure 2320499b37cSWarner Losh specified by DevicePath including the end of device path node. 2330499b37cSWarner Losh If DevicePath is NULL or invalid, then 0 is returned. 2340499b37cSWarner Losh 2350499b37cSWarner Losh @param DevicePath A pointer to a device path data structure. 2360499b37cSWarner Losh 2370499b37cSWarner Losh @retval 0 If DevicePath is NULL or invalid. 2380499b37cSWarner Losh @retval Others The size of a device path in bytes. 2390499b37cSWarner Losh 2400499b37cSWarner Losh **/ 2410499b37cSWarner Losh UINTN 2420499b37cSWarner Losh EFIAPI 2430499b37cSWarner Losh GetDevicePathSize ( 2440499b37cSWarner Losh IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath 2450499b37cSWarner Losh ); 2460499b37cSWarner Losh 2470499b37cSWarner Losh /** 2480499b37cSWarner Losh Creates a new copy of an existing device path. 2490499b37cSWarner Losh 2500499b37cSWarner Losh This function allocates space for a new copy of the device path specified by DevicePath. If 2510499b37cSWarner Losh DevicePath is NULL, then NULL is returned. If the memory is successfully allocated, then the 2520499b37cSWarner Losh contents of DevicePath are copied to the newly allocated buffer, and a pointer to that buffer 2530499b37cSWarner Losh is returned. Otherwise, NULL is returned. 2540499b37cSWarner Losh The memory for the new device path is allocated from EFI boot services memory. 2550499b37cSWarner Losh It is the responsibility of the caller to free the memory allocated. 2560499b37cSWarner Losh 2570499b37cSWarner Losh @param DevicePath A pointer to a device path data structure. 2580499b37cSWarner Losh 2590499b37cSWarner Losh @retval NULL DevicePath is NULL or invalid. 2600499b37cSWarner Losh @retval Others A pointer to the duplicated device path. 2610499b37cSWarner Losh 2620499b37cSWarner Losh **/ 2630499b37cSWarner Losh EFI_DEVICE_PATH_PROTOCOL * 2640499b37cSWarner Losh EFIAPI 2650499b37cSWarner Losh DuplicateDevicePath ( 2660499b37cSWarner Losh IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath 2670499b37cSWarner Losh ); 2680499b37cSWarner Losh 2690499b37cSWarner Losh /** 2700499b37cSWarner Losh Creates a new device path by appending a second device path to a first device path. 2710499b37cSWarner Losh 2720499b37cSWarner Losh This function creates a new device path by appending a copy of SecondDevicePath to a copy of 2730499b37cSWarner Losh FirstDevicePath in a newly allocated buffer. Only the end-of-device-path device node from 2740499b37cSWarner Losh SecondDevicePath is retained. The newly created device path is returned. 2750499b37cSWarner Losh If FirstDevicePath is NULL, then it is ignored, and a duplicate of SecondDevicePath is returned. 2760499b37cSWarner Losh If SecondDevicePath is NULL, then it is ignored, and a duplicate of FirstDevicePath is returned. 2770499b37cSWarner Losh If both FirstDevicePath and SecondDevicePath are NULL, then a copy of an end-of-device-path is 2780499b37cSWarner Losh returned. 2790499b37cSWarner Losh If there is not enough memory for the newly allocated buffer, then NULL is returned. 2800499b37cSWarner Losh The memory for the new device path is allocated from EFI boot services memory. It is the 2810499b37cSWarner Losh responsibility of the caller to free the memory allocated. 2820499b37cSWarner Losh 2830499b37cSWarner Losh @param FirstDevicePath A pointer to a device path data structure. 2840499b37cSWarner Losh @param SecondDevicePath A pointer to a device path data structure. 2850499b37cSWarner Losh 2860499b37cSWarner Losh @retval NULL If there is not enough memory for the newly allocated buffer. 2870499b37cSWarner Losh @retval NULL If FirstDevicePath or SecondDevicePath is invalid. 2880499b37cSWarner Losh @retval Others A pointer to the new device path if success. 2890499b37cSWarner Losh Or a copy an end-of-device-path if both FirstDevicePath and SecondDevicePath are NULL. 2900499b37cSWarner Losh 2910499b37cSWarner Losh **/ 2920499b37cSWarner Losh EFI_DEVICE_PATH_PROTOCOL * 2930499b37cSWarner Losh EFIAPI 2940499b37cSWarner Losh AppendDevicePath ( 2955d8674f2SWarner Losh IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath OPTIONAL, 2960499b37cSWarner Losh IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath OPTIONAL 2970499b37cSWarner Losh ); 2980499b37cSWarner Losh 2990499b37cSWarner Losh /** 3000499b37cSWarner Losh Creates a new path by appending the device node to the device path. 3010499b37cSWarner Losh 3020499b37cSWarner Losh This function creates a new device path by appending a copy of the device node specified by 3030499b37cSWarner Losh DevicePathNode to a copy of the device path specified by DevicePath in an allocated buffer. 3040499b37cSWarner Losh The end-of-device-path device node is moved after the end of the appended device node. 3050499b37cSWarner Losh If DevicePathNode is NULL then a copy of DevicePath is returned. 3060499b37cSWarner Losh If DevicePath is NULL then a copy of DevicePathNode, followed by an end-of-device path device 3070499b37cSWarner Losh node is returned. 3080499b37cSWarner Losh If both DevicePathNode and DevicePath are NULL then a copy of an end-of-device-path device node 3090499b37cSWarner Losh is returned. 3100499b37cSWarner Losh If there is not enough memory to allocate space for the new device path, then NULL is returned. 3110499b37cSWarner Losh The memory is allocated from EFI boot services memory. It is the responsibility of the caller to 3120499b37cSWarner Losh free the memory allocated. 3130499b37cSWarner Losh 3140499b37cSWarner Losh @param DevicePath A pointer to a device path data structure. 3150499b37cSWarner Losh @param DevicePathNode A pointer to a single device path node. 3160499b37cSWarner Losh 3170499b37cSWarner Losh @retval NULL There is not enough memory for the new device path. 3180499b37cSWarner Losh @retval Others A pointer to the new device path if success. 3190499b37cSWarner Losh A copy of DevicePathNode followed by an end-of-device-path node 3200499b37cSWarner Losh if both FirstDevicePath and SecondDevicePath are NULL. 3210499b37cSWarner Losh A copy of an end-of-device-path node if both FirstDevicePath and SecondDevicePath are NULL. 3220499b37cSWarner Losh 3230499b37cSWarner Losh **/ 3240499b37cSWarner Losh EFI_DEVICE_PATH_PROTOCOL * 3250499b37cSWarner Losh EFIAPI 3260499b37cSWarner Losh AppendDevicePathNode ( 3275d8674f2SWarner Losh IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL, 3280499b37cSWarner Losh IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode OPTIONAL 3290499b37cSWarner Losh ); 3300499b37cSWarner Losh 3310499b37cSWarner Losh /** 3320499b37cSWarner Losh Creates a new device path by appending the specified device path instance to the specified device 3330499b37cSWarner Losh path. 3340499b37cSWarner Losh 3350499b37cSWarner Losh This function creates a new device path by appending a copy of the device path instance specified 3360499b37cSWarner Losh by DevicePathInstance to a copy of the device path secified by DevicePath in a allocated buffer. 3370499b37cSWarner Losh The end-of-device-path device node is moved after the end of the appended device path instance 3380499b37cSWarner Losh and a new end-of-device-path-instance node is inserted between. 3390499b37cSWarner Losh If DevicePath is NULL, then a copy if DevicePathInstance is returned. 3400499b37cSWarner Losh If DevicePathInstance is NULL, then NULL is returned. 3410499b37cSWarner Losh If DevicePath or DevicePathInstance is invalid, then NULL is returned. 3420499b37cSWarner Losh If there is not enough memory to allocate space for the new device path, then NULL is returned. 3430499b37cSWarner Losh The memory is allocated from EFI boot services memory. It is the responsibility of the caller to 3440499b37cSWarner Losh free the memory allocated. 3450499b37cSWarner Losh 3460499b37cSWarner Losh @param DevicePath A pointer to a device path data structure. 3470499b37cSWarner Losh @param DevicePathInstance A pointer to a device path instance. 3480499b37cSWarner Losh 3490499b37cSWarner Losh @return A pointer to the new device path. 3500499b37cSWarner Losh 3510499b37cSWarner Losh **/ 3520499b37cSWarner Losh EFI_DEVICE_PATH_PROTOCOL * 3530499b37cSWarner Losh EFIAPI 3540499b37cSWarner Losh AppendDevicePathInstance ( 3555d8674f2SWarner Losh IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL, 3560499b37cSWarner Losh IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance OPTIONAL 3570499b37cSWarner Losh ); 3580499b37cSWarner Losh 3590499b37cSWarner Losh /** 3600499b37cSWarner Losh Creates a copy of the current device path instance and returns a pointer to the next device path 3610499b37cSWarner Losh instance. 3620499b37cSWarner Losh 3630499b37cSWarner Losh This function creates a copy of the current device path instance. It also updates DevicePath to 3640499b37cSWarner Losh point to the next device path instance in the device path (or NULL if no more) and updates Size 3650499b37cSWarner Losh to hold the size of the device path instance copy. 3660499b37cSWarner Losh If DevicePath is NULL, then NULL is returned. 3670499b37cSWarner Losh If DevicePath points to a invalid device path, then NULL is returned. 3680499b37cSWarner Losh If there is not enough memory to allocate space for the new device path, then NULL is returned. 3690499b37cSWarner Losh The memory is allocated from EFI boot services memory. It is the responsibility of the caller to 3700499b37cSWarner Losh free the memory allocated. 3710499b37cSWarner Losh If Size is NULL, then ASSERT(). 3720499b37cSWarner Losh 3730499b37cSWarner Losh @param DevicePath On input, this holds the pointer to the current device path 3740499b37cSWarner Losh instance. On output, this holds the pointer to the next device 3750499b37cSWarner Losh path instance or NULL if there are no more device path 3760499b37cSWarner Losh instances in the device path pointer to a device path data 3770499b37cSWarner Losh structure. 3780499b37cSWarner Losh @param Size On output, this holds the size of the device path instance, in 3790499b37cSWarner Losh bytes or zero, if DevicePath is NULL. 3800499b37cSWarner Losh 3810499b37cSWarner Losh @return A pointer to the current device path instance. 3820499b37cSWarner Losh 3830499b37cSWarner Losh **/ 3840499b37cSWarner Losh EFI_DEVICE_PATH_PROTOCOL * 3850499b37cSWarner Losh EFIAPI 3860499b37cSWarner Losh GetNextDevicePathInstance ( 3870499b37cSWarner Losh IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, 3880499b37cSWarner Losh OUT UINTN *Size 3890499b37cSWarner Losh ); 3900499b37cSWarner Losh 3910499b37cSWarner Losh /** 3920499b37cSWarner Losh Creates a device node. 3930499b37cSWarner Losh 3940499b37cSWarner Losh This function creates a new device node in a newly allocated buffer of size NodeLength and 3950499b37cSWarner Losh initializes the device path node header with NodeType and NodeSubType. The new device path node 3960499b37cSWarner Losh is returned. 3970499b37cSWarner Losh If NodeLength is smaller than a device path header, then NULL is returned. 3980499b37cSWarner Losh If there is not enough memory to allocate space for the new device path, then NULL is returned. 3990499b37cSWarner Losh The memory is allocated from EFI boot services memory. It is the responsibility of the caller to 4000499b37cSWarner Losh free the memory allocated. 4010499b37cSWarner Losh 4020499b37cSWarner Losh @param NodeType The device node type for the new device node. 4030499b37cSWarner Losh @param NodeSubType The device node sub-type for the new device node. 4040499b37cSWarner Losh @param NodeLength The length of the new device node. 4050499b37cSWarner Losh 4060499b37cSWarner Losh @return The new device path. 4070499b37cSWarner Losh 4080499b37cSWarner Losh **/ 4090499b37cSWarner Losh EFI_DEVICE_PATH_PROTOCOL * 4100499b37cSWarner Losh EFIAPI 4110499b37cSWarner Losh CreateDeviceNode ( 4120499b37cSWarner Losh IN UINT8 NodeType, 4130499b37cSWarner Losh IN UINT8 NodeSubType, 4140499b37cSWarner Losh IN UINT16 NodeLength 4150499b37cSWarner Losh ); 4160499b37cSWarner Losh 4170499b37cSWarner Losh /** 4180499b37cSWarner Losh Determines if a device path is single or multi-instance. 4190499b37cSWarner Losh 4200499b37cSWarner Losh This function returns TRUE if the device path specified by DevicePath is multi-instance. 4210499b37cSWarner Losh Otherwise, FALSE is returned. 4220499b37cSWarner Losh If DevicePath is NULL or invalid, then FALSE is returned. 4230499b37cSWarner Losh 4240499b37cSWarner Losh @param DevicePath A pointer to a device path data structure. 4250499b37cSWarner Losh 4260499b37cSWarner Losh @retval TRUE DevicePath is multi-instance. 4270499b37cSWarner Losh @retval FALSE DevicePath is not multi-instance, or DevicePath is NULL or invalid. 4280499b37cSWarner Losh 4290499b37cSWarner Losh **/ 4300499b37cSWarner Losh BOOLEAN 4310499b37cSWarner Losh EFIAPI 4320499b37cSWarner Losh IsDevicePathMultiInstance ( 4330499b37cSWarner Losh IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath 4340499b37cSWarner Losh ); 4350499b37cSWarner Losh 4360499b37cSWarner Losh /** 4370499b37cSWarner Losh Retrieves the device path protocol from a handle. 4380499b37cSWarner Losh 4390499b37cSWarner Losh This function returns the device path protocol from the handle specified by Handle. If Handle is 4400499b37cSWarner Losh NULL or Handle does not contain a device path protocol, then NULL is returned. 4410499b37cSWarner Losh 4420499b37cSWarner Losh @param Handle The handle from which to retrieve the device path protocol. 4430499b37cSWarner Losh 4440499b37cSWarner Losh @return The device path protocol from the handle specified by Handle. 4450499b37cSWarner Losh 4460499b37cSWarner Losh **/ 4470499b37cSWarner Losh EFI_DEVICE_PATH_PROTOCOL * 4480499b37cSWarner Losh EFIAPI 4490499b37cSWarner Losh DevicePathFromHandle ( 4500499b37cSWarner Losh IN EFI_HANDLE Handle 4510499b37cSWarner Losh ); 4520499b37cSWarner Losh 4530499b37cSWarner Losh /** 4540499b37cSWarner Losh Allocates a device path for a file and appends it to an existing device path. 4550499b37cSWarner Losh 4560499b37cSWarner Losh If Device is a valid device handle that contains a device path protocol, then a device path for 4570499b37cSWarner Losh the file specified by FileName is allocated and appended to the device path associated with the 4580499b37cSWarner Losh handle Device. The allocated device path is returned. If Device is NULL or Device is a handle 4590499b37cSWarner Losh that does not support the device path protocol, then a device path containing a single device 4600499b37cSWarner Losh path node for the file specified by FileName is allocated and returned. 4610499b37cSWarner Losh The memory for the new device path is allocated from EFI boot services memory. It is the responsibility 4620499b37cSWarner Losh of the caller to free the memory allocated. 4630499b37cSWarner Losh 4640499b37cSWarner Losh If FileName is NULL, then ASSERT(). 4650499b37cSWarner Losh If FileName is not aligned on a 16-bit boundary, then ASSERT(). 4660499b37cSWarner Losh 4670499b37cSWarner Losh @param Device A pointer to a device handle. This parameter is optional and 4680499b37cSWarner Losh may be NULL. 4690499b37cSWarner Losh @param FileName A pointer to a Null-terminated Unicode string. 4700499b37cSWarner Losh 4710499b37cSWarner Losh @return The allocated device path. 4720499b37cSWarner Losh 4730499b37cSWarner Losh **/ 4740499b37cSWarner Losh EFI_DEVICE_PATH_PROTOCOL * 4750499b37cSWarner Losh EFIAPI 4760499b37cSWarner Losh FileDevicePath ( 4775d8674f2SWarner Losh IN EFI_HANDLE Device OPTIONAL, 4780499b37cSWarner Losh IN CONST CHAR16 *FileName 4790499b37cSWarner Losh ); 4800499b37cSWarner Losh 4810499b37cSWarner Losh /** 4820499b37cSWarner Losh Converts a device path to its text representation. 4830499b37cSWarner Losh 4840499b37cSWarner Losh @param DevicePath A Pointer to the device to be converted. 4850499b37cSWarner Losh @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation 4860499b37cSWarner Losh of the display node is used, where applicable. If DisplayOnly 4870499b37cSWarner Losh is FALSE, then the longer text representation of the display node 4880499b37cSWarner Losh is used. 4890499b37cSWarner Losh @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text 4900499b37cSWarner Losh representation for a device node can be used, where applicable. 4910499b37cSWarner Losh 4920499b37cSWarner Losh @return A pointer to the allocated text representation of the device path or 4930499b37cSWarner Losh NULL if DeviceNode is NULL or there was insufficient memory. 4940499b37cSWarner Losh 4950499b37cSWarner Losh **/ 4960499b37cSWarner Losh CHAR16 * 4970499b37cSWarner Losh EFIAPI 4980499b37cSWarner Losh ConvertDevicePathToText ( 4990499b37cSWarner Losh IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, 5000499b37cSWarner Losh IN BOOLEAN DisplayOnly, 5010499b37cSWarner Losh IN BOOLEAN AllowShortcuts 5020499b37cSWarner Losh ); 5030499b37cSWarner Losh 5040499b37cSWarner Losh /** 5050499b37cSWarner Losh Converts a device node to its string representation. 5060499b37cSWarner Losh 5070499b37cSWarner Losh @param DeviceNode A Pointer to the device node to be converted. 5080499b37cSWarner Losh @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation 5090499b37cSWarner Losh of the display node is used, where applicable. If DisplayOnly 5100499b37cSWarner Losh is FALSE, then the longer text representation of the display node 5110499b37cSWarner Losh is used. 5120499b37cSWarner Losh @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text 5130499b37cSWarner Losh representation for a device node can be used, where applicable. 5140499b37cSWarner Losh 5150499b37cSWarner Losh @return A pointer to the allocated text representation of the device node or NULL if DeviceNode 5160499b37cSWarner Losh is NULL or there was insufficient memory. 5170499b37cSWarner Losh 5180499b37cSWarner Losh **/ 5190499b37cSWarner Losh CHAR16 * 5200499b37cSWarner Losh EFIAPI 5210499b37cSWarner Losh ConvertDeviceNodeToText ( 5220499b37cSWarner Losh IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode, 5230499b37cSWarner Losh IN BOOLEAN DisplayOnly, 5240499b37cSWarner Losh IN BOOLEAN AllowShortcuts 5250499b37cSWarner Losh ); 5260499b37cSWarner Losh 5270499b37cSWarner Losh /** 5280499b37cSWarner Losh Convert text to the binary representation of a device node. 5290499b37cSWarner Losh 5300499b37cSWarner Losh @param TextDeviceNode TextDeviceNode points to the text representation of a device 5310499b37cSWarner Losh node. Conversion starts with the first character and continues 5320499b37cSWarner Losh until the first non-device node character. 5330499b37cSWarner Losh 5340499b37cSWarner Losh @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was 5350499b37cSWarner Losh insufficient memory or text unsupported. 5360499b37cSWarner Losh 5370499b37cSWarner Losh **/ 5380499b37cSWarner Losh EFI_DEVICE_PATH_PROTOCOL * 5390499b37cSWarner Losh EFIAPI 5400499b37cSWarner Losh ConvertTextToDeviceNode ( 5410499b37cSWarner Losh IN CONST CHAR16 *TextDeviceNode 5420499b37cSWarner Losh ); 5430499b37cSWarner Losh 5440499b37cSWarner Losh /** 5450499b37cSWarner Losh Convert text to the binary representation of a device path. 5460499b37cSWarner Losh 5470499b37cSWarner Losh @param TextDevicePath TextDevicePath points to the text representation of a device 5480499b37cSWarner Losh path. Conversion starts with the first character and continues 5490499b37cSWarner Losh until the first non-device node character. 5500499b37cSWarner Losh 5510499b37cSWarner Losh @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or 5520499b37cSWarner Losh there was insufficient memory. 5530499b37cSWarner Losh 5540499b37cSWarner Losh **/ 5550499b37cSWarner Losh EFI_DEVICE_PATH_PROTOCOL * 5560499b37cSWarner Losh EFIAPI 5570499b37cSWarner Losh ConvertTextToDevicePath ( 5580499b37cSWarner Losh IN CONST CHAR16 *TextDevicePath 5590499b37cSWarner Losh ); 5600499b37cSWarner Losh 5610499b37cSWarner Losh #endif 562