Created
April 20, 2014 13:34
-
-
Save superwills/11114309 to your computer and use it in GitHub Desktop.
ioCheck
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map<IOReturn,string> ioMakeErrorMap() | |
{ | |
map<IOReturn,string> map; | |
map[ kIOReturnSuccess ] = "kIOReturnSuccess KERN_SUCCESS // OK"; | |
map[ kIOReturnError ] = " // general error"; | |
map[ kIOReturnNoMemory ] = " // can't allocate memory "; | |
map[ kIOReturnNoResources ] = "resource shortage "; | |
map[ kIOReturnIPCError ] = "error during IPC "; | |
map[ kIOReturnNoDevice ] = "no such device "; | |
map[ kIOReturnNotPrivileged ] = "privilege violation "; | |
map[ kIOReturnBadArgument ] = "invalid argument "; | |
map[ kIOReturnLockedRead ] = "device read locked "; | |
map[ kIOReturnLockedWrite ] = "device write locked "; | |
map[ kIOReturnExclusiveAccess ] = "exclusive access and device already open "; | |
map[ kIOReturnBadMessageID ] = "sent/received messages had different msg_id"; | |
map[ kIOReturnUnsupported ] = "unsupported function "; | |
map[ kIOReturnVMError ] = "misc. VM failure "; | |
map[ kIOReturnInternalError ] = "internal error "; | |
map[ kIOReturnIOError ] = "General I/O error "; | |
//map[ kIOReturn???Error iokit_common_err(0x2cb) // ??? | |
map[ kIOReturnCannotLock ] = "can't acquire lock"; | |
map[ kIOReturnNotOpen ] = "device not open "; | |
map[ kIOReturnNotReadable ] = "read not supported "; | |
map[ kIOReturnNotWritable ] = "write not supported "; | |
map[ kIOReturnNotAligned ] = "alignment error "; | |
map[ kIOReturnBadMedia ] = "Media Error "; | |
map[ kIOReturnStillOpen ] = "device(s) still open "; | |
map[ kIOReturnRLDError ] = "rld failure "; | |
map[ kIOReturnDMAError ] = "DMA failure "; | |
map[ kIOReturnBusy ] = "Device Busy "; | |
map[ kIOReturnTimeout ] = "I/O Timeout "; | |
map[ kIOReturnOffline ] = "device offline "; | |
map[ kIOReturnNotReady ] = "not ready "; | |
map[ kIOReturnNotAttached ] = "device not attached "; | |
map[ kIOReturnNoChannels ] = "no DMA channels left"; | |
map[ kIOReturnNoSpace ] = "no space for data "; | |
//map[ kIOReturn???Error ] = "??? " | |
map[ kIOReturnPortExists ] = "port already exists"; | |
map[ kIOReturnCannotWire ] = "can't wire down physical memory"; | |
map[ kIOReturnNoInterrupt ] = "no interrupt attached"; | |
map[ kIOReturnNoFrames ] = "no DMA frames enqueued"; | |
map[ kIOReturnMessageTooLarge ] = "oversized msg received on interrupt port"; | |
map[ kIOReturnNotPermitted ] = "not permitted"; | |
map[ kIOReturnNoPower ] = "no power to device"; | |
map[ kIOReturnNoMedia ] = "media not present"; | |
map[ kIOReturnUnformattedMedia ] = "media not formatted"; | |
map[ kIOReturnUnsupportedMode ] = "no such mode"; | |
map[ kIOReturnUnderrun ] = "data underrun"; | |
map[ kIOReturnOverrun ] = "data overrun"; | |
map[ kIOReturnDeviceError ] = "the device is not working properly!"; | |
map[ kIOReturnNoCompletion ] = "a completion routine is required"; | |
map[ kIOReturnAborted ] = "operation aborted"; | |
map[ kIOReturnNoBandwidth ] = "bus bandwidth would be exceeded"; | |
map[ kIOReturnNotResponding ] = "device not responding"; | |
map[ kIOReturnIsoTooOld ] = "isochronous I/O request for distant past!"; | |
map[ kIOReturnIsoTooNew ] = "isochronous I/O request for distant future"; | |
map[ kIOReturnNotFound ] = "data was not found"; | |
map[ kIOReturnInvalid ] = "should never be seen"; | |
return map; | |
} | |
bool ioCheck( IOReturn res, const char* msg ) | |
{ | |
static map<IOReturn,string> ioErrors = ioMakeErrorMap(); | |
if( res != kIOReturnSuccess ) | |
{ | |
printf( "IOError: %s %s\n", msg, ioErrors[res].c_str() ); | |
} | |
return res == kIOReturnSuccess; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment