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