3 * Copyright (c) 2011, ARM Limited. All rights reserved.
5 * This program and the accompanying materials
6 * are licensed and made available under the terms and conditions of the BSD License
7 * which accompanies this distribution. The full text of the license may be found at
8 * http://opensource.org/licenses/bsd-license.php
10 * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "BdsInternal.h"
17 EFI_STATUS
BdsLoadFileFromSimpleFileSystem(
22 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
*FsProtocol
;
23 EFI_FILE_PROTOCOL
*Fs
;
25 EFI_FILE_PROTOCOL
*FileHandle
= NULL
;
28 return EFI_INVALID_PARAMETER
;
31 Status
= gBS
->HandleProtocol(Handle
,&gEfiSimpleFileSystemProtocolGuid
, (VOID
**)&FsProtocol
);
32 if (EFI_ERROR(Status
)) {
36 //Try to Open the volume and get root directory
37 Status
= FsProtocol
->OpenVolume(FsProtocol
, &Fs
);
38 if (EFI_ERROR(Status
)) {
42 Status
= Fs
->Open(Fs
, &FileHandle
, FilePath
, EFI_FILE_MODE_READ
, 0);
44 File
->Type
= BDS_FILETYPE_FS
;
45 File
->FilePath
= FilePath
;
46 File
->File
.Fs
.Handle
= FileHandle
;
51 EFI_STATUS
BdsCopyRawFileToRuntimeMemoryFS(
52 IN EFI_FILE_PROTOCOL
*File
,
56 EFI_FILE_INFO
*FileInfo
;
62 File
->GetInfo(File
, &gEfiFileInfoGuid
, &Size
, NULL
);
63 FileInfo
= AllocatePool (Size
);
64 Status
= File
->GetInfo(File
, &gEfiFileInfoGuid
, &Size
, FileInfo
);
65 if (EFI_ERROR(Status
)) {
70 Size
= FileInfo
->FileSize
;
76 Image
= AllocateRuntimePool(Size
);
78 return EFI_OUT_OF_RESOURCES
;
81 Status
= File
->Read(File
, &Size
, Image
);
82 if (!EFI_ERROR(Status
)) {