of the raw block devices media. Currently "El Torito CD-ROM", UDF, Legacy\r
MBR, and GPT partition schemes are supported.\r
\r
-Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2018 Qualcomm Datacenter Technologies, Inc.\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
PartitionDriverBindingStart,\r
PartitionDriverBindingStop,\r
//\r
- // Grub4Dos copies the BPB of the first partition to the MBR. If the \r
- // DriverBindingStart() of the Fat driver gets run before that of Partition \r
+ // Grub4Dos copies the BPB of the first partition to the MBR. If the\r
+ // DriverBindingStart() of the Fat driver gets run before that of Partition\r
// driver only the first partition can be recognized.\r
// Let the driver binding version of Partition driver be higher than that of\r
// Fat driver to make sure the DriverBindingStart() of the Partition driver\r
};\r
\r
//\r
-// Prioritized function list to detect partition table. \r
+// Prioritized function list to detect partition table.\r
//\r
PARTITION_DETECT_ROUTINE mPartitionDetectRoutineTable[] = {\r
PartitionInstallGptChildHandles,\r
//\r
if (RemainingDevicePath != NULL) {\r
//\r
- // Check if RemainingDevicePath is the End of Device Path Node, \r
+ // Check if RemainingDevicePath is the End of Device Path Node,\r
// if yes, go on checking other conditions\r
//\r
if (!IsDevicePathEnd (RemainingDevicePath)) {\r
EFI_TPL OldTpl;\r
\r
BlockIo2 = NULL;\r
- OldTpl = gBS->RaiseTPL (TPL_CALLBACK); \r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
//\r
// Check RemainingDevicePath validation\r
//\r
if (RemainingDevicePath != NULL) {\r
//\r
- // Check if RemainingDevicePath is the End of Device Path Node, \r
+ // Check if RemainingDevicePath is the End of Device Path Node,\r
// if yes, return EFI_SUCCESS\r
//\r
if (IsDevicePathEnd (RemainingDevicePath)) {\r
// driver. So don't try to close them. Otherwise, we will break the dependency\r
// between the controller and the driver set up before.\r
//\r
- // In the case that when the media changes on a device it will Reinstall the \r
+ // In the case that when the media changes on a device it will Reinstall the\r
// BlockIo interaface. This will cause a call to our Stop(), and a subsequent\r
// reentrant call to our Start() successfully. We should leave the device open\r
// when this happen. The "media change" case includes either the status is\r
- // EFI_MEDIA_CHANGED or it is a "media" to "no media" change. \r
- // \r
+ // EFI_MEDIA_CHANGED or it is a "media" to "no media" change.\r
+ //\r
if (EFI_ERROR (Status) &&\r
!EFI_ERROR (OpenStatus) &&\r
Status != EFI_MEDIA_CHANGED &&\r
);\r
//\r
// Close Parent DiskIo2 if has.\r
- // \r
+ //\r
gBS->CloseProtocol (\r
ControllerHandle,\r
&gEfiDiskIo2ProtocolGuid,\r
BOOLEAN AllChildrenStopped;\r
PARTITION_PRIVATE_DATA *Private;\r
EFI_DISK_IO_PROTOCOL *DiskIo;\r
+ EFI_GUID *TypeGuid;\r
\r
BlockIo = NULL;\r
BlockIo2 = NULL;\r
);\r
//\r
// Close Parent BlockIO2 if has.\r
- // \r
+ //\r
gBS->CloseProtocol (\r
ControllerHandle,\r
&gEfiDiskIo2ProtocolGuid,\r
This->DriverBindingHandle,\r
ControllerHandle,\r
EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
- ); \r
+ );\r
\r
\r
Private = PARTITION_DEVICE_FROM_BLOCK_IO_THIS (BlockIo);\r
This->DriverBindingHandle,\r
ChildHandleBuffer[Index]\r
);\r
+\r
+ if (IsZeroGuid (&Private->TypeGuid)) {\r
+ TypeGuid = NULL;\r
+ } else {\r
+ TypeGuid = &Private->TypeGuid;\r
+ }\r
+\r
//\r
// All Software protocols have be freed from the handle so remove it.\r
// Remove the BlockIo Protocol if has.\r
&Private->BlockIo2,\r
&gEfiPartitionInfoProtocolGuid,\r
&Private->PartitionInfo,\r
- Private->EspGuid,\r
+ TypeGuid,\r
NULL,\r
NULL\r
);\r
&Private->BlockIo,\r
&gEfiPartitionInfoProtocolGuid,\r
&Private->PartitionInfo,\r
- Private->EspGuid,\r
+ TypeGuid,\r
NULL,\r
NULL\r
);\r
)\r
{\r
EFI_STATUS Status;\r
+ UINT8 Buffer[1];\r
\r
//\r
- // Read 1 byte from offset 0 but passing NULL as buffer pointer\r
+ // Read 1 byte from offset 0 to check if the MediaId is still valid.\r
+ // The reading operation is synchronious thus it is not worth it to\r
+ // allocate a buffer from the pool. The destination buffer for the\r
+ // data is in the stack.\r
//\r
- Status = DiskIo2->ReadDiskEx (DiskIo2, MediaId, 0, NULL, 1, NULL);\r
+ Status = DiskIo2->ReadDiskEx (DiskIo2, MediaId, 0, NULL, 1, (VOID*)Buffer);\r
if ((Status == EFI_NO_MEDIA) || (Status == EFI_MEDIA_CHANGED)) {\r
return Status;\r
}\r
\r
/**\r
Read BufferSize bytes from Lba into Buffer.\r
- \r
+\r
This function reads the requested number of blocks from the device. All the\r
blocks are read, or an error is returned.\r
If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_or EFI_MEDIA_CHANGED is returned and\r
not be signaled.\r
\r
@param[in] This Indicates a pointer to the calling context.\r
- @param[in] MediaId Id of the media, changes every time the media is \r
+ @param[in] MediaId Id of the media, changes every time the media is\r
replaced.\r
@param[in] Lba The starting Logical Block Address to read from.\r
- @param[in, out] Token A pointer to the token associated with the transaction.\r
- @param[in] BufferSize Size of Buffer, must be a multiple of device block size. \r
- @param[out] Buffer A pointer to the destination buffer for the data. The \r
- caller is responsible for either having implicit or \r
+ @param[in, out] Token A pointer to the token associated with the transaction.\r
+ @param[in] BufferSize Size of Buffer, must be a multiple of device block size.\r
+ @param[out] Buffer A pointer to the destination buffer for the data. The\r
+ caller is responsible for either having implicit or\r
explicit ownership of the buffer.\r
\r
@retval EFI_SUCCESS The read request was queued if Token->Event is\r
@retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
@retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the\r
intrinsic block size of the device.\r
- @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid, \r
+ @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r
or the buffer is not on proper alignment.\r
@retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack\r
of resources.\r
@retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r
@retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r
@retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
- @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid, \r
+ @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r
or the buffer is not on proper alignment.\r
@retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack\r
of resources.\r
if (Offset + BufferSize > Private->End) {\r
return ProbeMediaStatusEx (Private->DiskIo2, MediaId, EFI_INVALID_PARAMETER);\r
}\r
- \r
+\r
if ((Token != NULL) && (Token->Event != NULL)) {\r
Task = PartitionCreateAccessTask (Token);\r
if (Task == NULL) {\r
\r
/**\r
Flush the Block Device.\r
- \r
+\r
If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED\r
is returned and non-blocking I/O is being used, the Event associated with\r
- this request will not be signaled. \r
+ this request will not be signaled.\r
\r
@param[in] This Indicates a pointer to the calling context.\r
@param[in, out] Token A pointer to the token associated with the transaction\r
@param[in] Start Start Block.\r
@param[in] End End Block.\r
@param[in] BlockSize Child block size.\r
+ @param[in] TypeGuid Partition GUID Type.\r
\r
@retval EFI_SUCCESS A child handle was added.\r
@retval other A child handle was not added.\r
IN EFI_PARTITION_INFO_PROTOCOL *PartitionInfo,\r
IN EFI_LBA Start,\r
IN EFI_LBA End,\r
- IN UINT32 BlockSize\r
+ IN UINT32 BlockSize,\r
+ IN EFI_GUID *TypeGuid\r
)\r
{\r
EFI_STATUS Status;\r
// Set the BlockIO into Private Data.\r
//\r
Private->BlockIo.Revision = ParentBlockIo->Revision;\r
- \r
+\r
Private->BlockIo.Media = &Private->Media;\r
CopyMem (Private->BlockIo.Media, ParentBlockIo->Media, sizeof (EFI_BLOCK_IO_MEDIA));\r
\r
Private->BlockIo2.Reset = PartitionResetEx;\r
Private->BlockIo2.ReadBlocksEx = PartitionReadBlocksEx;\r
Private->BlockIo2.WriteBlocksEx = PartitionWriteBlocksEx;\r
- Private->BlockIo2.FlushBlocksEx = PartitionFlushBlocksEx; \r
+ Private->BlockIo2.FlushBlocksEx = PartitionFlushBlocksEx;\r
}\r
\r
Private->Media.IoAlign = 0;\r
//\r
CopyMem (&Private->PartitionInfo, PartitionInfo, sizeof (EFI_PARTITION_INFO_PROTOCOL));\r
\r
- if (PartitionInfo->System == 1) {\r
- Private->EspGuid = &gEfiPartTypeSystemPartGuid;\r
+ if (TypeGuid != NULL) {\r
+ CopyGuid(&(Private->TypeGuid), TypeGuid);\r
} else {\r
- //\r
- // If NULL InstallMultipleProtocolInterfaces will ignore it.\r
- //\r
- Private->EspGuid = NULL;\r
+ ZeroMem ((VOID *)&(Private->TypeGuid), sizeof (EFI_GUID));\r
}\r
\r
//\r
- // Create the new handle. \r
+ // Create the new handle.\r
//\r
Private->Handle = NULL;\r
if (Private->DiskIo2 != NULL) {\r
&Private->BlockIo2,\r
&gEfiPartitionInfoProtocolGuid,\r
&Private->PartitionInfo,\r
- Private->EspGuid,\r
+ TypeGuid,\r
NULL,\r
NULL\r
);\r
- } else { \r
+ } else {\r
Status = gBS->InstallMultipleProtocolInterfaces (\r
&Private->Handle,\r
&gEfiDevicePathProtocolGuid,\r
&Private->BlockIo,\r
&gEfiPartitionInfoProtocolGuid,\r
&Private->PartitionInfo,\r
- Private->EspGuid,\r
+ TypeGuid,\r
NULL,\r
NULL\r
);\r
/**\r
The user Entry Point for module Partition. The user code starts with this function.\r
\r
- @param[in] ImageHandle The firmware allocated handle for the EFI image. \r
+ @param[in] ImageHandle The firmware allocated handle for the EFI image.\r
@param[in] SystemTable A pointer to the EFI System Table.\r
- \r
+\r
@retval EFI_SUCCESS The entry point is executed successfully.\r
@retval other Some error occurs when executing this entry point.\r
\r