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

📄 syslib.c

📁 VxWorks下 MV2400的BSP源码
💻 C
📖 第 1 页 / 共 5 页
字号:
	 * Do dynamic memory sizing.	 *	 * Since Hawk memory controller chip has already been set to	 * control all memory, just read and interpret its DRAM Attributes	 * Register.	 */	for (i = 0; i < NELEMENTS(dramAttr); i++)	    {	    for (j = 0; j < 4; j++)	        {		if (dramAttr[i][j] & 0x80)	            {		    dramIndex = dramAttr[i][j] & 0x0F;		    sysPhysMemSize += dramSize [dramIndex];	            }		}	    }        /* Adjust initial DRAM size to actual physical memory. */        sysPhysMemDesc[1].len = (ULONG)sysPhysMemSize -			        (ULONG)sysPhysMemDesc[1].physicalAddr;#else /* not LOCAL_MEM_AUTOSIZE */	/* Don't do auto-sizing, use defined constants. */	sysPhysMemSize = (char *)(LOCAL_MEM_LOCAL_ADRS + LOCAL_MEM_SIZE);#endif /* LOCAL_MEM_AUTOSIZE */#ifdef EXTENDED_VME        /* check for invalid DRAM/VME A32 configuration */        if ((UINT32)sysPhysMemSize > VME_A32_MSTR_LOCAL)            {            int  dscEn;	    char dbgMsg [80];	    sprintf (dbgMsg,	    "\r\n\aERROR: Increase VME_A32_MSTR_LOCAL to at least 0x%x.\r\n",	    (UINT)sysMemTop()); 	    sysDebugMsg (dbgMsg, CONTINUE_EXECUTION);            /*              * Find and adjust initial starting addresses of VME PCI memory              * to allow board to come up.              */            for (dscEn = 0; dscEn < sysPhysMemDescNumEnt; dscEn++)                {                if ((UINT32)sysPhysMemDesc[dscEn].virtualAddr ==                    VME_A32_MSTR_LOCAL)                    {                    sysPhysMemDesc[dscEn].virtualAddr = (void *)sysPhysMemSize;                    sysPhysMemDesc[dscEn].physicalAddr = (void *)sysPhysMemSize;                    break;                    }                }	    }#endif /* EXTENDED_VME */	}    return sysPhysMemSize;    }/********************************************************************************* sysMemTop - get the address of the top of VxWorks memory** This routine returns a pointer to the first byte of memory not* controlled or used by VxWorks.** The user can reserve memory space by defining the macro USER_RESERVED_MEM* in config.h.  This routine returns the address of the reserved memory* area.  The value of USER_RESERVED_MEM is in bytes.** RETURNS: The address of the top of VxWorks memory.*/char * sysMemTop (void)    {    static char * memTop = NULL;    if (memTop == NULL)	{	memTop = sysPhysMemTop () - USER_RESERVED_MEM;	}    return memTop;    }/******************************************************************************** sysToMonitor - transfer control to the ROM monitor** This routine transfers control to the ROM monitor.  Normally, it is called* only by reboot()--which services ^X--and by bus errors at interrupt level.* However, in some circumstances, the user may wish to introduce a* <startType> to enable special boot ROM facilities.** RETURNS: Does not return.*/STATUS sysToMonitor    (    int startType	/* parameter passed to ROM to tell it how to boot */    )    {    FUNCPTR pRom = (FUNCPTR) (ROM_TEXT_ADRS + 4); /* Warm reboot */#if defined(INCLUDE_CACHE_SUPPORT) && defined(INCLUDE_CACHE_L2)    sysL2CacheDisable ();	/* Disable the L2 Cache */#endif    cacheDisable (0);   	/* Disable the Instruction Cache */    cacheDisable (1);   	/* Disable the Data Cache */    sysUniverseReset ();	/* reset Universe chip */    sysSerialReset ();		/* reset serial devices */    hawkErrClr ();		/* clear Hawk error conditions */    /* Clear the MSR */    vxMsrSet (0);    (*pRom) (startType);    return (OK);	/* in case we ever continue from ROM monitor */    }/******************************************************************************** sysHwInit2 - initialize additional system hardware** This routine connects system interrupt vectors and configures any * required features not configured by sysHwInit().** RETURNS: N/A*/void sysHwInit2 (void)    {    static BOOL configured = FALSE;    /* Int connects for various devices */    if (!configured)	{	/* connect Vme to PCI interrupt */	intConnect (INUM_TO_IVEC(UNIV_INT_VEC), sysUnivVmeIntr, 0);	/* interrupts can only be turned on ultimately by the PIC int ctrlr */	intEnable (UNIV_INT_LVL);#ifdef INCLUDE_HAWK_AUXCLK        sysAuxClkInit ();        intConnect (INUM_TO_IVEC(TIMER0_INT_VEC), sysAuxClkInt, 0);        intEnable (TIMER0_INT_LVL);#endif /* INCLUDE_HAWK_AUXCLK */	/* initialize serial interrupts */	sysSerialHwInit2();        /* connect a dummy routine for the spurious interrupt (0x07) */        intConnect (INUM_TO_IVEC(PP_INT_LVL), sysSpuriousIntHandler, 0);#ifdef INCLUDE_BPE        /* enable processor data and address bus parity checking */        sysConfigBpe ();#endif#ifdef INCLUDE_CACHE_L2#ifdef INCLUDE_CACHE_SUPPORT#ifdef USER_L2_CACHE_ENABLE	/* initialize the L2 cache */	sysL2CacheInit();#else	sysL2CacheDisable();#endif#endif#endif#ifdef INCLUDE_NETWORK        sysNetHwInit2 ();#endif        /* report any errors detected before they could be reported. */        reportBootromErrors ();	configured = TRUE;	}    }/******************************************************************************** sysProcNumGet - get the processor number** This routine returns the processor number for the CPU board, which is* set with sysProcNumSet().** RETURNS: The processor number for the CPU board.** SEE ALSO: sysProcNumSet()*/int sysProcNumGet (void)    {    return (sysProcNum);    }/******************************************************************************** sysProcNumSet - set the processor number** This routine sets the processor number for the CPU board.  Processor numbers* should be unique on a single backplane.  It also maps local resources onto* the VMEbus.** RETURNS: N/A** SEE ALSO: sysProcNumGet()**/void sysProcNumSet    (    int 	procNum			/* processor number */    )    {    /*     *	Init global variable - this needs to be done before     *	calling sysUniverseInit2() because it calls sysProcNumGet()     *	via the MACRO definition.     */    sysProcNum = procNum;    /*     *	Set up the node's VME slave decoders.     */    sysUniverseInit2(procNum);    }/* miscellaneous support routines *//******************************************************************************** sysLocalToBusAdrs - convert a local address to a bus address** This routine returns a VMEbus address as it would be seen on the bus.* The local address that is passed into this routine is the address of* the local resource as seen by the CPU.** RETURNS: OK, or ERROR if the address space is unknown or the mapping is not* possible.** SEE ALSO: sysBusToLocalAdrs()*/ STATUS sysLocalToBusAdrs    (    int 	adrsSpace,	/* bus address space where busAdrs resides */    char *	localAdrs,	/* local address to convert */     char **	pBusAdrs	/* where to return bus address */     )    {    switch (adrsSpace)        {        case VME_AM_EXT_SUP_PGM:        case VME_AM_EXT_SUP_DATA:        case VME_AM_EXT_USR_PGM:        case VME_AM_EXT_USR_DATA:	    if ((VME_A32_SLV_SIZE != 0) &&		((ULONG)localAdrs >= VME_A32_SLV_LOCAL) &&		((ULONG)localAdrs < (VME_A32_SLV_LOCAL + VME_A32_SLV_SIZE)))		{                *pBusAdrs = localAdrs + (VME_A32_SLV_BUS - VME_A32_SLV_LOCAL);                return (OK);                }	    /* localAdrs within VME Hardware register range? */	    if (((ULONG)localAdrs >= CPU_VME_HW_REGS_BASE) &&		((ULONG)localAdrs < (CPU_VME_HW_REGS_BASE +					 CPU_VME_HW_REGS_SZ)))		 {		 *pBusAdrs = (localAdrs - CPU_VME_HW_REGS_BASE) +			      (VME_A32_REG_BASE + (sysProcNumGet() *						   VME_A32_REG_SIZE));		 return (OK);		 }            else                return (ERROR);        case VME_AM_STD_SUP_PGM:        case VME_AM_STD_SUP_DATA:        case VME_AM_STD_USR_PGM:        case VME_AM_STD_USR_DATA:	    if ((VME_A24_SLV_SIZE != 0) &&		((ULONG)localAdrs >= VME_A24_SLV_LOCAL) &&		((ULONG)localAdrs < (VME_A24_SLV_LOCAL + VME_A24_SLV_SIZE)))		{                *pBusAdrs = localAdrs + (VME_A24_SLV_BUS - VME_A24_SLV_LOCAL);                return (OK);                }            else                return (ERROR);        case VME_AM_SUP_SHORT_IO:        case VME_AM_USR_SHORT_IO:	    if ((VME_A16_SLV_SIZE != 0) &&		((ULONG)localAdrs >= VME_A16_SLV_LOCAL) &&		((ULONG)localAdrs < (VME_A16_SLV_LOCAL + VME_A16_SLV_SIZE)))		{                *pBusAdrs = localAdrs + (VME_A16_SLV_BUS - VME_A16_SLV_LOCAL);                return (OK);                }            else                return (ERROR);         default:            return (ERROR);        }    }/******************************************************************************** sysBusToLocalAdrs - convert a bus address to a local address** This routine returns a local address that is used to access the VMEbus.* The bus address that is passed into this routine is the VMEbus address* as it would be seen on the bus.** RETURNS: OK, or ERROR if the address space is unknown or the mapping is not* possible.** SEE ALSO: sysLocalToBusAdrs()*/STATUS sysBusToLocalAdrs    (    int  	adrsSpace, 	/* bus address space where busAdrs resides */    char *	busAdrs,   	/* bus address to convert */    char **	pLocalAdrs 	/* where to return local address */    )    {    switch (adrsSpace)	{	case VME_AM_EXT_SUP_PGM:	case VME_AM_EXT_USR_PGM:	case VME_AM_EXT_SUP_DATA:	case VME_AM_EXT_USR_DATA:	    if ((VME_A32_MSTR_SIZE != 0) &&		((ULONG) busAdrs >= VME_A32_MSTR_BUS) &&		((ULONG) busAdrs < (VME_A32_MSTR_BUS + VME_A32_MSTR_SIZE)))		{	    	*pLocalAdrs = (char *)busAdrs + (VME_A32_MSTR_LOCAL -				                 VME_A32_MSTR_BUS);	    	return (OK);		}	    /*	     *	This handles the VME LM/SIG/SEM regs window	     */	    if (((ULONG) busAdrs >= VME_A32_REG_BASE) &&		((ULONG) busAdrs < (VME_A32_REG_BASE +				   VME_A32_REG_SPACE)))		{	    	*pLocalAdrs = (char *)busAdrs + (CPU_VME_WINDOW_REG_BASE -				                 VME_A32_REG_BASE);	    	return (OK);		}	    return (ERROR);	    break;	case VME_AM_STD_SUP_PGM:	case VME_AM_STD_USR_PGM:	case VME_AM_STD_SUP_DATA:	case VME_AM_STD_USR_DATA:	    if ((VME_A24_MSTR_SIZE == 0) ||		((ULONG) busAdrs < VME_A24_MSTR_BUS) ||		((ULONG) busAdrs >= (VME_A24_MSTR_BUS + VME_A24_MSTR_SIZE)))		{		return (ERROR);		}	    *pLocalAdrs = (char *) busAdrs +			    (VME_A24_MSTR_LOCAL - VME_A24_MSTR_BUS);	    return (OK);	    break;        case VME_AM_SUP_SHORT_IO:        case VME_AM_USR_SHORT_IO:	    if ((VME_A16_MSTR_SIZE == 0) ||		((ULONG) busAdrs < VME_A16_MSTR_BUS) ||		((ULONG) busAdrs >= (VME_A16_MSTR_BUS + VME_A16_MSTR_SIZE)))		{		return (ERROR);		}            *pLocalAdrs = (char *) busAdrs + 			    (VME_A16_MSTR_LOCAL - VME_A16_MSTR_BUS);            return (OK);	default:	    return (ERROR);	}    }/********************************************************************************* sysBusTas - test and set a specified location** This routine performs a test-and-set (TAS) instruction on the specified* address.  To prevent deadlocks, interrupts are disabled during the* test-and-set operation.  The following table defines the method used to* insure an atomic operation.** .CS*		Master		Slave_1		Slave_2** VME Chip	Don't Care	U1		U1*		----------	----		----* Method	VOWN		VOWN		VOWN** VME Chip	Don't Care	U1		U2*		----------	----		----* Method	VOWN		VOWN		RMW** VME Chip	U1 or		U2		U2*		U2+*		----------	----		----* Method	VOWN+++		RMW		RMW** VME Chip	U2++		U2		U2* PCI Bridge	or Hawk*		----------	----		----* Method	lwarx/stwcx	RMW		RMW

⌨️ 快捷键说明

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