]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiPassThru.h
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / NvmExpressPei / NvmExpressPeiPassThru.h
1 /** @file
2 The NvmExpressPei driver is used to manage non-volatile memory subsystem
3 which follows NVM Express specification at PEI phase.
4
5 Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
6
7 SPDX-License-Identifier: BSD-2-Clause-Patent
8
9 **/
10
11 #ifndef _NVM_EXPRESS_PEI_PASSTHRU_H_
12 #define _NVM_EXPRESS_PEI_PASSTHRU_H_
13
14 #define NVME_CONTROLLER_NSID 0
15
16 typedef struct {
17 UINT8 Opcode;
18 UINT8 FusedOperation;
19 #define NORMAL_CMD 0x00
20 #define FUSED_FIRST_CMD 0x01
21 #define FUSED_SECOND_CMD 0x02
22 UINT16 Cid;
23 } NVME_CDW0;
24
25 typedef struct {
26 NVME_CDW0 Cdw0;
27 UINT8 Flags;
28 #define CDW10_VALID 0x01
29 #define CDW11_VALID 0x02
30 #define CDW12_VALID 0x04
31 #define CDW13_VALID 0x08
32 #define CDW14_VALID 0x10
33 #define CDW15_VALID 0x20
34 UINT32 Nsid;
35 UINT32 Cdw10;
36 UINT32 Cdw11;
37 UINT32 Cdw12;
38 UINT32 Cdw13;
39 UINT32 Cdw14;
40 UINT32 Cdw15;
41 } EDKII_PEI_NVM_EXPRESS_COMMAND;
42
43 typedef struct {
44 UINT32 Cdw0;
45 UINT32 Cdw1;
46 UINT32 Cdw2;
47 UINT32 Cdw3;
48 } EDKII_PEI_NVM_EXPRESS_COMPLETION;
49
50 typedef struct {
51 UINT64 CommandTimeout;
52 VOID *TransferBuffer;
53 UINT32 TransferLength;
54 VOID *MetadataBuffer;
55 UINT32 MetadataLength;
56 UINT8 QueueType;
57 EDKII_PEI_NVM_EXPRESS_COMMAND *NvmeCmd;
58 EDKII_PEI_NVM_EXPRESS_COMPLETION *NvmeCompletion;
59 } EDKII_PEI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET;
60
61
62 /**
63 Sends an NVM Express Command Packet to an NVM Express controller or namespace. This function only
64 supports blocking execution of the command.
65
66 @param[in] Private The pointer to the NVME_CONTEXT Data structure.
67 @param[in] NamespaceId Is a 32 bit Namespace ID to which the Express HCI command packet will
68 be sent.
69 A Value of 0 denotes the NVM Express controller, a Value of all 0FFh in
70 the namespace ID specifies that the command packet should be sent to all
71 valid namespaces.
72 @param[in,out] Packet A pointer to the EDKII PEI NVM Express PassThru Command Packet to send
73 to the NVMe namespace specified by NamespaceId.
74
75 @retval EFI_SUCCESS The EDKII PEI NVM Express Command Packet was sent by the host.
76 TransferLength bytes were transferred to, or from DataBuffer.
77 @retval EFI_NOT_READY The EDKII PEI NVM Express Command Packet could not be sent because
78 the controller is not ready. The caller may retry again later.
79 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the EDKII PEI NVM
80 Express Command Packet.
81 @retval EFI_INVALID_PARAMETER Namespace, or the contents of EDKII_PEI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET
82 are invalid.
83 The EDKII PEI NVM Express Command Packet was not sent, so no
84 additional status information is available.
85 @retval EFI_UNSUPPORTED The command described by the EDKII PEI NVM Express Command Packet
86 is not supported by the host adapter.
87 The EDKII PEI NVM Express Command Packet was not sent, so no
88 additional status information is available.
89 @retval EFI_TIMEOUT A timeout occurred while waiting for the EDKII PEI NVM Express Command
90 Packet to execute.
91
92 **/
93 EFI_STATUS
94 NvmePassThru (
95 IN PEI_NVME_CONTROLLER_PRIVATE_DATA *Private,
96 IN UINT32 NamespaceId,
97 IN OUT EDKII_PEI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET *Packet
98 );
99
100 #endif