ReactOS 0.4.15-dev-8127-g6338913
hwdisk.c File Reference
#include <freeldr.h>
#include <debug.h>
Include dependency graph for hwdisk.c:

Go to the source code of this file.

Classes

struct  tagDISKCONTEXT
 

Macros

#define FIRST_BIOS_DISK   0x80
 
#define FIRST_PARTITION   1
 

Typedefs

typedef struct tagDISKCONTEXT DISKCONTEXT
 

Functions

 DBG_DEFAULT_CHANNEL (HWDETECT)
 
static ARC_STATUS DiskClose (ULONG FileId)
 
static ARC_STATUS DiskGetFileInformation (ULONG FileId, FILEINFORMATION *Information)
 
static ARC_STATUS DiskOpen (CHAR *Path, OPENMODE OpenMode, ULONG *FileId)
 
static ARC_STATUS DiskRead (ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
 
static ARC_STATUS DiskSeek (ULONG FileId, LARGE_INTEGER *Position, SEEKMODE SeekMode)
 
PCHAR GetHarddiskIdentifier (UCHAR DriveNumber)
 
static VOID GetHarddiskInformation (UCHAR DriveNumber)
 
static UCHAR EnumerateHarddisks (OUT PBOOLEAN BootDriveReported)
 
static BOOLEAN DiskIsDriveRemovable (UCHAR DriveNumber)
 
static BOOLEAN DiskGetBootPath (BOOLEAN IsPxe)
 
BOOLEAN PcInitializeBootDevices (VOID)
 

Variables

static const CHAR Hex [] = "0123456789abcdef"
 
UCHAR PcBiosDiskCount = 0
 
static CHAR PcDiskIdentifier [32][20]
 
PVOID DiskReadBuffer
 
SIZE_T DiskReadBufferSize
 
static const DEVVTBL DiskVtbl
 

Macro Definition Documentation

◆ FIRST_BIOS_DISK

#define FIRST_BIOS_DISK   0x80

Definition at line 31 of file hwdisk.c.

◆ FIRST_PARTITION

#define FIRST_PARTITION   1

Definition at line 32 of file hwdisk.c.

Typedef Documentation

◆ DISKCONTEXT

Function Documentation

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( HWDETECT  )

◆ DiskClose()

static ARC_STATUS DiskClose ( ULONG  FileId)
static

Definition at line 56 of file hwdisk.c.

57{
60 return ESUCCESS;
61}
VOID * FsGetDeviceSpecific(ULONG FileId)
Definition: fs.c:418
FORCEINLINE VOID FrLdrTempFree(PVOID Allocation, ULONG Tag)
Definition: mm.h:197
@ ESUCCESS
Definition: arc.h:32
#define TAG_HW_DISK_CONTEXT
Definition: uefidisk.c:16

◆ DiskGetBootPath()

static BOOLEAN DiskGetBootPath ( BOOLEAN  IsPxe)
static

Definition at line 420 of file hwdisk.c.

421{
422 if (*FrLdrBootPath)
423 return TRUE;
424
425 // FIXME! FIXME! Do this in some drive recognition procedure!!!!
426 if (IsPxe)
427 {
428 RtlStringCbCopyA(FrLdrBootPath, sizeof(FrLdrBootPath), "net(0)");
429 }
430 else
431 /* 0x49 is our magic ramdisk drive, so try to detect it first */
432 if (FrldrBootDrive == 0x49)
433 {
434 /* This is the ramdisk. See ArmInitializeBootDevices() too... */
435 // RtlStringCbPrintfA(FrLdrBootPath, sizeof(FrLdrBootPath), "ramdisk(%u)", 0);
436 RtlStringCbCopyA(FrLdrBootPath, sizeof(FrLdrBootPath), "ramdisk(0)");
437 }
439 {
440 /* This is a floppy */
442 "multi(0)disk(0)fdisk(%u)", FrldrBootDrive);
443 }
444 else if (FrldrBootPartition == 0xFF)
445 {
446 /* Boot Partition 0xFF is the magic value that indicates booting from CD-ROM (see isoboot.S) */
448 "multi(0)disk(0)cdrom(%u)", FrldrBootDrive - FIRST_BIOS_DISK);
449 }
450 else
451 {
452 ULONG BootPartition;
453 PARTITION_TABLE_ENTRY PartitionEntry;
454
455 /* This is a hard disk */
456 if (!DiskGetBootPartitionEntry(FrldrBootDrive, &PartitionEntry, &BootPartition))
457 {
458 ERR("Failed to get boot partition entry\n");
459 return FALSE;
460 }
461
462 FrldrBootPartition = BootPartition;
463
465 "multi(0)disk(0)rdisk(%u)partition(%lu)",
467 }
468
469 return TRUE;
470}
BOOLEAN DiskGetBootPartitionEntry(IN UCHAR DriveNumber, OUT PPARTITION_TABLE_ENTRY PartitionTableEntry, OUT PULONG BootPartition)
Definition: partition.c:367
#define ERR(fmt,...)
Definition: debug.h:113
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
CCHAR FrLdrBootPath[MAX_PATH]
Definition: freeldr.c:39
#define FIRST_BIOS_DISK
Definition: hwdisk.c:31
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
NTSTRSAFEAPI RtlStringCbCopyA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCSTR pszSrc)
Definition: ntstrsafe.h:156
Definition: parttest.c:75
uint32_t ULONG
Definition: typedefs.h:59
UCHAR FrldrBootDrive
Definition: uefidisk.c:47
ULONG FrldrBootPartition
Definition: uefidisk.c:48

Referenced by PcInitializeBootDevices().

◆ DiskGetFileInformation()

static ARC_STATUS DiskGetFileInformation ( ULONG  FileId,
FILEINFORMATION Information 
)
static

Definition at line 64 of file hwdisk.c.

65{
67
69
70 /*
71 * The ARC specification mentions that for partitions, StartingAddress and
72 * EndingAddress are the start and end positions of the partition in terms
73 * of byte offsets from the start of the disk.
74 * CurrentAddress is the current offset into (i.e. relative to) the partition.
75 */
76 Information->StartingAddress.QuadPart = Context->SectorOffset * Context->SectorSize;
77 Information->EndingAddress.QuadPart = (Context->SectorOffset + Context->SectorCount) * Context->SectorSize;
78 Information->CurrentAddress.QuadPart = Context->SectorNumber * Context->SectorSize;
79
80 return ESUCCESS;
81}
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1049

◆ DiskIsDriveRemovable()

static BOOLEAN DiskIsDriveRemovable ( UCHAR  DriveNumber)
static

Definition at line 405 of file hwdisk.c.

406{
407 /*
408 * Hard disks use drive numbers >= 0x80 . So if the drive number
409 * indicates a hard disk then return FALSE.
410 * 0x49 is our magic ramdisk drive, so return FALSE for that too.
411 */
412 if ((DriveNumber >= 0x80) || (DriveNumber == 0x49))
413 return FALSE;
414
415 /* The drive is a floppy diskette so return TRUE */
416 return TRUE;
417}

Referenced by PcInitializeBootDevices().

◆ DiskOpen()

static ARC_STATUS DiskOpen ( CHAR Path,
OPENMODE  OpenMode,
ULONG FileId 
)
static

Definition at line 84 of file hwdisk.c.

85{
87 UCHAR DriveNumber;
88 ULONG DrivePartition, SectorSize;
91 PARTITION_TABLE_ENTRY PartitionTableEntry;
92
93 if (DiskReadBufferSize == 0)
94 {
95 ERR("DiskOpen(): DiskReadBufferSize is 0, something is wrong.\n");
97 return ENOMEM;
98 }
99
100 if (!DissectArcPath(Path, NULL, &DriveNumber, &DrivePartition))
101 return EINVAL;
102
103 if (DrivePartition == 0xff)
104 {
105 /* This is a CD-ROM device */
106 SectorSize = 2048;
107 }
108 else
109 {
110 /*
111 * This is either a floppy disk device (DrivePartition == 0) or
112 * a hard disk device (DrivePartition != 0 && DrivePartition != 0xFF)
113 * but it doesn't matter which one because they both have 512 bytes
114 * per sector.
115 */
116 SectorSize = 512;
117 }
118
119 if (DrivePartition != 0xff && DrivePartition != 0)
120 {
121 if (!DiskGetPartitionEntry(DriveNumber, DrivePartition, &PartitionTableEntry))
122 return EINVAL;
123
124 SectorOffset = PartitionTableEntry.SectorCountBeforePartition;
125 SectorCount = PartitionTableEntry.PartitionSectorCount;
126 }
127 else
128 {
129 GEOMETRY Geometry;
130 if (!MachDiskGetDriveGeometry(DriveNumber, &Geometry))
131 return EINVAL;
132
133 if (SectorSize != Geometry.BytesPerSector)
134 {
135 ERR("SectorSize (%lu) != Geometry.BytesPerSector (%lu), expect problems!\n",
136 SectorSize, Geometry.BytesPerSector);
137 }
138
139 SectorOffset = 0;
140 SectorCount = (ULONGLONG)Geometry.Cylinders * Geometry.Heads * Geometry.Sectors;
141 }
142
144 if (!Context)
145 return ENOMEM;
146
147 Context->DriveNumber = DriveNumber;
148 Context->SectorSize = SectorSize;
149 Context->SectorOffset = SectorOffset;
150 Context->SectorCount = SectorCount;
151 Context->SectorNumber = 0;
153
154 return ESUCCESS;
155}
PRTL_UNICODE_STRING_BUFFER Path
#define EINVAL
Definition: acclib.h:90
#define ENOMEM
Definition: acclib.h:84
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 FsSetDeviceSpecific(ULONG FileId, VOID *Specific)
Definition: fs.c:411
#define MachDiskGetDriveGeometry(Drive, Geom)
Definition: machine.h:128
FORCEINLINE PVOID FrLdrTempAlloc(_In_ SIZE_T Size, _In_ ULONG Tag)
Definition: mm.h:188
#define SectorOffset(L)
Definition: cdprocs.h:1622
#define NULL
Definition: types.h:112
SIZE_T DiskReadBufferSize
Definition: hwdisk.c:50
#define ASSERT(a)
Definition: mode.c:44
ULONG SectorCount
Definition: part_xbox.c:31
ULONG PartitionSectorCount
Definition: parttest.c:85
ULONG SectorCountBeforePartition
Definition: parttest.c:84
Definition: disk.h:25
ULONG BytesPerSector
Definition: disk.h:29
ULONG Sectors
Definition: disk.h:28
ULONG Cylinders
Definition: disk.h:26
ULONG Heads
Definition: disk.h:27
uint64_t ULONGLONG
Definition: typedefs.h:67
_In_ ULONG SectorSize
Definition: halfuncs.h:291
unsigned char UCHAR
Definition: xmlstorage.h:181

◆ DiskRead()

static ARC_STATUS DiskRead ( ULONG  FileId,
VOID Buffer,
ULONG  N,
ULONG Count 
)
static

Definition at line 158 of file hwdisk.c.

159{
161 UCHAR* Ptr = (UCHAR*)Buffer;
162 ULONG Length, TotalSectors, MaxSectors, ReadSectors;
164 BOOLEAN ret;
165
167
168 TotalSectors = (N + Context->SectorSize - 1) / Context->SectorSize;
169 MaxSectors = DiskReadBufferSize / Context->SectorSize;
170 SectorOffset = Context->SectorOffset + Context->SectorNumber;
171
172 // If MaxSectors is 0, this will lead to infinite loop.
173 // In release builds assertions are disabled, however we also have sanity checks in DiskOpen()
174 ASSERT(MaxSectors > 0);
175
176 ret = TRUE;
177
178 while (TotalSectors)
179 {
180 ReadSectors = TotalSectors;
181 if (ReadSectors > MaxSectors)
182 ReadSectors = MaxSectors;
183
186 ReadSectors,
188 if (!ret)
189 break;
190
191 Length = ReadSectors * Context->SectorSize;
192 if (Length > N)
193 Length = N;
194
196
197 Ptr += Length;
198 N -= Length;
199 SectorOffset += ReadSectors;
200 TotalSectors -= ReadSectors;
201 }
202
204 Context->SectorNumber = SectorOffset - Context->SectorOffset;
205
206 return (!ret) ? EIO : ESUCCESS;
207}
#define N
Definition: crc32.c:57
unsigned char BOOLEAN
#define EIO
Definition: acclib.h:81
#define MachDiskReadLogicalSectors(Drive, Start, Count, Buf)
Definition: machine.h:126
Definition: bufpool.h:45
#define ULONG_PTR
Definition: config.h:101
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
PVOID DiskReadBuffer
Definition: hwdisk.c:49
int Count
Definition: noreturn.cpp:7
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG_PTR
Definition: typedefs.h:65
int ret

◆ DiskSeek()

static ARC_STATUS DiskSeek ( ULONG  FileId,
LARGE_INTEGER Position,
SEEKMODE  SeekMode 
)
static

Definition at line 210 of file hwdisk.c.

211{
213 LARGE_INTEGER NewPosition = *Position;
214
215 switch (SeekMode)
216 {
217 case SeekAbsolute:
218 break;
219 case SeekRelative:
220 NewPosition.QuadPart += (Context->SectorNumber * Context->SectorSize);
221 break;
222 default:
223 ASSERT(FALSE);
224 return EINVAL;
225 }
226
227 if (NewPosition.QuadPart & (Context->SectorSize - 1))
228 return EINVAL;
229
230 /* Convert in number of sectors */
231 NewPosition.QuadPart /= Context->SectorSize;
232
233 /* HACK: CDROMs may have a SectorCount of 0 */
234 if (Context->SectorCount != 0 && NewPosition.QuadPart >= Context->SectorCount)
235 return EINVAL;
236
237 Context->SectorNumber = NewPosition.QuadPart;
238 return ESUCCESS;
239}
@ SeekRelative
Definition: arc.h:60
@ SeekAbsolute
Definition: arc.h:59
static COORD Position
Definition: mouse.c:34
LONGLONG QuadPart
Definition: typedefs.h:114

◆ EnumerateHarddisks()

static UCHAR EnumerateHarddisks ( OUT PBOOLEAN  BootDriveReported)
static

Definition at line 345 of file hwdisk.c.

346{
347 UCHAR DiskCount, DriveNumber;
348 ULONG i;
349 BOOLEAN Changed;
350
351 *BootDriveReported = FALSE;
352
353 /* Count the number of visible harddisk drives */
355 DiskCount = 0;
356 DriveNumber = FIRST_BIOS_DISK;
357
359
360 /*
361 * There are some really broken BIOSes out there. There are even BIOSes
362 * that happily report success when you ask them to read from non-existent
363 * harddisks. So, we set the buffer to known contents first, then try to
364 * read. If the BIOS reports success but the buffer contents haven't
365 * changed then we fail anyway.
366 */
368 while (MachDiskReadLogicalSectors(DriveNumber, 0ULL, 1, DiskReadBuffer))
369 {
370 Changed = FALSE;
371 for (i = 0; !Changed && i < DiskReadBufferSize; i++)
372 {
373 Changed = ((PUCHAR)DiskReadBuffer)[i] != 0xcd;
374 }
375 if (!Changed)
376 {
377 TRACE("BIOS reports success for disk %d (0x%02X) but data didn't change\n",
378 (int)DiskCount, DriveNumber);
379 break;
380 }
381
382 /* Cache the BIOS hard disk information for later use */
383 GetHarddiskInformation(DriveNumber);
384
385 /* Check if we have seen the boot drive */
386 if (FrldrBootDrive == DriveNumber)
387 *BootDriveReported = TRUE;
388
389 DiskCount++;
390 DriveNumber++;
392 }
394
395 PcBiosDiskCount = DiskCount;
396 TRACE("BIOS reports %d harddisk%s\n",
397 (int)DiskCount, (DiskCount == 1) ? "" : "s");
398
399 return DiskCount;
400}
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
static VOID GetHarddiskInformation(UCHAR DriveNumber)
Definition: hwdisk.c:258
UCHAR PcBiosDiskCount
Definition: hwdisk.c:46
#define ULL(a, b)
Definition: format_msg.c:27
LONG DiskReportError(BOOLEAN bShowError)
Definition: pcdisk.c:120
#define memset(x, y, z)
Definition: compat.h:39
#define TRACE(s)
Definition: solgame.cpp:4
unsigned char * PUCHAR
Definition: typedefs.h:53

Referenced by PcInitializeBootDevices().

◆ GetHarddiskIdentifier()

PCHAR GetHarddiskIdentifier ( UCHAR  DriveNumber)

Definition at line 252 of file hwdisk.c.

253{
254 return PcDiskIdentifier[DriveNumber - FIRST_BIOS_DISK];
255}
static CHAR PcDiskIdentifier[32][20]
Definition: hwdisk.c:47

◆ GetHarddiskInformation()

static VOID GetHarddiskInformation ( UCHAR  DriveNumber)
static

Definition at line 258 of file hwdisk.c.

259{
262 ULONG i;
263 ULONG Checksum;
265 BOOLEAN ValidPartitionTable;
266 CHAR ArcName[MAX_PATH];
267 PARTITION_TABLE_ENTRY PartitionTableEntry;
269
270 /* Detect disk partition type */
271 DiskDetectPartitionType(DriveNumber);
272
273 /* Read the MBR */
274 if (!MachDiskReadLogicalSectors(DriveNumber, 0ULL, 1, DiskReadBuffer))
275 {
276 ERR("Reading MBR failed\n");
277 /* We failed, use a default identifier */
278 sprintf(Identifier, "BIOSDISK%d", DriveNumber - FIRST_BIOS_DISK + 1);
279 return;
280 }
281
284
285 Signature = Mbr->Signature;
286 TRACE("Signature: %x\n", Signature);
287
288 /* Calculate the MBR checksum */
289 Checksum = 0;
290 for (i = 0; i < 512 / sizeof(ULONG); i++)
291 {
292 Checksum += Buffer[i];
293 }
294 Checksum = ~Checksum + 1;
295 TRACE("Checksum: %x\n", Checksum);
296
297 ValidPartitionTable = (Mbr->MasterBootRecordMagic == 0xAA55);
298
299 /* Fill out the ARC disk block */
300 sprintf(ArcName, "multi(0)disk(0)rdisk(%u)", DriveNumber - FIRST_BIOS_DISK);
301 AddReactOSArcDiskInfo(ArcName, Signature, Checksum, ValidPartitionTable);
302
303 sprintf(ArcName, "multi(0)disk(0)rdisk(%u)partition(0)", DriveNumber - FIRST_BIOS_DISK);
304 FsRegisterDevice(ArcName, &DiskVtbl);
305
306 /* Add partitions */
309 while (DiskGetPartitionEntry(DriveNumber, i, &PartitionTableEntry))
310 {
311 if (PartitionTableEntry.SystemIndicator != PARTITION_ENTRY_UNUSED)
312 {
313 sprintf(ArcName, "multi(0)disk(0)rdisk(%u)partition(%lu)", DriveNumber - FIRST_BIOS_DISK, i);
314 FsRegisterDevice(ArcName, &DiskVtbl);
315 }
316 i++;
317 }
319
320 /* Convert checksum and signature to identifier string */
321 Identifier[0] = Hex[(Checksum >> 28) & 0x0F];
322 Identifier[1] = Hex[(Checksum >> 24) & 0x0F];
323 Identifier[2] = Hex[(Checksum >> 20) & 0x0F];
324 Identifier[3] = Hex[(Checksum >> 16) & 0x0F];
325 Identifier[4] = Hex[(Checksum >> 12) & 0x0F];
326 Identifier[5] = Hex[(Checksum >> 8) & 0x0F];
327 Identifier[6] = Hex[(Checksum >> 4) & 0x0F];
328 Identifier[7] = Hex[Checksum & 0x0F];
329 Identifier[8] = '-';
330 Identifier[9] = Hex[(Signature >> 28) & 0x0F];
331 Identifier[10] = Hex[(Signature >> 24) & 0x0F];
332 Identifier[11] = Hex[(Signature >> 20) & 0x0F];
333 Identifier[12] = Hex[(Signature >> 16) & 0x0F];
334 Identifier[13] = Hex[(Signature >> 12) & 0x0F];
335 Identifier[14] = Hex[(Signature >> 8) & 0x0F];
336 Identifier[15] = Hex[(Signature >> 4) & 0x0F];
337 Identifier[16] = Hex[Signature & 0x0F];
338 Identifier[17] = '-';
339 Identifier[18] = (ValidPartitionTable ? 'A' : 'X');
340 Identifier[19] = 0;
341 TRACE("Identifier: %s\n", Identifier);
342}
VOID AddReactOSArcDiskInfo(IN PSTR ArcName, IN ULONG Signature, IN ULONG Checksum, IN BOOLEAN ValidPartitionTable)
Definition: archwsup.c:77
@ Identifier
Definition: asmpp.cpp:95
VOID DiskDetectPartitionType(IN UCHAR DriveNumber)
Definition: partition.c:314
#define PARTITION_ENTRY_UNUSED
Definition: disk.h:86
struct _MASTER_BOOT_RECORD * PMASTER_BOOT_RECORD
VOID FsRegisterDevice(CHAR *Prefix, const DEVVTBL *FuncTable)
Definition: fs.c:385
#define MAX_PATH
Definition: compat.h:34
static const WCHAR Signature[]
Definition: parser.c:141
static const DEVVTBL DiskVtbl
Definition: hwdisk.c:241
static const CHAR Hex[]
Definition: hwdisk.c:43
#define FIRST_PARTITION
Definition: hwdisk.c:32
#define sprintf(buf, format,...)
Definition: sprintf.c:55
UCHAR SystemIndicator
Definition: parttest.c:80
USHORT MasterBootRecordMagic
Definition: disk.h:78
ULONG Signature
Definition: disk.h:75
uint32_t * PULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
char CHAR
Definition: xmlstorage.h:175

Referenced by EnumerateHarddisks().

◆ PcInitializeBootDevices()

BOOLEAN PcInitializeBootDevices ( VOID  )

Definition at line 473 of file hwdisk.c.

474{
475 UCHAR DiskCount;
476 BOOLEAN BootDriveReported = FALSE;
477 ULONG i;
478
479 DiskCount = EnumerateHarddisks(&BootDriveReported);
480
481 /* Initialize FrLdrBootPath, the boot path we're booting from (the "SystemPartition") */
483
484 /* Add it, if it's a floppy or cdrom */
485 if ((FrldrBootDrive >= FIRST_BIOS_DISK && !BootDriveReported) ||
487 {
488 /* TODO: Check if it's really a CDROM drive */
489
492 ULONG Checksum = 0;
494
495 /* Read the MBR */
497 {
498 ERR("Reading MBR failed\n");
499 return FALSE;
500 }
501
504
505 Signature = Mbr->Signature;
506 TRACE("Signature: %x\n", Signature);
507
508 /* Calculate the MBR checksum */
509 for (i = 0; i < 2048 / sizeof(ULONG); i++)
510 {
511 Checksum += Buffer[i];
512 }
513 Checksum = ~Checksum + 1;
514 TRACE("Checksum: %x\n", Checksum);
515
516 /* Fill out the ARC disk block */
518
520 DiskCount++; // This is not accounted for in the number of pre-enumerated BIOS drives!
521 TRACE("Additional boot drive detected: 0x%02X\n", (int)FrldrBootDrive);
522 }
523
524 return (DiskCount != 0);
525}
BOOLEAN PxeInit(VOID)
Definition: pxe.c:346
static BOOLEAN DiskGetBootPath(BOOLEAN IsPxe)
Definition: hwdisk.c:420
static BOOLEAN DiskIsDriveRemovable(UCHAR DriveNumber)
Definition: hwdisk.c:405
static UCHAR EnumerateHarddisks(OUT PBOOLEAN BootDriveReported)
Definition: hwdisk.c:345

Referenced by MachInit(), and Pc98InitializeBootDevices().

Variable Documentation

◆ DiskReadBuffer

PVOID DiskReadBuffer

◆ DiskReadBufferSize

SIZE_T DiskReadBufferSize

Definition at line 50 of file hwdisk.c.

Referenced by DiskOpen(), DiskRead(), EnumerateHarddisks(), and PcMemFinalizeMemoryMap().

◆ DiskVtbl

const DEVVTBL DiskVtbl
static
Initial value:
=
{
}
static ARC_STATUS DiskGetFileInformation(ULONG FileId, FILEINFORMATION *Information)
Definition: hwdisk.c:64
static ARC_STATUS DiskRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
Definition: hwdisk.c:158
static ARC_STATUS DiskOpen(CHAR *Path, OPENMODE OpenMode, ULONG *FileId)
Definition: hwdisk.c:84
static ARC_STATUS DiskSeek(ULONG FileId, LARGE_INTEGER *Position, SEEKMODE SeekMode)
Definition: hwdisk.c:210
static ARC_STATUS DiskClose(ULONG FileId)
Definition: hwdisk.c:56

Definition at line 241 of file hwdisk.c.

Referenced by GetHarddiskInformation(), and PcInitializeBootDevices().

◆ Hex

const CHAR Hex[] = "0123456789abcdef"
static

Definition at line 43 of file hwdisk.c.

Referenced by GetHarddiskInformation().

◆ PcBiosDiskCount

UCHAR PcBiosDiskCount = 0

Definition at line 46 of file hwdisk.c.

Referenced by EnumerateHarddisks().

◆ PcDiskIdentifier

CHAR PcDiskIdentifier[32][20]
static

Definition at line 47 of file hwdisk.c.

Referenced by GetHarddiskIdentifier(), and GetHarddiskInformation().