diff options
Diffstat (limited to 'OvmfPkg/MptScsiDxe/MptScsi.c')
-rw-r--r-- | OvmfPkg/MptScsiDxe/MptScsi.c | 447 |
1 files changed, 230 insertions, 217 deletions
diff --git a/OvmfPkg/MptScsiDxe/MptScsi.c b/OvmfPkg/MptScsiDxe/MptScsi.c index 9ed1831bac..f64ccec24d 100644 --- a/OvmfPkg/MptScsiDxe/MptScsi.c +++ b/OvmfPkg/MptScsiDxe/MptScsi.c @@ -27,43 +27,43 @@ // Higher versions will be used before lower, 0x10-0xffffffef is the version
// range for IVH (Indie Hardware Vendors)
//
-#define MPT_SCSI_BINDING_VERSION 0x10
+#define MPT_SCSI_BINDING_VERSION 0x10
//
// Runtime Structures
//
typedef struct {
- MPT_SCSI_REQUEST_ALIGNED IoRequest;
- MPT_SCSI_IO_REPLY_ALIGNED IoReply;
+ MPT_SCSI_REQUEST_ALIGNED IoRequest;
+ MPT_SCSI_IO_REPLY_ALIGNED IoReply;
//
// As EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET.SenseDataLength is defined
// as UINT8, defining here SenseData size to MAX_UINT8 will guarantee it
// cannot overflow when passed to device.
//
- UINT8 Sense[MAX_UINT8];
+ UINT8 Sense[MAX_UINT8];
//
// This size of the data is arbitrarily chosen.
// It seems to be sufficient for all I/O requests sent through
// EFI_SCSI_PASS_THRU_PROTOCOL.PassThru() for common boot scenarios.
//
- UINT8 Data[0x2000];
+ UINT8 Data[0x2000];
} MPT_SCSI_DMA_BUFFER;
-#define MPT_SCSI_DEV_SIGNATURE SIGNATURE_32 ('M','P','T','S')
+#define MPT_SCSI_DEV_SIGNATURE SIGNATURE_32 ('M','P','T','S')
typedef struct {
- UINT32 Signature;
- EFI_EXT_SCSI_PASS_THRU_PROTOCOL PassThru;
- EFI_EXT_SCSI_PASS_THRU_MODE PassThruMode;
- UINT8 MaxTarget;
- UINT32 StallPerPollUsec;
- EFI_PCI_IO_PROTOCOL *PciIo;
- UINT64 OriginalPciAttributes;
- EFI_EVENT ExitBoot;
- MPT_SCSI_DMA_BUFFER *Dma;
- EFI_PHYSICAL_ADDRESS DmaPhysical;
- VOID *DmaMapping;
- BOOLEAN IoReplyEnqueued;
+ UINT32 Signature;
+ EFI_EXT_SCSI_PASS_THRU_PROTOCOL PassThru;
+ EFI_EXT_SCSI_PASS_THRU_MODE PassThruMode;
+ UINT8 MaxTarget;
+ UINT32 StallPerPollUsec;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ UINT64 OriginalPciAttributes;
+ EFI_EVENT ExitBoot;
+ MPT_SCSI_DMA_BUFFER *Dma;
+ EFI_PHYSICAL_ADDRESS DmaPhysical;
+ VOID *DmaMapping;
+ BOOLEAN IoReplyEnqueued;
} MPT_SCSI_DEV;
#define MPT_SCSI_FROM_PASS_THRU(PassThruPtr) \
@@ -85,9 +85,9 @@ typedef struct { STATIC
EFI_STATUS
Out32 (
- IN MPT_SCSI_DEV *Dev,
- IN UINT32 Addr,
- IN UINT32 Data
+ IN MPT_SCSI_DEV *Dev,
+ IN UINT32 Addr,
+ IN UINT32 Data
)
{
return Dev->PciIo->Io.Write (
@@ -103,9 +103,9 @@ Out32 ( STATIC
EFI_STATUS
In32 (
- IN MPT_SCSI_DEV *Dev,
- IN UINT32 Addr,
- OUT UINT32 *Data
+ IN MPT_SCSI_DEV *Dev,
+ IN UINT32 Addr,
+ OUT UINT32 *Data
)
{
return Dev->PciIo->Io.Read (
@@ -121,9 +121,9 @@ In32 ( STATIC
EFI_STATUS
MptDoorbell (
- IN MPT_SCSI_DEV *Dev,
- IN UINT8 DoorbellFunc,
- IN UINT8 DoorbellArg
+ IN MPT_SCSI_DEV *Dev,
+ IN UINT8 DoorbellFunc,
+ IN UINT8 DoorbellArg
)
{
return Out32 (
@@ -136,10 +136,10 @@ MptDoorbell ( STATIC
EFI_STATUS
MptScsiReset (
- IN MPT_SCSI_DEV *Dev
+ IN MPT_SCSI_DEV *Dev
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Reset hardware
@@ -148,6 +148,7 @@ MptScsiReset ( if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Mask interrupts
//
@@ -155,6 +156,7 @@ MptScsiReset ( if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Clear interrupt status
//
@@ -169,18 +171,19 @@ MptScsiReset ( STATIC
EFI_STATUS
MptScsiInit (
- IN MPT_SCSI_DEV *Dev
+ IN MPT_SCSI_DEV *Dev
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
+
union {
- MPT_IO_CONTROLLER_INIT_REQUEST Data;
- UINT32 Uint32;
+ MPT_IO_CONTROLLER_INIT_REQUEST Data;
+ UINT32 Uint32;
} AlignedReq;
- MPT_IO_CONTROLLER_INIT_REQUEST *Req;
- MPT_IO_CONTROLLER_INIT_REPLY Reply;
- UINT8 *ReplyBytes;
- UINT32 ReplyWord;
+ MPT_IO_CONTROLLER_INIT_REQUEST *Req;
+ MPT_IO_CONTROLLER_INIT_REPLY Reply;
+ UINT8 *ReplyBytes;
+ UINT32 ReplyWord;
Req = &AlignedReq.Data;
@@ -191,16 +194,16 @@ MptScsiInit ( ZeroMem (Req, sizeof (*Req));
ZeroMem (&Reply, sizeof (Reply));
- Req->WhoInit = MPT_IOC_WHOINIT_ROM_BIOS;
+ Req->WhoInit = MPT_IOC_WHOINIT_ROM_BIOS;
Req->Function = MPT_MESSAGE_HDR_FUNCTION_IOC_INIT;
STATIC_ASSERT (
FixedPcdGet8 (PcdMptScsiMaxTargetLimit) < 255,
"Req supports 255 targets only (max target is 254)"
);
- Req->MaxDevices = Dev->MaxTarget + 1;
- Req->MaxBuses = 1;
- Req->ReplyFrameSize = sizeof Dev->Dma->IoReply.Data;
- Req->HostMfaHighAddr = MPT_SCSI_DMA_ADDR_HIGH (Dev, IoRequest);
+ Req->MaxDevices = Dev->MaxTarget + 1;
+ Req->MaxBuses = 1;
+ Req->ReplyFrameSize = sizeof Dev->Dma->IoReply.Data;
+ Req->HostMfaHighAddr = MPT_SCSI_DMA_ADDR_HIGH (Dev, IoRequest);
Req->SenseBufferHighAddr = MPT_SCSI_DMA_ADDR_HIGH (Dev, Sense);
//
@@ -222,6 +225,7 @@ MptScsiInit ( if (EFI_ERROR (Status)) {
return Status;
}
+
Status = Dev->PciIo->Io.Write (
Dev->PciIo,
EfiPciIoWidthFifoUint32,
@@ -252,6 +256,7 @@ MptScsiInit ( if (EFI_ERROR (Status)) {
return Status;
}
+
CopyMem (ReplyBytes, &ReplyWord, sizeof (UINT16));
ReplyBytes += sizeof (UINT16);
}
@@ -270,7 +275,7 @@ MptScsiInit ( STATIC
EFI_STATUS
ReportHostAdapterError (
- OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet
+ OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet
)
{
DEBUG ((DEBUG_ERROR, "%a: fatal error in scsi request\n", __FUNCTION__));
@@ -285,12 +290,12 @@ ReportHostAdapterError ( STATIC
EFI_STATUS
ReportHostAdapterOverrunError (
- OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet
+ OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet
)
{
- Packet->SenseDataLength = 0;
+ Packet->SenseDataLength = 0;
Packet->HostAdapterStatus =
- EFI_EXT_SCSI_STATUS_HOST_ADAPTER_DATA_OVERRUN_UNDERRUN;
+ EFI_EXT_SCSI_STATUS_HOST_ADAPTER_DATA_OVERRUN_UNDERRUN;
Packet->TargetStatus = EFI_EXT_SCSI_STATUS_TARGET_GOOD;
return EFI_BAD_BUFFER_SIZE;
}
@@ -298,44 +303,46 @@ ReportHostAdapterOverrunError ( STATIC
EFI_STATUS
MptScsiPopulateRequest (
- IN MPT_SCSI_DEV *Dev,
- IN UINT8 Target,
- IN UINT64 Lun,
- IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet
+ IN MPT_SCSI_DEV *Dev,
+ IN UINT8 Target,
+ IN UINT64 Lun,
+ IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet
)
{
- MPT_SCSI_REQUEST_WITH_SG *Request;
+ MPT_SCSI_REQUEST_WITH_SG *Request;
Request = &Dev->Dma->IoRequest.Data;
- if (Packet->DataDirection == EFI_EXT_SCSI_DATA_DIRECTION_BIDIRECTIONAL ||
- (Packet->InTransferLength > 0 && Packet->OutTransferLength > 0) ||
- Packet->CdbLength > sizeof (Request->Header.Cdb)) {
+ if ((Packet->DataDirection == EFI_EXT_SCSI_DATA_DIRECTION_BIDIRECTIONAL) ||
+ ((Packet->InTransferLength > 0) && (Packet->OutTransferLength > 0)) ||
+ (Packet->CdbLength > sizeof (Request->Header.Cdb)))
+ {
return EFI_UNSUPPORTED;
}
- if (Target > Dev->MaxTarget || Lun > 0 ||
- Packet->DataDirection > EFI_EXT_SCSI_DATA_DIRECTION_BIDIRECTIONAL ||
+ if ((Target > Dev->MaxTarget) || (Lun > 0) ||
+ (Packet->DataDirection > EFI_EXT_SCSI_DATA_DIRECTION_BIDIRECTIONAL) ||
//
// Trying to receive, but destination pointer is NULL, or contradicting
// transfer direction
//
- (Packet->InTransferLength > 0 &&
- (Packet->InDataBuffer == NULL ||
- Packet->DataDirection == EFI_EXT_SCSI_DATA_DIRECTION_WRITE
- )
- ) ||
+ ((Packet->InTransferLength > 0) &&
+ ((Packet->InDataBuffer == NULL) ||
+ (Packet->DataDirection == EFI_EXT_SCSI_DATA_DIRECTION_WRITE)
+ )
+ ) ||
//
// Trying to send, but source pointer is NULL, or contradicting transfer
// direction
//
- (Packet->OutTransferLength > 0 &&
- (Packet->OutDataBuffer == NULL ||
- Packet->DataDirection == EFI_EXT_SCSI_DATA_DIRECTION_READ
- )
- )
- ) {
+ ((Packet->OutTransferLength > 0) &&
+ ((Packet->OutDataBuffer == NULL) ||
+ (Packet->DataDirection == EFI_EXT_SCSI_DATA_DIRECTION_READ)
+ )
+ )
+ )
+ {
return EFI_INVALID_PARAMETER;
}
@@ -343,6 +350,7 @@ MptScsiPopulateRequest ( Packet->InTransferLength = sizeof (Dev->Dma->Data);
return ReportHostAdapterOverrunError (Packet);
}
+
if (Packet->OutTransferLength > sizeof (Dev->Dma->Data)) {
Packet->OutTransferLength = sizeof (Dev->Dma->Data);
return ReportHostAdapterOverrunError (Packet);
@@ -353,8 +361,8 @@ MptScsiPopulateRequest ( //
// Only LUN 0 is currently supported, hence the cast is safe
//
- Request->Header.Lun[1] = (UINT8)Lun;
- Request->Header.Function = MPT_MESSAGE_HDR_FUNCTION_SCSI_IO_REQUEST;
+ Request->Header.Lun[1] = (UINT8)Lun;
+ Request->Header.Function = MPT_MESSAGE_HDR_FUNCTION_SCSI_IO_REQUEST;
Request->Header.MessageContext = 1; // We handle one request at a time
Request->Header.CdbLength = Packet->CdbLength;
@@ -364,14 +372,14 @@ MptScsiPopulateRequest ( // SenseDataLength is UINT8, Sense[] is MAX_UINT8, so we can't overflow
//
ZeroMem (Dev->Dma->Sense, Packet->SenseDataLength);
- Request->Header.SenseBufferLength = Packet->SenseDataLength;
+ Request->Header.SenseBufferLength = Packet->SenseDataLength;
Request->Header.SenseBufferLowAddress = MPT_SCSI_DMA_ADDR_LOW (Dev, Sense);
- Request->Sg.EndOfList = 1;
- Request->Sg.EndOfBuffer = 1;
- Request->Sg.LastElement = 1;
- Request->Sg.ElementType = MPT_SG_ENTRY_TYPE_SIMPLE;
- Request->Sg.Is64BitAddress = 1;
+ Request->Sg.EndOfList = 1;
+ Request->Sg.EndOfBuffer = 1;
+ Request->Sg.LastElement = 1;
+ Request->Sg.ElementType = MPT_SG_ENTRY_TYPE_SIMPLE;
+ Request->Sg.Is64BitAddress = 1;
Request->Sg.DataBufferAddress = MPT_SCSI_DMA_ADDR (Dev, Data);
//
@@ -384,12 +392,12 @@ MptScsiPopulateRequest ( if (Packet->DataDirection == EFI_EXT_SCSI_DATA_DIRECTION_READ) {
Request->Header.DataLength = Packet->InTransferLength;
- Request->Sg.Length = Packet->InTransferLength;
- Request->Header.Control = MPT_SCSIIO_REQUEST_CONTROL_TXDIR_READ;
+ Request->Sg.Length = Packet->InTransferLength;
+ Request->Header.Control = MPT_SCSIIO_REQUEST_CONTROL_TXDIR_READ;
} else {
Request->Header.DataLength = Packet->OutTransferLength;
- Request->Sg.Length = Packet->OutTransferLength;
- Request->Header.Control = MPT_SCSIIO_REQUEST_CONTROL_TXDIR_WRITE;
+ Request->Sg.Length = Packet->OutTransferLength;
+ Request->Header.Control = MPT_SCSIIO_REQUEST_CONTROL_TXDIR_WRITE;
CopyMem (Dev->Dma->Data, Packet->OutDataBuffer, Packet->OutTransferLength);
Request->Sg.BufferContainsData = 1;
@@ -405,11 +413,11 @@ MptScsiPopulateRequest ( STATIC
EFI_STATUS
MptScsiSendRequest (
- IN MPT_SCSI_DEV *Dev,
- IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet
+ IN MPT_SCSI_DEV *Dev,
+ IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
if (!Dev->IoReplyEnqueued) {
//
@@ -420,6 +428,7 @@ MptScsiSendRequest ( if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
+
Dev->IoReplyEnqueued = TRUE;
}
@@ -434,19 +443,19 @@ MptScsiSendRequest ( STATIC
EFI_STATUS
MptScsiGetReply (
- IN MPT_SCSI_DEV *Dev,
- OUT UINT32 *Reply
+ IN MPT_SCSI_DEV *Dev,
+ OUT UINT32 *Reply
)
{
- EFI_STATUS Status;
- UINT32 Istatus;
- UINT32 EmptyReply;
+ EFI_STATUS Status;
+ UINT32 Istatus;
+ UINT32 EmptyReply;
//
// Timeouts are not supported for
// EFI_EXT_SCSI_PASS_THRU_PROTOCOL.PassThru() in this implementation.
//
- for (;;) {
+ for ( ; ;) {
Status = In32 (Dev, MPT_REG_ISTATUS, &Istatus);
if (EFI_ERROR (Status)) {
return Status;
@@ -473,7 +482,7 @@ MptScsiGetReply ( // next read reply to be the last.
//
Status = In32 (Dev, MPT_REG_REP_Q, &EmptyReply);
- if (EFI_ERROR (Status) || EmptyReply != MAX_UINT32) {
+ if (EFI_ERROR (Status) || (EmptyReply != MAX_UINT32)) {
return EFI_DEVICE_ERROR;
}
@@ -483,9 +492,9 @@ MptScsiGetReply ( STATIC
EFI_STATUS
MptScsiHandleReply (
- IN MPT_SCSI_DEV *Dev,
- IN UINT32 Reply,
- OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet
+ IN MPT_SCSI_DEV *Dev,
+ IN UINT32 Reply,
+ OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet
)
{
if (Packet->DataDirection == EFI_EXT_SCSI_DATA_DIRECTION_READ) {
@@ -496,10 +505,9 @@ MptScsiHandleReply ( //
// This is a turbo reply, everything is good
//
- Packet->SenseDataLength = 0;
+ Packet->SenseDataLength = 0;
Packet->HostAdapterStatus = EFI_EXT_SCSI_STATUS_HOST_ADAPTER_OK;
- Packet->TargetStatus = EFI_EXT_SCSI_STATUS_TARGET_GOOD;
-
+ Packet->TargetStatus = EFI_EXT_SCSI_STATUS_TARGET_GOOD;
} else if ((Reply & BIT31) != 0) {
DEBUG ((DEBUG_INFO, "%a: Full reply returned\n", __FUNCTION__));
//
@@ -524,23 +532,22 @@ MptScsiHandleReply ( }
switch (Dev->Dma->IoReply.Data.IocStatus) {
- case MPT_SCSI_IOCSTATUS_SUCCESS:
- Packet->HostAdapterStatus = EFI_EXT_SCSI_STATUS_HOST_ADAPTER_OK;
- break;
- case MPT_SCSI_IOCSTATUS_DEVICE_NOT_THERE:
- Packet->HostAdapterStatus =
- EFI_EXT_SCSI_STATUS_HOST_ADAPTER_SELECTION_TIMEOUT;
- return EFI_TIMEOUT;
- case MPT_SCSI_IOCSTATUS_DATA_UNDERRUN:
- case MPT_SCSI_IOCSTATUS_DATA_OVERRUN:
- Packet->HostAdapterStatus =
- EFI_EXT_SCSI_STATUS_HOST_ADAPTER_DATA_OVERRUN_UNDERRUN;
- break;
- default:
- Packet->HostAdapterStatus = EFI_EXT_SCSI_STATUS_HOST_ADAPTER_OTHER;
- return EFI_DEVICE_ERROR;
+ case MPT_SCSI_IOCSTATUS_SUCCESS:
+ Packet->HostAdapterStatus = EFI_EXT_SCSI_STATUS_HOST_ADAPTER_OK;
+ break;
+ case MPT_SCSI_IOCSTATUS_DEVICE_NOT_THERE:
+ Packet->HostAdapterStatus =
+ EFI_EXT_SCSI_STATUS_HOST_ADAPTER_SELECTION_TIMEOUT;
+ return EFI_TIMEOUT;
+ case MPT_SCSI_IOCSTATUS_DATA_UNDERRUN:
+ case MPT_SCSI_IOCSTATUS_DATA_OVERRUN:
+ Packet->HostAdapterStatus =
+ EFI_EXT_SCSI_STATUS_HOST_ADAPTER_DATA_OVERRUN_UNDERRUN;
+ break;
+ default:
+ Packet->HostAdapterStatus = EFI_EXT_SCSI_STATUS_HOST_ADAPTER_OTHER;
+ return EFI_DEVICE_ERROR;
}
-
} else {
DEBUG ((DEBUG_ERROR, "%a: unexpected reply (%x)\n", __FUNCTION__, Reply));
return ReportHostAdapterError (Packet);
@@ -557,16 +564,16 @@ STATIC EFI_STATUS
EFIAPI
MptScsiPassThru (
- IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
- IN UINT8 *Target,
- IN UINT64 Lun,
- IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,
- IN EFI_EVENT Event OPTIONAL
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN UINT8 *Target,
+ IN UINT64 Lun,
+ IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,
+ IN EFI_EVENT Event OPTIONAL
)
{
- EFI_STATUS Status;
- MPT_SCSI_DEV *Dev;
- UINT32 Reply;
+ EFI_STATUS Status;
+ MPT_SCSI_DEV *Dev;
+ UINT32 Reply;
Dev = MPT_SCSI_FROM_PASS_THRU (This);
//
@@ -596,16 +603,17 @@ MptScsiPassThru ( STATIC
BOOLEAN
IsTargetInitialized (
- IN UINT8 *Target
+ IN UINT8 *Target
)
{
- UINTN Idx;
+ UINTN Idx;
for (Idx = 0; Idx < TARGET_MAX_BYTES; ++Idx) {
if (Target[Idx] != 0xFF) {
return TRUE;
}
}
+
return FALSE;
}
@@ -613,12 +621,12 @@ STATIC EFI_STATUS
EFIAPI
MptScsiGetNextTargetLun (
- IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
- IN OUT UINT8 **Target,
- IN OUT UINT64 *Lun
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN OUT UINT8 **Target,
+ IN OUT UINT64 *Lun
)
{
- MPT_SCSI_DEV *Dev;
+ MPT_SCSI_DEV *Dev;
Dev = MPT_SCSI_FROM_PASS_THRU (This);
//
@@ -627,7 +635,7 @@ MptScsiGetNextTargetLun ( if (!IsTargetInitialized (*Target)) {
ZeroMem (*Target, TARGET_MAX_BYTES);
*Lun = 0;
- } else if (**Target > Dev->MaxTarget || *Lun > 0) {
+ } else if ((**Target > Dev->MaxTarget) || (*Lun > 0)) {
return EFI_INVALID_PARAMETER;
} else if (**Target < Dev->MaxTarget) {
//
@@ -646,11 +654,11 @@ STATIC EFI_STATUS
EFIAPI
MptScsiGetNextTarget (
- IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
- IN OUT UINT8 **Target
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN OUT UINT8 **Target
)
{
- MPT_SCSI_DEV *Dev;
+ MPT_SCSI_DEV *Dev;
Dev = MPT_SCSI_FROM_PASS_THRU (This);
if (!IsTargetInitialized (*Target)) {
@@ -674,14 +682,14 @@ STATIC EFI_STATUS
EFIAPI
MptScsiBuildDevicePath (
- IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
- IN UINT8 *Target,
- IN UINT64 Lun,
- IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN UINT8 *Target,
+ IN UINT64 Lun,
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
)
{
- MPT_SCSI_DEV *Dev;
- SCSI_DEVICE_PATH *ScsiDevicePath;
+ MPT_SCSI_DEV *Dev;
+ SCSI_DEVICE_PATH *ScsiDevicePath;
if (DevicePath == NULL) {
return EFI_INVALID_PARAMETER;
@@ -692,7 +700,7 @@ MptScsiBuildDevicePath ( // the LSB of Target.
//
Dev = MPT_SCSI_FROM_PASS_THRU (This);
- if (*Target > Dev->MaxTarget || Lun > 0) {
+ if ((*Target > Dev->MaxTarget) || (Lun > 0)) {
return EFI_NOT_FOUND;
}
@@ -716,29 +724,32 @@ STATIC EFI_STATUS
EFIAPI
MptScsiGetTargetLun (
- IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- OUT UINT8 **Target,
- OUT UINT64 *Lun
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ OUT UINT8 **Target,
+ OUT UINT64 *Lun
)
{
- MPT_SCSI_DEV *Dev;
- SCSI_DEVICE_PATH *ScsiDevicePath;
+ MPT_SCSI_DEV *Dev;
+ SCSI_DEVICE_PATH *ScsiDevicePath;
- if (DevicePath == NULL ||
- Target == NULL || *Target == NULL || Lun == NULL) {
+ if ((DevicePath == NULL) ||
+ (Target == NULL) || (*Target == NULL) || (Lun == NULL))
+ {
return EFI_INVALID_PARAMETER;
}
- if (DevicePath->Type != MESSAGING_DEVICE_PATH ||
- DevicePath->SubType != MSG_SCSI_DP) {
+ if ((DevicePath->Type != MESSAGING_DEVICE_PATH) ||
+ (DevicePath->SubType != MSG_SCSI_DP))
+ {
return EFI_UNSUPPORTED;
}
- Dev = MPT_SCSI_FROM_PASS_THRU (This);
+ Dev = MPT_SCSI_FROM_PASS_THRU (This);
ScsiDevicePath = (SCSI_DEVICE_PATH *)DevicePath;
- if (ScsiDevicePath->Pun > Dev->MaxTarget ||
- ScsiDevicePath->Lun > 0) {
+ if ((ScsiDevicePath->Pun > Dev->MaxTarget) ||
+ (ScsiDevicePath->Lun > 0))
+ {
return EFI_NOT_FOUND;
}
@@ -748,7 +759,7 @@ MptScsiGetTargetLun ( // of Target.
//
**Target = (UINT8)ScsiDevicePath->Pun;
- *Lun = ScsiDevicePath->Lun;
+ *Lun = ScsiDevicePath->Lun;
return EFI_SUCCESS;
}
@@ -757,7 +768,7 @@ STATIC EFI_STATUS
EFIAPI
MptScsiResetChannel (
- IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This
)
{
return EFI_UNSUPPORTED;
@@ -767,23 +778,24 @@ STATIC VOID
EFIAPI
MptScsiExitBoot (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- MPT_SCSI_DEV *Dev;
+ MPT_SCSI_DEV *Dev;
Dev = Context;
DEBUG ((DEBUG_VERBOSE, "%a: Context=0x%p\n", __FUNCTION__, Context));
MptScsiReset (Dev);
}
+
STATIC
EFI_STATUS
EFIAPI
MptScsiResetTargetLun (
- IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
- IN UINT8 *Target,
- IN UINT64 Lun
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN UINT8 *Target,
+ IN UINT64 Lun
)
{
return EFI_UNSUPPORTED;
@@ -797,14 +809,14 @@ STATIC EFI_STATUS
EFIAPI
MptScsiControllerSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
{
- EFI_STATUS Status;
- EFI_PCI_IO_PROTOCOL *PciIo;
- PCI_TYPE00 Pci;
+ EFI_STATUS Status;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ PCI_TYPE00 Pci;
Status = gBS->OpenProtocol (
ControllerHandle,
@@ -829,10 +841,11 @@ MptScsiControllerSupported ( goto Done;
}
- if (Pci.Hdr.VendorId == LSI_LOGIC_PCI_VENDOR_ID &&
- (Pci.Hdr.DeviceId == LSI_53C1030_PCI_DEVICE_ID ||
- Pci.Hdr.DeviceId == LSI_SAS1068_PCI_DEVICE_ID ||
- Pci.Hdr.DeviceId == LSI_SAS1068E_PCI_DEVICE_ID)) {
+ if ((Pci.Hdr.VendorId == LSI_LOGIC_PCI_VENDOR_ID) &&
+ ((Pci.Hdr.DeviceId == LSI_53C1030_PCI_DEVICE_ID) ||
+ (Pci.Hdr.DeviceId == LSI_SAS1068_PCI_DEVICE_ID) ||
+ (Pci.Hdr.DeviceId == LSI_SAS1068E_PCI_DEVICE_ID)))
+ {
Status = EFI_SUCCESS;
} else {
Status = EFI_UNSUPPORTED;
@@ -852,15 +865,15 @@ STATIC EFI_STATUS
EFIAPI
MptScsiControllerStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
{
- EFI_STATUS Status;
- MPT_SCSI_DEV *Dev;
- UINTN Pages;
- UINTN BytesMapped;
+ EFI_STATUS Status;
+ MPT_SCSI_DEV *Dev;
+ UINTN Pages;
+ UINTN BytesMapped;
Dev = AllocateZeroPool (sizeof (*Dev));
if (Dev == NULL) {
@@ -869,7 +882,7 @@ MptScsiControllerStart ( Dev->Signature = MPT_SCSI_DEV_SIGNATURE;
- Dev->MaxTarget = PcdGet8 (PcdMptScsiMaxTargetLimit);
+ Dev->MaxTarget = PcdGet8 (PcdMptScsiMaxTargetLimit);
Dev->StallPerPollUsec = PcdGet32 (PcdMptScsiStallPerPollUsec);
Status = gBS->OpenProtocol (
@@ -934,7 +947,7 @@ MptScsiControllerStart ( //
// Create buffers for data transfer
//
- Pages = EFI_SIZE_TO_PAGES (sizeof (*Dev->Dma));
+ Pages = EFI_SIZE_TO_PAGES (sizeof (*Dev->Dma));
Status = Dev->PciIo->AllocateBuffer (
Dev->PciIo,
AllocateAnyPages,
@@ -948,14 +961,14 @@ MptScsiControllerStart ( }
BytesMapped = EFI_PAGES_TO_SIZE (Pages);
- Status = Dev->PciIo->Map (
- Dev->PciIo,
- EfiPciIoOperationBusMasterCommonBuffer,
- Dev->Dma,
- &BytesMapped,
- &Dev->DmaPhysical,
- &Dev->DmaMapping
- );
+ Status = Dev->PciIo->Map (
+ Dev->PciIo,
+ EfiPciIoOperationBusMasterCommonBuffer,
+ Dev->Dma,
+ &BytesMapped,
+ &Dev->DmaPhysical,
+ &Dev->DmaMapping
+ );
if (EFI_ERROR (Status)) {
goto FreeBuffer;
}
@@ -984,19 +997,19 @@ MptScsiControllerStart ( //
// Host adapter channel, doesn't exist
//
- Dev->PassThruMode.AdapterId = MAX_UINT32;
+ Dev->PassThruMode.AdapterId = MAX_UINT32;
Dev->PassThruMode.Attributes =
EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_PHYSICAL |
EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_LOGICAL;
- Dev->PassThru.Mode = &Dev->PassThruMode;
- Dev->PassThru.PassThru = &MptScsiPassThru;
+ Dev->PassThru.Mode = &Dev->PassThruMode;
+ Dev->PassThru.PassThru = &MptScsiPassThru;
Dev->PassThru.GetNextTargetLun = &MptScsiGetNextTargetLun;
- Dev->PassThru.BuildDevicePath = &MptScsiBuildDevicePath;
- Dev->PassThru.GetTargetLun = &MptScsiGetTargetLun;
- Dev->PassThru.ResetChannel = &MptScsiResetChannel;
- Dev->PassThru.ResetTargetLun = &MptScsiResetTargetLun;
- Dev->PassThru.GetNextTarget = &MptScsiGetNextTarget;
+ Dev->PassThru.BuildDevicePath = &MptScsiBuildDevicePath;
+ Dev->PassThru.GetTargetLun = &MptScsiGetTargetLun;
+ Dev->PassThru.ResetChannel = &MptScsiResetChannel;
+ Dev->PassThru.ResetTargetLun = &MptScsiResetTargetLun;
+ Dev->PassThru.GetNextTarget = &MptScsiGetNextTarget;
Status = gBS->InstallProtocolInterface (
&ControllerHandle,
@@ -1055,15 +1068,15 @@ STATIC EFI_STATUS
EFIAPI
MptScsiControllerStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
)
{
- EFI_STATUS Status;
- EFI_EXT_SCSI_PASS_THRU_PROTOCOL *PassThru;
- MPT_SCSI_DEV *Dev;
+ EFI_STATUS Status;
+ EFI_EXT_SCSI_PASS_THRU_PROTOCOL *PassThru;
+ MPT_SCSI_DEV *Dev;
Status = gBS->OpenProtocol (
ControllerHandle,
@@ -1123,7 +1136,7 @@ MptScsiControllerStop ( }
STATIC
-EFI_DRIVER_BINDING_PROTOCOL mMptScsiDriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL mMptScsiDriverBinding = {
&MptScsiControllerSupported,
&MptScsiControllerStart,
&MptScsiControllerStop,
@@ -1137,20 +1150,20 @@ EFI_DRIVER_BINDING_PROTOCOL mMptScsiDriverBinding = { //
STATIC
-EFI_UNICODE_STRING_TABLE mDriverNameTable[] = {
+EFI_UNICODE_STRING_TABLE mDriverNameTable[] = {
{ "eng;en", L"LSI Fusion MPT SCSI Driver" },
- { NULL, NULL }
+ { NULL, NULL }
};
STATIC
-EFI_COMPONENT_NAME_PROTOCOL mComponentName;
+EFI_COMPONENT_NAME_PROTOCOL mComponentName;
EFI_STATUS
EFIAPI
MptScsiGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN CHAR8 *Language,
+ OUT CHAR16 **DriverName
)
{
return LookupUnicodeString2 (
@@ -1165,27 +1178,27 @@ MptScsiGetDriverName ( EFI_STATUS
EFIAPI
MptScsiGetDeviceName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE DeviceHandle,
- IN EFI_HANDLE ChildHandle,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE DeviceHandle,
+ IN EFI_HANDLE ChildHandle,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
)
{
return EFI_UNSUPPORTED;
}
STATIC
-EFI_COMPONENT_NAME_PROTOCOL mComponentName = {
+EFI_COMPONENT_NAME_PROTOCOL mComponentName = {
&MptScsiGetDriverName,
&MptScsiGetDeviceName,
"eng" // SupportedLanguages, ISO 639-2 language codes
};
STATIC
-EFI_COMPONENT_NAME2_PROTOCOL mComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) &MptScsiGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) &MptScsiGetDeviceName,
+EFI_COMPONENT_NAME2_PROTOCOL mComponentName2 = {
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)&MptScsiGetDriverName,
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)&MptScsiGetDeviceName,
"en" // SupportedLanguages, RFC 4646 language codes
};
@@ -1196,8 +1209,8 @@ EFI_COMPONENT_NAME2_PROTOCOL mComponentName2 = { EFI_STATUS
EFIAPI
MptScsiEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
return EfiLibInstallDriverBindingComponentName2 (
|