11UINT8 mMonthDays[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
33 Task->Signature = FAT_TASK_SIGNATURE;
35 Task->FileIoToken = Token;
59 while (!
IsNull (&Task->Subtasks, Link)) {
60 Subtask =
CR (Link,
FAT_SUBTASK, Link, FAT_SUBTASK_SIGNATURE);
79 BOOLEAN TaskQueueEmpty;
85 }
while (!TaskQueueEmpty);
104 gBS->CloseEvent (Subtask->DiskIo2Token.Event);
139 gBS->SignalEvent (Task->FileIoToken->Event);
158 ; Link != &Task->Subtasks
159 ; Link = NextLink, NextLink = Link->ForwardLink
162 Subtask =
CR (Link,
FAT_SUBTASK, Link, FAT_SUBTASK_SIGNATURE);
163 if (Subtask->Write) {
164 Status = IFile->OFile->Volume->DiskIo2->WriteDiskEx (
165 IFile->OFile->Volume->DiskIo2,
166 IFile->OFile->Volume->MediaId,
168 &Subtask->DiskIo2Token,
173 Status = IFile->OFile->Volume->DiskIo2->ReadDiskEx (
174 IFile->OFile->Volume->DiskIo2,
175 IFile->OFile->Volume->MediaId,
177 &Subtask->DiskIo2Token,
183 if (EFI_ERROR (Status)) {
188 if (EFI_ERROR (Status)) {
195 while (!
IsNull (&Task->Subtasks, Link)) {
196 Subtask =
CR (Link,
FAT_SUBTASK, Link, FAT_SUBTASK_SIGNATURE);
208 Task->FileIoToken =
NULL;
238 WriteCount = Volume->FatEntrySize;
239 return FatDiskIo (Volume, IoMode, Volume->FatPos + WriteCount, WriteCount, DirtyValue,
NULL);
267 Task = Subtask->Task;
268 Status = Subtask->DiskIo2Token.TransactionStatus;
270 ASSERT (Task->Signature == FAT_TASK_SIGNATURE);
271 ASSERT (Subtask->Signature == FAT_SUBTASK_SIGNATURE);
281 if (Task->FileIoToken !=
NULL) {
282 if (
IsListEmpty (&Task->Subtasks) || EFI_ERROR (Status)) {
283 Task->FileIoToken->Status = Status;
284 gBS->SignalEvent (Task->FileIoToken->Event);
288 Task->FileIoToken =
NULL;
332 Status = EFI_VOLUME_CORRUPTED;
333 if (Offset + BufferSize <= Volume->VolumeSize) {
334 if (CACHE_ENABLED (IoMode)) {
338 Status =
FatAccessCache (Volume, CACHE_TYPE (IoMode), RAW_ACCESS (IoMode), Offset, BufferSize, Buffer, Task);
347 DiskIo = Volume->DiskIo;
348 IoFunction = (IoMode == ReadDisk) ? DiskIo->ReadDisk : DiskIo->WriteDisk;
349 Status = IoFunction (DiskIo, Volume->MediaId, Offset, BufferSize, Buffer);
355 if (Subtask ==
NULL) {
356 Status = EFI_OUT_OF_RESOURCES;
358 Subtask->Signature = FAT_SUBTASK_SIGNATURE;
359 Subtask->Task = Task;
360 Subtask->Write = (BOOLEAN)(IoMode == WriteDisk);
361 Subtask->Offset = Offset;
362 Subtask->Buffer = Buffer;
363 Subtask->BufferSize = BufferSize;
364 Status =
gBS->CreateEvent (
369 &Subtask->DiskIo2Token.Event
371 if (!EFI_ERROR (Status)) {
381 if (EFI_ERROR (Status)) {
382 Volume->DiskError =
TRUE;
383 DEBUG ((DEBUG_ERROR,
"FatDiskIo: error %r\n", Status));
445 if (DirEnt->FileString !=
NULL) {
467 if (Volume->CacheBuffer !=
NULL) {
495 if (ETime->Year > 1980) {
496 FTime->Date.Year = (UINT16)(ETime->Year - 1980);
499 if (ETime->Year >= 1980 + FAT_MAX_YEAR_FROM_1980) {
500 FTime->Date.Year = FAT_MAX_YEAR_FROM_1980;
503 FTime->Date.Month = ETime->Month;
504 FTime->Date.Day = ETime->Day;
505 FTime->Time.Hour = ETime->Hour;
506 FTime->Time.Minute = ETime->Minute;
507 FTime->Time.DoubleSecond = (UINT16)(ETime->Second / 2);
524 ETime->Year = (UINT16)(FTime->Date.Year + 1980);
525 ETime->Month = (UINT8)FTime->Date.Month;
526 ETime->Day = (UINT8)FTime->Date.Day;
527 ETime->Hour = (UINT8)FTime->Time.Hour;
528 ETime->Minute = (UINT8)FTime->Time.Minute;
529 ETime->Second = (UINT8)(FTime->Time.DoubleSecond * 2);
530 ETime->Nanosecond = 0;
550 Status =
gRT->GetTime (&Now,
NULL);
551 if (!EFI_ERROR (Status)) {
586 if ((Time->Year < 1980) ||
588 (Time->Month > 12) ||
592 (Time->Minute > 59) ||
593 (Time->Second > 59) ||
594 (Time->Nanosecond > 999999999)
602 Day = mMonthDays[Time->Month - 1];
603 if ((Time->Month == 2) && IS_LEAP_YEAR (Time->Year)) {
610 if (Time->Day > Day) {
BOOLEAN EFIAPI IsNull(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
LIST_ENTRY *EFIAPI GetNextNode(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
LIST_ENTRY *EFIAPI GetFirstNode(IN CONST LIST_ENTRY *List)
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID FatCleanupODirCache(IN FAT_VOLUME *Volume)
EFI_STATUS FatAccessCache(IN FAT_VOLUME *Volume, IN CACHE_DATA_TYPE CacheDataType, IN IO_MODE IoMode, IN UINT64 Offset, IN UINTN BufferSize, IN OUT UINT8 *Buffer, IN FAT_TASK *Task)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID FatFreeVolume(IN FAT_VOLUME *Volume)
VOID FatDestroyTask(FAT_TASK *Task)
VOID FatFatTimeToEfiTime(IN FAT_DATE_TIME *FTime, OUT EFI_TIME *ETime)
FAT_TASK * FatCreateTask(FAT_IFILE *IFile, EFI_FILE_IO_TOKEN *Token)
VOID FatEfiTimeToFatTime(IN EFI_TIME *ETime, OUT FAT_DATE_TIME *FTime)
EFI_STATUS FatQueueTask(IN FAT_IFILE *IFile, IN FAT_TASK *Task)
VOID FatGetCurrentFatTime(OUT FAT_DATE_TIME *FatNow)
EFI_STATUS FatAcquireLockOrFail(VOID)
LIST_ENTRY * FatDestroySubtask(FAT_SUBTASK *Subtask)
VOID EFIAPI FatOnAccessComplete(IN EFI_EVENT Event, IN VOID *Context)
VOID FatWaitNonblockingTask(FAT_IFILE *IFile)
BOOLEAN FatIsValidTime(IN EFI_TIME *Time)
EFI_STATUS FatDiskIo(IN FAT_VOLUME *Volume, IN IO_MODE IoMode, IN UINT64 Offset, IN UINTN BufferSize, IN OUT VOID *Buffer, IN FAT_TASK *Task)
EFI_STATUS FatAccessVolumeDirty(IN FAT_VOLUME *Volume, IN IO_MODE IoMode, IN VOID *DirtyValue)
VOID FatFreeDirEnt(IN FAT_DIRENT *DirEnt)
VOID FatAcquireLock(VOID)
VOID FatReleaseLock(VOID)
EFI_RUNTIME_SERVICES * gRT
#define DEBUG(Expression)
#define CR(Record, TYPE, Field, TestSignature)
EFI_STATUS(EFIAPI * EFI_DISK_READ)(IN EFI_DISK_IO_PROTOCOL *This, IN UINT32 MediaId, IN UINT64 Offset, IN UINTN BufferSize, OUT VOID *Buffer)
EFI_TPL EFIAPI EfiGetCurrentTpl(VOID)
VOID EFIAPI EfiReleaseLock(IN EFI_LOCK *Lock)
EFI_STATUS EFIAPI EfiAcquireLockOrFail(IN EFI_LOCK *Lock)
VOID EFIAPI EfiAcquireLock(IN EFI_LOCK *Lock)
#define EFI_UNSPECIFIED_TIMEZONE