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 * IOFireWireLibPriv.h 24 * IOFireWireLib 25 * 26 * Created on Fri Apr 28 2000. 27 * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. 28 * 29 */ 30/* 31 $Log: IOFireWireLibPriv.h,v $ 32 Revision 1.70 2009/01/16 02:53:19 collin 33 and finally put TOT back... 34 35 Revision 1.66 2009/01/15 01:40:02 collin 36 <rdar://problem/6400981> BRB-VERIFY: 10A222: Trying to record a movie through QT X, getting error message. 37 38 Revision 1.65 2008/12/12 04:43:57 collin 39 user space compare swap command fixes 40 41 Revision 1.64 2008/11/26 23:55:21 collin 42 fix user physical address spaces on K64 43 44 Revision 1.63 2007/10/16 16:50:21 ayanowit 45 Removed existing "work-in-progress" support for buffer-fill isoch. 46 47 Revision 1.62 2007/08/24 01:14:31 collin 48 fix resp code on sync command execution 49 50 Revision 1.61 2007/05/12 01:10:45 arulchan 51 Asyncstream transmit command interface 52 53 Revision 1.60 2007/04/28 01:42:35 collin 54 *** empty log message *** 55 56 Revision 1.59 2007/04/24 02:50:09 collin 57 *** empty log message *** 58 59 Revision 1.58 2007/03/22 00:30:01 collin 60 *** empty log message *** 61 62 Revision 1.57 2007/03/10 07:48:25 collin 63 *** empty log message *** 64 65 Revision 1.56 2007/03/10 05:11:36 collin 66 *** empty log message *** 67 68 Revision 1.55 2007/03/10 02:58:03 collin 69 *** empty log message *** 70 71 Revision 1.54 2007/03/09 23:57:53 collin 72 *** empty log message *** 73 74 Revision 1.53 2007/03/08 02:37:13 collin 75 *** empty log message *** 76 77 Revision 1.52 2007/02/16 19:04:21 arulchan 78 *** empty log message *** 79 80 Revision 1.51 2007/02/16 00:28:26 ayanowit 81 More work on IRMAllocation APIs 82 83 Revision 1.50 2007/02/09 20:36:46 ayanowit 84 More Leopard IRMAllocation changes. 85 86 Revision 1.49 2007/02/07 01:35:36 collin 87 *** empty log message *** 88 89 Revision 1.48 2007/02/06 01:08:41 ayanowit 90 More work on Leopard features such as new User-space IRM allocation APIs. 91 92 Revision 1.47 2007/01/26 20:52:32 ayanowit 93 changes to user-space isoch stuff to support 64-bit apps. 94 95 Revision 1.46 2007/01/24 04:10:14 collin 96 *** empty log message *** 97 98 Revision 1.45 2007/01/16 02:41:25 collin 99 *** empty log message *** 100 101 Revision 1.44 2007/01/11 08:48:24 collin 102 *** empty log message *** 103 104 Revision 1.43 2007/01/06 06:20:44 collin 105 *** empty log message *** 106 107 Revision 1.42 2007/01/05 04:56:31 collin 108 *** empty log message *** 109 110 Revision 1.41 2007/01/04 21:59:38 ayanowit 111 more changes for 64-bit apps. 112 113 Revision 1.40 2007/01/04 04:07:25 collin 114 *** empty log message *** 115 116 Revision 1.39 2006/12/06 00:01:10 arulchan 117 Isoch Channel 31 Generic Receiver 118 119 Revision 1.38 2006/11/29 18:42:53 ayanowit 120 Modified the IOFireWireUserClient to use the Leopard externalMethod method of dispatch. 121 122 Revision 1.37 2006/02/09 00:21:55 niels 123 merge chardonnay branch to tot 124 125 Revision 1.36 2005/09/24 00:55:28 niels 126 *** empty log message *** 127 128 Revision 1.35 2005/04/02 02:43:46 niels 129 exporter works outside IOFireWireFamily 130 131 Revision 1.34.6.3 2006/01/31 04:49:57 collin 132 *** empty log message *** 133 134 Revision 1.34.6.1 2006/01/17 00:35:00 niels 135 <rdar://problem/4399365> FireWire NuDCL APIs need Rosetta support 136 137 Revision 1.34 2004/05/04 22:52:20 niels 138 *** empty log message *** 139 140 Revision 1.33 2004/01/22 01:50:01 niels 141 fix user space physical address space getPhysicalSegments 142 143 Revision 1.32 2003/12/19 22:07:46 niels 144 send force stop when channel dies/system sleeps 145 146 Revision 1.31 2003/11/07 21:01:19 niels 147 *** empty log message *** 148 149 Revision 1.30 2003/11/03 19:11:37 niels 150 fix local config rom reading; fix 3401223 151 152 Revision 1.29 2003/08/26 05:11:22 niels 153 *** empty log message *** 154 155 Revision 1.28 2003/08/25 08:39:17 niels 156 *** empty log message *** 157 158 Revision 1.27 2003/08/14 17:47:33 niels 159 *** empty log message *** 160 161 Revision 1.26 2003/08/08 21:03:47 gecko1 162 Merge max-rec clipping code into TOT 163 164 Revision 1.25 2003/07/24 20:49:50 collin 165 *** empty log message *** 166 167 Revision 1.24 2003/07/21 06:53:11 niels 168 merge isoch to TOT 169 170 Revision 1.23.14.3 2003/07/18 00:17:48 niels 171 *** empty log message *** 172 173 Revision 1.23.14.2 2003/07/09 21:24:08 niels 174 *** empty log message *** 175 176 Revision 1.23.14.1 2003/07/01 20:54:24 niels 177 isoch merge 178 179 Revision 1.23 2003/01/09 22:58:12 niels 180 radar 3061582: change kCFRunLoopDefaultMode to kCFRunLoopCommonModes 181 182 Revision 1.22 2002/12/12 22:44:04 niels 183 fixed radar 3126316: panic with Hamamatsu driver 184 185 Revision 1.21 2002/09/25 00:27:35 niels 186 flip your world upside-down 187 188 Revision 1.20 2002/09/12 22:41:56 niels 189 add GetIRMNodeID() to user client 190*/ 191 192#pragma mark USER SPACE 193 194#import "IOFWUserObjectExporter.h" 195 196#ifndef KERNEL 197 198#import "IOFireWireLib.h" 199 200// IOFireWireLib factory ID 201// uuid string: A1478010-F197-11D4-A28B-000502072F80 202#define kIOFireWireLibFactoryID CFUUIDGetConstantUUIDWithBytes(kCFAllocatorDefault, 0xA1, 0x47, 0x80, 0x10,0xF1, 0x97, 0x11, 0xD4, 0xA2, 0x8B, 0x00, 0x05,0x02, 0x07, 0x2F, 0x80) 203 204#if (IOFIREWIRELIBDEBUG) 205# include <syslog.h> 206 207# define DebugLog( x... ) { printf( "%s %u:", __FILE__, __LINE__ ); printf( x ) ; } 208# define DebugLogCond( x, y... ) { if (x) DebugLog( y ) ; } 209# else 210# define DebugLog(x...) 211# define DebugLogCond( x, y... ) 212# endif 213 214#define InfoLog(x...) {} 215 216/* Macros for min/max. */ 217#ifndef MIN 218#define MIN(a,b) (((a)<(b))?(a):(b)) 219#endif /* MIN */ 220#ifndef MAX 221#define MAX(a,b) (((a)>(b))?(a):(b)) 222#endif /* MAX */ 223 224extern "C" 225{ 226 void * IOFireWireLibFactory(CFAllocatorRef allocator, CFUUIDRef typeID) ; 227} 228 229#endif // ifndef KERNEL 230 231#pragma mark - 232#pragma mark SHARED 233 234#define kIOFireWireLibConnection 11 235 236namespace IOFireWireLib { 237 238 // 239 // command objects 240 // 241 242 enum CommandType { 243 kCommandType_Read, 244 kCommandType_ReadQuadlet, 245 kCommandType_Write, 246 kCommandType_WriteQuadlet, 247 kCommandType_CompareSwap 248 } ; 249 250 enum { 251 kFireWireCommandStale = (1 << 0), 252 kFireWireCommandStale_Buffer = (1 << 1), 253 kFireWireCommandStale_MaxPacket = (1 << 2), 254 kFireWireCommandStale_Timeout = (1 << 3), 255 kFireWireCommandStale_Retries = (1 << 4), 256 kFireWireCommandStale_Speed = (1 << 5) 257 } ; 258 259 typedef enum IOFireWireCommandType_t { 260 kFireWireCommandType_Read, 261 kFireWireCommandType_ReadQuadlet, 262 kFireWireCommandType_Write, 263 kFireWireCommandType_WriteQuadlet, 264 kFireWireCommandType_CompareSwap, 265 kFireWireCommandType_PHY, 266 kFireWireCommandType_AsyncStream 267 } IOFireWireCommandType ; 268 269 struct WriteQuadParams 270 { 271 FWAddress addr ; 272 UInt32 val ; 273 Boolean failOnReset ; 274 UInt32 generation ; 275 Boolean isAbs ; 276 } ; 277 278 typedef struct 279 { 280 FWAddress addr ; 281 mach_vm_address_t buf ; 282 UInt32 size ; 283 Boolean failOnReset ; 284 UInt32 generation ; 285 Boolean isAbs ; 286 } ReadParams, WriteParams, ReadQuadParams ; 287 288 struct CompareSwapParams 289 { 290 FWAddress addr ; 291 UInt64 cmpVal ; 292 UInt64 swapVal ; 293 UInt32 size ; 294 Boolean failOnReset ; 295 UInt32 generation ; 296 Boolean isAbs ; 297 } ; 298 299 struct CommandSubmitParams 300 { 301 UserObjectHandle kernCommandRef ; 302 IOFireWireCommandType type ; 303 mach_vm_address_t callback ; 304 mach_vm_address_t refCon ; 305 UInt32 flags ; 306 307 UInt32 staleFlags ; 308 UInt64 newTarget ; 309 mach_vm_address_t newBuffer ; 310 UInt32 newBufferSize ; // note: means numQuads for quadlet commands! 311 Boolean newFailOnReset ; 312 UInt32 newGeneration ; 313 UInt32 newMaxPacket ; 314 315 UInt32 timeoutDuration; 316 UInt32 retryCount; 317 UInt32 maxPacketSpeed; 318 UInt32 data1; 319 UInt32 data2; 320 UInt32 tag; 321 UInt32 sync; 322 } __attribute__ ((packed)); 323 324 struct CommandSubmitResult 325 { 326 UserObjectHandle kernCommandRef ; 327 IOReturn result ; 328 UInt32 bytesTransferred ; 329 UInt32 ackCode; 330 UInt32 responseCode; 331 mach_vm_address_t refCon; 332 } __attribute__ ((packed)); 333 334 struct FWCompareSwapLockInfo 335 { 336 Boolean didLock ; 337 UInt32 value[2]; 338 } __attribute__ ((packed)); 339 340 struct CompareSwapSubmitResult 341 { 342 UserObjectHandle kernCommandRef ; 343 IOReturn result ; 344 UInt32 bytesTransferred ; 345 UInt32 ackCode; 346 UInt32 responseCode; 347 FWCompareSwapLockInfo lockInfo ; 348 } __attribute__ ((packed)); 349 350 // 351 // DCL stuff 352 // 353 354 typedef struct LocalIsochPortAllocateParamsStruct 355 { 356 UInt32 version ; 357 358 UInt32 startEvent ; 359 UInt32 startState ; 360 UInt32 startMask ; 361 362 mach_vm_address_t programData ; 363 UInt32 programExportBytes ; 364 365 UInt32 bufferRangeCount ; 366 mach_vm_address_t bufferRanges ; 367 368 mach_vm_address_t userObj ; 369 370 UInt32 talking ; 371 372 UInt32 options ; 373 374 } __attribute__ ((packed)) LocalIsochPortAllocateParams; 375 376 // 377 // address spaces 378 // 379 380 struct AddressSpaceInfo 381 { 382 FWAddress address ; 383 } ; 384 385 struct AddressSpaceCreateParams 386 { 387 mach_vm_size_t size ; 388 mach_vm_address_t backingStore ; 389 mach_vm_size_t queueSize ; 390 mach_vm_address_t queueBuffer ; 391 UInt32 flags ; 392 mach_vm_address_t refCon ; 393 394 // for initial units address spaces: 395 Boolean isInitialUnits ; 396 UInt32 addressLo ; 397 } __attribute__ ((packed)); 398 399 struct FWUserAsyncStreamListenerCreateParams 400 { 401 UInt32 channel; 402 mach_vm_size_t queueSize ; 403 mach_vm_address_t queueBuffer ; 404 UInt32 flags ; 405 mach_vm_address_t callback ; 406 mach_vm_address_t refCon ; 407 } __attribute__ ((packed)); 408 409// struct PhysicalAddressSpaceCreateParams 410// { 411// UInt32 size ; 412// void* backingStore ; 413// UInt32 flags ; 414// } ; 415 416 // 417 // config ROM 418 // 419 420 typedef struct 421 { 422 UserObjectHandle data ; 423 UInt32 dataLength ; 424 UserObjectHandle text ; 425 UInt32 textLength ; 426 } GetKeyValueDataResults ; 427 428 typedef struct 429 { 430 FWAddress address ; 431 UserObjectHandle text ; 432 UInt32 length ; 433 } GetKeyOffsetResults ; 434 435 typedef struct 436 { 437 IOPhysicalAddress32 location; 438 IOPhysicalLength32 length; 439 } FWPhysicalSegment32; 440 441 typedef struct 442 { 443 mach_vm_address_t address; 444 mach_vm_size_t length; 445 } FWVirtualAddressRange; 446 447 // make sure these values don't conflict with any 448 // in enum 'NuDCLFlags' as defined in IOFireWireFamilyCommon.h 449 450 enum 451 { 452 kNuDCLUser = BIT( 18 ) // set back to BIT(18) when we want to support user space update before callback 453 } ; 454 455 enum 456 { 457 kDCLExportDataLegacyVersion = 0 458 , kDCLExportDataNuDCLRosettaVersion = 8 459 } ; 460 461 ///////////////////////////////////////// 462 // 463 // Method Selectors For User Client 464 // 465 ///////////////////////////////////////// 466 enum MethodSelector 467 { 468 kOpen = 0, 469 kOpenWithSessionRef, 470 kClose, 471 kReadQuad, 472 kRead, 473 kWriteQuad, 474 kWrite, 475 kCompareSwap, 476 kBusReset, 477 kCycleTime, 478 kGetGenerationAndNodeID, 479 kGetLocalNodeID, 480 kGetResetTime, 481 kReleaseUserObject, 482 kGetOSStringData, 483 kGetOSDataData, 484 kLocalConfigDirectory_Create, 485 kLocalConfigDirectory_AddEntry_Buffer, 486 kLocalConfigDirectory_AddEntry_UInt32, 487 kLocalConfigDirectory_AddEntry_FWAddr, 488 kLocalConfigDirectory_AddEntry_UnitDir, 489 kLocalConfigDirectory_Publish, 490 kLocalConfigDirectory_Unpublish, 491 kPseudoAddrSpace_Allocate, 492 kPseudoAddrSpace_GetFWAddrInfo, 493 kPseudoAddrSpace_ClientCommandIsComplete, 494 kPhysicalAddrSpace_Allocate, 495 kPhysicalAddrSpace_GetSegmentCount_d, 496 kPhysicalAddrSpace_GetSegments, 497 kConfigDirectory_Create, 498 kConfigDirectory_GetKeyType, 499 kConfigDirectory_GetKeyValue_UInt32, 500 kConfigDirectory_GetKeyValue_Data, 501 kConfigDirectory_GetKeyValue_ConfigDirectory, 502 kConfigDirectory_GetKeyOffset_FWAddress, 503 kConfigDirectory_GetIndexType, 504 kConfigDirectory_GetIndexKey, 505 kConfigDirectory_GetIndexValue_UInt32, 506 kConfigDirectory_GetIndexValue_Data, 507 kConfigDirectory_GetIndexValue_String, 508 kConfigDirectory_GetIndexValue_ConfigDirectory, 509 kConfigDirectory_GetIndexOffset_FWAddress, 510 kConfigDirectory_GetIndexOffset_UInt32, 511 kConfigDirectory_GetIndexEntry, 512 kConfigDirectory_GetSubdirectories, 513 kConfigDirectory_GetKeySubdirectories, 514 kConfigDirectory_GetType, 515 kConfigDirectory_GetNumEntries, 516 kIsochPort_GetSupported, 517 kIsochPort_AllocatePort_d, 518 kIsochPort_ReleasePort_d, 519 kIsochPort_Start_d, 520 kIsochPort_Stop_d, 521 kLocalIsochPort_Allocate, 522 kLocalIsochPort_ModifyJumpDCL_d, 523 kLocalIsochPort_Notify_d, 524 kLocalIsochPort_SetChannel, 525 kIsochChannel_Allocate, 526 kIsochChannel_UserAllocateChannelBegin, 527 kIsochChannel_UserReleaseChannelComplete_d, 528 kCommand_Cancel_d, 529 kSeize, 530 kFireLog, 531 kGetBusCycleTime, 532 kGetBusGeneration, 533 kGetLocalNodeIDWithGeneration, 534 kGetRemoteNodeID, 535 kGetSpeedToNode, 536 kGetSpeedBetweenNodes, 537 kGetIRMNodeID, 538 kClipMaxRec2K, 539 kIsochPort_SetIsochResourceFlags_d, 540 kGetSessionRef, 541 kAsyncStreamListener_Allocate, 542 kAsyncStreamListener_ClientCommandIsComplete, 543 kAsyncStreamListener_GetOverrunCounter, 544 kAsyncStreamListener_SetFlags, 545 kAsyncStreamListener_GetFlags, 546 kAsyncStreamListener_TurnOnNotification, 547 kAsyncStreamListener_TurnOffNotification, 548 kAllocateIRMBandwidth, 549 kReleaseIRMBandwidth, 550 kAllocateIRMChannel, 551 kReleaseIRMChannel, 552 kSetAsyncRef_BusReset, 553 kSetAsyncRef_BusResetDone, 554 kSetAsyncRef_Packet, 555 kSetAsyncRef_SkippedPacket, 556 kSetAsyncRef_Read, 557 kCommand_Submit, 558 kSetAsyncRef_IsochChannelForceStop, 559 kSetAsyncRef_DCLCallProc, 560 kSetAsyncStreamRef_Packet, 561 kSetAsyncStreamRef_SkippedPacket, 562 kIRMAllocation_Allocate, 563 kIRMAllocation_SetRef, 564 kIRMAllocation_AllocateResources, 565 kIRMAllocation_DeallocateResources, 566 kIRMAllocation_areResourcesAllocated, 567 kIRMAllocation_setDeallocateOnRelease, 568 kCommandCreateAsync, 569 kVectorCommandSetBuffers, 570 kVectorCommandSubmit, 571 kVectorCommandCreate, 572 kPHYPacketListenerCreate, 573 kPHYPacketListenerSetPacketCallback, 574 kPHYPacketListenerSetSkippedCallback, 575 kPHYPacketListenerActivate, 576 kPHYPacketListenerDeactivate, 577 kPHYPacketListenerClientCommandIsComplete, 578 kNumMethods 579 } ; 580 581} // namespace IOFireWireLib 582