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