ReactOS 0.4.16-dev-2613-g9533ad7
disk.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _GEOMETRY
 

Macros

#define PARTITION_ENTRY_UNUSED   0x00
 
#define PARTITION_FAT_12   0x01
 
#define PARTITION_FAT_16   0x04
 
#define PARTITION_EXTENDED   0x05
 
#define PARTITION_HUGE   0x06
 
#define PARTITION_IFS   0x07
 
#define PARTITION_FAT32   0x0B
 
#define PARTITION_FAT32_XINT13   0x0C
 
#define PARTITION_XINT13   0x0E
 
#define PARTITION_XINT13_EXTENDED   0x0F
 
#define PARTITION_PREP   0x41
 
#define PARTITION_LDM   0x42
 
#define PARTITION_GPT   0xEE
 

Typedefs

typedef struct _GEOMETRY GEOMETRY
 
typedef struct _GEOMETRYPGEOMETRY
 

Functions

LONG DiskReportError (_In_ BOOLEAN bShowError)
 
VOID DiskError (_In_ PCSTR ErrorString, _In_ ULONG ErrorCode)
 
PCSTR DiskGetErrorCodeString (_In_ ULONG ErrorCode)
 
ARC_STATUS DiskInitialize (_In_ UCHAR DriveNumber, _In_ PCSTR DeviceName, _In_ CONFIGURATION_TYPE DeviceType, _In_ const struct tagDEVVTBL *FuncTable, _Out_opt_ PULONG pChecksum, _Out_opt_ PULONG pSignature, _Out_opt_ PBOOLEAN pValidPartitionTable)
 
VOID DiskDetectPartitionType (_In_ UCHAR DriveNumber)
 
BOOLEAN DiskGetBootPartitionEntry (_In_ UCHAR DriveNumber, _Out_opt_ PPARTITION_INFORMATION PartitionEntry, _Out_ PULONG BootPartition)
 
BOOLEAN DiskGetPartitionEntry (_In_ UCHAR DriveNumber, _In_opt_ ULONG SectorSize, _In_ ULONG PartitionNumber, _Out_ PPARTITION_INFORMATION PartitionEntry)
 
ULONG LoadBootDeviceDriver (VOID)
 
PCCHAR FrLdrGetBootPath (VOID)
 
UCHAR FrldrGetBootDrive (VOID)
 
ULONG FrldrGetBootPartition (VOID)
 

Variables

PVOID DiskReadBuffer
 
SIZE_T DiskReadBufferSize
 
CCHAR FrLdrBootPath [MAX_PATH]
 

Macro Definition Documentation

◆ PARTITION_ENTRY_UNUSED

#define PARTITION_ENTRY_UNUSED   0x00

Definition at line 35 of file disk.h.

◆ PARTITION_EXTENDED

#define PARTITION_EXTENDED   0x05

Definition at line 38 of file disk.h.

◆ PARTITION_FAT32

#define PARTITION_FAT32   0x0B

Definition at line 41 of file disk.h.

◆ PARTITION_FAT32_XINT13

#define PARTITION_FAT32_XINT13   0x0C

Definition at line 42 of file disk.h.

◆ PARTITION_FAT_12

#define PARTITION_FAT_12   0x01

Definition at line 36 of file disk.h.

◆ PARTITION_FAT_16

#define PARTITION_FAT_16   0x04

Definition at line 37 of file disk.h.

◆ PARTITION_GPT

#define PARTITION_GPT   0xEE

Definition at line 47 of file disk.h.

◆ PARTITION_HUGE

#define PARTITION_HUGE   0x06

Definition at line 39 of file disk.h.

◆ PARTITION_IFS

#define PARTITION_IFS   0x07

Definition at line 40 of file disk.h.

◆ PARTITION_LDM

#define PARTITION_LDM   0x42

Definition at line 46 of file disk.h.

◆ PARTITION_PREP

#define PARTITION_PREP   0x41

Definition at line 45 of file disk.h.

◆ PARTITION_XINT13

#define PARTITION_XINT13   0x0E

Definition at line 43 of file disk.h.

◆ PARTITION_XINT13_EXTENDED

#define PARTITION_XINT13_EXTENDED   0x0F

Definition at line 44 of file disk.h.

Typedef Documentation

◆ GEOMETRY

◆ PGEOMETRY

Function Documentation

◆ DiskDetectPartitionType()

VOID DiskDetectPartitionType ( _In_ UCHAR  DriveNumber)

Definition at line 66 of file partition.c.

68{
69 MASTER_BOOT_RECORD MasterBootRecord;
70
71 /* Probe for Master Boot Record */
72 if (DiskReadBootRecord(DriveNumber, 0, &MasterBootRecord))
73 {
74#if 0
75 ULONG Index, PartitionCount = 0;
76 BOOLEAN GPTProtect = FALSE;
77#else
78 GPT_TABLE_HEADER GptHeader;
79#endif
80
82
83#if 0
84 /* Check for GUID Partition Table */
85 for (Index = 0; Index < 4; Index++)
86 {
87 PPARTITION_TABLE_ENTRY PartitionTableEntry = &MasterBootRecord.PartitionTable[Index];
88
89 if (PartitionTableEntry->SystemIndicator != PARTITION_ENTRY_UNUSED)
90 {
91 PartitionCount++;
92 if (Index == 0 && PartitionTableEntry->SystemIndicator == PARTITION_GPT)
93 GPTProtect = TRUE;
94 }
95 }
96
97 if (PartitionCount == 1 && GPTProtect)
98#else
99 if (DiskReadGptHeader(DriveNumber, &GptHeader))
100#endif
101 {
103 }
104 TRACE("Drive 0x%X partition type %s\n", DriveNumber, DiskPartitionType[DriveNumber] == PARTITION_STYLE_MBR ? "MBR" : "GPT");
105 return;
106 }
107
108 /* Probe for Xbox-BRFR partitioning */
109 if (DiskIsBrfr(DriveNumber))
110 {
111 DiskPartitionType[DriveNumber] = PARTITION_STYLE_BRFR;
112 TRACE("Drive 0x%X partition type Xbox-BRFR\n", DriveNumber);
113 return;
114 }
115
116 /* Failed to detect partitions, assume non-partitioned disk */
117 DiskPartitionType[DriveNumber] = PARTITION_STYLE_RAW;
118 TRACE("Drive 0x%X partition type unknown\n", DriveNumber);
119}
unsigned char BOOLEAN
Definition: actypes.h:127
BOOLEAN DiskReadBootRecord(IN UCHAR DriveNumber, IN ULONGLONG LogicalSectorNumber, OUT PMASTER_BOOT_RECORD BootRecord)
Definition: partition.c:23
static PARTITION_STYLE DiskPartitionType[MaxDriveNumber+1]
Definition: partition.c:18
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
@ PARTITION_STYLE_GPT
Definition: imports.h:202
@ PARTITION_STYLE_MBR
Definition: imports.h:201
static BOOLEAN DiskIsBrfr(_In_ UCHAR DriveNumber)
Definition: part_brfr.c:35
#define PARTITION_GPT
Definition: part_gpt.h:27
#define PARTITION_ENTRY_UNUSED
Definition: part_mbr.h:50
#define TRACE(s)
Definition: solgame.cpp:4
PARTITION_TABLE_ENTRY PartitionTable[4]
Definition: parttest.c:92
Definition: part_mbr.h:16
UCHAR SystemIndicator
Definition: part_mbr.h:22
uint32_t ULONG
Definition: typedefs.h:59
BOOLEAN DiskReadGptHeader(_In_ UCHAR DriveNumber, _Out_ PGPT_TABLE_HEADER GptHeader)
Definition: part_gpt.c:22
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by DiskInitialize().

◆ DiskError()

VOID DiskError ( _In_ PCSTR  ErrorString,
_In_ ULONG  ErrorCode 
)

Definition at line 48 of file disk.c.

