2 * COPYRIGHT: See COPYING.ARM in the top level directory
3 * PROJECT: ReactOS UEFI Boot Library
4 * FILE: boot/environ/lib/io/fat.c
5 * PURPOSE: Boot Library FAT File System Management Routines
6 * PROGRAMMER: Alex Ionescu (alex.ionescu@reactos.org)
9 /* INCLUDES ******************************************************************/
12 #include "..\drivers\filesystems\fs_rec\fs_rec.h"
14 /* DATA VARIABLES ************************************************************/
16 PVOID
* FatDeviceTable
;
17 ULONG FatDeviceTableEntries
;
18 PWCHAR FatpLongFileName
;
20 /* FUNCTIONS *****************************************************************/
26 _Out_ PBL_FILE_ENTRY
* FileEntry
29 BL_DEVICE_INFORMATION DeviceInformation
;
32 PACKED_BOOT_SECTOR FatBootSector
;
34 EfiPrintf(L
"FAT Mount on Device %d\r\n", DeviceId
);
37 BlDeviceGetInformation(DeviceId
, &DeviceInformation
);
38 UnknownFlag
= DeviceInformation
.BlockDeviceInfo
.Unknown
;
41 DeviceInformation
.BlockDeviceInfo
.Unknown
|= 1;
42 BlDeviceSetInformation(DeviceId
, &DeviceInformation
);
44 /* Read the boot sector */
45 EfiPrintf(L
"Reading fat boot sector...\r\n");
46 Status
= BlDeviceReadAtOffset(DeviceId
,
47 sizeof(FatBootSector
),
52 /* Restore thing back */
53 DeviceInformation
.BlockDeviceInfo
.Unknown
= UnknownFlag
;
54 BlDeviceSetInformation(DeviceId
, &DeviceInformation
);
55 if (!NT_SUCCESS(Status
))
57 EfiPrintf(L
"Failed reading drive: %lx\r\n", Status
);
61 EfiPrintf(L
"Drive read\r\n");
63 return STATUS_NOT_IMPLEMENTED
;
73 /* Allocate the device table with 2 entries*/
74 FatDeviceTableEntries
= 2;
75 FatDeviceTable
= BlMmAllocateHeap(sizeof(PBL_FILE_ENTRY
) *
76 FatDeviceTableEntries
);
80 RtlZeroMemory(FatDeviceTable
,
81 sizeof(PBL_FILE_ENTRY
) * FatDeviceTableEntries
);
83 /* Allocate a 512 byte buffer for long file name conversion */
84 FatpLongFileName
= BlMmAllocateHeap(512);
85 Status
= FatpLongFileName
!= NULL
? STATUS_SUCCESS
: STATUS_NO_MEMORY
;
90 Status
= STATUS_NO_MEMORY
;
93 /* Return back to caller */