/*
 *  TI_Errors.h
 *  TI Connect X CommMgr
 *
 *  Created by Stephen L. Reid on Fri Apr 19 2002.
 *  Copyright (c) 2002-2003 Texas Instruments Incorporated. All rights reserved.
 *
 */


#ifndef __TI_ERRORMAC__
#define __TI_ERRORMAC__

#include <IOKit/IOReturn.h>

//========================================================================================
// Errors presented by the TI Communications Shared Library System
// NOTE: These errors are true 32-bit value errors and require an
// OSStatus return variable to receive them.  All API's to the shared
// library are defined as returning a 32-bit return OSStatus value.
// 
//========================================================================================

// These are defined in mach/error.h, included inside of IOReturn.h
//#define err_system( x )				((( x ) & 0x3f ) << 26)
//#define err_sub( x )					((( x ) & 0xfff ) << 14)
//#define err_get_code( errno )				((errno) & 0x3fff)
//#define err_get_subsys( errno )			(((errno) >> 14) & 0xfff)
//#define err_get_system( errno )			(((errno) >> 26) & 0x3f)
//#define err_local					err_system( 0x3e )

#define err_ti					err_sub( 1960 )

#define err_is_system( errno )			((((errno) >> 26) & 0x3f) == 0x3e)
#define err_is_ti( errno )			( err_is_system(errno) & ((((errno) >> 14) & 0xfff) == 1960))

#define	ti_error( errno )			( err_local | err_ti | errno )


#define	errTINoError				kIOReturnSuccess	// No Error
#define	errTIIOPendingError			0x00000001		// I/O Pending

#define	errTIInvalidRequest					ti_error( 1 )		// ioFunction is invalid or unsupported.
#define	errTINoDeviceSupport				ti_error( 2 )		// Device support not present for requested device ID
#define	errTIBadParameterBlock				ti_error( 3 )		// Parameter block missing required information/data
#define	errTICommunicationsChecksum			ti_error( 4 )		// Checksum error during communications
#define	errTICommunicationsTimeout			ti_error( 5 )		// Communications Timeout condition reported
#define	errTIBatteriesTooLow				ti_error( 6 )		// Device Batteries are too low to continue
#define	errTIItemDoesNotExist				ti_error( 7 )		// Requested Item does not exist
#define	errTIItemIsLocked					ti_error( 8 )		// Requested Item is locked and cannot be changed
#define	errTIItemIsArchived					ti_error( 9 )		// Requested Item is Archived and cannot be changed

#define	errTIRequestIsUnsupported			ti_error( 10 )		// ioFunction is not supported by current device	
#define	errTIChannelIsNotOpen				ti_error( 11 )		// Communications channel reference is invalid
#define	errTIChannelIsAlreadyOpen			ti_error( 12 )		// Communications channel is already in use
#define	errTIChannelIsNotAvailable			ti_error( 13 )		// Communications channel req'd is not available
#define	errTINoParameterBlock				ti_error( 14 )		// Missing parameter block
#define	errTINoDataDescriptorPresent		ti_error( 15 )		// On send data selector, no data passed to send
#define	errTIParameterBlockInUseError		ti_error( 16 )		// Parameter Block reuse error
#define	errTIInvalidParameters				ti_error( 17 )		// Parameters to call are incomplete/invalid
#define	errTIDeviceIsNotReady				ti_error( 18 )		// Device is not ready for communications
#define	errTIObjectNameIsRequired			ti_error( 19 )		// ioNamePtr field not filled in PB.

#define	errTIPortNameIsRequired				ti_error( 20 )		// ioNamePtr does not point to a port name.
#define	errTIPortIsNotFound					ti_error( 21 )		// Cannot find communications port to use.
#define	errTIUnableToAllocateBuffer			ti_error( 22 )		// Unable to allocate comm buffer on open.
#define	errTIUnableToSendData				ti_error( 23 )		// Unable to write frame to output port.
#define	errTIUnableToRetrieveData			ti_error( 24 )		// Unable to read frame from input port.
#define	errTIUnableToAllocateMemory			ti_error( 25 )		// Couldn't allocate memory for data
#define	errTIUnableToCreatePB				ti_error( 26 )		// Couldn't create a parameter block
#define	errTINoDirectoryListAvailable		ti_error( 27 )		// No Directory list to retrieve
#define errTIBadCommunicationsSequence		ti_error( 28 )		// A comm packet has arrived that is not in sequence

#define errTIRequestIsNotValid				ti_error( 29 )		// Attempt to use a sequence invalid for the object passed in
#define errTICalculatorMemoryIsFull			ti_error( 30 )		// Calculator is full on attempted send object

#define errTIFlashMemoryIsFull				ti_error( 31 )		// Flash Memory is full (EOR 1)
#define errTIFlashDuplicateName				ti_error( 32 )		// Flash object duplicate name found (EOR 2)
#define errTIFlashInvalidCertificateHdr		ti_error( 33 )		// Flash object invalid certificate found (EOR 6)
#define errTIFlashNoCertificate				ti_error( 34 )		// Flash object no certificate found (EOR 7)
#define errTIFlashBadSignature				ti_error( 35 )		// Flash object signature is bad (EOR 8)
#define errTIFlashCertificateExpired		ti_error( 36 )		// Flash object certficate has expired (EOR 9)
#define errTIFlashCannotReplaceCert			ti_error( 37 )		// Flash certificate cannot be replaced (EOR 10)
#define errTIFlashBadLoadAddress			ti_error( 38 )		// Flash application load address is bad (EOR 11)
#define errTIFlashBatteriesAreTooLow		ti_error( 39 )		// Batteries are too low for flash operations.

