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

Go to the source code of this file.

Functions

EFI_STATUS EFIAPI DiskIoDriverBindingSupported (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL)
 
EFI_STATUS EFIAPI DiskIoDriverBindingStart (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL)
 
EFI_STATUS EFIAPI DiskIoDriverBindingStop (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
 
LIST_ENTRYDiskIoDestroySubtask (IN DISK_IO_PRIVATE_DATA *Instance, IN DISK_IO_SUBTASK *Subtask)
 
VOID EFIAPI DiskIo2OnReadWriteComplete (IN EFI_EVENT Event, IN VOID *Context)
 
DISK_IO_SUBTASKDiskIoCreateSubtask (IN BOOLEAN Write, IN UINT64 Lba, IN UINT32 Offset, IN UINTN Length, IN VOID *WorkingBuffer OPTIONAL, IN VOID *Buffer, IN BOOLEAN Blocking)
 
BOOLEAN DiskIoCreateSubtaskList (IN DISK_IO_PRIVATE_DATA *Instance, IN BOOLEAN Write, IN UINT64 Offset, IN UINTN BufferSize, IN VOID *Buffer, IN BOOLEAN Blocking, IN VOID *SharedWorkingBuffer, IN OUT LIST_ENTRY *Subtasks)
 
EFI_STATUS EFIAPI DiskIo2Cancel (IN EFI_DISK_IO2_PROTOCOL *This)
 
BOOLEAN DiskIo2RemoveCompletedTask (IN DISK_IO_PRIVATE_DATA *Instance)
 
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 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)
 
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)
 
VOID EFIAPI DiskIo2OnFlushComplete (IN EFI_EVENT Event, IN VOID *Context)
 
EFI_STATUS EFIAPI DiskIo2FlushDiskEx (IN EFI_DISK_IO2_PROTOCOL *This, IN OUT EFI_DISK_IO2_TOKEN *Token)
 
EFI_STATUS EFIAPI DiskIoReadDisk (IN EFI_DISK_IO_PROTOCOL *This, IN UINT32 MediaId, IN UINT64 Offset, IN UINTN BufferSize, OUT VOID *Buffer)
 
EFI_STATUS EFIAPI DiskIoWriteDisk (IN EFI_DISK_IO_PROTOCOL *This, IN UINT32 MediaId, IN UINT64 Offset, IN UINTN BufferSize, IN VOID *Buffer)
 
EFI_STATUS EFIAPI InitializeDiskIo (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 

Variables

EFI_DRIVER_BINDING_PROTOCOL gDiskIoDriverBinding
 
DISK_IO_PRIVATE_DATA gDiskIoPrivateDataTemplate
 

Detailed Description

DiskIo driver that lays on every BlockIo protocol in the system. DiskIo converts a block oriented device to a byte oriented device.

Disk access may have to handle unaligned request about 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.

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

Definition in file DiskIo.c.

Function Documentation

◆ DiskIo2Cancel()

EFI_STATUS EFIAPI DiskIo2Cancel ( IN EFI_DISK_IO2_PROTOCOL This)

Terminate outstanding asynchronous requests to a device.

Parameters
ThisIndicates a pointer to the calling context.
Return values
EFI_SUCCESSAll outstanding requests were successfully terminated.
EFI_DEVICE_ERRORThe device reported an error while performing the cancel operation.

Definition at line 745 of file DiskIo.c.

◆ DiskIo2FlushDiskEx()

EFI_STATUS EFIAPI DiskIo2FlushDiskEx ( IN EFI_DISK_IO2_PROTOCOL This,
IN OUT EFI_DISK_IO2_TOKEN Token 
)

Flushes all modified data to the physical device.

Parameters
ThisIndicates a pointer to the calling context.
TokenA pointer to the token associated with the transaction. If this field is NULL, synchronous/blocking IO is performed.
Return values
EFI_SUCCESSIf 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.
EFI_WRITE_PROTECTEDThe device cannot be written to.
EFI_DEVICE_ERRORThe device reported an error while performing the write operation.
EFI_NO_MEDIAThere is no medium in the device.
EFI_OUT_OF_RESOURCESThe request could not be completed due to a lack of resources.

Definition at line 1152 of file DiskIo.c.

◆ DiskIo2OnFlushComplete()

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

The callback for the BlockIo2 FlushBlocksEx.

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

Definition at line 1118 of file DiskIo.c.

◆ DiskIo2OnReadWriteComplete()

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

The callback for the BlockIo2 ReadBlocksEx/WriteBlocksEx.

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

Definition at line 409 of file DiskIo.c.

◆ DiskIo2ReadDiskEx()

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 
)

Reads a specified number of bytes from a device.

