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

Go to the source code of this file.

Macros

#define USB_MASS_TRANSPORT_COUNT   3
 

Functions

EFI_STATUS EFIAPI UsbMassReset (IN EFI_BLOCK_IO_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
 
EFI_STATUS EFIAPI UsbMassReadBlocks (IN EFI_BLOCK_IO_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA Lba, IN UINTN BufferSize, OUT VOID *Buffer)
 
EFI_STATUS EFIAPI UsbMassWriteBlocks (IN EFI_BLOCK_IO_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA Lba, IN UINTN BufferSize, IN VOID *Buffer)
 
EFI_STATUS EFIAPI UsbMassFlushBlocks (IN EFI_BLOCK_IO_PROTOCOL *This)
 
EFI_STATUS UsbMassInitMedia (IN USB_MASS_DEVICE *UsbMass)
 
EFI_STATUS UsbMassInitTransport (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, OUT USB_MASS_TRANSPORT **Transport, OUT VOID **Context, OUT UINT8 *MaxLun)
 
EFI_STATUS UsbMassInitMultiLun (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN USB_MASS_TRANSPORT *Transport, IN VOID *Context, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN UINT8 MaxLun)
 
EFI_STATUS UsbMassInitNonLun (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN USB_MASS_TRANSPORT *Transport, IN VOID *Context)
 
EFI_STATUS EFIAPI USBMassDriverBindingSupported (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
EFI_STATUS EFIAPI USBMassDriverBindingStart (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
EFI_STATUS EFIAPI USBMassDriverBindingStop (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
 
EFI_STATUS EFIAPI USBMassStorageEntryPoint (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 

Variables

USB_MASS_TRANSPORTmUsbMassTransport [USB_MASS_TRANSPORT_COUNT]
 
EFI_DRIVER_BINDING_PROTOCOL gUSBMassDriverBinding
 

Detailed Description

USB Mass Storage Driver that manages USB Mass Storage Device and produces Block I/O Protocol.

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

Definition in file UsbMassImpl.c.

Macro Definition Documentation

◆ USB_MASS_TRANSPORT_COUNT

#define USB_MASS_TRANSPORT_COUNT   3

Definition at line 11 of file UsbMassImpl.c.

Function Documentation

◆ USBMassDriverBindingStart()

EFI_STATUS EFIAPI USBMassDriverBindingStart ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  Controller,
IN EFI_DEVICE_PATH_PROTOCOL RemainingDevicePath 
)

Starts the USB mass storage device with this driver.

This function consumes USB I/O Protocol, initializes USB mass storage device, installs Block I/O Protocol, and submits Asynchronous Interrupt Transfer to manage the USB mass storage device.

Parameters
ThisThe USB mass storage driver binding protocol.
ControllerThe USB mass storage device to start on
RemainingDevicePathThe remaining device path.
Return values
EFI_SUCCESSThis driver supports this device.
EFI_UNSUPPORTEDThis driver does not support this device.
EFI_DEVICE_ERRORThis driver cannot be started due to device Error.
EFI_OUT_OF_RESOURCESCan't allocate memory resources.
EFI_ALREADY_STARTEDThis driver has been started.

Definition at line 791 of file UsbMassImpl.c.

◆ USBMassDriverBindingStop()

EFI_STATUS EFIAPI USBMassDriverBindingStop ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  Controller,
IN UINTN  NumberOfChildren,
IN EFI_HANDLE ChildHandleBuffer 
)

Stop controlling the device.

Parameters
ThisThe USB mass storage driver binding
ControllerThe device controller controlled by the driver.
NumberOfChildrenThe number of children of this device
ChildHandleBufferThe buffer of children handle.
Return values
EFI_SUCCESSThe driver stopped from controlling the device.
EFI_DEVICE_ERRORThe device could not be stopped due to a device error.
EFI_UNSUPPORTEDBlock I/O Protocol is not installed on Controller.
OthersFailed to stop the driver

Definition at line 907 of file UsbMassImpl.c.

◆ USBMassDriverBindingSupported()

EFI_STATUS EFIAPI USBMassDriverBindingSupported ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  Controller,
IN EFI_DEVICE_PATH_PROTOCOL RemainingDevicePath 
)

Check whether the controller is a supported USB mass storage.

Parameters
ThisThe USB mass storage driver binding protocol.
ControllerThe controller handle to check.
RemainingDevicePathThe remaining device path.
Return values
EFI_SUCCESSThe driver supports this controller.
otherThis device isn't supported.

Definition at line 707 of file UsbMassImpl.c.

◆ UsbMassFlushBlocks()

EFI_STATUS EFIAPI UsbMassFlushBlocks ( IN EFI_BLOCK_IO_PROTOCOL This)

Flushes all modified data to a physical block device.

This function implements EFI_BLOCK_IO_PROTOCOL.FlushBlocks(). USB mass storage device doesn't support write cache, so return EFI_SUCCESS directly.

Parameters
ThisIndicates a pointer to the calling context.
Return values
EFI_SUCCESSAll outstanding data were written correctly to the device.
EFI_DEVICE_ERRORThe device reported an error while attempting to write data.
EFI_NO_MEDIAThere is no media in the device.

Definition at line 319 of file UsbMassImpl.c.

◆ UsbMassInitMedia()

EFI_STATUS UsbMassInitMedia ( IN USB_MASS_DEVICE UsbMass)

Initialize the media parameter data for EFI_BLOCK_IO_MEDIA of Block I/O Protocol.

Parameters
UsbMassThe USB mass storage device
Return values
EFI_SUCCESSThe media parameters are updated successfully.
OthersFailed to get the media parameters.

Definition at line 336 of file UsbMassImpl.c.

◆ UsbMassInitMultiLun()

EFI_STATUS UsbMassInitMultiLun ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  Controller,
IN USB_MASS_TRANSPORT Transport,
IN VOID *  Context,
IN EFI_DEVICE_PATH_PROTOCOL DevicePath,
IN UINT8  MaxLun 
)

Initialize data for device that supports multiple LUNSs.

Parameters
ThisThe Driver Binding Protocol instance.
ControllerThe device to initialize.
TransportPointer to USB_MASS_TRANSPORT.
ContextParameter for USB_MASS_DEVICE.Context.
DevicePathThe remaining device path.
MaxLunThe max LUN number.
Return values
EFI_SUCCESSAt least one LUN is initialized successfully.
EFI_NOT_FOUNDFail to initialize any of multiple LUNs.

Definition at line 473 of file UsbMassImpl.c.

◆ UsbMassInitNonLun()

EFI_STATUS UsbMassInitNonLun ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  Controller,
IN USB_MASS_TRANSPORT Transport,
IN VOID *  Context 
)