51{
52 PCSTR ErrorDescription;
53 CHAR ErrorCodeString[200];
54
55 if (lReportError < 0)
56 return;
57
58 ErrorDescription = DiskGetErrorCodeString(ErrorCode);
59 if (ErrorDescription)
60 {
61 RtlStringCbPrintfA(ErrorCodeString, sizeof(ErrorCodeString),
62 "%s\n\nError Code: 0x%lx\nError: %s",
63 ErrorString, ErrorCode, ErrorDescription);
64 }
65 else
66 {
67 RtlStringCbCopyA(ErrorCodeString, sizeof(ErrorCodeString), ErrorString);
68 }
69
70 ERR("%s\n", ErrorCodeString);
71 UiMessageBox(ErrorCodeString);
72}
#define ERR(fmt,...)
Definition: precomp.h:57
static LONG lReportError
Definition: disk.c:35
VOID UiMessageBox(_In_ PCSTR Format,...)
Definition: ui.c:359
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
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
PCSTR DiskGetErrorCodeString(_In_ ULONG ErrorCode)
Definition: pcdisk.c:136
char CHAR
Definition: pedump.c:57
const char * PCSTR
Definition: typedefs.h:52

Referenced by Pc98DiskReadLogicalSectorsCHS(), Pc98DiskReadLogicalSectorsLBA(), PcDiskReadLogicalSectorsCHS(), PcDiskReadLogicalSectorsLBA(), and XboxDiskReadLogicalSectors().

◆ DiskGetBootPartitionEntry()

BOOLEAN DiskGetBootPartitionEntry ( _In_ UCHAR  DriveNumber,
_Out_opt_ PPARTITION_INFORMATION  PartitionEntry,
_Out_ PULONG  BootPartition 
)

Definition at line 123 of file partition.c.

127{
128#if 0
129 GEOMETRY Geometry;
130 if (!MachDiskGetDriveGeometry(DriveNumber, &Geometry))
131 return FALSE;
132#endif
133
134 switch (DiskPartitionType[DriveNumber])
135 {
137 {
138 return DiskGetActivePartitionEntry(DriveNumber,
139 /* MBR partition table always uses 512-byte sectors per specification */
140 512, // Geometry.BytesPerSector
141 PartitionEntry, BootPartition);
142 }
144 {
145 FIXME("DiskGetBootPartitionEntry() unimplemented for GPT\n");
146 return FALSE;
147 }
148 case PARTITION_STYLE_RAW:
149 {
150 FIXME("DiskGetBootPartitionEntry() unimplemented for RAW\n");
151 return FALSE;
152 }
153 case PARTITION_STYLE_BRFR:
154 {
155 PARTITION_INFORMATION TempPartitionEntry;
156 if (!PartitionEntry)
157 PartitionEntry = &TempPartitionEntry;
158 if (DiskGetBrfrPartitionEntry(DriveNumber,
159 512, // Geometry.BytesPerSector
161 PartitionEntry))
162 {
163 *BootPartition = FATX_DATA_PARTITION;
164 return TRUE;
165 }
166 return FALSE;
167 }
168 default:
169 {
170 ERR("Drive 0x%X partition type = %d, should not happen!\n", DriveNumber, DiskPartitionType[DriveNumber]);
171 ASSERT(FALSE);
172 }
173 }
174 return FALSE;
175}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define MachDiskGetDriveGeometry(Drive, Geom)
Definition: machine.h:122
#define ASSERT(a)
Definition: mode.c:44
#define FATX_DATA_PARTITION
Definition: part_brfr.c:17
BOOLEAN DiskGetBrfrPartitionEntry(_In_ UCHAR DriveNumber, _In_ ULONG SectorSize, _In_ ULONG PartitionNumber, _Out_ PPARTITION_INFORMATION PartitionEntry)
Definition: part_brfr.c:47
BOOLEAN DiskGetActivePartitionEntry(_In_ UCHAR DriveNumber, _In_ ULONG SectorSize, _Out_opt_ PPARTITION_INFORMATION PartitionEntry, _Out_ PULONG ActivePartition)
Definition: part_mbr.c:77
Definition: disk.h:24

Referenced by DiskGetBootPath().

◆ DiskGetErrorCodeString()

PCSTR DiskGetErrorCodeString ( _In_ ULONG  ErrorCode)

Definition at line 136 of file pcdisk.c.

