24 #if !defined (NTV2_NULL_DEVICE)
27 #include <mach/mach.h>
29 #endif // !defined (NTV2_NULL_DEVICE)
34 static const char *
GetKernErrStr (
const kern_return_t inError);
43 #define HEX2(__x__) xHEX0N(0xFF & uint8_t (__x__),2)
44 #define HEX4(__x__) xHEX0N(0xFFFF & uint16_t(__x__),4)
45 #define HEX8(__x__) xHEX0N(0xFFFFFFFF & uint32_t(__x__),8)
46 #define HEX16(__x__) xHEX0N(uint64_t(__x__),16)
47 #define KR(_kr_) "kernResult=" << HEX8(_kr_) << "(" << GetKernErrStr(_kr_) << ")"
48 #define INSTP(_p_) HEX0N(uint64_t(_p_),16)
50 #define DIFAIL(__x__) AJA_sERROR (AJA_DebugUnit_DriverInterface, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
51 #define DIWARN(__x__) AJA_sWARNING(AJA_DebugUnit_DriverInterface, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
52 #define DINOTE(__x__) AJA_sNOTICE (AJA_DebugUnit_DriverInterface, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
53 #define DIINFO(__x__) AJA_sINFO (AJA_DebugUnit_DriverInterface, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
54 #define DIDBG(__x__) AJA_sDEBUG (AJA_DebugUnit_DriverInterface, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
56 #define MDIFAIL(__x__) AJA_sERROR (AJA_DebugUnit_DriverInterface, AJAFUNC << ": " << __x__)
57 #define MDIWARN(__x__) AJA_sWARNING(AJA_DebugUnit_DriverInterface, AJAFUNC << ": " << __x__)
58 #define MDINOTE(__x__) AJA_sNOTICE (AJA_DebugUnit_DriverInterface, AJAFUNC << ": " << __x__)
59 #define MDIINFO(__x__) AJA_sINFO (AJA_DebugUnit_DriverInterface, AJAFUNC << ": " << __x__)
60 #define MDIDBG(__x__) AJA_sDEBUG (AJA_DebugUnit_DriverInterface, AJAFUNC << ": " << __x__)
63 #if !defined (NTV2_NULL_DEVICE)
65 #define OS_IOMasterPort(_x_,_y_) ::IOMasterPort ((_x_), (_y_))
66 #define OS_IOServiceOpen(_w_,_x_,_y_,_z_) ::IOServiceOpen((_w_), (_x_), (_y_), (_z_))
67 #define OS_IOServiceClose(_x_) ::IOServiceClose ((_x_))
68 #define OS_IOServiceMatching(_x_) ::IOServiceMatching ((_x_))
69 #define OS_IOServiceNameMatching(_x_) ::IOServiceNameMatching((_x_))
70 #define OS_IOServiceGetMatchingServices(_x_,_y_,_z_) ::IOServiceGetMatchingServices ((_x_), (_y_), (_z_))
71 #define OS_IOIteratorNext(_x_) ::IOIteratorNext ((_x_))
72 #define OS_IOObjectRelease(_x_) ::IOObjectRelease ((_x_))
73 #define OS_IORegistryEntryCreateCFProperty(_w_,_x_,_y_,_z_) ::IORegistryEntryCreateCFProperty ((_w_), (_x_), (_y_), (_z_))
74 #define OS_IOConnectCallMethod(_q_,_r_,_s_,_t_,_u_,_v_,_w_,_x_,_y_,_z_) ::IOConnectCallMethod ((_q_), (_r_), (_s_), (_t_), (_u_), (_v_), (_w_), (_x_), (_y_), (_z_))
75 #define OS_IOConnectCallScalarMethod(_u_,_v_,_w_,_x_,_y_,_z_) ::IOConnectCallScalarMethod ((_u_), (_v_), (_w_), (_x_), (_y_), (_z_))
76 #define OS_IOConnectCallStructMethod(_u_,_v_,_w_,_x_,_y_,_z_) ::IOConnectCallStructMethod ((_u_), (_v_), (_w_), (_x_), (_y_), (_z_))
77 #define OS_IOConnectMapMemory(_u_,_v_,_w_,_x_,_y_,_z_) ::IOConnectMapMemory ((_u_), (_v_), (_w_), (_x_), (_y_), (_z_))
78 #define OS_IOKitGetBusyState(_x_,_y_) ::IOKitGetBusyState ((_x_), (_y_))
79 #define OS_IOKitWaitQuiet(_x_,_y_) ::IOKitWaitQuiet ((_x_), (_y_))
80 #else // NTV2_NULL_DEVICE defined
83 static IOReturn
OS_IOMasterPort (
const mach_port_t inPort, mach_port_t * pOutPort)
85 MDIWARN(
"NTV2_NULL_DEVICE -- will not connect to IOKit");
90 static kern_return_t
OS_IOServiceOpen (
const io_service_t inSvc,
const task_port_t inTask,
const uint32_t inType, io_connect_t * pOutConn)
91 { (void)inSvc; (void)inTask; (void)inType;
92 if (pOutConn) *pOutConn = 0;
104 { (void)inPort; (void)inMatch;
117 static CFTypeRef
OS_IORegistryEntryCreateCFProperty (
const io_registry_entry_t inEntry,
const CFStringRef inKey,
const CFAllocatorRef inAllocator,
const IOOptionBits inOptions)
118 { (void)inEntry; (void)inKey; (void)inAllocator; (void)inOptions;
121 static IOReturn
OS_IOConnectCallScalarMethod (
const mach_port_t inConnect,
const uint32_t inSelector,
const uint64_t * pInput,
const uint32_t inCount, uint64_t * pOutput, uint32_t * pOutCount)
122 { (void)inConnect; (void)inSelector; (void)pInput; (void)inCount;
123 if (pOutput) *pOutput = 0;
124 if (pOutCount) *pOutCount = 0;
127 static kern_return_t
OS_IOConnectCallMethod (
const mach_port_t inConnect,
const uint32_t inSelector,
const uint64_t * pInput, uint32_t inputCnt,
const void * pInStruct,
const size_t inStructCnt, uint64_t * pOutput, uint32_t * pOutputCnt,
void * pOutStruct,
size_t * pOutStructCnt)
128 { (void)inConnect; (void)inSelector; (void)pInput; (void)inputCnt; (void)pInStruct; (void)inStructCnt; (void)pOutput; (void)pOutputCnt; (void)pOutStruct; (void)pOutStructCnt;
137 static IOReturn
OS_IOKitWaitQuiet (
const mach_port_t inPort,
const mach_timespec_t * pInOutWait)
138 { (void)inPort; (void)pInOutWait;
141 static IOReturn
OS_IOConnectCallStructMethod (
const io_connect_t inPort,
const uint32_t inSelector,
const void *inputStruct,
size_t inputStructCnt,
void *pOutStruct,
size_t *pOutStructCnt)
142 { (void)inPort; (void)inSelector; (void)inputStruct; (void)inputStructCnt; (void)pOutStruct; (void)pOutStructCnt;
145 static kern_return_t
OS_IOConnectMapMemory (
const io_connect_t inPort,
const uint32_t inMemType,
const task_port_t inTask, mach_vm_address_t * pAddr, mach_vm_size_t * pOutSize,
const IOOptionBits inOpts)
146 { (void)inPort; (void)inMemType; (void)inTask; (void)pAddr; (void)pOutSize; (void)inOpts;
149 #endif // NTV2_NULL_DEVICE defined
152 #if defined(USE_DEVICE_MAP)
153 static unsigned gnBoardMaps (0);
154 static const UWord kMaxNumDevices (32);
155 static uint64_t RECHECK_INTERVAL (1024LL);
156 static unsigned int TWO_SECONDS (2);
157 #define NTV2_IGNORE_IOREG_BUSY (true) // If defined, ignore IORegistry busy state;
175 NTV2_ASSERT (gnBoardMaps == 0 &&
"Attempt to create more than one DeviceMap");
177 ::memset (&mIOConnections, 0,
sizeof (mIOConnections));
178 ::memset (&mRecheckTally, 0,
sizeof (mRecheckTally));
179 mDrvrVersComps[0] = mDrvrVersComps[1] = mDrvrVersComps[2] = mDrvrVersComps[3] = 0;
183 if (error != kIOReturnSuccess)
185 MDIFAIL (
KR(error) <<
"Unable to get master port");
189 MDINOTE (
"DeviceMap singleton created");
198 MDINOTE (
"DeviceMap singleton destroyed");
203 void Reset (
const bool inResetMasterPort =
false)
207 for (
UWord ndx (0); ndx < kMaxNumDevices; ++ndx)
209 io_connect_t connection (mIOConnections [ndx]);
213 mIOConnections [ndx] = 0;
214 MDINOTE (
"Device " << ndx <<
" connection " <<
HEX8(connection) <<
" closed");
217 if (inResetMasterPort)
220 if (error != kIOReturnSuccess)
221 MDIFAIL (
KR(error) <<
"Unable to reset master port");
223 MDINOTE (
"reset mMasterPort=" <<
HEX8(mMasterPort));
228 io_connect_t GetConnection (
const UWord inDeviceIndex,
const bool inDoNotAllocate =
false)
230 if (inDeviceIndex >= kMaxNumDevices)
232 MDIWARN (
"Bad device index " << inDeviceIndex <<
", GetConnection fail");
237 const io_connect_t connection (mIOConnections [inDeviceIndex]);
238 if (connection && RECHECK_INTERVAL)
240 uint64_t & recheckTally (mRecheckTally [inDeviceIndex]);
241 if (++recheckTally % RECHECK_INTERVAL == 0)
244 if (!ConnectionIsStillOkay (inDeviceIndex))
246 MDIFAIL (
"Device " << inDeviceIndex <<
" connection " <<
HEX8(connection) <<
" invalid, resetting DeviceMap");
259 MDIWARN (
"Request to Open device " << inDeviceIndex <<
" denied because DeviceMap closing");
264 if (!WaitForBusToSettle ())
266 MDIWARN (
"IORegistry unstable, resetting DeviceMap");
272 UWord ndx (inDeviceIndex);
273 io_iterator_t ioIterator (0);
274 IOReturn error (kIOReturnSuccess);
275 io_object_t ioObject (0);
276 io_connect_t ioConnect (0);
283 if (error != kIOReturnSuccess)
285 MDIFAIL (
KR(error) <<
" -- IOServiceGetMatchingServices failed, no match for '" << className <<
"', device index " << inDeviceIndex <<
" requested");
306 if (error != kIOReturnSuccess)
308 MDIFAIL (
KR(error) <<
" -- IOServiceOpen failed on device " << inDeviceIndex);
313 mIOConnections [inDeviceIndex] = ioConnect;
314 mRecheckTally [inDeviceIndex] = 0;
315 MDINOTE (
"Device " << inDeviceIndex <<
" connection " <<
HEX8(ioConnect) <<
" opened");
321 void Dump (
const UWord inMaxNumDevices = 10)
const
324 for (
UWord ndx (0); ndx < inMaxNumDevices; ++ndx)
325 MDIDBG (
" [" << ndx <<
"]: con=" <<
HEX8(mIOConnections [ndx]));
329 UWord GetConnectionCount (
void)
const
333 for (
UWord ndx (0); ndx < kMaxNumDevices; ++ndx)
334 if (mIOConnections [ndx])
342 ULWord GetConnectionChecksum (
void)
const
346 for (
UWord ndx (0); ndx < kMaxNumDevices; ++ndx)
347 if (mIOConnections [ndx])
348 checksum += mIOConnections [ndx];
355 uint32_t GetDriverVersion (
void)
const {
return mDriverVersion; }
358 bool ConnectionIsStillOkay (
const UWord inDeviceIndex)
360 if (inDeviceIndex >= kMaxNumDevices)
362 MDIWARN (
"ConnectionIsStillOkay: bad 'inDeviceIndex' parameter " << inDeviceIndex);
366 const io_connect_t connection (mIOConnections [inDeviceIndex]);
369 uint64_t scalarO_64 [2] = {0, 0};
370 uint32_t outputCount = 2;
372 if (kernResult == KERN_SUCCESS)
378 uint64_t SetConnectionCheckInterval (
const uint64_t inNewInterval)
380 uint64_t oldValue (RECHECK_INTERVAL);
381 if (oldValue != inNewInterval)
383 RECHECK_INTERVAL = inNewInterval;
384 if (RECHECK_INTERVAL)
385 MDINOTE (
"connection recheck interval changed to" <<
HEX16(RECHECK_INTERVAL) <<
", was" <<
HEX16(oldValue));
387 MDINOTE (
"connection rechecking disabled, was" <<
HEX16(oldValue));
393 bool WaitForBusToSettle (
void)
395 uint32_t busyState (0);
398 if (kr != kIOReturnSuccess)
399 MDIFAIL (
"IOKitGetBusyState failed -- " <<
KR(kr));
402 #if defined (NTV2_IGNORE_IOREG_BUSY)
403 MDINOTE (
"IOKitGetBusyState reported BUSY");
406 mach_timespec_t maxWaitTime = {TWO_SECONDS, 0};
407 MDINOTE (
"IOKitGetBusyState reported BUSY -- waiting for IORegistry to stabilize...");
410 if (kr == kIOReturnSuccess)
412 MDIFAIL (
"IOKitWaitQuiet timed out -- " <<
KR(kr));
413 #endif // defined (NTV2_IGNORE_IOREG_BUSY)
421 io_connect_t mIOConnections [kMaxNumDevices];
422 uint64_t mRecheckTally [kMaxNumDevices];
424 mach_port_t mMasterPort;
426 uint32_t mDriverVersion;
427 uint16_t mDrvrVersComps[4];
432 static DeviceMap gDeviceMap;
435 io_connect_t CNTV2MacDriverInterface::GetIOConnect (
const bool inDoNotAllocate)
const
437 return gDeviceMap.GetConnection (_boardNumber, inDoNotAllocate);
439 #endif // defined(USE_DEVICE_MAP)
454 #if !defined(USE_DEVICE_MAP)
469 #if !defined(NTV2_NULL_DEVICE)
475 #if defined(USE_DEVICE_MAP)
477 _boardOpened = gDeviceMap.GetConnection (inDeviceIndex) != 0;
483 if (!gDeviceMap.ConnectionIsStillOkay(inDeviceIndex))
486 _boardOpened = gDeviceMap.GetConnection(inDeviceIndex) != 0;
489 #else // !defined(USE_DEVICE_MAP)
491 io_iterator_t ioIterator (0);
492 IOReturn error (kIOReturnSuccess);
493 io_object_t ioObject (0);
496 for (
size_t svcNdx(0); svcNdx < 2 && !mConnection; svcNdx++)
498 const string & svcName (kSvcNames[svcNdx]);
499 const char * pSvcName(svcName.c_str());
500 const bool tryKEXT (svcName.find(
"com_aja_iokit") != string::npos);
506 if (error != kIOReturnSuccess)
507 {
DIWARN(
KR(error) <<
": No '" << svcName <<
"' driver");
continue;}
521 DIWARN(
"No '" << svcName <<
"' devices");
528 if (error != kIOReturnSuccess)
529 {
DIWARN(
KR(error) <<
": IOServiceOpen failed for '" << svcName <<
"' ndx=" << inDeviceIndex);
continue;}
534 _boardOpened = mConnection != 0;
536 DIDBG((mIsDEXT ?
"DEXT" :
"KEXT") <<
" ndx=" << inDeviceIndex <<
" conn=" <<
HEX8(GetIOConnect()) <<
" opened");
537 #endif // !defined(USE_DEVICE_MAP)
539 {
DIFAIL(
INSTP(
this) <<
": No connection: ndx=" << inDeviceIndex);
return false;}
542 _boardNumber = inDeviceIndex;
545 DIFAIL(
"ReadRegister(kRegBoardID) failed: ndx=" << inDeviceIndex <<
" con=" <<
HEX8(GetIOConnect()) <<
" boardID=" <<
HEX8(_boardID));
560 DIDBG(
"Closed " << (mIsDEXT ?
"DEXT" :
"KEXT") <<
" ndx=" << _boardNumber <<
" con=" <<
HEX8(GetIOConnect()) <<
" id=" << ::
NTV2DeviceIDToString(_boardID));
561 _boardOpened =
false;
563 #if !defined(USE_DEVICE_MAP)
567 #endif // !defined(USE_DEVICE_MAP)
572 #endif // !defined(NTV2_NULL_DEVICE)
575 #if !defined(NTV2_DEPRECATE_16_0)
599 _pCh1FrameBaseAddress = _pCh2FrameBaseAddress =
AJA_NULL;
602 _pFrameBaseAddress =
reinterpret_cast<ULWord*
>(baseAddr);
609 _pCh1FrameBaseAddress = _pCh2FrameBaseAddress =
AJA_NULL;
624 _pRegisterBaseAddress =
reinterpret_cast<ULWord*
>(baseAddr);
645 _pXena2FlashBaseAddress =
reinterpret_cast<ULWord*
>(baseAddr);
665 mach_vm_size_t size(0);
667 reinterpret_cast<mach_vm_address_t*
>(memPtr),
668 &size, kIOMapDefaultCache | kIOMapAnywhere);
679 kern_return_t kernResult = KERN_FAILURE;
680 uint64_t scalarI_64[2] = {uint64_t(dataPtr), controlCode};
681 uint32_t outputCount = 0;
683 kernResult = KERN_INVALID_ARGUMENT;
684 else if (GetIOConnect())
691 if (kernResult == KERN_SUCCESS)
693 DIFAIL (
KR(kernResult) <<
", con=" <<
HEX8(GetIOConnect()));
696 #endif // !defined(NTV2_DEPRECATE_16_0)
698 #pragma mark - New Driver Calls
699 #if defined(AJA_MULTIRASTER_TEST)
701 static ULWord gMRRegs[] = { 0x01000004, 0x01000004, 0x01000004, 0x01000004, 0x01101D48, 0x00444400, 0x00000000, 0x00000001};
713 DIFAIL(
"Shift " <<
DEC(inShift) <<
" > 31, reg=" <<
DEC(inRegNum) <<
" msk=" <<
xHEX0N(inMask,8));
716 #if defined (NTV2_NUB_CLIENT_SUPPORT)
719 #endif // defined (NTV2_NUB_CLIENT_SUPPORT)
720 #if defined(AJA_MULTIRASTER_TEST)
722 {outValue = (gMRRegs[inRegNum -
kRegMRQ1Control] & inMask) >> inShift;
return true;}
724 kern_return_t kernResult(KERN_FAILURE);
725 uint64_t scalarI_64[2] = {inRegNum, inMask};
726 uint64_t scalarO_64 = outValue;
727 uint32_t outputCount = 1;
739 outValue = uint32_t(scalarO_64);
740 if (kernResult == KERN_SUCCESS)
742 DIFAIL(
KR(kernResult) <<
": ndx=" << _boardNumber <<
", con=" <<
HEX8(GetIOConnect())
743 <<
" -- reg=" <<
DEC(inRegNum) <<
", mask=" <<
HEX8(inMask) <<
", shift=" <<
HEX8(inShift));
758 DIFAIL(
"Shift " <<
DEC(inShift) <<
" > 31, reg=" <<
DEC(inRegNum) <<
" msk=" <<
xHEX0N(inMask,8));
761 #if defined(NTV2_WRITEREG_PROFILING) // Register Write Profiling
762 if (mRecordRegWrites)
765 mRegWrites.push_back(
NTV2RegInfo(inRegNum, inValue, inMask, inShift));
769 #endif // defined(NTV2_WRITEREG_PROFILING) // Register Write Profiling
770 #if defined(NTV2_NUB_CLIENT_SUPPORT)
773 #endif // defined (NTV2_NUB_CLIENT_SUPPORT)
774 #if defined(AJA_MULTIRASTER_TEST)
778 kern_return_t kernResult(KERN_FAILURE);
779 uint64_t scalarI_64[3] = {inRegNum, inValue, inMask};
780 uint32_t outputCount = 0;
792 if (kernResult == KERN_SUCCESS)
794 DIFAIL (
KR(kernResult) <<
": con=" <<
HEX8(GetIOConnect()) <<
" -- reg=" << inRegNum
795 <<
", val=" <<
HEX8(inValue) <<
", mask=" <<
HEX8(inMask) <<
", shift=" <<
HEX8(inShift));
810 kern_return_t kernResult = KERN_FAILURE;
811 uint64_t scalarI_64[2] = {uint64_t(appType), uint64_t(pid)};
812 uint32_t outputCount = 0;
822 if (kernResult == KERN_SUCCESS)
824 DIFAIL(
KR(kernResult) <<
": con=" <<
HEX8(GetIOConnect()));
834 kern_return_t kernResult = KERN_FAILURE;
835 uint64_t scalarI_64[2] = {uint64_t(appType), uint64_t(pid)};
836 uint32_t outputCount = 0;
846 if (kernResult == KERN_SUCCESS)
848 DIFAIL (
KR(kernResult) <<
": con=" <<
HEX8(GetIOConnect()));
865 kern_return_t kernResult = KERN_FAILURE;
866 uint64_t scalarI_64[2] = {uint64_t(appType), uint64_t(pid)};
867 uint32_t outputCount = 0;
877 if (kernResult == KERN_SUCCESS)
879 DIFAIL (
KR(kernResult) <<
": con=" <<
HEX8(GetIOConnect()));
892 kern_return_t kernResult = KERN_FAILURE;
893 uint64_t scalarI_64[2] = {uint64_t(appType), uint64_t(pid)};
894 uint32_t outputCount = 0;
904 if (kernResult == KERN_SUCCESS)
906 DIFAIL (
KR(kernResult) <<
": con=" <<
HEX8(GetIOConnect()));
922 kern_return_t kernResult = KERN_FAILURE;
923 uint64_t scalarI_64[2] = {uint64_t(appType), uint64_t(pid)};
924 uint32_t outputCount = 0;
934 if (kernResult == KERN_SUCCESS)
936 DIFAIL (
KR(kernResult) <<
": con=" <<
HEX8(GetIOConnect()));
946 kern_return_t kernResult = KERN_FAILURE;
947 uint64_t scalarO_64[2] = {0, 0};
948 uint32_t outputCount(2);
958 outAppType =
ULWord(scalarO_64[0]);
959 outProcessID = int32_t(scalarO_64[1]);
960 if (kernResult == KERN_SUCCESS)
962 DIFAIL (
KR(kernResult) <<
": con=" <<
HEX8(GetIOConnect()));
972 kern_return_t kernResult = KERN_FAILURE;
973 uint64_t scalarI_64[2] = {uint64_t(dataPtr), dataSize};
974 uint32_t outputCount = 0;
982 if (kernResult == KERN_SUCCESS)
984 DIFAIL (
KR(kernResult) <<
": con=" <<
HEX8(GetIOConnect()));
993 AJA_DebugStat_WaitForInterruptOthers,
AJA_DebugStat_WaitForInterruptOthers,
AJA_DebugStat_WaitForInterruptOthers,
AJA_DebugStat_WaitForInterruptOthers,
AJA_DebugStat_WaitForInterruptOthers,
AJA_DebugStat_WaitForInterruptOthers,
AJA_DebugStat_WaitForInterruptOthers,
AJA_DebugStat_WaitForInterruptOthers,
AJA_DebugStat_WaitForInterruptOthers,
AJA_DebugStat_WaitForInterruptOthers,
1020 return WaitForChangeEvent(timeout);
1022 kern_return_t kernResult = KERN_FAILURE;
1023 uint64_t scalarI_64[2] = {type, timeout};
1024 uint64_t scalarO_64 = 0;
1025 uint32_t outputCount = 1;
1028 kernResult = KERN_INVALID_VALUE;
1029 else if (GetIOConnect())
1040 UInt32 interruptOccurred = uint32_t(scalarO_64);
1041 if (kernResult != KERN_SUCCESS)
1042 {
DIFAIL (
KR(kernResult) <<
": con=" <<
HEX8(GetIOConnect()));
return false;}
1043 if (interruptOccurred)
1044 BumpEventCount(type);
1045 return interruptOccurred;
1055 kern_return_t kernResult = KERN_FAILURE;
1056 uint64_t scalarI_64[1] = {eInterrupt};
1057 uint64_t scalarO_64 = 0;
1058 uint32_t outputCount = 1;
1070 outCount =
ULWord(scalarO_64);
1071 if (kernResult == KERN_SUCCESS)
1073 DIFAIL(
KR(kernResult) <<
": con=" <<
HEX8(GetIOConnect()));
1086 kern_return_t kernResult = KERN_FAILURE;
1087 uint64_t scalarI_64[1] = {timeout};
1088 uint64_t scalarO_64 = 0;
1089 uint32_t outputCount = 1;
1097 if (kernResult != KERN_SUCCESS)
1098 DIFAIL(
KR(kernResult) <<
": con=" <<
HEX8(GetIOConnect()));
1099 return bool(scalarO_64);
1114 const bool inIsRead,
1115 const ULWord inFrameNumber,
1117 const ULWord inOffsetBytes,
1118 const ULWord inByteCount,
1119 const bool inSynchronous)
1123 inOffsetBytes, inByteCount, inSynchronous);
1126 kern_return_t kernResult = KERN_FAILURE;
1127 uint64_t scalarI_64[6] = {inDMAEngine, uint64_t(pFrameBuffer), inFrameNumber, inOffsetBytes, inByteCount, !inIsRead};
1128 uint32_t outputCount = 0;
1140 if (kernResult == KERN_SUCCESS)
1142 DIFAIL(
KR(kernResult) <<
": con=" <<
HEX8(GetIOConnect()) <<
", eng=" << inDMAEngine <<
", frm=" << inFrameNumber
1143 <<
", off=" <<
HEX8(inOffsetBytes) <<
", len=" <<
HEX8(inByteCount) <<
", " << (inIsRead ?
"R" :
"W"));
1159 const bool inIsRead,
1160 const ULWord inFrameNumber,
1162 const ULWord inCardOffsetBytes,
1163 const ULWord inByteCount,
1164 const ULWord inNumSegments,
1165 const ULWord inSegmentHostPitch,
1166 const ULWord inSegmentCardPitch,
1167 const bool inSynchronous)
1171 inNumSegments, inSegmentHostPitch, inSegmentCardPitch, inSynchronous);
1174 kern_return_t kernResult = KERN_FAILURE;
1175 size_t outputStructSize = 0;
1181 dmaTransfer64.
dmaSize = inByteCount;
1201 if (kernResult == KERN_SUCCESS)
1203 DIFAIL (
KR(kernResult) <<
": con=" <<
HEX8(GetIOConnect()));
1210 const bool inIsTarget,
1211 const ULWord inFrameNumber,
1212 const ULWord inCardOffsetBytes,
1213 const ULWord inByteCount,
1214 const ULWord inNumSegments,
1215 const ULWord inSegmentHostPitch,
1216 const ULWord inSegmentCardPitch,
1221 inNumSegments, inSegmentHostPitch, inSegmentCardPitch, inP2PData);
1231 kern_return_t kernResult = KERN_FAILURE;
1232 uint32_t outputCount = 0;
1240 if (kernResult == KERN_SUCCESS)
1242 DIFAIL (
KR(kernResult) <<
": con=" <<
HEX8(GetIOConnect()));
1252 kern_return_t kernResult = KERN_FAILURE;
1253 uint64_t scalarI_64[2] = {uint64_t(dataPtr), statusCode};
1254 uint32_t outputCount = 0;
1264 if (kernResult == KERN_SUCCESS)
1276 bool success =
true;
1280 kern_return_t kernResult = KERN_FAILURE;
1281 io_connect_t conn(GetIOConnect());
1299 size_t outputStructSize = 0;
1301 CopyTo_AUTOCIRCULATE_DATA_64 (&autoCircData, &autoCircData64);
1316 uint64_t scalarI_64[1];
1317 uint32_t outputCount = 0;
1346 CopyTo_AUTOCIRCULATE_DATA_64 (&autoCircData, &autoCircData64);
1380 CopyTo_AUTOCIRCULATE_DATA_64 (&autoCircData, &autoCircData64);
1407 kernResult = KERN_INVALID_ARGUMENT;
1411 success = (kernResult == KERN_SUCCESS);
1412 if (kernResult != KERN_SUCCESS && kernResult != kIOReturnOffline)
1422 if (!pInOutMessage->
IsValid())
1424 if (!pInOutMessage->GetSizeInBytes())
1430 ULWord* pU32 =
reinterpret_cast<ULWord*
>(pInOutMessage); pU32[6] = 0;
1432 kern_return_t kernResult (KERN_FAILURE);
1433 io_connect_t connection (GetIOConnect ());
1434 uint64_t scalarI_64 [2] = {uint64_t(pInOutMessage), pInOutMessage->GetSizeInBytes()};
1435 uint32_t numScalarOutputs(0);
1447 if (kernResult != KERN_SUCCESS && kernResult != kIOReturnOffline)
1448 MDIFAIL (
KR(kernResult) <<
INSTP(
this) <<
", con=" <<
HEX8(connection) << endl << *pInOutMessage);
1449 return kernResult == KERN_SUCCESS;
1455 #pragma mark Old Driver Calls
1583 printf(
"----------------------\n");
1586 uint8_t * ptr = (uint8_t *)p64;
1591 printf(
"%x ", *ptr++);
1593 printf(
"\n\n", *ptr++);
1598 printf(
"----------------------\n");
1612 printf(
"rp188.DBB %x\n",p64->
rp188.
DBB);
1613 printf(
"rp188.Low %x\n",p64->
rp188.
Low);
1614 printf(
"rp188.High %x\n",p64->
rp188.
High);
1617 printf(
"hUser %x\n",p64->
hUser);
1722 case kIOReturnError:
return "general error";
1723 case kIOReturnNoMemory:
return "can't allocate memory";
1724 case kIOReturnNoResources:
return "resource shortage";
1725 case kIOReturnIPCError:
return "error during IPC";
1726 case kIOReturnNoDevice:
return "no such device";
1727 case kIOReturnNotPrivileged:
return "privilege violation";
1728 case kIOReturnBadArgument:
return "invalid argument";
1729 case kIOReturnLockedRead:
return "device read locked";
1730 case kIOReturnLockedWrite:
return "device write locked";
1731 case kIOReturnExclusiveAccess:
return "exclusive access and device already open";
1732 case kIOReturnBadMessageID:
return "sent/received messages had different msg_id";
1733 case kIOReturnUnsupported:
return "unsupported function";
1734 case kIOReturnVMError:
return "misc. VM failure";
1735 case kIOReturnInternalError:
return "internal error";
1736 case kIOReturnIOError:
return "General I/O error";
1737 case kIOReturnCannotLock:
return "can't acquire lock";
1738 case kIOReturnNotOpen:
return "device not open";
1739 case kIOReturnNotReadable:
return "read not supported";
1740 case kIOReturnNotWritable:
return "write not supported";
1741 case kIOReturnNotAligned:
return "alignment error";
1742 case kIOReturnBadMedia:
return "Media Error";
1743 case kIOReturnStillOpen:
return "device(s) still open";
1744 case kIOReturnRLDError:
return "rld failure";
1745 case kIOReturnDMAError:
return "DMA failure";
1746 case kIOReturnBusy:
return "Device Busy";
1747 case kIOReturnTimeout:
return "I/O Timeout";
1748 case kIOReturnOffline:
return "device offline";
1749 case kIOReturnNotReady:
return "not ready";
1750 case kIOReturnNotAttached:
return "device not attached";
1751 case kIOReturnNoChannels:
return "no DMA channels left";
1752 case kIOReturnNoSpace:
return "no space for data";
1753 case kIOReturnPortExists:
return "port already exists";
1754 case kIOReturnCannotWire:
return "can't wire down physical memory";
1755 case kIOReturnNoInterrupt:
return "no interrupt attached";
1756 case kIOReturnNoFrames:
return "no DMA frames enqueued";
1757 case kIOReturnMessageTooLarge:
return "oversized msg received on interrupt port";
1758 case kIOReturnNotPermitted:
return "not permitted";
1759 case kIOReturnNoPower:
return "no power to device";
1760 case kIOReturnNoMedia:
return "media not present";
1761 case kIOReturnUnformattedMedia:
return "media not formatted";
1762 case kIOReturnUnsupportedMode:
return "no such mode";
1763 case kIOReturnUnderrun:
return "data underrun";
1764 case kIOReturnOverrun:
return "data overrun";
1765 case kIOReturnDeviceError:
return "the device is not working properly!";
1766 case kIOReturnNoCompletion:
return "a completion routine is required";
1767 case kIOReturnAborted:
return "operation aborted";
1768 case kIOReturnNoBandwidth:
return "bus bandwidth would be exceeded";
1769 case kIOReturnNotResponding:
return "device not responding";
1770 case kIOReturnIsoTooOld:
return "isochronous I/O request for distant past!";
1771 case kIOReturnIsoTooNew:
return "isochronous I/O request for distant future";
1772 case kIOReturnNotFound:
return "data was not found";
1773 case MACH_SEND_INVALID_DEST:
return "MACH_SEND_INVALID_DEST";