]>
git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/storage/IONeXTPartitionScheme.h
3172c6bd02a3374ca2dd912c14b663731c685731
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 _IONEXTPARTITIONSCHEME_H
24 #define _IONEXTPARTITIONSCHEME_H
26 #include <IOKit/IOTypes.h>
29 * NeXT Partition Map Definitions
32 #pragma pack(2) /* (enable 16-bit struct packing for dl_un, disk[tab,_label]) */
34 #include <sys/disktab.h>
36 /* Structure constants. */
38 #define MAXLBLLEN 24 /* (length of disk name) */
39 #define NBAD 1670 /* (size of bad sector table in map) */
40 #define NLABELS 4 /* (number of partition maps on disk) */
42 /* Structure aliases, for disktab and dl_un fields. */
44 #define dl_name dl_dt.d_name
45 #define dl_type dl_dt.d_type
46 #define dl_part dl_dt.d_partitions
47 #define dl_front dl_dt.d_front
48 #define dl_back dl_dt.d_back
49 #define dl_ngroups dl_dt.d_ngroups
50 #define dl_ag_size dl_dt.d_ag_size
51 #define dl_ag_alts dl_dt.d_ag_alts
52 #define dl_ag_off dl_dt.d_ag_off
53 #define dl_secsize dl_dt.d_secsize
54 #define dl_ncyl dl_dt.d_ncylinders
55 #define dl_nsect dl_dt.d_nsectors
56 #define dl_ntrack dl_dt.d_ntracks
57 #define dl_rpm dl_dt.d_rpm
58 #define dl_bootfile dl_dt.d_bootfile
59 #define dl_boot0_blkno dl_dt.d_boot0_blkno
60 #define dl_hostname dl_dt.d_hostname
61 #define dl_rootpartition dl_dt.d_rootpartition
62 #define dl_rwpartition dl_dt.d_rwpartition
63 #define dl_v3_checksum dl_un.DL_v3_checksum
64 #define dl_bad dl_un.DL_bad
66 /* Partition map, as found in block zero (or a redundant block) of the disk. */
70 UInt16 DL_v3_checksum
; /* (V3: ones complement checksum) */
71 SInt32 DL_bad
[NBAD
]; /* (V1-V2: bad sector table) */
74 typedef struct disk_label
76 SInt32 dl_version
; /* (unique signature for map) */
77 SInt32 dl_label_blkno
; /* (block on which this map resides) */
78 SInt32 dl_size
; /* (device block count) */
79 char dl_label
[MAXLBLLEN
]; /* (device name) */
80 UInt32 dl_flags
; /* (device flags) */
81 UInt32 dl_tag
; /* (device tag) */
82 struct disktab dl_dt
; /* (device info, partition entries) */
84 UInt16 dl_checksum
; /* (V1-V2: ones complement checksum) */
86 /* (add things here so dl_checksum stays in a fixed place) */
89 /* Partition map signature (dl_version). */
91 #define DL_V1 0x4e655854 /* (version 1: "NeXT") */
92 #define DL_V2 0x646c5632 /* (version 2: "dlV2") */
93 #define DL_V3 0x646c5633 /* (version 3: "dlV3") */
94 #define DL_VERSION DL_V3 /* (default version) */
96 /* Partition map flags (dl_flags). */
98 #define DL_UNINIT 0x80000000 /* (is uninitialized?) */
100 #pragma options align=reset /* (reset to default struct packing) */
106 #if defined(KERNEL) && defined(__cplusplus)
108 #include <IOKit/storage/IOPartitionScheme.h>
114 class IONeXTPartitionScheme
: public IOPartitionScheme
116 OSDeclareDefaultStructors(IONeXTPartitionScheme
);
121 * Compute a 16-bit (big-endian) checksum over the specified data range.
124 UInt16
checksum16(void * data
, UInt32 bytes
) const;
128 struct ExpansionData
{ /* */ };
129 ExpansionData
* _expansionData
;
131 OSSet
* _partitions
; /* (set of media objects representing partitions) */
134 * Free all of this object's outstanding resources.
137 virtual void free(void);
140 * Scan the provider media for a NeXT partition map. Returns the set
141 * of media objects representing each of the partitions (the retain for
142 * the set is passed to the caller), or null should no partition map be
143 * found. The default probe score can be adjusted up or down, based on
144 * the confidence of the scan.
147 virtual OSSet
* scan(SInt32
* score
);
150 * Ask whether the given partition is used.
153 virtual bool isPartitionUsed(partition_t
* partition
);
156 * Ask whether the given partition appears to be corrupt. A partition that
157 * is corrupt will cause the failure of the NeXT partition map recognition
161 virtual bool isPartitionCorrupt( partition_t
* partition
,
164 disk_label_t
* nextMap
);
167 * Ask whether the given partition appears to be invalid. A partition that
168 * is invalid will cause it to be skipped in the scan, but will not cause a
169 * failure of the NeXT partition map recognition.
172 virtual bool isPartitionInvalid( partition_t
* partition
,
175 disk_label_t
* nextMap
);
178 * Instantiate a new media object to represent the given partition.
181 virtual IOMedia
* instantiateMediaObject( partition_t
* partition
,
184 disk_label_t
* nextMap
);
187 * Allocate a new media object (called from instantiateMediaObject).
190 virtual IOMedia
* instantiateDesiredMediaObject( partition_t
* partition
,
193 disk_label_t
* nextMap
);
198 * Initialize this object's minimal state.
201 virtual bool init(OSDictionary
* properties
= 0);
204 * Determine whether the provider media contains a NeXT partition map.
207 virtual IOService
* probe(IOService
* provider
, SInt32
* score
);
210 * Publish the new media objects which represent our partitions.
213 virtual bool start(IOService
* provider
);
215 OSMetaClassDeclareReservedUnused(IONeXTPartitionScheme
, 0);
216 OSMetaClassDeclareReservedUnused(IONeXTPartitionScheme
, 1);
217 OSMetaClassDeclareReservedUnused(IONeXTPartitionScheme
, 2);
218 OSMetaClassDeclareReservedUnused(IONeXTPartitionScheme
, 3);
219 OSMetaClassDeclareReservedUnused(IONeXTPartitionScheme
, 4);
220 OSMetaClassDeclareReservedUnused(IONeXTPartitionScheme
, 5);
221 OSMetaClassDeclareReservedUnused(IONeXTPartitionScheme
, 6);
222 OSMetaClassDeclareReservedUnused(IONeXTPartitionScheme
, 7);
223 OSMetaClassDeclareReservedUnused(IONeXTPartitionScheme
, 8);
224 OSMetaClassDeclareReservedUnused(IONeXTPartitionScheme
, 9);
225 OSMetaClassDeclareReservedUnused(IONeXTPartitionScheme
, 10);
226 OSMetaClassDeclareReservedUnused(IONeXTPartitionScheme
, 11);
227 OSMetaClassDeclareReservedUnused(IONeXTPartitionScheme
, 12);
228 OSMetaClassDeclareReservedUnused(IONeXTPartitionScheme
, 13);
229 OSMetaClassDeclareReservedUnused(IONeXTPartitionScheme
, 14);
230 OSMetaClassDeclareReservedUnused(IONeXTPartitionScheme
, 15);
233 #endif /* defined(KERNEL) && defined(__cplusplus) */
235 #endif /* !_IONEXTPARTITIONSCHEME_H */