/*++ Copyright (c) 2024, Quinn Stephens. Provided under the BSD 3-Clause license. Module Name: efidevp.h Abstract: Provides EFI device path definitions. --*/ #ifndef _EFIDEVP_H #define _EFIDEVP_H typedef struct _EFI_DEVICE_PATH_PROTOCOL { UINT8 Type; UINT8 SubType; UINT8 Length[2]; } EFI_DEVICE_PATH_PROTOCOL; typedef struct _EFI_DEVICE_PATH_PROTOCOL _EFI_DEVICE_PATH; typedef EFI_DEVICE_PATH_PROTOCOL EFI_DEVICE_PATH; #define MEDIA_DEVICE_PATH 0x04 #define MEDIA_CDROM_DP 0x02 typedef struct { EFI_DEVICE_PATH Header; UINT32 BootEntry; UINT64 PartitionStart; UINT64 PartitionSize; } CDROM_DEVICE_PATH; FORCEINLINE UINT8 DevicePathType ( IN CONST VOID *Node ) /*++ Routine Description: Gets the type of a device path node. Arguments: Node - The node to get the type from. Return Value: The type of the node. --*/ { return ((EFI_DEVICE_PATH *)(Node))->Type; } FORCEINLINE UINT8 DevicePathSubType ( IN CONST VOID *Node ) /*++ Routine Description: Gets the subtype of a device path node. Arguments: Node - The node to get the subtype from. Return Value: The subtype of the node. --*/ { return ((EFI_DEVICE_PATH *)(Node))->SubType; } FORCEINLINE UINTN DevicePathNodeLength ( IN CONST VOID *Node ) /*++ Routine Description: Gets the length of a device path node. Arguments: Node - The node to get the length from. Return Value: The length of the node. --*/ { return *((UINT16 *)&((EFI_DEVICE_PATH *)(Node))->Length[0]); } FORCEINLINE EFI_DEVICE_PATH * NextDevicePathNode ( IN CONST VOID *Node ) /*++ Routine Description: Finds the next node in a device path. Arguments: Node - The current node to find the next node from. Return Value: A pointer to the next node. --*/ { return (EFI_DEVICE_PATH *)((UINT8 *)(Node) + DevicePathNodeLength(Node)); } FORCEINLINE BOOLEAN IsDevicePathEndType ( IN CONST VOID *Node ) /*++ Routine Description: Checks if a device path node is an end node. Arguments: Node - The node to check. Return Value: TRUE if the node is an end node. FALSE if the node is not an end node. --*/ { return (BOOLEAN)(DevicePathType(Node) == END_DEVICE_PATH_TYPE); } #endif