46PARTITION_DETECT_ROUTINE mPartitionDetectRoutineTable[] = {
84 if (RemainingDevicePath !=
NULL) {
95 if ((Node->DevPath.
Type != MEDIA_DEVICE_PATH) ||
99 return EFI_UNSUPPORTED;
107 Status =
gBS->OpenProtocol (
109 &gEfiDiskIoProtocolGuid,
111 This->DriverBindingHandle,
113 EFI_OPEN_PROTOCOL_BY_DRIVER
115 if (Status == EFI_ALREADY_STARTED) {
119 if (EFI_ERROR (Status)) {
128 &gEfiDiskIoProtocolGuid,
129 This->DriverBindingHandle,
136 Status =
gBS->OpenProtocol (
138 &gEfiDevicePathProtocolGuid,
139 (VOID **)&ParentDevicePath,
140 This->DriverBindingHandle,
142 EFI_OPEN_PROTOCOL_BY_DRIVER
144 if (Status == EFI_ALREADY_STARTED) {
148 if (EFI_ERROR (Status)) {
157 &gEfiDevicePathProtocolGuid,
158 This->DriverBindingHandle,
165 Status =
gBS->OpenProtocol (
167 &gEfiBlockIoProtocolGuid,
169 This->DriverBindingHandle,
171 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
207 PARTITION_DETECT_ROUTINE *Routine;
208 BOOLEAN MediaPresent;
212 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
216 if (RemainingDevicePath !=
NULL) {
231 Status =
gBS->OpenProtocol (
233 &gEfiBlockIoProtocolGuid,
235 This->DriverBindingHandle,
237 EFI_OPEN_PROTOCOL_GET_PROTOCOL
239 if (EFI_ERROR (Status)) {
243 Status =
gBS->OpenProtocol (
245 &gEfiBlockIo2ProtocolGuid,
247 This->DriverBindingHandle,
249 EFI_OPEN_PROTOCOL_GET_PROTOCOL
251 if (EFI_ERROR (Status)) {
258 Status =
gBS->OpenProtocol (
260 &gEfiDevicePathProtocolGuid,
261 (VOID **)&ParentDevicePath,
262 This->DriverBindingHandle,
264 EFI_OPEN_PROTOCOL_BY_DRIVER
266 if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
273 Status =
gBS->OpenProtocol (
275 &gEfiDiskIoProtocolGuid,
277 This->DriverBindingHandle,
279 EFI_OPEN_PROTOCOL_BY_DRIVER
281 if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
284 &gEfiDevicePathProtocolGuid,
285 This->DriverBindingHandle,
293 Status =
gBS->OpenProtocol (
295 &gEfiDiskIo2ProtocolGuid,
297 This->DriverBindingHandle,
299 EFI_OPEN_PROTOCOL_BY_DRIVER
301 if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
308 Status = EFI_UNSUPPORTED;
318 Routine = &mPartitionDetectRoutineTable[0];
319 while (*Routine !=
NULL) {
329 if (!EFI_ERROR (Status) || (Status == EFI_MEDIA_CHANGED) || (Status == EFI_NO_MEDIA)) {
349 if (EFI_ERROR (Status) &&
350 !EFI_ERROR (OpenStatus) &&
351 (Status != EFI_MEDIA_CHANGED) &&
352 !(MediaPresent && (Status == EFI_NO_MEDIA)))
356 &gEfiDiskIoProtocolGuid,
357 This->DriverBindingHandle,
365 &gEfiDiskIo2ProtocolGuid,
366 This->DriverBindingHandle,
372 &gEfiDevicePathProtocolGuid,
373 This->DriverBindingHandle,
379 gBS->RestoreTPL (OldTpl);
410 BOOLEAN AllChildrenStopped;
419 if (NumberOfChildren == 0) {
426 DEBUG ((DEBUG_ERROR,
"PartitionDriverBindingStop: Still has child.\n"));
427 return EFI_DEVICE_ERROR;
435 &gEfiDiskIoProtocolGuid,
436 This->DriverBindingHandle,
444 &gEfiDiskIo2ProtocolGuid,
445 This->DriverBindingHandle,
451 &gEfiDevicePathProtocolGuid,
452 This->DriverBindingHandle,
458 AllChildrenStopped =
TRUE;
459 for (Index = 0; Index < NumberOfChildren; Index++) {
461 ChildHandleBuffer[Index],
462 &gEfiBlockIoProtocolGuid,
464 This->DriverBindingHandle,
466 EFI_OPEN_PROTOCOL_GET_PROTOCOL
472 ChildHandleBuffer[Index],
473 &gEfiBlockIo2ProtocolGuid,
475 This->DriverBindingHandle,
477 EFI_OPEN_PROTOCOL_GET_PROTOCOL
480 Private = PARTITION_DEVICE_FROM_BLOCK_IO_THIS (BlockIo);
481 if (Private->InStop) {
489 Private->InStop =
TRUE;
491 BlockIo->FlushBlocks (BlockIo);
493 if (BlockIo2 !=
NULL) {
494 Status = BlockIo2->FlushBlocksEx (BlockIo2,
NULL);
495 DEBUG ((DEBUG_ERROR,
"PartitionDriverBindingStop: FlushBlocksEx returned with %r\n", Status));
502 &gEfiDiskIoProtocolGuid,
503 This->DriverBindingHandle,
504 ChildHandleBuffer[Index]
510 TypeGuid = &Private->TypeGuid;
518 if (BlockIo2 !=
NULL) {
525 if (Status != EFI_MEDIA_CHANGED) {
526 Status =
gBS->UninstallMultipleProtocolInterfaces (
527 ChildHandleBuffer[Index],
528 &gEfiDevicePathProtocolGuid,
530 &gEfiBlockIoProtocolGuid,
532 &gEfiBlockIo2ProtocolGuid,
535 &Private->PartitionInfo,
542 Status =
gBS->UninstallMultipleProtocolInterfaces (
543 ChildHandleBuffer[Index],
544 &gEfiDevicePathProtocolGuid,
546 &gEfiBlockIoProtocolGuid,
549 &Private->PartitionInfo,
556 if (EFI_ERROR (Status)) {
557 Private->InStop =
FALSE;
560 &gEfiDiskIoProtocolGuid,
562 This->DriverBindingHandle,
563 ChildHandleBuffer[Index],
564 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
571 if (EFI_ERROR (Status)) {
572 AllChildrenStopped =
FALSE;
573 if (Status == EFI_MEDIA_CHANGED) {
579 if (!AllChildrenStopped) {
580 return EFI_DEVICE_ERROR;
601 IN BOOLEAN ExtendedVerification
606 Private = PARTITION_DEVICE_FROM_BLOCK_IO_THIS (This);
608 return Private->ParentBlockIo->Reset (
609 Private->ParentBlockIo,
643 Status = DiskIo->ReadDisk (DiskIo, MediaId, 0, 1, (VOID *)Buffer);
644 if ((Status == EFI_NO_MEDIA) || (Status == EFI_MEDIA_CHANGED)) {
648 return DefaultStatus;
683 Private = PARTITION_DEVICE_FROM_BLOCK_IO_THIS (This);
685 if (BufferSize % Private->BlockSize != 0) {
689 Offset =
MultU64x32 (Lba, Private->BlockSize) + Private->Start;
690 if (Offset + BufferSize > Private->End) {
699 return Private->DiskIo->ReadDisk (Private->DiskIo, MediaId, Offset, BufferSize, Buffer);
735 Private = PARTITION_DEVICE_FROM_BLOCK_IO_THIS (This);
737 if (BufferSize % Private->BlockSize != 0) {
741 Offset =
MultU64x32 (Lba, Private->BlockSize) + Private->Start;
742 if (Offset + BufferSize > Private->End) {
751 return Private->DiskIo->WriteDisk (Private->DiskIo, MediaId, Offset, BufferSize, Buffer);
772 Private = PARTITION_DEVICE_FROM_BLOCK_IO_THIS (This);
774 return Private->ParentBlockIo->FlushBlocks (Private->ParentBlockIo);
806 Status = DiskIo2->ReadDiskEx (DiskIo2, MediaId, 0,
NULL, 1, (VOID *)Buffer);
807 if ((Status == EFI_NO_MEDIA) || (Status == EFI_MEDIA_CHANGED)) {
811 return DefaultStatus;
829 IN BOOLEAN ExtendedVerification
834 Private = PARTITION_DEVICE_FROM_BLOCK_IO2_THIS (This);
836 return Private->ParentBlockIo2->Reset (
837 Private->ParentBlockIo2,
859 gBS->CloseEvent (Event);
862 gBS->SignalEvent (Task->BlockIo2Token->
Event);
887 Status =
gBS->CreateEvent (
892 &Task->DiskIo2Token.Event
894 if (EFI_ERROR (Status)) {
899 Task->BlockIo2Token = Token;
953 Private = PARTITION_DEVICE_FROM_BLOCK_IO2_THIS (This);
955 if (BufferSize % Private->BlockSize != 0) {
959 Offset =
MultU64x32 (Lba, Private->BlockSize) + Private->Start;
960 if (Offset + BufferSize > Private->End) {
964 if ((Token !=
NULL) && (Token->Event !=
NULL)) {
967 return EFI_OUT_OF_RESOURCES;
970 Status = Private->DiskIo2->ReadDiskEx (Private->DiskIo2, MediaId, Offset, &Task->DiskIo2Token, BufferSize, Buffer);
971 if (EFI_ERROR (Status)) {
972 gBS->CloseEvent (Task->DiskIo2Token.Event);
976 Status = Private->DiskIo2->ReadDiskEx (Private->DiskIo2, MediaId, Offset,
NULL, BufferSize, Buffer);
1029 Private = PARTITION_DEVICE_FROM_BLOCK_IO2_THIS (This);
1031 if (BufferSize % Private->BlockSize != 0) {
1035 Offset =
MultU64x32 (Lba, Private->BlockSize) + Private->Start;
1036 if (Offset + BufferSize > Private->End) {
1040 if ((Token !=
NULL) && (Token->Event !=
NULL)) {
1043 return EFI_OUT_OF_RESOURCES;
1046 Status = Private->DiskIo2->WriteDiskEx (Private->DiskIo2, MediaId, Offset, &Task->DiskIo2Token, BufferSize, Buffer);
1047 if (EFI_ERROR (Status)) {
1048 gBS->CloseEvent (Task->DiskIo2Token.Event);
1052 Status = Private->DiskIo2->WriteDiskEx (Private->DiskIo2, MediaId, Offset,
NULL, BufferSize, Buffer);
1091 Private = PARTITION_DEVICE_FROM_BLOCK_IO2_THIS (This);
1093 if ((Token !=
NULL) && (Token->Event !=
NULL)) {
1096 return EFI_OUT_OF_RESOURCES;
1099 Status = Private->DiskIo2->FlushDiskEx (Private->DiskIo2, &Task->DiskIo2Token);
1100 if (EFI_ERROR (Status)) {
1101 gBS->CloseEvent (Task->DiskIo2Token.Event);
1105 Status = Private->DiskIo2->FlushDiskEx (Private->DiskIo2,
NULL);
1146 IN UINT32 BlockSize,
1155 if (Private ==
NULL) {
1156 return EFI_OUT_OF_RESOURCES;
1159 Private->Signature = PARTITION_PRIVATE_DATA_SIGNATURE;
1161 Private->Start =
MultU64x32 (Start, ParentBlockIo->Media->BlockSize);
1162 Private->End =
MultU64x32 (End + 1, ParentBlockIo->Media->BlockSize);
1164 Private->BlockSize = BlockSize;
1165 Private->ParentBlockIo = ParentBlockIo;
1166 Private->ParentBlockIo2 = ParentBlockIo2;
1167 Private->DiskIo = ParentDiskIo;
1168 Private->DiskIo2 = ParentDiskIo2;
1173 Private->BlockIo.
Revision = ParentBlockIo->Revision;
1175 Private->BlockIo.
Media = &Private->Media;
1186 if (Private->DiskIo2 !=
NULL) {
1187 ASSERT (Private->ParentBlockIo2 !=
NULL);
1188 Private->BlockIo2.
Media = &Private->Media2;
1202 ParentBlockIo->Media->BlockSize
1207 Private->Media.
BlockSize = (UINT32)BlockSize;
1212 Private->Media2.
BlockSize = (UINT32)BlockSize;
1218 if (Private->BlockIo.
Revision >= EFI_BLOCK_IO_PROTOCOL_REVISION2) {
1223 if (Private->BlockIo.
Revision >= EFI_BLOCK_IO_PROTOCOL_REVISION3) {
1231 if (Private->DevicePath ==
NULL) {
1233 return EFI_OUT_OF_RESOURCES;
1241 if (TypeGuid !=
NULL) {
1242 CopyGuid (&(Private->TypeGuid), TypeGuid);
1250 Private->Handle =
NULL;
1251 if (Private->DiskIo2 !=
NULL) {
1252 Status =
gBS->InstallMultipleProtocolInterfaces (
1254 &gEfiDevicePathProtocolGuid,
1255 Private->DevicePath,
1256 &gEfiBlockIoProtocolGuid,
1258 &gEfiBlockIo2ProtocolGuid,
1261 &Private->PartitionInfo,
1267 Status =
gBS->InstallMultipleProtocolInterfaces (
1269 &gEfiDevicePathProtocolGuid,
1270 Private->DevicePath,
1271 &gEfiBlockIoProtocolGuid,
1274 &Private->PartitionInfo,
1281 if (!EFI_ERROR (Status)) {
1285 Status =
gBS->OpenProtocol (
1287 &gEfiDiskIoProtocolGuid,
1288 (VOID **)&ParentDiskIo,
1289 This->DriverBindingHandle,
1291 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
1302 if (Status == EFI_ALREADY_STARTED) {
1335 &gPartitionDriverBinding,
1337 &gPartitionComponentName,
1338 &gPartitionComponentName2
1364 Status =
gBS->OpenProtocolInformation (
1366 &gEfiDiskIoProtocolGuid,
1372 for (Index = 0; Index < EntryCount; Index++) {
1373 if ((OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
1380 return (BOOLEAN)(Index < EntryCount);
UINT64 EFIAPI DivU64x32(IN UINT64 Dividend, IN UINT32 Divisor)
UINT64 EFIAPI MultU64x32(IN UINT64 Multiplicand, IN UINT32 Multiplier)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
BOOLEAN EFIAPI IsZeroGuid(IN CONST GUID *Guid)
#define MEDIA_HARDDRIVE_DP
UINTN EFIAPI DevicePathNodeLength(IN CONST VOID *Node)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI AppendDevicePathNode(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL, IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode OPTIONAL)
BOOLEAN EFIAPI IsDevicePathEnd(IN CONST VOID *Node)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
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)
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)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
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 PartitionResetEx(IN EFI_BLOCK_IO2_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
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 EFIAPI PartitionDriverBindingStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
EFI_STATUS EFIAPI InitializePartition(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
VOID EFIAPI PartitionOnAccessComplete(IN EFI_EVENT Event, IN VOID *Context)
EFI_STATUS EFIAPI PartitionDriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
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)
BOOLEAN HasChildren(IN EFI_HANDLE ControllerHandle)
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 PartitionDriverBindingStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
EFI_STATUS ProbeMediaStatusEx(IN EFI_DISK_IO2_PROTOCOL *DiskIo2, IN UINT32 MediaId, IN EFI_STATUS DefaultStatus)
EFI_STATUS EFIAPI PartitionFlushBlocks(IN EFI_BLOCK_IO_PROTOCOL *This)
EFI_STATUS EFIAPI PartitionReset(IN EFI_BLOCK_IO_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
PARTITION_ACCESS_TASK * PartitionCreateAccessTask(IN EFI_BLOCK_IO2_TOKEN *Token)
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 ProbeMediaStatus(IN EFI_DISK_IO_PROTOCOL *DiskIo, IN UINT32 MediaId, IN EFI_STATUS DefaultStatus)
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)
EFI_GUID gEfiPartitionInfoProtocolGuid
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
VOID EFIAPI Exit(IN EFI_STATUS Status)
EFI_STATUS EFIAPI EfiLibInstallDriverBindingComponentName2(IN CONST EFI_HANDLE ImageHandle, IN CONST EFI_SYSTEM_TABLE *SystemTable, IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, IN EFI_HANDLE DriverBindingHandle, IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName OPTIONAL, IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 OPTIONAL)
EFI_BLOCK_IO_MEDIA * Media
EFI_BLOCK_IO_MEDIA * Media
EFI_STATUS TransactionStatus
UINT32 LogicalBlocksPerPhysicalBlock
UINT32 OptimalTransferLengthGranularity