Parameters
ThisIndicates a pointer to the calling context.
MediaIdID of the medium to be read.
OffsetThe starting byte offset on the logical block I/O device to read from.
TokenA pointer to the token associated with the transaction. If this field is NULL, synchronous/blocking IO is performed.
BufferSizeThe size in bytes of Buffer. The number of bytes to read from the device.
BufferA pointer to the destination buffer for the data. The caller is responsible either having implicit or explicit ownership of the buffer.
Return values
EFI_SUCCESSIf 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.
EFI_DEVICE_ERRORThe device reported an error while performing the write.
EFI_NO_MEDIAThere is no medium in the device.
EFI_MEDIA_CHNAGEDThe MediaId is not for the current medium.
EFI_INVALID_PARAMETERThe read request contains device addresses that are not valid for the device.
EFI_OUT_OF_RESOURCESThe request could not be completed due to a lack of resources.

Definition at line 1046 of file DiskIo.c.

◆ DiskIo2ReadWriteDisk()

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 
)

Common routine to access the disk.

Parameters
InstancePointer to the DISK_IO_PRIVATE_DATA.
WriteTRUE: Write operation; FALSE: Read operation.
MediaIdID of the medium to access.
OffsetThe starting byte offset on the logical block I/O device to access.
TokenA pointer to the token associated with the transaction. If this field is NULL, synchronous/blocking IO is performed.
BufferSizeThe size in bytes of Buffer. The number of bytes to read from the device.
BufferA pointer to the destination buffer for the data. The caller is responsible either having implicit or explicit ownership of the buffer.

Definition at line 830 of file DiskIo.c.

◆ DiskIo2RemoveCompletedTask()

BOOLEAN DiskIo2RemoveCompletedTask ( IN DISK_IO_PRIVATE_DATA Instance)

Remove the completed tasks from Instance->TaskQueue. Completed tasks are those who don't have any subtasks.

Parameters
InstancePointer to the DISK_IO_PRIVATE_DATA.
Return values
TRUEThe Instance->TaskQueue is empty after the completed tasks are removed.
FALSEThe Instance->TaskQueue is not empty after the completed tasks are removed.

Definition at line 788 of file DiskIo.c.

◆ DiskIo2WriteDiskEx()

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 
)

Writes a specified number of bytes to a device.

Parameters
ThisIndicates a pointer to the calling context.
MediaIdID of the medium to be written.
OffsetThe starting byte offset on the logical block I/O device to write to.
TokenA pointer to the token associated with the transaction. If this field is NULL, synchronous/blocking IO is performed.
BufferSizeThe size in bytes of Buffer. The number of bytes to write to the device.
BufferA pointer to the buffer containing the data to be written.
Return values
EFI_SUCCESSIf 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.
EFI_WRITE_PROTECTEDThe device cannot be written to.
EFI_DEVICE_ERRORThe device reported an error while performing the write operation.
EFI_NO_MEDIAThere is no medium in the device.
EFI_MEDIA_CHNAGEDThe MediaId is not for the current medium.
EFI_INVALID_PARAMETERThe write request contains device addresses that are not valid for the device.
EFI_OUT_OF_RESOURCESThe request could not be completed due to a lack of resources.

Definition at line 1090 of file DiskIo.c.

◆ DiskIoCreateSubtask()

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 
)

Create the subtask.

Parameters
WriteTRUE: Write request; FALSE: Read request.
LbaThe starting logical block address to read from on the device.
OffsetThe starting byte offset to read from the LBA.
LengthThe number of bytes to read from the device.
WorkingBufferThe aligned buffer to hold the data for reading or writing.
BufferThe buffer to hold the data for reading or writing.
BlockingTRUE: Blocking request; FALSE: Non-blocking request.
Returns
A pointer to the created subtask.

Definition at line 468 of file DiskIo.c.

◆ DiskIoCreateSubtaskList()

BOOLEAN DiskIoCreateSubtaskList ( IN DISK_IO_PRIVATE_DATA Instance,
IN BOOLEAN  Write,
IN UINT64  Offset,
IN UINTN  BufferSize,
IN VOID *  Buffer,
IN BOOLEAN  Blocking,
IN VOID *  SharedWorkingBuffer,
IN OUT LIST_ENTRY Subtasks 
)

Create the subtask list.

Parameters
InstancePointer to the DISK_IO_PRIVATE_DATA.
WriteTRUE: Write request; FALSE: Read request.
OffsetThe starting byte offset to read from the device.
BufferSizeThe size in bytes of Buffer. The number of bytes to read from the device.
BufferA pointer to the buffer for the data.
BlockingTRUE: Blocking request; FALSE: Non-blocking request.
SharedWorkingBufferThe aligned buffer to hold the data for reading or writing.
SubtasksThe subtask list header.
Return values
TRUEThe subtask list is created successfully.
FALSEThe subtask list is not created.

Definition at line 538 of file DiskIo.c.

◆ DiskIoDestroySubtask()

LIST_ENTRY * DiskIoDestroySubtask ( IN DISK_IO_PRIVATE_DATA Instance,
IN DISK_IO_SUBTASK Subtask 
)

Destroy the sub task.

Parameters
InstancePointer to the DISK_IO_PRIVATE_DATA.
SubtaskSubtask.
Returns
LIST_ENTRY * Pointer to the next link of subtask.