138{
139 switch (ErrorCode)
140 {
141 case 0x00: return "No error";
142 case 0x01: return "Bad command passed to driver";
143 case 0x02: return "Address mark not found or bad sector";
144 case 0x03: return "Diskette write protect error";
145 case 0x04: return "Sector not found";
146 case 0x05: return "Fixed disk reset failed";
147 case 0x06: return "Diskette changed or removed";
148 case 0x07: return "Bad fixed disk parameter table";
149 case 0x08: return "DMA overrun";
150 case 0x09: return "DMA access across 64k boundary";
151 case 0x0A: return "Bad fixed disk sector flag";
152 case 0x0B: return "Bad fixed disk cylinder";
153 case 0x0C: return "Unsupported track/invalid media";
154 case 0x0D: return "Invalid number of sectors on fixed disk format";
155 case 0x0E: return "Fixed disk controlled data address mark detected";
156 case 0x0F: return "Fixed disk DMA arbitration level out of range";
157 case 0x10: return "ECC/CRC error on disk read";
158 case 0x11: return "Recoverable fixed disk data error, data fixed by ECC";
159 case 0x20: return "Controller error (NEC for floppies)";
160 case 0x40: return "Seek failure";
161 case 0x80: return "Time out, drive not ready";
162 case 0xAA: return "Fixed disk drive not ready";
163 case 0xBB: return "Fixed disk undefined error";
164 case 0xCC: return "Fixed disk write fault on selected drive";
165 case 0xE0: return "Fixed disk status error/Error reg = 0";
166 case 0xFF: return "Sense operation failed";
167
168 default: return "Unknown error code";
169 }
170}

Referenced by DiskError(), Pc98DiskReadLogicalSectorsCHS(), Pc98DiskReadLogicalSectorsLBA(), PcDiskReadLogicalSectorsCHS(), and PcDiskReadLogicalSectorsLBA().

◆ DiskGetPartitionEntry()

BOOLEAN DiskGetPartitionEntry ( _In_ UCHAR  DriveNumber,
_In_opt_ ULONG  SectorSize,
_In_ ULONG  PartitionNumber,
_Out_ PPARTITION_INFORMATION  PartitionEntry 
)

Definition at line 178 of file partition.c.

183{
184 if (SectorSize == 0)
185 {
186 GEOMETRY Geometry;
187 if (!MachDiskGetDriveGeometry(DriveNumber, &Geometry))
188 return FALSE;
189 SectorSize = Geometry.BytesPerSector;
190 }
191 if (SectorSize < 512)
192 {
193 ERR("Drive 0x%X: Invalid sector size %lu\n", DriveNumber, SectorSize);
194 return FALSE;
195 }
196
197 switch (DiskPartitionType[DriveNumber])
198 {
200 {
201 return DiskGetMbrPartitionEntry(DriveNumber,
202 /* MBR partition table always uses 512-byte sectors per specification */
203 512, // SectorSize
205 PartitionEntry);
206 }
208 {
209 return DiskGetGptPartitionEntry(DriveNumber,
212 PartitionEntry);
213 }
214 case PARTITION_STYLE_RAW:
215 {
216 FIXME("DiskGetPartitionEntry() unimplemented for RAW\n");
217 return FALSE;
218 }
219 case PARTITION_STYLE_BRFR:
220 {
221 return DiskGetBrfrPartitionEntry(DriveNumber,
222 512, // SectorSize
224 PartitionEntry);
225 }
226 default:
227 {
228 ERR("Drive 0x%X partition type = %d, should not happen!\n", DriveNumber, DiskPartitionType[DriveNumber]);
229 ASSERT(FALSE);
230 }
231 }
232 return FALSE;
233}
BOOLEAN DiskGetGptPartitionEntry(_In_ UCHAR DriveNumber, _In_ ULONG SectorSize, _In_ ULONG PartitionNumber, _Out_ PPARTITION_INFORMATION PartitionEntry)
Definition: part_gpt.c:46
BOOLEAN DiskGetMbrPartitionEntry(_In_ UCHAR DriveNumber, _In_ ULONG SectorSize, _In_ ULONG PartitionNumber, _Out_ PPARTITION_INFORMATION PartitionEntry)
Definition: part_mbr.c:139
ULONG BytesPerSector
Number of bytes per sector.
Definition: disk.h:28
_In_ ULONG SectorSize
Definition: halfuncs.h:291
_In_ ULONG _In_ ULONG PartitionNumber
Definition: iofuncs.h:2061

Referenced by DiskInitialize(), DiskOpen(), UefiDiskOpen(), and UefiGetBootPartitionEntry().

◆ DiskInitialize()

