LsiScsi.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. /** @file
  2. Internal definitions for the LSI 53C895A SCSI driver, which produces
  3. Extended SCSI Pass Thru Protocol instances for LSI 53C895A SCSI devices.
  4. Copyright (C) 2020, SUSE LLC.
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #ifndef _LSI_SCSI_DXE_H_
  8. #define _LSI_SCSI_DXE_H_
  9. typedef struct {
  10. //
  11. // Allocate 32 UINT32 entries for the script and it's sufficient for
  12. // 16 instructions.
  13. //
  14. UINT32 Script[32];
  15. //
  16. // The max size of CDB is 32.
  17. //
  18. UINT8 Cdb[32];
  19. //
  20. // Allocate 64KB for read/write buffer. It seems sufficient for the common
  21. // boot scenarios.
  22. //
  23. // NOTE: The number of bytes for data transmission is bounded by DMA Byte
  24. // Count (DBC), a 24-bit register, so the maximum is 0xFFFFFF (16MB-1).
  25. //
  26. UINT8 Data[SIZE_64KB];
  27. //
  28. // For SCSI Message In phase
  29. //
  30. UINT8 MsgIn[2];
  31. //
  32. // For SCSI Message Out phase
  33. //
  34. UINT8 MsgOut;
  35. //
  36. // For SCSI Status phase
  37. //
  38. UINT8 Status;
  39. } LSI_SCSI_DMA_BUFFER;
  40. typedef struct {
  41. UINT32 Signature;
  42. UINT64 OrigPciAttrs;
  43. EFI_EVENT ExitBoot;
  44. EFI_PCI_IO_PROTOCOL *PciIo;
  45. UINT8 MaxTarget;
  46. UINT8 MaxLun;
  47. UINT32 StallPerPollUsec;
  48. LSI_SCSI_DMA_BUFFER *Dma;
  49. EFI_PHYSICAL_ADDRESS DmaPhysical;
  50. VOID *DmaMapping;
  51. EFI_EXT_SCSI_PASS_THRU_MODE PassThruMode;
  52. EFI_EXT_SCSI_PASS_THRU_PROTOCOL PassThru;
  53. } LSI_SCSI_DEV;
  54. #define LSI_SCSI_DEV_SIGNATURE SIGNATURE_32 ('L','S','I','S')
  55. #define LSI_SCSI_FROM_PASS_THRU(PassThruPtr) \
  56. CR (PassThruPtr, LSI_SCSI_DEV, PassThru, LSI_SCSI_DEV_SIGNATURE)
  57. #define LSI_SCSI_DMA_ADDR(Dev, MemberName) \
  58. ((UINT32)(Dev->DmaPhysical + OFFSET_OF (LSI_SCSI_DMA_BUFFER, MemberName)))
  59. //
  60. // Probe, start and stop functions of this driver, called by the DXE core for
  61. // specific devices.
  62. //
  63. // The following specifications document these interfaces:
  64. // - Driver Writer's Guide for UEFI 2.3.1 v1.01, 9 Driver Binding Protocol
  65. // - UEFI Spec 2.3.1 + Errata C, 10.1 EFI Driver Binding Protocol
  66. //
  67. EFI_STATUS
  68. EFIAPI
  69. LsiScsiControllerSupported (
  70. IN EFI_DRIVER_BINDING_PROTOCOL *This,
  71. IN EFI_HANDLE ControllerHandle,
  72. IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
  73. );
  74. EFI_STATUS
  75. EFIAPI
  76. LsiScsiControllerStart (
  77. IN EFI_DRIVER_BINDING_PROTOCOL *This,
  78. IN EFI_HANDLE ControllerHandle,
  79. IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
  80. );
  81. EFI_STATUS
  82. EFIAPI
  83. LsiScsiControllerStop (
  84. IN EFI_DRIVER_BINDING_PROTOCOL *This,
  85. IN EFI_HANDLE ControllerHandle,
  86. IN UINTN NumberOfChildren,
  87. IN EFI_HANDLE *ChildHandleBuffer
  88. );
  89. //
  90. // The next seven functions implement EFI_EXT_SCSI_PASS_THRU_PROTOCOL
  91. // for the LSI 53C895A SCSI Controller. Refer to UEFI Spec 2.3.1 + Errata C,
  92. // sections
  93. // - 14.1 SCSI Driver Model Overview,
  94. // - 14.7 Extended SCSI Pass Thru Protocol.
  95. //
  96. EFI_STATUS
  97. EFIAPI
  98. LsiScsiPassThru (
  99. IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
  100. IN UINT8 *Target,
  101. IN UINT64 Lun,
  102. IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,
  103. IN EFI_EVENT Event OPTIONAL
  104. );
  105. EFI_STATUS
  106. EFIAPI
  107. LsiScsiGetNextTargetLun (
  108. IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
  109. IN OUT UINT8 **TargetPointer,
  110. IN OUT UINT64 *Lun
  111. );
  112. EFI_STATUS
  113. EFIAPI
  114. LsiScsiBuildDevicePath (
  115. IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
  116. IN UINT8 *Target,
  117. IN UINT64 Lun,
  118. IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
  119. );
  120. EFI_STATUS
  121. EFIAPI
  122. LsiScsiGetTargetLun (
  123. IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
  124. IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
  125. OUT UINT8 **TargetPointer,
  126. OUT UINT64 *Lun
  127. );
  128. EFI_STATUS
  129. EFIAPI
  130. LsiScsiResetChannel (
  131. IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This
  132. );
  133. EFI_STATUS
  134. EFIAPI
  135. LsiScsiResetTargetLun (
  136. IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
  137. IN UINT8 *Target,
  138. IN UINT64 Lun
  139. );
  140. EFI_STATUS
  141. EFIAPI
  142. LsiScsiGetNextTarget (
  143. IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
  144. IN OUT UINT8 **TargetPointer
  145. );
  146. //
  147. // The purpose of the following scaffolding (EFI_COMPONENT_NAME_PROTOCOL and
  148. // EFI_COMPONENT_NAME2_PROTOCOL implementation) is to format the driver's name
  149. // in English, for display on standard console devices. This is recommended for
  150. // UEFI drivers that follow the UEFI Driver Model. Refer to the Driver Writer's
  151. // Guide for UEFI 2.3.1 v1.01, 11 UEFI Driver and Controller Names.
  152. //
  153. // Device type names ("LSI 53C895A SCSI Controller") are not formatted because
  154. // the driver supports only that device type. Therefore the driver name
  155. // suffices for unambiguous identification.
  156. //
  157. EFI_STATUS
  158. EFIAPI
  159. LsiScsiGetDriverName (
  160. IN EFI_COMPONENT_NAME_PROTOCOL *This,
  161. IN CHAR8 *Language,
  162. OUT CHAR16 **DriverName
  163. );
  164. EFI_STATUS
  165. EFIAPI
  166. LsiScsiGetDeviceName (
  167. IN EFI_COMPONENT_NAME_PROTOCOL *This,
  168. IN EFI_HANDLE DeviceHandle,
  169. IN EFI_HANDLE ChildHandle,
  170. IN CHAR8 *Language,
  171. OUT CHAR16 **ControllerName
  172. );
  173. #endif // _LSI_SCSI_DXE_H_