13#include "EmuSimpleFileSystem.h"
37EmuSimpleFileSystemOpen (
53 if ((This ==
NULL) || (NewHandle ==
NULL) || (FileName ==
NULL)) {
54 return EFI_INVALID_PARAMETER;
58 case EFI_FILE_MODE_CREATE | EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE:
59 if (Attributes &~EFI_FILE_VALID_ATTR) {
60 return EFI_INVALID_PARAMETER;
63 if (Attributes & EFI_FILE_READ_ONLY) {
64 return EFI_INVALID_PARAMETER;
70 case EFI_FILE_MODE_READ:
71 case EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE:
75 return EFI_INVALID_PARAMETER;
78 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
80 PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
83 if (NewPrivateFile ==
NULL) {
84 Status = EFI_OUT_OF_RESOURCES;
88 Status = PrivateFile->Io->Open (PrivateFile->Io, &NewPrivateFile->Io, FileName, OpenMode, Attributes);
89 if (!EFI_ERROR (Status)) {
90 *NewHandle = &NewPrivateFile->EfiFile;
97 gBS->RestoreTPL (OldTpl);
112EmuSimpleFileSystemClose (
121 return EFI_INVALID_PARAMETER;
124 PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
126 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
128 Status = PrivateFile->Io->Close (PrivateFile->Io);
129 if (!EFI_ERROR (Status)) {
130 gBS->FreePool (PrivateFile);
133 gBS->RestoreTPL (OldTpl);
149EmuSimpleFileSystemDelete (
158 return EFI_INVALID_PARAMETER;
161 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
163 PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
165 Status = PrivateFile->Io->Delete (PrivateFile->Io);
166 if (!EFI_ERROR (Status)) {
167 gBS->FreePool (PrivateFile);
170 gBS->RestoreTPL (OldTpl);
191EmuSimpleFileSystemRead (
201 if ((This ==
NULL) || (BufferSize ==
NULL)) {
202 return EFI_INVALID_PARAMETER;
205 if ((*BufferSize != 0) && (Buffer ==
NULL)) {
207 return EFI_INVALID_PARAMETER;
210 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
212 PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
214 Status = PrivateFile->Io->Read (PrivateFile->Io, BufferSize, Buffer);
216 gBS->RestoreTPL (OldTpl);
240EmuSimpleFileSystemWrite (
250 if ((This ==
NULL) || (BufferSize ==
NULL) || (Buffer ==
NULL)) {
251 return EFI_INVALID_PARAMETER;
254 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
256 PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
258 Status = PrivateFile->Io->Write (PrivateFile->Io, BufferSize, Buffer);
260 gBS->RestoreTPL (OldTpl);
276EmuSimpleFileSystemGetPosition (
285 if ((This ==
NULL) || (Position ==
NULL)) {
286 return EFI_INVALID_PARAMETER;
289 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
291 PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
293 Status = PrivateFile->Io->GetPosition (PrivateFile->Io, Position);
295 gBS->RestoreTPL (OldTpl);
311EmuSimpleFileSystemSetPosition (
321 return EFI_INVALID_PARAMETER;
324 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
326 PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
328 Status = PrivateFile->Io->SetPosition (PrivateFile->Io, Position);
330 gBS->RestoreTPL (OldTpl);
354EmuSimpleFileSystemGetInfo (
365 if ((This ==
NULL) || (InformationType ==
NULL) || (BufferSize ==
NULL)) {
366 return EFI_INVALID_PARAMETER;
369 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
371 PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
373 Status = PrivateFile->Io->GetInfo (PrivateFile->Io, InformationType, BufferSize, Buffer);
375 gBS->RestoreTPL (OldTpl);
398EmuSimpleFileSystemSetInfo (
412 if ((This ==
NULL) || (InformationType ==
NULL) || (BufferSize == 0) || (Buffer ==
NULL)) {
413 return EFI_INVALID_PARAMETER;
416 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
418 PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
420 Status = PrivateFile->Io->SetInfo (PrivateFile->Io, InformationType, BufferSize, Buffer);
422 gBS->RestoreTPL (OldTpl);
443EmuSimpleFileSystemFlush (
452 return EFI_INVALID_PARAMETER;
455 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
457 PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
459 Status = PrivateFile->Io->Flush (PrivateFile->Io);
461 gBS->RestoreTPL (OldTpl);
482EmuSimpleFileSystemOpenVolume (
492 Status = EFI_UNSUPPORTED;
494 if ((This ==
NULL) || (Root ==
NULL)) {
495 return EFI_INVALID_PARAMETER;
498 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
500 Private = EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (This);
503 if (PrivateFile ==
NULL) {
504 Status = EFI_OUT_OF_RESOURCES;
508 PrivateFile->Signature = EMU_EFI_FILE_PRIVATE_SIGNATURE;
509 PrivateFile->IoThunk = Private->IoThunk;
510 PrivateFile->SimpleFileSystem = This;
512 ZeroMem (&PrivateFile->EfiFile, sizeof (PrivateFile->EfiFile));
513 PrivateFile->EfiFile.
Revision = EFI_FILE_PROTOCOL_REVISION;
514 PrivateFile->EfiFile.Open = EmuSimpleFileSystemOpen;
515 PrivateFile->EfiFile.Close = EmuSimpleFileSystemClose;
516 PrivateFile->EfiFile.Delete = EmuSimpleFileSystemDelete;
517 PrivateFile->EfiFile.Read = EmuSimpleFileSystemRead;
518 PrivateFile->EfiFile.Write = EmuSimpleFileSystemWrite;
519 PrivateFile->EfiFile.GetPosition = EmuSimpleFileSystemGetPosition;
520 PrivateFile->EfiFile.SetPosition = EmuSimpleFileSystemSetPosition;
521 PrivateFile->EfiFile.GetInfo = EmuSimpleFileSystemGetInfo;
522 PrivateFile->EfiFile.SetInfo = EmuSimpleFileSystemSetInfo;
523 PrivateFile->EfiFile.Flush = EmuSimpleFileSystemFlush;
525 *Root = &PrivateFile->EfiFile;
527 Status = Private->Io->OpenVolume (Private->Io, &PrivateFile->Io);
528 if (EFI_ERROR (Status)) {
535 &Private->ControllerNameTable,
543 &Private->ControllerNameTable,
549 if (EFI_ERROR (Status)) {
551 gBS->FreePool (PrivateFile);
557 gBS->RestoreTPL (OldTpl);
606EmuSimpleFileSystemDriverBindingSupported (
618 Status =
gBS->OpenProtocol (
620 &gEmuIoThunkProtocolGuid,
621 (VOID **)&EmuIoThunk,
622 This->DriverBindingHandle,
624 EFI_OPEN_PROTOCOL_BY_DRIVER
626 if (EFI_ERROR (Status)) {
633 Status = EFI_UNSUPPORTED;
634 if (
CompareGuid (EmuIoThunk->Protocol, &gEfiSimpleFileSystemProtocolGuid)) {
643 &gEmuIoThunkProtocolGuid,
644 This->DriverBindingHandle,
688EmuSimpleFileSystemDriverBindingStart (
703 Status =
gBS->OpenProtocol (
705 &gEmuIoThunkProtocolGuid,
706 (VOID **)&EmuIoThunk,
707 This->DriverBindingHandle,
709 EFI_OPEN_PROTOCOL_BY_DRIVER
711 if (EFI_ERROR (Status)) {
718 if (!
CompareGuid (EmuIoThunk->Protocol, &gEfiSimpleFileSystemProtocolGuid)) {
719 Status = EFI_UNSUPPORTED;
724 if (Private ==
NULL) {
725 Status = EFI_OUT_OF_RESOURCES;
729 Status = EmuIoThunk->Open (EmuIoThunk);
730 if (EFI_ERROR (Status)) {
734 Private->Signature = EMU_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE;
735 Private->IoThunk = EmuIoThunk;
736 Private->Io = EmuIoThunk->Interface;
738 Private->SimpleFileSystem.
Revision = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION;
739 Private->SimpleFileSystem.OpenVolume = EmuSimpleFileSystemOpenVolume;
741 Private->ControllerNameTable =
NULL;
746 &Private->ControllerNameTable,
747 EmuIoThunk->ConfigString,
754 &Private->ControllerNameTable,
755 EmuIoThunk->ConfigString,
759 Status =
gBS->InstallMultipleProtocolInterfaces (
761 &gEfiSimpleFileSystemProtocolGuid,
762 &Private->SimpleFileSystem,
767 if (EFI_ERROR (Status)) {
768 if (Private !=
NULL) {
769 if (Private->ControllerNameTable !=
NULL) {
773 gBS->FreePool (Private);
778 &gEmuIoThunkProtocolGuid,
779 This->DriverBindingHandle,
815EmuSimpleFileSystemDriverBindingStop (
829 Status =
gBS->OpenProtocol (
831 &gEfiSimpleFileSystemProtocolGuid,
832 (VOID **)&SimpleFileSystem,
833 This->DriverBindingHandle,
835 EFI_OPEN_PROTOCOL_GET_PROTOCOL
837 if (EFI_ERROR (Status)) {
838 return EFI_UNSUPPORTED;
841 Private = EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (SimpleFileSystem);
846 Status =
gBS->UninstallMultipleProtocolInterfaces (
848 &gEfiSimpleFileSystemProtocolGuid,
849 &Private->SimpleFileSystem,
852 if (!EFI_ERROR (Status)) {
853 Status =
gBS->CloseProtocol (
855 &gEmuIoThunkProtocolGuid,
856 This->DriverBindingHandle,
863 Status = Private->IoThunk->Close (Private->IoThunk);
869 gBS->FreePool (Private);
876 EmuSimpleFileSystemDriverBindingSupported,
877 EmuSimpleFileSystemDriverBindingStart,
878 EmuSimpleFileSystemDriverBindingStop,
896InitializeEmuSimpleFileSystem (
906 &gEmuSimpleFileSystemDriverBinding,
908 &gEmuSimpleFileSystemComponentName,
909 &gEmuSimpleFileSystemComponentName2
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
#define ASSERT_EFI_ERROR(StatusParameter)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
EFI_STATUS EFIAPI AddUnicodeString2(IN CONST CHAR8 *Language, IN CONST CHAR8 *SupportedLanguages, IN OUT EFI_UNICODE_STRING_TABLE **UnicodeStringTable, IN CONST CHAR16 *UnicodeString, IN BOOLEAN Iso639Language)
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)
EFI_STATUS EFIAPI FreeUnicodeStringTable(IN EFI_UNICODE_STRING_TABLE *UnicodeStringTable)
CHAR8 * SupportedLanguages
CHAR8 * SupportedLanguages
CHAR16 * ConfigString
Only be valid after Open() is called.