TianoCore EDK2 master
Loading...
Searching...
No Matches
Udf.c
Go to the documentation of this file.
1
9#include "Udf.h"
10
11//
12// UDF filesystem driver's Global Variables.
13//
14EFI_DRIVER_BINDING_PROTOCOL gUdfDriverBinding = {
18 0x10,
19 NULL,
20 NULL
21};
22
23EFI_SIMPLE_FILE_SYSTEM_PROTOCOL gUdfSimpleFsTemplate = {
24 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION,
26};
27
44EFIAPI
47 IN EFI_HANDLE ControllerHandle,
48 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
49 )
50{
51 EFI_STATUS Status;
53
54 //
55 // Open DiskIo protocol on ControllerHandle
56 //
57 Status = gBS->OpenProtocol (
58 ControllerHandle,
59 &gEfiDiskIoProtocolGuid,
60 (VOID **)&DiskIo,
61 This->DriverBindingHandle,
62 ControllerHandle,
63 EFI_OPEN_PROTOCOL_BY_DRIVER
64 );
65 if (EFI_ERROR (Status)) {
66 return Status;
67 }
68
69 //
70 // Close DiskIo protocol on ControllerHandle
71 //
72 gBS->CloseProtocol (
73 ControllerHandle,
74 &gEfiDiskIoProtocolGuid,
75 This->DriverBindingHandle,
76 ControllerHandle
77 );
78
79 //
80 // Test whether ControllerHandle supports BlockIo protocol
81 //
82 Status = gBS->OpenProtocol (
83 ControllerHandle,
84 &gEfiBlockIoProtocolGuid,
85 NULL,
86 This->DriverBindingHandle,
87 ControllerHandle,
88 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
89 );
90
91 return Status;
92}
93
111EFIAPI
114 IN EFI_HANDLE ControllerHandle,
115 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
116 )
117{
118 EFI_TPL OldTpl;
119 EFI_STATUS Status;
120 EFI_BLOCK_IO_PROTOCOL *BlockIo;
121 EFI_DISK_IO_PROTOCOL *DiskIo;
122 PRIVATE_UDF_SIMPLE_FS_DATA *PrivFsData;
123
124 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
125
126 //
127 // Open BlockIo protocol on ControllerHandle
128 //
129 Status = gBS->OpenProtocol (
130 ControllerHandle,
131 &gEfiBlockIoProtocolGuid,
132 (VOID **)&BlockIo,
133 This->DriverBindingHandle,
134 ControllerHandle,
135 EFI_OPEN_PROTOCOL_GET_PROTOCOL
136 );
137 ASSERT_EFI_ERROR (Status);
138
139 //
140 // Open DiskIo protocol on ControllerHandle
141 //
142 Status = gBS->OpenProtocol (
143 ControllerHandle,
144 &gEfiDiskIoProtocolGuid,
145 (VOID **)&DiskIo,
146 This->DriverBindingHandle,
147 ControllerHandle,
148 EFI_OPEN_PROTOCOL_BY_DRIVER
149 );
150 ASSERT_EFI_ERROR (Status);
151
152 //
153 // Check if ControllerHandle supports an UDF file system
154 //
155 Status = SupportUdfFileSystem (This, ControllerHandle);
156 if (EFI_ERROR (Status)) {
157 goto Exit;
158 }
159
160 //
161 // Initialize private file system structure
162 //
163 PrivFsData =
166 if (PrivFsData == NULL) {
167 Status = EFI_OUT_OF_RESOURCES;
168 goto Exit;
169 }
170
171 //
172 // Create new child handle
173 //
174 PrivFsData->Signature = PRIVATE_UDF_SIMPLE_FS_DATA_SIGNATURE;
175 PrivFsData->BlockIo = BlockIo;
176 PrivFsData->DiskIo = DiskIo;
177 PrivFsData->Handle = ControllerHandle;
178
179 //
180 // Set up SimpleFs protocol
181 //
182 CopyMem (
183 (VOID *)&PrivFsData->SimpleFs,
184 (VOID *)&gUdfSimpleFsTemplate,
186 );
187
188 //
189 // Install child handle
190 //
191 Status = gBS->InstallMultipleProtocolInterfaces (
192 &PrivFsData->Handle,
193 &gEfiSimpleFileSystemProtocolGuid,
194 &PrivFsData->SimpleFs,
195 NULL
196 );
197
198Exit:
199 if (EFI_ERROR (Status)) {
200 //
201 // Close DiskIo protocol on ControllerHandle
202 //
203 gBS->CloseProtocol (
204 ControllerHandle,
205 &gEfiDiskIoProtocolGuid,
206 This->DriverBindingHandle,
207 ControllerHandle
208 );
209 //
210 // Close BlockIo protocol on ControllerHandle
211 //
212 gBS->CloseProtocol (
213 ControllerHandle,
214 &gEfiBlockIoProtocolGuid,
215 This->DriverBindingHandle,
216 ControllerHandle
217 );
218 }
219
220 gBS->RestoreTPL (OldTpl);
221
222 return Status;
223}
224
240EFIAPI
243 IN EFI_HANDLE ControllerHandle,
244 IN UINTN NumberOfChildren,
245 IN EFI_HANDLE *ChildHandleBuffer
246 )
247{
248 PRIVATE_UDF_SIMPLE_FS_DATA *PrivFsData;
249 EFI_STATUS Status;
251
252 //
253 // Open SimpleFs protocol on ControllerHandle
254 //
255 Status = gBS->OpenProtocol (
256 ControllerHandle,
257 &gEfiSimpleFileSystemProtocolGuid,
258 (VOID **)&SimpleFs,
259 This->DriverBindingHandle,
260 ControllerHandle,
261 EFI_OPEN_PROTOCOL_GET_PROTOCOL
262 );
263 if (!EFI_ERROR (Status)) {
264 PrivFsData = PRIVATE_UDF_SIMPLE_FS_DATA_FROM_THIS (SimpleFs);
265
266 //
267 // Uninstall child handle
268 //
269 Status = gBS->UninstallMultipleProtocolInterfaces (
270 PrivFsData->Handle,
271 &gEfiSimpleFileSystemProtocolGuid,
272 &PrivFsData->SimpleFs,
273 NULL
274 );
275
276 FreePool ((VOID *)PrivFsData);
277 }
278
279 if (!EFI_ERROR (Status)) {
280 //
281 // Close DiskIo protocol on ControllerHandle
282 //
283 gBS->CloseProtocol (
284 ControllerHandle,
285 &gEfiDiskIoProtocolGuid,
286 This->DriverBindingHandle,
287 ControllerHandle
288 );
289 //
290 // Close BlockIo protocol on ControllerHandle
291 //
292 gBS->CloseProtocol (
293 ControllerHandle,
294 &gEfiBlockIoProtocolGuid,
295 This->DriverBindingHandle,
296 ControllerHandle
297 );
298 }
299
300 return Status;
301}
302
315EFIAPI
317 IN EFI_HANDLE ImageHandle,
318 IN EFI_SYSTEM_TABLE *SystemTable
319 )
320{
321 EFI_STATUS Status;
322
324 ImageHandle,
325 SystemTable,
326 &gUdfDriverBinding,
327 ImageHandle,
328 &gUdfComponentName,
329 &gUdfComponentName2
330 );
331 ASSERT_EFI_ERROR (Status);
332
333 return Status;
334}
UINT64 UINTN
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STATUS EFIAPI UdfOpenVolume(IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This, OUT EFI_FILE_PROTOCOL **Root)
Definition: File.c:53
EFI_STATUS SupportUdfFileSystem(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle)
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
EFI_STATUS EFIAPI UdfDriverBindingStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: Udf.c:112
EFI_STATUS EFIAPI InitializeUdf(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: Udf.c:316
EFI_STATUS EFIAPI UdfDriverBindingStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
Definition: Udf.c:241
EFI_STATUS EFIAPI UdfDriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: Udf.c:45
VOID EFIAPI Exit(IN EFI_STATUS Status)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
UINTN EFI_TPL
Definition: UefiBaseType.h:41
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
EFI_BOOT_SERVICES * gBS
EFI_STATUS EFIAPI EfiLibInstallDriverBindingComponentName2(IN CONST EFI_HANDLE ImageHandle, IN CONST EFI_SYSTEM_TABLE *SystemTable, IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, IN EFI_HANDLE DriverBindingHandle, IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName OPTIONAL, IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 OPTIONAL)