ReactOS  0.4.13-dev-242-g611e6d7
disk.h
Go to the documentation of this file.
1 /*
2  * FreeLoader
3  * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #pragma once
21 
22 #include <reactos/rosioctl.h>
23 
24 typedef struct _GEOMETRY
25 {
26  ULONG Cylinders; // Number of cylinders on the disk
27  ULONG Heads; // Number of heads on the disk
28  ULONG Sectors; // Number of sectors per track
29  ULONG BytesPerSector; // Number of bytes per sector
30 
32 
33 //
34 // Extended disk geometry (Int13 / ah=48h)
35 //
36 #include <pshpack1.h>
37 typedef struct _EXTENDED_GEOMETRY
38 {
47 
49 
50 //
51 // Define the structure of a partition table entry
52 //
53 typedef struct _PARTITION_TABLE_ENTRY
54 {
55  UCHAR BootIndicator; // 0x00 - non-bootable partition,
56  // 0x80 - bootable partition (one partition only)
57  UCHAR StartHead; // Beginning head number
58  UCHAR StartSector; // Beginning sector (2 high bits of cylinder #)
59  UCHAR StartCylinder; // Beginning cylinder# (low order bits of cylinder #)
60  UCHAR SystemIndicator; // System indicator
61  UCHAR EndHead; // Ending head number
62  UCHAR EndSector; // Ending sector (2 high bits of cylinder #)
63  UCHAR EndCylinder; // Ending cylinder# (low order bits of cylinder #)
64  ULONG SectorCountBeforePartition; // Number of sectors preceding the partition
65  ULONG PartitionSectorCount; // Number of sectors in the partition
66 
68 
69 //
70 // Define the structure of the master boot record
71 //
72 typedef struct _MASTER_BOOT_RECORD
73 {
74  UCHAR MasterBootRecordCodeAndData[0x1b8]; /* 0x000 */
75  ULONG Signature; /* 0x1B8 */
76  USHORT Reserved; /* 0x1BC */
79 
81 #include <poppack.h>
82 
83 //
84 // Partition type defines (of PSDK)
85 //
86 #define PARTITION_ENTRY_UNUSED 0x00 // Entry unused
87 #define PARTITION_FAT_12 0x01 // 12-bit FAT entries
88 #define PARTITION_XENIX_1 0x02 // Xenix
89 #define PARTITION_XENIX_2 0x03 // Xenix
90 #define PARTITION_FAT_16 0x04 // 16-bit FAT entries
91 #define PARTITION_EXTENDED 0x05 // Extended partition entry
92 #define PARTITION_HUGE 0x06 // Huge partition MS-DOS V4
93 #define PARTITION_IFS 0x07 // IFS Partition
94 #define PARTITION_OS2BOOTMGR 0x0A // OS/2 Boot Manager/OPUS/Coherent swap
95 #define PARTITION_FAT32 0x0B // FAT32
96 #define PARTITION_FAT32_XINT13 0x0C // FAT32 using extended int13 services
97 #define PARTITION_XINT13 0x0E // Win95 partition using extended int13 services
98 #define PARTITION_XINT13_EXTENDED 0x0F // Same as type 5 but uses extended int13 services
99 #define PARTITION_NTFS 0x17 // NTFS
100 #define PARTITION_PREP 0x41 // PowerPC Reference Platform (PReP) Boot Partition
101 #define PARTITION_LDM 0x42 // Logical Disk Manager partition
102 #define PARTITION_UNIX 0x63 // Unix
103 #define VALID_NTFT 0xC0 // NTFT uses high order bits
104 #define PARTITION_NTFT 0x80 // NTFT partition
105 #ifdef __REACTOS__
106 #define PARTITION_OLD_LINUX 0x43
107 #define PARTITION_LINUX 0x83
108 #endif
109 
111 //
112 // PC x86/64 BIOS Disk Functions (pcdisk.c)
113 //
115 #if defined(__i386__) || defined(_M_AMD64)
117 #endif // defined __i386__ || defined(_M_AMD64)
118 
120 //
121 // FreeLoader Disk Functions
122 //
125 VOID DiskError(PCSTR ErrorString, ULONG ErrorCode);
127 BOOLEAN DiskIsDriveRemovable(UCHAR DriveNumber);
128 
130 /* Platform-specific boot drive and partition numbers */
131 extern UCHAR FrldrBootDrive;
133 /* ARC path of the boot drive and partition */
134 extern CHAR FrldrBootPath[MAX_PATH];
135 
136 /* Buffer for disk reads */
137 extern PVOID DiskReadBuffer;
139 
140 
142 //
143 // Fixed Disk Partition Management Functions
144 //
146 
147 /* Signature of DiskGetPartitionEntry(...) */
148 typedef
149 BOOLEAN
152  PPARTITION_TABLE_ENTRY PartitionTableEntry);
153 
154 /* This function serves to retrieve a partition entry for devices that handle partitions differently */
156 
157 BOOLEAN DiskGetActivePartitionEntry(UCHAR DriveNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry, ULONG *ActivePartition);
161 BOOLEAN DiskReadBootRecord(UCHAR DriveNumber, ULONGLONG LogicalSectorNumber, PMASTER_BOOT_RECORD BootRecord);
162 
163 /*
164  * SCSI support (disk/scsiport.c)
165  */
signed char * PCHAR
Definition: retypes.h:7
ULONG Signature
Definition: disk.h:75
BOOLEAN DiskGetFirstPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTITION_TABLE_ENTRY PartitionTableEntry)
Definition: partition.c:176
BOOLEAN DiskGetBootPath(OUT PCHAR BootPath, IN ULONG Size)
Definition: disk.c:102
BOOLEAN(* DISK_GET_PARTITION_ENTRY)(UCHAR DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
Definition: disk.h:150
USHORT Flags
Definition: disk.h:40
#define IN
Definition: typedefs.h:38
VOID DiskReportError(BOOLEAN bError)
Definition: disk.c:33
USHORT MasterBootRecordMagic
Definition: disk.h:78
struct _MASTER_BOOT_RECORD MASTER_BOOT_RECORD
Definition: disk.h:53
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
ULONG PartitionSectorCount
Definition: disk.h:65
UCHAR EndCylinder
Definition: disk.h:63
UCHAR StartHead
Definition: disk.h:57
ULONG Cylinders
Definition: disk.h:26
char CHAR
Definition: xmlstorage.h:175
UCHAR SystemIndicator
Definition: disk.h:60
BOOLEAN DiskGetFirstExtendedPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTITION_TABLE_ENTRY PartitionTableEntry)
Definition: partition.c:197
USHORT Reserved
Definition: disk.h:76
_In_ ULONG _In_ ULONG PartitionNumber
Definition: iofuncs.h:2056
DISK_GET_PARTITION_ENTRY DiskGetPartitionEntry
Definition: partition.c:33
ULONG Cylinders
Definition: disk.h:41
ULONG LoadBootDeviceDriver(VOID)
Definition: scsiport.c:1591
UCHAR StartSector
Definition: disk.h:58
PCSTR DiskGetErrorCodeString(ULONG ErrorCode)
Definition: disk.c:53
UCHAR MasterBootRecordCodeAndData[0x1b8]
Definition: disk.h:74
ULONG SectorsPerTrack
Definition: disk.h:43
unsigned char BOOLEAN
UCHAR EndHead
Definition: disk.h:61
VOID DiskError(PCSTR ErrorString, ULONG ErrorCode)
Definition: disk.c:38
ULONG SectorCountBeforePartition
Definition: disk.h:64
PVOID DiskReadBuffer
Definition: hwdisk.c:47
struct _GEOMETRY * PGEOMETRY
BOOLEAN DiskIsDriveRemovable(UCHAR DriveNumber)
Definition: disk.c:88
ULONG Sectors
Definition: disk.h:28
uint64_t ULONGLONG
Definition: typedefs.h:65
CHAR FrldrBootPath[MAX_PATH]
Definition: disk.c:27
#define MAX_PATH
Definition: compat.h:26
Definition: parttest.c:75
UCHAR BootIndicator
Definition: disk.h:55
PARTITION_TABLE_ENTRY PartitionTable[4]
Definition: disk.h:77
unsigned char UCHAR
Definition: xmlstorage.h:181
BOOLEAN DiskReadBootRecord(UCHAR DriveNumber, ULONGLONG LogicalSectorNumber, PMASTER_BOOT_RECORD BootRecord)
Definition: partition.c:216
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
USHORT Size
Definition: disk.h:39
SIZE_T DiskReadBufferSize
Definition: hwdisk.c:48
UCHAR EndSector
Definition: disk.h:62
ULONG FrldrBootPartition
ULONG_PTR SIZE_T
Definition: typedefs.h:78
ULONG BytesPerSector
Definition: disk.h:29
USHORT BytesPerSector
Definition: disk.h:45
BOOLEAN DiskGetActivePartitionEntry(UCHAR DriveNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry, ULONG *ActivePartition)
Definition: partition.c:35
unsigned short USHORT
Definition: pedump.c:61
UCHAR StartCylinder
Definition: disk.h:59
ULONG Heads
Definition: disk.h:42
Definition: disk.h:24
UCHAR FrldrBootDrive
BOOLEAN DiskGetMbrPartitionEntry(UCHAR DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
Definition: partition.c:93
struct _EXTENDED_GEOMETRY EXTENDED_GEOMETRY
struct _PARTITION_TABLE_ENTRY * PPARTITION_TABLE_ENTRY
struct _GEOMETRY GEOMETRY
#define BOOLEAN
Definition: pedump.c:73
struct _MASTER_BOOT_RECORD * PMASTER_BOOT_RECORD
#define OUT
Definition: typedefs.h:39
ULONG PDPTE
Definition: disk.h:46
unsigned int ULONG
Definition: retypes.h:1
ULONGLONG Sectors
Definition: disk.h:44
const char * PCSTR
Definition: typedefs.h:51
struct _EXTENDED_GEOMETRY * PEXTENDED_GEOMETRY
struct _PARTITION_TABLE_ENTRY PARTITION_TABLE_ENTRY
char BootPath[0x100]
Definition: mach.c:35
VOID DiskStopFloppyMotor(VOID)
Definition: macharm.c:62
ULONG Heads
Definition: disk.h:27