123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571 |
- /*++
- Copyright (c) 2014 Minoca Corp.
- This file is licensed under the terms of the GNU General Public License
- version 3. Alternative licensing terms are available. Contact
- info@minocacorp.com for details. See the LICENSE file at the root of this
- project for complete licensing information.
- Module Name:
- devpath.h
- Abstract:
- This header contains definitions for the UEFI core device path support.
- Author:
- Evan Green 5-Mar-2014
- --*/
- //
- // ------------------------------------------------------------------- Includes
- //
- //
- // ---------------------------------------------------------------- Definitions
- //
- //
- // ------------------------------------------------------ Data Type Definitions
- //
- //
- // -------------------------------------------------------------------- Globals
- //
- //
- // -------------------------------------------------------- Function Prototypes
- //
- EFIAPI
- EFI_DEVICE_PATH_PROTOCOL *
- EfiCoreDuplicateDevicePath (
- CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
- );
- /*++
- Routine Description:
- This routine creates a duplicate of the specified path.
- Arguments:
- DevicePath - Supplies a pointer to the device path instance.
- Return Value:
- Returns a pointer to the duplicate device path on success.
- NULL on allocation failure or if the input device path was null.
- --*/
- EFIAPI
- EFI_DEVICE_PATH_PROTOCOL *
- EfiCoreAppendDevicePath (
- CONST EFI_DEVICE_PATH_PROTOCOL *First,
- CONST EFI_DEVICE_PATH_PROTOCOL *Second
- );
- /*++
- Routine Description:
- This routine creates a new path by appending the second device path to the
- first. If the first source is NULL and the second is not, then a duplicate
- of the second is returned. If the first is not NULL and the second is, a
- duplicate of the first is made. If both are NULL, then a copy of an
- end-of-device-path is returned.
- Arguments:
- First - Supplies an optional pointer to the first device path instance.
- Second - Supplies an optional pointer to the second device path instance.
- Return Value:
- Returns a pointer to the duplicate appended device path on success.
- NULL on allocation failure.
- --*/
- EFIAPI
- EFI_DEVICE_PATH_PROTOCOL *
- EfiCoreAppendDevicePathInstance (
- CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance
- );
- /*++
- Routine Description:
- This routine creates a new path by appending the second device path
- instance to the first. The end-of-device-path device node is moved after
- the end of the appended device path instance and a new
- end-of-device-path-instance node is inserted between. If DevicePath is
- NULL, then a copy if DevicePathInstance is returned. If the device path
- instance is NULL, then NULL is returned. If the device path or device path
- instance is invalid, then NULL is returned. If there is not enough memory
- to allocate space for the new device path, then NULL is returned. The
- memory is allocated from EFI boot services memory. It is the responsibility
- of the caller to free the memory allocated.
- Arguments:
- DevicePath - Supplies an optional pointer to the device path.
- DevicePathInstance - Supplies a pointer to the device path instance to
- append.
- Return Value:
- Returns a pointer to the appended device path on success. The caller is
- responsible for freeing this newly allocated memory.
- NULL on allocation failure.
- --*/
- EFIAPI
- EFI_DEVICE_PATH_PROTOCOL *
- EfiCoreAppendDevicePathNode (
- CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- CONST EFI_DEVICE_PATH_PROTOCOL *Node
- );
- /*++
- Routine Description:
- This routine creates a new device path by appending a copy of the given
- device path node to a copy of the given device path in an allocated buffer.
- The end-of-device-path device node is moved after the end of the appended
- device node. If the node is NULL then a copy of the device path is returned.
- If the device path is NULL then a copy of the node, followed by an
- end-of-device path device node is returned. If both are NULL then a copy of
- an end-of-device-path device node is returned. If there is not enough
- memory to allocate space for the new device path, then NULL is returned.
- The memory is allocated from EFI boot services memory. It is the
- responsibility of the caller to free the memory allocated.
- Arguments:
- DevicePath - Supplies an optional pointer to the device path.
- Node - Supplies an optional pointer to the device path node to append.
- Return Value:
- Returns a pointer to the appended device path on success. The caller is
- responsible for freeing this newly allocated memory.
- NULL on allocation failure.
- --*/
- EFIAPI
- UINTN
- EfiCoreGetDevicePathSize (
- CONST VOID *DevicePath
- );
- /*++
- Routine Description:
- This routine returns the length of the given device path in bytes.
- Arguments:
- DevicePath - Supplies a pointer to the device path.
- Return Value:
- Returns the device path size in bytes.
- 0 if the device path is NULL or invalid.
- --*/
- EFIAPI
- EFI_DEVICE_PATH_PROTOCOL *
- EfiCoreGetNextDevicePathNode (
- CONST VOID *Node
- );
- /*++
- Routine Description:
- This routine returns a pointer to the next node in the device.
- Arguments:
- Node - Supplies a pointer to the device path node.
- Return Value:
- Returns a pointer to the device path node that follows this node.
- --*/
- EFIAPI
- EFI_DEVICE_PATH_PROTOCOL *
- EfiCoreGetNextDevicePathInstance (
- EFI_DEVICE_PATH_PROTOCOL **DevicePath,
- UINTN *Size
- );
- /*++
- Routine Description:
- This routine creates a copy of the current device path instance and returns
- a pointer to the next device path instance.
- Arguments:
- DevicePath - Supplies a pointer that on input contains a pointer to the
- device path instance to copy. On output, this will point to the next
- device path instance on success or NULL on failure.
- Size - Supplies a pointer that on input contains the size of the device
- path. On output this value will be updated to contain the remaining
- size.
- Return Value:
- Returns a pointer to the current device path instance (duplicate).
- --*/
- EFIAPI
- EFI_DEVICE_PATH_PROTOCOL *
- EfiCoreGetDevicePathFromHandle (
- EFI_HANDLE Handle
- );
- /*++
- Routine Description:
- This routine returns the device path protocol instance on the given handle.
- Arguments:
- Handle - Supplies the handle to get the device path on.
- Return Value:
- Returns a pointer to the device path protocol on the handle.
- NULL on failure.
- --*/
- EFIAPI
- BOOLEAN
- EfiCoreIsDevicePathValid (
- CONST VOID *DevicePath,
- UINTN MaxSize
- );
- /*++
- Routine Description:
- This routine determines if a device path is valid.
- Arguments:
- DevicePath - Supplies a pointer to the device path to query.
- MaxSize - Supplies the maximum size of the device path structure.
- Return Value:
- TRUE if the device path is valid.
- FALSE if the length of any node is less than the header size, or the length
- exceeds the given maximum size (if not zero).
- --*/
- EFIAPI
- BOOLEAN
- EfiCoreIsDevicePathEnd (
- CONST VOID *Node
- );
- /*++
- Routine Description:
- This routine determines if a device path node is an end node of an
- entire device path.
- Arguments:
- Node - Supplies a pointer to the device path node.
- Return Value:
- TRUE if this node is the end of the entire device path.
- FALSE if this node is not the end of the entire device path.
- --*/
- EFIAPI
- BOOLEAN
- EfiCoreIsDevicePathEndInstance (
- CONST VOID *Node
- );
- /*++
- Routine Description:
- This routine determines if a device path node is an end node of a
- device path instance.
- Arguments:
- Node - Supplies a pointer to the device path node.
- Return Value:
- TRUE if this node is the end of the device path instance.
- FALSE if this node is not the end of the device path instance.
- --*/
- EFIAPI
- BOOLEAN
- EfiCoreIsDevicePathEndType (
- CONST VOID *Node
- );
- /*++
- Routine Description:
- This routine determines if a device path node is the end device path type.
- Arguments:
- Node - Supplies a pointer to the device path node.
- Return Value:
- TRUE if this node's type is the end type.
- FALSE if this node's type is not the end type.
- --*/
- EFIAPI
- UINT8
- EfiCoreGetDevicePathType (
- CONST VOID *Node
- );
- /*++
- Routine Description:
- This routine returns the device path type for the given node.
- Arguments:
- Node - Supplies a pointer to the device path node.
- Return Value:
- Returns the node's type.
- --*/
- EFIAPI
- UINT8
- EfiCoreGetDevicePathSubType (
- CONST VOID *Node
- );
- /*++
- Routine Description:
- This routine returns the device path sub-type for the given node.
- Arguments:
- Node - Supplies a pointer to the device path node.
- Return Value:
- Returns the node's sub-type.
- --*/
- EFIAPI
- UINTN
- EfiCoreGetDevicePathNodeLength (
- CONST VOID *Node
- );
- /*++
- Routine Description:
- This routine returns the length of the given device path node.
- Arguments:
- Node - Supplies a pointer to the device path node.
- Return Value:
- Returns the device path node length.
- --*/
- EFIAPI
- VOID
- EfiCoreInitializeFirmwareVolumeDevicePathNode (
- MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FirmwareFile,
- EFI_GUID *NameGuid
- );
- /*++
- Routine Description:
- This routine initializes a firmware volume file path.
- Arguments:
- FirmwareFile - Supplies a pointer to the device path node to initialize.
- NameGuid - Supplies a pointer to the name of the file.
- Return Value:
- None.
- --*/
- EFIAPI
- EFI_DEVICE_PATH_PROTOCOL *
- EfiCoreCreateFileDevicePath (
- EFI_HANDLE Device,
- CONST CHAR16 *FileName
- );
- /*++
- Routine Description:
- This routine creates a device path for a file and appends it to an existing
- device path. If the given device is a valid handle that contains a device
- path protocol, then a device path for the file specified by the given file
- name is allocated and appended to the device path associated with the
- given handle. The allocated device path is returned. If the device is NULL
- or the device is a handle that does not support the device path protocol,
- then a device path containing a single device path node for the file
- specified by the file name is allocated and returned. The memory for the
- new device path is allocated from EFI boot services memory. It is the
- responsibility of the caller to free the memory allocated.
- Arguments:
- Device - Supplies an optional device handle.
- FileName - Supplies a pointer to a null-terminated file path string.
- Return Value:
- Returns a pointer to the created device path.
- --*/
- EFIAPI
- EFI_GUID *
- EfiCoreGetNameGuidFromFirmwareVolumeDevicePathNode (
- CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *DevicePathNode
- );
- /*++
- Routine Description:
- This routine returns the file name GUID out of a firmware volume file
- path node.
- Arguments:
- DevicePathNode - Supplies a pointer to the device path node.
- Return Value:
- Returns a pointer to the file name GUID.
- --*/
- EFIAPI
- UINT16
- EfiCoreSetDevicePathNodeLength (
- VOID *Node,
- UINTN Length
- );
- /*++
- Routine Description:
- This routine sets a device path node length.
- Arguments:
- Node - Supplies a pointer to the device path header.
- Length - Supplies the length to set.
- Return Value:
- Returns the length value.
- --*/
- EFIAPI
- VOID
- EfiCoreSetDevicePathEndNode (
- VOID *Node
- );
- /*++
- Routine Description:
- This routine sets the given device path node as an end of the entire
- device path.
- Arguments:
- Node - Supplies a pointer to the device path header.
- Return Value:
- None.
- --*/
|