]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/Include/IndustryStandard/PvScsi.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / OvmfPkg / Include / IndustryStandard / PvScsi.h
1 /** @file
2
3 VMware PVSCSI Device specific type and macro definitions.
4
5 Copyright (C) 2020, Oracle and/or its affiliates.
6
7 SPDX-License-Identifier: BSD-2-Clause-Patent
8
9 **/
10
11 #ifndef __PVSCSI_H_
12 #define __PVSCSI_H_
13
14 //
15 // Device offsets and constants
16 //
17
18 #define PCI_VENDOR_ID_VMWARE (0x15ad)
19 #define PCI_DEVICE_ID_VMWARE_PVSCSI (0x07c0)
20
21 //
22 // CDB (Command Descriptor Block) with size above this constant
23 // should be considered out-of-band
24 //
25 #define PVSCSI_CDB_MAX_SIZE (16)
26
27 typedef enum {
28 PvScsiRegOffsetCommand = 0x0,
29 PvScsiRegOffsetCommandData = 0x4,
30 PvScsiRegOffsetCommandStatus = 0x8,
31 PvScsiRegOffsetLastSts0 = 0x100,
32 PvScsiRegOffsetLastSts1 = 0x104,
33 PvScsiRegOffsetLastSts2 = 0x108,
34 PvScsiRegOffsetLastSts3 = 0x10c,
35 PvScsiRegOffsetIntrStatus = 0x100c,
36 PvScsiRegOffsetIntrMask = 0x2010,
37 PvScsiRegOffsetKickNonRwIo = 0x3014,
38 PvScsiRegOffsetDebug = 0x3018,
39 PvScsiRegOffsetKickRwIo = 0x4018,
40 } PVSCSI_BAR0_OFFSETS;
41
42 //
43 // Define Interrupt-Status register flags
44 //
45 #define PVSCSI_INTR_CMPL_0 BIT0
46 #define PVSCSI_INTR_CMPL_1 BIT1
47 #define PVSCSI_INTR_CMPL_MASK (PVSCSI_INTR_CMPL_0 | PVSCSI_INTR_CMPL_1)
48
49 typedef enum {
50 PvScsiCmdFirst = 0,
51 PvScsiCmdAdapterReset = 1,
52 PvScsiCmdIssueScsi = 2,
53 PvScsiCmdSetupRings = 3,
54 PvScsiCmdResetBus = 4,
55 PvScsiCmdResetDevice = 5,
56 PvScsiCmdAbortCmd = 6,
57 PvScsiCmdConfig = 7,
58 PvScsiCmdSetupMsgRing = 8,
59 PvScsiCmdDeviceUnplug = 9,
60 PvScsiCmdLast = 10
61 } PVSCSI_COMMANDS;
62
63 #define PVSCSI_SETUP_RINGS_MAX_NUM_PAGES (32)
64
65 #pragma pack (1)
66 typedef struct {
67 UINT32 ReqRingNumPages;
68 UINT32 CmpRingNumPages;
69 UINT64 RingsStatePPN;
70 UINT64 ReqRingPPNs[PVSCSI_SETUP_RINGS_MAX_NUM_PAGES];
71 UINT64 CmpRingPPNs[PVSCSI_SETUP_RINGS_MAX_NUM_PAGES];
72 } PVSCSI_CMD_DESC_SETUP_RINGS;
73 #pragma pack ()
74
75 #define PVSCSI_MAX_CMD_DATA_WORDS \
76 (sizeof (PVSCSI_CMD_DESC_SETUP_RINGS) / sizeof (UINT32))
77
78 #pragma pack (1)
79 typedef struct {
80 UINT32 ReqProdIdx;
81 UINT32 ReqConsIdx;
82 UINT32 ReqNumEntriesLog2;
83
84 UINT32 CmpProdIdx;
85 UINT32 CmpConsIdx;
86 UINT32 CmpNumEntriesLog2;
87
88 UINT8 Pad[104];
89
90 UINT32 MsgProdIdx;
91 UINT32 MsgConsIdx;
92 UINT32 MsgNumEntriesLog2;
93 } PVSCSI_RINGS_STATE;
94 #pragma pack ()
95
96 //
97 // Define PVSCSI request descriptor tags
98 //
99 #define PVSCSI_SIMPLE_QUEUE_TAG (0x20)
100
101 //
102 // Define PVSCSI request descriptor flags
103 //
104 #define PVSCSI_FLAG_CMD_WITH_SG_LIST BIT0
105 #define PVSCSI_FLAG_CMD_OUT_OF_BAND_CDB BIT1
106 #define PVSCSI_FLAG_CMD_DIR_NONE BIT2
107 #define PVSCSI_FLAG_CMD_DIR_TOHOST BIT3
108 #define PVSCSI_FLAG_CMD_DIR_TODEVICE BIT4
109
110 #pragma pack (1)
111 typedef struct {
112 UINT64 Context;
113 UINT64 DataAddr;
114 UINT64 DataLen;
115 UINT64 SenseAddr;
116 UINT32 SenseLen;
117 UINT32 Flags;
118 UINT8 Cdb[16];
119 UINT8 CdbLen;
120 UINT8 Lun[8];
121 UINT8 Tag;
122 UINT8 Bus;
123 UINT8 Target;
124 UINT8 VcpuHint;
125 UINT8 Unused[59];
126 } PVSCSI_RING_REQ_DESC;
127 #pragma pack ()
128
129 //
130 // Host adapter status/error codes
131 //
132 typedef enum {
133 PvScsiBtStatSuccess = 0x00, // CCB complete normally with no errors
134 PvScsiBtStatLinkedCommandCompleted = 0x0a,
135 PvScsiBtStatLinkedCommandCompletedWithFlag = 0x0b,
136 PvScsiBtStatDataUnderrun = 0x0c,
137 PvScsiBtStatSelTimeout = 0x11, // SCSI selection timeout
138 PvScsiBtStatDatarun = 0x12, // Data overrun/underrun
139 PvScsiBtStatBusFree = 0x13, // Unexpected bus free
140 PvScsiBtStatInvPhase = 0x14, //
141 // Invalid bus phase or sequence requested
142 // by target
143 //
144 PvScsiBtStatLunMismatch = 0x17, //
145 // Linked CCB has different LUN from first
146 // CCB
147 //
148 PvScsiBtStatSensFailed = 0x1b, // Auto request sense failed
149 PvScsiBtStatTagReject = 0x1c, //
150 // SCSI II tagged queueing message rejected
151 // by target
152 //
153 PvScsiBtStatBadMsg = 0x1d, //
154 // Unsupported message received by the host
155 // adapter
156 //
157 PvScsiBtStatHaHardware = 0x20, // Host adapter hardware failed
158 PvScsiBtStatNoResponse = 0x21, //
159 // Target did not respond to SCSI ATN sent
160 // a SCSI RST
161 //
162 PvScsiBtStatSentRst = 0x22, // Host adapter asserted a SCSI RST
163 PvScsiBtStatRecvRst = 0x23, // Other SCSI devices asserted a SCSI RST
164 PvScsiBtStatDisconnect = 0x24, //
165 // Target device reconnected improperly
166 // (w/o tag)
167 //
168 PvScsiBtStatBusReset = 0x25, // Host adapter issued BUS device reset
169 PvScsiBtStatAbortQueue = 0x26, // Abort queue generated
170 PvScsiBtStatHaSoftware = 0x27, // Host adapter software error
171 PvScsiBtStatHaTimeout = 0x30, // Host adapter hardware timeout error
172 PvScsiBtStatScsiParity = 0x34, // SCSI parity error detected
173 } PVSCSI_HOST_BUS_ADAPTER_STATUS;
174
175 #pragma pack (1)
176 typedef struct {
177 UINT64 Context;
178 UINT64 DataLen;
179 UINT32 SenseLen;
180 UINT16 HostStatus;
181 UINT16 ScsiStatus;
182 UINT32 Pad[2];
183 } PVSCSI_RING_CMP_DESC;
184 #pragma pack ()
185
186 #endif // __PVSCSI_H_