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

📄 syslib.c

📁 VxWorkS下 MV2604的BSP源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
/********************************************************************************* sysPhysMemTop - get the address of the top of physical memory** This routine returns the address of the first missing byte of memory,* which indicates the top of memory.** Normally, the user specifies the amount of physical memory with the* macro LOCAL_MEM_SIZE in config.h.  BSPs that support run-time* memory sizing do so only if the macro LOCAL_MEM_AUTOSIZE is defined.* If not defined, then LOCAL_MEM_SIZE is assumed to be, and must be, the* true size of physical memory.** NOTE: Do no adjust LOCAL_MEM_SIZE to reserve memory for application* use.  See sysMemTop() for more information on reserving memory.** RETURNS: The address of the top of physical memory.** SEE ALSO: sysMemTop()*/char * sysPhysMemTop (void)    {    static char * sysPhysMemSize = NULL;	/* ptr to top of mem + 1 */#ifdef LOCAL_MEM_AUTOSIZE    UINT32        dramAttr;    UINT32        dramIndex;    int           i;    static UINT32 dramSize[8] =    /*   0,         16MB,       32MB,       64MB,       128MB,      256MB,        1GB,         0   */    {0x00000000, 0x01000000, 0x02000000, 0x04000000,     0x08000000, 0x10000000, 0x40000000, 0x00000000};#endif /* LOCAL_MEM_AUTOSIZE */    if (sysPhysMemSize == NULL)	{#ifdef LOCAL_MEM_AUTOSIZE	/*	 * Do dynamic memory sizing.	 *	 * Since Falcon memory controller chip has already been set to	 * control all memory, just read and interpret its DRAM Attributes	 * Register.	 */	dramAttr = sysIn32 ((UINT32 *)FALCON_DRAM_ATTR);	for (i = 0; i < 4; ++i)	    {	    if ((dramAttr & 0x80) != 0)	        {		dramIndex = dramAttr & 0x07;		sysPhysMemSize = (char *)((UINT32)sysPhysMemSize + dramSize [dramIndex]);		}	    dramAttr >>= 8;	    }        /* 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);            /*              * 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 */#if     (CPU == PPC604)    vxHid0Set (vxHid0Get () & ~_PPC_HID0_SIED);	/* Enable Serial Instr Exec */#endif  /* (CPU == PPC604) */    sysUniverseReset ();	/* reset Universe chip */    sysSerialReset ();		/* reset serial devices */    sysRavenErrClr ();		/* clear Raven error conditions */    /* Clear the MSR */    vxMsrSet (0);    (*pRom) (startType);    return (OK);	/* in case we ever continue from ROM monitor */    }/******************************************************************************** sysDebugMsg - print a debug string to the console in polled mode.** This routine prints a message to the system console in polled mode.** RETURNS: N/A**/void sysDebugMsg    (    char * str    )    {    int msgSize;    int msgIx;    SIO_CHAN * pSioChan;        /* serial I/O channel */    msgSize = strlen (str);    pSioChan = sysSerialChanGet (0);    sioIoctl (pSioChan, SIO_MODE_SET, (void *) SIO_MODE_POLL);    for (msgIx = 0; msgIx < msgSize; msgIx++)        {        while (sioPollOutput (pSioChan, str[msgIx]) == EAGAIN);        }    }/******************************************************************************** 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);#ifndef MV2300	sysZ8536Init();	intConnect (INUM_TO_IVEC(Z8536_INT_VEC), sysClkIntCIO, 0);	intEnable (Z8536_INT_LVL);#else  /* MV2300 */#   ifdef INCLUDE_RAVEN_AUXCLK	sysAuxClkInit();	intConnect (INUM_TO_IVEC(TIMER0_INT_VEC), sysAuxClkInt, 0);	intEnable(TIMER0_INT_LVL);#   endif /* INCLUDE_RAVEN_AUXCLK */#endif /* MV2300 */	/* initialize serial interrupts */	sysSerialHwInit2();        /* connect a dummy routine for the spurious interrupt (0x07) */        intConnect (INUM_TO_IVEC(PP_INT_LVL), sysSpuriousIntHandler, 0);#ifdef INCLUDE_CACHE_L2#ifdef INCLUDE_CACHE_SUPPORT#ifdef USER_L2_CACHE_ENABLE	/* initialize the L2 cache */	sysL2CacheInit();#else	sysL2CacheDisable();#endif#endif#endif	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) 	            if(((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);		      }#	        endif                return (ERROR);        case VME_AM_SUP_SHORT_IO:        case VME_AM_USR_SHORT_IO:#	    if (VME_A16_SLV_SIZE != 0) 		if(((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);		  }#	    endif            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);

⌨️ 快捷键说明

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