TianoCore EDK2 master
|
#include <PiPei.h>
#include <Guid/RecoveryDevice.h>
#include <Ppi/BlockIo.h>
#include <Ppi/BlockIo2.h>
#include <Ppi/DeviceRecoveryModule.h>
#include <Library/DebugLib.h>
#include <Library/BaseLib.h>
#include <Library/PeimEntryPoint.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PcdLib.h>
#include <Library/PeiServicesTablePointerLib.h>
#include <Library/PeiServicesLib.h>
#include "FatLiteApi.h"
#include "FatLiteFmt.h"
Go to the source code of this file.
Data Structures | |
struct | PEI_FAT_BLOCK_DEVICE |
struct | PEI_FAT_VOLUME |
struct | PEI_FAT_FILE |
struct | PEI_FAT_CACHE_BUFFER |
struct | PEI_FAT_PRIVATE_DATA |
Macros | |
#define | PEI_FAT_CACHE_SIZE 4 |
#define | PEI_FAT_MAX_BLOCK_SIZE 8192 |
#define | FAT_MAX_FILE_NAME_LENGTH 128 |
#define | PEI_FAT_MAX_BLOCK_DEVICE 64 |
#define | PEI_FAT_MAX_BLOCK_IO_PPI 32 |
#define | PEI_FAT_MAX_VOLUME 64 |
#define | PEI_FAT_MEMORY_PAGE_SIZE 0x1000 |
#define | PEI_FAT_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('p', 'f', 'a', 't') |
#define | PEI_FAT_PRIVATE_DATA_FROM_THIS(a) CR (a, PEI_FAT_PRIVATE_DATA, DeviceRecoveryPpi, PEI_FAT_PRIVATE_DATA_SIGNATURE) |
#define | UNPACK_INT32(a) (INT32) ((((UINT8 *) a)[0] << 0) | (((UINT8 *) a)[1] << 8) | (((UINT8 *) a)[2] << 16) | (((UINT8 *) a)[3] << 24)) |
#define | UNPACK_UINT32(a) (UINT32) ((((UINT8 *) a)[0] << 0) | (((UINT8 *) a)[1] << 8) | (((UINT8 *) a)[2] << 16) | (((UINT8 *) a)[3] << 24)) |
Data structures for FAT recovery PEIM
Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file FatLitePeim.h.
#define FAT_MAX_FILE_NAME_LENGTH 128 |
Definition at line 38 of file FatLitePeim.h.
#define PEI_FAT_CACHE_SIZE 4 |
Definition at line 36 of file FatLitePeim.h.
#define PEI_FAT_MAX_BLOCK_DEVICE 64 |
Definition at line 39 of file FatLitePeim.h.
#define PEI_FAT_MAX_BLOCK_IO_PPI 32 |
Definition at line 40 of file FatLitePeim.h.
#define PEI_FAT_MAX_BLOCK_SIZE 8192 |
Definition at line 37 of file FatLitePeim.h.
#define PEI_FAT_MAX_VOLUME 64 |
Definition at line 41 of file FatLitePeim.h.
#define PEI_FAT_MEMORY_PAGE_SIZE 0x1000 |
Definition at line 43 of file FatLitePeim.h.
#define PEI_FAT_PRIVATE_DATA_FROM_THIS | ( | a | ) | CR (a, PEI_FAT_PRIVATE_DATA, DeviceRecoveryPpi, PEI_FAT_PRIVATE_DATA_SIGNATURE) |
Definition at line 157 of file FatLitePeim.h.
#define PEI_FAT_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('p', 'f', 'a', 't') |
Definition at line 135 of file FatLitePeim.h.
#define UNPACK_INT32 | ( | a | ) | (INT32) ((((UINT8 *) a)[0] << 0) | (((UINT8 *) a)[1] << 8) | (((UINT8 *) a)[2] << 16) | (((UINT8 *) a)[3] << 24)) |
Definition at line 163 of file FatLitePeim.h.
#define UNPACK_UINT32 | ( | a | ) | (UINT32) ((((UINT8 *) a)[0] << 0) | (((UINT8 *) a)[1] << 8) | (((UINT8 *) a)[2] << 16) | (((UINT8 *) a)[3] << 24)) |
Definition at line 169 of file FatLitePeim.h.
This version is different from the version in Unicode collation protocol in that this version strips off trailing blanks. Converts an 8.3 FAT file name using an OEM character set to a Null-terminated Unicode string. Here does not expand DBCS FAT chars.
FatSize | The size of the string Fat in bytes. |
Fat | A pointer to a Null-terminated string that contains an 8.3 file name using an OEM character set. |
Str | A pointer to a Null-terminated Unicode string. The string must be allocated in advance to hold FatSize Unicode characters |
Definition at line 307 of file FatLiteLib.c.
BOOLEAN EngStriColl | ( | IN PEI_FAT_PRIVATE_DATA * | PrivateData, |
IN CHAR16 * | Str1, | ||
IN CHAR16 * | Str2 | ||
) |
Performs a case-insensitive comparison of two Null-terminated Unicode strings.
PrivateData | Global memory map for accessing global variables |
Str1 | First string to perform case insensitive comparison. |
Str2 | Second string to perform case insensitive comparison. |
Definition at line 342 of file FatLiteLib.c.
VOID FatFindPartitions | ( | IN PEI_FAT_PRIVATE_DATA * | PrivateData | ) |
EFI_STATUS FatGetBpbInfo | ( | IN PEI_FAT_PRIVATE_DATA * | PrivateData, |
IN OUT PEI_FAT_VOLUME * | Volume | ||
) |
Check if there is a valid FAT in the corresponding Block device of the volume and if yes, fill in the relevant fields for the volume structure. Note there should be a valid Block device number already set.
PrivateData | Global memory map for accessing global variables. |
Volume | On input, the BlockDeviceNumber field of the Volume should be a valid value. On successful output, all fields except the VolumeNumber field is initialized. |
EFI_SUCCESS | A FAT is found and the volume structure is initialized. |
EFI_NOT_FOUND | There is no FAT on the corresponding device. |
EFI_DEVICE_ERROR | There is something error while accessing device. |
Definition at line 32 of file FatLiteAccess.c.
EFI_STATUS FatGetNextCluster | ( | IN PEI_FAT_PRIVATE_DATA * | PrivateData, |
IN PEI_FAT_VOLUME * | Volume, | ||
IN UINT32 | Cluster, | ||
OUT UINT32 * | NextCluster | ||
) |
Gets the next cluster in the cluster chain.
PrivateData | Global memory map for accessing global variables |
Volume | The volume |
Cluster | The cluster |
NextCluster | The cluster number of the next cluster |
EFI_SUCCESS | The address is got |
EFI_INVALID_PARAMETER | ClusterNo exceeds the MaxCluster of the volume. |
EFI_DEVICE_ERROR | Read disk error |
Gets the next cluster in the cluster chain
PrivateData | Global memory map for accessing global variables |
Volume | The volume |
Cluster | The cluster |
NextCluster | The cluster number of the next cluster |
EFI_SUCCESS | The address is got |
EFI_INVALID_PARAMETER | ClusterNo exceeds the MaxCluster of the volume. |
EFI_DEVICE_ERROR | Read disk error |
Definition at line 187 of file FatLiteAccess.c.
EFI_STATUS FatReadBlock | ( | IN PEI_FAT_PRIVATE_DATA * | PrivateData, |
IN UINTN | BlockDeviceNo, | ||
IN EFI_PEI_LBA | Lba, | ||
IN UINTN | BufferSize, | ||
OUT VOID * | Buffer | ||
) |
Reads a block of data from the block device by calling underlying Block I/O service.
PrivateData | Global memory map for accessing global variables |
BlockDeviceNo | The index for the block device number. |
Lba | The logic block address to read data from. |
BufferSize | The size of data in byte to read. |
Buffer | The buffer of the |
EFI_DEVICE_ERROR | The specified block device number exceeds the maximum device number. |
EFI_DEVICE_ERROR | The maximum address has exceeded the maximum address of the block device. |
Definition at line 54 of file FatLiteLib.c.
EFI_STATUS FatReadDisk | ( | IN PEI_FAT_PRIVATE_DATA * | PrivateData, |
IN UINTN | BlockDeviceNo, | ||
IN UINT64 | StartingAddress, | ||
IN UINTN | Size, | ||
OUT VOID * | Buffer | ||
) |
Disk reading.
PrivateData | the global memory map; |
BlockDeviceNo | the block device to read; |
StartingAddress | the starting address. |
Size | the amount of data to read. |
Buffer | the buffer holding the data |
EFI_SUCCESS | The function completed successfully. |
EFI_DEVICE_ERROR | Something error. |
Definition at line 221 of file FatLiteLib.c.
EFI_STATUS FatReadFile | ( | IN PEI_FAT_PRIVATE_DATA * | PrivateData, |
IN PEI_FAT_FILE * | File, | ||
IN UINTN | Size, | ||
OUT VOID * | Buffer | ||
) |
Reads file data. Updates the file's CurrentPos.
PrivateData | Global memory map for accessing global variables |
File | The file. |
Size | The amount of data to read. |
Buffer | The buffer storing the data. |
EFI_SUCCESS | The data is read. |
EFI_INVALID_PARAMETER | File is invalid. |
EFI_DEVICE_ERROR | Something error while accessing media. |
Definition at line 349 of file FatLiteAccess.c.
EFI_STATUS FatReadNextDirectoryEntry | ( | IN PEI_FAT_PRIVATE_DATA * | PrivateData, |
IN PEI_FAT_FILE * | ParentDir, | ||
OUT PEI_FAT_FILE * | SubFile | ||
) |
This function reads the next item in the parent directory and initializes the output parameter SubFile (CurrentPos is initialized to 0). The function updates the CurrentPos of the parent dir to after the item read. If no more items were found, the function returns EFI_NOT_FOUND.
PrivateData | Global memory map for accessing global variables |
ParentDir | The parent directory. |
SubFile | The File structure containing the sub file that is caught. |
EFI_SUCCESS | The next sub file is obtained. |
EFI_INVALID_PARAMETER | The ParentDir is not a directory. |
EFI_NOT_FOUND | No more sub file exists. |
EFI_DEVICE_ERROR | Something error while accessing media. |
Definition at line 437 of file FatLiteAccess.c.
EFI_STATUS FatSetFilePos | ( | IN PEI_FAT_PRIVATE_DATA * | PrivateData, |
IN PEI_FAT_FILE * | File, | ||
IN UINT32 | Pos | ||
) |
Set a file's CurrentPos and CurrentCluster, then compute StraightReadAmount.
PrivateData | the global memory map |
File | the file |
Pos | the Position which is offset from the file's CurrentPos |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Pos is beyond file's size. |
EFI_DEVICE_ERROR | Something error while accessing media. |
Definition at line 263 of file FatLiteAccess.c.
EFI_STATUS FindRecoveryFile | ( | IN PEI_FAT_PRIVATE_DATA * | PrivateData, |
IN UINTN | VolumeIndex, | ||
IN CHAR16 * | FileName, | ||
OUT PEI_FILE_HANDLE * | Handle | ||
) |
Finds the recovery file on a FAT volume. This function finds the recovery file named FileName on a specified FAT volume and returns its FileHandle pointer.
PrivateData | Global memory map for accessing global variables. |
VolumeIndex | The index of the volume. |
FileName | The recovery file name to find. |
Handle | The output file handle. |
EFI_DEVICE_ERROR | Some error occurred when operating the FAT volume. |
EFI_NOT_FOUND | The recovery file was not found. |
EFI_SUCCESS | The recovery file was successfully found on the FAT volume. |
Definition at line 615 of file FatLiteApi.c.
EFI_STATUS EFIAPI GetNumberRecoveryCapsules | ( | IN EFI_PEI_SERVICES ** | PeiServices, |
IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI * | This, | ||
OUT UINTN * | NumberRecoveryCapsules | ||
) |
Returns the number of DXE capsules residing on the device. This function, by whatever mechanism, searches for DXE capsules from the associated device and returns the number and maximum size in bytes of the capsules discovered.Entry 1 is assumed to be the highest load priority and entry N is assumed to be the lowest priority.
PeiServices | General-purpose services that are available to every PEIM. |
This | Indicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI instance. |
NumberRecoveryCapsules | Pointer to a caller-allocated UINTN.On output, NumberRecoveryCapsules contains the number of recovery capsule images available for retrieval from this PEIM instance. |
EFI_SUCCESS | The function completed successfully. |
Returns the number of DXE capsules residing on the device.
This function searches for DXE capsules from the associated device and returns the number and maximum size in bytes of the capsules discovered. Entry 1 is assumed to be the highest load priority and entry N is assumed to be the lowest priority.
[in] | PeiServices | General-purpose services that are available to every PEIM |
[in] | This | Indicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI instance. |
[out] | NumberRecoveryCapsules | Pointer to a caller-allocated UINTN. On output, *NumberRecoveryCapsules contains the number of recovery capsule images available for retrieval from this PEIM instance. |
EFI_SUCCESS | One or more capsules were discovered. |
EFI_DEVICE_ERROR | A device error occurred. |
EFI_NOT_FOUND | A recovery DXE capsule cannot be found. |
Definition at line 350 of file FatLiteApi.c.
EFI_STATUS EFIAPI GetRecoveryCapsuleInfo | ( | IN EFI_PEI_SERVICES ** | PeiServices, |
IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI * | This, | ||
IN UINTN | CapsuleInstance, | ||
OUT UINTN * | Size, | ||
OUT EFI_GUID * | CapsuleType | ||
) |
Returns the size and type of the requested recovery capsule. This function returns the size and type of the capsule specified by CapsuleInstance.
PeiServices | General-purpose services that are available to every PEIM. |
This | Indicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI instance. |
CapsuleInstance | Specifies for which capsule instance to retrieve the information.T his parameter must be between one and the value returned by GetNumberRecoveryCapsules() in NumberRecoveryCapsules. |
Size | A pointer to a caller-allocated UINTN in which the size of the requested recovery module is returned. |
CapsuleType | A pointer to a caller-allocated EFI_GUID in which the type of the requested recovery capsule is returned.T he semantic meaning of the value returned is defined by the implementation. |
EFI_SUCCESS | The capsule type and size were retrieved. |
EFI_INVALID_PARAMETER | The input CapsuleInstance does not match any discovered recovery capsule. |
Returns the size and type of the requested recovery capsule.
This function gets the size and type of the capsule specified by CapsuleInstance.
[in] | PeiServices | General-purpose services that are available to every PEIM |
[in] | This | Indicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI instance. |
[in] | CapsuleInstance | Specifies for which capsule instance to retrieve the information. This parameter must be between one and the value returned by GetNumberRecoveryCapsules() in NumberRecoveryCapsules. |
[out] | Size | A pointer to a caller-allocated UINTN in which the size of the requested recovery module is returned. |
[out] | CapsuleType | A pointer to a caller-allocated EFI_GUID in which the type of the requested recovery capsule is returned. The semantic meaning of the value returned is defined by the implementation. |
EFI_SUCCESS | One or more capsules were discovered. |
EFI_DEVICE_ERROR | A device error occurred. |
EFI_NOT_FOUND | A recovery DXE capsule cannot be found. |
Definition at line 413 of file FatLiteApi.c.
EFI_STATUS EFIAPI LoadRecoveryCapsule | ( | IN EFI_PEI_SERVICES ** | PeiServices, |
IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI * | This, | ||
IN UINTN | CapsuleInstance, | ||
OUT VOID * | Buffer | ||
) |
Loads a DXE capsule from some media into memory.
This function, by whatever mechanism, retrieves a DXE capsule from some device and loads it into memory. Note that the published interface is device neutral.
[in] | PeiServices | General-purpose services that are available to every PEIM |
[in] | This | Indicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI instance. |
[in] | CapsuleInstance | Specifies which capsule instance to retrieve. |
[out] | Buffer | Specifies a caller-allocated buffer in which the requested recovery capsule will be returned. |
EFI_SUCCESS | The capsule was loaded correctly. |
EFI_DEVICE_ERROR | A device error occurred. |
EFI_NOT_FOUND | A requested recovery DXE capsule cannot be found. |
Definition at line 542 of file FatLiteApi.c.