TianoCore EDK2 master
Loading...
Searching...
No Matches
FatLitePeim.h File Reference

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))
 

Functions

EFI_STATUS FindRecoveryFile (IN PEI_FAT_PRIVATE_DATA *PrivateData, IN UINTN VolumeIndex, IN CHAR16 *FileName, OUT PEI_FILE_HANDLE *Handle)
 
EFI_STATUS EFIAPI GetNumberRecoveryCapsules (IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This, OUT UINTN *NumberRecoveryCapsules)
 
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)
 
EFI_STATUS EFIAPI LoadRecoveryCapsule (IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This, IN UINTN CapsuleInstance, OUT VOID *Buffer)
 
VOID EngFatToStr (IN UINTN FatSize, IN CHAR8 *Fat, OUT CHAR16 *Str)
 
BOOLEAN EngStriColl (IN PEI_FAT_PRIVATE_DATA *PrivateData, IN CHAR16 *Str1, IN CHAR16 *Str2)
 
EFI_STATUS FatReadBlock (IN PEI_FAT_PRIVATE_DATA *PrivateData, IN UINTN BlockDeviceNo, IN EFI_PEI_LBA Lba, IN UINTN BufferSize, OUT VOID *Buffer)
 
EFI_STATUS FatGetBpbInfo (IN PEI_FAT_PRIVATE_DATA *PrivateData, IN OUT PEI_FAT_VOLUME *Volume)
 
EFI_STATUS FatGetNextCluster (IN PEI_FAT_PRIVATE_DATA *PrivateData, IN PEI_FAT_VOLUME *Volume, IN UINT32 Cluster, OUT UINT32 *NextCluster)
 
EFI_STATUS FatReadDisk (IN PEI_FAT_PRIVATE_DATA *PrivateData, IN UINTN BlockDeviceNo, IN UINT64 StartingAddress, IN UINTN Size, OUT VOID *Buffer)
 
EFI_STATUS FatSetFilePos (IN PEI_FAT_PRIVATE_DATA *PrivateData, IN PEI_FAT_FILE *File, IN UINT32 Pos)
 
EFI_STATUS FatReadFile (IN PEI_FAT_PRIVATE_DATA *PrivateData, IN PEI_FAT_FILE *File, IN UINTN Size, OUT VOID *Buffer)
 
EFI_STATUS FatReadNextDirectoryEntry (IN PEI_FAT_PRIVATE_DATA *PrivateData, IN PEI_FAT_FILE *ParentDir, OUT PEI_FAT_FILE *SubFile)
 
VOID FatFindPartitions (IN PEI_FAT_PRIVATE_DATA *PrivateData)
 

Detailed Description

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.

Macro Definition Documentation

◆ FAT_MAX_FILE_NAME_LENGTH

#define FAT_MAX_FILE_NAME_LENGTH   128

Definition at line 38 of file FatLitePeim.h.

◆ PEI_FAT_CACHE_SIZE

#define PEI_FAT_CACHE_SIZE   4

Definition at line 36 of file FatLitePeim.h.

◆ PEI_FAT_MAX_BLOCK_DEVICE

#define PEI_FAT_MAX_BLOCK_DEVICE   64

Definition at line 39 of file FatLitePeim.h.

◆ PEI_FAT_MAX_BLOCK_IO_PPI

#define PEI_FAT_MAX_BLOCK_IO_PPI   32

Definition at line 40 of file FatLitePeim.h.

◆ PEI_FAT_MAX_BLOCK_SIZE

#define PEI_FAT_MAX_BLOCK_SIZE   8192

Definition at line 37 of file FatLitePeim.h.

◆ PEI_FAT_MAX_VOLUME

#define PEI_FAT_MAX_VOLUME   64

Definition at line 41 of file FatLitePeim.h.

◆ PEI_FAT_MEMORY_PAGE_SIZE

#define PEI_FAT_MEMORY_PAGE_SIZE   0x1000

Definition at line 43 of file FatLitePeim.h.

◆ PEI_FAT_PRIVATE_DATA_FROM_THIS

#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.

◆ PEI_FAT_PRIVATE_DATA_SIGNATURE

