]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiPassThru.h
MdeModulePkg/NvmExpressPei: Add the NVME device PEI BlockIo support
[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 This program and the accompanying materials
8 are licensed and made available under the terms and conditions
9 of the BSD License which accompanies this distribution. The
10 full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
12
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
16 **/
17
18 #ifndef _NVM_EXPRESS_PEI_PASSTHRU_H_
19 #define _NVM_EXPRESS_PEI_PASSTHRU_H_
20
21 #define NVME_CONTROLLER_NSID 0
22
23 typedef struct {
24 UINT8 Opcode;
25 UINT8 FusedOperation;
26 #define NORMAL_CMD 0x00
27 #define FUSED_FIRST_CMD 0x01
28 #define FUSED_SECOND_CMD 0x02
29 UINT16 Cid;
30 } NVME_CDW0;
31
32 typedef struct {
33 NVME_CDW0 Cdw0;
34 UINT8 Flags;
35 #define CDW10_VALID 0x01
36 #define CDW11_VALID 0x02
37 #define CDW12_VALID 0x04
38 #define CDW13_VALID 0x08
39 #define CDW14_VALID 0x10
40 #define CDW15_VALID 0x20
41 UINT32 Nsid;
42 UINT32 Cdw10;
43 UINT32 Cdw11;
44 UINT32 Cdw12;
45 UINT32 Cdw13;
46 UINT32 Cdw14;
47 UINT32 Cdw15;
48 } EDKII_PEI_NVM_EXPRESS_COMMAND;
49
50 typedef struct {
51 UINT32 Cdw0;
52 UINT32 Cdw1;
53 UINT32 Cdw2;
54 UINT32 Cdw3;
55 } EDKII_PEI_NVM_EXPRESS_COMPLETION;
56
57 typedef struct {
58 UINT64 CommandTimeout;
59 VOID *TransferBuffer;
60 UINT32 TransferLength;
61 VOID *MetadataBuffer;
62 UINT32 MetadataLength;
63 UINT8 QueueType;
64 EDKII_PEI_NVM_EXPRESS_COMMAND *NvmeCmd;
65 EDKII_PEI_NVM_EXPRESS_COMPLETION *NvmeCompletion;
66 } EDKII_PEI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET;
67
68
69 /**
70 Sends an NVM Express Command Packet to an NVM Express controller or namespace. This function only
71 supports blocking execution of the command.
72
73 @param[in] Private The pointer to the NVME_CONTEXT Data structure.
74 @param[in] NamespaceId Is a 32 bit Namespace ID to which the Express HCI command packet will
75 be sent.
76 A Value of 0 denotes the NVM Express controller, a Value of all 0FFh in
77 the namespace ID specifies that the command packet should be sent to all
78 valid namespaces.
79 @param[in,out] Packet A pointer to the EDKII PEI NVM Express PassThru Command Packet to send
80 to the NVMe namespace specified by NamespaceId.
81
82 @retval EFI_SUCCESS The EDKII PEI NVM Express Command Packet was sent by the host.
83 TransferLength bytes were transferred to, or from DataBuffer.
84 @retval EFI_NOT_READY The EDKII PEI NVM Express Command Packet could not be sent because
85 the controller is not ready. The caller may retry again later.
86 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the EDKII PEI NVM
87 Express Command Packet.
88 @retval EFI_INVALID_PARAMETER Namespace, or the contents of EDKII_PEI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET
89 are invalid.
90 The EDKII PEI NVM Express Command Packet was not sent, so no
91 additional status information is available.
92 @retval EFI_UNSUPPORTED The command described by the EDKII PEI NVM Express Command Packet
93 is not supported by the host adapter.
94 The EDKII PEI NVM Express Command Packet was not sent, so no
95 additional status information is available.
96 @retval EFI_TIMEOUT A timeout occurred while waiting for the EDKII PEI NVM Express Command
97 Packet to execute.
98
99 **/
100 EFI_STATUS
101 NvmePassThru (
102 IN PEI_NVME_CONTROLLER_PRIVATE_DATA *Private,
103 IN UINT32 NamespaceId,
104 IN OUT EDKII_PEI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET *Packet
105 );
106
107 #endif