210 lines
3.1 KiB
C
210 lines
3.1 KiB
C
/*++
|
|
|
|
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 END_DEVICE_PATH_TYPE 0x7f
|
|
|
|
#define HARDWARE_DEVICE_PATH 0x01
|
|
|
|
#define HW_MEMMAP_DP 0x03
|
|
|
|
typedef struct {
|
|
EFI_DEVICE_PATH Header;
|
|
UINT32 MemoryType;
|
|
EFI_PHYSICAL_ADDRESS StartingAddress;
|
|
EFI_PHYSICAL_ADDRESS EndingAddress;
|
|
} MEMMAP_DEVICE_PATH;
|
|
|
|
#define MEDIA_DEVICE_PATH 0x04
|
|
|
|
#define MEDIA_HARDDRIVE_DP 0x01
|
|
|
|
typedef struct {
|
|
EFI_DEVICE_PATH Header;
|
|
UINT32 PartitionNumber;
|
|
UINT64 PartitionStart;
|
|
UINT64 PartitionSize;
|
|
UINT8 Signature[16];
|
|
UINT8 MBRType;
|
|
UINT8 SignatureType;
|
|
} HARDDRIVE_DEVICE_PATH;
|
|
|
|
#define MBR_TYPE_PCAT 0x01
|
|
#define MBR_TYPE_EFI_PARTITION_TABLE_HEADER 0x02
|
|
|
|
#define NO_DISK_SIGNATURE 0x00
|
|
#define SIGNATURE_TYPE_MBR 0x01
|
|
#define SIGNATURE_TYPE_GUID 0x02
|
|
|
|
#define MEDIA_CDROM_DP 0x02
|
|
|
|
typedef struct {
|
|
EFI_DEVICE_PATH Header;
|
|
UINT32 BootEntry;
|
|
UINT64 PartitionStart;
|
|
UINT64 PartitionSize;
|
|
} CDROM_DEVICE_PATH;
|
|
|
|
#define MEDIA_FILEPATH_DP 0x04
|
|
|
|
typedef struct {
|
|
EFI_DEVICE_PATH Header;
|
|
CHAR16 PathName[1];
|
|
} FILEPATH_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
|