📄 syslib.c
字号:
/* sysLib.c - Samsung SBC ARM7 system-dependent routines *//* Copyright 2004-2005 Amine@263.net *//* Copyright 1984-2002 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01o,29jul04,a_m BSP定制 for 思创S3C44B0X黄金开发板01k,26mar02,m_h rename glbEnetAddr to sysSngks32cMacAddr01j,17jan02,m_h fix cache issues and diab build warnings01i,27sep01,m_h base MAC address on user DIP setting, Big Endian Support01h,23jul01,m_h builds in UNIX01g,17jul01,g_h add visionWARE 2.00 support01f,11jul01,g_h disable cache in sysToMonitor()01e,10jul01,g_h add INCLUDE_LCD & INCLUDE_LED & INCLUDE_NETWORK macros01d,09jul01,g_h add #include "sbcCksum.c" instead of the makefile01c,26apr01,m_h convert tabs to spaces for readability01b,25apr01,m_h add comments to cache functions01a,12apr01,m_h created from snds100 template.*//*DESCRIPTIONThis library provides board-specific routines for the WindRiver SBC ARM7Ver 1.0 Development Board BSP for the Samsung KS32C chip.It #includes the following chip drivers: nullVme.c - dummy VMEbus routines sngks32cTimer.c - SNGKS32CARM7 timer driver sngks32cIntrCtl.c - SNGKS32CARM7 interrupt controller driver nullNvRam.c - dummy NVRAM routinesIt #includes the following BSP files: sysSerial.c - serial device initialization routines sysEnd.c - END network driver support routines.INCLUDE FILES: sysLib.h string.h intLib.h taskLib.h vxLib.h muxLib.hSEE ALSO:<Configuration><ARM Architecture Reference Manual>,<Samsung KS32C50100 Microcontroller User's Manual>,<Samsung KS32C5000(A)/50100 Microcontroller Application Notes>*//* includes */#include "vxWorks.h"#include "config.h"#include "sysLib.h"#include "string.h"#include "intLib.h"#include "taskLib.h"#include "vxLib.h"#include "muxLib.h"#include "cacheLib.h"#include "memLib.h"#include "wrSbcArm7.h"/* imports */IMPORT char end; /* end of system, created by ld */IMPORT VOIDFUNCPTR _func_armIntStackSplit; /* ptr to fn to split stack *//* globals */int sysBus = BUS; /* system bus type (VME_BUS, etc) */int sysCpu = CPU; /* system cpu type */char * sysBootLine = BOOT_LINE_ADRS; /* address of boot line */char * sysExcMsg = EXC_MSG_ADRS; /* catastrophic message area */int sysProcNum; /* processor number of this cpu */int sysFlags; /* boot flags */char sysBootHost [BOOT_FIELD_LEN]; /* name of host from which we booted */char sysBootFile [BOOT_FIELD_LEN]; /* name of file from which we booted */CACHE_FUNCS sngks32cCacheFuncs;/* Amine: sysSngks32cMacAddr->ne2000EnetAddr */unsigned char ne2000EnetAddr[] = ETHERNET_MAC_ADRS;/* locals *//* Amine: 21->26 */#if S3C44B0X_INTNUMLEVELS != 26# error sbcIntLvlMask is wrong size for number of levels#endif/* defines */ /* externals */IMPORT void sngks32cIntDevInit (void);IMPORT void sysIntStackSplit (char *, long);/*local defines*/#ifndef SBCARM7_CTRL_REG_READ# define SBCARM7_CTRL_REG_READ(x,result) \ ((result) = *(volatile UINT32 *)(x))#endif /*SBCARM7_READ*/#ifndef SBCARM7_CTRL_REG_WRITE# define SBCARM7_CTRL_REG_WRITE(x,data) \ (*((volatile UINT32 *)(x)) = (data))#endif /*SBCARM7_WRITE*//* globals *//* forward LOCAL functions declarations *//* forward declarations */char * sysPhysMemTop (void);#ifdef INCLUDE_CACHE_SUPPORTSTATUS sngks32cCacheLibInit(CACHE_MODE instMode, CACHE_MODE dataMode);FUNCPTR sysCacheLibInit = sngks32cCacheLibInit;void sysDebug (char *str);void sngks32cCacheFlush (void); void * sngks32cCacheDmaMalloc(size_t bytes);STATUS sngks32cCacheDmaFree (void *pBuf);void sngks32cCacheEnable (void);void sngks32cCacheDisable (void);void * sngks32cPhysToVirtRtn (void *adrs);void * sngks32cVirtToPhysRtn (void *adrs);#endif /*INCLUDE_CACHE_SUPPORT*//* included source files */#ifdef INCLUDE_FLASH#include "flashMem.c"#else /* INCLUDE_FLASH */#include "mem/nullNvRam.c"#endif /* INCLUDE_FLASH */#include "vme/nullVme.c"#include "sysSerial.c"#include "sngks32cTimer.c"#include "sngks32cIntrCtl.c"#ifdef INCLUDE_NETWORK#ifdef INCLUDE_END#include "sbcCksum.c"#include "sysEnd.c"#endif /* INCLUDE_END */#endif /* INCLUDE_NETWORK */#ifdef INCLUDE_LCD#include "sysLcd.c"#endif /* INCLUDE_LCD */#ifdef INCLUDE_LED#include "sysLed.c"#endif /* INCLUDE_LCD */#ifdef INCLUDE_VWARE_LAUNCH#include "sysVware.c"#endif /* INCLUDE_VWARE_LAUNCH *//* Amine: added */extern void excEnterUndef(void);extern void excEnterSwi(void);extern void excEnterPrefetchAbort(void);extern void excEnterDataAbort(void);extern void intEnt(void);/******************************************************************************** portInit - 针对硬板,初始化CPU各端口* */static void portInit(void){ /* BIT 9 8 7 6 5 4 3 2 1 0 */ /* A24 A23 A22 A21 A20 A19 A18 A17 A16 A0 */ /* 0 1 1 1 1 1 1 1 1 1 */ rPCONA = 0x0ff; rPDATA = 0x0ff; /* BIT 10 9 8 7 6 5 4 3 2 1 0 */ /* /CS5 /CS4 /CS3 /CS2 /CS1 nWBE3 nWBE2 /SRAS /SCAS SCLK SCKE */ /* EXT NIC USB IDE SMC NC NC Sdram Sdram Sdram Sdram */ /* 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1 */ rPDATB = 0x7ff; #if(BOARD_TYPE == BOARD_ARMEPS) /*ARMCORE V1.0*/ rPCONB = 0x7df; /* GPB5->网络芯片复位 */ #else rPCONB = 0x7ff; #endif /* PC15 14 13 12 11 10 9 8 */ /* o o RXD1 TXD1 o o o o */ /* NC NC Uart1 Uart1 NC NC NC NC */ /* 11 11 11 11 11 11 01 00 */ /* PC7 6 5 4 3 2 1 0 */ /* o o o o o o o o */ /* NC NC NC NC SMCALE SMCCLE SMCCE SMCRB*/ /* 01 01 01 01 01 01 01 01 */ rPDATC = 0x0000; rPCONC = 0xfff45555; rPUPC = 0xFC00; /* PORT D GROUP(I/O OR LCD) */ /* BIT7 6 5 4 3 2 1 0 */ /* VF VM VLINE VCLK VD3 VD2 VD1 VD0 */ /* 01 01 01 01 01 01 01 01 */ rPDATD= 0x55; rPCOND= 0xaaaa; rPUPD = 0x00; /* Bit 8 7 6 5 4 3 2 1 0 */ /* ENDLAN LED3 LED2 LED1 LED0 BEEP RXD0 TXD0 CLKOUT */ /* 00 01 01 01 01 01 10 10 00 */ #if(BOARD_TYPE == BOARD_ARMEPS) /*ARMCORE V1.0*/ rPDATE = 0x1FF; /*060828*/ rPCONE = 0x029; /*0x5569*/ /* ARMCORE V1.0 GPE0->运行灯 */ rPUPE = 0x0; #else rPDATE = 0x157; /*060828*/ rPCONE = 0x5568; rPUPE = 0xff; #endif /* Bit8 7 6 5 4 3 2 1 0 */ /* IISCLK IISDI IISDO IISLRCK Input Input Input IICSDA IICSCL */ /* 100 100 100 100 00 01 01 10 10 */ #if(BOARD_TYPE == BOARD_ARMEPS) /*ARMCORE V1.0*/ rPDATF = 0x1FF; rPCONF = 0x92555; rPUPF = 0x1FE; #else rPDATF = 0x0; rPCONF = 0x24915a; rPUPF = 0x1E3; #endif /* BIT7 6 5 4 3 2 1 0 */ /* INT7 INT6 INT5 INT4 INT3 INT2 INT1 INT0 */ /* S3 S4 S5 S6 NIC EXT IDE USB */ /* 11 11 11 11 11 11 11 11 */ rPDATG = 0xFF; rPCONG = 0xFFFF; rPUPG = 0x00; rSPUCR=0x7; /*定义非Cache区*/ /*rNCACHBE0 = 0xc0002000; */ rEXTINT=0x0044; /*网卡使用EXTINT1,上升沿触发*/}/******************************************************************************** rtl8019Init - RTL8019网络芯片初始化(与NE2000不兼容)* loopDelay - 循环延时函数,每个时间单位为100us*/static int delayLoopCount = 400;static void loopDelay(int time){ int i; for(;time>0;time--) for(i=0;i<delayLoopCount;i++);}static void rtl8019Init(void){ /*Reset MAC*/ #if(BOARD_TYPE == BOARD_STRONG) *CPLDREG1 |= 0x20; loopDelay(500); *CPLDREG1 &= 0xDF; #endif #if(BOARD_TYPE == BOARD_ARMEPS) /*ARMCORE V1.0*/ rPDATB |= (0x20); /*网络芯片复位*/ loopDelay(500); rPDATB &= ~(0x20); /*网络芯片复位*/ #endif loopDelay(100); #if(BOARD_TYPE == BOARD_ARM3000) *(NETBASE+0x3c) = *(NETBASE+0x3e); loopDelay(100); /* Page 3 Set power status & msic*/ *(NETBASE+0x00) = 0xc1; *(NETBASE+0x02) = 0xcf; /**(NETBASE+0x20) = 0xc0;*/ *(NETBASE+0x08) = 0x80; *(NETBASE+0x0a) = 0x00; *(NETBASE+0x0c) = 0x70; /**(NETBASE+0x26) = 0xFF;*//*07H TEST R/W Reserved, Do not write*/ *(NETBASE+0x02) = 0x0f; /*关闭写允许*/ #else *(NETBASE+0x1e) = *(NETBASE+0x1e + 0x20); loopDelay(100); /* Page 3 Set power status & msic*/ *(NETBASE+0x00) = 0xc1; *(NETBASE+0x20) = 0xcf; /**(NETBASE+0x20) = 0xc0;*/ *(NETBASE+0x04) = 0x80; *(NETBASE+0x24) = 0x00; *(NETBASE+0x06) = 0x70; /**(NETBASE+0x26) = 0xFF;*//*07H TEST R/W Reserved, Do not write*/ *(NETBASE+0x20) = 0x0f; /*关闭写允许*/ #endif}/******************************************************************************** s3cExcVecSet - 构成RAM中向量表**/void s3cExcVecSet(void){ int i; i = (int)&excEnterUndef; *((volatile int*)(S3C_EXC_BASE + 0x0)) = i; i = (int)&excEnterSwi; *((volatile int*)(S3C_EXC_BASE + 0x4)) = i; i = (int)&excEnterPrefetchAbort; *((volatile int*)(S3C_EXC_BASE + 0x8)) = i; i = (int)&excEnterDataAbort; *((volatile int*)(S3C_EXC_BASE + 0xc)) = i; i = (int)&intEnt; *((volatile int*)(S3C_EXC_BASE + 0x14)) = i; return;}/******************************************************************************** sysInByte,sysOutByte,sysInWordString,sysOutWordString** NE2000驱动需要的输入输出函数.* * 注意:sysInWordString和sysOutWordString的端口地址不累加,使用8位操作.*/unsigned char sysInByte (unsigned long port){ return (REG8(port));}void sysOutByte (unsigned long port, unsigned char data){ REG8(port) = data;}void sysInWordString (unsigned long port, unsigned short *pData, int count){ int i, byte_count; char *pbyte; pbyte = (char *)pData; byte_count = count*2; for(i=0; i<byte_count; i++){ *(pbyte) = REG8(port); pbyte++; }}void sysOutWordString(unsigned long port, unsigned short *pData, int count){ int i, byte_count; char *pbyte; pbyte = (char *)pData; byte_count = count*2; for(i=0; i<byte_count; i++){ REG8(port) = *(pbyte); pbyte++; }}/******************************************************************************** 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.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -