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.
23 #include <reactos/rosioctl.h>
25 typedef struct _GEOMETRY
27 ULONG Cylinders
; // Number of cylinders on the disk
28 ULONG Heads
; // Number of heads on the disk
29 ULONG Sectors
; // Number of sectors per track
30 ULONG BytesPerSector
; // Number of bytes per sector
32 } GEOMETRY
, *PGEOMETRY
;
35 // Extended disk geometry (Int13 / ah=48h)
38 typedef struct _EXTENDED_GEOMETRY
44 ULONG SectorsPerTrack
;
46 USHORT BytesPerSector
;
48 } EXTENDED_GEOMETRY
, *PEXTENDED_GEOMETRY
;
51 // Define the structure of a partition table entry
53 typedef struct _PARTITION_TABLE_ENTRY
55 UCHAR BootIndicator
; // 0x00 - non-bootable partition, 0x80 - bootable partition (one partition only)
56 UCHAR StartHead
; // Beginning head number
57 UCHAR StartSector
; // Beginning sector (2 high bits of cylinder #)
58 UCHAR StartCylinder
; // Beginning cylinder# (low order bits of cylinder #)
59 UCHAR SystemIndicator
; // System indicator
60 UCHAR EndHead
; // Ending head number
61 UCHAR EndSector
; // Ending sector (2 high bits of cylinder #)
62 UCHAR EndCylinder
; // Ending cylinder# (low order bits of cylinder #)
63 ULONG SectorCountBeforePartition
; // Number of sectors preceding the partition
64 ULONG PartitionSectorCount
; // Number of sectors in the partition
66 } PARTITION_TABLE_ENTRY
, *PPARTITION_TABLE_ENTRY
;
69 // Define the structure of the master boot record
71 typedef struct _MASTER_BOOT_RECORD
73 UCHAR MasterBootRecordCodeAndData
[0x1b8]; /* 0x000 */
74 ULONG Signature
; /* 0x1B8 */
75 USHORT Reserved
; /* 0x1BC */
76 PARTITION_TABLE_ENTRY PartitionTable
[4]; /* 0x1BE */
77 USHORT MasterBootRecordMagic
; /* 0x1FE */
79 } MASTER_BOOT_RECORD
, *PMASTER_BOOT_RECORD
;
83 // Partition type defines (of PSDK)
85 #define PARTITION_ENTRY_UNUSED 0x00 // Entry unused
86 #define PARTITION_FAT_12 0x01 // 12-bit FAT entries
87 #define PARTITION_XENIX_1 0x02 // Xenix
88 #define PARTITION_XENIX_2 0x03 // Xenix
89 #define PARTITION_FAT_16 0x04 // 16-bit FAT entries
90 #define PARTITION_EXTENDED 0x05 // Extended partition entry
91 #define PARTITION_HUGE 0x06 // Huge partition MS-DOS V4
92 #define PARTITION_IFS 0x07 // IFS Partition
93 #define PARTITION_FAT32 0x0B // FAT32
94 #define PARTITION_FAT32_XINT13 0x0C // FAT32 using extended int13 services
95 #define PARTITION_XINT13 0x0E // Win95 partition using extended int13 services
96 #define PARTITION_XINT13_EXTENDED 0x0F // Same as type 5 but uses extended int13 services
97 #define PARTITION_NTFS 0x17 // NTFS
98 #define PARTITION_PREP 0x41 // PowerPC Reference Platform (PReP) Boot Partition
99 #define PARTITION_LDM 0x42 // Logical Disk Manager partition
100 #define PARTITION_UNIX 0x63 // Unix
102 ///////////////////////////////////////////////////////////////////////////////////////
104 // i386 BIOS Disk Functions (i386disk.c)
106 ///////////////////////////////////////////////////////////////////////////////////////
107 #if defined(__i386__) || defined(_M_AMD64)
109 BOOLEAN
DiskResetController(ULONG DriveNumber
);
110 BOOLEAN
DiskInt13ExtensionsSupported(ULONG DriveNumber
);
111 //VOID DiskStopFloppyMotor(VOID);
112 BOOLEAN
DiskGetExtendedDriveParameters(ULONG DriveNumber
, PVOID Buffer
, USHORT BufferSize
);
114 #endif // defined __i386__ || defined(_M_AMD64)
116 ///////////////////////////////////////////////////////////////////////////////////////
118 // FreeLoader Disk Functions
120 ///////////////////////////////////////////////////////////////////////////////////////
121 VOID
DiskReportError (BOOLEAN bError
);
122 VOID
DiskError(PCSTR ErrorString
, ULONG ErrorCode
);
123 PCSTR
DiskGetErrorCodeString(ULONG ErrorCode
);
124 BOOLEAN
DiskReadLogicalSectors(ULONG DriveNumber
, ULONGLONG SectorNumber
, ULONG SectorCount
, PVOID Buffer
); // Implemented in i386disk.c
125 BOOLEAN
DiskIsDriveRemovable(ULONG DriveNumber
);
126 VOID
DiskStopFloppyMotor(VOID
); // Implemented in i386disk.c
127 extern ULONG BootDrive
;
128 extern ULONG BootPartition
;
130 BOOLEAN
DiskGetBootPath(char *BootPath
, unsigned Size
);
131 BOOLEAN
DiskNormalizeSystemPath(char *SystemPath
, 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 #endif // defined __DISK_H