]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Bus/Isa/IsaFloppy/Dxe/ComponentName.c
Update the copyright headers of IsaFloppyDxe.
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Isa / IsaFloppy / Dxe / ComponentName.c
1 /*++
2
3 Copyright (c) 2006 - 2007, Intel Corporation<BR>
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12
13 Module Name:
14
15 ComponentName.c
16
17 Abstract:
18
19 --*/
20
21 #include "IsaFloppy.h"
22
23 //
24 // EFI Component Name Protocol
25 //
26 EFI_COMPONENT_NAME_PROTOCOL gIsaFloppyComponentName = {
27 IsaFloppyComponentNameGetDriverName,
28 IsaFloppyComponentNameGetControllerName,
29 "eng"
30 };
31
32 STATIC EFI_UNICODE_STRING_TABLE mIsaFloppyDriverNameTable[] = {
33 {
34 "eng",
35 L"ISA Floppy Driver"
36 },
37 {
38 NULL,
39 NULL
40 }
41 };
42
43 EFI_STATUS
44 EFIAPI
45 IsaFloppyComponentNameGetDriverName (
46 IN EFI_COMPONENT_NAME_PROTOCOL *This,
47 IN CHAR8 *Language,
48 OUT CHAR16 **DriverName
49 )
50 /*++
51
52 Routine Description:
53
54 Retrieves a Unicode string that is the user readable name of the EFI Driver.
55
56 Arguments:
57
58 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
59 Language - A pointer to a three character ISO 639-2 language identifier.
60 This is the language of the driver name that that the caller
61 is requesting, and it must match one of the languages specified
62 in SupportedLanguages. The number of languages supported by a
63 driver is up to the driver writer.
64 DriverName - A pointer to the Unicode string to return. This Unicode string
65 is the name of the driver specified by This in the language
66 specified by Language.
67
68 Returns:
69
70 EFI_SUCCESS - The Unicode string for the Driver specified by This
71 and the language specified by Language was returned
72 in DriverName.
73 EFI_INVALID_PARAMETER - Language is NULL.
74 EFI_INVALID_PARAMETER - DriverName is NULL.
75 EFI_UNSUPPORTED - The driver specified by This does not support the
76 language specified by Language.
77
78 --*/
79 {
80 return LookupUnicodeString (
81 Language,
82 gIsaFloppyComponentName.SupportedLanguages,
83 mIsaFloppyDriverNameTable,
84 DriverName
85 );
86 }
87
88 EFI_STATUS
89 EFIAPI
90 IsaFloppyComponentNameGetControllerName (
91 IN EFI_COMPONENT_NAME_PROTOCOL *This,
92 IN EFI_HANDLE ControllerHandle,
93 IN EFI_HANDLE ChildHandle OPTIONAL,
94 IN CHAR8 *Language,
95 OUT CHAR16 **ControllerName
96 )
97 /*++
98
99 Routine Description:
100
101 Retrieves a Unicode string that is the user readable name of the controller
102 that is being managed by an EFI Driver.
103
104 Arguments:
105
106 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
107 ControllerHandle - The handle of a controller that the driver specified by
108 This is managing. This handle specifies the controller
109 whose name is to be returned.
110 ChildHandle - The handle of the child controller to retrieve the name
111 of. This is an optional parameter that may be NULL. It
112 will be NULL for device drivers. It will also be NULL
113 for a bus drivers that wish to retrieve the name of the
114 bus controller. It will not be NULL for a bus driver
115 that wishes to retrieve the name of a child controller.
116 Language - A pointer to a three character ISO 639-2 language
117 identifier. This is the language of the controller name
118 that that the caller is requesting, and it must match one
119 of the languages specified in SupportedLanguages. The
120 number of languages supported by a driver is up to the
121 driver writer.
122 ControllerName - A pointer to the Unicode string to return. This Unicode
123 string is the name of the controller specified by
124 ControllerHandle and ChildHandle in the language
125 specified by Language from the point of view of the
126 driver specified by This.
127
128 Returns:
129
130 EFI_SUCCESS - The Unicode string for the user readable name in the
131 language specified by Language for the driver
132 specified by This was returned in DriverName.
133 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
134 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid
135 EFI_HANDLE.
136 EFI_INVALID_PARAMETER - Language is NULL.
137 EFI_INVALID_PARAMETER - ControllerName is NULL.
138 EFI_UNSUPPORTED - The driver specified by This is not currently
139 managing the controller specified by
140 ControllerHandle and ChildHandle.
141 EFI_UNSUPPORTED - The driver specified by This does not support the
142 language specified by Language.
143
144 --*/
145 {
146 EFI_STATUS Status;
147 EFI_BLOCK_IO_PROTOCOL *BlkIo;
148 FDC_BLK_IO_DEV *FdcDev;
149 EFI_ISA_IO_PROTOCOL *IsaIoProtocol;
150
151 //
152 // This is a device driver, so ChildHandle must be NULL.
153 //
154 if (ChildHandle != NULL) {
155 return EFI_UNSUPPORTED;
156 }
157 //
158 // Check Controller's handle
159 //
160 Status = gBS->OpenProtocol (
161 ControllerHandle,
162 &gEfiIsaIoProtocolGuid,
163 (VOID **) &IsaIoProtocol,
164 gFdcControllerDriver.DriverBindingHandle,
165 ControllerHandle,
166 EFI_OPEN_PROTOCOL_BY_DRIVER
167 );
168 if (!EFI_ERROR (Status)) {
169 gBS->CloseProtocol (
170 ControllerHandle,
171 &gEfiIsaIoProtocolGuid,
172 gFdcControllerDriver.DriverBindingHandle,
173 ControllerHandle
174 );
175
176 return EFI_UNSUPPORTED;
177 }
178
179 if (Status != EFI_ALREADY_STARTED) {
180 return EFI_UNSUPPORTED;
181 }
182 //
183 // Get the Block I/O Protocol on Controller
184 //
185 Status = gBS->OpenProtocol (
186 ControllerHandle,
187 &gEfiBlockIoProtocolGuid,
188 (VOID **) &BlkIo,
189 gFdcControllerDriver.DriverBindingHandle,
190 ControllerHandle,
191 EFI_OPEN_PROTOCOL_GET_PROTOCOL
192 );
193 if (EFI_ERROR (Status)) {
194 return Status;
195 }
196 //
197 // Get the Floppy Disk Controller's Device structure
198 //
199 FdcDev = FDD_BLK_IO_FROM_THIS (BlkIo);
200
201 return LookupUnicodeString (
202 Language,
203 gIsaFloppyComponentName.SupportedLanguages,
204 FdcDev->ControllerNameTable,
205 ControllerName
206 );
207 }
208
209 VOID
210 AddName (
211 IN FDC_BLK_IO_DEV *FdcDev
212 )
213 /*++
214
215 Routine Description:
216
217 Add the component name for the floppy device
218
219 Arguments:
220
221 FdcDev - A pointer to the FDC_BLK_IO_DEV instance.
222
223 Returns:
224
225 None
226
227 --*/
228 {
229 CHAR16 FloppyDriveName[FLOPPY_DRIVE_NAME_ASCII_LEN + 1];
230
231 StrCpy (FloppyDriveName, FLOPPY_DRIVE_NAME);
232 FloppyDriveName[FLOPPY_DRIVE_NAME_ASCII_LEN - 1] = (CHAR16) (L'0' + FdcDev->Disk);
233 AddUnicodeString (
234 "eng",
235 gIsaFloppyComponentName.SupportedLanguages,
236 &FdcDev->ControllerNameTable,
237 FloppyDriveName
238 );
239 }