summaryrefslogtreecommitdiff
path: root/Include/Protocol/NvmExpressPassThru.h
blob: 2e9e7ac879984b1cb015978429a675bb581bebfb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
//**********************************************************************
//**********************************************************************
//**                                                                  **
//**        (C)Copyright 1985-2015, American Megatrends, Inc.         **
//**                                                                  **
//**                       All Rights Reserved.                       **
//**                                                                  **
//**         5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093     **
//**                                                                  **
//**                       Phone: (770)-246-8600                      **
//**                                                                  **
//**********************************************************************
//**********************************************************************
//**********************************************************************
// $Header: /Alaska/SOURCE/Modules/NVMe/Nvme Protocol/NvmExpressPassThru.h 1     5/14/15 2:40a Karthikar $
//
// $Revision: 1 $  
//
// $Date: 5/14/15 2:40a $
//**********************************************************************
//**********************************************************************
//<AMI_FHDR_START>
//
// Name:        NvmExpressPassThru.h
//
// Description: Protocol Header file for the NvmExpressPassThru Protocol 
//
//<AMI_FHDR_END>
//**********************************************************************

#ifndef __EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL_H__
#define __EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL_H__

typedef struct _EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL;

#define EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL_GUID \
  {0x52c78312, 0x8edc, 0x4233, { 0x98, 0xf2, 0x1a, 0x1a, 0xa5, 0xe3, 0x88, 0xa5 } }

#define EFI_NVM_EXPRESS_PASS_THRU_ATTRIBUTES_PHYSICAL      0x0001

#define EFI_NVM_EXPRESS_PASS_THRU_ATTRIBUTES_LOGICAL       0x0002

#define EFI_NVM_EXPRESS_PASS_THRU_ATTRIBUTES_NONBLOCKINGIO 0x0004

#define EFI_NVM_EXPRESS_PASS_THRU_ATTRIBUTES_CMD_SET_NVME  0x0008

// FusedOperation
#define NORMAL_CMD          0x00
#define FUSED_FIRST_CMD     0x01
#define FUSED_SECOND_CMD    0x02

// Flags
#define CDW2_VALID       0x01
#define CDW3_VALID       0x02
#define CDW10_VALID      0x04
#define CDW11_VALID      0x08
#define CDW12_VALID      0x10
#define CDW13_VALID      0x20
#define CDW14_VALID      0x40
#define CDW15_VALID      0x80

typedef struct {
  UINT32    Attributes;
  UINT32    IoAlign;
  UINT32    NvmeVersion;
} EFI_NVM_EXPRESS_PASS_THRU_MODE;

typedef struct { 
  UINT8    OpCode;
  UINT8    FusedOperation;
  UINT16   Unused;
} NVME_CDW0;

typedef struct {
  NVME_CDW0  Cdw0;
  UINT8      Flags;
  UINT32     Nsid;
  UINT32     Cdw2;
  UINT32     Cdw3;
  UINT32     Cdw10;
  UINT32     Cdw11;
  UINT32     Cdw12;
  UINT32     Cdw13;
  UINT32     Cdw14;
  UINT32     Cdw15;
} EFI_NVM_EXPRESS_COMMAND;

// This structure maps to the NVM Express specification Completion Queue Entry 

typedef struct { 
  UINT32    DW0;
  UINT32    DW1;
  UINT32    DW2;
  UINT32    DW3;
} EFI_NVM_EXPRESS_COMPLETION;

typedef struct _EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET {
  // The timeout, in 100 ns units, to use for the execution of this 
  // NVM Express Command Packet. A Timeout value of 0 means that this 
  // function will wait indefinitely for the command to execute. 
  // If Timeout is greater than zero, then this function will return 
  // EFI_TIMEOUT if the time required to execute the NVM Express 
  // command is greater than Timeout
  UINT64                      CommandTimeout;
  // 
  // A pointer to the data buffer to transfer between the host, and the 
  // NVM Express controller for read, write, and bi-directional commands
  //
  VOID                        *TransferBuffer;
  //
  // On input, the size in bytes of TransferBuffer. On output, the number
  // of bytes transferred to the NVM Express controller, or namespace
  //
  UINT32                      TransferLength;
  //
  // A pointer to the optional metadata buffer to transfer between the host,
  // and the NVM Express controller.If this field is not NULL, then it must
  // be aligned on the boundary specified by the IoAlign field in the 
  // EFI_NVM_EXPRESS_PASS_THRU_MODE structure.
  //
  VOID                        *MetaDataBuffer;
  //
  // On Input, the size in bytes of MetadataBuffer. On output, the number 
  // of bytes transferred to/from the NVM Express controller, or namespace
  //
  UINT32                      MetadataLength;
  //
  // The type of the queue that the NVMe command should be posted to.
  // A value of 0 indicates it should be posted to the Admin Submission Queue.
  // A value of 1 indicates it should be posted to an I/O Submission Queue
  //
  UINT16                      QueueType;
  //
  // A pointer to an NVM Express Command Packet.
  //
  EFI_NVM_EXPRESS_COMMAND     *NvmeCmd;
  //
  // The raw NVM Express completion queue 
  //
  EFI_NVM_EXPRESS_COMPLETION  *NvmeCompletion;
} EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET;
//**********************************************************************
//<AMI_PHDR_START>
//
//
// Description: Sends an NVM Express Command Packet to an NVM Express controller or namespace.
//
// Input:
//  IN This         A pointer to the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL instance
//  IN NamespaceId  A 32 bit namespace ID as defined in the NVMe specification 
//                        to which the NVM Express Command Packet will be sent.  
//  IN Packet       A pointer to the NVM Express Command Packet to send to
//                        the NVMe namespace specified by NamespaceId. 
//  IN Event        Event to be signalled when the NVM Express Command Packet completes
//                        and non-blocking I/O is supported
// Output:
//  EFI_SUCCESS          The NVM Express Command Packet was sent by the host successfully
//  EFI_BAD_BUFFER_SIZE  The number of bytes that could be transferred is not valid
//  EFI_NOT_READY        The NVM Express Command Packet could not be sent as the controller
//                                 is not ready
//  EFI_DEVICE_ERROR     Device error
//  EFI_UNSUPPORTED      The command described by the NVM Express Command Packet is not 
//                                 supported by the host adapter
//  EFI_TIMEOUT          A timeout occurred while waiting for the NVM Express Command Packet
//                                 to execute  
// Modified:
//      
// Referrals:  
//
// Notes:   
//<AMI_PHDR_END>
//**********************************************************************

