878ddf1f |
1 | /*++\r |
2 | \r |
3 | Copyright (c) 2006, Intel Corporation \r |
4 | All rights reserved. This program and the accompanying materials \r |
5 | are licensed and made available under the terms and conditions of the BSD License \r |
6 | which accompanies this distribution. The full text of the license may be found at \r |
7 | http://opensource.org/licenses/bsd-license.php \r |
8 | \r |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r |
11 | \r |
12 | Module Name:\r |
13 | \r |
14 | WinNtSimpleFileSystem.h\r |
15 | \r |
16 | Abstract:\r |
17 | \r |
18 | Produce Simple File System abstractions for a directory on your PC using Win32 APIs.\r |
19 | The configuration of what devices to mount or emulate comes from NT \r |
20 | environment variables. The variables must be visible to the Microsoft* \r |
21 | Developer Studio for them to work.\r |
22 | \r |
23 | * Other names and brands may be claimed as the property of others.\r |
24 | \r |
25 | --*/\r |
26 | \r |
27 | #ifndef _WIN_NT_SIMPLE_FILE_SYSTEM_H_\r |
28 | #define _WIN_NT_SIMPLE_FILE_SYSTEM_H_\r |
29 | \r |
30 | \r |
31 | \r |
32 | #define WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE EFI_SIGNATURE_32 ('N', 'T', 'f', 's')\r |
33 | \r |
34 | typedef struct {\r |
35 | UINTN Signature;\r |
36 | EFI_WIN_NT_THUNK_PROTOCOL *WinNtThunk;\r |
37 | EFI_SIMPLE_FILE_SYSTEM_PROTOCOL SimpleFileSystem;\r |
38 | CHAR16 *FilePath;\r |
39 | CHAR16 *VolumeLabel;\r |
40 | EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r |
41 | } WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE;\r |
42 | \r |
43 | #define WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS(a) \\r |
44 | CR (a, \\r |
45 | WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE, \\r |
46 | SimpleFileSystem, \\r |
47 | WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE \\r |
48 | )\r |
49 | \r |
50 | #define WIN_NT_EFI_FILE_PRIVATE_SIGNATURE EFI_SIGNATURE_32 ('l', 'o', 'f', 's')\r |
51 | \r |
52 | typedef struct {\r |
53 | UINTN Signature;\r |
54 | EFI_WIN_NT_THUNK_PROTOCOL *WinNtThunk;\r |
55 | EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem;\r |
56 | EFI_FILE EfiFile;\r |
57 | HANDLE LHandle;\r |
58 | HANDLE DirHandle;\r |
59 | BOOLEAN IsRootDirectory;\r |
60 | BOOLEAN IsDirectoryPath;\r |
61 | BOOLEAN IsOpenedByRead;\r |
62 | CHAR16 *FilePath;\r |
63 | WCHAR *FileName;\r |
64 | BOOLEAN IsValidFindBuf;\r |
65 | WIN32_FIND_DATA FindBuf;\r |
66 | } WIN_NT_EFI_FILE_PRIVATE;\r |
67 | \r |
68 | #define WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS(a) \\r |
69 | CR (a, \\r |
70 | WIN_NT_EFI_FILE_PRIVATE, \\r |
71 | EfiFile, \\r |
72 | WIN_NT_EFI_FILE_PRIVATE_SIGNATURE \\r |
73 | )\r |
74 | \r |
75 | //\r |
76 | // Global Protocol Variables\r |
77 | //\r |
78 | extern EFI_DRIVER_BINDING_PROTOCOL gWinNtSimpleFileSystemDriverBinding;\r |
79 | extern EFI_COMPONENT_NAME_PROTOCOL gWinNtSimpleFileSystemComponentName;\r |
80 | \r |
81 | //\r |
82 | // Driver Binding protocol member functions\r |
83 | //\r |
84 | EFI_STATUS\r |
85 | EFIAPI\r |
86 | WinNtSimpleFileSystemDriverBindingSupported (\r |
87 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r |
88 | IN EFI_HANDLE ControllerHandle,\r |
89 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r |
90 | )\r |
91 | /*++\r |
92 | \r |
93 | Routine Description:\r |
94 | \r |
95 | Check to see if the driver supports a given controller.\r |
96 | \r |
97 | Arguments:\r |
98 | \r |
99 | This - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL.\r |
100 | \r |
101 | ControllerHandle - EFI handle of the controller to test.\r |
102 | \r |
103 | RemainingDevicePath - Pointer to remaining portion of a device path.\r |
104 | \r |
105 | Returns:\r |
106 | \r |
107 | EFI_SUCCESS - The device specified by ControllerHandle and RemainingDevicePath is supported by the driver\r |
108 | specified by This.\r |
109 | \r |
110 | EFI_ALREADY_STARTED - The device specified by ControllerHandle and RemainingDevicePath is already being managed by\r |
111 | the driver specified by This.\r |
112 | \r |
113 | EFI_ACCESS_DENIED - The device specified by ControllerHandle and RemainingDevicePath is already being managed by\r |
114 | a different driver or an application that requires exclusive access.\r |
115 | \r |
116 | EFI_UNSUPPORTED - The device specified by ControllerHandle and RemainingDevicePath is not supported by the\r |
117 | driver specified by This.\r |
118 | \r |
119 | --*/\r |
120 | ;\r |
121 | \r |
122 | EFI_STATUS\r |
123 | EFIAPI\r |
124 | WinNtSimpleFileSystemDriverBindingStart (\r |
125 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r |
126 | IN EFI_HANDLE ControllerHandle,\r |
127 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r |
128 | )\r |
129 | /*++\r |
130 | \r |
131 | Routine Description:\r |
132 | \r |
133 | Starts a device controller or a bus controller.\r |
134 | \r |
135 | Arguments:\r |
136 | \r |
137 | This - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL.\r |
138 | \r |
139 | ControllerHandle - EFI handle of the controller to start.\r |
140 | \r |
141 | RemainingDevicePath - Pointer to remaining portion of a device path.\r |
142 | \r |
143 | Returns:\r |
144 | \r |
145 | EFI_SUCCESS - The device or bus controller has been started.\r |
146 | \r |
147 | EFI_DEVICE_ERROR - The device could not be started due to a device failure.\r |
148 | \r |
149 | EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.\r |
150 | \r |
151 | --*/\r |
152 | ;\r |
153 | \r |
154 | EFI_STATUS\r |
155 | EFIAPI\r |
156 | WinNtSimpleFileSystemDriverBindingStop (\r |
157 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r |
158 | IN EFI_HANDLE ControllerHandle,\r |
159 | IN UINTN NumberOfChildren,\r |
160 | IN EFI_HANDLE *ChildHandleBuffer OPTIONAL\r |
161 | )\r |
162 | /*++\r |
163 | \r |
164 | Routine Description:\r |
165 | \r |
166 | TODO: Add function description\r |
167 | \r |
168 | Arguments:\r |
169 | \r |
170 | This - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL.\r |
171 | \r |
172 | ControllerHandle - A handle to the device to be stopped.\r |
173 | \r |
174 | NumberOfChildren - The number of child device handles in ChildHandleBuffer.\r |
175 | \r |
176 | ChildHandleBuffer - An array of child device handles to be freed.\r |
177 | \r |
178 | Returns:\r |
179 | \r |
180 | EFI_SUCCESS - The device has been stopped.\r |
181 | \r |
182 | EFI_DEVICE_ERROR - The device could not be stopped due to a device failure.\r |
183 | \r |
184 | --*/\r |
185 | ;\r |
186 | \r |
187 | //\r |
188 | // Simple File System protocol member functions\r |
189 | //\r |
190 | EFI_STATUS\r |
191 | EFIAPI\r |
192 | WinNtSimpleFileSystemOpenVolume (\r |
193 | IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,\r |
194 | OUT EFI_FILE **Root\r |
195 | )\r |
196 | /*++\r |
197 | \r |
198 | Routine Description:\r |
199 | \r |
200 | Open the root directory on a volume.\r |
201 | \r |
202 | Arguments:\r |
203 | \r |
204 | This - A pointer to the volume to open.\r |
205 | \r |
206 | Root - A pointer to storage for the returned opened file handle of the root directory.\r |
207 | \r |
208 | Returns:\r |
209 | \r |
210 | EFI_SUCCESS - The volume was opened.\r |
211 | \r |
212 | EFI_UNSUPPORTED - The volume does not support the requested file system type.\r |
213 | \r |
214 | EFI_NO_MEDIA - The device has no media.\r |
215 | \r |
216 | EFI_DEVICE_ERROR - The device reported an error.\r |
217 | \r |
218 | EFI_VOLUME_CORRUPTED - The file system structures are corrupted.\r |
219 | \r |
220 | EFI_ACCESS_DENIED - The service denied access to the file.\r |
221 | \r |
222 | EFI_OUT_OF_RESOURCES - The file volume could not be opened due to lack of resources.\r |
223 | \r |
224 | EFI_MEDIA_CHANGED - The device has new media or the media is no longer supported.\r |
225 | \r |
226 | --*/\r |
227 | ;\r |
228 | \r |
229 | EFI_STATUS\r |
230 | EFIAPI\r |
231 | WinNtSimpleFileSystemOpen (\r |
232 | IN EFI_FILE *This,\r |
233 | OUT EFI_FILE **NewHandle,\r |
234 | IN CHAR16 *FileName,\r |
235 | IN UINT64 OpenMode,\r |
236 | IN UINT64 Attributes\r |
237 | )\r |
238 | /*++\r |
239 | \r |
240 | Routine Description:\r |
241 | \r |
242 | Open a file relative to the source file location.\r |
243 | \r |
244 | Arguments:\r |
245 | \r |
246 | This - A pointer to the source file location.\r |
247 | \r |
248 | NewHandle - Pointer to storage for the new file handle.\r |
249 | \r |
250 | FileName - Pointer to the file name to be opened.\r |
251 | \r |
252 | OpenMode - File open mode information.\r |
253 | \r |
254 | Attributes - File creation attributes.\r |
255 | \r |
256 | Returns:\r |
257 | \r |
258 | EFI_SUCCESS - The file was opened.\r |
259 | \r |
260 | EFI_NOT_FOUND - The file could not be found in the volume.\r |
261 | \r |
262 | EFI_NO_MEDIA - The device has no media.\r |
263 | \r |
264 | EFI_MEDIA_CHANGED - The device has new media or the media is no longer supported.\r |
265 | \r |
266 | EFI_DEVICE_ERROR - The device reported an error.\r |
267 | \r |
268 | EFI_VOLUME_CORRUPTED - The file system structures are corrupted.\r |
269 | \r |
270 | EFI_WRITE_PROTECTED - The volume or file is write protected.\r |
271 | \r |
272 | EFI_ACCESS_DENIED - The service denied access to the file.\r |
273 | \r |
274 | EFI_OUT_OF_RESOURCES - Not enough resources were available to open the file.\r |
275 | \r |
276 | EFI_VOLUME_FULL - There is not enough space left to create the new file.\r |
277 | \r |
278 | --*/\r |
279 | ;\r |
280 | \r |
281 | EFI_STATUS\r |
282 | EFIAPI\r |
283 | WinNtSimpleFileSystemClose (\r |
284 | IN EFI_FILE *This\r |
285 | )\r |
286 | /*++\r |
287 | \r |
288 | Routine Description:\r |
289 | \r |
290 | Close the specified file handle.\r |
291 | \r |
292 | Arguments:\r |
293 | \r |
294 | This - Pointer to a returned opened file handle.\r |
295 | \r |
296 | Returns:\r |
297 | \r |
298 | EFI_SUCCESS - The file handle has been closed.\r |
299 | \r |
300 | --*/\r |
301 | ;\r |
302 | \r |
303 | EFI_STATUS\r |
304 | EFIAPI\r |
305 | WinNtSimpleFileSystemDelete (\r |
306 | IN EFI_FILE *This\r |
307 | )\r |
308 | /*++\r |
309 | \r |
310 | Routine Description:\r |
311 | \r |
312 | Close and delete a file.\r |
313 | \r |
314 | Arguments:\r |
315 | \r |
316 | This - Pointer to a returned opened file handle.\r |
317 | \r |
318 | Returns:\r |
319 | \r |
320 | EFI_SUCCESS - The file handle was closed and deleted.\r |
321 | \r |
322 | EFI_WARN_DELETE_FAILURE - The handle was closed but could not be deleted.\r |
323 | \r |
324 | --*/\r |
325 | ;\r |
326 | \r |
327 | EFI_STATUS\r |
328 | EFIAPI\r |
329 | WinNtSimpleFileSystemRead (\r |
330 | IN EFI_FILE *This,\r |
331 | IN OUT UINTN *BufferSize,\r |
332 | OUT VOID *Buffer\r |
333 | )\r |
334 | /*++\r |
335 | \r |
336 | Routine Description:\r |
337 | \r |
338 | Read data from a file.\r |
339 | \r |
340 | Arguments:\r |
341 | \r |
342 | This - Pointer to a returned open file handle.\r |
343 | \r |
344 | BufferSize - On input, the size of the Buffer. On output, the number of bytes stored in the Buffer.\r |
345 | \r |
346 | Buffer - Pointer to the first byte of the read Buffer.\r |
347 | \r |
348 | Returns:\r |
349 | \r |
350 | EFI_SUCCESS - The data was read.\r |
351 | \r |
352 | EFI_NO_MEDIA - The device has no media.\r |
353 | \r |
354 | EFI_DEVICE_ERROR - The device reported an error.\r |
355 | \r |
356 | EFI_VOLUME_CORRUPTED - The file system structures are corrupted.\r |
357 | \r |
358 | EFI_BUFFER_TOO_SMALL - The supplied buffer size was too small to store the current directory entry.\r |
359 | *BufferSize has been updated with the size needed to complete the request.\r |
360 | \r |
361 | --*/\r |
362 | ;\r |
363 | \r |
364 | EFI_STATUS\r |
365 | EFIAPI\r |
366 | WinNtSimpleFileSystemWrite (\r |
367 | IN EFI_FILE *This,\r |
368 | IN OUT UINTN *BufferSize,\r |
369 | IN VOID *Buffer\r |
370 | )\r |
371 | /*++\r |
372 | \r |
373 | Routine Description:\r |
374 | \r |
375 | Write data to a file.\r |
376 | \r |
377 | Arguments:\r |
378 | \r |
379 | This - Pointer to an opened file handle.\r |
380 | \r |
381 | BufferSize - On input, the number of bytes in the Buffer to write to the file. On output, the number of bytes\r |
382 | of data written to the file.\r |
383 | \r |
384 | Buffer - Pointer to the first by of data in the buffer to write to the file.\r |
385 | \r |
386 | Returns:\r |
387 | \r |
388 | EFI_SUCCESS - The data was written to the file.\r |
389 | \r |
390 | EFI_UNSUPPORTED - Writes to an open directory are not supported.\r |
391 | \r |
392 | EFI_NO_MEDIA - The device has no media.\r |
393 | \r |
394 | EFI_DEVICE_ERROR - The device reported an error.\r |
395 | \r |
396 | EFI_VOLUME_CORRUPTED - The file system structures are corrupt.\r |
397 | \r |
398 | EFI_WRITE_PROTECTED - The file, directory, volume, or device is write protected.\r |
399 | \r |
400 | EFI_ACCESS_DENIED - The file was opened read-only.\r |
401 | \r |
402 | EFI_VOLUME_FULL - The volume is full.\r |
403 | \r |
404 | --*/\r |
405 | ;\r |
406 | \r |
407 | EFI_STATUS\r |
408 | EFIAPI\r |
409 | WinNtSimpleFileSystemSetPosition (\r |
410 | IN EFI_FILE *This,\r |
411 | IN UINT64 Position\r |
412 | )\r |
413 | /*++\r |
414 | \r |
415 | Routine Description:\r |
416 | \r |
417 | Set a file's current position.\r |
418 | \r |
419 | Arguments:\r |
420 | \r |
421 | This - Pointer to an opened file handle.\r |
422 | \r |
423 | Position - The byte position from the start of the file to set.\r |
424 | \r |
425 | Returns:\r |
426 | \r |
427 | EFI_SUCCESS - The file position has been changed.\r |
428 | \r |
429 | EFI_UNSUPPORTED - The seek request for non-zero is not supported for directories.\r |
430 | \r |
431 | --*/\r |
432 | ;\r |
433 | \r |
434 | EFI_STATUS\r |
435 | EFIAPI\r |
436 | WinNtSimpleFileSystemGetPosition (\r |
437 | IN EFI_FILE *This,\r |
438 | OUT UINT64 *Position\r |
439 | )\r |
440 | /*++\r |
441 | \r |
442 | Routine Description:\r |
443 | \r |
444 | Get a file's current position.\r |
445 | \r |
446 | Arguments:\r |
447 | \r |
448 | This - Pointer to an opened file handle.\r |
449 | \r |
450 | Position - Pointer to storage for the current position.\r |
451 | \r |
452 | Returns:\r |
453 | \r |
454 | EFI_SUCCESS - The file position has been reported.\r |
455 | \r |
456 | EFI_UNSUPPORTED - Not valid for directories.\r |
457 | \r |
458 | --*/\r |
459 | ;\r |
460 | \r |
461 | EFI_STATUS\r |
462 | EFIAPI\r |
463 | WinNtSimpleFileSystemGetInfo (\r |
464 | IN EFI_FILE *This,\r |
465 | IN EFI_GUID *InformationType,\r |
466 | IN OUT UINTN *BufferSize,\r |
467 | OUT VOID *Buffer\r |
468 | )\r |
469 | /*++\r |
470 | \r |
471 | Routine Description:\r |
472 | \r |
473 | Return information about a file or volume.\r |
474 | \r |
475 | Arguments:\r |
476 | \r |
477 | This - Pointer to an opened file handle.\r |
478 | \r |
479 | InformationType - GUID describing the type of information to be returned.\r |
480 | \r |
481 | BufferSize - On input, the size of the information buffer. On output, the number of bytes written to the\r |
482 | information buffer.\r |
483 | \r |
484 | Buffer - Pointer to the first byte of the information buffer.\r |
485 | \r |
486 | Returns:\r |
487 | \r |
488 | EFI_SUCCESS - The requested information has been written into the buffer.\r |
489 | \r |
490 | EFI_UNSUPPORTED - The InformationType is not known.\r |
491 | \r |
492 | EFI_NO_MEDIA - The device has no media.\r |
493 | \r |
494 | EFI_DEVICE_ERROR - The device reported an error.\r |
495 | \r |
496 | EFI_VOLUME_CORRUPTED - The file system structures are corrupt.\r |
497 | \r |
498 | EFI_BUFFER_TOO_SMALL - The buffer size was too small to contain the requested information. The buffer size has\r |
499 | been updated with the size needed to complete the requested operation.\r |
500 | \r |
501 | --*/\r |
502 | ;\r |
503 | \r |
504 | EFI_STATUS\r |
505 | EFIAPI\r |
506 | WinNtSimpleFileSystemSetInfo (\r |
507 | IN EFI_FILE *This,\r |
508 | IN EFI_GUID *InformationType,\r |
509 | IN UINTN BufferSize,\r |
510 | IN VOID *Buffer\r |
511 | )\r |
512 | /*++\r |
513 | \r |
514 | Routine Description:\r |
515 | \r |
516 | Set information about a file or volume.\r |
517 | \r |
518 | Arguments:\r |
519 | \r |
520 | This - Pointer to an opened file handle.\r |
521 | \r |
522 | InformationType - GUID identifying the type of information to set.\r |
523 | \r |
524 | BufferSize - Number of bytes of data in the information buffer.\r |
525 | \r |
526 | Buffer - Pointer to the first byte of data in the information buffer.\r |
527 | \r |
528 | Returns:\r |
529 | \r |
530 | EFI_SUCCESS - The file or volume information has been updated.\r |
531 | \r |
532 | EFI_UNSUPPORTED - The information identifier is not recognised.\r |
533 | \r |
534 | EFI_NO_MEDIA - The device has no media.\r |
535 | \r |
536 | EFI_DEVICE_ERROR - The device reported an error.\r |
537 | \r |
538 | EFI_VOLUME_CORRUPTED - The file system structures are corrupt.\r |
539 | \r |
540 | EFI_WRITE_PROTECTED - The file, directory, volume, or device is write protected.\r |
541 | \r |
542 | EFI_ACCESS_DENIED - The file was opened read-only.\r |
543 | \r |
544 | EFI_VOLUME_FULL - The volume is full.\r |
545 | \r |
546 | EFI_BAD_BUFFER_SIZE - The buffer size is smaller than the type indicated by InformationType.\r |
547 | \r |
548 | --*/\r |
549 | ;\r |
550 | \r |
551 | EFI_STATUS\r |
552 | EFIAPI\r |
553 | WinNtSimpleFileSystemFlush (\r |
554 | IN EFI_FILE *This\r |
555 | )\r |
556 | /*++\r |
557 | \r |
558 | Routine Description:\r |
559 | \r |
560 | Flush all modified data to the media.\r |
561 | \r |
562 | Arguments:\r |
563 | \r |
564 | This - Pointer to an opened file handle.\r |
565 | \r |
566 | Returns:\r |
567 | \r |
568 | EFI_SUCCESS - The data has been flushed.\r |
569 | \r |
570 | EFI_NO_MEDIA - The device has no media.\r |
571 | \r |
572 | EFI_DEVICE_ERROR - The device reported an error.\r |
573 | \r |
574 | EFI_VOLUME_CORRUPTED - The file system structures have been corrupted.\r |
575 | \r |
576 | EFI_WRITE_PROTECTED - The file, directory, volume, or device is write protected.\r |
577 | \r |
578 | EFI_ACCESS_DENIED - The file was opened read-only.\r |
579 | \r |
580 | EFI_VOLUME_FULL - The volume is full.\r |
581 | \r |
582 | --*/\r |
583 | ;\r |
584 | \r |
585 | #endif /* _WIN_NT_SIMPLE_FILE_SYSTEM_H_ */\r |
586 | \r |
587 | /* eof - WinNtSimpleFileSystem.h */\r |