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

📄 syslib_765.c

📁 sysLib.c - generic PPC system-dependent library 765BSP重要文件
💻 C
📖 第 1 页 / 共 5 页
字号:
    /* Upon completion, clear BFL (Board Fail) LED */    *(UINT8 *)BRD_MOD_FAIL_REG_ADRS &= ~BRD_MOD_FAIL_MASK;    }/********************************************************************************* sysDramSize - returns the real top of local DRAM.** RETURNS: The address of the top of DRAM.**/UINT32 sysDramSize (void)    {    UINT32        dramIndex;    int           i, j;    UINT32        localDram = 0;    static UINT32 dramSize[] =        {        0x00000000,			/*   0MB */        0x02000000,			/*  32MB (4Mx16) */        0x04000000,			/*  64MB (8Mx8) */        0x04000000,			/*  64MB (8Mx16) */        0x08000000,			/* 128MB (16Mx4) */        0x08000000,			/* 128MB (16Mx8) */        0x08000000,			/* 128MB (16Mx16) */        0x10000000,			/* 256MB (32Mx4) */        0x10000000,			/* 256MB (32Mx8) */        0x20000000,			/* 512MB (64Mx4 */        0x40000000,			/*   1GB (64Mx8) */        0x80000000,			/*   2GB (128x4) */        0x00000000,			/*   0MB reserved */        0x00000000,			/*   0MB reserved */        0x00000000,			/*   0MB reserved */        0x00000000,			/*   0MB reserved */        };    static UINT8 *dramAttr[] =        {        (UINT8 *) HAWK_SMC_SDRAM_ATTR_AD,        (UINT8 *) HAWK_SMC_SDRAM_ATTR_EH,        };    /*     * 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;                localDram += dramSize [dramIndex];                }            }        }    return (localDram);    }/********************************************************************************* 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 not 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)    {    UINT32 localDram = 0;    if (sysPhysMemSize == NULL)        {        localDram = sysDramSize();#ifdef LOCAL_MEM_AUTOSIZE        sysPhysMemSize = (char *)localDram;#else        sysPhysMemSize = (char *)(LOCAL_MEM_LOCAL_ADRS + LOCAL_MEM_SIZE);#endif        /* Adjust initial DRAM size to actual physical memory. */        sysPhysMemDesc[SYS_DECS_DRAM_INDEX].len =             (ULONG)sysPhysMemSize -             (ULONG)sysPhysMemDesc[SYS_DECS_DRAM_INDEX].physicalAddr;#ifdef EXTENDED_PCI        /*          * Adjust the start of PCI I/O and Memory addresses to the top of DRAM.          */        sysPhysMemDesc[SYS_DECS_PCI_IO_INDEX].physicalAddr =             (void *)(localDram);        sysPhysMemDesc[SYS_DECS_PCI_IO_INDEX].virtualAddr =             (void *)(localDram);        sysPhysMemDesc[SYS_DECS_PCI_MEM_INDEX].physicalAddr =             (void *)(localDram + PCI_MSTR_MEMIO_SIZE);        sysPhysMemDesc[SYS_DECS_PCI_MEM_INDEX].virtualAddr =             (void *)(localDram + PCI_MSTR_MEMIO_SIZE);#endif /* EXTENDED_PCI */        }    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)    {    return ((char *)(sysPhysMemTop () - USER_RESERVED_MEM));    }/******************************************************************************** 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 + 8); /* Warm reboot (for Max) */#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 */    sysSerialReset ();		/* reset serial devices */    sysHawkErrClr ();		/* 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)	{#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();	/* capture hawk window configuration */	sysHawkCapt ();#ifdef INCLUDE_DEC2155X	/* Initialize Dec2155x interrupts */	sysDec2155xInit2 ();#endif#ifdef INCLUDE_BPE        /* enable processor data and address bus parity checking */        sysConfigBpe ();#endif#ifdef INCLUDE_DPM        /* enable dynamic power management */        sysConfigDpm ();#endif#ifdef INCLUDE_CACHE_L2#ifdef INCLUDE_CACHE_SUPPORT#ifdef USER_L2_CACHE_ENABLE	/* initialize the L2 cache */	sysL2CacheInit();#else	sysL2CacheDisable();#endif  /* USER_L2_CACHE_ENABLE */#endif  /* INCLUDE_CACHE_SUPPORT */#endif  /* INCLUDE_CACHE_L2 */#ifdef INCLUDE_ALTIVEC        _func_altivecProbeRtn = sysAltivecProbe;#endif#ifdef INCLUDE_SM_COMMON	sysSmParamsCompute ();#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 Compact PCI Bus.** RETURNS: N/A** SEE ALSO: sysProcNumGet()**/void sysProcNumSet    (    int 	procNum			/* processor number */    )    {    /* Init global variable */    sysProcNum = procNum;    }/* miscellaneous support routines *//******************************************************************************** sysHawkCapt - capture Hawk window information** This routine captures the configuration of the Hawk PPC and PCI slave* registers. This information is used to perform address translations from* CPU to PCI addresses and vice versa.** RETURNS: N/A** SEE ALSO: sysBusToLocalAdrs(), sysLocalToBusAdrs()*/LOCAL void sysHawkCapt (void)    {    UINT32 index;		/* widow counter */    UINT8  attr;		/* window attribute */    UINT32 temp;		/* working variable */    UINT16 trans;		/* window translation value */    HAWK_OFFSETS *    pHawkOff;	/* pointer to hawk addresses and offsets */    HAWK_WIN_STRUCT * pHawkCpu; /* pointer to cpu windows */    HAWK_WIN_STRUCT * pHawkPci; /* poiner to pci windows */    /* initialize number of valid windows found */    sysValidHawkWindows = 0;    /* point to window save arrays */    pHawkCpu = &sysHawkCpuToPciWin[0];    pHawkPci = &sysHawkPciToCpuWin[0];    /* start with the cpu to pci windows (ppc slaves) */    pHawkOff = &sysHawkCpuWinOff[0];    /* loop through each window */    for (index = 0; index < HAWK_CPU_WIN_CNT; index++)	{	/* read the window attributes */	attr = sysInByte (pHawkOff->attr);	if (attr & HAWK_RDWR_ENA)	    {	    /* active window found, bump valid window counter */	    sysValidHawkWindows++;	    /* determine the window type (memory or i/o) */	    pHawkCpu->winType = (attr & CPU2PCI_ATTR_MEM) ? PCI_BAR_SPACE_MEM :				PCI_BAR_SPACE_IO;	    pHawkPci->winType = pHawkCpu->winType;	    /* read the window range */	    temp = sysIn32 ((UINT32 *)pHawkOff->range);	    trans = sysIn16 ((UINT16 *)pHawkOff->offset);	    pHawkCpu->winBase = temp & ~0xffff;	    pHawkCpu->winLimit = (temp << 16) | 0xffff;	    /* calculate translated values */	    pHawkPci->winBase = pHawkCpu->winBase + (trans << 16);	    pHawkPci->winLimit = pHawkCpu->winLimit + (trans << 16);	    /* advance in preparation for next valid window */	    pHawkCpu++;	    pHawkPci++;	    }	/* advance to next set of hawk offsets */	pHawkOff++;	}    /* switch to hawk pci to cpu windows (pci slaves) */    pHawkOff = &sysHawkPciWinOff[0];    /* loop through each window */    for (index = 0; index < HAWK_PCI_WIN_CNT; index++)	{	/* read the window attributes */	pciConfigInByte (sysHawkPciBusNo, sysHawkPciDevNo, sysHawkPciFuncNo,                         pHawkOff->attr, &attr);	if (attr & HAWK_RDWR_ENA)	    {	    /* active window found, bump valid window counter */	    sysValidHawkWindows++;	    /* set the window type to memory */	    pHawkCpu->winType = PCI_BAR_SPACE_MEM;	    pHawkPci->winType = PCI_BAR_SPACE_MEM;	    /* read the window range */	    pciConfigInLong (sysHawkPciBusNo, sysHawkPciDevNo, sysHawkPciFuncNo,			     pHawkOff->range, &temp);	    pciConfigInWord (sysHawkPciBusNo, sysHawkPciDevNo, sysHawkPciFuncNo,			     pHawkOff->offset, &trans);	    /* isolate the window base (start) and limit (end) */	    pHawkPci->winBase = temp & ~0xffff;	    pHawkPci->winLimit = (temp << 16) | 0xffff;	    /* calculate translated values */	    pHawkCpu->winBase = pHawkPci->winBase + (trans << 16);	    pHawkCpu->winLimit = pHawkPci->winLimit + (trans << 16);	    /* advance in preparation for next valid window */	    pHawkCpu++;	    pHawkPci++;	    }	/* advance to next set of hawk offsets */	pHawkOff++;	}    }/******************************************************************************** sysHawkTransAdrs - translate an address that passes through the hawk.** This routine converts an address from a cpu to pci address or vice versa. It* uses a pair of window arrays built during hardware init2 to guide the* translation. The adrs parameter is the address to convert.** RETURNS: OK, or ERROR if the address space is unknown or the mapping is not* possible.** SEE ALSO: sysHawkCapt()**/LOCAL STATUS sysHawkTransAdrs    (    UINT32            adrsSpace,    /* address space (memory or i/o ) */    UINT32            adrs,	    /* known address */    UINT32 *          pTransAdrs,   /* pointer to the translated address */    UINT32            winCnt,	    /* number of open windows */    HAWK_WIN_STRUCT * pSrc,	    /* pointer to the source windows */    HAWK_WIN_STRUCT * pDest	    /* pointer to the destination windows */    )    {    while (winCnt--)	{	/* check for a match on window type and in bounds */

⌨️ 快捷键说明

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