1/* 2 * Copyright (c) 2000-2008 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// AppleCDDAFileSystemDefines.h created by CJS on Mon 10-Apr-2000 25 26#ifndef __APPLE_CDDA_FS_DEFINES_H__ 27#define __APPLE_CDDA_FS_DEFINES_H__ 28 29#ifndef __AIFF_SUPPORT_H__ 30#include "AIFFSupport.h" 31#endif 32 33#ifdef __cplusplus 34extern "C" { 35#endif 36 37#include <sys/types.h> 38#include <sys/param.h> 39#include <sys/mount.h> 40#include <sys/stat.h> 41#include <sys/attr.h> 42#include <libkern/OSTypes.h> 43 44#if KERNEL 45#include <sys/systm.h> 46#endif 47 48 49// Enums for Control field in SubChannelQ 50enum 51{ 52 kPreEmphasisBit = 0, 53 kDigitalDataBit = 2 54}; 55 56enum 57{ 58 kPreEmphasisMask = ( 1 << kPreEmphasisBit ), 59 kDigitalDataMask = ( 1 << kDigitalDataBit ) 60}; 61 62 63// Time constants 64enum 65{ 66 kSecondsPerMinute = 60, 67 kFramesPerSecond = 75, 68 kMSFToLBA = (kFramesPerSecond << 1) // 2 seconds 69}; 70 71 72// Node types 73enum cddaNodeType 74{ 75 kAppleCDDADirectoryType = 1, 76 kAppleCDDATrackType = 2, 77 kAppleCDDAXMLFileType = 3 78}; 79 80 81// File references 82enum 83{ 84 kAppleCDDANumberOfFileReferences = 1, 85 kAppleCDDANumberOfRootDirReferences = 2 86}; 87 88 89// Flags 90enum 91{ 92 kAppleCDDANodeBusyBit = 0, 93 kAppleCDDANodeWantedBit = 1, 94 kAppleCDDANodeBusyMask = ( 1 << kAppleCDDANodeBusyBit ), 95 kAppleCDDANodeWantedMask = ( 1 << kAppleCDDANodeWantedBit ) 96}; 97 98 99// ".TOC.plist" file stuff 100enum 101{ 102 kAppleCDDAXMLFileID = 3 103}; 104 105enum 106{ 107 kUnknownUserID = 99, 108 kUnknownGroupID = 99 109}; 110 111enum 112{ 113 kCDDAMaxFileNameBytes = 3 * 255 114}; 115 116 117//----------------------------------------------------------------------------- 118// FinderInfo flags and structures 119//----------------------------------------------------------------------------- 120 121enum 122{ 123 kFinderInfoOnDesktopBit = 0, 124 kFinderInfoOwnApplBit = 1, 125 kFinderInfoNoFileExtensionBit = 4, 126 kFinderInfoSharedBit = 6, 127 kFinderInfoCachedBit = 7, 128 kFinderInfoInitedBit = 8, 129 kFinderInfoChangedBit = 9, 130 kFinderInfoBusyBit = 10, 131 kFinderInfoNoCopyBit = 11, 132 kFinderInfoSystemBit = 12, 133 kFinderInfoHasBundleBit = 13, 134 kFinderInfoInvisibleBit = 14, 135 kFinderInfoLockedBit = 15 136}; 137 138enum 139{ 140 kFinderInfoOnDesktopMask = (1 << kFinderInfoOnDesktopBit), 141 kFinderInfoOwnApplMask = (1 << kFinderInfoOwnApplBit), 142 kFinderInfoNoFileExtensionMask = (1 << kFinderInfoNoFileExtensionBit), 143 kFinderInfoSharedMask = (1 << kFinderInfoSharedBit), 144 kFinderInfoCachedMask = (1 << kFinderInfoCachedBit), 145 kFinderInfoInitedMask = (1 << kFinderInfoInitedBit), 146 kFinderInfoChangedMask = (1 << kFinderInfoChangedBit), 147 kFinderInfoBusyMask = (1 << kFinderInfoBusyBit), 148 kFinderInfoNoCopyMask = (1 << kFinderInfoNoCopyBit), 149 kFinderInfoSystemMask = (1 << kFinderInfoSystemBit), 150 kFinderInfoHasBundleMask = (1 << kFinderInfoHasBundleBit), 151 kFinderInfoInvisibleMask = (1 << kFinderInfoInvisibleBit), 152 kFinderInfoLockedMask = (1 << kFinderInfoLockedBit) 153}; 154 155#define kExtendedFinderInfoSize 16 156 157struct FinderInfo 158{ 159 UInt32 fileType; 160 UInt32 fileCreator; 161 UInt16 finderFlags; 162 struct 163 { 164 SInt16 v; /* file's location */ 165 SInt16 h; 166 } location; 167 UInt16 reserved; 168}; 169typedef struct FinderInfo FinderInfo; 170 171 172enum 173{ 174 175 kAppleCDDACommonAttributesValidMask = ATTR_CMN_NAME | ATTR_CMN_DEVID | ATTR_CMN_FSID | 176 ATTR_CMN_OBJTYPE | ATTR_CMN_OBJTAG | ATTR_CMN_OBJID | 177 ATTR_CMN_OBJPERMANENTID | ATTR_CMN_PAROBJID | ATTR_CMN_SCRIPT | 178 ATTR_CMN_CRTIME | ATTR_CMN_MODTIME | ATTR_CMN_CHGTIME | 179 ATTR_CMN_ACCTIME | ATTR_CMN_BKUPTIME | ATTR_CMN_FNDRINFO | 180 ATTR_CMN_OWNERID | ATTR_CMN_GRPID | ATTR_CMN_ACCESSMASK | 181 ATTR_CMN_FLAGS | ATTR_CMN_USERACCESS, 182 183 kAppleCDDAVolumeAttributesValidMask = ATTR_VOL_FSTYPE | ATTR_VOL_SIGNATURE | ATTR_VOL_SIZE | 184 ATTR_VOL_SPACEFREE | ATTR_VOL_SPACEAVAIL | 185 ATTR_VOL_MINALLOCATION | ATTR_VOL_ALLOCATIONCLUMP | 186 ATTR_VOL_IOBLOCKSIZE | ATTR_VOL_OBJCOUNT | ATTR_VOL_FILECOUNT | 187 ATTR_VOL_DIRCOUNT | ATTR_VOL_MAXOBJCOUNT | 188 ATTR_VOL_MOUNTPOINT | ATTR_VOL_NAME | ATTR_VOL_MOUNTFLAGS | 189 ATTR_VOL_MOUNTEDDEVICE | ATTR_VOL_ENCODINGSUSED | 190 ATTR_VOL_CAPABILITIES | ATTR_VOL_ATTRIBUTES | ATTR_VOL_INFO, 191 192 kAppleCDDADirectoryAttributesValidMask = ATTR_DIR_LINKCOUNT | ATTR_DIR_ENTRYCOUNT | ATTR_DIR_MOUNTSTATUS, 193 194 kAppleCDDAFileAttributesValidMask = ATTR_FILE_LINKCOUNT | ATTR_FILE_TOTALSIZE | ATTR_FILE_ALLOCSIZE | 195 ATTR_FILE_IOBLOCKSIZE | ATTR_FILE_CLUMPSIZE | ATTR_FILE_DEVTYPE | 196 ATTR_FILE_DATALENGTH | ATTR_FILE_DATAALLOCSIZE | 197 ATTR_FILE_RSRCLENGTH | ATTR_FILE_RSRCALLOCSIZE, 198 199 kAppleCDDAForkAttributesValidMask = 0x00000000 200 201}; 202 203enum 204{ 205 kAppleCDDAFileSystemVolumeSignature = 0x4244, // 'BD' 206 kAppleCDDAFileSystemVCBFSID = 0x4A48 // 'JH' 207}; 208 209 210//----------------------------------------------------------------------------- 211// SubQTOCInfo - Structure which describes the SubQTOCInfo defined in 212// MMC-2 NCITS T10/1228D SCSI MultiMedia Commands Version 2 213// rev 9.F April 1, 1999, p. 215 214// ATAPI SFF-8020 rev 1.2 Feb 24, 1994, p. 149 215//----------------------------------------------------------------------------- 216 217 218struct SubQTOCInfo 219{ 220 221 UInt8 sessionNumber; 222#if defined(__BIG_ENDIAN__) 223 UInt8 address:4; 224 UInt8 control:4; 225#elif defined(__LITTLE_ENDIAN__) 226 UInt8 control:4; 227 UInt8 address:4; 228#else 229#error Unknown byte order 230#endif /* __LITTLE_ENDIAN__ */ 231 UInt8 tno; 232 UInt8 point; 233 UInt8 ATIP[3]; 234 UInt8 zero; 235 union { 236 237 struct { 238 UInt8 minutes; 239 UInt8 seconds; 240 UInt8 frames; 241 } startPosition; 242 243 struct { 244 UInt8 firstTrackNum; 245 UInt8 discType; 246 UInt8 reserved; 247 } A0PMSF; 248 249 struct { 250 UInt8 lastTrackNum; 251 UInt8 reserved[2]; 252 } A1PMSF; 253 254 struct { 255 UInt8 minutes; 256 UInt8 seconds; 257 UInt8 frames; 258 } leadOutStartPosition; 259 260 } PMSF; 261 262}; 263typedef struct SubQTOCInfo SubQTOCInfo; 264typedef struct SubQTOCInfo * SubQTOCInfoPtr; 265 266 267//----------------------------------------------------------------------------- 268// QTOCDataFormat10 - Structure which describes the QTOCDataFormat10 defined in 269// MMC-2 NCITS T10/1228D SCSI MultiMedia Commands Version 2 270// rev 9.F April 1, 1999, p. 215 271// ATAPI SFF-8020 rev 1.2 Feb 24, 1994, p. 149 272//----------------------------------------------------------------------------- 273 274 275struct QTOCDataFormat10 276{ 277 UInt16 TOCDataLength; 278 UInt8 firstSessionNumber; 279 UInt8 lastSessionNumber; 280 SubQTOCInfo trackDescriptors[1]; 281}; 282typedef struct QTOCDataFormat10 QTOCDataFormat10; 283typedef struct QTOCDataFormat10 * QTOCDataFormat10Ptr; 284 285 286//----------------------------------------------------------------------------- 287// AppleCDDAArguments - These are the arguments passed to the filesystem 288// at mount time 289//----------------------------------------------------------------------------- 290 291struct AppleCDDAArguments 292{ 293#ifndef KERNEL 294 char * device; 295#endif 296 UInt32 numTracks; // Number of audio tracks 297 user_addr_t nameData; // Buffer for track names and album name 298 UInt32 nameDataSize; // Size of buffer 299 user_addr_t xmlData; // Pointer to XML data 300 UInt32 xmlFileSize; // Size of XML plist-style buffer/file 301 UInt32 fileType; // Type in FOUR_CHAR_CODE 302 UInt32 fileCreator; // Creator in FOUR_CHAR_CODE 303} __attribute__((packed)); 304typedef struct AppleCDDAArguments AppleCDDAArguments; 305 306 307 308#define kMaxNameSize 257 309#define kMaxTrackCount 99 310#define kMaxNameDataSize ((kMaxNameSize * kMaxTrackCount) + PAGE_SIZE) 311 312#define kMaxXMLDataSize PAGE_SIZE * 10 // 40K = Arbitrary size. Definitely shouldn't be bigger than this... 313 314 315#if KERNEL 316 317//----------------------------------------------------------------------------- 318// AppleCDDANodeInfo - Structure used to store node information 319//----------------------------------------------------------------------------- 320 321 322struct AppleCDDANodeInfo 323{ 324 vnode_t vNodePtr; // Ptr to vnode 325 UInt8 nameSize; // Size of the name 326 char * name; // The name 327 SubQTOCInfo trackDescriptor; // TOC info for a node 328 UInt32 LBA; // Logical Block Address on disc 329 UInt32 numBytes; // File size in number of bytes 330 UInt32 flags; // Flags 331}; 332typedef struct AppleCDDANodeInfo AppleCDDANodeInfo; 333typedef struct AppleCDDANodeInfo * AppleCDDANodeInfoPtr; 334 335 336//----------------------------------------------------------------------------- 337// AppleCDDAMount - Private Mount data 338//----------------------------------------------------------------------------- 339 340 341struct AppleCDDAMount 342{ 343 vnode_t root; // Root VNode 344 UInt32 rootVID; // Root VNode ID 345 vnode_t xmlFileVNodePtr; // XMLFile VNode 346 UInt32 xmlFileFlags; // Flags 347 UInt32 nameDataSize; // Size of buffer 348 UInt8 * nameData; // Buffer for track names and album name 349 AppleCDDANodeInfoPtr nodeInfoArrayPtr; // Ptr to NodeInfo array 350 lck_grp_t * cddaMountLockGroup; // Lock group 351 lck_grp_attr_t * cddaMountLockGroupAttr; // Lock group attributes 352 lck_mtx_t * cddaMountLock; // Locks access to AppleCDDAMount structures and NodeInfo array 353 lck_attr_t * cddaMountLockAttr; // Lock attributes 354 UInt8 numTracks; // Number of audio tracks 355 struct timespec mountTime; // The time we were mounted 356 UInt32 xmlDataSize; // XML data size 357 UInt8 * xmlData; // XML data ptr 358 UInt32 fileType; // Type in FOUR_CHAR_CODE 359 UInt32 fileCreator; // Creator in FOUR_CHAR_CODE 360}; 361typedef struct AppleCDDAMount AppleCDDAMount; 362typedef struct AppleCDDAMount * AppleCDDAMountPtr; 363 364 365//----------------------------------------------------------------------------- 366// AppleCDDADirectoryNode - Structure which describes everything about 367// one of our directory nodes 368//----------------------------------------------------------------------------- 369 370 371struct AppleCDDADirectoryNode 372{ 373 UInt32 entryCount; // Number of directory entries 374 UInt64 directorySize; // Size of the directory 375}; 376typedef struct AppleCDDADirectoryNode AppleCDDADirectoryNode; 377typedef struct AppleCDDADirectoryNode * AppleCDDADirectoryNodePtr; 378 379 380//----------------------------------------------------------------------------- 381// AppleCDDAFileNode - Structure which describes everything about one of 382// our track nodes 383//----------------------------------------------------------------------------- 384 385 386struct AppleCDDAFileNode 387{ 388 CDAIFFHeader aiffHeader; // AIFF File Header 389 AppleCDDANodeInfoPtr nodeInfoPtr; // Ptr to AppleCDDANodeInfo about this track 390}; 391typedef struct AppleCDDAFileNode AppleCDDAFileNode; 392typedef struct AppleCDDAFileNode * AppleCDDAFileNodePtr; 393 394 395//----------------------------------------------------------------------------- 396// AppleCDDAXMLFileNode - Used to handle the ".TOC.plist" file 397//----------------------------------------------------------------------------- 398 399 400struct AppleCDDAXMLFileNode 401{ 402 UInt32 fileSize; // size of the XML file 403 UInt8 * fileDataPtr; // Ptr to file data 404}; 405typedef struct AppleCDDAXMLFileNode AppleCDDAXMLFileNode; 406typedef struct AppleCDDAXMLFileNode * AppleCDDAXMLFileNodePtr; 407 408 409//----------------------------------------------------------------------------- 410// AppleCDDANode - Structure which describes everything about one of 411// our nodes 412//----------------------------------------------------------------------------- 413 414 415struct AppleCDDANode 416{ 417 enum cddaNodeType nodeType; // Node type: directory or track 418 vnode_t vNodePtr; // Pointer to vnode this node is "hung-off" 419 vnode_t blockDeviceVNodePtr; // block device vnode pointer 420 UInt32 nodeID; // Node ID 421 union 422 { 423 AppleCDDADirectoryNode directory; 424 AppleCDDAFileNode file; 425 AppleCDDAXMLFileNode xmlFile; 426 } u; 427}; 428typedef struct AppleCDDANode AppleCDDANode; 429typedef struct AppleCDDANode * AppleCDDANodePtr; 430 431 432//----------------------------------------------------------------------------- 433// Conversion Macros 434//----------------------------------------------------------------------------- 435 436#define VFSTOCDDA(mp) ((AppleCDDAMountPtr)(vfs_fsprivate(mp))) 437#define VTOCDDA(vp) ((AppleCDDANodePtr)(vnode_fsnode(vp))) 438#define CDDATOV(cddaNodePtr) ((cddaNodePtr)->vNodePtr) 439#define CDDATONODEINFO(cddaNodePtr) ((cddaNodePtr)->u.file.nodeInfoPtr) 440#define VFSTONODEINFO(mp) ((AppleCDDANodeInfoPtr)((AppleCDDAMountPtr)(vfs_fsprivate(mp)))->nodeInfoArrayPtr) 441#define VFSTONAMEINFO(mp) ((UInt8 *)((AppleCDDAMountPtr)(vfs_fsprivate(mp)))->nameData) 442#define VFSTOXMLDATA(mp) ((UInt8 *)((AppleCDDAMountPtr)(vfs_fsprivate(mp)))->xmlData) 443 444#endif /* KERNEL */ 445 446#ifdef __cplusplus 447} 448#endif 449 450 451#endif // __APPLE_CDDA_FS_DEFINES_H__