ReactOS 0.4.16-dev-297-gc569aee
fat.c File Reference
#include <bl.h>
#include <fs_rec/fs_rec.h>
Include dependency graph for fat.c:

Go to the source code of this file.

Functions

NTSTATUS FatMount (_In_ ULONG DeviceId, _In_ ULONG Unknown, _Out_ PBL_FILE_ENTRY *FileEntry)
 
NTSTATUS FatInitialize (VOID)
 

Variables

PVOIDFatDeviceTable
 
ULONG FatDeviceTableEntries
 
PWCHAR FatpLongFileName
 

Function Documentation

◆ FatInitialize()

NTSTATUS FatInitialize ( VOID  )

Definition at line 81 of file fat.c.

84{
86
87 /* Allocate the device table with 2 entries*/
92 {
93 /* Zero it out */
96
97 /* Allocate a 512 byte buffer for long file name conversion */
100 }
101 else
102 {
103 /* No memory, fail */
105 }
106
107 /* Return back to caller */
108 return Status;
109}
LONG NTSTATUS
Definition: precomp.h:26
PVOID BlMmAllocateHeap(_In_ SIZE_T Size)
Definition: heapalloc.c:569
ULONG FatDeviceTableEntries
Definition: fat.c:17
PVOID * FatDeviceTable
Definition: fat.c:16
PWCHAR FatpLongFileName
Definition: fat.c:18
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#define NULL
Definition: types.h:112
Status
Definition: gdiplustypes.h:25
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: bl.h:1038
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

◆ FatMount()

NTSTATUS FatMount ( _In_ ULONG  DeviceId,
_In_ ULONG  Unknown,
_Out_ PBL_FILE_ENTRY FileEntry 
)

Definition at line 23 of file fat.c.

28{
29 BL_DEVICE_INFORMATION DeviceInformation;
30 ULONG UnknownFlag;
32 PACKED_BOOT_SECTOR FatBootSector;
33 BIOS_PARAMETER_BLOCK BiosBlock;
34
35 /* Capture thing */
36 BlDeviceGetInformation(DeviceId, &DeviceInformation);
37 UnknownFlag = DeviceInformation.BlockDeviceInfo.Unknown;
38
39 /* Set thing to 1 */
40 DeviceInformation.BlockDeviceInfo.Unknown |= 1;
41 BlDeviceSetInformation(DeviceId, &DeviceInformation);
42
43 /* Read the boot sector */
45 sizeof(FatBootSector),
46 0,
47 &FatBootSector,
48 NULL);
49
50 /* Restore thing back */
51 DeviceInformation.BlockDeviceInfo.Unknown = UnknownFlag;
52 BlDeviceSetInformation(DeviceId, &DeviceInformation);
53 if (!NT_SUCCESS(Status))
54 {
55 EfiPrintf(L"Failed reading drive: %lx\r\n", Status);
56 return Status;
57 }
58
59 FatUnpackBios(&BiosBlock, &FatBootSector.PackedBpb);
60
61 /* For now, quickly fail if this isn't FAT */
62 if (FatBootSector.Jump[0] != 0xE9)
63 {
65 }
66
67 EfiPrintf(L"Jump: %lx Bytes Per Sector: %d Sectors Per Cluster: %d Reserved: %d Fats: %d Sectors: %d Large Sectors: %d Media: %lx RootEntries: %d\r\n",
68 FatBootSector.Jump[0],
69 BiosBlock.BytesPerSector,
70 BiosBlock.SectorsPerCluster,
71 BiosBlock.ReservedSectors,
72 BiosBlock.Fats,
73 BiosBlock.Sectors,
74 BiosBlock.LargeSectors,
75 BiosBlock.Media,
76 BiosBlock.RootEntries);
78}
NTSTATUS BlDeviceGetInformation(_In_ ULONG DeviceId, _Out_ PBL_DEVICE_INFORMATION DeviceInformation)
Definition: device.c:682
NTSTATUS BlDeviceReadAtOffset(_In_ ULONG DeviceId, _In_ ULONG Size, _In_ ULONGLONG Offset, _In_ PVOID Buffer, _Out_ PULONG BytesRead)
Definition: device.c:773
VOID EfiPrintf(_In_ PWCHAR Format,...)
Definition: firmware.c:126
NTSTATUS BlDeviceSetInformation(_In_ ULONG DeviceId, _In_ PBL_DEVICE_INFORMATION DeviceInformation)
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define FatUnpackBios(Bios, Pbios)
Definition: fat.h:136
#define L(x)
Definition: ntvdm.h:50
USHORT ReservedSectors
Definition: fat.h:106
USHORT BytesPerSector
Definition: fat.h:104
USHORT Sectors
Definition: fat.h:109
ULONG32 LargeSectors
Definition: fat.h:115
USHORT RootEntries
Definition: fat.h:108
UCHAR SectorsPerCluster
Definition: fat.h:105
BL_BLOCK_DEVICE_INFORMATION BlockDeviceInfo
Definition: bl.h:1228
UCHAR Jump[3]
Definition: fat.h:163
PACKED_BIOS_PARAMETER_BLOCK PackedBpb
Definition: fat.h:165
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132

Variable Documentation

◆ FatDeviceTable

PVOID* FatDeviceTable

Definition at line 16 of file fat.c.

Referenced by FatInitialize().

◆ FatDeviceTableEntries

ULONG FatDeviceTableEntries

Definition at line 17 of file fat.c.

Referenced by FatInitialize().

◆ FatpLongFileName

PWCHAR FatpLongFileName

Definition at line 18 of file fat.c.

Referenced by FatInitialize().