From: Ruiyu Ni Date: Tue, 20 Aug 2013 03:14:30 +0000 (+0000) Subject: Add DiskIo2 protocol definition to MdePkg. X-Git-Tag: edk2-stable201903~12336 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=493d8e3a5e86f78ef975e18dfa5754adce9e82de Add DiskIo2 protocol definition to MdePkg. Change DiskIoDxe to produce DiskIo2 protocol when the BlockIo2 protocol is available. Change PartitionDxe to produce BlockIo2 protocol based on DiskIo2 protocol instead of BlockIo2 protocol. Signed-off-by: Ruiyu Ni Reviewed-by: Kinney Michael git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14570 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c b/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c index 0175465ade..4bd6772046 100644 --- a/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c +++ b/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c @@ -9,7 +9,7 @@ Aligned - A read of N contiguous sectors. OverRun - The last byte is not on a sector boundary. -Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -45,10 +45,15 @@ DISK_IO_PRIVATE_DATA gDiskIoPrivateDataTemplate = { DiskIoReadDisk, DiskIoWriteDisk }, - NULL + { + EFI_DISK_IO2_PROTOCOL_REVISION, + DiskIo2Cancel, + DiskIo2ReadDiskEx, + DiskIo2WriteDiskEx, + DiskIo2FlushDiskEx + } }; - /** Test to see if this driver supports ControllerHandle. @@ -92,11 +97,11 @@ DiskIoDriverBindingSupported ( // Close the I/O Abstraction(s) used to perform the supported test. // gBS->CloseProtocol ( - ControllerHandle, - &gEfiBlockIoProtocolGuid, - This->DriverBindingHandle, - ControllerHandle - ); + ControllerHandle, + &gEfiBlockIoProtocolGuid, + This->DriverBindingHandle, + ControllerHandle + ); return EFI_SUCCESS; } @@ -124,14 +129,16 @@ DiskIoDriverBindingStart ( ) { EFI_STATUS Status; - DISK_IO_PRIVATE_DATA *Private; + DISK_IO_PRIVATE_DATA *Instance; EFI_TPL OldTpl; + EFI_BLOCK_IO_MEDIA *Media; + + Instance = NULL; OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - Private = NULL; // - // Connect to the Block IO interface on ControllerHandle. + // Connect to the Block IO and Block IO2 interface on ControllerHandle. // Status = gBS->OpenProtocol ( ControllerHandle, @@ -144,39 +151,86 @@ DiskIoDriverBindingStart ( if (EFI_ERROR (Status)) { goto ErrorExit1; } + + Status = gBS->OpenProtocol ( + ControllerHandle, + &gEfiBlockIo2ProtocolGuid, + (VOID **) &gDiskIoPrivateDataTemplate.BlockIo2, + This->DriverBindingHandle, + ControllerHandle, + EFI_OPEN_PROTOCOL_BY_DRIVER + ); + if (EFI_ERROR (Status)) { + gDiskIoPrivateDataTemplate.BlockIo2 = NULL; + } // // Initialize the Disk IO device instance. // - Private = AllocateCopyPool (sizeof (DISK_IO_PRIVATE_DATA), &gDiskIoPrivateDataTemplate); - if (Private == NULL) { + Instance = AllocateCopyPool (sizeof (DISK_IO_PRIVATE_DATA), &gDiskIoPrivateDataTemplate); + if (Instance == NULL) { Status = EFI_OUT_OF_RESOURCES; goto ErrorExit; } + Media = Instance->BlockIo->Media; + + // + // The BlockSize and IoAlign of BlockIo and BlockIo2 should equal. + // + ASSERT ((Instance->BlockIo2 == NULL) || + ((Instance->BlockIo->Media->IoAlign == Instance->BlockIo2->Media->IoAlign) && + (Instance->BlockIo->Media->BlockSize == Instance->BlockIo2->Media->BlockSize) + )); + + InitializeListHead (&Instance->TaskQueue); + EfiInitializeLock (&Instance->TaskQueueLock, TPL_NOTIFY); + Instance->SharedWorkingBuffer = AllocateAlignedPages ( + EFI_SIZE_TO_PAGES (DATA_BUFFER_BLOCK_NUM * Instance->BlockIo->Media->BlockSize), + Instance->BlockIo->Media->IoAlign + ); + if (Instance->SharedWorkingBuffer == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto ErrorExit; + } + // // Install protocol interfaces for the Disk IO device. // - Status = gBS->InstallProtocolInterface ( - &ControllerHandle, - &gEfiDiskIoProtocolGuid, - EFI_NATIVE_INTERFACE, - &Private->DiskIo - ); + if (Instance->BlockIo2 != NULL) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &ControllerHandle, + &gEfiDiskIoProtocolGuid, &Instance->DiskIo, + &gEfiDiskIo2ProtocolGuid, &Instance->DiskIo2, + NULL + ); + } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &ControllerHandle, + &gEfiDiskIoProtocolGuid, &Instance->DiskIo, + NULL + ); + } ErrorExit: if (EFI_ERROR (Status)) { + if (Instance != NULL && Instance->SharedWorkingBuffer != NULL) { + FreeAlignedPages ( + Instance->SharedWorkingBuffer, + EFI_SIZE_TO_PAGES (DATA_BUFFER_BLOCK_NUM * Instance->BlockIo->Media->BlockSize) + ); + } - if (Private != NULL) { - FreePool (Private); + if (Instance != NULL) { + FreePool (Instance); } gBS->CloseProtocol ( - ControllerHandle, - &gEfiBlockIoProtocolGuid, - This->DriverBindingHandle, - ControllerHandle - ); + ControllerHandle, + &gEfiBlockIoProtocolGuid, + This->DriverBindingHandle, + ControllerHandle + ); } ErrorExit1: @@ -184,7 +238,6 @@ ErrorExit1: return Status; } - /** Stop this driver on ControllerHandle by removing Disk IO protocol and closing the Block IO protocol on ControllerHandle. @@ -210,7 +263,9 @@ DiskIoDriverBindingStop ( { EFI_STATUS Status; EFI_DISK_IO_PROTOCOL *DiskIo; - DISK_IO_PRIVATE_DATA *Private; + EFI_DISK_IO2_PROTOCOL *DiskIo2; + DISK_IO_PRIVATE_DATA *Instance; + BOOLEAN AllTaskDone; // // Get our context back. @@ -224,489 +279,947 @@ DiskIoDriverBindingStop ( EFI_OPEN_PROTOCOL_GET_PROTOCOL ); if (EFI_ERROR (Status)) { - return EFI_UNSUPPORTED; + return Status; } - - Private = DISK_IO_PRIVATE_DATA_FROM_THIS (DiskIo); - - Status = gBS->UninstallProtocolInterface ( + Status = gBS->OpenProtocol ( ControllerHandle, - &gEfiDiskIoProtocolGuid, - &Private->DiskIo + &gEfiDiskIo2ProtocolGuid, + (VOID **) &DiskIo2, + This->DriverBindingHandle, + ControllerHandle, + EFI_OPEN_PROTOCOL_GET_PROTOCOL ); + if (EFI_ERROR (Status)) { + DiskIo2 = NULL; + } + + Instance = DISK_IO_PRIVATE_DATA_FROM_DISK_IO (DiskIo); + + if (DiskIo2 != NULL) { + // + // Call BlockIo2::Reset() to terminate any in-flight non-blocking I/O requests + // + ASSERT (Instance->BlockIo2 != NULL); + Status = Instance->BlockIo2->Reset (Instance->BlockIo2, FALSE); + if (EFI_ERROR (Status)) { + return Status; + } + Status = gBS->UninstallMultipleProtocolInterfaces ( + ControllerHandle, + &gEfiDiskIoProtocolGuid, &Instance->DiskIo, + &gEfiDiskIo2ProtocolGuid, &Instance->DiskIo2, + NULL + ); + } else { + Status = gBS->UninstallMultipleProtocolInterfaces ( + ControllerHandle, + &gEfiDiskIoProtocolGuid, &Instance->DiskIo, + NULL + ); + } if (!EFI_ERROR (Status)) { + + do { + EfiAcquireLock (&Instance->TaskQueueLock); + AllTaskDone = IsListEmpty (&Instance->TaskQueue); + EfiReleaseLock (&Instance->TaskQueueLock); + } while (!AllTaskDone); + + FreeAlignedPages ( + Instance->SharedWorkingBuffer, + EFI_SIZE_TO_PAGES (DATA_BUFFER_BLOCK_NUM * Instance->BlockIo->Media->BlockSize) + ); + Status = gBS->CloseProtocol ( ControllerHandle, &gEfiBlockIoProtocolGuid, This->DriverBindingHandle, ControllerHandle ); + ASSERT_EFI_ERROR (Status); + if (DiskIo2 != NULL) { + Status = gBS->CloseProtocol ( + ControllerHandle, + &gEfiBlockIo2ProtocolGuid, + This->DriverBindingHandle, + ControllerHandle + ); + ASSERT_EFI_ERROR (Status); + } + + FreePool (Instance); } - if (!EFI_ERROR (Status)) { - FreePool (Private); + return Status; +} + + +/** + Destroy the sub task. + + @param Subtask Subtask. + + @return LIST_ENTRY * Pointer to the next link of subtask. +**/ +LIST_ENTRY * +DiskIoDestroySubtask ( + IN DISK_IO_PRIVATE_DATA *Instance, + IN DISK_IO_SUBTASK *Subtask + ) +{ + LIST_ENTRY *Link; + Link = RemoveEntryList (&Subtask->Link); + if (!Subtask->Blocking) { + if (Subtask->WorkingBuffer != NULL) { + FreeAlignedPages ( + Subtask->WorkingBuffer, + Subtask->Length < Instance->BlockIo->Media->BlockSize + ? EFI_SIZE_TO_PAGES (Instance->BlockIo->Media->BlockSize) + : EFI_SIZE_TO_PAGES (Subtask->Length) + ); + } + if (Subtask->BlockIo2Token.Event != NULL) { + gBS->CloseEvent (Subtask->BlockIo2Token.Event); + } } + FreePool (Subtask); - return Status; + return Link; } +/** + The callback for the BlockIo2 ReadBlocksEx/WriteBlocksEx. + @param Event Event whose notification function is being invoked. + @param Context The pointer to the notification function's context, + which points to the DISK_IO_SUBTASK instance. +**/ +VOID +EFIAPI +DiskIo2OnReadWriteComplete ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + DISK_IO_SUBTASK *Subtask; + DISK_IO2_TASK *Task; + EFI_STATUS TransactionStatus; + DISK_IO_PRIVATE_DATA *Instance; + + gBS->CloseEvent (Event); + + Subtask = (DISK_IO_SUBTASK *) Context; + TransactionStatus = Subtask->BlockIo2Token.TransactionStatus; + Task = Subtask->Task; + Instance = Task->Instance; + + ASSERT (Subtask->Signature == DISK_IO_SUBTASK_SIGNATURE); + ASSERT (Instance->Signature == DISK_IO_PRIVATE_DATA_SIGNATURE); + ASSERT (Task->Signature == DISK_IO2_TASK_SIGNATURE); + if (Subtask->WorkingBuffer != NULL) { + if (!EFI_ERROR (TransactionStatus) && (Task->Token != NULL) && !Subtask->Write) { + CopyMem (Subtask->Buffer, Subtask->WorkingBuffer + Subtask->Offset, Subtask->Length); + } + + // + // The WorkingBuffer of blocking subtask either points to SharedWorkingBuffer + // or will be used by non-blocking subtask which will be freed below. + // + if (!Subtask->Blocking) { + FreeAlignedPages ( + Subtask->WorkingBuffer, + Subtask->Length < Instance->BlockIo->Media->BlockSize + ? EFI_SIZE_TO_PAGES (Instance->BlockIo->Media->BlockSize) + : EFI_SIZE_TO_PAGES (Subtask->Length) + ); + } + } + RemoveEntryList (&Subtask->Link); + FreePool (Subtask); + + if (EFI_ERROR (TransactionStatus) || IsListEmpty (&Task->Subtasks)) { + if (Task->Token != NULL) { + // + // Signal error status once the subtask is failed. + // Or signal the last status once the last subtask is finished. + // + Task->Token->TransactionStatus = TransactionStatus; + gBS->SignalEvent (Task->Token->Event); + + // + // Mark token to NULL + // + Task->Token = NULL; + } + } + + if (IsListEmpty (&Task->Subtasks)) { + EfiAcquireLock (&Instance->TaskQueueLock); + RemoveEntryList (&Task->Link); + EfiReleaseLock (&Instance->TaskQueueLock); + + FreePool (Task); + } +} /** - Read BufferSize bytes from Offset into Buffer. - Reads may support reads that are not aligned on - sector boundaries. There are three cases: - UnderRun - The first byte is not on a sector boundary or the read request is - less than a sector in length. - Aligned - A read of N contiguous sectors. - OverRun - The last byte is not on a sector boundary. + Create the subtask. - @param This Protocol instance pointer. - @param MediaId Id of the media, changes every time the media is replaced. - @param Offset The starting byte offset to read from - @param BufferSize Size of Buffer - @param Buffer Buffer containing read data + @param Write TRUE: Write request; FALSE: Read request. + @param Lba The starting logical block address to read from on the device. + @param Offset The starting byte offset to read from the LBA. + @param Length The number of bytes to read from the device. + @param WorkingBuffer The aligned buffer to hold the data for reading or writing. + @param Buffer The buffer to hold the data for reading or writing. + @param Blocking TRUE: Blocking request; FALSE: Non-blocking request. - @retval EFI_SUCCESS The data was read correctly from the device. - @retval EFI_DEVICE_ERROR The device reported an error while performing the read. - @retval EFI_NO_MEDIA There is no media in the device. - @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device. - @retval EFI_INVALID_PARAMETER The read request contains device addresses that are not - valid for the device. + @return A pointer to the created subtask. +**/ +DISK_IO_SUBTASK * +DiskIoCreateSubtask ( + IN BOOLEAN Write, + IN UINT64 Lba, + IN UINT32 Offset, + IN UINTN Length, + IN VOID *WorkingBuffer, OPTIONAL + IN VOID *Buffer, + IN BOOLEAN Blocking + ) +{ + DISK_IO_SUBTASK *Subtask; + EFI_STATUS Status; + Subtask = AllocateZeroPool (sizeof (DISK_IO_SUBTASK)); + if (Subtask == NULL) { + return NULL; + } + Subtask->Signature = DISK_IO_SUBTASK_SIGNATURE; + Subtask->Write = Write; + Subtask->Lba = Lba; + Subtask->Offset = Offset; + Subtask->Length = Length; + Subtask->WorkingBuffer = WorkingBuffer; + Subtask->Buffer = Buffer; + Subtask->Blocking = Blocking; + if (!Blocking) { + Status = gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL, + TPL_NOTIFY, + DiskIo2OnReadWriteComplete, + Subtask, + &Subtask->BlockIo2Token.Event + ); + if (EFI_ERROR (Status)) { + FreePool (Subtask); + return NULL; + } + } + DEBUG (( + EFI_D_BLKIO, + " %c:Lba/Offset/Length/WorkingBuffer/Buffer = %016lx/%08x/%08x/%08x/%08x\n", + Write ? 'W': 'R', Lba, Offset, Length, WorkingBuffer, Buffer + )); + + return Subtask; +} + +/** + Create the subtask list. + + @param Instance Pointer to the DISK_IO_PRIVATE_DATA. + @param Write TRUE: Write request; FALSE: Read request. + @param Offset The starting byte offset to read from the device. + @param BufferSize The size in bytes of Buffer. The number of bytes to read from the device. + @param Buffer A pointer to the buffer for the data. + @param Blocking TRUE: Blocking request; FALSE: Non-blocking request. + @param SharedWorkingBuffer The aligned buffer to hold the data for reading or writing. + @param Subtasks The subtask list header. + + @retval TRUE The subtask list is created successfully. + @retval FALSE The subtask list is not created. **/ -EFI_STATUS -EFIAPI -DiskIoReadDisk ( - IN EFI_DISK_IO_PROTOCOL *This, - IN UINT32 MediaId, +BOOLEAN +DiskIoCreateSubtaskList ( + IN DISK_IO_PRIVATE_DATA *Instance, + IN BOOLEAN Write, IN UINT64 Offset, IN UINTN BufferSize, - OUT VOID *Buffer + IN VOID *Buffer, + IN BOOLEAN Blocking, + IN VOID *SharedWorkingBuffer, + IN OUT LIST_ENTRY *Subtasks ) { - EFI_STATUS Status; - DISK_IO_PRIVATE_DATA *Private; - EFI_BLOCK_IO_PROTOCOL *BlockIo; - EFI_BLOCK_IO_MEDIA *Media; UINT32 BlockSize; + UINT32 IoAlign; UINT64 Lba; UINT64 OverRunLba; UINT32 UnderRun; UINT32 OverRun; - BOOLEAN TransactionComplete; - UINTN WorkingBufferSize; - UINT8 *WorkingBuffer; + UINT8 *BufferPtr; UINTN Length; - UINT8 *Data; - UINT8 *PreData; - UINTN IsBufferAligned; UINTN DataBufferSize; - BOOLEAN LastRead; + DISK_IO_SUBTASK *Subtask; + VOID *WorkingBuffer; + LIST_ENTRY *Link; - Private = DISK_IO_PRIVATE_DATA_FROM_THIS (This); - - BlockIo = Private->BlockIo; - Media = BlockIo->Media; - BlockSize = Media->BlockSize; + DEBUG ((EFI_D_BLKIO, "DiskIo: Create subtasks for task: Offset/BufferSize/Buffer = %016lx/%08x/%08x\n", Offset, BufferSize, Buffer)); - if (Media->MediaId != MediaId) { - return EFI_MEDIA_CHANGED; + BlockSize = Instance->BlockIo->Media->BlockSize; + IoAlign = Instance->BlockIo->Media->IoAlign; + if (IoAlign == 0) { + IoAlign = 1; } - - WorkingBuffer = Buffer; - WorkingBufferSize = BufferSize; + + Lba = DivU64x32Remainder (Offset, BlockSize, &UnderRun); + BufferPtr = (UINT8 *) Buffer; // - // Allocate a temporary buffer for operation + // Special handling for zero BufferSize // - DataBufferSize = BlockSize * DATA_BUFFER_BLOCK_NUM; - - if (Media->IoAlign > 1) { - PreData = AllocatePool (DataBufferSize + Media->IoAlign); - Data = PreData - ((UINTN) PreData & (Media->IoAlign - 1)) + Media->IoAlign; - } else { - PreData = AllocatePool (DataBufferSize); - Data = PreData; - } - - if (PreData == NULL) { - return EFI_OUT_OF_RESOURCES; + if (BufferSize == 0) { + Subtask = DiskIoCreateSubtask (Write, Lba, UnderRun, 0, NULL, BufferPtr, Blocking); + if (Subtask == NULL) { + goto Done; + } + InsertTailList (Subtasks, &Subtask->Link); + return TRUE; } - Lba = DivU64x32Remainder (Offset, BlockSize, &UnderRun); - - Length = BlockSize - UnderRun; - TransactionComplete = FALSE; - - Status = EFI_SUCCESS; if (UnderRun != 0) { - // - // Offset starts in the middle of an Lba, so read the entire block. - // - Status = BlockIo->ReadBlocks ( - BlockIo, - MediaId, - Lba, - BlockSize, - Data - ); - - if (EFI_ERROR (Status)) { - goto Done; + Length = MIN (BlockSize - UnderRun, BufferSize); + if (Blocking) { + WorkingBuffer = SharedWorkingBuffer; + } else { + WorkingBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES (BlockSize), IoAlign); + if (WorkingBuffer == NULL) { + goto Done; + } + } + if (Write) { + // + // A half write operation can be splitted to a blocking block-read and half write operation + // This can simplify the sub task processing logic + // + Subtask = DiskIoCreateSubtask (FALSE, Lba, 0, BlockSize, NULL, WorkingBuffer, TRUE); + if (Subtask == NULL) { + goto Done; + } + InsertTailList (Subtasks, &Subtask->Link); } - if (Length > BufferSize) { - Length = BufferSize; - TransactionComplete = TRUE; + Subtask = DiskIoCreateSubtask (Write, Lba, UnderRun, Length, WorkingBuffer, BufferPtr, Blocking); + if (Subtask == NULL) { + goto Done; } + InsertTailList (Subtasks, &Subtask->Link); + + BufferPtr += Length; + Offset += Length; + BufferSize -= Length; + Lba ++; + } - CopyMem (WorkingBuffer, Data + UnderRun, Length); + OverRunLba = Lba + DivU64x32Remainder (BufferSize, BlockSize, &OverRun); + BufferSize -= OverRun; - WorkingBuffer += Length; + if (OverRun != 0) { + if (Blocking) { + WorkingBuffer = SharedWorkingBuffer; + } else { + WorkingBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES (BlockSize), IoAlign); + if (WorkingBuffer == NULL) { + goto Done; + } + } + if (Write) { + // + // A half write operation can be splitted to a blocking block-read and half write operation + // This can simplify the sub task processing logic + // + Subtask = DiskIoCreateSubtask (FALSE, OverRunLba, 0, BlockSize, NULL, WorkingBuffer, TRUE); + if (Subtask == NULL) { + goto Done; + } + InsertTailList (Subtasks, &Subtask->Link); + } - WorkingBufferSize -= Length; - if (WorkingBufferSize == 0) { + Subtask = DiskIoCreateSubtask (Write, OverRunLba, 0, OverRun, WorkingBuffer, BufferPtr, Blocking); + if (Subtask == NULL) { goto Done; } - - Lba += 1; + InsertTailList (Subtasks, &Subtask->Link); } - - OverRunLba = Lba + DivU64x32Remainder (WorkingBufferSize, BlockSize, &OverRun); - - if (!TransactionComplete && WorkingBufferSize >= BlockSize) { + + if (OverRunLba > Lba) { // // If the DiskIo maps directly to a BlockIo device do the read. // - if (OverRun != 0) { - WorkingBufferSize -= OverRun; - } - // - // Check buffer alignment - // - IsBufferAligned = (UINTN) WorkingBuffer & (UINTN) (Media->IoAlign - 1); - - if (Media->IoAlign <= 1 || IsBufferAligned == 0) { - // - // Alignment is satisfied, so read them together - // - Status = BlockIo->ReadBlocks ( - BlockIo, - MediaId, - Lba, - WorkingBufferSize, - WorkingBuffer - ); - - if (EFI_ERROR (Status)) { + if (ALIGN_POINTER (BufferPtr, IoAlign) == BufferPtr) { + Subtask = DiskIoCreateSubtask (Write, Lba, 0, BufferSize, NULL, BufferPtr, Blocking); + if (Subtask == NULL) { goto Done; } + InsertTailList (Subtasks, &Subtask->Link); - WorkingBuffer += WorkingBufferSize; + BufferPtr += BufferSize; + Offset += BufferSize; + BufferSize -= BufferSize; } else { - // - // Use the allocated buffer instead of the original buffer - // to avoid alignment issue. - // Here, the allocated buffer (8-byte align) can satisfy the alignment - // - LastRead = FALSE; - do { - if (WorkingBufferSize <= DataBufferSize) { + if (Blocking) { + // + // Use the allocated buffer instead of the original buffer + // to avoid alignment issue. + // + for (; Lba < OverRunLba; Lba += DATA_BUFFER_BLOCK_NUM) { + DataBufferSize = MIN (BufferSize, DATA_BUFFER_BLOCK_NUM * BlockSize); + + Subtask = DiskIoCreateSubtask (Write, Lba, 0, DataBufferSize, SharedWorkingBuffer, BufferPtr, Blocking); + if (Subtask == NULL) { + goto Done; + } + InsertTailList (Subtasks, &Subtask->Link); + + BufferPtr += DataBufferSize; + Offset += DataBufferSize; + BufferSize -= DataBufferSize; + } + } else { + WorkingBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES (BufferSize), IoAlign); + if (WorkingBuffer == NULL) { // - // It is the last calling to readblocks in this loop + // If there is not enough memory, downgrade to blocking access // - DataBufferSize = WorkingBufferSize; - LastRead = TRUE; - } - - Status = BlockIo->ReadBlocks ( - BlockIo, - MediaId, - Lba, - DataBufferSize, - Data - ); - if (EFI_ERROR (Status)) { - goto Done; + DEBUG ((EFI_D_VERBOSE, "DiskIo: No enough memory so downgrade to blocking access\n")); + if (!DiskIoCreateSubtaskList (Instance, Write, Offset, BufferSize, BufferPtr, TRUE, SharedWorkingBuffer, Subtasks)) { + goto Done; + } + } else { + Subtask = DiskIoCreateSubtask (Write, Lba, 0, BufferSize, WorkingBuffer, BufferPtr, Blocking); + if (Subtask == NULL) { + goto Done; + } + InsertTailList (Subtasks, &Subtask->Link); } - CopyMem (WorkingBuffer, Data, DataBufferSize); - WorkingBufferSize -= DataBufferSize; - WorkingBuffer += DataBufferSize; - Lba += DATA_BUFFER_BLOCK_NUM; - } while (!LastRead); + BufferPtr += BufferSize; + Offset += BufferSize; + BufferSize -= BufferSize; + } } } - if (!TransactionComplete && OverRun != 0) { - // - // Last read is not a complete block. - // - Status = BlockIo->ReadBlocks ( - BlockIo, - MediaId, - OverRunLba, - BlockSize, - Data - ); + ASSERT (BufferSize == 0); - if (EFI_ERROR (Status)) { - goto Done; - } - - CopyMem (WorkingBuffer, Data, OverRun); - } + return TRUE; Done: - if (PreData != NULL) { - FreePool (PreData); + // + // Remove all the subtasks. + // + for (Link = GetFirstNode (Subtasks); !IsNull (Subtasks, Link); ) { + Subtask = CR (Link, DISK_IO_SUBTASK, Link, DISK_IO_SUBTASK_SIGNATURE); + Link = DiskIoDestroySubtask (Instance, Subtask); } - - return Status; + return FALSE; } - /** - Writes BufferSize bytes from Buffer into Offset. - Writes may require a read modify write to support writes that are not - aligned on sector boundaries. There are three cases: - UnderRun - The first byte is not on a sector boundary or the write request - is less than a sector in length. Read modify write is required. - Aligned - A write of N contiguous sectors. - OverRun - The last byte is not on a sector boundary. Read modified write - required. + Terminate outstanding asynchronous requests to a device. - @param This Protocol instance pointer. - @param MediaId Id of the media, changes every time the media is replaced. - @param Offset The starting byte offset to read from - @param BufferSize Size of Buffer - @param Buffer Buffer containing read data - - @retval EFI_SUCCESS The data was written correctly to the device. - @retval EFI_WRITE_PROTECTED The device can not be written to. - @retval EFI_DEVICE_ERROR The device reported an error while performing the write. - @retval EFI_NO_MEDIA There is no media in the device. - @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device. - @retval EFI_INVALID_PARAMETER The write request contains device addresses that are not - valid for the device. + @param This Indicates a pointer to the calling context. + @retval EFI_SUCCESS All outstanding requests were successfully terminated. + @retval EFI_DEVICE_ERROR The device reported an error while performing the cancel + operation. **/ EFI_STATUS EFIAPI -DiskIoWriteDisk ( - IN EFI_DISK_IO_PROTOCOL *This, - IN UINT32 MediaId, - IN UINT64 Offset, - IN UINTN BufferSize, - IN VOID *Buffer +DiskIo2Cancel ( + IN EFI_DISK_IO2_PROTOCOL *This ) { - EFI_STATUS Status; - DISK_IO_PRIVATE_DATA *Private; - EFI_BLOCK_IO_PROTOCOL *BlockIo; - EFI_BLOCK_IO_MEDIA *Media; - UINT32 BlockSize; - UINT64 Lba; - UINT64 OverRunLba; - UINT32 UnderRun; - UINT32 OverRun; - BOOLEAN TransactionComplete; - UINTN WorkingBufferSize; - UINT8 *WorkingBuffer; - UINTN Length; - UINT8 *Data; - UINT8 *PreData; - UINTN IsBufferAligned; - UINTN DataBufferSize; - BOOLEAN LastWrite; + DISK_IO_PRIVATE_DATA *Instance; + DISK_IO2_TASK *Task; + LIST_ENTRY *Link; + + Instance = DISK_IO_PRIVATE_DATA_FROM_DISK_IO2 (This); - Private = DISK_IO_PRIVATE_DATA_FROM_THIS (This); + EfiAcquireLock (&Instance->TaskQueueLock); - BlockIo = Private->BlockIo; - Media = BlockIo->Media; - BlockSize = Media->BlockSize; + for (Link = GetFirstNode (&Instance->TaskQueue) + ; !IsNull (&Instance->TaskQueue, Link) + ; Link = GetNextNode (&Instance->TaskQueue, Link) + ) { + Task = CR (Link, DISK_IO2_TASK, Link, DISK_IO2_TASK_SIGNATURE); - if (Media->ReadOnly) { - return EFI_WRITE_PROTECTED; + if (Task->Token != NULL) { + Task->Token->TransactionStatus = EFI_ABORTED; + gBS->SignalEvent (Task->Token->Event); + // + // Set Token to NULL so that the further BlockIo2 responses will be ignored + // + Task->Token = NULL; + } } - if (Media->MediaId != MediaId) { - return EFI_MEDIA_CHANGED; - } + EfiReleaseLock (&Instance->TaskQueueLock); - DataBufferSize = BlockSize * DATA_BUFFER_BLOCK_NUM; + return EFI_SUCCESS; +} - if (Media->IoAlign > 1) { - PreData = AllocatePool (DataBufferSize + Media->IoAlign); - Data = PreData - ((UINTN) PreData & (Media->IoAlign - 1)) + Media->IoAlign; - } else { - PreData = AllocatePool (DataBufferSize); - Data = PreData; - } +/** + Common routine to access the disk. + + @param Instance Pointer to the DISK_IO_PRIVATE_DATA. + @param Write TRUE: Write operation; FALSE: Read operation. + @param MediaId ID of the medium to access. + @param Offset The starting byte offset on the logical block I/O device to access. + @param Token A pointer to the token associated with the transaction. + If this field is NULL, synchronous/blocking IO is performed. + @param BufferSize The size in bytes of Buffer. The number of bytes to read from the device. + @param Buffer A pointer to the destination buffer for the data. + The caller is responsible either having implicit or explicit ownership of the buffer. +**/ +EFI_STATUS +DiskIo2ReadWriteDisk ( + IN DISK_IO_PRIVATE_DATA *Instance, + IN BOOLEAN Write, + IN UINT32 MediaId, + IN UINT64 Offset, + IN EFI_DISK_IO2_TOKEN *Token, + IN UINTN BufferSize, + IN UINT8 *Buffer + ) +{ + EFI_STATUS Status; + EFI_BLOCK_IO_PROTOCOL *BlockIo; + EFI_BLOCK_IO2_PROTOCOL *BlockIo2; + EFI_BLOCK_IO_MEDIA *Media; + LIST_ENTRY *Link; + LIST_ENTRY Subtasks; + DISK_IO_SUBTASK *Subtask; + DISK_IO2_TASK *Task; + BOOLEAN TaskQueueEmpty; + EFI_TPL OldTpl; + BOOLEAN Blocking; + LIST_ENTRY *SubtasksPtr; + + Task = NULL; + BlockIo = Instance->BlockIo; + BlockIo2 = Instance->BlockIo2; + Media = BlockIo->Media; + Status = EFI_SUCCESS; + Blocking = ((Token == NULL) || (Token->Event == NULL)); - if (PreData == NULL) { - return EFI_OUT_OF_RESOURCES; + if (Media->MediaId != MediaId) { + return EFI_MEDIA_CHANGED; } - - WorkingBuffer = Buffer; - WorkingBufferSize = BufferSize; - - Lba = DivU64x32Remainder (Offset, BlockSize, &UnderRun); - - Length = BlockSize - UnderRun; - TransactionComplete = FALSE; - - Status = EFI_SUCCESS; - if (UnderRun != 0) { + + if (Write && Media->ReadOnly) { + return EFI_WRITE_PROTECTED; + } + + if (Blocking) { // - // Offset starts in the middle of an Lba, so do read modify write. + // Wait till pending async task is completed. // - Status = BlockIo->ReadBlocks ( - BlockIo, - MediaId, - Lba, - BlockSize, - Data - ); + do { + EfiAcquireLock (&Instance->TaskQueueLock); + TaskQueueEmpty = IsListEmpty (&Instance->TaskQueue); + EfiReleaseLock (&Instance->TaskQueueLock); + } while (!TaskQueueEmpty); - if (EFI_ERROR (Status)) { - goto Done; - } - - if (Length > BufferSize) { - Length = BufferSize; - TransactionComplete = TRUE; + SubtasksPtr = &Subtasks; + } else { + Task = AllocatePool (sizeof (DISK_IO2_TASK)); + if (Task == NULL) { + return EFI_OUT_OF_RESOURCES; } + + EfiAcquireLock (&Instance->TaskQueueLock); + InsertTailList (&Instance->TaskQueue, &Task->Link); + EfiReleaseLock (&Instance->TaskQueueLock); - CopyMem (Data + UnderRun, WorkingBuffer, Length); + Task->Signature = DISK_IO2_TASK_SIGNATURE; + Task->Instance = Instance; + Task->Token = Token; - Status = BlockIo->WriteBlocks ( - BlockIo, - MediaId, - Lba, - BlockSize, - Data - ); - if (EFI_ERROR (Status)) { - goto Done; - } + SubtasksPtr = &Task->Subtasks; + } - WorkingBuffer += Length; - WorkingBufferSize -= Length; - if (WorkingBufferSize == 0) { - goto Done; + InitializeListHead (SubtasksPtr); + if (!DiskIoCreateSubtaskList (Instance, Write, Offset, BufferSize, Buffer, Blocking, Instance->SharedWorkingBuffer, SubtasksPtr)) { + if (Task != NULL) { + FreePool (Task); } - - Lba += 1; + return EFI_OUT_OF_RESOURCES; } + ASSERT (!IsListEmpty (SubtasksPtr)); - OverRunLba = Lba + DivU64x32Remainder (WorkingBufferSize, BlockSize, &OverRun); + OldTpl = gBS->RaiseTPL (TPL_CALLBACK); + for (Link = GetFirstNode (SubtasksPtr); !IsNull (SubtasksPtr, Link); Link = GetNextNode (SubtasksPtr, Link)) { + Subtask = CR (Link, DISK_IO_SUBTASK, Link, DISK_IO_SUBTASK_SIGNATURE); - if (!TransactionComplete && WorkingBufferSize >= BlockSize) { - // - // If the DiskIo maps directly to a BlockIo device do the write. - // - if (OverRun != 0) { - WorkingBufferSize -= OverRun; + if (!Subtask->Blocking) { + Subtask->Task = Task; } - // - // Check buffer alignment - // - IsBufferAligned = (UINTN) WorkingBuffer & (UINTN) (Media->IoAlign - 1); - if (Media->IoAlign <= 1 || IsBufferAligned == 0) { + if (Subtask->Write) { // - // Alignment is satisfied, so write them together + // Write // - Status = BlockIo->WriteBlocks ( - BlockIo, - MediaId, - Lba, - WorkingBufferSize, - WorkingBuffer - ); - - if (EFI_ERROR (Status)) { - goto Done; + if (Subtask->WorkingBuffer != NULL) { + // + // A sub task before this one should be a block read operation, causing the WorkingBuffer filled with the entire one block data. + // + CopyMem (Subtask->WorkingBuffer + Subtask->Offset, Subtask->Buffer, Subtask->Length); } - WorkingBuffer += WorkingBufferSize; + if (Subtask->Blocking) { + Status = BlockIo->WriteBlocks ( + BlockIo, + MediaId, + Subtask->Lba, + Subtask->Length < Media->BlockSize ? Media->BlockSize : Subtask->Length, + (Subtask->WorkingBuffer != NULL) ? Subtask->WorkingBuffer : Subtask->Buffer + ); + } else { + Status = BlockIo2->WriteBlocksEx ( + BlockIo2, + MediaId, + Subtask->Lba, + &Subtask->BlockIo2Token, + Subtask->Length < Media->BlockSize ? Media->BlockSize : Subtask->Length, + (Subtask->WorkingBuffer != NULL) ? Subtask->WorkingBuffer : Subtask->Buffer + ); + } } else { // - // The buffer parameter is not aligned with the request - // So use the allocated instead. - // It can fit almost all the cases. + // Read // - LastWrite = FALSE; - do { - if (WorkingBufferSize <= DataBufferSize) { - // - // It is the last calling to writeblocks in this loop - // - DataBufferSize = WorkingBufferSize; - LastWrite = TRUE; - } - - CopyMem (Data, WorkingBuffer, DataBufferSize); - Status = BlockIo->WriteBlocks ( + if (Subtask->Blocking) { + Status = BlockIo->ReadBlocks ( BlockIo, MediaId, - Lba, - DataBufferSize, - Data + Subtask->Lba, + Subtask->Length < Media->BlockSize ? Media->BlockSize : Subtask->Length, + (Subtask->WorkingBuffer != NULL) ? Subtask->WorkingBuffer : Subtask->Buffer ); - if (EFI_ERROR (Status)) { - goto Done; + if (!EFI_ERROR (Status) && (Subtask->WorkingBuffer != NULL)) { + CopyMem (Subtask->Buffer, Subtask->WorkingBuffer + Subtask->Offset, Subtask->Length); } - - WorkingBufferSize -= DataBufferSize; - WorkingBuffer += DataBufferSize; - Lba += DATA_BUFFER_BLOCK_NUM; - } while (!LastWrite); + } else { + Status = BlockIo2->ReadBlocksEx ( + BlockIo2, + MediaId, + Subtask->Lba, + &Subtask->BlockIo2Token, + Subtask->Length < Media->BlockSize ? Media->BlockSize : Subtask->Length, + (Subtask->WorkingBuffer != NULL) ? Subtask->WorkingBuffer : Subtask->Buffer + ); + } + } + + if (EFI_ERROR (Status)) { + break; } } + + gBS->RaiseTPL (TPL_NOTIFY); - if (!TransactionComplete && OverRun != 0) { - // - // Last bit is not a complete block, so do a read modify write. - // - Status = BlockIo->ReadBlocks ( - BlockIo, - MediaId, - OverRunLba, - BlockSize, - Data - ); + // + // Remove all the remaining subtasks when failure. + // We shouldn't remove all the tasks because the non-blocking requests have been submitted and cannot be canceled. + // + if (EFI_ERROR (Status)) { + while (!IsNull (SubtasksPtr, Link)) { + Subtask = CR (Link, DISK_IO_SUBTASK, Link, DISK_IO_SUBTASK_SIGNATURE); + Link = DiskIoDestroySubtask (Instance, Subtask); + } + } - if (EFI_ERROR (Status)) { - goto Done; + // + // Remove all the blocking subtasks because the non-blocking callback only removes the non-blocking subtask. + // + for (Link = GetFirstNode (SubtasksPtr); !IsNull (SubtasksPtr, Link); ) { + Subtask = CR (Link, DISK_IO_SUBTASK, Link, DISK_IO_SUBTASK_SIGNATURE); + if (Subtask->Blocking) { + Link = DiskIoDestroySubtask (Instance, Subtask); + } else { + Link = GetNextNode (SubtasksPtr, Link); } + } - CopyMem (Data, WorkingBuffer, OverRun); + // + // It's possible that the callback runs before raising TPL to NOTIFY, + // so the subtasks list only contains blocking subtask. + // Remove the Task after the blocking subtasks are removed in above. + // + if (!Blocking && IsListEmpty (SubtasksPtr)) { + EfiAcquireLock (&Instance->TaskQueueLock); + RemoveEntryList (&Task->Link); + EfiReleaseLock (&Instance->TaskQueueLock); - Status = BlockIo->WriteBlocks ( - BlockIo, - MediaId, - OverRunLba, - BlockSize, - Data - ); - if (EFI_ERROR (Status)) { - goto Done; + if (Task->Token != NULL) { + // + // Task->Token should be set to NULL by the DiskIo2OnReadWriteComplete + // It it's not, that means the non-blocking request was downgraded to blocking request. + // + DEBUG ((EFI_D_VERBOSE, "DiskIo: Non-blocking request was downgraded to blocking request, signal event directly.\n")); + Task->Token->TransactionStatus = Status; + gBS->SignalEvent (Task->Token->Event); } + + FreePool (Task); } -Done: - if (PreData != NULL) { - FreePool (PreData); + gBS->RestoreTPL (OldTpl); + + return Status; +} + +/** + Reads a specified number of bytes from a device. + + @param This Indicates a pointer to the calling context. + @param MediaId ID of the medium to be read. + @param Offset The starting byte offset on the logical block I/O device to read from. + @param Token A pointer to the token associated with the transaction. + If this field is NULL, synchronous/blocking IO is performed. + @param BufferSize The size in bytes of Buffer. The number of bytes to read from the device. + @param Buffer A pointer to the destination buffer for the data. + The caller is responsible either having implicit or explicit ownership of the buffer. + + @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was read correctly from the device. + If Event is not NULL (asynchronous I/O): The request was successfully queued for processing. + Event will be signaled upon completion. + @retval EFI_DEVICE_ERROR The device reported an error while performing the write. + @retval EFI_NO_MEDIA There is no medium in the device. + @retval EFI_MEDIA_CHNAGED The MediaId is not for the current medium. + @retval EFI_INVALID_PARAMETER The read request contains device addresses that are not valid for the device. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. + +**/ +EFI_STATUS +EFIAPI +DiskIo2ReadDiskEx ( + IN EFI_DISK_IO2_PROTOCOL *This, + IN UINT32 MediaId, + IN UINT64 Offset, + IN OUT EFI_DISK_IO2_TOKEN *Token, + IN UINTN BufferSize, + OUT VOID *Buffer + ) +{ + return DiskIo2ReadWriteDisk ( + DISK_IO_PRIVATE_DATA_FROM_DISK_IO2 (This), + FALSE, MediaId, Offset, Token, BufferSize, (UINT8 *) Buffer + ); +} + +/** + Writes a specified number of bytes to a device. + + @param This Indicates a pointer to the calling context. + @param MediaId ID of the medium to be written. + @param Offset The starting byte offset on the logical block I/O device to write to. + @param Token A pointer to the token associated with the transaction. + If this field is NULL, synchronous/blocking IO is performed. + @param BufferSize The size in bytes of Buffer. The number of bytes to write to the device. + @param Buffer A pointer to the buffer containing the data to be written. + + @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was written correctly to the device. + If Event is not NULL (asynchronous I/O): The request was successfully queued for processing. + Event will be signaled upon completion. + @retval EFI_WRITE_PROTECTED The device cannot be written to. + @retval EFI_DEVICE_ERROR The device reported an error while performing the write operation. + @retval EFI_NO_MEDIA There is no medium in the device. + @retval EFI_MEDIA_CHNAGED The MediaId is not for the current medium. + @retval EFI_INVALID_PARAMETER The write request contains device addresses that are not valid for the device. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. + +**/ +EFI_STATUS +EFIAPI +DiskIo2WriteDiskEx ( + IN EFI_DISK_IO2_PROTOCOL *This, + IN UINT32 MediaId, + IN UINT64 Offset, + IN OUT EFI_DISK_IO2_TOKEN *Token, + IN UINTN BufferSize, + IN VOID *Buffer + ) +{ + return DiskIo2ReadWriteDisk ( + DISK_IO_PRIVATE_DATA_FROM_DISK_IO2 (This), + TRUE, MediaId, Offset, Token, BufferSize, (UINT8 *) Buffer + ); +} + +/** + The callback for the BlockIo2 FlushBlocksEx. + @param Event Event whose notification function is being invoked. + @param Context The pointer to the notification function's context, + which points to the DISK_IO2_FLUSH_TASK instance. +**/ +VOID +EFIAPI +DiskIo2OnFlushComplete ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + DISK_IO2_FLUSH_TASK *Task; + + gBS->CloseEvent (Event); + + Task = (DISK_IO2_FLUSH_TASK *) Context; + ASSERT (Task->Signature == DISK_IO2_FLUSH_TASK_SIGNATURE); + Task->Token->TransactionStatus = Task->BlockIo2Token.TransactionStatus; + gBS->SignalEvent (Task->Token->Event); +} + +/** + Flushes all modified data to the physical device. + + @param This Indicates a pointer to the calling context. + @param Token A pointer to the token associated with the transaction. + If this field is NULL, synchronous/blocking IO is performed. + + @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was flushed successfully to the device. + If Event is not NULL (asynchronous I/O): The request was successfully queued for processing. + Event will be signaled upon completion. + @retval EFI_WRITE_PROTECTED The device cannot be written to. + @retval EFI_DEVICE_ERROR The device reported an error while performing the write operation. + @retval EFI_NO_MEDIA There is no medium in the device. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. +**/ +EFI_STATUS +EFIAPI +DiskIo2FlushDiskEx ( + IN EFI_DISK_IO2_PROTOCOL *This, + IN OUT EFI_DISK_IO2_TOKEN *Token + ) +{ + EFI_STATUS Status; + DISK_IO2_FLUSH_TASK *Task; + DISK_IO_PRIVATE_DATA *Private; + + Private = DISK_IO_PRIVATE_DATA_FROM_DISK_IO2 (This); + + if ((Token != NULL) && (Token->Event != NULL)) { + Task = AllocatePool (sizeof (DISK_IO2_FLUSH_TASK)); + if (Task == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + Status = gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, + DiskIo2OnFlushComplete, + Task, + &Task->BlockIo2Token.Event + ); + if (EFI_ERROR (Status)) { + FreePool (Task); + return Status; + } + Task->Signature = DISK_IO2_FLUSH_TASK_SIGNATURE; + Status = Private->BlockIo2->FlushBlocksEx (Private->BlockIo2, &Task->BlockIo2Token); + if (EFI_ERROR (Status)) { + gBS->CloseEvent (Task->BlockIo2Token.Event); + FreePool (Task); + } + } else { + Status = Private->BlockIo2->FlushBlocksEx (Private->BlockIo2, NULL); } return Status; } +/** + Read BufferSize bytes from Offset into Buffer. + Reads may support reads that are not aligned on + sector boundaries. There are three cases: + UnderRun - The first byte is not on a sector boundary or the read request is + less than a sector in length. + Aligned - A read of N contiguous sectors. + OverRun - The last byte is not on a sector boundary. + + @param This Protocol instance pointer. + @param MediaId Id of the media, changes every time the media is replaced. + @param Offset The starting byte offset to read from + @param BufferSize Size of Buffer + @param Buffer Buffer containing read data + + @retval EFI_SUCCESS The data was read correctly from the device. + @retval EFI_DEVICE_ERROR The device reported an error while performing the read. + @retval EFI_NO_MEDIA There is no media in the device. + @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device. + @retval EFI_INVALID_PARAMETER The read request contains device addresses that are not + valid for the device. + +**/ +EFI_STATUS +EFIAPI +DiskIoReadDisk ( + IN EFI_DISK_IO_PROTOCOL *This, + IN UINT32 MediaId, + IN UINT64 Offset, + IN UINTN BufferSize, + OUT VOID *Buffer + ) +{ + return DiskIo2ReadWriteDisk ( + DISK_IO_PRIVATE_DATA_FROM_DISK_IO (This), + FALSE, MediaId, Offset, NULL, BufferSize, (UINT8 *) Buffer + ); +} + + +/** + Writes BufferSize bytes from Buffer into Offset. + Writes may require a read modify write to support writes that are not + aligned on sector boundaries. There are three cases: + UnderRun - The first byte is not on a sector boundary or the write request + is less than a sector in length. Read modify write is required. + Aligned - A write of N contiguous sectors. + OverRun - The last byte is not on a sector boundary. Read modified write + required. + + @param This Protocol instance pointer. + @param MediaId Id of the media, changes every time the media is replaced. + @param Offset The starting byte offset to read from + @param BufferSize Size of Buffer + @param Buffer Buffer containing read data + + @retval EFI_SUCCESS The data was written correctly to the device. + @retval EFI_WRITE_PROTECTED The device can not be written to. + @retval EFI_DEVICE_ERROR The device reported an error while performing the write. + @retval EFI_NO_MEDIA There is no media in the device. + @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device. + @retval EFI_INVALID_PARAMETER The write request contains device addresses that are not + valid for the device. + +**/ +EFI_STATUS +EFIAPI +DiskIoWriteDisk ( + IN EFI_DISK_IO_PROTOCOL *This, + IN UINT32 MediaId, + IN UINT64 Offset, + IN UINTN BufferSize, + IN VOID *Buffer + ) +{ + return DiskIo2ReadWriteDisk ( + DISK_IO_PRIVATE_DATA_FROM_DISK_IO (This), + TRUE, MediaId, Offset, NULL, BufferSize, (UINT8 *) Buffer + ); +} /** The user Entry Point for module DiskIo. The user code starts with this function. @@ -740,7 +1253,5 @@ InitializeDiskIo ( ); ASSERT_EFI_ERROR (Status); - return Status; } - diff --git a/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.h b/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.h index 77f6dbf89d..a08d4df799 100644 --- a/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.h +++ b/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.h @@ -1,7 +1,7 @@ /** @file Master header file for DiskIo driver. It includes the module private defininitions. -Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -17,6 +17,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include +#include +#include #include #include #include @@ -28,18 +30,69 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include - +// +// Pre-allocate an aligned buffer of 64 blocks so very large Disk I/O requests +// will be broken up into 64 * BlockSize chunks to provide better performance +// than allocating an aligned 1 block buffer. +// #define DATA_BUFFER_BLOCK_NUM 64 #define DISK_IO_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('d', 's', 'k', 'I') - typedef struct { - UINTN Signature; - EFI_DISK_IO_PROTOCOL DiskIo; - EFI_BLOCK_IO_PROTOCOL *BlockIo; + UINT32 Signature; + + EFI_DISK_IO_PROTOCOL DiskIo; + EFI_DISK_IO2_PROTOCOL DiskIo2; + EFI_BLOCK_IO_PROTOCOL *BlockIo; + EFI_BLOCK_IO2_PROTOCOL *BlockIo2; + + UINT8 *SharedWorkingBuffer; + + EFI_LOCK TaskQueueLock; + LIST_ENTRY TaskQueue; } DISK_IO_PRIVATE_DATA; +#define DISK_IO_PRIVATE_DATA_FROM_DISK_IO(a) CR (a, DISK_IO_PRIVATE_DATA, DiskIo, DISK_IO_PRIVATE_DATA_SIGNATURE) +#define DISK_IO_PRIVATE_DATA_FROM_DISK_IO2(a) CR (a, DISK_IO_PRIVATE_DATA, DiskIo2, DISK_IO_PRIVATE_DATA_SIGNATURE) -#define DISK_IO_PRIVATE_DATA_FROM_THIS(a) CR (a, DISK_IO_PRIVATE_DATA, DiskIo, DISK_IO_PRIVATE_DATA_SIGNATURE) +#define DISK_IO2_TASK_SIGNATURE SIGNATURE_32 ('d', 'i', 'a', 't') +typedef struct { + UINT32 Signature; + LIST_ENTRY Link; /// < link to other task + LIST_ENTRY Subtasks; /// < header of subtasks + EFI_DISK_IO2_TOKEN *Token; + DISK_IO_PRIVATE_DATA *Instance; +} DISK_IO2_TASK; + +#define DISK_IO2_FLUSH_TASK_SIGNATURE SIGNATURE_32 ('d', 'i', 'f', 't') +typedef struct { + UINT32 Signature; + EFI_BLOCK_IO2_TOKEN BlockIo2Token; + EFI_DISK_IO2_TOKEN *Token; +} DISK_IO2_FLUSH_TASK; + +#define DISK_IO_SUBTASK_SIGNATURE SIGNATURE_32 ('d', 'i', 's', 't') +typedef struct { + // + // UnderRun: Offset != 0, Length < BlockSize + // OverRun: Offset == 0, Length < BlockSize + // Middle: Offset is block aligned, Length is multiple of block size + // + UINT32 Signature; + LIST_ENTRY Link; + BOOLEAN Write; + UINT64 Lba; + UINT32 Offset; + UINTN Length; + UINT8 *WorkingBuffer; /// < NULL indicates using "Buffer" directly + UINT8 *Buffer; + BOOLEAN Blocking; + + // + // Following fields are for DiskIo2 + // + DISK_IO2_TASK *Task; + EFI_BLOCK_IO2_TOKEN BlockIo2Token; +} DISK_IO_SUBTASK; // // Global Variables @@ -189,6 +242,110 @@ DiskIoWriteDisk ( IN VOID *Buffer ); + +/** + Terminate outstanding asynchronous requests to a device. + + @param This Indicates a pointer to the calling context. + + @retval EFI_SUCCESS All outstanding requests were successfully terminated. + @retval EFI_DEVICE_ERROR The device reported an error while performing the cancel + operation. +**/ +EFI_STATUS +EFIAPI +DiskIo2Cancel ( + IN EFI_DISK_IO2_PROTOCOL *This + ); + +/** + Reads a specified number of bytes from a device. + + @param This Indicates a pointer to the calling context. + @param MediaId ID of the medium to be read. + @param Offset The starting byte offset on the logical block I/O device to read from. + @param Token A pointer to the token associated with the transaction. + If this field is NULL, synchronous/blocking IO is performed. + @param BufferSize The size in bytes of Buffer. The number of bytes to read from the device. + @param Buffer A pointer to the destination buffer for the data. + The caller is responsible either having implicit or explicit ownership of the buffer. + + @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was read correctly from the device. + If Event is not NULL (asynchronous I/O): The request was successfully queued for processing. + Event will be signaled upon completion. + @retval EFI_DEVICE_ERROR The device reported an error while performing the write. + @retval EFI_NO_MEDIA There is no medium in the device. + @retval EFI_MEDIA_CHNAGED The MediaId is not for the current medium. + @retval EFI_INVALID_PARAMETER The read request contains device addresses that are not valid for the device. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. + +**/ +EFI_STATUS +EFIAPI +DiskIo2ReadDiskEx ( + IN EFI_DISK_IO2_PROTOCOL *This, + IN UINT32 MediaId, + IN UINT64 Offset, + IN OUT EFI_DISK_IO2_TOKEN *Token, + IN UINTN BufferSize, + OUT VOID *Buffer + ); + +/** + Writes a specified number of bytes to a device. + + @param This Indicates a pointer to the calling context. + @param MediaId ID of the medium to be written. + @param Offset The starting byte offset on the logical block I/O device to write to. + @param Token A pointer to the token associated with the transaction. + If this field is NULL, synchronous/blocking IO is performed. + @param BufferSize The size in bytes of Buffer. The number of bytes to write to the device. + @param Buffer A pointer to the buffer containing the data to be written. + + @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was written correctly to the device. + If Event is not NULL (asynchronous I/O): The request was successfully queued for processing. + Event will be signaled upon completion. + @retval EFI_WRITE_PROTECTED The device cannot be written to. + @retval EFI_DEVICE_ERROR The device reported an error while performing the write operation. + @retval EFI_NO_MEDIA There is no medium in the device. + @retval EFI_MEDIA_CHNAGED The MediaId is not for the current medium. + @retval EFI_INVALID_PARAMETER The write request contains device addresses that are not valid for the device. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. + +**/ +EFI_STATUS +EFIAPI +DiskIo2WriteDiskEx ( + IN EFI_DISK_IO2_PROTOCOL *This, + IN UINT32 MediaId, + IN UINT64 Offset, + IN EFI_DISK_IO2_TOKEN *Token, + IN UINTN BufferSize, + IN VOID *Buffer + ); + +/** + Flushes all modified data to the physical device. + + @param This Indicates a pointer to the calling context. + @param Token A pointer to the token associated with the transaction. + If this field is NULL, synchronous/blocking IO is performed. + + @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was flushed successfully to the device. + If Event is not NULL (asynchronous I/O): The request was successfully queued for processing. + Event will be signaled upon completion. + @retval EFI_WRITE_PROTECTED The device cannot be written to. + @retval EFI_DEVICE_ERROR The device reported an error while performing the write operation. + @retval EFI_NO_MEDIA There is no medium in the device. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. +**/ +EFI_STATUS +EFIAPI +DiskIo2FlushDiskEx ( + IN EFI_DISK_IO2_PROTOCOL *This, + IN OUT EFI_DISK_IO2_TOKEN *Token + ); + // // EFI Component Name Functions // diff --git a/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf b/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf index 1a270e7f98..8cf2595dfa 100644 --- a/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf +++ b/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf @@ -8,7 +8,7 @@ # already have a Disk I/O protocol. File systems and other disk access # code utilize the Disk I/O protocol. # -# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+# Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
# This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License # which accompanies this distribution. The full text of the license may be found at @@ -59,5 +59,7 @@ [Protocols] gEfiDiskIoProtocolGuid ## BY_START + gEfiDiskIo2ProtocolGuid ## BY_START gEfiBlockIoProtocolGuid ## TO_START + gEfiBlockIo2ProtocolGuid ## TO_START diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c b/MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c index 13b94c307f..3d7cf2dc6c 100644 --- a/MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c @@ -1,7 +1,7 @@ /** @file Decode an El Torito formatted CD-ROM -Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -22,6 +22,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. @param[in] This Calling context. @param[in] Handle Parent Handle. @param[in] DiskIo Parent DiskIo interface. + @param[in] DiskIo2 Parent DiskIo2 interface. @param[in] BlockIo Parent BlockIo interface. @param[in] BlockIo2 Parent BlockIo2 interface. @param[in] DevicePath Parent Device Path @@ -37,6 +38,7 @@ PartitionInstallElToritoChildHandles ( 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 @@ -258,6 +260,7 @@ PartitionInstallElToritoChildHandles ( This, Handle, DiskIo, + DiskIo2, BlockIo, BlockIo2, DevicePath, diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Gpt.c b/MdeModulePkg/Universal/Disk/PartitionDxe/Gpt.c index 0778588298..35860515c1 100644 --- a/MdeModulePkg/Universal/Disk/PartitionDxe/Gpt.c +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Gpt.c @@ -184,6 +184,7 @@ PartitionSetCrc ( @param[in] This Calling context. @param[in] Handle Parent Handle. @param[in] DiskIo Parent DiskIo interface. + @param[in] DiskIo2 Parent DiskIo2 interface. @param[in] BlockIo Parent BlockIo interface. @param[in] BlockIo2 Parent BlockIo2 interface. @param[in] DevicePath Parent Device Path. @@ -198,6 +199,7 @@ 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 @@ -400,6 +402,7 @@ PartitionInstallGptChildHandles ( This, Handle, DiskIo, + DiskIo2, BlockIo, BlockIo2, DevicePath, diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c b/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c index 4c64663746..a35b4f2d0d 100644 --- a/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c @@ -11,7 +11,7 @@ always on the first sector of a media. The first sector also contains the legacy boot strap code. -Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -104,6 +104,7 @@ PartitionValidMbr ( @param[in] This Calling context. @param[in] Handle Parent Handle. @param[in] DiskIo Parent DiskIo interface. + @param[in] DiskIo2 Parent DiskIo2 interface. @param[in] BlockIo Parent BlockIo interface. @param[in] BlockIo2 Parent BlockIo2 interface. @param[in] DevicePath Parent Device Path. @@ -118,6 +119,7 @@ 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 @@ -226,6 +228,7 @@ PartitionInstallMbrChildHandles ( This, Handle, DiskIo, + DiskIo2, BlockIo, BlockIo2, DevicePath, @@ -287,6 +290,7 @@ PartitionInstallMbrChildHandles ( This, Handle, DiskIo, + DiskIo2, BlockIo, BlockIo2, DevicePath, diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c index 318bfe4326..5cc1397e7c 100644 --- a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c @@ -4,7 +4,7 @@ of the raw block devices media. Currently "El Torito CD-ROM", Legacy MBR, and GPT partition schemes are supported. -Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -200,6 +200,7 @@ PartitionDriverBindingStart ( EFI_BLOCK_IO_PROTOCOL *BlockIo; EFI_BLOCK_IO2_PROTOCOL *BlockIo2; EFI_DISK_IO_PROTOCOL *DiskIo; + EFI_DISK_IO2_PROTOCOL *DiskIo2; EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath; PARTITION_DETECT_ROUTINE *Routine; BOOLEAN MediaPresent; @@ -243,8 +244,11 @@ PartitionDriverBindingStart ( (VOID **) &BlockIo2, This->DriverBindingHandle, ControllerHandle, - EFI_OPEN_PROTOCOL_BY_DRIVER + EFI_OPEN_PROTOCOL_GET_PROTOCOL ); + if (EFI_ERROR (Status)) { + BlockIo2 = NULL; + } // // Get the Device Path Protocol on ControllerHandle's handle. @@ -261,6 +265,9 @@ PartitionDriverBindingStart ( goto Exit; } + // + // Get the DiskIo and DiskIo2. + // Status = gBS->OpenProtocol ( ControllerHandle, &gEfiDiskIoProtocolGuid, @@ -281,6 +288,18 @@ PartitionDriverBindingStart ( OpenStatus = Status; + Status = gBS->OpenProtocol ( + ControllerHandle, + &gEfiDiskIo2ProtocolGuid, + (VOID **) &DiskIo2, + This->DriverBindingHandle, + ControllerHandle, + EFI_OPEN_PROTOCOL_BY_DRIVER + ); + if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) { + DiskIo2 = NULL; + } + // // Try to read blocks when there's media or it is removable physical partition. // @@ -299,6 +318,7 @@ PartitionDriverBindingStart ( This, ControllerHandle, DiskIo, + DiskIo2, BlockIo, BlockIo2, ParentDevicePath @@ -404,7 +424,7 @@ PartitionDriverBindingStop ( // gBS->CloseProtocol ( ControllerHandle, - &gEfiBlockIo2ProtocolGuid, + &gEfiDiskIo2ProtocolGuid, This->DriverBindingHandle, ControllerHandle ); @@ -699,7 +719,7 @@ PartitionFlushBlocks ( Probe the media status and return EFI_NO_MEDIA or EFI_MEDIA_CHANGED for no media or media change case. Otherwise DefaultStatus is returned. - @param BlockIo2 Pointer to the BlockIo2 instance. + @param DiskIo2 Pointer to the DiskIo2 instance. @param MediaId Id of the media, changes every time the media is replaced. @param DefaultStatus The default status to return when it's not the no media or media change case. @@ -710,7 +730,7 @@ PartitionFlushBlocks ( **/ EFI_STATUS ProbeMediaStatusEx ( - IN EFI_BLOCK_IO2_PROTOCOL *BlockIo2, + IN EFI_DISK_IO2_PROTOCOL *DiskIo2, IN UINT32 MediaId, IN EFI_STATUS DefaultStatus ) @@ -718,16 +738,9 @@ ProbeMediaStatusEx ( EFI_STATUS Status; // - // Read from LBA 0 but passing NULL as buffer pointer to detect the media status. + // Read 1 byte from offset 0 but passing NULL as buffer pointer // - Status = BlockIo2->ReadBlocksEx ( - BlockIo2, - MediaId, - 0, - NULL, - 0, - NULL - ); + Status = DiskIo2->ReadDiskEx (DiskIo2, MediaId, 0, NULL, 1, NULL); if ((Status == EFI_NO_MEDIA) || (Status == EFI_MEDIA_CHANGED)) { return Status; } @@ -762,6 +775,68 @@ PartitionResetEx ( ); } +/** + The general callback for the DiskIo2 interfaces. + @param Event Event whose notification function is being invoked. + @param Context The pointer to the notification function's context, + which points to the PARTITION_ACCESS_TASK instance. +**/ +VOID +EFIAPI +PartitionOnAccessComplete ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + PARTITION_ACCESS_TASK *Task; + + Task = (PARTITION_ACCESS_TASK *) Context; + + gBS->CloseEvent (Event); + + Task->BlockIo2Token->TransactionStatus = Task->DiskIo2Token.TransactionStatus; + gBS->SignalEvent (Task->BlockIo2Token->Event); + + FreePool (Task); +} + +/** + Create a new PARTITION_ACCESS_TASK instance. + + @param Token Pointer to the EFI_BLOCK_IO2_TOKEN. + + @return Pointer to the created PARTITION_ACCESS_TASK instance or NULL upon failure. +**/ +PARTITION_ACCESS_TASK * +PartitionCreateAccessTask ( + IN EFI_BLOCK_IO2_TOKEN *Token + ) +{ + EFI_STATUS Status; + PARTITION_ACCESS_TASK *Task; + + Task = AllocatePool (sizeof (*Task)); + if (Task == NULL) { + return NULL; + } + + Status = gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, + PartitionOnAccessComplete, + Task, + &Task->DiskIo2Token.Event + ); + if (EFI_ERROR (Status)) { + FreePool (Task); + return NULL; + } + + Task->BlockIo2Token = Token; + + return Task; +} + /** Read BufferSize bytes from Lba into Buffer. @@ -806,44 +881,38 @@ PartitionReadBlocksEx ( OUT VOID *Buffer ) { + EFI_STATUS Status; PARTITION_PRIVATE_DATA *Private; UINT64 Offset; - UINT32 UnderRun; + PARTITION_ACCESS_TASK *Task; Private = PARTITION_DEVICE_FROM_BLOCK_IO2_THIS (This); - if (Token == NULL) { - return ProbeMediaStatusEx (Private->ParentBlockIo2, MediaId, EFI_INVALID_PARAMETER); - } - if (BufferSize % Private->BlockSize != 0) { - return ProbeMediaStatusEx (Private->ParentBlockIo2, MediaId, EFI_BAD_BUFFER_SIZE); + return ProbeMediaStatusEx (Private->DiskIo2, MediaId, EFI_BAD_BUFFER_SIZE); } Offset = MultU64x32 (Lba, Private->BlockSize) + Private->Start; if (Offset + BufferSize > Private->End) { - return ProbeMediaStatusEx (Private->ParentBlockIo2, MediaId, EFI_INVALID_PARAMETER); + return ProbeMediaStatusEx (Private->DiskIo2, MediaId, EFI_INVALID_PARAMETER); } - // - // Since the BlockIO2 call Parent BlockIO2 directly, so here the offset must - // be multiple of BlockSize. If the Spec will be updated the DiskIO to support - // BlockIO2, this limitation will be removed and call DiskIO here. - // - Lba = DivU64x32Remainder (Offset, Private->BlockSize, &UnderRun); - if (UnderRun != 0) { - return ProbeMediaStatusEx (Private->ParentBlockIo2, MediaId, EFI_UNSUPPORTED); - } + if ((Token != NULL) && (Token->Event != NULL)) { + Task = PartitionCreateAccessTask (Token); + if (Task == NULL) { + return EFI_OUT_OF_RESOURCES; + } - // - // Because some partitions have different block size from their parent - // device, in that case the Block I/O2 couldn't be called. - // - if (Private->BlockSize != Private->ParentBlockIo->Media->BlockSize) { - return ProbeMediaStatusEx (Private->ParentBlockIo2, MediaId, EFI_UNSUPPORTED); + Status = Private->DiskIo2->ReadDiskEx (Private->DiskIo2, MediaId, Offset, &Task->DiskIo2Token, BufferSize, Buffer); + if (EFI_ERROR (Status)) { + gBS->CloseEvent (Task->DiskIo2Token.Event); + FreePool (Task); + } + } else { + Status = Private->DiskIo2->ReadDiskEx (Private->DiskIo2, MediaId, Offset, NULL, BufferSize, Buffer); } - return Private->ParentBlockIo2->ReadBlocksEx (Private->ParentBlockIo2, MediaId, Lba, Token, BufferSize, Buffer); + return Status; } /** @@ -888,44 +957,37 @@ PartitionWriteBlocksEx ( IN VOID *Buffer ) { + EFI_STATUS Status; PARTITION_PRIVATE_DATA *Private; UINT64 Offset; - UINT32 UnderRun; + PARTITION_ACCESS_TASK *Task; Private = PARTITION_DEVICE_FROM_BLOCK_IO2_THIS (This); - if (Token == NULL) { - return ProbeMediaStatusEx (Private->ParentBlockIo2, MediaId, EFI_INVALID_PARAMETER); - } - if (BufferSize % Private->BlockSize != 0) { - return ProbeMediaStatusEx (Private->ParentBlockIo2, MediaId, EFI_BAD_BUFFER_SIZE); + return ProbeMediaStatusEx (Private->DiskIo2, MediaId, EFI_BAD_BUFFER_SIZE); } Offset = MultU64x32 (Lba, Private->BlockSize) + Private->Start; if (Offset + BufferSize > Private->End) { - return ProbeMediaStatusEx (Private->ParentBlockIo2, MediaId, EFI_INVALID_PARAMETER); - } - - // - // Since the BlockIO2 call Parent BlockIO2 directly, so here the offset must - // be multiple of BlockSize. If the Spec will be updated the DiskIO to support - // BlockIO2, this limitation will be removed and call DiskIO here. - // - Lba = DivU64x32Remainder (Offset, Private->BlockSize, &UnderRun); - if (UnderRun != 0) { - return ProbeMediaStatusEx (Private->ParentBlockIo2, MediaId, EFI_UNSUPPORTED); + return ProbeMediaStatusEx (Private->DiskIo2, MediaId, EFI_INVALID_PARAMETER); } + + if ((Token != NULL) && (Token->Event != NULL)) { + Task = PartitionCreateAccessTask (Token); + if (Task == NULL) { + return EFI_OUT_OF_RESOURCES; + } - // - // Because some kinds of partition have different block size from their parent, - // in that case it couldn't call parent Block I/O2. - // - if (Private->BlockSize != Private->ParentBlockIo->Media->BlockSize) { - return ProbeMediaStatusEx (Private->ParentBlockIo2, MediaId, EFI_UNSUPPORTED); + Status = Private->DiskIo2->WriteDiskEx (Private->DiskIo2, MediaId, Offset, &Task->DiskIo2Token, BufferSize, Buffer); + if (EFI_ERROR (Status)) { + gBS->CloseEvent (Task->DiskIo2Token.Event); + FreePool (Task); + } + } else { + Status = Private->DiskIo2->WriteDiskEx (Private->DiskIo2, MediaId, Offset, NULL, BufferSize, Buffer); } - - return Private->ParentBlockIo2->WriteBlocksEx (Private->ParentBlockIo2, MediaId, Lba, Token, BufferSize, Buffer); + return Status; } /** @@ -957,19 +1019,27 @@ PartitionFlushBlocksEx ( IN OUT EFI_BLOCK_IO2_TOKEN *Token ) { + EFI_STATUS Status; PARTITION_PRIVATE_DATA *Private; + PARTITION_ACCESS_TASK *Task; Private = PARTITION_DEVICE_FROM_BLOCK_IO2_THIS (This); - // - // Because some kinds of partition have different block size from their parent, - // in that case it couldn't call parent Block I/O2. - // - if (Private->BlockSize != Private->ParentBlockIo->Media->BlockSize) { - return EFI_UNSUPPORTED; - } + if ((Token != NULL) && (Token->Event != NULL)) { + Task = PartitionCreateAccessTask (Token); + if (Task == NULL) { + return EFI_OUT_OF_RESOURCES; + } - return Private->ParentBlockIo2->FlushBlocksEx (Private->ParentBlockIo2, Token); + Status = Private->DiskIo2->FlushDiskEx (Private->DiskIo2, &Task->DiskIo2Token); + if (EFI_ERROR (Status)) { + gBS->CloseEvent (Task->DiskIo2Token.Event); + FreePool (Task); + } + } else { + Status = Private->DiskIo2->FlushDiskEx (Private->DiskIo2, NULL); + } + return Status; } @@ -980,6 +1050,7 @@ PartitionFlushBlocksEx ( @param[in] This Protocol instance pointer. @param[in] ParentHandle Parent Handle for new child. @param[in] ParentDiskIo Parent DiskIo interface. + @param[in] ParentDiskIo2 Parent DiskIo2 interface. @param[in] ParentBlockIo Parent BlockIo interface. @param[in] ParentBlockIo2 Parent BlockIo2 interface. @param[in] ParentDevicePath Parent Device Path. @@ -998,6 +1069,7 @@ 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, @@ -1026,6 +1098,7 @@ PartitionInstallChildHandle ( Private->ParentBlockIo = ParentBlockIo; Private->ParentBlockIo2 = ParentBlockIo2; Private->DiskIo = ParentDiskIo; + Private->DiskIo2 = ParentDiskIo2; // // Set the BlockIO into Private Data. @@ -1043,7 +1116,8 @@ PartitionInstallChildHandle ( // // Set the BlockIO2 into Private Data. // - if (Private->ParentBlockIo2 != NULL) { + if (Private->DiskIo2 != NULL) { + ASSERT (Private->ParentBlockIo2 != NULL); Private->BlockIo2.Media = &Private->Media2; CopyMem (Private->BlockIo2.Media, ParentBlockIo2->Media, sizeof (EFI_BLOCK_IO_MEDIA)); @@ -1065,9 +1139,7 @@ PartitionInstallChildHandle ( Private->Media.BlockSize = (UINT32) BlockSize; - // - // For BlockIO2, it should keep the same alignment with the parent BlockIO2's. - // + Private->Media2.IoAlign = 0; Private->Media2.LogicalPartition = TRUE; Private->Media2.LastBlock = Private->Media.LastBlock; Private->Media2.BlockSize = (UINT32) BlockSize; @@ -1105,17 +1177,9 @@ PartitionInstallChildHandle ( // // Create the new handle. - // BlockIO2 will be installed on the condition that the blocksize of parent BlockIO - // is same with the child BlockIO's. Instead of calling the DiskIO, the child BlockIO2 - // directly call the parent BlockIO and doesn't handle the different block size issue. - // If SPEC will update the DiskIO to support the Non-Blocking model, the BlockIO2 will call - // DiskIO to handle the blocksize unequal issue and the limitation will be remove from - // here. // Private->Handle = NULL; - if ((Private->ParentBlockIo2 != NULL) && - (Private->ParentBlockIo2->Media->BlockSize == BlockSize) - ) { + if (Private->DiskIo2 != NULL) { Status = gBS->InstallMultipleProtocolInterfaces ( &Private->Handle, &gEfiDevicePathProtocolGuid, diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h index 7a4ca8a319..06470f689f 100644 --- a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h @@ -26,6 +26,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include +#include #include #include #include @@ -54,6 +55,7 @@ typedef struct { EFI_BLOCK_IO_MEDIA Media2;//For BlockIO2 EFI_DISK_IO_PROTOCOL *DiskIo; + EFI_DISK_IO2_PROTOCOL *DiskIo2; EFI_BLOCK_IO_PROTOCOL *ParentBlockIo; EFI_BLOCK_IO2_PROTOCOL *ParentBlockIo2; UINT64 Start; @@ -64,6 +66,11 @@ typedef struct { } PARTITION_PRIVATE_DATA; +typedef struct { + EFI_DISK_IO2_TOKEN DiskIo2Token; + EFI_BLOCK_IO2_TOKEN *BlockIo2Token; +} PARTITION_ACCESS_TASK; + #define PARTITION_DEVICE_FROM_BLOCK_IO_THIS(a) CR (a, PARTITION_PRIVATE_DATA, BlockIo, PARTITION_PRIVATE_DATA_SIGNATURE) #define PARTITION_DEVICE_FROM_BLOCK_IO2_THIS(a) CR (a, PARTITION_PRIVATE_DATA, BlockIo2, PARTITION_PRIVATE_DATA_SIGNATURE) @@ -308,6 +315,7 @@ PartitionComponentNameGetControllerName ( @param[in] This Protocol instance pointer. @param[in] ParentHandle Parent Handle for new child. @param[in] ParentDiskIo Parent DiskIo interface. + @param[in] ParentDiskIo2 Parent DiskIo2 interface. @param[in] ParentBlockIo Parent BlockIo interface. @param[in] ParentBlockIo2 Parent BlockIo2 interface. @param[in] ParentDevicePath Parent Device Path. @@ -326,6 +334,7 @@ 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, @@ -342,6 +351,7 @@ PartitionInstallChildHandle ( @param[in] This Calling context. @param[in] Handle Parent Handle. @param[in] DiskIo Parent DiskIo interface. + @param[in] DiskIo2 Parent DiskIo2 interface. @param[in] BlockIo Parent BlockIo interface. @param[in] BlockIo2 Parent BlockIo2 interface. @param[in] DevicePath Parent Device Path. @@ -357,6 +367,7 @@ 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 @@ -368,6 +379,7 @@ PartitionInstallGptChildHandles ( @param[in] This Calling context. @param[in] Handle Parent Handle. @param[in] DiskIo Parent DiskIo interface. + @param[in] DiskIo2 Parent DiskIo2 interface. @param[in] BlockIo Parent BlockIo interface. @param[in] BlockIo2 Parent BlockIo2 interface. @param[in] DevicePath Parent Device Path @@ -383,6 +395,7 @@ PartitionInstallElToritoChildHandles ( 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 @@ -394,6 +407,7 @@ PartitionInstallElToritoChildHandles ( @param[in] This Calling context. @param[in] Handle Parent Handle. @param[in] DiskIo Parent DiskIo interface. + @param[in] DiskIo2 Parent DiskIo2 interface. @param[in] BlockIo Parent BlockIo interface. @param[in] BlockIo2 Parent BlockIo2 interface. @param[in] DevicePath Parent Device Path. @@ -408,6 +422,7 @@ 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 @@ -419,6 +434,7 @@ EFI_STATUS 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 diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf b/MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf index aac20a13b1..089918f5a9 100644 --- a/MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf @@ -12,7 +12,7 @@ # This external input must be validated carefully to avoid security issue like # buffer overflow, integer overflow. # -# Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
+# Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
# This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License # which accompanies this distribution. The full text of the license may be found at @@ -74,7 +74,9 @@ gEfiBlockIoProtocolGuid ## BY_START gEfiDevicePathProtocolGuid ## BY_START gEfiDiskIoProtocolGuid ## BY_START + gEfiDiskIo2ProtocolGuid ## BY_START gEfiBlockIoProtocolGuid ## TO_START gEfiBlockIo2ProtocolGuid ## TO_START gEfiDevicePathProtocolGuid ## TO_START gEfiDiskIoProtocolGuid ## TO_START + gEfiDiskIo2ProtocolGuid ## TO_START diff --git a/MdePkg/Include/Protocol/DiskIo2.h b/MdePkg/Include/Protocol/DiskIo2.h new file mode 100644 index 0000000000..a6badf231a --- /dev/null +++ b/MdePkg/Include/Protocol/DiskIo2.h @@ -0,0 +1,173 @@ +/** @file + Disk IO protocol as defined in the UEFI 2.0 specification. + + The Disk IO2 protocol is used to convert block oriented devices into byte + oriented devices. The Disk IO protocol is intended to layer on top of the + Block IO protocol. + + Copyright (c) 2013, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __DISK_IO2_H__ +#define __DISK_IO2_H__ + +#define EFI_DISK_IO2_PROTOCOL_GUID \ + { \ + 0x151c8eae, 0x7f2c, 0x472c, 0x9e, 0x54, 0x98, 0x28, 0x19, 0x4f, 0x6a, 0x88 \ + } + +typedef struct _EFI_DISK_IO2_PROTOCOL EFI_DISK_IO2_PROTOCOL; + +/** + The struct of Disk IO2 Token. +**/ +typedef struct { + // + // If Event is NULL, then blocking I/O is performed. + // If Event is not NULL and non-blocking I/O is supported, then non-blocking I/O is performed, + // and Event will be signaled when the I/O request is completed. + // The caller must be prepared to handle the case where the callback associated with Event occurs + // before the original asynchronous I/O request call returns. + // + EFI_EVENT Event; + + // + // Defines whether or not the signaled event encountered an error. + // + EFI_STATUS TransactionStatus; +} EFI_DISK_IO2_TOKEN; + +/** + Terminate outstanding asynchronous requests to a device. + + @param This Indicates a pointer to the calling context. + + @retval EFI_SUCCESS All outstanding requests were successfully terminated. + @retval EFI_DEVICE_ERROR The device reported an error while performing the cancel + operation. +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_DISK_CANCEL_EX) ( + IN EFI_DISK_IO2_PROTOCOL *This + ); + +/** + Reads a specified number of bytes from a device. + + @param This Indicates a pointer to the calling context. + @param MediaId ID of the medium to be read. + @param Offset The starting byte offset on the logical block I/O device to read from. + @param Token A pointer to the token associated with the transaction. + If this field is NULL, synchronous/blocking IO is performed. + @param BufferSize The size in bytes of Buffer. The number of bytes to read from the device. + @param Buffer A pointer to the destination buffer for the data. + The caller is responsible either having implicit or explicit ownership of the buffer. + + @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was read correctly from the device. + If Event is not NULL (asynchronous I/O): The request was successfully queued for processing. + Event will be signaled upon completion. + @retval EFI_DEVICE_ERROR The device reported an error while performing the write. + @retval EFI_NO_MEDIA There is no medium in the device. + @retval EFI_MEDIA_CHNAGED The MediaId is not for the current medium. + @retval EFI_INVALID_PARAMETER The read request contains device addresses that are not valid for the device. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_DISK_READ_EX) ( + IN EFI_DISK_IO2_PROTOCOL *This, + IN UINT32 MediaId, + IN UINT64 Offset, + IN OUT EFI_DISK_IO2_TOKEN *Token, + IN UINTN BufferSize, + OUT VOID *Buffer + ); + +/** + Writes a specified number of bytes to a device. + + @param This Indicates a pointer to the calling context. + @param MediaId ID of the medium to be written. + @param Offset The starting byte offset on the logical block I/O device to write to. + @param Token A pointer to the token associated with the transaction. + If this field is NULL, synchronous/blocking IO is performed. + @param BufferSize The size in bytes of Buffer. The number of bytes to write to the device. + @param Buffer A pointer to the buffer containing the data to be written. + + @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was written correctly to the device. + If Event is not NULL (asynchronous I/O): The request was successfully queued for processing. + Event will be signaled upon completion. + @retval EFI_WRITE_PROTECTED The device cannot be written to. + @retval EFI_DEVICE_ERROR The device reported an error while performing the write operation. + @retval EFI_NO_MEDIA There is no medium in the device. + @retval EFI_MEDIA_CHNAGED The MediaId is not for the current medium. + @retval EFI_INVALID_PARAMETER The write request contains device addresses that are not valid for the device. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_DISK_WRITE_EX) ( + IN EFI_DISK_IO2_PROTOCOL *This, + IN UINT32 MediaId, + IN UINT64 Offset, + IN OUT EFI_DISK_IO2_TOKEN *Token, + IN UINTN BufferSize, + IN VOID *Buffer + ); + +/** + Flushes all modified data to the physical device. + + @param This Indicates a pointer to the calling context. + @param MediaId ID of the medium to be written. + @param Token A pointer to the token associated with the transaction. + If this field is NULL, synchronous/blocking IO is performed. + + @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was flushed successfully to the device. + If Event is not NULL (asynchronous I/O): The request was successfully queued for processing. + Event will be signaled upon completion. + @retval EFI_WRITE_PROTECTED The device cannot be written to. + @retval EFI_DEVICE_ERROR The device reported an error while performing the write operation. + @retval EFI_NO_MEDIA There is no medium in the device. + @retval EFI_MEDIA_CHNAGED The MediaId is not for the current medium. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_DISK_FLUSH_EX) ( + IN EFI_DISK_IO2_PROTOCOL *This, + IN OUT EFI_DISK_IO2_TOKEN *Token + ); + +#define EFI_DISK_IO2_PROTOCOL_REVISION 0x00020000 + +/// +/// This protocol is used to abstract Block I/O interfaces. +/// +struct _EFI_DISK_IO2_PROTOCOL { + /// + /// The revision to which the disk I/O interface adheres. All future + /// revisions must be backwards compatible. If a future version is not + /// backwards compatible, it is not the same GUID. + /// + UINT64 Revision; + EFI_DISK_CANCEL_EX Cancel; + EFI_DISK_READ_EX ReadDiskEx; + EFI_DISK_WRITE_EX WriteDiskEx; + EFI_DISK_FLUSH_EX FlushDiskEx; +}; + +extern EFI_GUID gEfiDiskIo2ProtocolGuid; + +#endif diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index 6ff7ae66f6..16c278aec3 100644 --- a/MdePkg/MdePkg.dec +++ b/MdePkg/MdePkg.dec @@ -5,7 +5,7 @@ # It also provides the definitions(including PPIs/PROTOCOLs/GUIDs) of # EFI1.10/UEFI2.3.1/PI1.2 and some Industry Standards. # -# Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.
# Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
# # This program and the accompanying materials are licensed and made available under @@ -1290,10 +1290,16 @@ gEfiBlockIo2ProtocolGuid = { 0xa77b2472, 0xe282, 0x4e9f, {0xa2, 0x45, 0xc2, 0xc0, 0xe2, 0x7b, 0xbc, 0xc1 }} ## Include/Protocol/StorageSecurityCommand.h - gEfiStorageSecurityCommandProtocolGuid = { 0xc88b0b6d, 0x0dfc, 0x49a7, {0x9c, 0xb4, 0x49, 0x7, 0x4b, 0x4c, 0x3a, 0x78 }} + gEfiStorageSecurityCommandProtocolGuid = { 0xc88b0b6d, 0x0dfc, 0x49a7, {0x9c, 0xb4, 0x49, 0x7, 0x4b, 0x4c, 0x3a, 0x78 }} ## Include/Protocol/UserCredential2.h - gEfiUserCredential2ProtocolGuid = { 0xe98adb03, 0xb8b9, 0x4af8, {0xba, 0x20, 0x26, 0xe9, 0x11, 0x4c, 0xbc, 0xe5 }} + gEfiUserCredential2ProtocolGuid = { 0xe98adb03, 0xb8b9, 0x4af8, {0xba, 0x20, 0x26, 0xe9, 0x11, 0x4c, 0xbc, 0xe5 }} + + # + # Protocols defined in UEFI2.4 + # + ## Include/Protocol/DiskIo2.h + gEfiDiskIo2ProtocolGuid = { 0x151c8eae, 0x7f2c, 0x472c, { 0x9e, 0x54, 0x98, 0x28, 0x19, 0x4f, 0x6a, 0x88 }} [PcdsFeatureFlag] ## If TRUE, the component name protocol will not be installed.