ARC_STATUS DiskInitialize ( _In_ UCHAR  DriveNumber,
_In_ PCSTR  DeviceName,
_In_ CONFIGURATION_TYPE  DeviceType,
_In_ const struct tagDEVVTBL FuncTable,
_Out_opt_ PULONG  pChecksum,
_Out_opt_ PULONG  pSignature,
_Out_opt_ PBOOLEAN  pValidPartitionTable 
)

◆ DiskReportError()

LONG DiskReportError ( _In_ BOOLEAN  bShowError)

Definition at line 38 of file disk.c.

40{
41 /* Set the reference count */
42 if (bShowError) ++lReportError;
43 else --lReportError;
44 return lReportError;
45}

Referenced by EnumerateHarddisks(), GetHarddiskInformation(), PcInitializeBootDevices(), and UefiInitializeBootDevices().

◆ FrldrGetBootDrive()

UCHAR FrldrGetBootDrive ( VOID  )

Definition at line 202 of file freeldr.c.

203{
204 return FrldrBootDrive;
205}
UCHAR FrldrBootDrive
Definition: uefidisk.c:57

◆ FrldrGetBootPartition()

ULONG FrldrGetBootPartition ( VOID  )

Definition at line 207 of file freeldr.c.

208{
209 return FrldrBootPartition;
210}
ULONG FrldrBootPartition
Definition: uefidisk.c:58

◆ FrLdrGetBootPath()

PCCHAR FrLdrGetBootPath ( VOID  )

Definition at line 197 of file freeldr.c.

198{
199 return FrLdrBootPath;
200}
CCHAR FrLdrBootPath[MAX_PATH]
Definition: freeldr.c:29

Referenced by BuildArgvForOsLoader(), and LoadBootDeviceDriver().

◆ LoadBootDeviceDriver()

ULONG LoadBootDeviceDriver ( VOID  )

Definition at line 1656 of file scsiport.c.

1657{
1658 PLDR_DATA_TABLE_ENTRY BootDdDTE;
1659 CHAR NtBootDdPath[MAX_PATH];
1660 PVOID ImageBase = NULL;
1663
1664 // FIXME: Must be done *INSIDE* the HAL!
1665#ifdef _M_IX86
1668#endif
1669
1670 /* Create full ntbootdd.sys path */
1671 strcpy(NtBootDdPath, FrLdrGetBootPath());
1672 strcat(NtBootDdPath, "\\NTBOOTDD.SYS");
1673
1674 /* Load ntbootdd.sys */
1675 Success = PeLdrLoadBootImage(NtBootDdPath,
1676 "ntbootdd.sys",
1677 ImageBase,
1678 &BootDdDTE);
1679 if (!Success)
1680 {
1681 /* That's OK, file simply doesn't exist */
1682 return ESUCCESS;
1683 }
1684
1685 /* Call the entrypoint */
1686 EntryPoint = VaToPa(BootDdDTE->EntryPoint);
1687 (*EntryPoint)(NULL, NULL);
1688
1689 return ESUCCESS;
1690}
VOID NTAPI HalpInitBusHandler(VOID)
Definition: bushndlr.c:444
VOID NTAPI HalpInitializePciStubs(VOID)
Definition: pcibus.c:1190
FORCEINLINE PVOID VaToPa(PVOID Va)
Definition: conversion.h:15
#define NULL
Definition: types.h:112
#define MAX_PATH
Definition: compat.h:34
@ Success
Definition: eventcreate.c:712
PCCHAR FrLdrGetBootPath(VOID)
Definition: freeldr.c:197
BOOLEAN PeLdrLoadBootImage(_In_ PCSTR FilePath, _In_ PCSTR BaseDllName, _Out_ PVOID *ImageBase, _Out_ PLDR_DATA_TABLE_ENTRY *DataTableEntry)
Definition: peloader.c:1052
@ ESUCCESS
Definition: arc.h:32
strcat
Definition: string.h:92
strcpy
Definition: string.h:131
Definition: btrfs_drv.h:1876
PVOID EntryPoint
Definition: ntddk_ex.h:203
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213

Referenced by RunLoader().

Variable Documentation

◆ DiskReadBuffer

◆ DiskReadBufferSize

◆ FrLdrBootPath