ReactOS 0.4.16-dev-1946-g52006dd
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 Information->Type = DiskPeripheral; /* No floppy for you for now... */
136
137 return ESUCCESS;
138}
139
140static
142UefiDiskOpen(CHAR *Path, OPENMODE OpenMode, ULONG *FileId)
143{
145 UCHAR DriveNumber;
146 ULONG DrivePartition, SectorSize;
149 ULONG UefiDriveNumber = 0;
150 PARTITION_TABLE_ENTRY PartitionTableEntry;
151
152 TRACE("UefiDiskOpen: File ID: %d, Path: %s\n", FileId, Path);
153
154 if (DiskReadBufferSize == 0)
155 {
156 ERR("DiskOpen(): DiskReadBufferSize is 0, something is wrong.\n");
157 ASSERT(FALSE);
158 return ENOMEM;
159 }
160
161 if (!DissectArcPath(Path, NULL, &DriveNumber, &DrivePartition))
162 return EINVAL;
163
164 TRACE("Opening disk: DriveNumber: %d, DrivePartition: %d\n", DriveNumber, DrivePartition);
165 UefiDriveNumber = DriveNumber - FIRST_BIOS_DISK;
166 GlobalSystemTable->BootServices->HandleProtocol(handles[UefiDriveNumber], &bioGuid, (void**)&bio);
168
169 if (DrivePartition != 0xff && DrivePartition != 0)
170 {
171 if (!DiskGetPartitionEntry(DriveNumber, DrivePartition, &PartitionTableEntry))
172 return EINVAL;
173
174 SectorOffset = PartitionTableEntry.SectorCountBeforePartition;
175 SectorCount = PartitionTableEntry.PartitionSectorCount;
176 }
177 else
178 {
179 GEOMETRY Geometry;
180 if (!MachDiskGetDriveGeometry(DriveNumber, &Geometry))
181 return EINVAL;
182
183 if (SectorSize != Geometry.BytesPerSector)
184 {
185 ERR("SectorSize (%lu) != Geometry.BytesPerSector (%lu), expect problems!\n",
186 SectorSize, Geometry.BytesPerSector);
187 }
188
189 SectorOffset = 0;
190 SectorCount = Geometry.Sectors;
191 }
192
194 if (!Context)
195 return ENOMEM;
196
197 Context->DriveNumber = DriveNumber;
198 Context->SectorSize = SectorSize;
199 Context->SectorOffset = SectorOffset;
200 Context->SectorCount = SectorCount;
201 Context->SectorNumber = 0;
203 return ESUCCESS;
204}
205
206static
209{
211 UCHAR* Ptr = (UCHAR*)Buffer;
212 ULONG Length, TotalSectors, MaxSectors, ReadSectors;
214 BOOLEAN ret;
215
217
218 TotalSectors = (N + Context->SectorSize - 1) / Context->SectorSize;
219 MaxSectors = DiskReadBufferSize / Context->SectorSize;
220 SectorOffset = Context->SectorOffset + Context->SectorNumber;
221
222 // If MaxSectors is 0, this will lead to infinite loop.
223 // In release builds assertions are disabled, however we also have sanity checks in DiskOpen()
224 ASSERT(MaxSectors > 0);
225
226 ret = TRUE;
227
228 while (TotalSectors)
229 {
230 ReadSectors = min(TotalSectors, MaxSectors);
231
234 ReadSectors,
236 if (!ret)
237 break;
238
239 Length = ReadSectors * Context->SectorSize;
240 Length = min(Length, N);
241
243
244 Ptr += Length;
245 N -= Length;
246 SectorOffset += ReadSectors;
247 TotalSectors -= ReadSectors;
248 }
249
251 Context->SectorNumber = SectorOffset - Context->SectorOffset;
252
253 return (ret ? ESUCCESS : EIO);
254}
255
256static
259{
261 LARGE_INTEGER NewPosition = *Position;
262
263 switch (SeekMode)
264 {
265 case SeekAbsolute:
266 break;
267 case SeekRelative:
268 NewPosition.QuadPart += (Context->SectorNumber * Context->SectorSize);
269 break;
270 default:
271 ASSERT(FALSE);
272 return EINVAL;
273 }
274
275 if (NewPosition.QuadPart & (Context->SectorSize - 1))
276 return EINVAL;
277
278 /* Convert in number of sectors */
279 NewPosition.QuadPart /= Context->SectorSize;
280
281 /* HACK: CDROMs may have a SectorCount of 0 */
282 if (Context->SectorCount != 0 && NewPosition.QuadPart >= Context->SectorCount)
283 return EINVAL;
284
285 Context->SectorNumber = NewPosition.QuadPart;
286 return ESUCCESS;
287}
288
289static const DEVVTBL UefiDiskVtbl =
290{
296};
297
298static
299VOID
301{
304 ULONG i;
305 ULONG Checksum;
307 BOOLEAN ValidPartitionTable;
308 CHAR ArcName[MAX_PATH];
309 PARTITION_TABLE_ENTRY PartitionTableEntry;
311
312 /* Detect disk partition type */
313 DiskDetectPartitionType(DriveNumber);
314
315 /* Read the MBR */
316 if (!MachDiskReadLogicalSectors(DriveNumber, 0ULL, 1, DiskReadBuffer))
317 {
318 ERR("Reading MBR failed\n");
319 /* We failed, use a default identifier */
320 sprintf(Identifier, "BIOSDISK%d", DriveNumber - FIRST_BIOS_DISK);
321 return;
322 }
323
326
327 Signature = Mbr->Signature;
328 TRACE("Signature: %x\n", Signature);
329
330 /* Calculate the MBR checksum */
331 Checksum = 0;
332 for (i = 0; i < 512 / sizeof(ULONG); i++)
333 {
334 Checksum += Buffer[i];
335 }
336 Checksum = ~Checksum + 1;
337 TRACE("Checksum: %x\n", Checksum);
338
339 ValidPartitionTable = (Mbr->MasterBootRecordMagic == 0xAA55);
340
341 /* Fill out the ARC disk block */
342 sprintf(ArcName, "multi(0)disk(0)rdisk(%u)", DriveNumber - FIRST_BIOS_DISK);
343 AddReactOSArcDiskInfo(ArcName, Signature, Checksum, ValidPartitionTable);
344
345 sprintf(ArcName, "multi(0)disk(0)rdisk(%u)partition(0)", DriveNumber - FIRST_BIOS_DISK);
347
348 /* Add partitions */
351 while (DiskGetPartitionEntry(DriveNumber, i, &PartitionTableEntry))
352 {
353 if (PartitionTableEntry.SystemIndicator != PARTITION_ENTRY_UNUSED)
354 {
355 sprintf(ArcName, "multi(0)disk(0)rdisk(%u)partition(%lu)", DriveNumber - FIRST_BIOS_DISK, i);
357 }
358 i++;
359 }
361
362 InternalUefiDisk[DriveNumber].NumOfPartitions = i;
363 /* Convert checksum and signature to identifier string */
364 Identifier[0] = Hex[(Checksum >> 28) & 0x0F];
365 Identifier[1] = Hex[(Checksum >> 24) & 0x0F];
366 Identifier[2] = Hex[(Checksum >> 20) & 0x0F];
367 Identifier[3] = Hex[(Checksum >> 16) & 0x0F];
368 Identifier[4] = Hex[(Checksum >> 12) & 0x0F];
369 Identifier[5] = Hex[(Checksum >> 8) & 0x0F];
370 Identifier[6] = Hex[(Checksum >> 4) & 0x0F];
371 Identifier[7] = Hex[Checksum & 0x0F];
372 Identifier[8] = '-';
373 Identifier[9] = Hex[(Signature >> 28) & 0x0F];
374 Identifier[10] = Hex[(Signature >> 24) & 0x0F];
375 Identifier[11] = Hex[(Signature >> 20) & 0x0F];
376 Identifier[12] = Hex[(Signature >> 16) & 0x0F];
377 Identifier[13] = Hex[(Signature >> 12) & 0x0F];
378 Identifier[14] = Hex[(Signature >> 8) & 0x0F];
379 Identifier[15] = Hex[(Signature >> 4) & 0x0F];
380 Identifier[16] = Hex[Signature & 0x0F];
381 Identifier[17] = '-';
382 Identifier[18] = (ValidPartitionTable ? 'A' : 'X');
383 Identifier[19] = 0;
384 TRACE("Identifier: %s\n", Identifier);
385}
386
387static
388VOID
390{
391 ULONG BlockDeviceIndex;
392 ULONG SystemHandleCount;
394 ULONG i;
395
396 UINTN handle_size = 0;
397 PcBiosDiskCount = 0;
399
400 /* 1) Setup a list of boot handles by using the LocateHandle protocol */
404 SystemHandleCount = handle_size / sizeof(EFI_HANDLE);
406
407 BlockDeviceIndex = 0;
408 /* 2) Parse the handle list */
409 for (i = 0; i < SystemHandleCount; ++i)
410 {
412 if (handles[i] == PublicBootHandle)
413 {
414 OffsetToBoot = i; /* Drive offset in the handles list */
415 }
416
417 if (EFI_ERROR(Status) ||
418 bio == NULL ||
419 bio->Media->BlockSize == 0 ||
420 bio->Media->BlockSize > 4096)
421 {
422 TRACE("UefiSetupBlockDevices: UEFI has found a block device that failed, skipping\n");
423 continue;
424 }
426 {
427 TRACE("Found root of a HDD\n");
429 InternalUefiDisk[BlockDeviceIndex].ArcDriveNumber = BlockDeviceIndex;
430 InternalUefiDisk[BlockDeviceIndex].UefiRootNumber = i;
431 GetHarddiskInformation(BlockDeviceIndex + FIRST_BIOS_DISK);
432 BlockDeviceIndex++;
433 }
434 else if (handles[i] == PublicBootHandle)
435 {
438 {
439 ULONG j;
440
441 TRACE("Found root at index %u\n", i);
443
444 for (j = 0; j <= PcBiosDiskCount; ++j)
445 {
446 /* Now only of the root drive number is equal to this drive we found above */
447 if (InternalUefiDisk[j].UefiRootNumber == UefiBootRootIdentifier)
448 {
451 TRACE("Found Boot drive\n");
452 }
453 }
454 }
455 }
456 }
457}
458
459static
462{
463 TRACE("UefiSetBootpath: Setting up boot path\n");
466 if (bio->Media->RemovableMedia == TRUE && bio->Media->BlockSize == 2048)
467 {
468 /* Boot Partition 0xFF is the magic value that indicates booting from CD-ROM (see isoboot.S) */
469 FrldrBootPartition = 0xFF;
471 "multi(0)disk(0)cdrom(%u)", PublicBootArcDisk);
472 }
473 else
474 {
475 ULONG BootPartition;
476 PARTITION_TABLE_ENTRY PartitionEntry;
477
478 /* This is a hard disk */
479 if (!UefiGetBootPartitionEntry(FrldrBootDrive, &PartitionEntry, &BootPartition))
480 {
481 ERR("Failed to get boot partition entry\n");
482 return FALSE;
483 }
484
486 "multi(0)disk(0)rdisk(%u)partition(%lu)",
487 PublicBootArcDisk, BootPartition);
488 }
489
490 return TRUE;
491}
492
495{
500
501 /* Add it, if it's a cdrom */
503 if (bio->Media->RemovableMedia == TRUE && bio->Media->BlockSize == 2048)
504 {
507 ULONG Checksum = 0;
509 ULONG i;
510
511 /* Read the MBR */
513 {
514 ERR("Reading MBR failed\n");
515 return FALSE;
516 }
517
520
521 Signature = Mbr->Signature;
522 TRACE("Signature: %x\n", Signature);
523
524 /* Calculate the MBR checksum */
525 for (i = 0; i < 2048 / sizeof(ULONG); i++)
526 {
527 Checksum += Buffer[i];
528 }
529 Checksum = ~Checksum + 1;
530 TRACE("Checksum: %x\n", Checksum);
531
532 /* Fill out the ARC disk block */
534
536 PcBiosDiskCount++; // This is not accounted for in the number of pre-enumerated BIOS drives!
537 TRACE("Additional boot drive detected: 0x%02X\n", (int)FrldrBootDrive);
538 }
539 return TRUE;
540}
541
542UCHAR
544{
545 /* No floppy for you for now... */
546 return 0;
547}
548
551 IN UCHAR DriveNumber,
552 IN ULONGLONG SectorNumber,
555{
556 ULONG UefiDriveNumber;
557
558 UefiDriveNumber = InternalUefiDisk[DriveNumber - FIRST_BIOS_DISK].UefiRootNumber;
559 TRACE("UefiDiskReadLogicalSectors: DriveNumber: %d\n", UefiDriveNumber);
560 GlobalSystemTable->BootServices->HandleProtocol(handles[UefiDriveNumber], &bioGuid, (void**)&bio);
561
562 /* Devices setup */
564 return TRUE;
565}
566
569{
570 ULONG UefiDriveNumber;
571
572 UefiDriveNumber = InternalUefiDisk[DriveNumber - FIRST_BIOS_DISK].UefiRootNumber;
573 GlobalSystemTable->BootServices->HandleProtocol(handles[UefiDriveNumber], &bioGuid, (void**)&bio);
574 Geometry->Cylinders = 1; // Not relevant for the UEFI BIO protocol
575 Geometry->Heads = 1; // Not relevant for the UEFI BIO protocol
576 Geometry->SectorsPerTrack = (bio->Media->LastBlock + 1);
577 Geometry->BytesPerSector = bio->Media->BlockSize;
578 Geometry->Sectors = (bio->Media->LastBlock + 1);
579
580 return TRUE;
581}
582
583ULONG
585{
586 ULONG UefiDriveNumber = InternalUefiDisk[DriveNumber - FIRST_BIOS_DISK].UefiRootNumber;
587 TRACE("UefiDiskGetCacheableBlockCount: DriveNumber: %d\n", UefiDriveNumber);
588
589 GlobalSystemTable->BootServices->HandleProtocol(handles[UefiDriveNumber], &bioGuid, (void**)&bio);
590 return (bio->Media->LastBlock + 1);
591}
#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:71
struct _MASTER_BOOT_RECORD * PMASTER_BOOT_RECORD
PVOID FsGetDeviceSpecific(ULONG FileId)
Definition: fs.c:709
VOID FsSetDeviceSpecific(ULONG FileId, PVOID Specific)
Definition: fs.c:702
VOID FsRegisterDevice(_In_ PCSTR DeviceName, _In_ const DEVVTBL *FuncTable)
Definition: fs.c:673
#define MachDiskGetDriveGeometry(Drive, Geom)
Definition: machine.h:122
#define MachDiskReadLogicalSectors(Drive, Start, Count, Buf)
Definition: machine.h:120
VOID FrLdrTempFree(PVOID Allocation, ULONG Tag)
Definition: heap.c:553
PVOID MmAllocateMemoryWithType(SIZE_T MemorySize, TYPE_OF_MEMORY MemoryType)
Definition: mm.c:31
PVOID FrLdrTempAlloc(_In_ SIZE_T Size, _In_ ULONG Tag)
Definition: heap.c:545
#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
return ret
Definition: mutex.c:146
#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
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 GLint GLint j
Definition: glfuncs.h:250
#define ASSERT(a)
Definition: mode.c:44
#define sprintf
Definition: sprintf.c:45
#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:298
ULONG ARC_STATUS
Definition: arc.h:4
@ DiskPeripheral
Definition: arc.h:138
@ 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:63
ULONG Signature
Definition: disk.h:60
Definition: disk.h:40
Definition: fs.h:25
ULONGLONG SectorOffset
Definition: hwdisk.c:39
UCHAR DriveNumber
Definition: hwdisk.c:36
ULONGLONG SectorCount
Definition: hwdisk.c:40
ULONGLONG SectorNumber
Definition: hwdisk.c:41
ULONG SectorSize
Definition: hwdisk.c:38
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:568
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:550
struct tagDISKCONTEXT DISKCONTEXT
static CHAR PcDiskIdentifier[32][20]
Definition: uefidisk.c:53
BOOLEAN UefiInitializeBootDevices(VOID)
Definition: uefidisk.c:494
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:289
static VOID UefiSetupBlockDevices(VOID)
Definition: uefidisk.c:389
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:142
static ARC_STATUS UefiDiskSeek(ULONG FileId, LARGE_INTEGER *Position, SEEKMODE SeekMode)
Definition: uefidisk.c:258
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:300
PCHAR GetHarddiskIdentifier(UCHAR DriveNumber)
Definition: uefidisk.c:67
static ARC_STATUS UefiDiskRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
Definition: uefidisk.c:208
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:543
SIZE_T DiskReadBufferSize
Definition: uefidisk.c:49
ULONG UefiDiskGetCacheableBlockCount(UCHAR DriveNumber)
Definition: uefidisk.c:584
UCHAR FrldrBootDrive
Definition: uefidisk.c:47
static BOOLEAN UefiSetBootpath(VOID)
Definition: uefidisk.c:461
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
_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