2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
23 #ifndef _IOAPPLEPARTITIONSCHEME_H
24 #define _IOAPPLEPARTITIONSCHEME_H
26 #include <IOKit/IOTypes.h>
29 * Apple Partition Map Definitions
32 #pragma pack(2) /* (enable 16-bit struct packing for dpme, DDMap, Block0) */
34 /* Structure constants. */
38 /* Partition map entry, as found in blocks 1 to dpme_map_entries of the disk. */
42 UInt16 dpme_signature
; /* (unique value for partition entry, 'PM') */
43 UInt16 dpme_reserved_1
; /* (reserved for future use) */
44 UInt32 dpme_map_entries
; /* (number of partition entries) */
45 UInt32 dpme_pblock_start
; /* (physical block start of partition) */
46 UInt32 dpme_pblocks
; /* (physical block count of partition) */
47 char dpme_name
[DPISTRLEN
]; /* (name of partition) */
48 char dpme_type
[DPISTRLEN
]; /* (type of partition, eg. Apple_HFS) */
49 UInt32 dpme_lblock_start
; /* (logical block start of partition) */
50 UInt32 dpme_lblocks
; /* (logical block count of partition) */
51 UInt32 dpme_flags
; /* (partition flags, see defines below) */
52 UInt32 dpme_boot_block
; /* (logical block start of boot code) */
53 UInt32 dpme_boot_bytes
; /* (byte count of boot code) */
54 UInt8
* dpme_load_addr
; /* (load address in memory of boot code) */
55 UInt8
* dpme_load_addr_2
; /* (reserved for future use) */
56 UInt8
* dpme_goto_addr
; /* (jump address in memory of boot code) */
57 UInt8
* dpme_goto_addr_2
; /* (reserved for future use) */
58 UInt32 dpme_checksum
; /* (checksum of boot code) */
59 UInt8 dpme_process_id
[16]; /* (processor type) */
60 UInt32 dpme_reserved_2
[32]; /* (reserved for future use) */
61 UInt32 dpme_reserved_3
[62]; /* (reserved for future use) */
64 /* Driver descriptor map entry. */
68 UInt32 ddBlock
; /* (driver's block start, sbBlkSize-blocks) */
69 UInt16 ddSize
; /* (driver's block count, 512-blocks) */
70 UInt16 ddType
; /* (driver's system type) */
73 /* Driver descriptor map, as found in block zero of the disk. */
77 UInt16 sbSig
; /* (unique value for block zero, 'ER') */
78 UInt16 sbBlkSize
; /* (block size for this device) */
79 UInt32 sbBlkCount
; /* (block count for this device) */
80 UInt16 sbDevType
; /* (device type) */
81 UInt16 sbDevId
; /* (device id) */
82 UInt32 sbDrvrData
; /* (driver data) */
83 UInt16 sbDrvrCount
; /* (driver descriptor count) */
84 DDMap sbDrvrMap
[8]; /* (driver descriptor table) */
85 UInt8 sbReserved
[430]; /* (reserved for future use) */
88 /* Partition map signature (sbSig). */
90 #define BLOCK0_SIGNATURE 0x4552
92 /* Partition map entry signature (dpme_signature). */
94 #define DPME_SIGNATURE 0x504D
96 /* Partition map entry flags (dpme_flags). */
98 #define DPME_FLAGS_VALID 0x00000001 /* (bit 0) */
99 #define DPME_FLAGS_ALLOCATED 0x00000002 /* (bit 1) */
100 #define DPME_FLAGS_IN_USE 0x00000004 /* (bit 2) */
101 #define DPME_FLAGS_BOOTABLE 0x00000008 /* (bit 3) */
102 #define DPME_FLAGS_READABLE 0x00000010 /* (bit 4) */
103 #define DPME_FLAGS_WRITABLE 0x00000020 /* (bit 5) */
104 #define DPME_FLAGS_OS_PIC_CODE 0x00000040 /* (bit 6) */
105 #define DPME_FLAGS_OS_SPECIFIC_2 0x00000080 /* (bit 7) */
106 #define DPME_FLAGS_OS_SPECIFIC_1 0x00000100 /* (bit 8) */
107 #define DPME_FLAGS_RESERVED_2 0xFFFFFE00 /* (bit 9..31) */
109 #pragma options align=reset /* (reset to default struct packing) */
115 #if defined(KERNEL) && defined(__cplusplus)
117 #include <IOKit/storage/IOPartitionScheme.h>
123 class IOApplePartitionScheme
: public IOPartitionScheme
125 OSDeclareDefaultStructors(IOApplePartitionScheme
);
129 struct ExpansionData
{ /* */ };
130 ExpansionData
* _expansionData
;
132 OSSet
* _partitions
; /* (set of media objects representing partitions) */
135 * Free all of this object's outstanding resources.
138 virtual void free(void);
141 * Scan the provider media for an Apple partition map. Returns the set
142 * of media objects representing each of the partitions (the retain for
143 * the set is passed to the caller), or null should no partition map be
144 * found. The default probe score can be adjusted up or down, based on
145 * the confidence of the scan.
148 virtual OSSet
* scan(SInt32
* score
);
151 * Ask whether the given partition appears to be corrupt. A partition that
152 * is corrupt will cause the failure of the Apple partition map recognition
156 virtual bool isPartitionCorrupt( dpme
* partition
,
158 UInt32 partitionBlockSize
);
161 * Ask whether the given partition appears to be invalid. A partition that
162 * is invalid will cause it to be skipped in the scan, but will not cause a
163 * failure of the Apple partition map recognition.
166 virtual bool isPartitionInvalid( dpme
* partition
,
168 UInt32 partitionBlockSize
);
171 * Instantiate a new media object to represent the given partition.
174 virtual IOMedia
* instantiateMediaObject( dpme
* partition
,
176 UInt32 partitionBlockSize
);
179 * Allocate a new media object (called from instantiateMediaObject).
182 virtual IOMedia
* instantiateDesiredMediaObject(
185 UInt32 partitionBlockSize
);
188 * Attach the given media object to the device tree plane.
191 virtual bool attachMediaObjectToDeviceTree(IOMedia
* media
);
194 * Detach the given media object from the device tree plane.
197 virtual void detachMediaObjectFromDeviceTree(IOMedia
* media
);
202 * Initialize this object's minimal state.
205 virtual bool init(OSDictionary
* properties
= 0);
208 * Determine whether the provider media contains an Apple partition map.
211 virtual IOService
* probe(IOService
* provider
, SInt32
* score
);
214 * Publish the new media objects which represent our partitions.
217 virtual bool start(IOService
* provider
);
220 * Clean up after the media objects we published before terminating.
223 virtual void stop(IOService
* provider
);
225 OSMetaClassDeclareReservedUnused(IOApplePartitionScheme
, 0);
226 OSMetaClassDeclareReservedUnused(IOApplePartitionScheme
, 1);
227 OSMetaClassDeclareReservedUnused(IOApplePartitionScheme
, 2);
228 OSMetaClassDeclareReservedUnused(IOApplePartitionScheme
, 3);
229 OSMetaClassDeclareReservedUnused(IOApplePartitionScheme
, 4);
230 OSMetaClassDeclareReservedUnused(IOApplePartitionScheme
, 5);
231 OSMetaClassDeclareReservedUnused(IOApplePartitionScheme
, 6);
232 OSMetaClassDeclareReservedUnused(IOApplePartitionScheme
, 7);
233 OSMetaClassDeclareReservedUnused(IOApplePartitionScheme
, 8);
234 OSMetaClassDeclareReservedUnused(IOApplePartitionScheme
, 9);
235 OSMetaClassDeclareReservedUnused(IOApplePartitionScheme
, 10);
236 OSMetaClassDeclareReservedUnused(IOApplePartitionScheme
, 11);
237 OSMetaClassDeclareReservedUnused(IOApplePartitionScheme
, 12);
238 OSMetaClassDeclareReservedUnused(IOApplePartitionScheme
, 13);
239 OSMetaClassDeclareReservedUnused(IOApplePartitionScheme
, 14);
240 OSMetaClassDeclareReservedUnused(IOApplePartitionScheme
, 15);
243 #endif /* defined(KERNEL) && defined(__cplusplus) */
245 #endif /* !_IOAPPLEPARTITIONSCHEME_H */