#define PEI_FAT_PRIVATE_DATA_SIGNATURE   SIGNATURE_32 ('p', 'f', 'a', 't')

Definition at line 135 of file FatLitePeim.h.

◆ UNPACK_INT32

#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.

◆ UNPACK_UINT32

#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.

Function Documentation

◆ EngFatToStr()

VOID EngFatToStr ( IN UINTN  FatSize,
IN CHAR8 *  Fat,
OUT CHAR16 *  Str 
)

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.

Parameters
FatSizeThe size of the string Fat in bytes.
FatA pointer to a Null-terminated string that contains an 8.3 file name using an OEM character set.
StrA 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.

◆ EngStriColl()

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.

Parameters
PrivateDataGlobal memory map for accessing global variables
Str1First string to perform case insensitive comparison.
Str2Second string to perform case insensitive comparison.

Definition at line 342 of file FatLiteLib.c.

◆ FatFindPartitions()

VOID FatFindPartitions ( IN PEI_FAT_PRIVATE_DATA PrivateData)

This function finds partitions (logical devices) in physical block devices.

Parameters
PrivateDataGlobal memory map for accessing global variables.

Definition at line 75 of file Part.c.

◆ FatGetBpbInfo()

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.

Parameters
PrivateDataGlobal memory map for accessing global variables.
VolumeOn input, the BlockDeviceNumber field of the Volume should be a valid value. On successful output, all fields except the VolumeNumber field is initialized.
Return values
EFI_SUCCESSA FAT is found and the volume structure is initialized.
EFI_NOT_FOUNDThere is no FAT on the corresponding device.
EFI_DEVICE_ERRORThere is something error while accessing device.

Definition at line 32 of file FatLiteAccess.c.

◆ FatGetNextCluster()

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.

Parameters
PrivateDataGlobal memory map for accessing global variables
VolumeThe volume
ClusterThe cluster
NextClusterThe cluster number of the next cluster
Return values
EFI_SUCCESSThe address is got
EFI_INVALID_PARAMETERClusterNo exceeds the MaxCluster of the volume.
EFI_DEVICE_ERRORRead disk error

Gets the next cluster in the cluster chain

Parameters
PrivateDataGlobal memory map for accessing global variables
VolumeThe volume
ClusterThe cluster
NextClusterThe cluster number of the next cluster
Return values
EFI_SUCCESSThe address is got
EFI_INVALID_PARAMETERClusterNo exceeds the MaxCluster of the volume.
EFI_DEVICE_ERRORRead disk error

Definition at line 187 of file FatLiteAccess.c.

◆ FatReadBlock()

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.

Parameters
PrivateDataGlobal memory map for accessing global variables
BlockDeviceNoThe index for the block device number.
LbaThe logic block address to read data from.
BufferSizeThe size of data in byte to read.
BufferThe buffer of the
Return values
EFI_DEVICE_ERRORThe specified block device number exceeds the maximum device number.
EFI_DEVICE_ERRORThe maximum address has exceeded the maximum address of the block device.

Definition at line 54 of file FatLiteLib.c.

◆ FatReadDisk()

EFI_STATUS FatReadDisk ( IN PEI_FAT_PRIVATE_DATA PrivateData,
IN UINTN  BlockDeviceNo,
IN UINT64  StartingAddress,
IN UINTN  Size,
OUT VOID *  Buffer 
)

Disk reading.

Parameters
PrivateDatathe global memory map;
BlockDeviceNothe block device to read;
StartingAddressthe starting address.
Sizethe amount of data to read.
Bufferthe buffer holding the data
Return values
EFI_SUCCESSThe function completed successfully.
EFI_DEVICE_ERRORSomething error.

Definition at line 221 of file FatLiteLib.c.

◆ FatReadFile()

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.

Parameters
PrivateDataGlobal memory map for accessing global variables
FileThe file.
SizeThe amount of data to read.
BufferThe buffer storing the data.
Return values
EFI_SUCCESSThe data is read.
EFI_INVALID_PARAMETERFile is invalid.
EFI_DEVICE_ERRORSomething error while accessing media.

Definition at line 349 of file FatLiteAccess.c.

◆ FatReadNextDirectoryEntry()

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.

