OvmfPkg/LsiScsiDxe: Process the SCSI Request Packet
This is the second part of LsiScsiPassThru(). LsiScsiProcessRequest() is added to translate the SCSI Request Packet into the LSI 53C895A commands. This function utilizes the so-called Script buffer to transmit a series of commands to the chip and then polls the DMA Status (DSTAT) register until the Scripts Interrupt Instruction Received (SIR) bit sets. Once the script is done, the SCSI Request Packet will be modified to reflect the result of the script. The Cumulative SCSI Byte Count (CSBC) register is fetched before and after the script to calculate the transferred bytes and update InTransferLength/OutTransferLength if necessary. v3: - Set DStat, SIst0, and SIst1 to 0 before using them - Amend the if statements for the DMA data instruction and add the assertions for the data direction - Also set SenseDataLength to 0 on the error path - Fix typos and amend comments - Amend the error handling of the calculation of transferred bytes v2: - Use the BITx macros for the most of LSI_* constants - Fix a typo: contorller => controller - Add SeaBIOS lsi-scsi driver as one of the references of the script - Cast the result of sizeof to UINT32 for the instructions of the script - Drop the backslashes - Replace LSI_SCSI_DMA_ADDR_LOW with LSI_SCSI_DMA_ADDR since we already removed DUAL_ADDRESS_CYCLE - Add more comments for the script - Fix the check of the script size at the end of the script - Always set SenseDataLength to 0 to avoid the caller to access SenseData - Improve the error handling in LsiScsiProcessRequest() Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Cc: Ard Biesheuvel <ard.biesheuvel@arm.com> Signed-off-by: Gary Lin <glin@suse.com> Message-Id: <20200717061130.8881-11-glin@suse.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
This commit is contained in:
@@ -13,6 +13,11 @@
|
||||
#define _LSI_SCSI_DXE_H_
|
||||
|
||||
typedef struct {
|
||||
//
|
||||
// Allocate 32 UINT32 entries for the script and it's sufficient for
|
||||
// 16 instructions.
|
||||
//
|
||||
UINT32 Script[32];
|
||||
//
|
||||
// The max size of CDB is 32.
|
||||
//
|
||||
@@ -25,6 +30,18 @@ typedef struct {
|
||||
// Count (DBC), a 24-bit register, so the maximum is 0xFFFFFF (16MB-1).
|
||||
//
|
||||
UINT8 Data[SIZE_64KB];
|
||||
//
|
||||
// For SCSI Message In phase
|
||||
//
|
||||
UINT8 MsgIn[2];
|
||||
//
|
||||
// For SCSI Message Out phase
|
||||
//
|
||||
UINT8 MsgOut;
|
||||
//
|
||||
// For SCSI Status phase
|
||||
//
|
||||
UINT8 Status;
|
||||
} LSI_SCSI_DMA_BUFFER;
|
||||
|
||||
typedef struct {
|
||||
@@ -34,6 +51,7 @@ typedef struct {
|
||||
EFI_PCI_IO_PROTOCOL *PciIo;
|
||||
UINT8 MaxTarget;
|
||||
UINT8 MaxLun;
|
||||
UINT32 StallPerPollUsec;
|
||||
LSI_SCSI_DMA_BUFFER *Dma;
|
||||
EFI_PHYSICAL_ADDRESS DmaPhysical;
|
||||
VOID *DmaMapping;
|
||||
@@ -46,6 +64,9 @@ typedef struct {
|
||||
#define LSI_SCSI_FROM_PASS_THRU(PassThruPtr) \
|
||||
CR (PassThruPtr, LSI_SCSI_DEV, PassThru, LSI_SCSI_DEV_SIGNATURE)
|
||||
|
||||
#define LSI_SCSI_DMA_ADDR(Dev, MemberName) \
|
||||
((UINT32)(Dev->DmaPhysical + OFFSET_OF (LSI_SCSI_DMA_BUFFER, MemberName)))
|
||||
|
||||
|
||||
//
|
||||
// Probe, start and stop functions of this driver, called by the DXE core for
|
||||
|
Reference in New Issue
Block a user