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