12#define CHAR_FAT_VALID 0x01
30 if ((
'a' <= Letter) && (Letter <=
'z')) {
31 Letter = (CHAR16)(Letter - 0x20);
65 if (BlockDeviceNo > PEI_FAT_MAX_BLOCK_DEVICE - 1) {
66 return EFI_DEVICE_ERROR;
70 BlockDev = &(PrivateData->BlockDevice[BlockDeviceNo]);
72 if (BufferSize >
MultU64x32 (BlockDev->LastBlock - Lba + 1, BlockDev->BlockSize)) {
73 return EFI_DEVICE_ERROR;
76 if (!BlockDev->Logical) {
81 if (BlockDev->BlockIo2 !=
NULL) {
85 BlockDev->PhysicalDevNo,
94 BlockDev->PhysicalDevNo,
103 BlockDev->ParentDevNo,
104 BlockDev->StartingPos +
MultU64x32 (Lba, BlockDev->BlockSize),
146 for (Index = 0; Index < PEI_FAT_CACHE_SIZE; Index++) {
147 CacheBuffer = &(PrivateData->CacheBuffer[Index]);
148 if (CacheBuffer->Valid && (CacheBuffer->BlockDeviceNo == BlockDeviceNo) && (CacheBuffer->Lba == Lba)) {
153 if (Index < PEI_FAT_CACHE_SIZE) {
154 *CachePtr = (CHAR8 *)CacheBuffer->Buffer;
161 for (Index = 0; Index < PEI_FAT_CACHE_SIZE; Index++) {
162 if (!PrivateData->CacheBuffer[Index].Valid) {
170 if (Index == PEI_FAT_CACHE_SIZE) {
171 Index = (Seed++) % PEI_FAT_CACHE_SIZE;
177 if (BlockDeviceNo >= PEI_FAT_MAX_BLOCK_DEVICE) {
178 return EFI_DEVICE_ERROR;
181 CacheBuffer = &(PrivateData->CacheBuffer[Index]);
183 CacheBuffer->BlockDeviceNo = BlockDeviceNo;
184 CacheBuffer->Lba = Lba;
185 CacheBuffer->Size = PrivateData->BlockDevice[BlockDeviceNo].BlockSize;
197 if (EFI_ERROR (Status)) {
198 return EFI_DEVICE_ERROR;
201 CacheBuffer->Valid =
TRUE;
202 *CachePtr = (CHAR8 *)CacheBuffer->Buffer;
224 IN UINT64 StartingAddress,
240 BlockSize = PrivateData->BlockDevice[BlockDeviceNo].BlockSize;
247 if (EFI_ERROR (Status)) {
248 return EFI_DEVICE_ERROR;
251 Amount = Size < (BlockSize - Offset) ? Size : (BlockSize - Offset);
252 CopyMem (BufferPtr, CachePtr + Offset, Amount);
254 if (Size == Amount) {
260 StartingAddress += Amount;
269 Status =
FatReadBlock (PrivateData, BlockDeviceNo, Lba, Size, BufferPtr);
270 if (EFI_ERROR (Status)) {
271 return EFI_DEVICE_ERROR;
280 Status =
FatGetCacheBlock (PrivateData, BlockDeviceNo, OverRunLba, &CachePtr);
281 if (EFI_ERROR (Status)) {
282 return EFI_DEVICE_ERROR;
285 CopyMem (BufferPtr, CachePtr, Offset);
319 while (*Fat != 0 && FatSize != 0) {
354 if (UpperS1 != UpperS2) {
364 return (BOOLEAN)((*Str2 != 0) ?
FALSE :
TRUE);
CONST EFI_PEI_SERVICES **EFIAPI GetPeiServicesTablePointer(VOID)
UINT64 EFIAPI MultU64x32(IN UINT64 Multiplicand, IN UINT32 Multiplier)
UINT64 EFIAPI DivU64x32Remainder(IN UINT64 Dividend, IN UINT32 Divisor, OUT UINT32 *Remainder OPTIONAL)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID EngFatToStr(IN UINTN FatSize, IN CHAR8 *Fat, OUT CHAR16 *Str)
EFI_STATUS FatReadBlock(IN PEI_FAT_PRIVATE_DATA *PrivateData, IN UINTN BlockDeviceNo, IN EFI_PEI_LBA Lba, IN UINTN BufferSize, OUT VOID *Buffer)
CHAR16 ToUpper(IN CHAR16 Letter)
EFI_STATUS FatGetCacheBlock(IN PEI_FAT_PRIVATE_DATA *PrivateData, IN UINTN BlockDeviceNo, IN UINT64 Lba, OUT CHAR8 **CachePtr)
BOOLEAN EngStriColl(IN PEI_FAT_PRIVATE_DATA *PrivateData, IN CHAR16 *Str1, IN CHAR16 *Str2)
EFI_STATUS FatReadDisk(IN PEI_FAT_PRIVATE_DATA *PrivateData, IN UINTN BlockDeviceNo, IN UINT64 StartingAddress, IN UINTN Size, OUT VOID *Buffer)
EFI_PEI_READ_BLOCKS2 ReadBlocks
EFI_PEI_READ_BLOCKS ReadBlocks