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