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

Go to the source code of this file.

Functions

EFI_STATUS EFIAPI EmuBlockIo2Reset (IN EFI_BLOCK_IO2_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
 
EFI_STATUS EFIAPI EmuBlockIo2ReadBlocksEx (IN EFI_BLOCK_IO2_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA LBA, IN OUT EFI_BLOCK_IO2_TOKEN *Token, IN UINTN BufferSize, OUT VOID *Buffer)
 
EFI_STATUS EFIAPI EmuBlockIo2WriteBlocksEx (IN EFI_BLOCK_IO2_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA LBA, IN OUT EFI_BLOCK_IO2_TOKEN *Token, IN UINTN BufferSize, IN VOID *Buffer)
 
EFI_STATUS EFIAPI EmuBlockIo2Flush (IN EFI_BLOCK_IO2_PROTOCOL *This, IN OUT EFI_BLOCK_IO2_TOKEN *Token)
 
EFI_STATUS EFIAPI EmuBlockIoReset (IN EFI_BLOCK_IO_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
 
EFI_STATUS EFIAPI EmuBlockIoReadBlocks (IN EFI_BLOCK_IO_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA Lba, IN UINTN BufferSize, OUT VOID *Buffer)
 
EFI_STATUS EFIAPI EmuBlockIoWriteBlocks (IN EFI_BLOCK_IO_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA Lba, IN UINTN BufferSize, IN VOID *Buffer)
 
EFI_STATUS EFIAPI EmuBlockIoFlushBlocks (IN EFI_BLOCK_IO_PROTOCOL *This)
 
EFI_STATUS EFIAPI EmuBlockIoDriverBindingSupported (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Handle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
EFI_STATUS EFIAPI EmuBlockIoDriverBindingStart (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Handle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
EFI_STATUS EFIAPI EmuBlockIoDriverBindingStop (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Handle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
 
EFI_STATUS EFIAPI InitializeEmuBlockIo (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 

Variables

EFI_DRIVER_BINDING_PROTOCOL gEmuBlockIoDriverBinding
 

Detailed Description

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

Definition in file EmuBlockIo.c.

Function Documentation

◆ EmuBlockIo2Flush()

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

Flush the Block Device.

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

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

Definition at line 182 of file EmuBlockIo.c.

◆ EmuBlockIo2ReadBlocksEx()

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

Read BufferSize bytes from Lba into Buffer.

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

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

Definition at line 79 of file EmuBlockIo.c.

◆ EmuBlockIo2Reset()

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

Reset the block device hardware.

Parameters
[in]ThisIndicates a pointer to the calling context.
[in]ExtendedVerificationIndicates that the driver may perform a more exhausive verfication operation of the device during reset.
Return values
EFI_SUCCESSThe device was reset.
EFI_DEVICE_ERRORThe device is not functioning properly and could not be reset.

Definition at line 25 of file EmuBlockIo.c.

◆ EmuBlockIo2WriteBlocksEx()

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

Write BufferSize bytes from Lba into Buffer.

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

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

Definition at line 135 of file EmuBlockIo.c.

◆ EmuBlockIoDriverBindingStart()

EFI_STATUS EFIAPI EmuBlockIoDriverBindingStart ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  Handle,
IN EFI_DEVICE_PATH_PROTOCOL RemainingDevicePath 
)

Starts a device controller or a bus controller.

The Start() function is designed to be invoked from the EFI boot service ConnectController(). As a result, much of the error checking on the parameters to Start() has been moved into this common boot service. It is legal to call Start() from other locations, but the following calling restrictions must be followed, or the system behavior will not be deterministic.

  1. ControllerHandle must be a valid EFI_HANDLE.
  2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned EFI_DEVICE_PATH_PROTOCOL.
  3. Prior to calling Start(), the Supported() function for the driver specified by This must have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
Parameters
[in]ThisA pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
[in]ControllerHandleThe handle of the controller to start. This handle must support a protocol interface that supplies an I/O abstraction to the driver.
[in]RemainingDevicePathA pointer to the remaining portion of a device path. This parameter is ignored by device drivers, and is optional for bus drivers. For a bus driver, if this parameter is NULL, then handles for all the children of Controller are created by this driver. If this parameter is not NULL and the first Device Path Node is not the End of Device Path Node, then only the handle for the child device specified by the first Device Path Node of RemainingDevicePath is created by this driver. If the first Device Path Node of RemainingDevicePath is the End of Device Path Node, no child handle is created by this driver.
Return values
EFI_SUCCESSThe device was started.
EFI_DEVICE_ERRORThe device could not be started due to a device error.Currently not implemented.
EFI_OUT_OF_RESOURCESThe request could not be completed due to a lack of resources.
OthersThe driver failded to start the device.

Definition at line 481 of file EmuBlockIo.c.

◆ EmuBlockIoDriverBindingStop()

EFI_STATUS EFIAPI EmuBlockIoDriverBindingStop ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  Handle,
IN UINTN  NumberOfChildren,
IN EFI_HANDLE ChildHandleBuffer 
)

Stops a device controller or a bus controller.

The Stop() function is designed to be invoked from the EFI boot service DisconnectController(). As a result, much of the error checking on the parameters to Stop() has been moved into this common boot service. It is legal to call Stop() from other locations, but the following calling restrictions must be followed, or the system behavior will not be deterministic.

  1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this same driver's Start() function.
  2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid EFI_HANDLE. In addition, all of these handles must have been created in this driver's Start() function, and the Start() function must have called OpenProtocol() on ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
Parameters
[in]ThisA pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
[in]ControllerHandleA handle to the device being stopped. The handle must support a bus specific I/O protocol for the driver to use to stop the device.
[in]NumberOfChildrenThe number of child device handles in ChildHandleBuffer.
[in]ChildHandleBufferAn array of child handles to be freed. May be NULL if NumberOfChildren is 0.
Return values
EFI_SUCCESSThe device was stopped.
EFI_DEVICE_ERRORThe device could not be stopped due to a device error.

Definition at line 621 of file EmuBlockIo.c.

◆ EmuBlockIoDriverBindingSupported()

EFI_STATUS EFIAPI EmuBlockIoDriverBindingSupported ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  Handle,
IN EFI_DEVICE_PATH_PROTOCOL RemainingDevicePath 
)

Tests to see if this driver supports a given controller. If a child device is provided, it further tests to see if this driver supports creating a handle for the specified child device.

This function checks to see if the driver specified by This supports the device specified by ControllerHandle. Drivers will typically use the device path attached to ControllerHandle and/or the services from the bus I/O abstraction attached to ControllerHandle to determine if the driver supports ControllerHandle. This function may be called many times during platform initialization. In order to reduce boot times, the tests performed by this function must be very small, and take as little time as possible to execute. This function must not change the state of any hardware devices, and this function must be aware that the device specified by ControllerHandle may already be managed by the same driver or a different driver. This function must match its calls to AllocatePages() with FreePages(), AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol(). Because ControllerHandle may have been previously started by the same driver, if a protocol is already in the opened state, then it must not be closed with CloseProtocol(). This is required to guarantee the state of ControllerHandle is not modified by this function.

Parameters
[in]ThisA pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
[in]ControllerHandleThe handle of the controller to test. This handle must support a protocol interface that supplies an I/O abstraction to the driver.
[in]RemainingDevicePathA pointer to the remaining portion of a device path. This parameter is ignored by device drivers, and is optional for bus drivers. For bus drivers, if this parameter is not NULL, then the bus driver must determine if the bus controller specified by ControllerHandle and the child controller specified by RemainingDevicePath are both supported by this bus driver.
Return values
EFI_SUCCESSThe device specified by ControllerHandle and RemainingDevicePath is supported by the driver specified by This.
EFI_ALREADY_STARTEDThe device specified by ControllerHandle and RemainingDevicePath is already being managed by the driver specified by This.
EFI_ACCESS_DENIEDThe device specified by ControllerHandle and RemainingDevicePath is already being managed by a different driver or an application that requires exclusive access. Currently not implemented.
EFI_UNSUPPORTEDThe device specified by ControllerHandle and RemainingDevicePath is not supported by the driver specified by This.

Definition at line 400 of file EmuBlockIo.c.

◆ EmuBlockIoFlushBlocks()

EFI_STATUS EFIAPI EmuBlockIoFlushBlocks ( IN EFI_BLOCK_IO_PROTOCOL This)

Flush the Block Device.

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

Definition at line 336 of file EmuBlockIo.c.

◆ EmuBlockIoReadBlocks()

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

Read BufferSize bytes from Lba into Buffer.

Parameters
ThisIndicates a pointer to the calling context.
MediaIdId of the media, changes every time the media is replaced.
LbaThe starting Logical Block Address to read from
BufferSizeSize of Buffer, must be a multiple of device block size.
BufferA pointer to the destination buffer for the data. The caller is responsible for either having implicit or explicit ownership of the buffer.
Return values
EFI_SUCCESSThe data was read correctly from the device.
EFI_DEVICE_ERRORThe device reported an error while performing the read.
EFI_NO_MEDIAThere is no media in the device.
EFI_MEDIA_CHANGEDThe MediaId does not matched the current device.
EFI_BAD_BUFFER_SIZEThe Buffer was not a multiple of the block size of the device.
EFI_INVALID_PARAMETERThe read request contains LBAs that are not valid, or the buffer is not on proper alignment.

Definition at line 254 of file EmuBlockIo.c.

◆ EmuBlockIoReset()

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

Reset the Block Device.

Parameters
ThisIndicates a pointer to the calling context.
ExtendedVerificationDriver may perform diagnostics on reset.
Return values
EFI_SUCCESSThe device was reset.
EFI_DEVICE_ERRORThe device is not functioning properly and could not be reset.

Definition at line 214 of file EmuBlockIo.c.

◆ EmuBlockIoWriteBlocks()

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

Write BufferSize bytes from Lba into Buffer.

Parameters
ThisIndicates a pointer to the calling context.
MediaIdThe media ID that the write request is for.
LbaThe starting logical block address to be written. The caller is responsible for writing to only legitimate locations.
BufferSizeSize of Buffer, must be a multiple of device block size.
BufferA pointer to the source buffer for the 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_BAD_BUFFER_SIZEThe Buffer was not a multiple of the block size of the device.
EFI_INVALID_PARAMETERThe write request contains LBAs that are not valid, or the buffer is not on proper alignment.

Definition at line 300 of file EmuBlockIo.c.

◆ InitializeEmuBlockIo()

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

The user Entry Point for module EmuBlockIo . 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 701 of file EmuBlockIo.c.

Variable Documentation

◆ gEmuBlockIoDriverBinding

EFI_DRIVER_BINDING_PROTOCOL gEmuBlockIoDriverBinding
Initial value:
= {
0xa,
}
EFI_STATUS EFIAPI EmuBlockIoDriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Handle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: EmuBlockIo.c:400
EFI_STATUS EFIAPI EmuBlockIoDriverBindingStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Handle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: EmuBlockIo.c:481
EFI_STATUS EFIAPI EmuBlockIoDriverBindingStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Handle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
Definition: EmuBlockIo.c:621
#define NULL
Definition: Base.h:319

Definition at line 680 of file EmuBlockIo.c.