ReactOS 0.4.16-dev-334-g4d9f67c
uefidisk.c
Go to the documentation of this file.
1/*
2 * PROJECT: FreeLoader UEFI Support
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Disk Access Functions
5 * COPYRIGHT: Copyright 2022 Justin Miller <justinmiller100@gmail.com>
6 */
7
8/* INCLUDES ******************************************************************/
9
10#include <uefildr.h>
11
12#include <debug.h>
14
15#define TAG_HW_RESOURCE_LIST 'lRwH'
16#define TAG_HW_DISK_CONTEXT 'cDwH'
17#define FIRST_BIOS_DISK 0x80
18#define FIRST_PARTITION 1
19
20typedef struct tagDISKCONTEXT
21{
28
29typedef struct _INTERNAL_UEFI_DISK
30{
36
37/* GLOBALS *******************************************************************/
38
41extern EFI_HANDLE PublicBootHandle; /* Freeldr itself */
42
43/* Made to match BIOS */
46
51
52static const CHAR Hex[] = "0123456789abcdef";
53static CHAR PcDiskIdentifier[32][20];
54
55/* UEFI-specific */
63
64/* FUNCTIONS *****************************************************************/
65
68{
69 TRACE("GetHarddiskIdentifier: DriveNumber: %d\n", DriveNumber);
70 return PcDiskIdentifier[DriveNumber - FIRST_BIOS_DISK];
71}
72
73static LONG lReportError = 0; // >= 0: display errors; < 0: hide errors.
74
75LONG
77{
78 /* Set the reference count */
79 if (bShowError) ++lReportError;
80 else --lReportError;
81 return lReportError;
82}
83
84static
87 IN UCHAR DriveNumber,
88 OUT PPARTITION_TABLE_ENTRY PartitionTableEntry,
89 OUT PULONG BootPartition)
90{
91 ULONG PartitionNum;
92
93 TRACE("UefiGetBootPartitionEntry: DriveNumber: %d\n", DriveNumber - FIRST_BIOS_DISK);
94 /* UefiBootRoot is the offset into the array of handles where the raw disk of the boot drive is.
95 * Partitions start with 1 in ARC, but UEFI root drive identitfier is also first partition. */
96 PartitionNum = (OffsetToBoot - UefiBootRootIdentifier);
97 if (PartitionNum == 0)
98 {
99 TRACE("Boot PartitionNumber is 0\n");
100 /* The OffsetToBoot is equal to the RootIdentifier */
101 PartitionNum = FIRST_PARTITION;
102 }
103
104 *BootPartition = PartitionNum;
105 TRACE("UefiGetBootPartitionEntry: Boot Partition is: %d\n", PartitionNum);
106 return TRUE;
107}
108
109static
112{
115 return ESUCCESS;
116}
117
118static
121{
124
125 /*
126 * The ARC specification mentions that for partitions, StartingAddress and
127 * EndingAddress are the start and end positions of the partition in terms
128 * of byte offsets from the start of the disk.
129 * CurrentAddress is the current offset into (i.e. relative to) the partition.
130 */
131 Information->StartingAddress.QuadPart = Context->SectorOffset * Context->SectorSize;
132 Information->EndingAddress.QuadPart = (Context->SectorOffset + Context->SectorCount) * Context->SectorSize;
133 Information->CurrentAddress.QuadPart = Context->SectorNumber * Context->SectorSize;
134
135 return ESUCCESS;
136}
137
138static
140UefiDiskOpen(CHAR *Path, OPENMODE OpenMode, ULONG *FileId)
141{
143 UCHAR DriveNumber;
144 ULONG DrivePartition, SectorSize;
147 ULONG UefiDriveNumber = 0;
148 PARTITION_TABLE_ENTRY PartitionTableEntry;
149
150 TRACE("UefiDiskOpen: File ID: %d, Path: %s\n", FileId, Path);
151
152 if (DiskReadBufferSize == 0)
153 {
154 ERR("DiskOpen(): DiskReadBufferSize is 0, something is wrong.\n");
155 ASSERT(FALSE);
156 return ENOMEM;
157 }
158
159 if (!DissectArcPath(Path, NULL, &DriveNumber, &DrivePartition))
160 return EINVAL;
161
162 TRACE("Opening disk: DriveNumber: %d, DrivePartition: %d\n", DriveNumber, DrivePartition);
163 UefiDriveNumber = DriveNumber - FIRST_BIOS_DISK;
164 GlobalSystemTable->BootServices->HandleProtocol(handles[UefiDriveNumber], &bioGuid, (void**)&bio);
166
167 if (DrivePartition != 0xff && DrivePartition != 0)
168 {
169 if (!DiskGetPartitionEntry(DriveNumber, DrivePartition, &PartitionTableEntry))
170 return EINVAL;
171
172 SectorOffset = PartitionTableEntry.SectorCountBeforePartition;
173 SectorCount = PartitionTableEntry.PartitionSectorCount;
174 }
175 else
176 {
177 GEOMETRY Geometry;
178 if (!MachDiskGetDriveGeometry(DriveNumber, &Geometry))
179 return EINVAL;
180
181 if (SectorSize != Geometry.BytesPerSector)
182 {
183 ERR("SectorSize (%lu) != Geometry.BytesPerSector (%lu), expect problems!\n",
184 SectorSize, Geometry.BytesPerSector);
185 }
186
187 SectorOffset = 0;
188 SectorCount = Geometry.Sectors;
189 }
190
192 if (!Context)
193 return ENOMEM;
194
195 Context->DriveNumber = DriveNumber;
196 Context->SectorSize = SectorSize;
197 Context->SectorOffset = SectorOffset;
198 Context->SectorCount = SectorCount;
199 Context->SectorNumber = 0;
201 return ESUCCESS;
202}
203
204static
207{
209 UCHAR* Ptr = (UCHAR*)Buffer;
210 ULONG Length, TotalSectors, MaxSectors, ReadSectors;
212 BOOLEAN ret;
213
215
216 TotalSectors = (N + Context->SectorSize - 1) / Context->SectorSize;
217 MaxSectors = DiskReadBufferSize / Context->SectorSize;
218 SectorOffset = Context->SectorOffset + Context->SectorNumber;
219
220 // If MaxSectors is 0, this will lead to infinite loop.
221 // In release builds assertions are disabled, however we also have sanity checks in DiskOpen()
222 ASSERT(MaxSectors > 0);
223
224 ret = TRUE;
225
226 while (TotalSectors)
227 {
228 ReadSectors = min(TotalSectors, MaxSectors);
229
232 ReadSectors,
234 if (!ret)
235 break;
236
237 Length = ReadSectors * Context->SectorSize;
238 Length = min(Length, N);
239
241
242 Ptr += Length;
243 N -= Length;
244 SectorOffset += ReadSectors;
245 TotalSectors -= ReadSectors;
246 }
247
249 Context->SectorNumber = SectorOffset - Context->SectorOffset;
250
251 return (ret ? ESUCCESS : EIO);
252}
253
254static
257{
259 LARGE_INTEGER NewPosition = *Position;
260
261 switch (SeekMode)
262 {
263 case SeekAbsolute:
264 break;
265 case SeekRelative:
266 NewPosition.QuadPart += (Context->SectorNumber * Context->SectorSize);
267 break;
268 default:
269 ASSERT(FALSE);
270 return EINVAL;
271 }
272
273 if (NewPosition.QuadPart & (Context->SectorSize - 1))
274 return EINVAL;
275
276 /* Convert in number of sectors */
277 NewPosition.QuadPart /= Context->SectorSize;
278
279 /* HACK: CDROMs may have a SectorCount of 0 */
280 if (Context->SectorCount != 0 && NewPosition.QuadPart >= Context->SectorCount)
281 return EINVAL;
282
283 Context->SectorNumber = NewPosition.QuadPart;
284 return ESUCCESS;
285}
286
287static const DEVVTBL UefiDiskVtbl =
288{
294};
295
296static
297VOID
299{
302 ULONG i;
303 ULONG Checksum;
305 BOOLEAN ValidPartitionTable;
306 CHAR ArcName[MAX_PATH];
307 PARTITION_TABLE_ENTRY PartitionTableEntry;
309
310 /* Detect disk partition type */
311 DiskDetectPartitionType(DriveNumber);
312
313 /* Read the MBR */
314 if (!MachDiskReadLogicalSectors(DriveNumber, 0ULL, 1, DiskReadBuffer))
315 {
316 ERR("Reading MBR failed\n");
317 /* We failed, use a default identifier */
318 sprintf(Identifier, "BIOSDISK%d", DriveNumber - FIRST_BIOS_DISK);
319 return;
320 }
321
324
325 Signature = Mbr->Signature;
326 TRACE("Signature: %x\n", Signature);
327
328 /* Calculate the MBR checksum */
329 Checksum = 0;
330 for (i = 0; i < 512 / sizeof(ULONG); i++)
331 {
332 Checksum += Buffer[i];
333 }
334 Checksum = ~Checksum + 1;
335 TRACE("Checksum: %x\n", Checksum);
336
337 ValidPartitionTable = (Mbr->MasterBootRecordMagic == 0xAA55);
338
339 /* Fill out the ARC disk block */
340 sprintf(ArcName, "multi(0)disk(0)rdisk(%u)", DriveNumber - FIRST_BIOS_DISK);
341 AddReactOSArcDiskInfo(ArcName, Signature, Checksum, ValidPartitionTable);
342
343 sprintf(ArcName, "multi(0)disk(0)rdisk(%u)partition(0)", DriveNumber - FIRST_BIOS_DISK);
345
346 /* Add partitions */
349 while (DiskGetPartitionEntry(DriveNumber, i, &PartitionTableEntry))
350 {
351 if (PartitionTableEntry.SystemIndicator != PARTITION_ENTRY_UNUSED)
352 {
353 sprintf(ArcName, "multi(0)disk(0)rdisk(%u)partition(%lu)", DriveNumber - FIRST_BIOS_DISK, i);
355 }
356 i++;
357 }
359
360 InternalUefiDisk[DriveNumber].NumOfPartitions = i;
361 /* Convert checksum and signature to identifier string */
362 Identifier[0] = Hex[(Checksum >> 28) & 0x0F];
363 Identifier[1] = Hex[(Checksum >> 24) & 0x0F];
364 Identifier[2] = Hex[(Checksum >> 20) & 0x0F];
365 Identifier[3] = Hex[(Checksum >> 16) & 0x0F];
366 Identifier[4] = Hex[(Checksum >> 12) & 0x0F];
367 Identifier[5] = Hex[(Checksum >> 8) & 0x0F];
368 Identifier[6] = Hex[(Checksum >> 4) & 0x0F];
369 Identifier[7] = Hex[Checksum & 0x0F];
370 Identifier[8] = '-';
371 Identifier[9] = Hex[(Signature >> 28) & 0x0F];
372 Identifier[10] = Hex[(Signature >> 24) & 0x0F];
373 Identifier[11] = Hex[(Signature >> 20) & 0x0F];
374 Identifier[12] = Hex[(Signature >> 16) & 0x0F];
375 Identifier[13] = Hex[(Signature >> 12) & 0x0F];
376 Identifier[14] = Hex[(Signature >> 8) & 0x0F];
377 Identifier[15] = Hex[(Signature >> 4) & 0x0F];
378 Identifier[16] = Hex[Signature & 0x0F];
379 Identifier[17] = '-';
380 Identifier[18] = (ValidPartitionTable ? 'A' : 'X');
381 Identifier[19] = 0;
382 TRACE("Identifier: %s\n", Identifier);
383}
384
385static
386VOID
388{
389 ULONG BlockDeviceIndex;
390 ULONG SystemHandleCount;
392 ULONG i;
393
394 UINTN handle_size = 0;
395 PcBiosDiskCount = 0;
397
398 /* 1) Setup a list of boot handles by using the LocateHandle protocol */
402 SystemHandleCount = handle_size / sizeof(EFI_HANDLE);
404
405 BlockDeviceIndex = 0;
406 /* 2) Parse the handle list */
407 for (i = 0; i < SystemHandleCount; ++i)
408 {
410 if (handles[i] == PublicBootHandle)
411 {
412 OffsetToBoot = i; /* Drive offset in the handles list */
413 }
414
415 if (EFI_ERROR(Status) ||
416 bio == NULL ||
417 bio->Media->BlockSize == 0 ||
418 bio->Media->BlockSize > 4096)
419 {
420 TRACE("UefiSetupBlockDevices: UEFI has found a block device that failed, skipping\n");
421 continue;
422 }
424 {
425 TRACE("Found root of a HDD\n");
427 InternalUefiDisk[BlockDeviceIndex].ArcDriveNumber = BlockDeviceIndex;
428 InternalUefiDisk[BlockDeviceIndex].UefiRootNumber = i;
429 GetHarddiskInformation(BlockDeviceIndex + FIRST_BIOS_DISK);
430 BlockDeviceIndex++;
431 }
432 else if (handles[i] == PublicBootHandle)
433 {
434 ULONG increment = 0;
435 ULONG i;
436
437 /* 3) Grab the offset into the array of handles and decrement per volume (valid partition) */
438 for (increment = OffsetToBoot; increment > 0; increment--)
439 {
442 {
443 TRACE("Found root at increment %u\n", increment);
444 UefiBootRootIdentifier = increment;
445
446 for (i = 0; i <= PcBiosDiskCount; ++i)
447 {
448 /* Now only of the root drive number is equal to this drive we found above */
449 if (InternalUefiDisk[i].UefiRootNumber == UefiBootRootIdentifier)
450 {
453 TRACE("Found Boot drive\n");
454 }
455 }
456
457 break;
458 }
459 }
460 }
461 }
462}
463
464static
467{
468 TRACE("UefiSetBootpath: Setting up boot path\n");
471 if (bio->Media->RemovableMedia == TRUE && bio->Media->BlockSize == 2048)
472 {
473 /* Boot Partition 0xFF is the magic value that indicates booting from CD-ROM (see isoboot.S) */
474 FrldrBootPartition = 0xFF;
476 "multi(0)disk(0)cdrom(%u)", PublicBootArcDisk);
477 }
478 else
479 {
480 ULONG BootPartition;
481 PARTITION_TABLE_ENTRY PartitionEntry;
482
483 /* This is a hard disk */
484 if (!UefiGetBootPartitionEntry(FrldrBootDrive, &PartitionEntry, &BootPartition))
485 {
486 ERR("Failed to get boot partition entry\n");
487 return FALSE;
488 }
489
491 "multi(0)disk(0)rdisk(%u)partition(%lu)",
492 PublicBootArcDisk, BootPartition);
493 }
494
495 return TRUE;
496}
497
500{
501 ULONG i = 0;
502
507
508 /* Add it, if it's a cdrom */
510 if (bio->Media->RemovableMedia == TRUE && bio->Media->BlockSize == 2048)
511 {
514 ULONG Checksum = 0;
516
517 /* Read the MBR */
519 {
520 ERR("Reading MBR failed\n");
521 return FALSE;
522 }
523
526
527 Signature = Mbr->Signature;
528 TRACE("Signature: %x\n", Signature);
529
530 /* Calculate the MBR checksum */
531 for (i = 0; i < 2048 / sizeof(ULONG); i++)
532 {
533 Checksum += Buffer[i];
534 }
535 Checksum = ~Checksum + 1;
536 TRACE("Checksum: %x\n", Checksum);
537
538 /* Fill out the ARC disk block */
540
542 PcBiosDiskCount++; // This is not accounted for in the number of pre-enumerated BIOS drives!
543 TRACE("Additional boot drive detected: 0x%02X\n", (int)FrldrBootDrive);
544 }
545 return TRUE;
546}
547
548UCHAR
550{
551 /* No floppy for you for now... */
552 return 0;
553}
554
557 IN UCHAR DriveNumber,
558 IN ULONGLONG SectorNumber,
561{
562 ULONG UefiDriveNumber;
563
564 UefiDriveNumber = InternalUefiDisk[DriveNumber - FIRST_BIOS_DISK].UefiRootNumber;
565 TRACE("UefiDiskReadLogicalSectors: DriveNumber: %d\n", UefiDriveNumber);
566 GlobalSystemTable->BootServices->HandleProtocol(handles[UefiDriveNumber], &bioGuid, (void**)&bio);
567
568 /* Devices setup */
570 return TRUE;
571}
572
575{
576 ULONG UefiDriveNumber;
577
578 UefiDriveNumber = InternalUefiDisk[DriveNumber - FIRST_BIOS_DISK].UefiRootNumber;
579 GlobalSystemTable->BootServices->HandleProtocol(handles[UefiDriveNumber], &bioGuid, (void**)&bio);
580 Geometry->Cylinders = 1; // Not relevant for the UEFI BIO protocol
581 Geometry->Heads = 1; // Not relevant for the UEFI BIO protocol
582 Geometry->SectorsPerTrack = (bio->Media->LastBlock + 1);
583 Geometry->BytesPerSector = bio->Media->BlockSize;
584 Geometry->Sectors = (bio->Media->LastBlock + 1);
585
586 return TRUE;
587}
588
589ULONG
591{
592 ULONG UefiDriveNumber = InternalUefiDisk[DriveNumber - FIRST_BIOS_DISK].UefiRootNumber;
593 TRACE("UefiDiskGetCacheableBlockCount: DriveNumber: %d\n", UefiDriveNumber);
594
595 GlobalSystemTable->BootServices->HandleProtocol(handles[UefiDriveNumber], &bioGuid, (void**)&bio);
596 return (bio->Media->LastBlock + 1);
597}
#define N
Definition: crc32.c:57
#define BLOCK_IO_PROTOCOL
Definition: BlockIo.h:31
#define WARNING
Definition: BusLogic958.h:56
unsigned char BOOLEAN
UINT32 UINTN
PRTL_UNICODE_STRING_BUFFER Path
#define EFI_PAGE_SIZE
Definition: UefiBaseType.h:189
#define EFI_ERROR(A)
Definition: UefiBaseType.h:165
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:31
VOID * EFI_HANDLE
Definition: UefiBaseType.h:35
@ ByProtocol
Definition: UefiSpec.h:1428
#define EINVAL
Definition: acclib.h:90
#define ENOMEM
Definition: acclib.h:84
#define EIO
Definition: acclib.h:81
VOID AddReactOSArcDiskInfo(IN PSTR ArcName, IN ULONG Signature, IN ULONG Checksum, IN BOOLEAN ValidPartitionTable)
Definition: archwsup.c:77
@ Identifier
Definition: asmpp.cpp:95
#define ERR(fmt,...)
Definition: precomp.h:57
BOOLEAN DissectArcPath(IN PCSTR ArcPath, OUT PCSTR *Path OPTIONAL, OUT PUCHAR DriveNumber, OUT PULONG PartitionNumber)
Definition: arcname.c:25
BOOLEAN DiskGetPartitionEntry(IN UCHAR DriveNumber, IN ULONG PartitionNumber, OUT PPARTITION_TABLE_ENTRY PartitionTableEntry)
Definition: partition.c:407
VOID DiskDetectPartitionType(IN UCHAR DriveNumber)
Definition: partition.c:314
#define DBG_DEFAULT_CHANNEL(ch)
Definition: debug.h:106
#define PARTITION_ENTRY_UNUSED
Definition: disk.h:87
struct _MASTER_BOOT_RECORD * PMASTER_BOOT_RECORD
PVOID FsGetDeviceSpecific(ULONG FileId)
Definition: fs.c:632
VOID FsSetDeviceSpecific(ULONG FileId, PVOID Specific)
Definition: fs.c:625
VOID FsRegisterDevice(_In_ PCSTR DeviceName, _In_ const DEVVTBL *FuncTable)
Definition: fs.c:596
#define MachDiskGetDriveGeometry(Drive, Geom)
Definition: machine.h:128
#define MachDiskReadLogicalSectors(Drive, Start, Count, Buf)
Definition: machine.h:126
PVOID MmAllocateMemoryWithType(SIZE_T MemorySize, TYPE_OF_MEMORY MemoryType)
Definition: mm.c:31
FORCEINLINE PVOID FrLdrTempAlloc(_In_ SIZE_T Size, _In_ ULONG Tag)
Definition: mm.h:188
FORCEINLINE VOID FrLdrTempFree(PVOID Allocation, ULONG Tag)
Definition: mm.h:197
#define SectorOffset(L)
Definition: cdprocs.h:1622
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define MAX_PATH
Definition: compat.h:34
static const WCHAR Signature[]
Definition: parser.c:141
#define ULONG_PTR
Definition: config.h:101
CCHAR FrLdrBootPath[MAX_PATH]
Definition: freeldr.c:29
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
Status
Definition: gdiplustypes.h:25
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ASSERT(a)
Definition: mode.c:44
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define ULL(a, b)
Definition: format_msg.c:27
#define min(a, b)
Definition: monoChain.cc:55
int Count
Definition: noreturn.cpp:7
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
NTSTRSAFEVAPI RtlStringCbPrintfA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
Definition: ntstrsafe.h:1148
ULONG SectorCount
Definition: part_xbox.c:31
long LONG
Definition: pedump.c:60
@ ESUCCESS
Definition: arc.h:32
@ LoaderFirmwareTemporary
Definition: arc.h:179
ULONG ARC_STATUS
Definition: arc.h:4
@ SeekRelative
Definition: arc.h:60
@ SeekAbsolute
Definition: arc.h:59
enum _OPENMODE OPENMODE
enum _SEEKMODE SEEKMODE
#define TRACE(s)
Definition: solgame.cpp:4
BOOLEAN RemovableMedia
Definition: BlockIo.h:143
BOOLEAN LogicalPartition
Definition: BlockIo.h:156
UINT32 BlockSize
Definition: BlockIo.h:173
EFI_LBA LastBlock
Definition: BlockIo.h:184
EFI_LOCATE_HANDLE LocateHandle
Definition: UefiSpec.h:1835
EFI_HANDLE_PROTOCOL HandleProtocol
Definition: UefiSpec.h:1832
EFI_BOOT_SERVICES * BootServices
Definition: UefiSpec.h:1959
Definition: parttest.c:75
ULONG PartitionSectorCount
Definition: parttest.c:85
ULONG SectorCountBeforePartition
Definition: parttest.c:84
UCHAR SystemIndicator
Definition: parttest.c:80
EFI_BLOCK_IO_MEDIA * Media
Definition: BlockIo.h:230
EFI_BLOCK_READ ReadBlocks
Definition: BlockIo.h:233
Definition: disk.h:26
ULONG BytesPerSector
Number of bytes per sector.
Definition: disk.h:30
ULONG Cylinders
Number of cylinders on the disk.
Definition: disk.h:27
ULONGLONG Sectors
Total number of disk sectors/LBA blocks.
Definition: disk.h:31
ULONG SectorsPerTrack
Number of sectors per track.
Definition: disk.h:29
ULONG Heads
Number of heads on the disk.
Definition: disk.h:28
BOOLEAN IsThisTheBootDrive
Definition: uefidisk.c:34
UCHAR UefiRootNumber
Definition: uefidisk.c:33
UCHAR ArcDriveNumber
Definition: uefidisk.c:31
UCHAR NumOfPartitions
Definition: uefidisk.c:32
USHORT MasterBootRecordMagic
Definition: disk.h:79
ULONG Signature
Definition: disk.h:76
Definition: disk.h:56
Definition: fs.h:25
ULONGLONG SectorOffset
Definition: hwdisk.c:38
UCHAR DriveNumber
Definition: hwdisk.c:36
ULONGLONG SectorCount
Definition: hwdisk.c:39
ULONGLONG SectorNumber
Definition: hwdisk.c:40
ULONG SectorSize
Definition: hwdisk.c:37
static COORD Position
Definition: mouse.c:34
uint32_t * PULONG
Definition: typedefs.h:59
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
uint64_t ULONGLONG
Definition: typedefs.h:67
#define OUT
Definition: typedefs.h:40
char * PCHAR
Definition: typedefs.h:51
static LONG lReportError
Definition: uefidisk.c:73
static ULONG PublicBootArcDisk
Definition: uefidisk.c:58
static EFI_GUID bioGuid
Definition: uefidisk.c:60
static EFI_BLOCK_IO * bio
Definition: uefidisk.c:61
BOOLEAN UefiDiskGetDriveGeometry(UCHAR DriveNumber, PGEOMETRY Geometry)
Definition: uefidisk.c:574
PVOID Buffer
Definition: uefidisk.c:50
#define TAG_HW_DISK_CONTEXT
Definition: uefidisk.c:16
static BOOLEAN UefiGetBootPartitionEntry(IN UCHAR DriveNumber, OUT PPARTITION_TABLE_ENTRY PartitionTableEntry, OUT PULONG BootPartition)
Definition: uefidisk.c:86
PVOID DiskReadBuffer
Definition: uefidisk.c:44
BOOLEAN UefiDiskReadLogicalSectors(IN UCHAR DriveNumber, IN ULONGLONG SectorNumber, IN ULONG SectorCount, OUT PVOID Buffer)
Definition: uefidisk.c:556
struct tagDISKCONTEXT DISKCONTEXT
static CHAR PcDiskIdentifier[32][20]
Definition: uefidisk.c:53
BOOLEAN UefiInitializeBootDevices(VOID)
Definition: uefidisk.c:499
static ARC_STATUS UefiDiskGetFileInformation(ULONG FileId, FILEINFORMATION *Information)
Definition: uefidisk.c:120
static ULONG UefiBootRootIdentifier
Definition: uefidisk.c:56
EFI_HANDLE PublicBootHandle
Definition: uefimem.c:39
EFI_SYSTEM_TABLE * GlobalSystemTable
Definition: uefildr.c:16
LONG DiskReportError(BOOLEAN bShowError)
Definition: uefidisk.c:76
static const DEVVTBL UefiDiskVtbl
Definition: uefidisk.c:287
static VOID UefiSetupBlockDevices(VOID)
Definition: uefidisk.c:387
static const CHAR Hex[]
Definition: uefidisk.c:52
#define FIRST_BIOS_DISK
Definition: uefidisk.c:17
static ARC_STATUS UefiDiskOpen(CHAR *Path, OPENMODE OpenMode, ULONG *FileId)
Definition: uefidisk.c:140
static ARC_STATUS UefiDiskSeek(ULONG FileId, LARGE_INTEGER *Position, SEEKMODE SeekMode)
Definition: uefidisk.c:256
static INTERNAL_UEFI_DISK * InternalUefiDisk
Definition: uefidisk.c:59
static ARC_STATUS UefiDiskClose(ULONG FileId)
Definition: uefidisk.c:111
static VOID GetHarddiskInformation(UCHAR DriveNumber)
Definition: uefidisk.c:298
PCHAR GetHarddiskIdentifier(UCHAR DriveNumber)
Definition: uefidisk.c:67
static ARC_STATUS UefiDiskRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
Definition: uefidisk.c:206
EFI_HANDLE GlobalImageHandle
Definition: uefildr.c:15
struct _INTERNAL_UEFI_DISK INTERNAL_UEFI_DISK
UCHAR PcBiosDiskCount
Definition: uefidisk.c:45
static ULONG OffsetToBoot
Definition: uefidisk.c:57
static EFI_HANDLE * handles
Definition: uefidisk.c:62
UCHAR UefiGetFloppyCount(VOID)
Definition: uefidisk.c:549
SIZE_T DiskReadBufferSize
Definition: uefidisk.c:49
ULONG UefiDiskGetCacheableBlockCount(UCHAR DriveNumber)
Definition: uefidisk.c:590
UCHAR FrldrBootDrive
Definition: uefidisk.c:47
static BOOLEAN UefiSetBootpath(VOID)
Definition: uefidisk.c:466
ULONG FrldrBootPartition
Definition: uefidisk.c:48
struct _INTERNAL_UEFI_DISK * PINTERNAL_UEFI_DISK
#define FIRST_PARTITION
Definition: uefidisk.c:18
LONGLONG QuadPart
Definition: typedefs.h:114
int ret
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1049
_In_ ULONG SectorSize
Definition: halfuncs.h:291
unsigned char UCHAR
Definition: xmlstorage.h:181
char CHAR
Definition: xmlstorage.h:175