📄 ixf_api.c
字号:
/*
*---------------------------------------------------------------------------
*
* I N T E L P R O P R I E T A R Y
*
* COPYRIGHT (c) 2001 BY INTEL CORPORATION. ALL RIGHTS
* RESERVED. NO PART OF THIS PROGRAM OR PUBLICATION MAY
* BE REPRODUCED, TRANSMITTED, TRANSCRIBED, STORED IN A
* RETRIEVAL SYSTEM, OR TRANSLATED INTO ANY LANGUAGE OR COMPUTER
* LANGUAGE IN ANY FORM OR BY ANY MEANS, ELECTRONIC, MECHANICAL,
* MAGNETIC, OPTICAL, CHEMICAL, MANUAL, OR OTHERWISE, WITHOUT
* THE PRIOR WRITTEN PERMISSION OF :
*
* INTEL CORPORATION
*
* 2200 MISSION COLLEGE BLVD
*
* SANTA CLARA, CALIFORNIA 95052-8119
*
*---------------------------------------------------------------------------
*/
#include "memory.h"
#include "common_types.h"
#include "common_def.h"
#include "ixf_api_d.h"
#include "devlib.h"
/******************************************************************
* Function : IxfApiInit
*-----------------------------------------------------------------
* Description : This routine initializes the main data structure
* and returns a handle to that structure.
*-----------------------------------------------------------------
* Inputs : baseAddress : Specifies the base address of the device
* chipType : Specifices the type of device
* pChipData : A pointer to an allocated structure.
* Outputs : pChipData : A pointer to the chip data structure.
* This structure is passed to most API
* routines.
*-----------------------------------------------------------------
* Returns : bb_Error_e Returns Error Condition if Not successful
*-----------------------------------------------------------------
* Access Globals : None.
*-----------------------------------------------------------------
******************************************************************/
bb_Error_e
IxfApiInit(void *baseAddress, bb_ChipType_e chipType,
bb_ChipData_t *pChipData)
{
/* Store the input parameters in our data structures. */
pChipData->BaseAddress = (bb_RegPointer_type) baseAddress;
pChipData->ChipType = chipType;
/* Initialize the chip configuration structure */
pChipData->pChipCfg = NULL;
/* Initialize the chip alarm structure */
pChipData->pAlarmCfg = NULL;
/* Initialize the chip's api routines */
pChipData->funcPtr = (void *) getChipFuncPtr(chipType);
return bb_NO_ERROR;
}
/******************************************************************
* Function : IxfApiInitChip
*-----------------------------------------------------------------
* Description : This routine commits the internal register table
* down to the chip and initializes the bb_ChipData_t
* structure.
*-----------------------------------------------------------------
* Inputs : pChipData : A pointer to an allocated structure.
* pTable : Table to be committed to the device.
* Outputs : None.
*-----------------------------------------------------------------
* Returns : bb_Error_e Returns Error Condition if Not successful
*-----------------------------------------------------------------
* Access Globals : None.
*-----------------------------------------------------------------
******************************************************************/
bb_Error_e
IxfApiInitChip(bb_ChipData_t *pChipData, InitRegTable_t *pTable)
{
CommonFunctionPointers_t *pChipFuncPtrs;
bb_Error_e rc = bb_NO_ERROR;
/* Check to see if the specific chip's function pointer table
has be initialized */
if(((ChipFunctionPointers_t *) pChipData->funcPtr) != NULL)
{
if(((ChipFunctionPointers_t *) pChipData->funcPtr)->tCommonFuncPtr ==
NULL)
{
/* Set Return Code */
rc = bb_FN_NOT_SUPPORTED;
}
}
else
{
/* Set Return Code */
rc = bb_FN_NOT_SUPPORTED;
}
/* Assign the chip's COMMON function pointers */
if (rc != bb_FN_NOT_SUPPORTED)
{
pChipFuncPtrs =
((ChipFunctionPointers_t *) pChipData->funcPtr)->tCommonFuncPtr;
/* If function pointer is valid */
if (pChipFuncPtrs->InitChipFuncPtr)
{
/* Call Function Pointer */
rc = (pChipFuncPtrs->InitChipFuncPtr)(pChipData, pTable);
}
else
{
rc = bb_FN_NOT_SUPPORTED;
}
}
return rc;
}
#if 0
/******************************************************************
* Function : IxfApiAllocDataStructureMem
*-----------------------------------------------------------------
* Description : This routine dynamically allocates memory within
* the "pChipData" parameter for those members that
* need dynamic allocation.
*-----------------------------------------------------------------
* Inputs : pChipData : A pointer to the chip data structure without
* pointers memory allocation.
* Outputs : pChipData : A pointer to the chip data structure with
* pointer memory allocation.
*-----------------------------------------------------------------
* Returns :
*-----------------------------------------------------------------
* Access Globals : None.
*-----------------------------------------------------------------
* Comments : See IxfApiInit for the completion of the initialization
******************************************************************/
bb_Error_e
IxfApiAllocDataStructureMem(bb_ChipData_t *pChipData)
{
CommonFunctionPointers_t *pChipFuncPtrs;
bb_Error_e rc = bb_NO_ERROR;
/* Check to see if the specific chip's function pointer table
has be initialized */
if(((ChipFunctionPointers_t *) pChipData->funcPtr) != NULL)
{
if(((ChipFunctionPointers_t *) pChipData->funcPtr)->tCommonFuncPtr ==
NULL)
{
/* Set Return Code */
rc = bb_FN_NOT_SUPPORTED;
}
}
else
{
/* Set Return Code */
rc = bb_FN_NOT_SUPPORTED;
}
/* Assign the chip's COMMON function pointers */
if (rc != bb_FN_NOT_SUPPORTED)
{
pChipFuncPtrs =
((ChipFunctionPointers_t *) pChipData->funcPtr)->tCommonFuncPtr;
/* If function pointer is valid */
if (pChipFuncPtrs->AllocFuncPtr)
{
/* Call Function Pointer */
rc = (pChipFuncPtrs->AllocFuncPtr)(pChipData);
}
else
{
rc = bb_FN_NOT_SUPPORTED;
}
}
return rc;
}
/******************************************************************
* Function : IxfApiDeAllocMemory
*-----------------------------------------------------------------
* Description : This routine frees the dynamically allocated memory
* within the "pChipData" structure
*-----------------------------------------------------------------
* Inputs : pChipData : A pointer to the chip data structure.
* Outputs : None.
*-----------------------------------------------------------------
* Returns : Status
*-----------------------------------------------------------------
* Access Globals : None.
*-----------------------------------------------------------------
* Comments : None.
******************************************************************/
bb_Error_e
IxfApiDeAllocMemory(bb_ChipData_t *pChipData)
{
CommonFunctionPointers_t *pChipFuncPtrs;
bb_Error_e rc = bb_NO_ERROR;
/* Check to see if the specific chip's function pointer table
has be initialized */
if(((ChipFunctionPointers_t *) pChipData->funcPtr) != NULL)
{
if(((ChipFunctionPointers_t *) pChipData->funcPtr)->tCommonFuncPtr ==
NULL)
{
/* Set Return Code */
rc = bb_FN_NOT_SUPPORTED;
}
}
else
{
/* Set Return Code */
rc = bb_FN_NOT_SUPPORTED;
}
/* Assign the chip's COMMON function pointers */
if (rc != bb_FN_NOT_SUPPORTED)
{
pChipFuncPtrs =
((ChipFunctionPointers_t *) pChipData->funcPtr)->tCommonFuncPtr;
/* If function pointer is valid */
if (pChipFuncPtrs->DeAllocFuncPtr)
{
/* Call Function Pointer */
rc = (pChipFuncPtrs->DeAllocFuncPtr)(pChipData);
}
else
{
rc = bb_FN_NOT_SUPPORTED;
}
}
return rc;
}
/******************************************************************
* Function : IxfApiSetCfg
*-----------------------------------------------------------------
* Description : This routine is used to configure the chip.
* Many different types of configurations could be
* performed with the combination of SelCfg and the
* generic pointer of the ptCfg.
*-----------------------------------------------------------------
* Inputs : pChipData : pointer to the chip information.
* ptSegment : pointer to chip segment structure
* SelCfg : enum value defining what configuration
* needs to be set
* Outputs : None.
*-----------------------------------------------------------------
* Returns : bb_NO_ERROR, bb_INV_PARAMETER
*-----------------------------------------------------------------
* Access Globals : None.
*-----------------------------------------------------------------
* Comments :
******************************************************************/
bb_Error_e
IxfApiSetCfg(bb_ChipData_t *pChipData, bb_ChipSegment_t *ptSegment,
bb_SelConfig_e SelCfg)
{
CommonFunctionPointers_t *pChipFuncPtrs;
bb_Error_e rc = bb_NO_ERROR;
/* Check to see if the specific chip's function pointer table
has be initialized */
if(((ChipFunctionPointers_t *) pChipData->funcPtr) != NULL)
{
if(((ChipFunctionPointers_t *) pChipData->funcPtr)->tCommonFuncPtr ==
NULL)
{
/* Set Return Code */
rc = bb_FN_NOT_SUPPORTED;
}
}
else
{
/* Set Return Code */
rc = bb_FN_NOT_SUPPORTED;
}
/* Assign the chip's COMMON function pointers */
if (rc != bb_FN_NOT_SUPPORTED)
{
pChipFuncPtrs =
((ChipFunctionPointers_t *) pChipData->funcPtr)->tCommonFuncPtr;
/* If function pointer is valid */
if (pChipFuncPtrs->SetCfgFuncPtr)
{
/* Call Function Pointer */
rc = (pChipFuncPtrs->SetCfgFuncPtr)(pChipData, ptSegment,
SelCfg);
}
else
{
rc = bb_FN_NOT_SUPPORTED;
}
}
return rc;
}
/******************************************************************
* Function : IxfApiGetCfg
*-----------------------------------------------------------------
* Description : This routine is used to get the configuration of
* the chip. Many different types of configurations
* could be performed with the combination of SelCfg
* and the sgeneric pointer of the ptCfg.
*-----------------------------------------------------------------
* Inputs : pChipData : pointer to the chip information.
* ptSegment : pointer to chip segment structure
* SelCfg : enum value defining what configuration
* needs to be retrieved
* Outputs : None
*-----------------------------------------------------------------
* Returns : bb_NO_ERROR, bb_INV_PARAMETER
*-----------------------------------------------------------------
* Access Globals : None.
*-----------------------------------------------------------------
* Comments :
******************************************************************/
bb_Error_e
IxfApiGetCfg(bb_ChipData_t *pChipData, bb_ChipSegment_t *ptSegment,
bb_SelConfig_e SelCfg)
{
CommonFunctionPointers_t *pChipFuncPtrs;
bb_Error_e rc = bb_NO_ERROR;
/* Check to see if the specific chip's function pointer table
has be initialized */
if(((ChipFunctionPointers_t *) pChipData->funcPtr) != NULL)
{
if(((ChipFunctionPointers_t *) pChipData->funcPtr)->tCommonFuncPtr ==
NULL)
{
/* Set Return Code */
rc = bb_FN_NOT_SUPPORTED;
}
}
else
{
/* Set Return Code */
rc = bb_FN_NOT_SUPPORTED;
}
/* Assign the chip's COMMON function pointers */
if (rc != bb_FN_NOT_SUPPORTED)
{
pChipFuncPtrs =
((ChipFunctionPointers_t *) pChipData->funcPtr)->tCommonFuncPtr;
/* If function pointer is valid */
if (pChipFuncPtrs->GetCfgFuncPtr)
{
/* Call Function Pointer */
rc = (pChipFuncPtrs->GetCfgFuncPtr)(pChipData, ptSegment,
SelCfg);
}
else
{
rc = bb_FN_NOT_SUPPORTED;
}
}
return rc;
}
/******************************************************************
* Function : IxfApiGetStatus
*-----------------------------------------------------------------
* Description : Gets the Status.
*-----------------------------------------------------------------
* Inputs : pChipData : Initialized Chip Data
* section : Determines the section(block) to get the
* status from.
* selStatus : Type of Status:
* Outputs : pStatus : place to put Status.
*-----------------------------------------------------------------
* Returns : bb_Error_e Returns Error Condition if Not successful
*-----------------------------------------------------------------
* Access Globals : None.
*-----------------------------------------------------------------
* Comments : None.
******************************************************************/
bb_Error_e
IxfApiGetStatus(bb_ChipData_t *pChipData, bb_ChipSegment_t *section,
bb_SelStatus_e selStatus, void *pStatus)
{
CommonFunctionPointers_t *pChipFuncPtrs;
bb_Error_e rc = bb_NO_ERROR;
/* Check to see if the specific chip's function pointer table
has be initialized */
if(((ChipFunctionPointers_t *) pChipData->funcPtr) != NULL)
{
if(((ChipFunctionPointers_t *) pChipData->funcPtr)->tCommonFuncPtr ==
NULL)
{
/* Set Return Code */
rc = bb_FN_NOT_SUPPORTED;
}
}
else
{
/* Set Return Code */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -