ReactOS  0.4.13-dev-249-gcba1a2f
disk.c File Reference
#include <freeldr.h>
#include <debug.h>
Include dependency graph for disk.c:

Go to the source code of this file.

Functions

 DBG_DEFAULT_CHANNEL (DISK)
 
VOID DiskReportError (BOOLEAN bError)
 
VOID DiskError (PCSTR ErrorString, ULONG ErrorCode)
 
PCSTR DiskGetErrorCodeString (ULONG ErrorCode)
 
BOOLEAN DiskIsDriveRemovable (UCHAR DriveNumber)
 
BOOLEAN DiskGetBootPath (OUT PCHAR BootPath, IN ULONG Size)
 

Variables

CHAR FrldrBootPath [MAX_PATH] = ""
 
static BOOLEAN bReportError = TRUE
 

Function Documentation

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( DISK  )

◆ DiskError()

VOID DiskError ( PCSTR  ErrorString,
ULONG  ErrorCode 
)

Definition at line 38 of file disk.c.

39 {
40  CHAR ErrorCodeString[200];
41 
42  if (bReportError == FALSE)
43  return;
44 
45  sprintf(ErrorCodeString, "%s\n\nError Code: 0x%lx\nError: %s",
47 
48  TRACE("%s\n", ErrorCodeString);
49 
50  UiMessageBox(ErrorCodeString);
51 }
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
char CHAR
Definition: xmlstorage.h:175
PCSTR DiskGetErrorCodeString(ULONG ErrorCode)
Definition: disk.c:53
#define sprintf(buf, format,...)
Definition: sprintf.c:55
VOID UiMessageBox(PCSTR Format,...)
Definition: ui.c:347
#define TRACE(s)
Definition: solgame.cpp:4
static BOOLEAN bReportError
Definition: disk.c:29

Referenced by PcDiskReadLogicalSectorsCHS().

◆ DiskGetBootPath()

BOOLEAN DiskGetBootPath ( OUT PCHAR  BootPath,
IN ULONG  Size 
)

Definition at line 102 of file disk.c.

103 {
104  if (*FrldrBootPath)
105  goto Done;
106 
107  /* 0x49 is our magic ramdisk drive, so try to detect it first */
108  if (FrldrBootDrive == 0x49)
109  {
110  /* This is the ramdisk. See ArmDiskGetBootPath too... */
111  // sprintf(FrldrBootPath, "ramdisk(%u)", 0);
112  strcpy(FrldrBootPath, "ramdisk(0)");
113  }
114  else if (FrldrBootDrive < 0x80)
115  {
116  /* This is a floppy */
117  sprintf(FrldrBootPath, "multi(0)disk(0)fdisk(%u)", FrldrBootDrive);
118  }
119  else if (FrldrBootPartition == 0xFF)
120  {
121  /* Boot Partition 0xFF is the magic value that indicates booting from CD-ROM (see isoboot.S) */
122  sprintf(FrldrBootPath, "multi(0)disk(0)cdrom(%u)", FrldrBootDrive - 0x80);
123  }
124  else
125  {
126  ULONG BootPartition;
127  PARTITION_TABLE_ENTRY PartitionEntry;
128 
129  /* This is a hard disk */
130  if (!DiskGetActivePartitionEntry(FrldrBootDrive, &PartitionEntry, &BootPartition))
131  {
132  ERR("Invalid active partition information\n");
133  return FALSE;
134  }
135 
136  FrldrBootPartition = BootPartition;
137 
138  sprintf(FrldrBootPath, "multi(0)disk(0)rdisk(%u)partition(%lu)",
140  }
141 
142 Done:
143  /* Copy back the buffer */
144  if (Size < strlen(FrldrBootPath) + 1)
145  return FALSE;
147  return TRUE;
148 }
#define TRUE
Definition: types.h:120
BOOLEAN DiskGetActivePartitionEntry(UCHAR DriveNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry, ULONG *ActivePartition)
Definition: partition.c:35
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
#define sprintf(buf, format,...)
Definition: sprintf.c:55
CHAR FrldrBootPath[MAX_PATH]
Definition: disk.c:27
Definition: parttest.c:75
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
ULONG FrldrBootPartition
#define ERR(fmt,...)
Definition: debug.h:109
UCHAR FrldrBootDrive
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
unsigned int ULONG
Definition: retypes.h:1
char BootPath[0x100]
Definition: mach.c:35

Referenced by PcDiskGetBootPath(), and XboxMachInit().

◆ DiskGetErrorCodeString()

PCSTR DiskGetErrorCodeString ( ULONG  ErrorCode)

Definition at line 53 of file disk.c.

54 {
55  switch (ErrorCode)
56  {
57  case 0x00: return "no error";
58  case 0x01: return "bad command passed to driver";
59  case 0x02: return "address mark not found or bad sector";
60  case 0x03: return "diskette write protect error";
61  case 0x04: return "sector not found";
62  case 0x05: return "fixed disk reset failed";
63  case 0x06: return "diskette changed or removed";
64  case 0x07: return "bad fixed disk parameter table";
65  case 0x08: return "DMA overrun";
66  case 0x09: return "DMA access across 64k boundary";
67  case 0x0A: return "bad fixed disk sector flag";
68  case 0x0B: return "bad fixed disk cylinder";
69  case 0x0C: return "unsupported track/invalid media";
70  case 0x0D: return "invalid number of sectors on fixed disk format";
71  case 0x0E: return "fixed disk controlled data address mark detected";
72  case 0x0F: return "fixed disk DMA arbitration level out of range";
73  case 0x10: return "ECC/CRC error on disk read";
74  case 0x11: return "recoverable fixed disk data error, data fixed by ECC";
75  case 0x20: return "controller error (NEC for floppies)";
76  case 0x40: return "seek failure";
77  case 0x80: return "time out, drive not ready";
78  case 0xAA: return "fixed disk drive not ready";
79  case 0xBB: return "fixed disk undefined error";
80  case 0xCC: return "fixed disk write fault on selected drive";
81  case 0xE0: return "fixed disk status error/Error reg = 0";
82  case 0xFF: return "sense operation failed";
83 
84  default: return "unknown error code";
85  }
86 }
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436

Referenced by DiskError().

◆ DiskIsDriveRemovable()

BOOLEAN DiskIsDriveRemovable ( UCHAR  DriveNumber)

Definition at line 88 of file disk.c.

89 {
90  /*
91  * Hard disks use drive numbers >= 0x80 . So if the drive number
92  * indicates a hard disk then return FALSE.
93  * 0x49 is our magic ramdisk drive, so return FALSE for that too.
94  */
95  if ((DriveNumber >= 0x80) || (DriveNumber == 0x49))
96  return FALSE;
97 
98  /* The drive is a floppy diskette so return TRUE */
99  return TRUE;
100 }
#define TRUE
Definition: types.h:120

Referenced by PcInitializeBootDevices().

◆ DiskReportError()

VOID DiskReportError ( BOOLEAN  bError)

Definition at line 33 of file disk.c.

34 {
35  bReportError = bError;
36 }
static BOOLEAN bReportError
Definition: disk.c:29

Referenced by EnumerateHarddisks(), and GetHarddiskInformation().

Variable Documentation

◆ bReportError

BOOLEAN bReportError = TRUE
static

Definition at line 29 of file disk.c.

Referenced by DiskError(), and DiskReportError().

◆ FrldrBootPath

CHAR FrldrBootPath[MAX_PATH] = ""

Definition at line 27 of file disk.c.

Referenced by DiskGetBootPath(), and PcDiskGetBootPath().