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