]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDiskInfo.c
IntelSiliconPkg: Replace BSD License with BSD+Patent License
[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
5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php.\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include "NvmExpress.h"\r
16\r
17EFI_DISK_INFO_PROTOCOL gNvmExpressDiskInfoProtocolTemplate = {\r
18 EFI_DISK_INFO_NVME_INTERFACE_GUID,\r
19 NvmExpressDiskInfoInquiry,\r
20 NvmExpressDiskInfoIdentify,\r
21 NvmExpressDiskInfoSenseData,\r
22 NvmExpressDiskInfoWhichIde\r
23};\r
24\r
25/**\r
26 Initialize the installation of DiskInfo protocol.\r
27\r
28 This function prepares for the installation of DiskInfo protocol on the child handle.\r
29 By default, it installs DiskInfo protocol with NVME interface GUID.\r
30\r
31 @param[in] Device The pointer of NVME_DEVICE_PRIVATE_DATA.\r
32\r
33**/\r
34VOID\r
35InitializeDiskInfo (\r
36 IN NVME_DEVICE_PRIVATE_DATA *Device\r
37 )\r
38{\r
39 CopyMem (&Device->DiskInfo, &gNvmExpressDiskInfoProtocolTemplate, sizeof (EFI_DISK_INFO_PROTOCOL));\r
40}\r
41\r
42\r
43/**\r
44 Provides inquiry information for the controller type.\r
45\r
46 This function is used to get inquiry data. Data format\r
47 of Identify data is defined by the Interface GUID.\r
48\r
49 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
50 @param[in, out] InquiryData Pointer to a buffer for the inquiry data.\r
51 @param[in, out] InquiryDataSize Pointer to the value for the inquiry data size.\r
52\r
53 @retval EFI_SUCCESS The command was accepted without any errors.\r
54 @retval EFI_NOT_FOUND Device does not support this data class\r
55 @retval EFI_DEVICE_ERROR Error reading InquiryData from device\r
56 @retval EFI_BUFFER_TOO_SMALL InquiryDataSize not big enough\r
57\r
58**/\r
59EFI_STATUS\r
60EFIAPI\r
61NvmExpressDiskInfoInquiry (\r
62 IN EFI_DISK_INFO_PROTOCOL *This,\r
63 IN OUT VOID *InquiryData,\r
64 IN OUT UINT32 *InquiryDataSize\r
65 )\r
66{\r
67 return EFI_NOT_FOUND;\r
68}\r
69\r
70\r
71/**\r
72 Provides identify information for the controller type.\r
73\r
74 This function is used to get identify data. Data format\r
75 of Identify data is defined by the Interface GUID.\r
76\r
77 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL\r
78 instance.\r
79 @param[in, out] IdentifyData Pointer to a buffer for the identify data.\r
80 @param[in, out] IdentifyDataSize Pointer to the value for the identify data\r
81 size.\r
82\r
83 @retval EFI_SUCCESS The command was accepted without any errors.\r
84 @retval EFI_NOT_FOUND Device does not support this data class\r
85 @retval EFI_DEVICE_ERROR Error reading IdentifyData from device\r
86 @retval EFI_BUFFER_TOO_SMALL IdentifyDataSize not big enough\r
87\r
88**/\r
89EFI_STATUS\r
90EFIAPI\r
91NvmExpressDiskInfoIdentify (\r
92 IN EFI_DISK_INFO_PROTOCOL *This,\r
93 IN OUT VOID *IdentifyData,\r
94 IN OUT UINT32 *IdentifyDataSize\r
95 )\r
96{\r
97 EFI_STATUS Status;\r
98 NVME_DEVICE_PRIVATE_DATA *Device;\r
99\r
100 Device = NVME_DEVICE_PRIVATE_DATA_FROM_DISK_INFO (This);\r
101\r
102 Status = EFI_BUFFER_TOO_SMALL;\r
103 if (*IdentifyDataSize >= sizeof (Device->NamespaceData)) {\r
104 Status = EFI_SUCCESS;\r
105 CopyMem (IdentifyData, &Device->NamespaceData, sizeof (Device->NamespaceData));\r
106 }\r
107 *IdentifyDataSize = sizeof (Device->NamespaceData);\r
108 return Status;\r
109}\r
110\r
111/**\r
112 Provides sense data information for the controller type.\r
113\r
114 This function is used to get sense data.\r
115 Data format of Sense data is defined by the Interface GUID.\r
116\r
117 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
118 @param[in, out] SenseData Pointer to the SenseData.\r
119 @param[in, out] SenseDataSize Size of SenseData in bytes.\r
120 @param[out] SenseDataNumber Pointer to the value for the sense data size.\r
121\r
122 @retval EFI_SUCCESS The command was accepted without any errors.\r
123 @retval EFI_NOT_FOUND Device does not support this data class.\r
124 @retval EFI_DEVICE_ERROR Error reading SenseData from device.\r
125 @retval EFI_BUFFER_TOO_SMALL SenseDataSize not big enough.\r
126\r
127**/\r
128EFI_STATUS\r
129EFIAPI\r
130NvmExpressDiskInfoSenseData (\r
131 IN EFI_DISK_INFO_PROTOCOL *This,\r
132 IN OUT VOID *SenseData,\r
133 IN OUT UINT32 *SenseDataSize,\r
134 OUT UINT8 *SenseDataNumber\r
135 )\r
136{\r
137 return EFI_NOT_FOUND;\r
138}\r
139\r
140\r
141/**\r
142 This function is used to get controller information.\r
143\r
144 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
145 @param[out] IdeChannel Pointer to the Ide Channel number. Primary or secondary.\r
146 @param[out] IdeDevice Pointer to the Ide Device number. Master or slave.\r
147\r
148 @retval EFI_SUCCESS IdeChannel and IdeDevice are valid.\r
149 @retval EFI_UNSUPPORTED This is not an IDE device.\r
150\r
151**/\r
152EFI_STATUS\r
153EFIAPI\r
154NvmExpressDiskInfoWhichIde (\r
155 IN EFI_DISK_INFO_PROTOCOL *This,\r
156 OUT UINT32 *IdeChannel,\r
157 OUT UINT32 *IdeDevice\r
158 )\r
159{\r
160 return EFI_UNSUPPORTED;\r
161}\r
162\r