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