Definition at line 365 of file DiskIo.c.

◆ DiskIoDriverBindingStart()

EFI_STATUS EFIAPI DiskIoDriverBindingStart ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath  OPTIONAL 
)

Start this driver on ControllerHandle by opening a Block IO protocol and installing a Disk IO protocol on ControllerHandle.

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

Definition at line 118 of file DiskIo.c.

◆ DiskIoDriverBindingStop()

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

Stop this driver on ControllerHandle by removing Disk IO protocol and closing the Block IO protocol on ControllerHandle.

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

Definition at line 252 of file DiskIo.c.

◆ DiskIoDriverBindingSupported()

EFI_STATUS EFIAPI DiskIoDriverBindingSupported ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath  OPTIONAL 
)

Test to see if this driver supports ControllerHandle.

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

Definition at line 66 of file DiskIo.c.

◆ DiskIoReadDisk()

EFI_STATUS EFIAPI DiskIoReadDisk ( IN EFI_DISK_IO_PROTOCOL This,
IN UINT32  MediaId,
IN UINT64  Offset,
IN UINTN  BufferSize,
OUT VOID *  Buffer 
)

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.

Parameters
ThisProtocol instance pointer.
MediaIdId of the media, changes every time the media is replaced.
OffsetThe starting byte offset to read from
BufferSizeSize of Buffer
BufferBuffer containing read data
Return values
EFI_SUCCESSThe data was read correctly from the device.
EFI_DEVICE_ERRORThe device reported an error while performing the read.
EFI_NO_MEDIAThere is no media in the device.
EFI_MEDIA_CHNAGEDThe MediaId does not matched the current device.
EFI_INVALID_PARAMETERThe read request contains device addresses that are not valid for the device.

Definition at line 1220 of file DiskIo.c.

◆ DiskIoWriteDisk()

EFI_STATUS EFIAPI DiskIoWriteDisk ( IN EFI_DISK_IO_PROTOCOL This,
IN UINT32  MediaId,
IN UINT64  Offset,
IN UINTN  BufferSize,
IN VOID *  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.

Parameters
ThisProtocol instance pointer.
MediaIdId of the media, changes every time the media is replaced.
OffsetThe starting byte offset to read from
BufferSizeSize of Buffer
BufferBuffer containing read data
Return values
EFI_SUCCESSThe data was written correctly to the device.
EFI_WRITE_PROTECTEDThe device can not be written to.
EFI_DEVICE_ERRORThe device reported an error while performing the write.
EFI_NO_MEDIAThere is no media in the device.
EFI_MEDIA_CHNAGEDThe MediaId does not matched the current device.
EFI_INVALID_PARAMETERThe write request contains device addresses that are not valid for the device.

Definition at line 1266 of file DiskIo.c.

◆ InitializeDiskIo()

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

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

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

Definition at line 1297 of file DiskIo.c.

Variable Documentation

◆ gDiskIoDriverBinding

EFI_DRIVER_BINDING_PROTOCOL gDiskIoDriverBinding
Initial value:
= {
0xa,
}
EFI_STATUS EFIAPI DiskIoDriverBindingStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
Definition: DiskIo.c:252
EFI_STATUS EFIAPI DiskIoDriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL)
Definition: DiskIo.c:66
EFI_STATUS EFIAPI DiskIoDriverBindingStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL)
Definition: DiskIo.c:118
#define NULL
Definition: Base.h:319

Definition at line 22 of file DiskIo.c.

◆ gDiskIoPrivateDataTemplate

DISK_IO_PRIVATE_DATA gDiskIoPrivateDataTemplate
Initial value:
= {
DISK_IO_PRIVATE_DATA_SIGNATURE,
{
EFI_DISK_IO_PROTOCOL_REVISION,
},
{
EFI_DISK_IO2_PROTOCOL_REVISION,
}
}
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)
Definition: DiskIo.c:1090
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)
Definition: DiskIo.c:1046
EFI_STATUS EFIAPI DiskIoWriteDisk(IN EFI_DISK_IO_PROTOCOL *This, IN UINT32 MediaId, IN UINT64 Offset, IN UINTN BufferSize, IN VOID *Buffer)
Definition: DiskIo.c:1266
EFI_STATUS EFIAPI DiskIo2Cancel(IN EFI_DISK_IO2_PROTOCOL *This)
Definition: DiskIo.c:745
EFI_STATUS EFIAPI DiskIoReadDisk(IN EFI_DISK_IO_PROTOCOL *This, IN UINT32 MediaId, IN UINT64 Offset, IN UINTN BufferSize, OUT VOID *Buffer)
Definition: DiskIo.c:1220
EFI_STATUS EFIAPI DiskIo2FlushDiskEx(IN EFI_DISK_IO2_PROTOCOL *This, IN OUT EFI_DISK_IO2_TOKEN *Token)
Definition: DiskIo.c:1152

Definition at line 35 of file DiskIo.c.