📄 syslib.c
字号:
/****************************************************************************** sysProcNumSet - set the processor number** Set the processor number for the CPU board. Processor numbers should be* unique on a single backplane.** NOTE* By convention, only processor 0 should dual-port its memory.** RETURNS: N/A** SEE ALSO: sysProcNumGet()*/void sysProcNumSet ( int procNum /* processor number */ ) { sysProcNum = procNum; }/********************************************************************************* sysModel - return the model name of the CPU board** This routine returns the model name of the CPU board.** RETURNS: A pointer to a string identifying the board and CPU.*/char *sysModel (void) {#if (_BYTE_ORDER == _BIG_ENDIAN) if(isNPUMaster()) return "Intel IXDP 2400 BE (Master/Egress)"; else return "Intel IXDP 2400 BE (Slave/Ingress)"; #else if(isNPUMaster()) return "Intel IXDP 2400 LE (Master/Egress)"; else return "Intel IXDP 2400 LE (Slave/Ingress)";#endif }/********************************************************************************* sysBspRev - return the bsp version with the revision eg 1.1/<x>** This function returns a pointer to a bsp version with the revision.* for eg. 1.1/<x>. BSP_REV is concatanated to BSP_VERSION to form the* BSP identification string.** RETURNS: A pointer to the BSP version/revision string.*/char * sysBspRev (void) { return (BSP_VERSION BSP_REV); }/* Wrappers *//********************************************************************************* ixpVersion - return the Intel IXP version** This function returns a pointer to a BSP version with the revision.* This is the Intel IXP version in the form "major.minor.build_num".** RETURNS: A pointer to the BSP version/revision string.*/char * ixpVersion (void) { return (IXP_VERSION); }/********************************************************************************* sysIntDisable - disable an interrupt level** This routine disables a specified interrupt level.** .nT** RETURNS: OK, or ERROR if <intLevel> is out of range.** SEE ALSO: sysIntEnable(),* .sA*/STATUS sysIntDisable ( int intLevel /* interrupt level to disable */ ) { return (ixp2400IntLvlDisable (intLevel)); }/********************************************************************************* sysIntEnable - enable an interrupt level** This routine enables a specified interrupt level.** .nT** RETURNS: OK, or ERROR if <intLevel> is out of range.** SEE ALSO: sysIntDisable(),* .sA*/STATUS sysIntEnable ( int intLevel /* interrupt level to enable */ ) { return (ixp2400IntLvlEnable (intLevel)); }#ifdef INCLUDE_HSI_PROBE/******************************************************************************** sysVirtToPhys - translate a virtual address to a physical address (ARM)** This function converts a virtual address (of part of a page table in* DRAM) to a physical address. This routine is used both by the BSP MMU* initialisation and by the vm(Base)Lib code later (via function* pointer). The mapping set up in the initial BSP MMU initialisation is* the same as that done later and that done previously by Angel.** RETURNS: the physical adddress*/void * sysVirtToPhys ( void * virtAddr /* virtual address in DRAM */ ) { return virtAddr; }/******************************************************************************** sysPhysToVirt - translate a physical address to a virtual address (ARM)** This function converts a physical address (of part of a page table in* DRAM) to a virtual address. This routine is used by the vm(Base)Lib* code later (via function pointer).** RETURNS: the virtual adddress*/void * sysPhysToVirt ( void * physAddr /* physical address in DRAM */ ) { return physAddr; }#else/******************************************************************************** sysVirtToPhys - translate a virtual address to a physical address (ARM)** This function converts a virtual address (of part of a page table in* DRAM) to a physical address. This routine is used both by the BSP MMU* initialisation and by the vm(Base)Lib code later (via function* pointer). The mapping set up in the initial BSP MMU initialisation is* the same as that done later and that done previously by Angel.** RETURNS: the physical adddress*/void * sysVirtToPhys ( void * virtAddr /* virtual address in DRAM */ ) { void * physAddr; if (((UINT32) virtAddr) >= SDRAM_END) return virtAddr; if (((UINT32) virtAddr) >= SDRAM_HIGH_VIRT) { physAddr = (void *) (((UINT32) virtAddr)- SDRAM_HIGH_VIRT); return (void *) (((UINT32) virtAddr)- SDRAM_HIGH_VIRT); } else { physAddr = (void *) (((UINT32) virtAddr) + SDRAM_HIGH_PHY); return (void *) (((UINT32) virtAddr) + SDRAM_HIGH_PHY); } return virtAddr; }/******************************************************************************** sysPhysToVirt - translate a physical address to a virtual address (ARM)** This function converts a physical address (of part of a page table in* DRAM) to a virtual address. This routine is used by the vm(Base)Lib* code later (via function pointer).** RETURNS: the virtual adddress*/void * sysPhysToVirt ( void * physAddr /* physical address in DRAM */ ) { void * virtAddr; if (((UINT32) physAddr) >= SDRAM_END) return physAddr; if (((UINT32) physAddr) < SDRAM_HIGH_PHY) { virtAddr = (void *) (((UINT32) physAddr) + SDRAM_HIGH_VIRT); return (void *) (((UINT32) physAddr) + SDRAM_HIGH_VIRT); } else { virtAddr = (void *) (((UINT32) physAddr) - SDRAM_HIGH_PHY); return (void *) (((UINT32) physAddr) - SDRAM_HIGH_PHY); } return physAddr; }#endif/****led****/void sysLEDDisplay(unsigned char c1,unsigned char c2,unsigned char c3,unsigned char c4){ FAST int locKey; locKey = intLock();#if (_BYTE_ORDER == _BIG_ENDIAN) if ((getProductID(MAJ_REV)>>4)==1) /* if B0 silicon, then set FIFO to interrup fater 32 bytes*/ { *((volatile char *)ALPHANUM_DIS_DATA) = c4; *((volatile char *)(ALPHANUM_DIS_DATA + 1)) = c3; *((volatile char *)(ALPHANUM_DIS_DATA + 2)) = c2; *((volatile char *)(ALPHANUM_DIS_DATA + 3)) = c1; } else { *((volatile char *)ALPHANUM_DIS_DATA) = c1; *((volatile char *)(ALPHANUM_DIS_DATA + 1)) = c2; *((volatile char *)(ALPHANUM_DIS_DATA + 2)) = c3; *((volatile char *)(ALPHANUM_DIS_DATA + 3)) = c4; }#else *((volatile char *)ALPHANUM_DIS_DATA) = c1; *((volatile char *)(ALPHANUM_DIS_DATA + 1)) = c2; *((volatile char *)(ALPHANUM_DIS_DATA + 2)) = c3; *((volatile char *)(ALPHANUM_DIS_DATA + 3)) = c4;#endif intUnlock(locKey);}/********************************************************************************* sysMemVirtSize - get sizes of virtual memory regions** This routine returns sizes of virtual memory regions.** SYS_ALL is the actual amount of memory from the SDRAM. * Some amount of the top end of this may be* reserved by users, so the amount actually available to VxWorks* is given by SYS. The size SDRAM which is available to the HW and * not used by VxWorks is given by SDRAM.** RETURNS: N/A*/void sysMemVirtSize ( unsigned int* sys, /* Size of memory mapped at zero for VxWorks */ unsigned int* sys_all, /* Total SDRAM size */ unsigned int* sdram, /* Size of memory mapped at C0000000 and usable by HW */ unsigned int* sram, /* Size of sram Total */ unsigned int* sram0, unsigned int* sram1, unsigned int* sram2, unsigned int* sram3, unsigned int* flash /* Size of Flash */ ){ /* Size of memory from SDRAM */ *sys_all = LOCAL_MEM_SIZE + SDRAM_HIGH_PHY; /* Size of memory mapped at zero and usable by VxWorks */ *sys = LOCAL_MEM_SIZE - USER_RESERVED_MEM; /* Size of memory mapped at 20000000 and usable by HW */ *sdram = SDRAM_HIGH_PHY; /* Size of sram */ *sram = sramSize; *sram0 = sramChanSize[0]; *sram1 = sramChanSize[1]; *sram2 = 0x0; *sram3 = 0x0; /* Size of Flash */ *flash = ROM_SIZE;}/********************************************************************************* cacheDmaXMalloc - allocate a cache-safe buffer when X-bit set** cacheDmaMalloc returns the newly allocated buffer with attributes XCB = 000* This type of memory region can cause problem on IXP2400,* so we need to provide a platform specific work around. which returns buffer* with XCB = 101** This routine attempts to return a pointer to a section of memory* that will not experience cache coherency problems. This routine* is only called when MMU support is available for cache control.** RETURNS: A pointer to a cache-safe buffer, or NULL.** Note: malloc is used by default when called early on during initialization,* (cacheDmaMalloc works the same way)** NOMANUAL*/void * cacheDmaXMalloc ( size_t bytes /* size of cache-safe buffer */ ) { void * pBuf; int pageSize; /* * This seems dangerous, as the buffer could be allocated and then the * cache could be switched on later. However, it is what the other * architectures do. */ if (!(mmuCrGet() & MMUCR_I_ENABLE)) { /* If cache is off, just allocate buffer */ return malloc (bytes); } if ((pageSize = VM_PAGE_SIZE_GET ()) == ERROR) pageSize = VM_PAGE_SIZE; /* make sure bytes is a multiple of pageSize */ bytes = ROUND_UP (bytes, pageSize);#if (!ARM_HAS_MPU) if ((_func_valloc == NULL) || ((pBuf = (void *)(* _func_valloc) (bytes)) == NULL)) return malloc (bytes);#else /* (!ARM_HAS_MPU) */ /* * On MPUs, regions must be aligned with their size, which must be * a power of two and at least 4k in size. * * Round up to a power of two in size. */ bytes = ROUND_UP (bytes, (1 << (ffsMsb(bytes) - 1))); if ((_func_memalign == NULL) || ((pBuf = (void *)(* _func_memalign) (bytes, bytes)) == NULL)) return malloc (bytes);#endif /* !ARM_HAS_MPU) */ /* * Note that on MPUs we need to specify VM_STATE_VALID here, in * order that a new region will be created, if necessary, and that * that region will be marked as active, with appropriate access * rights. We should also free the allocate buffer and return NULL * if the VM_STATE_SET call fails. Here we set the cacheable & bufferable * bits under X-bit support. */ if (VM_STATE_SET (NULL, pBuf, bytes, VM_STATE_MASK_EX_CACHEABLE | VM_STATE_MASK_EX_BUFFERABLE | VM_STATE_MASK_VALID, VM_STATE_EX_CACHEABLE_NOT | VM_STATE_EX_BUFFERABLE | VM_STATE_VALID) != OK) { free (pBuf); return NULL; } return pBuf; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -