PvScsi.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /** @file
  2. Internal definitions for the PVSCSI driver, which produces Extended SCSI
  3. Pass Thru Protocol instances for pvscsi devices.
  4. Copyright (C) 2020, Oracle and/or its affiliates.
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #ifndef __PVSCSI_DXE_H_
  8. #define __PVSCSI_DXE_H_
  9. #include <Library/DebugLib.h>
  10. #include <Protocol/ScsiPassThruExt.h>
  11. typedef struct {
  12. EFI_PHYSICAL_ADDRESS DeviceAddress;
  13. VOID *Mapping;
  14. } PVSCSI_DMA_DESC;
  15. typedef struct {
  16. PVSCSI_RINGS_STATE *RingState;
  17. PVSCSI_DMA_DESC RingStateDmaDesc;
  18. PVSCSI_RING_REQ_DESC *RingReqs;
  19. PVSCSI_DMA_DESC RingReqsDmaDesc;
  20. PVSCSI_RING_CMP_DESC *RingCmps;
  21. PVSCSI_DMA_DESC RingCmpsDmaDesc;
  22. } PVSCSI_RING_DESC;
  23. typedef struct {
  24. //
  25. // As EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET.SenseDataLength is defined
  26. // as UINT8, defining here SenseData size to MAX_UINT8 will guarantee it
  27. // cannot overflow when passed to device.
  28. //
  29. UINT8 SenseData[MAX_UINT8];
  30. //
  31. // This size of the data is arbitrarily chosen.
  32. // It seems to be sufficient for all I/O requests sent through
  33. // EFI_SCSI_PASS_THRU_PROTOCOL.PassThru() for common boot scenarios.
  34. //
  35. UINT8 Data[0x2000];
  36. } PVSCSI_DMA_BUFFER;
  37. #define PVSCSI_SIG SIGNATURE_32 ('P', 'S', 'C', 'S')
  38. typedef struct {
  39. UINT32 Signature;
  40. EFI_PCI_IO_PROTOCOL *PciIo;
  41. EFI_EVENT ExitBoot;
  42. UINT64 OriginalPciAttributes;
  43. PVSCSI_RING_DESC RingDesc;
  44. PVSCSI_DMA_BUFFER *DmaBuf;
  45. PVSCSI_DMA_DESC DmaBufDmaDesc;
  46. UINT8 MaxTarget;
  47. UINT8 MaxLun;
  48. UINTN WaitForCmpStallInUsecs;
  49. EFI_EXT_SCSI_PASS_THRU_PROTOCOL PassThru;
  50. EFI_EXT_SCSI_PASS_THRU_MODE PassThruMode;
  51. } PVSCSI_DEV;
  52. #define PVSCSI_FROM_PASS_THRU(PassThruPointer) \
  53. CR (PassThruPointer, PVSCSI_DEV, PassThru, PVSCSI_SIG)
  54. #define PVSCSI_DMA_BUF_DEV_ADDR(Dev, MemberName) \
  55. (Dev->DmaBufDmaDesc.DeviceAddress + OFFSET_OF(PVSCSI_DMA_BUFFER, MemberName))
  56. #endif // __PVSCSI_DXE_H_