3 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
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.
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.
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.
22 #include <reactos/rosioctl.h>
24 typedef struct _GEOMETRY
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
31 } GEOMETRY
, *PGEOMETRY
;
34 // Extended disk geometry (Int13 / ah=48h)
37 typedef struct _EXTENDED_GEOMETRY
43 ULONG SectorsPerTrack
;
45 USHORT BytesPerSector
;
47 } EXTENDED_GEOMETRY
, *PEXTENDED_GEOMETRY
;
50 // Define the structure of a partition table entry
52 typedef struct _PARTITION_TABLE_ENTRY
54 UCHAR BootIndicator
; // 0x00 - non-bootable partition, 0x80 - bootable partition (one partition only)
55 UCHAR StartHead
; // Beginning head number
56 UCHAR StartSector
; // Beginning sector (2 high bits of cylinder #)
57 UCHAR StartCylinder
; // Beginning cylinder# (low order bits of cylinder #)
58 UCHAR SystemIndicator
; // System indicator
59 UCHAR EndHead
; // Ending head number
60 UCHAR EndSector
; // Ending sector (2 high bits of cylinder #)
61 UCHAR EndCylinder
; // Ending cylinder# (low order bits of cylinder #)
62 ULONG SectorCountBeforePartition
; // Number of sectors preceding the partition
63 ULONG PartitionSectorCount
; // Number of sectors in the partition
65 } PARTITION_TABLE_ENTRY
, *PPARTITION_TABLE_ENTRY
;
68 // Define the structure of the master boot record
70 typedef struct _MASTER_BOOT_RECORD
72 UCHAR MasterBootRecordCodeAndData
[0x1b8]; /* 0x000 */
73 ULONG Signature
; /* 0x1B8 */
74 USHORT Reserved
; /* 0x1BC */
75 PARTITION_TABLE_ENTRY PartitionTable
[4]; /* 0x1BE */
76 USHORT MasterBootRecordMagic
; /* 0x1FE */
78 } MASTER_BOOT_RECORD
, *PMASTER_BOOT_RECORD
;
82 // Partition type defines (of PSDK)
84 #define PARTITION_ENTRY_UNUSED 0x00 // Entry unused
85 #define PARTITION_FAT_12 0x01 // 12-bit FAT entries
86 #define PARTITION_XENIX_1 0x02 // Xenix
87 #define PARTITION_XENIX_2 0x03 // Xenix
88 #define PARTITION_FAT_16 0x04 // 16-bit FAT entries
89 #define PARTITION_EXTENDED 0x05 // Extended partition entry
90 #define PARTITION_HUGE 0x06 // Huge partition MS-DOS V4
91 #define PARTITION_IFS 0x07 // IFS Partition
92 #define PARTITION_FAT32 0x0B // FAT32
93 #define PARTITION_FAT32_XINT13 0x0C // FAT32 using extended int13 services
94 #define PARTITION_XINT13 0x0E // Win95 partition using extended int13 services
95 #define PARTITION_XINT13_EXTENDED 0x0F // Same as type 5 but uses extended int13 services
96 #define PARTITION_NTFS 0x17 // NTFS
97 #define PARTITION_PREP 0x41 // PowerPC Reference Platform (PReP) Boot Partition
98 #define PARTITION_LDM 0x42 // Logical Disk Manager partition
99 #define PARTITION_UNIX 0x63 // Unix
101 ///////////////////////////////////////////////////////////////////////////////////////
103 // i386 BIOS Disk Functions (i386disk.c)
105 ///////////////////////////////////////////////////////////////////////////////////////
106 #if defined(__i386__) || defined(_M_AMD64)
108 BOOLEAN
DiskResetController(ULONG DriveNumber
);
109 BOOLEAN
DiskInt13ExtensionsSupported(ULONG DriveNumber
);
110 //VOID DiskStopFloppyMotor(VOID);
111 BOOLEAN
DiskGetExtendedDriveParameters(ULONG DriveNumber
, PVOID Buffer
, USHORT BufferSize
);
113 #endif // defined __i386__ || defined(_M_AMD64)
115 ///////////////////////////////////////////////////////////////////////////////////////
117 // FreeLoader Disk Functions
119 ///////////////////////////////////////////////////////////////////////////////////////
120 VOID
DiskReportError (BOOLEAN bError
);
121 VOID
DiskError(PCSTR ErrorString
, ULONG ErrorCode
);
122 PCSTR
DiskGetErrorCodeString(ULONG ErrorCode
);
123 BOOLEAN
DiskReadLogicalSectors(ULONG DriveNumber
, ULONGLONG SectorNumber
, ULONG SectorCount
, PVOID Buffer
); // Implemented in i386disk.c
124 BOOLEAN
DiskIsDriveRemovable(ULONG DriveNumber
);
125 VOID
DiskStopFloppyMotor(VOID
); // Implemented in i386disk.c
127 extern ULONG FrldrBootDrive
;
128 extern ULONG FrldrBootPartition
;
131 BOOLEAN
DiskGetBootPath(char *BootPath
, unsigned Size
);
134 ///////////////////////////////////////////////////////////////////////////////////////
136 // Fixed Disk Partition Management Functions
138 ///////////////////////////////////////////////////////////////////////////////////////
139 BOOLEAN
DiskGetActivePartitionEntry(ULONG DriveNumber
, PPARTITION_TABLE_ENTRY PartitionTableEntry
, ULONG
*ActivePartition
);
140 BOOLEAN
DiskGetPartitionEntry(ULONG DriveNumber
, ULONG PartitionNumber
, PPARTITION_TABLE_ENTRY PartitionTableEntry
);
141 BOOLEAN
DiskGetFirstPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord
, PPARTITION_TABLE_ENTRY PartitionTableEntry
);
142 BOOLEAN
DiskGetFirstExtendedPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord
, PPARTITION_TABLE_ENTRY PartitionTableEntry
);
143 BOOLEAN
DiskReadBootRecord(ULONG DriveNumber
, ULONGLONG LogicalSectorNumber
, PMASTER_BOOT_RECORD BootRecord
);
145 ULONG
LoadBootDeviceDriver(VOID
);