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