[BOOT:BOOTLIB] Improve EFI device protocol support
This commit is contained in:
parent
2680e9b4c0
commit
2530ffd322
@ -21,8 +21,150 @@ typedef struct _EFI_DEVICE_PATH_PROTOCOL {
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user