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