⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 csslib_dy4.c

📁 Curtiss-Wright Controls Embedded Computing公司的cw183板bsp源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/* cssLib.c - Card specific shared service routines *//************************************************************************** * *   Copyright (c) 2006 Curtiss-Wright Controls, Inc. All rights *   reserved.  This Source Code is the Property of Curtiss-Wright *   Controls, Inc. and can only be used in accordance with Source *   Code License Agreement(s) of Curtiss-Wright Controls, Inc. or any *   of its subsidiaries. * **************************************************************************//*modification history--------------------01o 17jan06,tis  remove ss_nvmInit() from cssInit2() and make sure to call it before using any                   cssNvm_xxx() routine to solve dual CPUs booting problem CR#12975.01n 06dec05,tis  added support for SCP-124.01m 30Jun05,rcd  added cssNVMP support thought new ss_nvm interface (CR#2576).01l 26may05,tis  add support for In-Circuit Service Programming (ISP).01k 09may05,tis  add support for CCA-14601j 02may05,aak  - Diab compiler support01i 28apr05,aak  - NVMP not supported on VME-183 (CR#3309);01h,09feb05,tis - modified the functions cssGetCardType(), cssNVM_program(), cssNVM_erase,                   and cssNVM_lock to call the new cssX NVM routines for CCA-145 BSP.                - added cssCheckSum() service call.01g,15feb05,rcd - added fpga RAM size check for 183.01f,14oct04,rcd - added cssXInit call.01e,07oct04,rcd - changed sysIbitInit to bitInit.01d,05oct04,rcd - added check for A32/A24 base address swapped by bootrom.01c,04oct04,tis - add sysIbitInit() to support IBIT.01b,07sep04,rcd - ported to use fwx based services.01a,25feb04,rcd - initial release for VME-182.*//*DESCRIPTIONThis library contains Card Shared Services (CSS) wrapper routines to callfirmware Shared Services.  Some services require interrupts to be disabled.Automatic initialization is done where necessary.INCLUDE FILES: vxCss_dy4.h*//* includes */#include "vxWorks.h"#include "logLib.h"#include "intLib.h"#include "ioLib.h"#include "iosLib.h"#include "tyLib.h"#include "h/drv/bit/bitLib.h"#include "h/drv/dy4/dy4std.h"#include "h/drv/dy4/vxCss_dy4.h"#include "config.h"#ifdef INCLUDE_VME#include "h/drv/vme/universe_dy4.h"#endif#include <stdio.h>#include "semLib.h"#ifdef VME_182#include "dy4182.h"#endif#ifdef VME_183#include "cwv183.h"#include "fpga183.h"#endif #ifdef SCP_124#include "cwcp124.h"#include "fpga124.h"#endif/* defines */#define SEM_TIMEOUT	sysClkRateGet() * 60/* globals *//* locals */static BOOL cssInitialized = FALSE;static BOOL cssNVMInit = FALSE;/* Mutual Exclusion Resource *//*  * Currently, the limitation is to allow access to only one flash  * bank at a time. * A default timeout is used so that tasks are not blocked indefinitely * when a callout to CSS hangs. */LOCAL  SEMAPHORE    flashBankLockSem;static SEM_ID	    flashBankLock;/* external references */IMPORT  int logMsg           (           char * fmt,  /* format string for print */           int    arg1, /* first of six required args for fmt */           int    arg2,           int    arg3,           int    arg4,           int    arg5,           int    arg6           ); /* from sysLib.c */IMPORT      int sysClkRateGet(void);IMPORT ULONG  sysInLong (ULONG);IMPORT UINT32  sysGetUniverseIoBaseAdrs ( void );/* from cssX library */IMPORT void cssXInit(void);IMPORT void fwxInitLocPciData(void);#if (defined (VME_183) || defined (SCP_124))IMPORT UCHAR  sysInByte (ULONG);#elseIMPORT UINT32 ss_getRamBase(void);IMPORT UINT32 ss_getRamSize(void);#endifIMPORT void ss_checkSumCalculation(    const void    *pStartAddress,    const UINT32  uSize,    UINT32        *pResult);IMPORT void ss_nvmInit(void);IMPORT UINT32 ss_nvmErase(UINT32 dest,                           UINT32 size,                           css_nvmp_memory_struct *bankInfo,                          void (*notifyRoutine)(UINT32 progress));IMPORT UINT32 ss_nvmGetInfo(UINT32 operation,                      UINT32 *dest,                      UINT32 param,                      css_nvmp_memory_struct *bankInfo,                      void **result);IMPORT UINT32 ss_nvmLock(UINT32  destAddress,                 UINT32  numBytes,                 UINT32  lock,                 css_nvmp_memory_struct *bankInfo);IMPORT UINT32 ss_nvmProgram    (    UINT32                  srcAddress,    UINT32                  destAddress,    UINT32                  numBytes,    css_nvmp_memory_struct *bankInfo,    UINT32                  buffer,    UINT32                  bufSize,    void                    (*notifyRoutine)(UINT32 progress)    );void ss_nvmPrintError    (    UINT32                  errCode    );#if 0 /* currently not supported */IMPORT int xsvfExecute(UINT8 *startBufferAddress);#endif/***************************************************************************** cssInit - CSS initialization function** This function is invoked to setup the CSS FFW services.  It sets the global* flag cssInitialized when done.  Each CSS wrapper function checks this* flag and returns ERROR if cssInit() has not been called. cssInit is called* from sysHwInit() so the application should not call this function.** NOTE: Kernel services such as malloc are not available since this is called*       in sysHwInit.  Please put functions that require malloc in cssInit2().** RETURNS: N/A** SEE ALSO:	{$BSP_DIR}/src/drv/vxCss/cssLib.c**/STATUS cssInit(void)    {    /* init the cssX support library */    cssXInit();        /* init the pci support library */    fwxInitLocPciData();        cssInitialized = TRUE;    return (OK);    }/***************************************************************************** cssInit2 - CSS post kernel initialization** This function is invoked to setup the CSS FFW services that require* vxWorks Kernel services.  It is called from sysHwInit2().** RETURNS: N/A** SEE ALSO:	{$BSP_DIR}/src/drv/vxCss/cssLib.c**/STATUS cssInit2(void)    {    UINT32 semBInitStatus;     /* semBInit must be used here because of the time this function is called      * in the boot sequence. It is called in sysHwInit(), before any kernel      * capability has been initialized. semBInit() has been tested, and it      * works fine in that type of environment.      */    semBInitStatus = semBInit (&flashBankLockSem, SEM_Q_FIFO, SEM_FULL);    if (semBInitStatus == ERROR)        {        cssNVMInit = FALSE;        return (ERROR);        }    /* We are doing this just to avoid the use of an & in every call to     * semTake() or semGive()!     */    flashBankLock = &flashBankLockSem;    return (OK);    }/***************************************************************************** cssGetLocalRam - get local RAM base address and size from FFW** This routine calls Get_local_map() to retrieve the RAM base address, and* size.** RETURNS: OK always.** SEE ALSO:	{$BSP_DIR}/src/drv/vxCss/cssLib.c, cssInit()** History*/STATUS	cssGetLocalRam( char **localBase, UINT *localSize)    {#if (defined(VME_183) || defined (SCP_124))    /* on the 183 we can read it from the FPGA */    UINT8 fpgaBoardConfig = sysInByte((ULONG)FPGA_BOARD_CONFIG);    /* UINT32 pBase = (UINT32*)  */    switch(fpgaBoardConfig & 0x0f)        {        case 1:#ifdef SCP_124        case 14:#endif             *localSize = 0x20000000;            break;        case 2:#ifdef SCP_124        case 15:#endif                     *localSize = 0x40000000;            break;        case 3:             *localSize = 0x40000000;            break;        case 4:             *localSize = 0x80000000;            break;        case 5:            *localSize = 0x80000000;            break;        default:            *localSize = 0x20000000;            break;        }    *localBase = NULL;#else  /*else VME_182*/    (UINT32) *localBase = ss_getRamBase();    (UINT32) *localSize = ss_getRamSize();#endif /*VME_183*/    return OK;    }#ifdef INCLUDE_VME/***************************************************************************** cssGetVmeA32Image - CSS Wrapper function for CSS_GetVmeA32BaseAddressNSize** This routine provides a wrapper for the CSS Service call to* get the A32 address and image size.** Do not call this function to get an accurate picture of what the VME map is* after sysHwInit. The BSP changes the map that FFW sets up and the FFW * doesn't know about it. To get an accurate picture of the VME map, * call sysVmeMapShow().** RETURNS: OK always.** SEE ALSO:	{$BSP_DIR}/src/drv/vxCss/cssLib.c, cssInit(), * CSS_GetVmeA32BaseAddressNSize** History* */STATUS	cssGetVmeA32Image	(	char **vmeA32Base, 	/* pointer to pointer to return A32 address */	UINT *vmeA32Size	/* pointer to UINT to return A32 size       */	)	{	  int	ps;	  UINT32 temp = 0;		  if (cssInitialized == FALSE)	    {	      return (ERROR);	    }			  ps = intLock();	  temp = sysInLong((UINT32)(UNIVERSE_VSI1_BS));          /* check if this is an A32 Address programmed by firmware */          /* any address greater than the A24 range is acceptable */          if(temp > (0x10000 + VME_A24_MSTR_SIZE)) 	      {              /* use this image register set */              *vmeA32Size = (UINT) ((sysInLong((UINT32)(UNIVERSE_VSI1_BD))) - temp);	      }          else	      {	      /* the vxWorks bootrom has already done the Job, so the result is in VSI0 */               temp = sysInLong((UINT32)(UNIVERSE_VSI0_BS));	      *vmeA32Size = (UINT) ((sysInLong((UINT32)(UNIVERSE_VSI0_BD))) - temp);	      }      *vmeA32Base =  (char *) temp;	  intUnlock (ps);		  return (OK);	}/***************************************************************************** cssGetVmeA24Image - CSS Wrapper function for CSS_GetVmeA24BaseAddressNSize** This routine provides a wrapper for the CSS service call to* get the A24 address and image size.** Do not call this function to get an accurate picture of what the VME map is* after sysHwInit. The BSP changes the map that FFW sets up and the FFW * doesn't know about it. To get an accurate picture of the VME map, * call sysVmeMapShow().*** RETURNS: OK always** SEE ALSO:	{$BSP_DIR}/src/drv/vxCss/cssLib.c, cssInit(), * CSS_GetVmeA24BaseAddressNSize** History* */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -