📄 txc_envoy_drv_mgmt_api.c
字号:
/* verify the device actually exists at the base addr */
switch (deviceVersionData.partNumber)
{
case ENVOY_CE2_DEVICE_NUMBER:
/* save the device type & set the return handle to the correct value*/
envoyDatabase.envoyDeviceData[i].deviceType = ENVOY_CE2;
registerDeviceDataPtr->handle = i;
error = TXC_NO_ERR;
break;
case ENVOY_CE4_DEVICE_NUMBER:
/* save the device type & set the return handle to the correct value*/
envoyDatabase.envoyDeviceData[i].deviceType = ENVOY_CE4;
registerDeviceDataPtr->handle = i;
error = TXC_NO_ERR;
break;
default :
/* the device type did not match, deactivate the handle */
envoyDatabase.envoyDeviceData[i].deviceActive = TXC_FALSE;
envoyDatabase.envoyDeviceData[i].baseAddr = TXC_NULL;
registerDeviceDataPtr->handle = TXC_U16_INVALID;
error = TXC_DEVICE_NOT_FOUND_ERR;
break;
} /* end of switch */
} /* end of if device not active */
/* test if an available handle was found, if so, break out of for loop */
if (foundAvailHandle != TXC_FALSE)
break;
}/* end of for loop */
}
/* this will return TXC_WARNING if the base address was found, TXC_NO_ERR if a handle
was available, or TXC_DEVICE_INIT_ERR is all handles were used */
return error;
}
/*--------------------------------------------------------------------------*
FUNCTION: TXC_ENVOY_UnregisterDevice
DESCRIPTION: This function deletes a device from the software driver.
The device delete is the complement of the device create function; it
frees the handle, but leaves the device configuration intact. This
function will not affect any live traffic already passing in the device.
INPUTS: handle: Instance of the Envoy device to delete.
RETURNS: TXC_NO_ERR or an appropriate specific error code listed in
appendix. This function will return a TXC_WARNING if the device handle
was already deleted or never created at the base address.
REVISION HISTORY:
Rev Date Author Description
----- ------- ------------ -----------------
0.5.0 6/03/04 F. Giannella Initial release (beta)
*--------------------------------------------------------------------------*/
TXC_U16BIT TXC_ENVOY_UnregisterDevice (TXC_U16BIT handle)
{
TXC_U16BIT error;
/* check if the handle is out of range */
if (handle >= ENVOY_MAX_DEVICES)
return TXC_INVALID_HANDLE_ERR;
/* check if the handle is NOT active */
if (envoyDatabase.envoyDeviceData[handle].deviceActive == TXC_FALSE)
{
error = TXC_WARNING;
}
/* clear out the database */
else
{
/* clear out the database */
memset (&envoyDatabase.envoyDeviceData[handle], 0, sizeof (ENVOY_DEVICE_DATABASE) );
error = TXC_NO_ERR;
}
/* return the error code */
return error;
}
/*--------------------------------------------------------------------------*
FUNCTION: TXC_ENVOY_DeviceReset
DESCRIPTION: The device-reset function allows the user to reset the
entire device or selected portions of it.
INPUTS: handle: Instance of the Envoy device to reset
deviceResetType: a pointer to type ENVOY_DEV_RESET_STRUCT.
RETURNS: TXC_NO_ERR or an appropriate specific error code
REVISION HISTORY:
Rev Date Author Description
----- ------- ------------ -----------------
0.5.0 6/03/04 F. Giannella Initial release (beta)
*--------------------------------------------------------------------------*/
TXC_U16BIT TXC_ENVOY_DeviceReset(TXC_U16BIT handle, ENVOY_DEV_RESET_STRUCT * deviceResetTypePtr)
{
TXC_U16BIT error;
/* first, validate the input */
error = ENVOY_DeviceResetValid (handle, deviceResetTypePtr);
/* only if the device is active perform this function */
#ifdef TXC_ENVOY_VIRTUAL_DEVICE_MODE
/* do nothing except return validation error */
#else /* NOT TXC_ENVOY_VIRTUAL_DEVICE_MODE */
if (error == TXC_NO_ERR)
error = ENVOY_DeviceResetReal (handle, deviceResetTypePtr);
#endif
/* return the error code */
return error;
}
/* this function validates the parameters */
static TXC_U16BIT ENVOY_DeviceResetValid
(TXC_U16BIT handle, ENVOY_DEV_RESET_STRUCT * deviceResetTypePtr)
{
TXC_U16BIT error;
/* check the handle. This may return invalid handle or driver not created */
error = ENVOY_DbVerifyHandle (handle);
/* now check the parameters */
if (error == TXC_NO_ERR)
{
/* check the resetType variable */
if (deviceResetTypePtr->resetType >= ENVOY_END_OF_DEV_RESET_ENUM)
{
error = TXC_INVALID_PARM_ERR;
deviceResetTypePtr->resetType = ENVOY_DEV_RESET_ENUM_ERR;
}
} /* end of in no error */
/* return the error code */
return error;
}
/*--------------------------------------------------------------------------*
FUNCTION: TXC_ENVOY_DriverVersion
DESCRIPTION: This function retrieves current device driver software
version numbers.
INPUTS: driverVersionDataPtr: a pointer to type ENVOY_DRIVER_VERSION_STRUCT.
RETURNS: TXC_NO_ERR or an appropriate specific error code listed in
appendix.
REVISION HISTORY:
Rev Date Author Description
----- ------- ------------ -----------------
0.5.0 6/03/04 F. Giannella Initial release (beta)
*--------------------------------------------------------------------------*/
TXC_U16BIT TXC_ENVOY_DriverVersion (ENVOY_DRIVER_VERSION_STRUCT * driverVersionDataPtr)
{
driverVersionDataPtr->majorVersion = TXC_ENVOY_MAJOR_VERSION;
driverVersionDataPtr->minorVersion = TXC_ENVOY_MINOR_VERSION;
driverVersionDataPtr->patchVersion = TXC_ENVOY_PATCH_VERSION;
return TXC_NO_ERR;
}
/*--------------------------------------------------------------------------*
FUNCTION: TXC_ENVOY_DeviceVersion
DESCRIPTION: This function retrieves standard JTAG identification
information from the device.
INPUTS: handle: Instance of the Envoy device from which to read the version.
deviceVersionDataPtr: a pointer to type ENVOY_DEVICE_VERSION_STRUCT.
RETURNS: TXC_NO_ERR or an appropriate specific error code listed in
appendix.
REVISION HISTORY:
REVISION HISTORY:
Rev Date Author Description
----- ------- ------------ -----------------
0.5.0 6/03/04 F. Giannella Initial release (beta)
*--------------------------------------------------------------------------*/
TXC_U16BIT TXC_ENVOY_DeviceVersion (TXC_U16BIT handle,
ENVOY_DEVICE_VERSION_STRUCT * deviceVersionDataPtr)
{
TXC_U16BIT error;
/* first, validate the input */
error = ENVOY_DbVerifyHandle (handle);
/* only if the device is active perform this function */
#ifdef TXC_ENVOY_VIRTUAL_DEVICE_MODE
if (error == TXC_NO_ERR)
{
deviceVersionDataPtr->partNumber = 0x6842;
deviceVersionDataPtr->manufId = 107;
deviceVersionDataPtr->version = 0;
error = TXC_NO_ERR;
}
#else /* NOT TXC_ENVOY_VIRTUAL_DEVICE_MODE */
if (error == TXC_NO_ERR)
error = ENVOY_DeviceVersionReal (handle, deviceVersionDataPtr);
#endif
/* return the error code */
return error;
}
/****************************************************************************
** End of Module **
****************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -