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

Go to the source code of this file.

Functions

EFI_STATUS EFIAPI ScsiioToPassThruPacket (IN EFI_SCSI_IO_SCSI_REQUEST_PACKET *Packet, OUT EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *CommandPacket)
 
EFI_STATUS EFIAPI PassThruToScsiioPacket (IN EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *ScsiPacket, OUT EFI_SCSI_IO_SCSI_REQUEST_PACKET *Packet)
 
VOID EFIAPI NotifyFunction (IN EFI_EVENT Event, IN VOID *Context)
 
VOID * AllocateAlignedBuffer (IN SCSI_IO_DEV *ScsiIoDevice, IN UINTN BufferSize)
 
VOID FreeAlignedBuffer (IN VOID *Buffer, IN UINTN BufferSize)
 
EFI_STATUS EFIAPI InitializeScsiBus (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 
EFI_STATUS EFIAPI SCSIBusDriverBindingSupported (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
EFI_STATUS EFIAPI SCSIBusDriverBindingStart (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
EFI_STATUS EFIAPI SCSIBusDriverBindingStop (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
 
EFI_STATUS EFIAPI ScsiGetDeviceType (IN EFI_SCSI_IO_PROTOCOL *This, OUT UINT8 *DeviceType)
 
EFI_STATUS EFIAPI ScsiGetDeviceLocation (IN EFI_SCSI_IO_PROTOCOL *This, IN OUT UINT8 **Target, OUT UINT64 *Lun)
 
EFI_STATUS EFIAPI ScsiResetBus (IN EFI_SCSI_IO_PROTOCOL *This)
 
EFI_STATUS EFIAPI ScsiResetDevice (IN EFI_SCSI_IO_PROTOCOL *This)
 
EFI_STATUS EFIAPI ScsiExecuteSCSICommand (IN EFI_SCSI_IO_PROTOCOL *This, IN OUT EFI_SCSI_IO_SCSI_REQUEST_PACKET *Packet, IN EFI_EVENT Event OPTIONAL)
 
EFI_STATUS EFIAPI ScsiScanCreateDevice (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN SCSI_TARGET_ID *TargetId, IN UINT64 Lun, IN OUT SCSI_BUS_DEVICE *ScsiBusDev)
 
EFI_STATUS DiscoverScsiDevice (IN OUT SCSI_IO_DEV *ScsiIoDevice)
 

Variables

EFI_DRIVER_BINDING_PROTOCOL gSCSIBusDriverBinding
 
VOID * mWorkingBuffer
 

Detailed Description

SCSI Bus driver that layers on every SCSI Pass Thru and Extended SCSI Pass Thru protocol in the system.

Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
Copyright (c) 1985 - 2022, American Megatrends International LLC.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file ScsiBus.c.

Function Documentation

◆ AllocateAlignedBuffer()

VOID * AllocateAlignedBuffer ( IN SCSI_IO_DEV ScsiIoDevice,
IN UINTN  BufferSize 
)

Allocates an aligned buffer for SCSI device.

This function allocates an aligned buffer for the SCSI device to perform SCSI pass through operations. The alignment requirement is from SCSI pass through interface.

Parameters
ScsiIoDeviceThe SCSI child device involved for the operation.
BufferSizeThe request buffer size.
Returns
A pointer to the aligned buffer or NULL if the allocation fails.

Definition at line 82 of file ScsiBus.c.

◆ DiscoverScsiDevice()

EFI_STATUS DiscoverScsiDevice ( IN OUT SCSI_IO_DEV ScsiIoDevice)

Discovery SCSI Device

Parameters
ScsiIoDeviceThe pointer of SCSI_IO_DEV
Return values
EFI_SUCCESSFind SCSI Device and verify it.
EFI_NOT_FOUNDUnable to find SCSI Device.
EFI_OUT_OF_RESOURCESFail to allocate memory resources.

Definition at line 1286 of file ScsiBus.c.

◆ FreeAlignedBuffer()

VOID FreeAlignedBuffer ( IN VOID *  Buffer,
IN UINTN  BufferSize 
)

Frees an aligned buffer for SCSI device.

This function frees an aligned buffer for the SCSI device to perform SCSI pass through operations.

Parameters
BufferThe aligned buffer to be freed.
BufferSizeThe request buffer size.

Definition at line 101 of file ScsiBus.c.

◆ InitializeScsiBus()

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

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

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.
otherSome error occurs when executing this entry point.

Definition at line 123 of file ScsiBus.c.

◆ NotifyFunction()

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

Notify Function in which convert EFI1.0 PassThru Packet back to UEF2.0 SCSI IO Packet.

Parameters
EventThe instance of EFI_EVENT.
ContextThe parameter passed in.

Definition at line 1492 of file ScsiBus.c.

◆ PassThruToScsiioPacket()

EFI_STATUS EFIAPI PassThruToScsiioPacket ( IN EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET ScsiPacket,
OUT EFI_SCSI_IO_SCSI_REQUEST_PACKET Packet 
)

Convert EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET packet to EFI_SCSI_IO_SCSI_REQUEST_PACKET packet.

Parameters
ScsiPacketThe pointer of EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
PacketThe pointer of EFI_SCSI_IO_SCSI_REQUEST_PACKET

Definition at line 1457 of file ScsiBus.c.

◆ SCSIBusDriverBindingStart()

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

Start this driver on ControllerHandle.

This service is called by the EFI boot service ConnectController(). In order to make drivers as small as possible, there are a few calling restrictions for this service. ConnectController() must follow these calling restrictions. If any other agent wishes to call Start() it must also follow these calling restrictions.

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 294 of file ScsiBus.c.

◆ SCSIBusDriverBindingStop()

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

Stop this driver on ControllerHandle.

This service is called by the EFI boot service DisconnectController(). In order to make drivers as small as possible, there are a few calling restrictions for this service. DisconnectController() must follow these calling restrictions. If any other agent wishes to call Stop() it must also follow these calling restrictions.

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 597 of file ScsiBus.c.

◆ SCSIBusDriverBindingSupported()

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

Test to see if this driver supports ControllerHandle.

This service is called by the EFI boot service ConnectController(). In order to make drivers as small as possible, there are a few calling restrictions for this service. ConnectController() must follow these calling restrictions. If any other agent wishes to call Supported() it must also follow these calling restrictions.

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 167 of file ScsiBus.c.

◆ ScsiExecuteSCSICommand()

EFI_STATUS EFIAPI ScsiExecuteSCSICommand ( IN EFI_SCSI_IO_PROTOCOL This,
IN OUT EFI_SCSI_IO_SCSI_REQUEST_PACKET Packet,
IN EFI_EVENT Event  OPTIONAL 
)

Sends a SCSI Request Packet to the SCSI Controller for execution.

Parameters
ThisProtocol instance pointer.
CommandPacketThe SCSI request packet to send to the SCSI Controller specified by the device handle.
EventIf the SCSI bus where the SCSI device is attached does not support non-blocking I/O, then Event is ignored, and blocking I/O is performed. 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 SCSI Request Packet completes.
Return values
EFI_SUCCESSThe SCSI Request Packet was sent by the host successfully, and TransferLength bytes were transferred to/from DataBuffer.See HostAdapterStatus, TargetStatus, SenseDataLength, and SenseData in that order for additional status information.
EFI_BAD_BUFFER_SIZEThe SCSI Request Packet was executed, but the entire DataBuffer could not be transferred. The actual number of bytes transferred is returned in TransferLength. See HostAdapterStatus, TargetStatus, SenseDataLength, and SenseData in that order for additional status information.
EFI_NOT_READYThe SCSI Request Packet could not be sent because there are too many SCSI Command Packets already queued.The caller may retry again later.
EFI_DEVICE_ERRORA device error occurred while attempting to send the SCSI Request Packet. See HostAdapterStatus, TargetStatus, SenseDataLength, and SenseData in that order for additional status information.
EFI_INVALID_PARAMETERThe contents of CommandPacket are invalid. The SCSI Request Packet was not sent, so no additional status information is available.
EFI_UNSUPPORTEDThe command described by the SCSI Request Packet is not supported by the SCSI initiator(i.e., SCSI Host Controller). The SCSI Request Packet was not sent, so no additional status information is available.
EFI_TIMEOUTA timeout occurred while waiting for the SCSI Request Packet to execute. See HostAdapterStatus, TargetStatus, SenseDataLength, and SenseData in that order for additional status information.

Definition at line 961 of file ScsiBus.c.

◆ ScsiGetDeviceLocation()

EFI_STATUS EFIAPI ScsiGetDeviceLocation ( IN EFI_SCSI_IO_PROTOCOL This,
IN OUT UINT8 **  Target,
OUT UINT64 *  Lun 
)

Retrieves the device location in the SCSI channel.

Parameters
ThisProtocol instance pointer.
TargetA pointer to the Target ID of a SCSI device on the SCSI channel.
LunA pointer to the LUN of the SCSI device on the SCSI channel.
Return values
EFI_SUCCESSRetrieves the device location successfully.
EFI_INVALID_PARAMETERThe Target or Lun is NULL.

Definition at line 805 of file ScsiBus.c.

◆ ScsiGetDeviceType()

EFI_STATUS EFIAPI ScsiGetDeviceType ( IN EFI_SCSI_IO_PROTOCOL This,
OUT UINT8 *  DeviceType 
)

Retrieves the device type information of the SCSI Controller.

Parameters
ThisProtocol instance pointer.
DeviceTypeA pointer to the device type information retrieved from the SCSI Controller.
Return values
EFI_SUCCESSRetrieves the device type information successfully.
EFI_INVALID_PARAMETERThe DeviceType is NULL.

Definition at line 774 of file ScsiBus.c.

◆ ScsiioToPassThruPacket()

EFI_STATUS EFIAPI ScsiioToPassThruPacket ( IN EFI_SCSI_IO_SCSI_REQUEST_PACKET Packet,
OUT EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET CommandPacket 
)

Convert EFI_SCSI_IO_SCSI_REQUEST_PACKET packet to EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET packet.

Parameters
PacketThe pointer of EFI_SCSI_IO_SCSI_REQUEST_PACKET
CommandPacketThe pointer of EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET

Definition at line 1414 of file ScsiBus.c.

◆ ScsiResetBus()

EFI_STATUS EFIAPI ScsiResetBus ( IN EFI_SCSI_IO_PROTOCOL This)

Resets the SCSI Bus that the SCSI Controller is attached to.

Parameters
ThisProtocol instance pointer.
Return values
EFI_SUCCESSThe SCSI bus is reset successfully.
EFI_DEVICE_ERRORErrors encountered when resetting the SCSI bus.
EFI_UNSUPPORTEDThe bus reset operation is not supported by the SCSI Host Controller.
EFI_TIMEOUTA timeout occurred while attempting to reset the SCSI bus.

Definition at line 840 of file ScsiBus.c.

◆ ScsiResetDevice()

EFI_STATUS EFIAPI ScsiResetDevice ( IN EFI_SCSI_IO_PROTOCOL This)

Resets the SCSI Controller that the device handle specifies.

Parameters
ThisProtocol instance pointer.
Return values
EFI_SUCCESSReset the SCSI controller successfully.
EFI_DEVICE_ERRORErrors are encountered when resetting the SCSI Controller.
EFI_UNSUPPORTEDThe SCSI bus does not support a device reset operation.
EFI_TIMEOUTA timeout occurred while attempting to reset the SCSI Controller.

Definition at line 877 of file ScsiBus.c.

◆ ScsiScanCreateDevice()

EFI_STATUS EFIAPI ScsiScanCreateDevice ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  Controller,
IN SCSI_TARGET_ID TargetId,
IN UINT64  Lun,
IN OUT SCSI_BUS_DEVICE ScsiBusDev 
)

Scan SCSI Bus to discover the device, and attach ScsiIoProtocol to it.

Parameters
ThisProtocol instance pointer
ControllerController handle
TargetIdTarget to be scanned
LunThe Lun of the SCSI device on the SCSI channel.
ScsiBusDevThe pointer of SCSI_BUS_DEVICE
Return values
EFI_SUCCESSSuccessfully to discover the device and attach ScsiIoProtocol to it.
EFI_NOT_FOUNDFail to discover the device.
EFI_OUT_OF_RESOURCESFail to allocate memory resources.

Definition at line 1114 of file ScsiBus.c.

Variable Documentation

◆ gSCSIBusDriverBinding

EFI_DRIVER_BINDING_PROTOCOL gSCSIBusDriverBinding
Initial value:
= {
0xa,
}
#define NULL
Definition: Base.h:319
EFI_STATUS EFIAPI SCSIBusDriverBindingStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: ScsiBus.c:294
EFI_STATUS EFIAPI SCSIBusDriverBindingStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
Definition: ScsiBus.c:597
EFI_STATUS EFIAPI SCSIBusDriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: ScsiBus.c:167

Definition at line 14 of file ScsiBus.c.

◆ mWorkingBuffer

VOID* mWorkingBuffer

Definition at line 23 of file ScsiBus.c.