]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDiskInfo.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / NvmExpressDxe / NvmExpressDiskInfo.c
CommitLineData
4b738c76
HT
1/** @file\r
2 This file is used to implement the EFI_DISK_INFO_PROTOCOL interface..\r
3\r
4 Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>\r
9d510e61 5 SPDX-License-Identifier: BSD-2-Clause-Patent\r
4b738c76
HT
6\r
7**/\r
8\r
9#include "NvmExpress.h"\r
10\r
1436aea4 11EFI_DISK_INFO_PROTOCOL gNvmExpressDiskInfoProtocolTemplate = {\r
4b738c76
HT
12 EFI_DISK_INFO_NVME_INTERFACE_GUID,\r
13 NvmExpressDiskInfoInquiry,\r
14 NvmExpressDiskInfoIdentify,\r
15 NvmExpressDiskInfoSenseData,\r
16 NvmExpressDiskInfoWhichIde\r
17};\r
18\r
19/**\r
20 Initialize the installation of DiskInfo protocol.\r
21\r
22 This function prepares for the installation of DiskInfo protocol on the child handle.\r
23 By default, it installs DiskInfo protocol with NVME interface GUID.\r
24\r
25 @param[in] Device The pointer of NVME_DEVICE_PRIVATE_DATA.\r
26\r
27**/\r
28VOID\r
29InitializeDiskInfo (\r
1436aea4 30 IN NVME_DEVICE_PRIVATE_DATA *Device\r
4b738c76
HT
31 )\r
32{\r
33 CopyMem (&Device->DiskInfo, &gNvmExpressDiskInfoProtocolTemplate, sizeof (EFI_DISK_INFO_PROTOCOL));\r
34}\r
35\r
4b738c76
HT
36/**\r
37 Provides inquiry information for the controller type.\r
38\r
39 This function is used to get inquiry data. Data format\r
40 of Identify data is defined by the Interface GUID.\r
41\r
42 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
43 @param[in, out] InquiryData Pointer to a buffer for the inquiry data.\r
44 @param[in, out] InquiryDataSize Pointer to the value for the inquiry data size.\r
45\r
46 @retval EFI_SUCCESS The command was accepted without any errors.\r
47 @retval EFI_NOT_FOUND Device does not support this data class\r
48 @retval EFI_DEVICE_ERROR Error reading InquiryData from device\r
49 @retval EFI_BUFFER_TOO_SMALL InquiryDataSize not big enough\r
50\r
51**/\r
52EFI_STATUS\r
53EFIAPI\r
54NvmExpressDiskInfoInquiry (\r
1436aea4
MK
55 IN EFI_DISK_INFO_PROTOCOL *This,\r
56 IN OUT VOID *InquiryData,\r
57 IN OUT UINT32 *InquiryDataSize\r
4b738c76
HT
58 )\r
59{\r
60 return EFI_NOT_FOUND;\r
61}\r
62\r
4b738c76
HT
63/**\r
64 Provides identify information for the controller type.\r
65\r
66 This function is used to get identify data. Data format\r
67 of Identify data is defined by the Interface GUID.\r
68\r
69 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL\r
70 instance.\r
71 @param[in, out] IdentifyData Pointer to a buffer for the identify data.\r
72 @param[in, out] IdentifyDataSize Pointer to the value for the identify data\r
73 size.\r
74\r
75 @retval EFI_SUCCESS The command was accepted without any errors.\r
76 @retval EFI_NOT_FOUND Device does not support this data class\r
77 @retval EFI_DEVICE_ERROR Error reading IdentifyData from device\r
78 @retval EFI_BUFFER_TOO_SMALL IdentifyDataSize not big enough\r
79\r
80**/\r
81EFI_STATUS\r
82EFIAPI\r
83NvmExpressDiskInfoIdentify (\r
1436aea4
MK
84 IN EFI_DISK_INFO_PROTOCOL *This,\r
85 IN OUT VOID *IdentifyData,\r
86 IN OUT UINT32 *IdentifyDataSize\r
4b738c76
HT
87 )\r
88{\r
1436aea4
MK
89 EFI_STATUS Status;\r
90 NVME_DEVICE_PRIVATE_DATA *Device;\r
4b738c76
HT
91\r
92 Device = NVME_DEVICE_PRIVATE_DATA_FROM_DISK_INFO (This);\r
93\r
94 Status = EFI_BUFFER_TOO_SMALL;\r
95 if (*IdentifyDataSize >= sizeof (Device->NamespaceData)) {\r
96 Status = EFI_SUCCESS;\r
97 CopyMem (IdentifyData, &Device->NamespaceData, sizeof (Device->NamespaceData));\r
98 }\r
1436aea4 99\r
4b738c76
HT
100 *IdentifyDataSize = sizeof (Device->NamespaceData);\r
101 return Status;\r
102}\r
103\r
104/**\r
105 Provides sense data information for the controller type.\r
106\r
107 This function is used to get sense data.\r
108 Data format of Sense data is defined by the Interface GUID.\r
109\r
110 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
111 @param[in, out] SenseData Pointer to the SenseData.\r
112 @param[in, out] SenseDataSize Size of SenseData in bytes.\r
113 @param[out] SenseDataNumber Pointer to the value for the sense data size.\r
114\r
115 @retval EFI_SUCCESS The command was accepted without any errors.\r
116 @retval EFI_NOT_FOUND Device does not support this data class.\r
117 @retval EFI_DEVICE_ERROR Error reading SenseData from device.\r
118 @retval EFI_BUFFER_TOO_SMALL SenseDataSize not big enough.\r
119\r
120**/\r
121EFI_STATUS\r
122EFIAPI\r
123NvmExpressDiskInfoSenseData (\r
1436aea4
MK
124 IN EFI_DISK_INFO_PROTOCOL *This,\r
125 IN OUT VOID *SenseData,\r
126 IN OUT UINT32 *SenseDataSize,\r
127 OUT UINT8 *SenseDataNumber\r
4b738c76
HT
128 )\r
129{\r
130 return EFI_NOT_FOUND;\r
131}\r
132\r
4b738c76
HT
133/**\r
134 This function is used to get controller information.\r
135\r
136 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
137 @param[out] IdeChannel Pointer to the Ide Channel number. Primary or secondary.\r
138 @param[out] IdeDevice Pointer to the Ide Device number. Master or slave.\r
139\r
140 @retval EFI_SUCCESS IdeChannel and IdeDevice are valid.\r
141 @retval EFI_UNSUPPORTED This is not an IDE device.\r
142\r
143**/\r
144EFI_STATUS\r
145EFIAPI\r
146NvmExpressDiskInfoWhichIde (\r
1436aea4
MK
147 IN EFI_DISK_INFO_PROTOCOL *This,\r
148 OUT UINT32 *IdeChannel,\r
149 OUT UINT32 *IdeDevice\r
4b738c76
HT
150 )\r
151{\r
152 return EFI_UNSUPPORTED;\r
153}\r