Root/
Source at commit 296 created 12 years 11 months ago. By ifabio, add i386 folder | |
---|---|
1 | /*␊ |
2 | * Copyright (c) 1998-2009 Apple Inc. All rights reserved.␊ |
3 | *␊ |
4 | * @APPLE_LICENSE_HEADER_START@␊ |
5 | * ␊ |
6 | * This file contains Original Code and/or Modifications of Original Code␊ |
7 | * as defined in and that are subject to the Apple Public Source License␊ |
8 | * Version 2.0 (the 'License'). You may not use this file except in␊ |
9 | * compliance with the License. Please obtain a copy of the License at␊ |
10 | * http://www.opensource.apple.com/apsl/ and read it before using this␊ |
11 | * file.␊ |
12 | * ␊ |
13 | * The Original Code and all software distributed under the License are␊ |
14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER␊ |
15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,␊ |
16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,␊ |
17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.␊ |
18 | * Please see the License for the specific language governing rights and␊ |
19 | * limitations under the License.␊ |
20 | * ␊ |
21 | * @APPLE_LICENSE_HEADER_END@␊ |
22 | */␊ |
23 | ␊ |
24 | /*␊ |
25 | * This header contains the IOGUIDPartitionScheme class definition.␊ |
26 | */␊ |
27 | ␊ |
28 | #ifndef _IOGUIDPARTITIONSCHEME_H␊ |
29 | #define _IOGUIDPARTITIONSCHEME_H␊ |
30 | ␊ |
31 | #include <IOKit/IOTypes.h>␊ |
32 | ␊ |
33 | typedef unsigned char uuid_t[16];␊ |
34 | /*␊ |
35 | * kIOGUIDPartitionSchemeClass is the name of the IOGUIDPartitionScheme class.␊ |
36 | */␊ |
37 | ␊ |
38 | #define kIOGUIDPartitionSchemeClass "IOGUIDPartitionScheme"␊ |
39 | ␊ |
40 | ␊ |
41 | #pragma pack(push, 1) /* (enable 8-bit struct packing) */␊ |
42 | ␊ |
43 | /* Partition map. */␊ |
44 | ␊ |
45 | struct gpt_hdr␊ |
46 | {␊ |
47 | uint8_t hdr_sig[8];␊ |
48 | uint32_t hdr_revision;␊ |
49 | uint32_t hdr_size;␊ |
50 | uint32_t hdr_crc_self;␊ |
51 | uint32_t __reserved;␊ |
52 | uint64_t hdr_lba_self;␊ |
53 | uint64_t hdr_lba_alt;␊ |
54 | uint64_t hdr_lba_start;␊ |
55 | uint64_t hdr_lba_end;␊ |
56 | uuid_t hdr_uuid;␊ |
57 | uint64_t hdr_lba_table;␊ |
58 | uint32_t hdr_entries;␊ |
59 | uint32_t hdr_entsz;␊ |
60 | uint32_t hdr_crc_table;␊ |
61 | uint32_t padding;␊ |
62 | };␊ |
63 | ␊ |
64 | /* Partition map entry. */␊ |
65 | ␊ |
66 | struct gpt_ent␊ |
67 | {␊ |
68 | uuid_t ent_type;␊ |
69 | uuid_t ent_uuid;␊ |
70 | uint64_t ent_lba_start;␊ |
71 | uint64_t ent_lba_end;␊ |
72 | uint64_t ent_attr;␊ |
73 | uint16_t ent_name[36];␊ |
74 | };␊ |
75 | ␊ |
76 | /* Partition map signature (hdr_sig). */␊ |
77 | ␊ |
78 | #define GPT_HDR_SIG "EFI PART"␊ |
79 | ␊ |
80 | /* Partition map version (hdr_revision). */␊ |
81 | ␊ |
82 | #define GPT_HDR_REVISION 0x00010000␊ |
83 | ␊ |
84 | /* Partition map entry flags (ent_attr). */␊ |
85 | ␊ |
86 | #define GPT_ENT_ATTR_PLATFORM 0x00000001␊ |
87 | ␊ |
88 | #pragma pack(pop) /* (reset to default struct packing) */␊ |
89 | ␊ |
90 | #ifdef KERNEL␊ |
91 | #ifdef __cplusplus␊ |
92 | ␊ |
93 | /*␊ |
94 | * Kernel␊ |
95 | */␊ |
96 | ␊ |
97 | #include <IOKit/storage/IOPartitionScheme.h>␊ |
98 | ␊ |
99 | /*␊ |
100 | * Class␊ |
101 | */␊ |
102 | ␊ |
103 | class IOGUIDPartitionScheme : public IOPartitionScheme␊ |
104 | {␊ |
105 | OSDeclareDefaultStructors(IOGUIDPartitionScheme);␊ |
106 | ␊ |
107 | protected:␊ |
108 | ␊ |
109 | struct ExpansionData { /* */ };␊ |
110 | ExpansionData * _expansionData;␊ |
111 | ␊ |
112 | OSSet * _partitions; /* (set of media objects representing partitions) */␊ |
113 | ␊ |
114 | /*␊ |
115 | * Free all of this object's outstanding resources.␊ |
116 | */␊ |
117 | ␊ |
118 | virtual void free(void);␊ |
119 | ␊ |
120 | /*␊ |
121 | * Scan the provider media for a GUID partition map. Returns the set␊ |
122 | * of media objects representing each of the partitions (the retain for␊ |
123 | * the set is passed to the caller), or null should no partition map be␊ |
124 | * found. The default probe score can be adjusted up or down, based on␊ |
125 | * the confidence of the scan.␊ |
126 | */␊ |
127 | ␊ |
128 | virtual OSSet * scan(SInt32 * score);␊ |
129 | ␊ |
130 | /*␊ |
131 | * Ask whether the given partition is used.␊ |
132 | */␊ |
133 | ␊ |
134 | virtual bool isPartitionUsed(gpt_ent * partition);␊ |
135 | ␊ |
136 | /*␊ |
137 | * Ask whether the given partition appears to be corrupt. A partition that␊ |
138 | * is corrupt will cause the failure of the GUID partition map recognition␊ |
139 | * altogether.␊ |
140 | */␊ |
141 | ␊ |
142 | virtual bool isPartitionCorrupt( gpt_ent * partition,␊ |
143 | UInt32 partitionID );␊ |
144 | ␊ |
145 | /*␊ |
146 | * Ask whether the given partition appears to be invalid. A partition that␊ |
147 | * is invalid will cause it to be skipped in the scan, but will not cause a␊ |
148 | * failure of the GUID partition map recognition.␊ |
149 | */␊ |
150 | ␊ |
151 | virtual bool isPartitionInvalid( gpt_ent * partition,␊ |
152 | UInt32 partitionID );␊ |
153 | ␊ |
154 | /*␊ |
155 | * Instantiate a new media object to represent the given partition.␊ |
156 | */␊ |
157 | ␊ |
158 | virtual IOMedia * instantiateMediaObject( gpt_ent * partition,␊ |
159 | UInt32 partitionID );␊ |
160 | ␊ |
161 | /*␊ |
162 | * Allocate a new media object (called from instantiateMediaObject).␊ |
163 | */␊ |
164 | ␊ |
165 | virtual IOMedia * instantiateDesiredMediaObject( gpt_ent * partition,␊ |
166 | UInt32 partitionID );␊ |
167 | ␊ |
168 | #ifndef __LP64__␊ |
169 | /*␊ |
170 | * Attach the given media object to the device tree plane.␊ |
171 | */␊ |
172 | ␊ |
173 | virtual bool attachMediaObjectToDeviceTree(IOMedia * media) __attribute__ ((deprecated));␊ |
174 | ␊ |
175 | /*␊ |
176 | * Detach the given media object from the device tree plane.␊ |
177 | */␊ |
178 | ␊ |
179 | virtual void detachMediaObjectFromDeviceTree(IOMedia * media) __attribute__ ((deprecated));␊ |
180 | #endif /* !__LP64__ */␊ |
181 | ␊ |
182 | public:␊ |
183 | ␊ |
184 | /*␊ |
185 | * Initialize this object's minimal state.␊ |
186 | */␊ |
187 | ␊ |
188 | virtual bool init(OSDictionary * properties = 0);␊ |
189 | ␊ |
190 | /*␊ |
191 | * Determine whether the provider media contains a GUID partition map.␊ |
192 | */␊ |
193 | ␊ |
194 | virtual IOService * probe(IOService * provider, SInt32 * score);␊ |
195 | ␊ |
196 | /*␊ |
197 | * Publish the new media objects which represent our partitions.␊ |
198 | */␊ |
199 | ␊ |
200 | virtual bool start(IOService * provider);␊ |
201 | ␊ |
202 | /*␊ |
203 | * Clean up after the media objects we published before terminating.␊ |
204 | */␊ |
205 | ␊ |
206 | virtual void stop(IOService * provider);␊ |
207 | ␊ |
208 | /*␊ |
209 | * Request that the provider media be re-scanned for partitions.␊ |
210 | */␊ |
211 | ␊ |
212 | virtual IOReturn requestProbe(IOOptionBits options);␊ |
213 | ␊ |
214 | OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 0);␊ |
215 | OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 1);␊ |
216 | OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 2);␊ |
217 | OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 3);␊ |
218 | OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 4);␊ |
219 | OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 5);␊ |
220 | OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 6);␊ |
221 | OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 7);␊ |
222 | OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 8);␊ |
223 | OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 9);␊ |
224 | OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 10);␊ |
225 | OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 11);␊ |
226 | OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 12);␊ |
227 | OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 13);␊ |
228 | OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 14);␊ |
229 | OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 15);␊ |
230 | };␊ |
231 | ␊ |
232 | #endif /* __cplusplus */␊ |
233 | #endif /* KERNEL */␊ |
234 | #endif /* !_IOGUIDPARTITIONSCHEME_H */␊ |
235 |