Parameters
PrivateDataGlobal memory map for accessing global variables
ParentDirThe parent directory.
SubFileThe File structure containing the sub file that is caught.
Return values
EFI_SUCCESSThe next sub file is obtained.
EFI_INVALID_PARAMETERThe ParentDir is not a directory.
EFI_NOT_FOUNDNo more sub file exists.
EFI_DEVICE_ERRORSomething error while accessing media.

Definition at line 437 of file FatLiteAccess.c.

◆ FatSetFilePos()

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.

Parameters
PrivateDatathe global memory map
Filethe file
Posthe Position which is offset from the file's CurrentPos
Return values
EFI_SUCCESSSuccess.
EFI_INVALID_PARAMETERPos is beyond file's size.
EFI_DEVICE_ERRORSomething error while accessing media.

Definition at line 263 of file FatLiteAccess.c.

◆ FindRecoveryFile()

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.

Parameters
PrivateDataGlobal memory map for accessing global variables.
VolumeIndexThe index of the volume.
FileNameThe recovery file name to find.
HandleThe output file handle.
Return values
EFI_DEVICE_ERRORSome error occurred when operating the FAT volume.
EFI_NOT_FOUNDThe recovery file was not found.
EFI_SUCCESSThe recovery file was successfully found on the FAT volume.

Definition at line 615 of file FatLiteApi.c.

◆ GetNumberRecoveryCapsules()

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.

Parameters
PeiServicesGeneral-purpose services that are available to every PEIM.
ThisIndicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI instance.
NumberRecoveryCapsulesPointer to a caller-allocated UINTN.On output, NumberRecoveryCapsules contains the number of recovery capsule images available for retrieval from this PEIM instance.
Return values
EFI_SUCCESSThe 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.

Parameters
[in]PeiServicesGeneral-purpose services that are available to every PEIM
[in]ThisIndicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI instance.
[out]NumberRecoveryCapsulesPointer to a caller-allocated UINTN. On output, *NumberRecoveryCapsules contains the number of recovery capsule images available for retrieval from this PEIM instance.
Return values
EFI_SUCCESSOne or more capsules were discovered.
EFI_DEVICE_ERRORA device error occurred.
EFI_NOT_FOUNDA recovery DXE capsule cannot be found.

Definition at line 350 of file FatLiteApi.c.

◆ GetRecoveryCapsuleInfo()

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.

Parameters
PeiServicesGeneral-purpose services that are available to every PEIM.
ThisIndicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI instance.
CapsuleInstanceSpecifies for which capsule instance to retrieve the information.T his parameter must be between one and the value returned by GetNumberRecoveryCapsules() in NumberRecoveryCapsules.
SizeA pointer to a caller-allocated UINTN in which the size of the requested recovery module is returned.
CapsuleTypeA 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.
Return values
EFI_SUCCESSThe capsule type and size were retrieved.
EFI_INVALID_PARAMETERThe 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.

Parameters
[in]PeiServicesGeneral-purpose services that are available to every PEIM
[in]ThisIndicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI instance.
[in]CapsuleInstanceSpecifies for which capsule instance to retrieve the information. This parameter must be between one and the value returned by GetNumberRecoveryCapsules() in NumberRecoveryCapsules.
[out]SizeA pointer to a caller-allocated UINTN in which the size of the requested recovery module is returned.
[out]CapsuleTypeA 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.
Return values
EFI_SUCCESSOne or more capsules were discovered.
EFI_DEVICE_ERRORA device error occurred.
EFI_NOT_FOUNDA recovery DXE capsule cannot be found.

Definition at line 413 of file FatLiteApi.c.

◆ LoadRecoveryCapsule()

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.

Parameters
[in]PeiServicesGeneral-purpose services that are available to every PEIM
[in]ThisIndicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI instance.
[in]CapsuleInstanceSpecifies which capsule instance to retrieve.
[out]BufferSpecifies a caller-allocated buffer in which the requested recovery capsule will be returned.
Return values
EFI_SUCCESSThe capsule was loaded correctly.
EFI_DEVICE_ERRORA device error occurred.
EFI_NOT_FOUNDA requested recovery DXE capsule cannot be found.

Definition at line 542 of file FatLiteApi.c.