typedef
EFI_STATUS 
(EFIAPI *EFI_NVM_EXPRESS_PASS_THRU_PASSTHRU) ( 
  IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL            *This,
  IN UINT32                                        NamespaceId,
  IN OUT EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET  *Packet,
  IN EFI_EVENT                                     Event
  );

//**********************************************************************
//<AMI_PHDR_START>
//
// Description:Used to retrieve the next namespace ID for this NVM Express controller. 
//
// Input:
//  IN This          A pointer to the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL instance
//  IN NamespaceId   On input, a pointer to a valid namespace ID on this NVM Express controller
//	             or a pointer to the value 0xFFFFFFFF. A pointer to the value 0xFFFFFFFF retrieves 
//		     the first valid namespace ID on this NVM Express controller.
// Output: 
//  EFI_SUCCESS           The Namespace ID of the next Namespace was returned
//  EFI_NOT_FOUND         There are no more namespaces defined on this controller
//  EFI_INVALID_PARAMETER The Namespace ID was not valid
//
// Modified:
//      
// Referrals:  
//
// Notes:   
//
//<AMI_PHDR_END>
//**********************************************************************
 
typedef 
EFI_STATUS
(EFIAPI *EFI_NVM_EXPRESS_PASS_THRU_GET_NEXT_NAMESPACE) (
  IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL    *This,
  IN OUT UINT32                            *NamespaceId
  );
//**********************************************************************
//<AMI_PHDR_START>
//
// Description:Used to allocate and build a device path node for an NVM Express namespace 
//    on an NVM Express controller
//
// Input:
//  IN This          A pointer to the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL instance
//  IN NamespaceId   The NVM Express namespace ID for which a device path node is
//                        to be allocated and built
//  IN DevicePath   A pointer to a single device path node that describes the 
//                  NVM Express namespace specified by NamespaceId. 
//			This function is responsible for allocating the buffer DevicePath
//			with the boot service AllocatePool(). It is the caller's responsibility
//			to free DevicePath when the caller is finished with DevicePath.
//
// Output: 
//  EFI_SUCCESS           The device path node that describes the NVM Express 
//                         namespace specified by NamespaceId was allocated and 
//                         returned in DevicePath
//  EFI_NOT_FOUND         The NamespaceIdis not valid
//  EFI_INVALID_PARAMETER DevicePath is NULL
//  EFI_OUT_OF_RESOURCES  There are not enough resources to allocate the 
//                                  DevicePath node.
// Modified:
//      
// Referrals:  
//
// Notes:   
//
//<AMI_PHDR_END>
//**********************************************************************
typedef
EFI_STATUS 
(EFIAPI *EFI_NVM_EXPRESS_PASS_THRU_BUILD_DEVICE_PATH) (
  IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL    *This,
  IN UINT32                                NamespaceId,
  IN OUT EFI_DEVICE_PATH_PROTOCOL          **DevicePath
  ); 

//**********************************************************************
//<AMI_PHDR_START>
//
// Description: Used to translate a device path node to a namespace ID
//
// Input:
//  IN This          A pointer to the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL instance
//  IN NamespaceId  The NVM Express namespace ID contained in the device path node
//  IN DevicePath   A pointer to the device path node that describes an NVM 
//                        Express namespace on the NVM Express controller. 
// Output: 
//  EFI_SUCCESS          Namespace ID is returned in NamespaceID
//
// Modified:
//      
// Referrals:  
//
// Notes:   
//
//<AMI_PHDR_END>
//**********************************************************************

typedef
EFI_STATUS 
(EFIAPI *EFI_NVM_EXPRESS_PASS_THRU_GET_NAMESPACE) (
  IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL    *This,
  IN EFI_DEVICE_PATH_PROTOCOL              *DevicePath,
  OUT UINT32                               *NamespaceId
  ); 

struct _EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL {
  EFI_NVM_EXPRESS_PASS_THRU_MODE                 *Mode;
  EFI_NVM_EXPRESS_PASS_THRU_PASSTHRU             PassThru;
  EFI_NVM_EXPRESS_PASS_THRU_GET_NEXT_NAMESPACE   GetNextNamespace;           
  EFI_NVM_EXPRESS_PASS_THRU_BUILD_DEVICE_PATH    BuildDevicePath;            
  EFI_NVM_EXPRESS_PASS_THRU_GET_NAMESPACE        GetNameSpace;               
};

extern EFI_GUID gEfiNvmExpressPassThruProtocolGuid;

#endif

//**********************************************************************
//**********************************************************************
//**                                                                  **
//**        (C)Copyright 1985-2015, American Megatrends, Inc.         **
//**                                                                  **
//**                       All Rights Reserved.                       **
//**                                                                  **
//**         5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093     **
//**                                                                  **
//**                       Phone: (770)-246-8600                      **
//**                                                                  **
//**********************************************************************
//**********************************************************************