TianoCore EDK2 master
Loading...
Searching...
No Matches
Partition.c File Reference
#include "Partition.h"

Go to the source code of this file.

Functions

EFI_STATUS EFIAPI PartitionDriverBindingSupported (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
EFI_STATUS EFIAPI PartitionDriverBindingStart (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
EFI_STATUS EFIAPI PartitionDriverBindingStop (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
 
EFI_STATUS EFIAPI PartitionReset (IN EFI_BLOCK_IO_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
 
EFI_STATUS ProbeMediaStatus (IN EFI_DISK_IO_PROTOCOL *DiskIo, IN UINT32 MediaId, IN EFI_STATUS DefaultStatus)
 
EFI_STATUS EFIAPI PartitionReadBlocks (IN EFI_BLOCK_IO_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA Lba, IN UINTN BufferSize, OUT VOID *Buffer)
 
EFI_STATUS EFIAPI PartitionWriteBlocks (IN EFI_BLOCK_IO_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA Lba, IN UINTN BufferSize, IN VOID *Buffer)
 
EFI_STATUS EFIAPI PartitionFlushBlocks (IN EFI_BLOCK_IO_PROTOCOL *This)
 
EFI_STATUS ProbeMediaStatusEx (IN EFI_DISK_IO2_PROTOCOL *DiskIo2, IN UINT32 MediaId, IN EFI_STATUS DefaultStatus)
 
EFI_STATUS EFIAPI PartitionResetEx (IN EFI_BLOCK_IO2_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
 
VOID EFIAPI PartitionOnAccessComplete (IN EFI_EVENT Event, IN VOID *Context)
 
PARTITION_ACCESS_TASKPartitionCreateAccessTask (IN EFI_BLOCK_IO2_TOKEN *Token)
 
EFI_STATUS EFIAPI PartitionReadBlocksEx (IN EFI_BLOCK_IO2_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA Lba, IN OUT EFI_BLOCK_IO2_TOKEN *Token, IN UINTN BufferSize, OUT VOID *Buffer)
 
EFI_STATUS EFIAPI PartitionWriteBlocksEx (IN EFI_BLOCK_IO2_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA Lba, IN OUT EFI_BLOCK_IO2_TOKEN *Token, IN UINTN BufferSize, IN VOID *Buffer)
 
EFI_STATUS EFIAPI PartitionFlushBlocksEx (IN EFI_BLOCK_IO2_PROTOCOL *This, IN OUT EFI_BLOCK_IO2_TOKEN *Token)
 
EFI_STATUS PartitionInstallChildHandle (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ParentHandle, IN EFI_DISK_IO_PROTOCOL *ParentDiskIo, IN EFI_DISK_IO2_PROTOCOL *ParentDiskIo2, IN EFI_BLOCK_IO_PROTOCOL *ParentBlockIo, IN EFI_BLOCK_IO2_PROTOCOL *ParentBlockIo2, IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath, IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode, IN EFI_PARTITION_INFO_PROTOCOL *PartitionInfo, IN EFI_LBA Start, IN EFI_LBA End, IN UINT32 BlockSize, IN EFI_GUID *TypeGuid)
 
EFI_STATUS EFIAPI InitializePartition (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 
BOOLEAN HasChildren (IN EFI_HANDLE ControllerHandle)
 

Variables

EFI_DRIVER_BINDING_PROTOCOL gPartitionDriverBinding
 
PARTITION_DETECT_ROUTINE mPartitionDetectRoutineTable []
 

Detailed Description

Partition driver that produces logical BlockIo devices from a physical BlockIo device. The logical BlockIo devices are based on the format of the raw block devices media. Currently "El Torito CD-ROM", UDF, Legacy MBR, and GPT partition schemes are supported.

Copyright (c) 2018 Qualcomm Datacenter Technologies, Inc. Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file Partition.c.

Function Documentation

◆ HasChildren()

BOOLEAN HasChildren ( IN EFI_HANDLE  ControllerHandle)

Test to see if there is any child on ControllerHandle.

Parameters
[in]ControllerHandleHandle of device to test.
Return values
TRUEThere are children on the ControllerHandle.
FALSENo child is on the ControllerHandle.

Definition at line 1355 of file Partition.c.

◆ InitializePartition()

EFI_STATUS EFIAPI InitializePartition ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

The user Entry Point for module Partition. The user code starts with this function.

Parameters
[in]ImageHandleThe firmware allocated handle for the EFI image.
[in]SystemTableA pointer to the EFI System Table.
Return values
EFI_SUCCESSThe entry point is executed successfully.
otherSome error occurs when executing this entry point.

Definition at line 1322 of file Partition.c.

◆ PartitionCreateAccessTask()

PARTITION_ACCESS_TASK * PartitionCreateAccessTask ( IN EFI_BLOCK_IO2_TOKEN Token)

Create a new PARTITION_ACCESS_TASK instance.

Parameters
TokenPointer to the EFI_BLOCK_IO2_TOKEN.
Returns
Pointer to the created PARTITION_ACCESS_TASK instance or NULL upon failure.

Definition at line 875 of file Partition.c.

◆ PartitionDriverBindingStart()

EFI_STATUS EFIAPI PartitionDriverBindingStart ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL RemainingDevicePath 
)

Start this driver on ControllerHandle by opening a Block IO or a Block IO2 or both, and Disk IO protocol, reading Device Path, and creating a child handle with a Disk IO and device path protocol.

Parameters
[in]ThisProtocol instance pointer.
[in]ControllerHandleHandle of device to bind driver to
[in]RemainingDevicePathOptional parameter use to pick a specific child device to start.
Return values
EFI_SUCCESSThis driver is added to ControllerHandle
EFI_ALREADY_STARTEDThis driver is already running on ControllerHandle
otherThis driver does not support this device

Definition at line 194 of file Partition.c.

◆ PartitionDriverBindingStop()

EFI_STATUS EFIAPI PartitionDriverBindingStop ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  ControllerHandle,
IN UINTN  NumberOfChildren,
IN EFI_HANDLE ChildHandleBuffer 
)

Stop this driver on ControllerHandle. Support stopping any child handles created by this driver.

Parameters
ThisProtocol instance pointer.
ControllerHandleHandle of device to stop driver on
NumberOfChildrenNumber of Handles in ChildHandleBuffer. If number of children is zero stop the entire bus driver.
ChildHandleBufferList of Child Handles to Stop.
Return values
EFI_SUCCESSThis driver is removed ControllerHandle
otherThis driver was not removed from this device

Definition at line 399 of file Partition.c.

◆ PartitionDriverBindingSupported()

EFI_STATUS EFIAPI PartitionDriverBindingSupported ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL RemainingDevicePath 
)

Test to see if this driver supports ControllerHandle. Any ControllerHandle than contains a BlockIo and DiskIo protocol or a BlockIo2 protocol can be supported.

Parameters
[in]ThisProtocol instance pointer.
[in]ControllerHandleHandle of device to test.
[in]RemainingDevicePathOptional parameter use to pick a specific child device to start.
Return values
EFI_SUCCESSThis driver supports this device
EFI_ALREADY_STARTEDThis driver is already running on this device
otherThis driver does not support this device

Definition at line 70 of file Partition.c.

◆ PartitionFlushBlocks()

EFI_STATUS EFIAPI PartitionFlushBlocks ( IN EFI_BLOCK_IO_PROTOCOL This)

Flush the parent Block Device.

Parameters
ThisProtocol instance pointer.
Return values
EFI_SUCCESSAll outstanding data was written to the device
EFI_DEVICE_ERRORThe device reported an error while writting back the data
EFI_NO_MEDIAThere is no media in the device.

Definition at line 766 of file Partition.c.

◆ PartitionFlushBlocksEx()

EFI_STATUS EFIAPI PartitionFlushBlocksEx ( IN EFI_BLOCK_IO2_PROTOCOL This,
IN OUT EFI_BLOCK_IO2_TOKEN Token 
)

Flush the Block Device.

If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED is returned and non-blocking I/O is being used, the Event associated with this request will not be signaled.

Parameters
[in]ThisIndicates a pointer to the calling context.
[in,out]TokenA pointer to the token associated with the transaction
Return values
EFI_SUCCESSThe flush request was queued if Event is not NULL. All outstanding data was written correctly to the device if the Event is NULL.
EFI_DEVICE_ERRORThe device reported an error while writting back the data.
EFI_WRITE_PROTECTEDThe device cannot be written to.
EFI_NO_MEDIAThere is no media in the device.
EFI_MEDIA_CHANGEDThe MediaId is not for the current media.
EFI_OUT_OF_RESOURCESThe request could not be completed due to a lack of resources.

Definition at line 1082 of file Partition.c.

◆ PartitionInstallChildHandle()

EFI_STATUS PartitionInstallChildHandle ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  ParentHandle,
IN EFI_DISK_IO_PROTOCOL ParentDiskIo,
IN EFI_DISK_IO2_PROTOCOL ParentDiskIo2,
IN EFI_BLOCK_IO_PROTOCOL ParentBlockIo,
IN EFI_BLOCK_IO2_PROTOCOL ParentBlockIo2,
IN EFI_DEVICE_PATH_PROTOCOL ParentDevicePath,
IN EFI_DEVICE_PATH_PROTOCOL DevicePathNode,
IN EFI_PARTITION_INFO_PROTOCOL PartitionInfo,
IN EFI_LBA  Start,
IN EFI_LBA  End,
IN UINT32  BlockSize,
IN EFI_GUID TypeGuid 
)

Create a child handle for a logical block device that represents the bytes Start to End of the Parent Block IO device.

Parameters
[in]ThisProtocol instance pointer.
[in]ParentHandleParent Handle for new child.
[in]ParentDiskIoParent DiskIo interface.
[in]ParentDiskIo2Parent DiskIo2 interface.
[in]ParentBlockIoParent BlockIo interface.
[in]ParentBlockIo2Parent BlockIo2 interface.
[in]ParentDevicePathParent Device Path.
[in]DevicePathNodeChild Device Path node.
[in]PartitionInfoChild Partition Information interface.
[in]StartStart Block.
[in]EndEnd Block.
[in]BlockSizeChild block size.
[in]TypeGuidPartition GUID Type.
Return values
EFI_SUCCESSA child handle was added.
otherA child handle was not added.

Definition at line 1134 of file Partition.c.

◆ PartitionOnAccessComplete()

VOID EFIAPI PartitionOnAccessComplete ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

The general callback for the DiskIo2 interfaces.

Parameters
EventEvent whose notification function is being invoked.
ContextThe pointer to the notification function's context, which points to the PARTITION_ACCESS_TASK instance.

Definition at line 850 of file Partition.c.

◆ PartitionReadBlocks()

EFI_STATUS EFIAPI PartitionReadBlocks ( IN EFI_BLOCK_IO_PROTOCOL This,
IN UINT32  MediaId,
IN EFI_LBA  Lba,
IN UINTN  BufferSize,
OUT VOID *  Buffer 
)

Read by using the Disk IO protocol on the parent device. Lba addresses must be converted to byte offsets.

Parameters
ThisProtocol instance pointer.
MediaIdId of the media, changes every time the media is replaced.
LbaThe starting Logical Block Address to read from
BufferSizeSize of Buffer, must be a multiple of device block size.
BufferBuffer containing read data
Return values
EFI_SUCCESSThe data was read correctly from the device.
EFI_DEVICE_ERRORThe device reported an error while performing the read.
EFI_NO_MEDIAThere is no media in the device.
EFI_MEDIA_CHANGEDThe MediaId does not matched the current device.
EFI_BAD_BUFFER_SIZEThe Buffer was not a multiple of the block size of the device.
EFI_INVALID_PARAMETERThe read request contains device addresses that are not valid for the device.

Definition at line 672 of file Partition.c.

◆ PartitionReadBlocksEx()

EFI_STATUS EFIAPI PartitionReadBlocksEx ( IN EFI_BLOCK_IO2_PROTOCOL This,
IN UINT32  MediaId,
IN EFI_LBA  Lba,
IN OUT EFI_BLOCK_IO2_TOKEN Token,
IN UINTN  BufferSize,
OUT VOID *  Buffer 
)

Read BufferSize bytes from Lba into Buffer.

This function reads the requested number of blocks from the device. All the blocks are read, or an error is returned. If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_or EFI_MEDIA_CHANGED is returned and non-blocking I/O is being used, the Event associated with this request will not be signaled.

Parameters
[in]ThisIndicates a pointer to the calling context.
[in]MediaIdId of the media, changes every time the media is replaced.
[in]LbaThe starting Logical Block Address to read from.
[in,out]TokenA pointer to the token associated with the transaction.
[in]BufferSizeSize of Buffer, must be a multiple of device block size.
[out]BufferA pointer to the destination buffer for the data. The caller is responsible for either having implicit or explicit ownership of the buffer.
Return values
EFI_SUCCESSThe read request was queued if Token->Event is not NULL.The data was read correctly from the device if the Token->Event is NULL.
EFI_DEVICE_ERRORThe device reported an error while performing the read.
EFI_NO_MEDIAThere is no media in the device.
EFI_MEDIA_CHANGEDThe MediaId is not for the current media.
EFI_BAD_BUFFER_SIZEThe BufferSize parameter is not a multiple of the intrinsic block size of the device.
EFI_INVALID_PARAMETERThe read request contains LBAs that are not valid, or the buffer is not on proper alignment.
EFI_OUT_OF_RESOURCESThe request could not be completed due to a lack of resources.

Definition at line 939 of file Partition.c.

◆ PartitionReset()

EFI_STATUS EFIAPI PartitionReset ( IN EFI_BLOCK_IO_PROTOCOL This,
IN BOOLEAN  ExtendedVerification 
)

Reset the Block Device.

Parameters
ThisProtocol instance pointer.
ExtendedVerificationDriver may perform diagnostics on reset.
Return values
EFI_SUCCESSThe device was reset.
EFI_DEVICE_ERRORThe device is not functioning properly and could not be reset.

Definition at line 599 of file Partition.c.

◆ PartitionResetEx()

EFI_STATUS EFIAPI PartitionResetEx ( IN EFI_BLOCK_IO2_PROTOCOL This,
IN BOOLEAN  ExtendedVerification 
)

Reset the Block Device throught Block I/O2 protocol.

Parameters
ThisProtocol instance pointer.
ExtendedVerificationDriver may perform diagnostics on reset.
Return values
EFI_SUCCESSThe device was reset.
EFI_DEVICE_ERRORThe device is not functioning properly and could not be reset.

Definition at line 827 of file Partition.c.

◆ PartitionWriteBlocks()

EFI_STATUS EFIAPI PartitionWriteBlocks ( IN EFI_BLOCK_IO_PROTOCOL This,
IN UINT32  MediaId,
IN EFI_LBA  Lba,
IN UINTN  BufferSize,
IN VOID *  Buffer 
)

Write by using the Disk IO protocol on the parent device. Lba addresses must be converted to byte offsets.

Parameters
[in]ThisProtocol instance pointer.
[in]MediaIdId of the media, changes every time the media is replaced.
[in]LbaThe starting Logical Block Address to read from
[in]BufferSizeSize of Buffer, must be a multiple of device block size.
[in]BufferBuffer containing data to be written to device.
Return values
EFI_SUCCESSThe data was written correctly to the device.
EFI_WRITE_PROTECTEDThe device can not be written to.
EFI_DEVICE_ERRORThe device reported an error while performing the write.
EFI_NO_MEDIAThere is no media in the device.
EFI_MEDIA_CHNAGEDThe MediaId does not matched the current device.
EFI_BAD_BUFFER_SIZEThe Buffer was not a multiple of the block size of the device.
EFI_INVALID_PARAMETERThe write request contains a LBA that is not valid for the device.

Definition at line 724 of file Partition.c.

◆ PartitionWriteBlocksEx()

EFI_STATUS EFIAPI PartitionWriteBlocksEx ( IN EFI_BLOCK_IO2_PROTOCOL This,
IN UINT32  MediaId,
IN EFI_LBA  Lba,
IN OUT EFI_BLOCK_IO2_TOKEN Token,
IN UINTN  BufferSize,
IN VOID *  Buffer 
)

Write BufferSize bytes from Lba into Buffer.

This function writes the requested number of blocks to the device. All blocks are written, or an error is returned.If EFI_DEVICE_ERROR, EFI_NO_MEDIA, EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED is returned and non-blocking I/O is being used, the Event associated with this request will not be signaled.

Parameters
[in]ThisIndicates a pointer to the calling context.
[in]MediaIdThe media ID that the write request is for.
[in]LbaThe starting logical block address to be written. The caller is responsible for writing to only legitimate locations.
[in,out]TokenA pointer to the token associated with the transaction.
[in]BufferSizeSize of Buffer, must be a multiple of device block size.
[in]BufferA pointer to the source buffer for the data.
Return values
EFI_SUCCESSThe write request was queued if Event is not NULL. The data was written correctly to the device if the Event is NULL.
EFI_WRITE_PROTECTEDThe device can not be written to.
EFI_NO_MEDIAThere is no media in the device.
EFI_MEDIA_CHNAGEDThe MediaId does not matched the current device.
EFI_DEVICE_ERRORThe device reported an error while performing the write.
EFI_BAD_BUFFER_SIZEThe Buffer was not a multiple of the block size of the device.
EFI_INVALID_PARAMETERThe write request contains LBAs that are not valid, or the buffer is not on proper alignment.
EFI_OUT_OF_RESOURCESThe request could not be completed due to a lack of resources.

Definition at line 1015 of file Partition.c.

◆ ProbeMediaStatus()

EFI_STATUS ProbeMediaStatus ( IN EFI_DISK_IO_PROTOCOL DiskIo,
IN UINT32  MediaId,
IN EFI_STATUS  DefaultStatus 
)

Probe the media status and return EFI_NO_MEDIA or EFI_MEDIA_CHANGED for no media or media change case. Otherwise DefaultStatus is returned.

Parameters
DiskIoPointer to the DiskIo instance.
MediaIdId of the media, changes every time the media is replaced.
DefaultStatusThe default status to return when it's not the no media or media change case.
Return values
EFI_NO_MEDIAThere is no media.
EFI_MEDIA_CHANGEDThe media was changed.
othersThe default status to return.

Definition at line 628 of file Partition.c.

◆ ProbeMediaStatusEx()

EFI_STATUS ProbeMediaStatusEx ( IN EFI_DISK_IO2_PROTOCOL DiskIo2,
IN UINT32  MediaId,
IN EFI_STATUS  DefaultStatus 
)

Probe the media status and return EFI_NO_MEDIA or EFI_MEDIA_CHANGED for no media or media change case. Otherwise DefaultStatus is returned.

Parameters
DiskIo2Pointer to the DiskIo2 instance.
MediaIdId of the media, changes every time the media is replaced.
DefaultStatusThe default status to return when it's not the no media or media change case.
Return values
EFI_NO_MEDIAThere is no media.
EFI_MEDIA_CHANGEDThe media was changed.
othersThe default status to return.

Definition at line 791 of file Partition.c.

Variable Documentation

◆ gPartitionDriverBinding

EFI_DRIVER_BINDING_PROTOCOL gPartitionDriverBinding
Initial value:
= {
0xb,
}
#define NULL
Definition: Base.h:319
EFI_STATUS EFIAPI PartitionDriverBindingStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
Definition: Partition.c:399
EFI_STATUS EFIAPI PartitionDriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: Partition.c:70
EFI_STATUS EFIAPI PartitionDriverBindingStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: Partition.c:194

Definition at line 18 of file Partition.c.

◆ mPartitionDetectRoutineTable

PARTITION_DETECT_ROUTINE mPartitionDetectRoutineTable[]
Initial value:
= {
}
EFI_STATUS PartitionInstallGptChildHandles(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Handle, IN EFI_DISK_IO_PROTOCOL *DiskIo, IN EFI_DISK_IO2_PROTOCOL *DiskIo2, IN EFI_BLOCK_IO_PROTOCOL *BlockIo, IN EFI_BLOCK_IO2_PROTOCOL *BlockIo2, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
Definition: Gpt.c:186
EFI_STATUS PartitionInstallMbrChildHandles(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Handle, IN EFI_DISK_IO_PROTOCOL *DiskIo, IN EFI_DISK_IO2_PROTOCOL *DiskIo2, IN EFI_BLOCK_IO_PROTOCOL *BlockIo, IN EFI_BLOCK_IO2_PROTOCOL *BlockIo2, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
Definition: Mbr.c:118
EFI_STATUS PartitionInstallUdfChildHandles(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Handle, IN EFI_DISK_IO_PROTOCOL *DiskIo, IN EFI_DISK_IO2_PROTOCOL *DiskIo2, IN EFI_BLOCK_IO_PROTOCOL *BlockIo, IN EFI_BLOCK_IO2_PROTOCOL *BlockIo2, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
Definition: Udf.c:738

Definition at line 46 of file Partition.c.