// Flash errors specific to CBL2/Labpro devices
#define errTIFlashFrameTooLarge				ti_error( 40 )		// RTS/Send Frame is too large (EOR 20)
#define errTIFlashErrorErasingFlash			ti_error( 41 )		// Error erasing flash memory (hw related) (EOR 21)
#define errTIFlashErrorWritingFlash			ti_error( 42 )		// Error writing flash memory (hw related) (EOR 22)

#define errTIFlashUnknownErrorCode			ti_error( 43 )		// Unknown/Undocumented error code
#define errTIFlashBadObjectFileFormat		ti_error( 44 )		// error encountered reading object file

#define errTIDeviceMismatchOnSend			ti_error( 45 )		// Device mismatch on sending of object
#define errTIDeviceChannelIsOpen			ti_error( 46 )		// Channel endpoint is still open. Close channel.

#define errTICannotDeleteObject				ti_error( 47 )		// GENERIC cannot delete object
#define errTIIllegalDataType				ti_error( 48 )		// Illegal data type code
#define errTIMismatchedDataType				ti_error( 49 )		// Mismatched data types
#define errTIFolderIsNotEmpty				ti_error( 50 )		// Folder is not empty (and cannot be deleted)
#define errTIUnableToDeleteItem				ti_error( 51 )		// unable to delete item
#define errTIObjectTypeIsNotSupported		ti_error( 52 )		// cannot send this type of object to CBL 2/Labpro
#define errTINeedNewerOperatingSystem		ti_error( 53 )		// TI OS is too old to process this request.  Update to newer OS
#define	errTICantUseThisOSUpdate			ti_error( 54 )		// TI OS provided does not apply to this device
#define errTICannotOverwriteObject			ti_error( 55 )		// Cannot overwrite object for some reason.
#define errTICannotOverwriteSystemReserved 	ti_error( 56 )		// Cannot overwrite object due to reserved name
#define errTINameIsIllegalOrInvalid			ti_error( 57 )		// The provided name is illegal
#define errTINameIsReservedOrRestricted		ti_error( 58 )		// The provided name is a restricted or reserved name (ie. 'y1' on a TI92Plus...)
#define errTILoginIsInvalid					ti_error( 59 )		// The login sequence was not detected
#define errTILoginWasAborted				ti_error( 60 )		// The login sequence was aborted
#define errTILoginIsPending					ti_error( 61 )		// The device is waiting for the login sequence

#define errTIOperationCanceled				ti_error( 62 )		// The operation was cancelled by user request
#define errTIItemCannotTranslateForDevice	ti_error( 63 )		// The item cannot be translated to an item for the target device
#define errTIDeviceDoesNotSupportLogin		ti_error( 64 )		// The device does not support the login event.
// Added 12/10/03
#define errTIItemIsTooNew					ti_error( 65 )		// The item is too new and cannot be used on this device.
// Added 03/16/05 - password access over IP (zero-configuration) // :sreid:20050316 
#define errPasswordIsInvalid				ti_error(66)		// the password is not valid
#define errRequiresAuthentication			ti_error(67)		// setting a new password requires the previous password
#define errAuthenticationWasInvalid			ti_error(68)		// the authentication password was not correct
#define errNewPasswordIsSameAsOldPassword	ti_error(69)		// the new password and old password are the same
#define errInsufficientPriveleges			ti_error(70)		// user has insufficient priveleges to set/change password
#define errUnableToChangeSharingSetting		ti_error(71)		// user has insufficient priveleges to change sharing setting.
#define errPasswordError					ti_error(72)		// unknown error occurred in the setting/changing of the password.
#define errMustProvideANewPassword			ti_error(73)		// empty password passed in with no current password set.


// File Support Library specific errors
#define errTIInvalidFileSpecification		ti_error( 100 )		// Invalid or missing file specification
#define errTIFileNotRecognized				ti_error( 101 )		// File is NOT a TI object file
#define errTIFileRecognizedButTooNew		ti_error( 102 )		// File IS a TI File, but is not recognized by this library
#define errTIUnrecognizedObjectFormat		ti_error( 103 )		// Flash object code format is NOT recognized
#define errTIAsynchOperationNotAllowed		ti_error( 104 )		// Asynchronous operation mode not permitted on this operation
#define errTICantAccessDescriptors			ti_error( 105 )		// Cannot properly count the items in the AE Desc list
#define errTICantAccessResources			ti_error( 106 )		// Cannot properly access needed resources
#define errTICantOverwriteExistingFile		ti_error( 107 )		// File specified already exists and did not order to overwrite.
#define errTIUnrecognizedDeviceID			ti_error( 108 )		// On write, device id is not recognized
#define errTIIllegalPBOperation				ti_error( 109 )		// Attempt to destroy a parameter block not owned by the framework
#define errDontAllowToWriteFile             ti_error( 110 )     // we dont want to DnD out from the device.

#endif
