Add WinNtSimpleFileSystemDxe driver into Nt32Pkg.
[mirror_edk2.git] / Nt32Pkg / WinNtSimpleFileSystemDxe / ComponentName.c
1 /*++
2
3 Copyright (c) 2006, Intel Corporation
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 Module Name:
13
14 ComponentName.c
15
16 Abstract:
17
18 --*/
19 //
20 // The package level header files this module uses
21 //
22 #include <Uefi.h>
23 #include <WinNtDxe.h>
24 //
25 // The protocols, PPI and GUID defintions for this module
26 //
27 #include <Guid/FileSystemVolumeLabelInfo.h>
28 #include <Protocol/WinNtIo.h>
29 #include <Protocol/ComponentName.h>
30 #include <Guid/FileInfo.h>
31 #include <Protocol/DriverBinding.h>
32 #include <Guid/FileSystemInfo.h>
33 #include <Protocol/SimpleFileSystem.h>
34 //
35 // The Library classes this module consumes
36 //
37 #include <Library/DebugLib.h>
38 #include <Library/BaseLib.h>
39 #include <Library/UefiDriverEntryPoint.h>
40 #include <Library/UefiLib.h>
41 #include <Library/BaseMemoryLib.h>
42 #include <Library/UefiBootServicesTableLib.h>
43 #include <Library/MemoryAllocationLib.h>
44
45 #include "WinNtSimpleFileSystem.h"
46
47 //
48 // EFI Component Name Functions
49 //
50 EFI_STATUS
51 EFIAPI
52 WinNtSimpleFileSystemComponentNameGetDriverName (
53 IN EFI_COMPONENT_NAME_PROTOCOL *This,
54 IN CHAR8 *Language,
55 OUT CHAR16 **DriverName
56 );
57
58 EFI_STATUS
59 EFIAPI
60 WinNtSimpleFileSystemComponentNameGetControllerName (
61 IN EFI_COMPONENT_NAME_PROTOCOL *This,
62 IN EFI_HANDLE ControllerHandle,
63 IN EFI_HANDLE ChildHandle OPTIONAL,
64 IN CHAR8 *Language,
65 OUT CHAR16 **ControllerName
66 );
67
68 //
69 // EFI Component Name Protocol
70 //
71 EFI_COMPONENT_NAME_PROTOCOL gWinNtSimpleFileSystemComponentName = {
72 WinNtSimpleFileSystemComponentNameGetDriverName,
73 WinNtSimpleFileSystemComponentNameGetControllerName,
74 "eng"
75 };
76
77 static EFI_UNICODE_STRING_TABLE mWinNtSimpleFileSystemDriverNameTable[] = {
78 {
79 "eng",
80 L"Windows Simple File System Driver"
81 },
82 {
83 NULL,
84 NULL
85 }
86 };
87
88 EFI_STATUS
89 EFIAPI
90 WinNtSimpleFileSystemComponentNameGetDriverName (
91 IN EFI_COMPONENT_NAME_PROTOCOL *This,
92 IN CHAR8 *Language,
93 OUT CHAR16 **DriverName
94 )
95 /*++
96
97 Routine Description:
98 Retrieves a Unicode string that is the user readable name of the EFI Driver.
99
100 Arguments:
101 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
102 Language - A pointer to a three character ISO 639-2 language identifier.
103 This is the language of the driver name that that the caller
104 is requesting, and it must match one of the languages specified
105 in SupportedLanguages. The number of languages supported by a
106 driver is up to the driver writer.
107 DriverName - A pointer to the Unicode string to return. This Unicode string
108 is the name of the driver specified by This in the language
109 specified by Language.
110
111 Returns:
112 EFI_SUCCESS - The Unicode string for the Driver specified by This
113 and the language specified by Language was returned
114 in DriverName.
115 EFI_INVALID_PARAMETER - Language is NULL.
116 EFI_INVALID_PARAMETER - DriverName is NULL.
117 EFI_UNSUPPORTED - The driver specified by This does not support the
118 language specified by Language.
119
120 --*/
121 {
122 return LookupUnicodeString (
123 Language,
124 gWinNtSimpleFileSystemComponentName.SupportedLanguages,
125 mWinNtSimpleFileSystemDriverNameTable,
126 DriverName
127 );
128 }
129
130 EFI_STATUS
131 EFIAPI
132 WinNtSimpleFileSystemComponentNameGetControllerName (
133 IN EFI_COMPONENT_NAME_PROTOCOL *This,
134 IN EFI_HANDLE ControllerHandle,
135 IN EFI_HANDLE ChildHandle OPTIONAL,
136 IN CHAR8 *Language,
137 OUT CHAR16 **ControllerName
138 )
139 /*++
140
141 Routine Description:
142 Retrieves a Unicode string that is the user readable name of the controller
143 that is being managed by an EFI Driver.
144
145 Arguments:
146 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
147 ControllerHandle - The handle of a controller that the driver specified by
148 This is managing. This handle specifies the controller
149 whose name is to be returned.
150 ChildHandle - The handle of the child controller to retrieve the name
151 of. This is an optional parameter that may be NULL. It
152 will be NULL for device drivers. It will also be NULL
153 for a bus drivers that wish to retrieve the name of the
154 bus controller. It will not be NULL for a bus driver
155 that wishes to retrieve the name of a child controller.
156 Language - A pointer to a three character ISO 639-2 language
157 identifier. This is the language of the controller name
158 that that the caller is requesting, and it must match one
159 of the languages specified in SupportedLanguages. The
160 number of languages supported by a driver is up to the
161 driver writer.
162 ControllerName - A pointer to the Unicode string to return. This Unicode
163 string is the name of the controller specified by
164 ControllerHandle and ChildHandle in the language specified
165 by Language from the point of view of the driver specified
166 by This.
167
168 Returns:
169 EFI_SUCCESS - The Unicode string for the user readable name in the
170 language specified by Language for the driver
171 specified by This was returned in DriverName.
172 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
173 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
174 EFI_INVALID_PARAMETER - Language is NULL.
175 EFI_INVALID_PARAMETER - ControllerName is NULL.
176 EFI_UNSUPPORTED - The driver specified by This is not currently managing
177 the controller specified by ControllerHandle and
178 ChildHandle.
179 EFI_UNSUPPORTED - The driver specified by This does not support the
180 language specified by Language.
181
182 --*/
183 {
184 EFI_STATUS Status;
185 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem;
186 WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE *Private;
187
188 //
189 // This is a device driver, so ChildHandle must be NULL.
190 //
191 if (ChildHandle != NULL) {
192 return EFI_UNSUPPORTED;
193 }
194
195 //
196 // Make sure this driver is currently managing ControllerHandle
197 //
198 Status = EfiTestManagedDevice (
199 ControllerHandle,
200 gWinNtSimpleFileSystemDriverBinding.DriverBindingHandle,
201 &gEfiWinNtIoProtocolGuid
202 );
203 if (EFI_ERROR (Status)) {
204 return EFI_UNSUPPORTED;
205 }
206 //
207 // Get our context back
208 //
209 Status = gBS->OpenProtocol (
210 ControllerHandle,
211 &gEfiSimpleFileSystemProtocolGuid,
212 &SimpleFileSystem,
213 gWinNtSimpleFileSystemDriverBinding.DriverBindingHandle,
214 ControllerHandle,
215 EFI_OPEN_PROTOCOL_GET_PROTOCOL
216 );
217 if (EFI_ERROR (Status)) {
218 return EFI_UNSUPPORTED;
219 }
220
221 Private = WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (SimpleFileSystem);
222
223 return LookupUnicodeString (
224 Language,
225 gWinNtSimpleFileSystemComponentName.SupportedLanguages,
226 Private->ControllerNameTable,
227 ControllerName
228 );
229 }