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