Fix some Rtl Prototype inconsistencies, more are in ntifs/winddk but i have fixed...
[reactos.git] / freeldr / freeldr / include / disk.h
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
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #ifndef __DISK_H
21 #define __DISK_H
22
23
24 typedef struct _GEOMETRY
25 {
26 U32 Cylinders; // Number of cylinders on the disk
27 U32 Heads; // Number of heads on the disk
28 U32 Sectors; // Number of sectors per track
29 U32 BytesPerSector; // Number of bytes per sector
30
31 } GEOMETRY, *PGEOMETRY;
32
33 //
34 // Extended disk geometry (Int13 / ah=48h)
35 //
36 typedef struct _EXTENDED_GEOMETRY
37 {
38 U16 Size;
39 U16 Flags;
40 U32 Cylinders;
41 U32 Heads;
42 U32 SectorsPerTrack;
43 U64 Sectors;
44 U16 BytesPerSector;
45 U32 PDPTE;
46 } __attribute__((packed)) EXTENDED_GEOMETRY, *PEXTENDED_GEOMETRY;
47
48 //
49 // Define the structure of a partition table entry
50 //
51 typedef struct _PARTITION_TABLE_ENTRY
52 {
53 U8 BootIndicator; // 0x00 - non-bootable partition, 0x80 - bootable partition (one partition only)
54 U8 StartHead; // Beginning head number
55 U8 StartSector; // Beginning sector (2 high bits of cylinder #)
56 U8 StartCylinder; // Beginning cylinder# (low order bits of cylinder #)
57 U8 SystemIndicator; // System indicator
58 U8 EndHead; // Ending head number
59 U8 EndSector; // Ending sector (2 high bits of cylinder #)
60 U8 EndCylinder; // Ending cylinder# (low order bits of cylinder #)
61 U32 SectorCountBeforePartition; // Number of sectors preceding the partition
62 U32 PartitionSectorCount; // Number of sectors in the partition
63
64 } PACKED PARTITION_TABLE_ENTRY, *PPARTITION_TABLE_ENTRY;
65
66 //
67 // Define the structure of the master boot record
68 //
69 typedef struct _MASTER_BOOT_RECORD
70 {
71 U8 MasterBootRecordCodeAndData[0x1b8]; /* 0x000 */
72 U32 Signature; /* 0x1B8 */
73 U16 Reserved; /* 0x1BC */
74 PARTITION_TABLE_ENTRY PartitionTable[4]; /* 0x1BE */
75 U16 MasterBootRecordMagic; /* 0x1FE */
76
77 } PACKED MASTER_BOOT_RECORD, *PMASTER_BOOT_RECORD;
78
79 //
80 // Partition type defines
81 //
82 #define PARTITION_ENTRY_UNUSED 0x00 // Entry unused
83 #define PARTITION_FAT_12 0x01 // 12-bit FAT entries
84 #define PARTITION_XENIX_1 0x02 // Xenix
85 #define PARTITION_XENIX_2 0x03 // Xenix
86 #define PARTITION_FAT_16 0x04 // 16-bit FAT entries
87 #define PARTITION_EXTENDED 0x05 // Extended partition entry
88 #define PARTITION_HUGE 0x06 // Huge partition MS-DOS V4
89 #define PARTITION_IFS 0x07 // IFS Partition
90 #define PARTITION_OS2BOOTMGR 0x0A // OS/2 Boot Manager/OPUS/Coherent swap
91 #define PARTITION_FAT32 0x0B // FAT32
92 #define PARTITION_FAT32_XINT13 0x0C // FAT32 using extended int13 services
93 #define PARTITION_XINT13 0x0E // Win95 partition using extended int13 services
94 #define PARTITION_XINT13_EXTENDED 0x0F // Same as type 5 but uses extended int13 services
95 #define PARTITION_NTFS 0x17 // NTFS
96 #define PARTITION_PREP 0x41 // PowerPC Reference Platform (PReP) Boot Partition
97 #define PARTITION_LDM 0x42 // Logical Disk Manager partition
98 #define PARTITION_UNIX 0x63 // Unix
99 #define PARTITION_LINUX_SWAP 0x82 // Linux Swap Partition
100 #define PARTITION_EXT2 0x83 // Linux Ext2/Ext3
101
102 ///////////////////////////////////////////////////////////////////////////////////////
103 //
104 // i386 BIOS Disk Functions (i386disk.c)
105 //
106 ///////////////////////////////////////////////////////////////////////////////////////
107 #ifdef __i386__
108
109 BOOL DiskResetController(U32 DriveNumber);
110 BOOL DiskInt13ExtensionsSupported(U32 DriveNumber);
111 //VOID DiskStopFloppyMotor(VOID);
112 BOOL DiskGetExtendedDriveParameters(U32 DriveNumber, PVOID Buffer, U16 BufferSize);
113
114 #endif // defined __i386__
115
116 ///////////////////////////////////////////////////////////////////////////////////////
117 //
118 // FreeLoader Disk Functions
119 //
120 ///////////////////////////////////////////////////////////////////////////////////////
121 VOID DiskReportError (BOOL bError);
122 VOID DiskError(PUCHAR ErrorString, U32 ErrorCode);
123 PUCHAR DiskGetErrorCodeString(U32 ErrorCode);
124 BOOL DiskReadLogicalSectors(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, PVOID Buffer); // Implemented in i386disk.c
125 BOOL DiskIsDriveRemovable(U32 DriveNumber);
126 VOID DiskStopFloppyMotor(VOID); // Implemented in i386disk.c
127
128 ///////////////////////////////////////////////////////////////////////////////////////
129 //
130 // Fixed Disk Partition Management Functions
131 //
132 ///////////////////////////////////////////////////////////////////////////////////////
133 BOOL DiskGetActivePartitionEntry(U32 DriveNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
134 BOOL DiskGetPartitionEntry(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
135 BOOL DiskGetFirstPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTITION_TABLE_ENTRY PartitionTableEntry);
136 BOOL DiskGetFirstExtendedPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTITION_TABLE_ENTRY PartitionTableEntry);
137 BOOL DiskReadBootRecord(U32 DriveNumber, U64 LogicalSectorNumber, PMASTER_BOOT_RECORD BootRecord);
138
139 #endif // defined __DISK_H