28#define GUID_STRING_SIZE (37 * sizeof (CHAR16))
30#define FVFS_VOLUME_LABEL_PREFIX L"Firmware Volume: "
31#define FVFS_VOLUME_LABEL_SIZE (sizeof (FVFS_VOLUME_LABEL_PREFIX) + GUID_STRING_SIZE - sizeof (CHAR16))
32#define FVFS_FALLBACK_VOLUME_LABEL L"Firmware Volume"
38 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION,
86 UINT32 Authentication;
88 EFI_FV_FILETYPE FileType;
98 Instance = FVFS_INSTANCE_FROM_SIMPLE_FS_THIS (This);
101 if (Instance->Root ==
NULL) {
107 return EFI_OUT_OF_RESOURCES;
110 Instance->Root = Root;
111 Root->Instance = Instance;
112 Root->Signature = FVFS_FILE_SIGNATURE;
113 CopyMem (&Root->FileProtocol, &mFileSystemTemplate, sizeof (mFileSystemTemplate));
115 if (Root->FvFileInfo ==
NULL) {
116 return EFI_OUT_OF_RESOURCES;
120 Root->FvFileInfo->FileInfo.
Attribute = EFI_FILE_DIRECTORY | EFI_FILE_READ_ONLY;
126 FvProtocol = Instance->FvProtocol;
135 Status = FvProtocol->GetNextFile (
143 if (EFI_ERROR (Status)) {
144 ASSERT (Status == EFI_NOT_FOUND);
153 Status = FvProtocol->ReadSection (
156 EFI_SECTION_USER_INTERFACE,
162 if (!EFI_ERROR (Status)) {
167 return EFI_OUT_OF_RESOURCES;
170 NumChars =
UnicodeSPrint (Name, GUID_STRING_SIZE, L
"%g", &NameGuid);
171 ASSERT ((NumChars + 1) *
sizeof (CHAR16) == GUID_STRING_SIZE);
179 if (FV_FILETYPE_IS_EXECUTABLE (FileType)) {
180 NameLen +=
StrSize (L
".efi") -
sizeof (CHAR16);
184 if (FvFileInfo ==
NULL) {
185 return EFI_OUT_OF_RESOURCES;
188 FvFileInfo->Signature = FVFS_FILE_INFO_SIGNATURE;
191 FvFileInfo->Type = FileType;
196 DestMax = NameLen /
sizeof (CHAR16);
200 if (FV_FILETYPE_IS_EXECUTABLE (FileType)) {
209 FvFileInfo->FileInfo.
Attribute = EFI_FILE_READ_ONLY;
216 if (Status == EFI_NOT_FOUND) {
221 Instance->Root->DirReadNext =
NULL;
223 Instance->Root->DirReadNext = FVFS_GET_FIRST_FILE_INFO (Instance);
226 *RootFile = &Instance->Root->FileProtocol;
250 IN CONST CHAR8 *DefaultLanguage
259 BOOLEAN Iso639Language;
263 Status =
gBS->LocateHandleBuffer (
270 if (EFI_ERROR (Status)) {
274 Iso639Language = (BOOLEAN)(ProtocolGuid == &gEfiUnicodeCollationProtocolGuid);
277 ReturnStatus = EFI_UNSUPPORTED;
278 for (Index = 0; Index < NumHandles; Index++) {
282 Status =
gBS->OpenProtocol (
288 EFI_OPEN_PROTOCOL_GET_PROTOCOL
290 if (EFI_ERROR (Status)) {
299 Uci->SupportedLanguages,
301 (Language ==
NULL) ?
"" : Language,
305 if (BestLanguage !=
NULL) {
307 mUnicodeCollation = Uci;
313 if (Language !=
NULL) {
342 Status = EFI_UNSUPPORTED;
349 &gEfiUnicodeCollation2ProtocolGuid,
357 if (EFI_ERROR (Status)) {
360 &gEfiUnicodeCollationProtocolGuid,
390 return gBS->OpenProtocol (
392 &gEfiFirmwareVolume2ProtocolGuid,
396 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
430 if (EFI_ERROR (Status)) {
437 Status =
gBS->OpenProtocol (
439 &gEfiFirmwareVolume2ProtocolGuid,
440 (VOID **)&FvProtocol,
443 EFI_OPEN_PROTOCOL_BY_DRIVER
445 if (EFI_ERROR (Status)) {
453 ASSERT (Instance !=
NULL);
455 Instance->Root =
NULL;
456 Instance->FvProtocol = FvProtocol;
457 Instance->Signature = FVFS_INSTANCE_SIGNATURE;
460 CopyMem (&Instance->SimpleFs, &mSimpleFsTemplate, sizeof (mSimpleFsTemplate));
462 Status =
gBS->InstallProtocolInterface (
464 &gEfiSimpleFileSystemProtocolGuid,
474 Instance->VolumeLabel =
NULL;
475 Status =
gBS->OpenProtocol (
477 &gEfiDevicePathProtocolGuid,
478 (VOID **)&FvDevicePath,
481 EFI_OPEN_PROTOCOL_GET_PROTOCOL
483 if (!EFI_ERROR (Status)) {
498 if (Instance->VolumeLabel !=
NULL) {
507 Instance->VolumeLabel,
508 FVFS_VOLUME_LABEL_SIZE,
509 FVFS_VOLUME_LABEL_PREFIX L
"%g",
512 ASSERT ((NumChars + 1) *
sizeof (CHAR16) == FVFS_VOLUME_LABEL_SIZE);
525 if (Instance->VolumeLabel ==
NULL) {
527 sizeof (FVFS_FALLBACK_VOLUME_LABEL),
528 FVFS_FALLBACK_VOLUME_LABEL
565 Status =
gBS->OpenProtocol (
567 &gEfiSimpleFileSystemProtocolGuid,
568 (VOID **)&SimpleFile,
569 DriverBinding->DriverBindingHandle,
571 EFI_OPEN_PROTOCOL_GET_PROTOCOL
573 if (EFI_ERROR (Status)) {
577 Instance = FVFS_INSTANCE_FROM_SIMPLE_FS_THIS (SimpleFile);
583 return EFI_DEVICE_ERROR;
589 Status =
gBS->CloseProtocol (
591 &gEfiFirmwareVolume2ProtocolGuid,
597 Status =
gBS->UninstallProtocolInterface (
599 &gEfiSimpleFileSystemProtocolGuid,
611 for (Entry = Instance->FileInfoHead.ForwardLink;
612 Entry != (&Instance->FileInfoHead);
616 Entry = Entry->ForwardLink;
617 FvFileInfo = FVFS_FILE_INFO_FROM_LINK (DelEntry);
624 if (Instance->Root !=
NULL) {
628 if (Instance->Root->FvFileInfo !=
NULL) {
629 FreePool (Instance->Root->FvFileInfo);
638 if (Instance->VolumeLabel !=
NULL) {
674 &gFvSimpleFileSystemComponentName,
675 &gFvSimpleFileSystemComponentName2
UINTN EFIAPI StrSize(IN CONST CHAR16 *String)
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
LIST_ENTRY *EFIAPI InsertHeadList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
RETURN_STATUS EFIAPI StrnCatS(IN OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source, IN UINTN Length)
RETURN_STATUS EFIAPI StrnCpyS(OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source, IN UINTN Length)
UINTN EFIAPI StrLen(IN CONST CHAR16 *String)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
#define MEDIA_PIWG_FW_VOL_DP
UINT8 EFIAPI DevicePathType(IN CONST VOID *Node)
UINT8 EFIAPI DevicePathSubType(IN CONST VOID *Node)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI NextDevicePathNode(IN CONST VOID *Node)
BOOLEAN EFIAPI IsDevicePathEndType(IN CONST VOID *Node)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
EFI_STATUS FvFsGetFileSize(IN EFI_FIRMWARE_VOLUME2_PROTOCOL *FvProtocol, IN OUT FV_FILESYSTEM_FILE_INFO *FvFileInfo)
EFI_STATUS EFIAPI FvSimpleFileSystemDriverStop(IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer OPTIONAL)
EFI_STATUS EFIAPI FvSimpleFileSystemDriverStart(IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL)
EFI_STATUS EFIAPI FvSimpleFileSystemEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS EFIAPI FvSimpleFileSystemOpenVolume(IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This, OUT EFI_FILE_PROTOCOL **RootFile)
EFI_STATUS InitializeUnicodeCollationSupportWorker(IN EFI_HANDLE AgentHandle, IN EFI_GUID *ProtocolGuid, IN CONST CHAR16 *VariableName, IN CONST CHAR8 *DefaultLanguage)
EFI_STATUS EFIAPI FvSimpleFileSystemDriverSupported(IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL)
EFI_STATUS InitializeUnicodeCollationSupport(IN EFI_HANDLE AgentHandle)
UINTN EFIAPI UnicodeSPrint(OUT CHAR16 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR16 *FormatString,...)
#define ASSERT_EFI_ERROR(StatusParameter)
#define PcdGetPtr(TokenName)
#define EFI_FV_FILETYPE_ALL
UINT32 EFI_FV_FILE_ATTRIBUTES
EFI_STATUS EFIAPI GetEfiGlobalVariable2(IN CONST CHAR16 *Name, OUT VOID **Value, OUT UINTN *Size OPTIONAL)
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)
CHAR8 *EFIAPI GetBestLanguage(IN CONST CHAR8 *SupportedLanguages, IN UINTN Iso639Language,...)