TianoCore EDK2 master
Loading...
Searching...
No Matches
FatLitePeim.h
Go to the documentation of this file.
1
10#ifndef _FAT_PEIM_H_
11#define _FAT_PEIM_H_
12
13#include <PiPei.h>
14
15#include <Guid/RecoveryDevice.h>
16#include <Ppi/BlockIo.h>
17#include <Ppi/BlockIo2.h>
19
20#include <Library/DebugLib.h>
21#include <Library/BaseLib.h>
25#include <Library/PcdLib.h>
28
29#include "FatLiteApi.h"
30#include "FatLiteFmt.h"
31
32//
33// Definitions
34//
35
36#define PEI_FAT_CACHE_SIZE 4
37#define PEI_FAT_MAX_BLOCK_SIZE 8192
38#define FAT_MAX_FILE_NAME_LENGTH 128
39#define PEI_FAT_MAX_BLOCK_DEVICE 64
40#define PEI_FAT_MAX_BLOCK_IO_PPI 32
41#define PEI_FAT_MAX_VOLUME 64
42
43#define PEI_FAT_MEMORY_PAGE_SIZE 0x1000
44
45//
46// Data Structures
47//
48//
49// The block device
50//
51typedef struct {
52 UINT32 BlockSize;
53 UINT64 LastBlock;
54 UINT32 IoAlign;
55 BOOLEAN Logical;
56 BOOLEAN PartitionChecked;
57
58 //
59 // Following fields only valid for logical device
60 //
61 CHAR8 PartitionFlag[8];
62 UINT64 StartingPos;
63 UINTN ParentDevNo;
64
65 //
66 // Following fields only valid for physical device
67 //
69 UINT8 InterfaceType;
70 //
71 // EFI_PEI_READ_BLOCKS ReadFunc;
72 //
75 UINT8 PhysicalDevNo;
77
78//
79// the Volume structure
80//
81typedef struct {
82 UINTN BlockDeviceNo;
83 UINTN VolumeNo;
84 UINT64 VolumeSize;
85 UINTN MaxCluster;
86 CHAR16 VolumeLabel[FAT_MAX_FILE_NAME_LENGTH];
87 PEI_FAT_TYPE FatType;
88 UINT64 FatPos;
89 UINT32 SectorSize;
90 UINT32 ClusterSize;
91 UINT64 FirstClusterPos;
92 UINT64 RootDirPos;
93 UINT32 RootEntries;
94 UINT32 RootDirCluster;
96
97//
98// File instance
99//
100typedef struct {
101 PEI_FAT_VOLUME *Volume;
102 CHAR16 FileName[FAT_MAX_FILE_NAME_LENGTH];
103
104 BOOLEAN IsFixedRootDir;
105
106 UINT32 StartingCluster;
107 UINT32 CurrentPos;
108 UINT32 StraightReadAmount;
109 UINT32 CurrentCluster;
110
111 UINT8 Attributes;
112 UINT32 FileSize;
114
115//
116// Cache Buffer
117//
118typedef struct {
119 BOOLEAN Valid;
120 UINTN BlockDeviceNo;
121 UINT64 Lba;
122 UINT32 Lru;
123 UINT64 Buffer[PEI_FAT_MAX_BLOCK_SIZE / 8];
124 UINTN Size;
126
127//
128// Private Data.
129// This structure abstracts the whole memory usage in FAT PEIM.
130// The entry point routine will get a chunk of memory (by whatever
131// means) whose size is sizeof(PEI_FAT_PRIVATE_DATA), which is clean
132// in both 32 and 64 bit environment. The boundary of the memory chunk
133// should be 64bit aligned.
134//
135#define PEI_FAT_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('p', 'f', 'a', 't')
136
137typedef struct {
138 UINTN Signature;
139 EFI_PEI_DEVICE_RECOVERY_MODULE_PPI DeviceRecoveryPpi;
140 EFI_PEI_PPI_DESCRIPTOR PpiDescriptor;
141 EFI_PEI_NOTIFY_DESCRIPTOR NotifyDescriptor[2];
142
143 UINT8 UnicodeCaseMap[0x300];
144 CHAR8 *EngUpperMap;
145 CHAR8 *EngLowerMap;
146 CHAR8 *EngInfoMap;
147
148 UINT64 BlockData[PEI_FAT_MAX_BLOCK_SIZE / 8];
149 UINTN BlockDeviceCount;
150 PEI_FAT_BLOCK_DEVICE BlockDevice[PEI_FAT_MAX_BLOCK_DEVICE];
151 UINTN VolumeCount;
152 PEI_FAT_VOLUME Volume[PEI_FAT_MAX_VOLUME];
153 PEI_FAT_FILE File;
154 PEI_FAT_CACHE_BUFFER CacheBuffer[PEI_FAT_CACHE_SIZE];
156
157#define PEI_FAT_PRIVATE_DATA_FROM_THIS(a) \
158 CR (a, PEI_FAT_PRIVATE_DATA, DeviceRecoveryPpi, PEI_FAT_PRIVATE_DATA_SIGNATURE)
159
160//
161// Extract INT32 from char array
162//
163#define UNPACK_INT32(a) \
164 (INT32) ((((UINT8 *) a)[0] << 0) | (((UINT8 *) a)[1] << 8) | (((UINT8 *) a)[2] << 16) | (((UINT8 *) a)[3] << 24))
165
166//
167// Extract UINT32 from char array
168//
169#define UNPACK_UINT32(a) \
170 (UINT32) ((((UINT8 *) a)[0] << 0) | (((UINT8 *) a)[1] << 8) | (((UINT8 *) a)[2] << 16) | (((UINT8 *) a)[3] << 24))
171
172//
173// API functions
174//
175
196 IN PEI_FAT_PRIVATE_DATA *PrivateData,
197 IN UINTN VolumeIndex,
198 IN CHAR16 *FileName,
199 OUT PEI_FILE_HANDLE *Handle
200 );
201
221EFIAPI
223 IN EFI_PEI_SERVICES **PeiServices,
225 OUT UINTN *NumberRecoveryCapsules
226 );
227
256EFIAPI
258 IN EFI_PEI_SERVICES **PeiServices,
260 IN UINTN CapsuleInstance,
261 OUT UINTN *Size,
262 OUT EFI_GUID *CapsuleType
263 );
264
285EFIAPI
287 IN EFI_PEI_SERVICES **PeiServices,
289 IN UINTN CapsuleInstance,
290 OUT VOID *Buffer
291 );
292
308VOID
310 IN UINTN FatSize,
311 IN CHAR8 *Fat,
312 OUT CHAR16 *Str
313 );
314
323BOOLEAN
325 IN PEI_FAT_PRIVATE_DATA *PrivateData,
326 IN CHAR16 *Str1,
327 IN CHAR16 *Str2
328 );
329
348 IN PEI_FAT_PRIVATE_DATA *PrivateData,
349 IN UINTN BlockDeviceNo,
350 IN EFI_PEI_LBA Lba,
351 IN UINTN BufferSize,
352 OUT VOID *Buffer
353 );
354
376 IN PEI_FAT_PRIVATE_DATA *PrivateData,
377 IN OUT PEI_FAT_VOLUME *Volume
378 );
379
395 IN PEI_FAT_PRIVATE_DATA *PrivateData,
396 IN PEI_FAT_VOLUME *Volume,
397 IN UINT32 Cluster,
398 OUT UINT32 *NextCluster
399 );
400
416 IN PEI_FAT_PRIVATE_DATA *PrivateData,
417 IN UINTN BlockDeviceNo,
418 IN UINT64 StartingAddress,
419 IN UINTN Size,
420 OUT VOID *Buffer
421 );
422
438 IN PEI_FAT_PRIVATE_DATA *PrivateData,
439 IN PEI_FAT_FILE *File,
440 IN UINT32 Pos
441 );
442
458 IN PEI_FAT_PRIVATE_DATA *PrivateData,
459 IN PEI_FAT_FILE *File,
460 IN UINTN Size,
461 OUT VOID *Buffer
462 );
463
483 IN PEI_FAT_PRIVATE_DATA *PrivateData,
484 IN PEI_FAT_FILE *ParentDir,
485 OUT PEI_FAT_FILE *SubFile
486 );
487
494VOID
496 IN PEI_FAT_PRIVATE_DATA *PrivateData
497 );
498
499#endif // _FAT_PEIM_H_
UINT64 UINTN
VOID EngFatToStr(IN UINTN FatSize, IN CHAR8 *Fat, OUT CHAR16 *Str)
Definition: FatLiteLib.c:307
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)
Definition: FatLiteApi.c:413
EFI_STATUS FatReadNextDirectoryEntry(IN PEI_FAT_PRIVATE_DATA *PrivateData, IN PEI_FAT_FILE *ParentDir, OUT PEI_FAT_FILE *SubFile)
EFI_STATUS FindRecoveryFile(IN PEI_FAT_PRIVATE_DATA *PrivateData, IN UINTN VolumeIndex, IN CHAR16 *FileName, OUT PEI_FILE_HANDLE *Handle)
Definition: FatLiteApi.c:615
EFI_STATUS EFIAPI GetNumberRecoveryCapsules(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This, OUT UINTN *NumberRecoveryCapsules)
Definition: FatLiteApi.c:350
EFI_STATUS FatReadBlock(IN PEI_FAT_PRIVATE_DATA *PrivateData, IN UINTN BlockDeviceNo, IN EFI_PEI_LBA Lba, IN UINTN BufferSize, OUT VOID *Buffer)
Definition: FatLiteLib.c:54
EFI_STATUS FatGetBpbInfo(IN PEI_FAT_PRIVATE_DATA *PrivateData, IN OUT PEI_FAT_VOLUME *Volume)
Definition: FatLiteAccess.c:32
VOID FatFindPartitions(IN PEI_FAT_PRIVATE_DATA *PrivateData)
Definition: Part.c:75
EFI_STATUS EFIAPI LoadRecoveryCapsule(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This, IN UINTN CapsuleInstance, OUT VOID *Buffer)
Definition: FatLiteApi.c:542
EFI_STATUS FatSetFilePos(IN PEI_FAT_PRIVATE_DATA *PrivateData, IN PEI_FAT_FILE *File, IN UINT32 Pos)
BOOLEAN EngStriColl(IN PEI_FAT_PRIVATE_DATA *PrivateData, IN CHAR16 *Str1, IN CHAR16 *Str2)
Definition: FatLiteLib.c:342
EFI_STATUS FatReadFile(IN PEI_FAT_PRIVATE_DATA *PrivateData, IN PEI_FAT_FILE *File, IN UINTN Size, OUT VOID *Buffer)
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)
Definition: FatLiteLib.c:221
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
EFI_PEI_BLOCK_DEVICE_TYPE
Definition: BlockIo.h:46
UINT64 EFI_PEI_LBA
Definition: BlockIo.h:41
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
Definition: Base.h:213