Fixed GetExtendedMemorySize(). My i486-DX4/75 didn't like the old routine.
[reactos.git] / freeldr / freeldr / fs.h
1 /*
2 * FreeLoader
3 * Copyright (C) 1999, 2000, 2001 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 __FS_H
21 #define __FS_H
22
23 //
24 // Define the structure of a partition table entry
25 //
26 typedef struct _PARTITION_TABLE_ENTRY
27 {
28 BYTE BootIndicator; // 0x00 - non-bootable partition, 0x80 - bootable partition (one partition only)
29 BYTE StartHead; // Beginning head number
30 BYTE StartSector; // Beginning sector (2 high bits of cylinder #)
31 BYTE StartCylinder; // Beginning cylinder# (low order bits of cylinder #)
32 BYTE SystemIndicator; // System indicator
33 BYTE EndHead; // Ending head number
34 BYTE EndSector; // Ending sector (2 high bits of cylinder #)
35 BYTE EndCylinder; // Ending cylinder# (low order bits of cylinder #)
36 DWORD SectorCountBeforePartition; // Number of sectors preceding the partition
37 DWORD PartitionSectorCount; // Number of sectors in the partition
38
39 } PACKED PARTITION_TABLE_ENTRY, *PPARTITION_TABLE_ENTRY;
40
41 //
42 // This macro will return the cylinder when you pass it a cylinder/sector
43 // pair where the high 2 bits of the cylinder are stored in the sector byte
44 //
45 #define MAKE_CYLINDER(cylinder, sector) ( cylinder + ((((WORD)sector) & 0xC0) << 2) )
46
47 //
48 // Define the structure of the master boot record
49 //
50 typedef struct _MASTER_BOOT_RECORD
51 {
52 BYTE MasterBootRecordCodeAndData[0x1be];
53 PARTITION_TABLE_ENTRY PartitionTable[4];
54 WORD MasterBootRecordMagic;
55
56 } PACKED MASTER_BOOT_RECORD, *PMASTER_BOOT_RECORD;
57
58 //
59 // Partition type defines
60 //
61 #define PARTITION_ENTRY_UNUSED 0x00 // Entry unused
62 #define PARTITION_FAT_12 0x01 // 12-bit FAT entries
63 #define PARTITION_XENIX_1 0x02 // Xenix
64 #define PARTITION_XENIX_2 0x03 // Xenix
65 #define PARTITION_FAT_16 0x04 // 16-bit FAT entries
66 #define PARTITION_EXTENDED 0x05 // Extended partition entry
67 #define PARTITION_HUGE 0x06 // Huge partition MS-DOS V4
68 #define PARTITION_IFS 0x07 // IFS Partition
69 #define PARTITION_OS2BOOTMGR 0x0A // OS/2 Boot Manager/OPUS/Coherent swap
70 #define PARTITION_FAT32 0x0B // FAT32
71 #define PARTITION_FAT32_XINT13 0x0C // FAT32 using extended int13 services
72 #define PARTITION_XINT13 0x0E // Win95 partition using extended int13 services
73 #define PARTITION_XINT13_EXTENDED 0x0F // Same as type 5 but uses extended int13 services
74 #define PARTITION_PREP 0x41 // PowerPC Reference Platform (PReP) Boot Partition
75 #define PARTITION_LDM 0x42 // Logical Disk Manager partition
76 #define PARTITION_UNIX 0x63 // Unix
77
78 typedef struct _GEOMETRY
79 {
80 ULONG Cylinders;
81 ULONG Heads;
82 ULONG Sectors;
83 ULONG BytesPerSector;
84
85 } GEOMETRY, *PGEOMETRY;
86
87 #define FILE VOID
88 #define PFILE FILE *
89
90 VOID FileSystemError(PUCHAR ErrorString);
91 BOOL OpenDiskDrive(ULONG DriveNumber, ULONG PartitionNumber);
92 VOID SetDriveGeometry(ULONG Cylinders, ULONG Heads, ULONG Sectors, ULONG BytesPerSector);
93 VOID SetVolumeProperties(ULONG HiddenSectors);
94 BOOL ReadMultipleLogicalSectors(ULONG SectorNumber, ULONG SectorCount, PVOID Buffer);
95 BOOL ReadLogicalSector(ULONG SectorNumber, PVOID Buffer);
96 PFILE OpenFile(PUCHAR FileName);
97 VOID CloseFile(PFILE FileHandle);
98 BOOL ReadFile(PFILE FileHandle, ULONG BytesToRead, PULONG BytesRead, PVOID Buffer);
99 ULONG GetFileSize(PFILE FileHandle);
100 VOID SetFilePointer(PFILE FileHandle, ULONG NewFilePointer);
101 ULONG GetFilePointer(PFILE FileHandle);
102 BOOL IsEndOfFile(PFILE FileHandle);
103
104
105 #define EOF -1
106
107 #define ATTR_NORMAL 0x00
108 #define ATTR_READONLY 0x01
109 #define ATTR_HIDDEN 0x02
110 #define ATTR_SYSTEM 0x04
111 #define ATTR_VOLUMENAME 0x08
112 #define ATTR_DIRECTORY 0x10
113 #define ATTR_ARCHIVE 0x20
114
115 #define FS_FAT 1
116 #define FS_NTFS 2
117 #define FS_EXT2 3
118
119 #define FAT12 1
120 #define FAT16 2
121 #define FAT32 3
122
123 #endif // #defined __FS_H