Initialize data for device that does not support multiple LUNSs.

Parameters
ThisThe Driver Binding Protocol instance.
ControllerThe device to initialize.
TransportPointer to USB_MASS_TRANSPORT.
ContextParameter for USB_MASS_DEVICE.Context.
Return values
EFI_SUCCESSInitialization succeeds.
OtherInitialization fails.

Definition at line 611 of file UsbMassImpl.c.

◆ UsbMassInitTransport()

EFI_STATUS UsbMassInitTransport ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  Controller,
OUT USB_MASS_TRANSPORT **  Transport,
OUT VOID **  Context,
OUT UINT8 *  MaxLun 
)

Initialize the USB Mass Storage transport.

This function tries to find the matching USB Mass Storage transport protocol for USB device. If found, initializes the matching transport.

Parameters
ThisThe USB mass driver's driver binding.
ControllerThe device to test.
TransportThe pointer to pointer to USB_MASS_TRANSPORT.
ContextThe parameter for USB_MASS_DEVICE.Context.
MaxLunGet the MaxLun if is BOT dev.
Return values
EFI_SUCCESSThe initialization is successful.
EFI_UNSUPPORTEDNo matching transport protocol is found.
OthersFailed to initialize dev.

Definition at line 387 of file UsbMassImpl.c.

◆ UsbMassReadBlocks()

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

Reads the requested number of blocks from the device.

This function implements EFI_BLOCK_IO_PROTOCOL.ReadBlocks(). It reads the requested number of blocks from the device. All the blocks are read, or an error is returned.

Parameters
ThisIndicates a pointer to the calling context.
MediaIdThe media ID that the read request is for.
LbaThe starting logical block address to read from on the device.
BufferSizeThe size of the Buffer in bytes. This must be a multiple of the intrinsic block size of the device.
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 attempting to perform the read operation.
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.

Definition at line 96 of file UsbMassImpl.c.

◆ UsbMassReset()

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

Reset the block device.

This function implements EFI_BLOCK_IO_PROTOCOL.Reset(). It resets the block device hardware. ExtendedVerification is ignored in this implementation.

Parameters
ThisIndicates a pointer to the calling context.
ExtendedVerificationIndicates that the driver may perform a more exhaustive verification operation of the device during reset.
Return values
EFI_SUCCESSThe block device was reset.
EFI_DEVICE_ERRORThe block device is not functioning correctly and could not be reset.

Definition at line 47 of file UsbMassImpl.c.

◆ USBMassStorageEntryPoint()

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

Entrypoint of USB Mass Storage Driver.

This function is the entrypoint of USB Mass Storage Driver. It installs Driver Binding Protocol together with Component Name Protocols.

Parameters
ImageHandleThe firmware allocated handle for the EFI image.
SystemTableA pointer to the EFI System Table.
Return values
EFI_SUCCESSThe entry point is executed successfully.

Definition at line 1089 of file UsbMassImpl.c.

◆ UsbMassWriteBlocks()

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

Writes a specified number of blocks to the device.

This function implements EFI_BLOCK_IO_PROTOCOL.WriteBlocks(). It writes a specified number of blocks to the device. All blocks are written, or an error is returned.

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.
BufferSizeThe size of the Buffer in bytes. This must be a multiple of the intrinsic block size of the device.
BufferPointer to the source buffer for the data.
Return values
EFI_SUCCESSThe data were written correctly to the device.
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_DEVICE_ERRORThe device reported an error while attempting to perform the write operation.
EFI_BAD_BUFFER_SIZEThe BufferSize parameter is not a multiple of the intrinsic 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 211 of file UsbMassImpl.c.

Variable Documentation

◆ gUSBMassDriverBinding

EFI_DRIVER_BINDING_PROTOCOL gUSBMassDriverBinding
Initial value:
= {
0x11,
}
#define NULL
Definition: Base.h:319
EFI_STATUS EFIAPI USBMassDriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: UsbMassImpl.c:707
EFI_STATUS EFIAPI USBMassDriverBindingStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: UsbMassImpl.c:791
EFI_STATUS EFIAPI USBMassDriverBindingStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
Definition: UsbMassImpl.c:907

Definition at line 21 of file UsbMassImpl.c.

◆ mUsbMassTransport

USB_MASS_TRANSPORT* mUsbMassTransport[USB_MASS_TRANSPORT_COUNT]
Initial value:
= {
&mUsbCbi0Transport,
&mUsbCbi1Transport,
&mUsbBotTransport,
}

Definition at line 15 of file UsbMassImpl.c.