]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * The contents of this file constitute Original Code as defined in and | |
7 | * are subject to the Apple Public Source License Version 1.1 (the | |
8 | * "License"). You may not use this file except in compliance with the | |
9 | * License. Please obtain a copy of the License at | |
10 | * http://www.apple.com/publicsource and read it before using this file. | |
11 | * | |
12 | * This Original Code and all software distributed under the License are | |
13 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the | |
17 | * License for the specific language governing rights and limitations | |
18 | * under the License. | |
19 | * | |
20 | * @APPLE_LICENSE_HEADER_END@ | |
21 | */ | |
22 | ||
23 | #ifndef _IOFDISKPARTITIONSCHEME_H | |
24 | #define _IOFDISKPARTITIONSCHEME_H | |
25 | ||
26 | #include <IOKit/IOTypes.h> | |
27 | ||
28 | /* | |
29 | * FDisk Partition Map Definitions | |
30 | */ | |
31 | ||
32 | #pragma pack(2) /* (enable 16-bit struct packing for fdisk_part, disk_blk0) */ | |
33 | ||
34 | /* Structure constants. */ | |
35 | ||
36 | #define DISK_BLK0SZ sizeof(struct disk_blk0) /* (size of partition map) */ | |
37 | #define DISK_BOOTSZ 446 /* (size of boot code in map) */ | |
38 | #define DISK_NPART 4 /* (number of entries in map) */ | |
39 | ||
40 | /* Partition map entry. */ | |
41 | ||
42 | struct fdisk_part | |
43 | { | |
44 | UInt8 bootid; /* (is active boot partition?) */ | |
45 | UInt8 beghead; /* (beginning head) */ | |
46 | UInt8 begsect; /* (beginning sector; beginning cylinder, high 2 bits) */ | |
47 | UInt8 begcyl; /* (beginning cylinder, low 8 bits) */ | |
48 | UInt8 systid; /* (type) */ | |
49 | UInt8 endhead; /* (ending head) */ | |
50 | UInt8 endsect; /* (ending sector; ending cylinder, high 2 bits) */ | |
51 | UInt8 endcyl; /* (ending cylinder, low 8 bits) */ | |
52 | UInt32 relsect; /* (block start) */ | |
53 | UInt32 numsect; /* (block count) */ | |
54 | }; | |
55 | ||
56 | /* Partition map, as found in block zero of the disk (or extended partition). */ | |
57 | ||
58 | struct disk_blk0 | |
59 | { | |
60 | UInt8 bootcode[DISK_BOOTSZ]; /* (boot code) */ | |
61 | struct fdisk_part parts[DISK_NPART]; /* (partition entries) */ | |
62 | UInt16 signature; /* (unique signature for map) */ | |
63 | }; | |
64 | ||
65 | /* Partition map signature (signature). */ | |
66 | ||
67 | #define DISK_SIGNATURE 0xAA55 | |
68 | ||
69 | /* Partition map entry types (systid). */ | |
70 | ||
71 | #define FDISK_PARTITION_TYPE_01 "DOS_FAT_12" | |
72 | #define FDISK_PARTITION_TYPE_04 "DOS_FAT_16_S" | |
73 | #define FDISK_PARTITION_TYPE_05 "DOS_Extended" | |
74 | #define FDISK_PARTITION_TYPE_06 "DOS_FAT_16" | |
75 | #define FDISK_PARTITION_TYPE_07 "Windows_NTFS" | |
76 | #define FDISK_PARTITION_TYPE_0A "Boot_Manager" | |
77 | #define FDISK_PARTITION_TYPE_0B "DOS_FAT_32" | |
78 | #define FDISK_PARTITION_TYPE_0C "Windows_FAT_32" | |
79 | #define FDISK_PARTITION_TYPE_0E "Windows_FAT_16" | |
80 | #define FDISK_PARTITION_TYPE_0F "Windows_Extended" | |
81 | #define FDISK_PARTITION_TYPE_11 "DOS_FAT_12_Hidden" | |
82 | #define FDISK_PARTITION_TYPE_14 "DOS_FAT_16_S_Hidden" | |
83 | #define FDISK_PARTITION_TYPE_16 "DOS_FAT_16_Hidden" | |
84 | #define FDISK_PARTITION_TYPE_17 "Windows_NTFS_Hidden" | |
85 | #define FDISK_PARTITION_TYPE_1B "DOS_FAT_32_Hidden" | |
86 | #define FDISK_PARTITION_TYPE_1C "Windows_FAT_32_Hidden" | |
87 | #define FDISK_PARTITION_TYPE_1E "Windows_FAT_16_Hidden" | |
88 | #define FDISK_PARTITION_TYPE_63 "UNIX" | |
89 | #define FDISK_PARTITION_TYPE_82 "Linux_Swap" | |
90 | #define FDISK_PARTITION_TYPE_83 "Linux_Ext2FS" | |
91 | #define FDISK_PARTITION_TYPE_84 "Hibernation" | |
92 | #define FDISK_PARTITION_TYPE_85 "Linux_Extended" | |
93 | #define FDISK_PARTITION_TYPE_86 "Windows_FAT_16_FT" | |
94 | #define FDISK_PARTITION_TYPE_87 "Windows_NTFS_FT" | |
95 | #define FDISK_PARTITION_TYPE_A5 "FreeBSD" | |
96 | #define FDISK_PARTITION_TYPE_A6 "OpenBSD" | |
97 | #define FDISK_PARTITION_TYPE_A7 "Apple_Rhapsody_UFS" | |
98 | #define FDISK_PARTITION_TYPE_A8 "Apple_UFS" | |
99 | #define FDISK_PARTITION_TYPE_A9 "NetBSD" | |
100 | #define FDISK_PARTITION_TYPE_AB "Apple_Boot" | |
101 | #define FDISK_PARTITION_TYPE_AF "Apple_HFS" | |
102 | #define FDISK_PARTITION_TYPE_B7 "BSDI" | |
103 | #define FDISK_PARTITION_TYPE_B8 "BSDI_Swap" | |
104 | #define FDISK_PARTITION_TYPE_C6 "Windows_FAT_16_FT_Corrupt" | |
105 | #define FDISK_PARTITION_TYPE_C7 "Windows_NTFS_FT_Corrupt" | |
106 | #define FDISK_PARTITION_TYPE_EB "BeOS" | |
107 | #define FDISK_PARTITION_TYPE_F2 "DOS_Secondary" | |
108 | #define FDISK_PARTITION_TYPE_FD "Linux_RAID" | |
109 | ||
110 | #pragma options align=reset /* (reset to default struct packing) */ | |
111 | ||
112 | /* | |
113 | * Kernel | |
114 | */ | |
115 | ||
116 | #if defined(KERNEL) && defined(__cplusplus) | |
117 | ||
118 | #include <IOKit/storage/IOPartitionScheme.h> | |
119 | ||
120 | /* | |
121 | * Class | |
122 | */ | |
123 | ||
124 | class IOFDiskPartitionScheme : public IOPartitionScheme | |
125 | { | |
126 | OSDeclareDefaultStructors(IOFDiskPartitionScheme); | |
127 | ||
128 | protected: | |
129 | ||
130 | struct ExpansionData { /* */ }; | |
131 | ExpansionData * _expansionData; | |
132 | ||
133 | OSSet * _partitions; /* (set of media objects representing partitions) */ | |
134 | ||
135 | /* | |
136 | * Free all of this object's outstanding resources. | |
137 | */ | |
138 | ||
139 | virtual void free(void); | |
140 | ||
141 | /* | |
142 | * Scan the provider media for an FDisk partition map. Returns the set | |
143 | * of media objects representing each of the partitions (the retain for | |
144 | * the set is passed to the caller), or null should no partition map be | |
145 | * found. The default probe score can be adjusted up or down, based on | |
146 | * the confidence of the scan. | |
147 | */ | |
148 | ||
149 | virtual OSSet * scan(SInt32 * score); | |
150 | ||
151 | /* | |
152 | * Ask whether the given partition is extended. | |
153 | */ | |
154 | ||
155 | virtual bool isPartitionExtended(fdisk_part * partition); | |
156 | ||
157 | /* | |
158 | * Ask whether the given partition is used. | |
159 | */ | |
160 | ||
161 | virtual bool isPartitionUsed(fdisk_part * partition); | |
162 | ||
163 | /* | |
164 | * Ask whether the given partition appears to be corrupt. A partition that | |
165 | * is corrupt will cause the failure of the FDisk partition map recognition | |
166 | * altogether. | |
167 | */ | |
168 | ||
169 | virtual bool isPartitionCorrupt( fdisk_part * partition, | |
170 | UInt32 partitionID, | |
171 | UInt32 fdiskBlock ); | |
172 | ||
173 | /* | |
174 | * Ask whether the given partition appears to be invalid. A partition that | |
175 | * is invalid will cause it to be skipped in the scan, but will not cause a | |
176 | * failure of the FDisk partition map recognition. | |
177 | */ | |
178 | ||
179 | virtual bool isPartitionInvalid( fdisk_part * partition, | |
180 | UInt32 partitionID, | |
181 | UInt32 fdiskBlock ); | |
182 | ||
183 | /* | |
184 | * Instantiate a new media object to represent the given partition. | |
185 | */ | |
186 | ||
187 | virtual IOMedia * instantiateMediaObject( fdisk_part * partition, | |
188 | UInt32 partitionID, | |
189 | UInt32 fdiskBlock ); | |
190 | ||
191 | /* | |
192 | * Allocate a new media object (called from instantiateMediaObject). | |
193 | */ | |
194 | ||
195 | virtual IOMedia * instantiateDesiredMediaObject( fdisk_part * partition, | |
196 | UInt32 partitionID, | |
197 | UInt32 fdiskBlock ); | |
198 | ||
199 | public: | |
200 | ||
201 | /* | |
202 | * Initialize this object's minimal state. | |
203 | */ | |
204 | ||
205 | virtual bool init(OSDictionary * properties = 0); | |
206 | ||
207 | /* | |
208 | * Determine whether the provider media contains an FDisk partition map. | |
209 | */ | |
210 | ||
211 | virtual IOService * probe(IOService * provider, SInt32 * score); | |
212 | ||
213 | /* | |
214 | * Publish the new media objects which represent our partitions. | |
215 | */ | |
216 | ||
217 | virtual bool start(IOService * provider); | |
218 | ||
219 | OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 0); | |
220 | OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 1); | |
221 | OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 2); | |
222 | OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 3); | |
223 | OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 4); | |
224 | OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 5); | |
225 | OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 6); | |
226 | OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 7); | |
227 | OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 8); | |
228 | OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 9); | |
229 | OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 10); | |
230 | OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 11); | |
231 | OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 12); | |
232 | OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 13); | |
233 | OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 14); | |
234 | OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 15); | |
235 | }; | |
236 | ||
237 | #endif /* defined(KERNEL) && defined(__cplusplus) */ | |
238 | ||
239 | #endif /* !_IOFDISKPARTITIONSCHEME_H */ |