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

📄 syslib.c

📁 一个基于三星ARM7系列的S3C44B0 的vxWorks的BSP源文件包。
💻 C
📖 第 1 页 / 共 2 页
字号:
/************************************************ * modify 	: hugang hgxxx@51eda.com			* * data		: 2004-05-05						* ************************************************//* sysLib.c - Samsung SBC ARM7 system-dependent routines *//* Copyright 1984-2002 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------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;unsigned char ne2000EnetAddr[] = ETHERNET_MAC_ADRS;/* locals */#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 *//******************************************************************************** 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 == _LITTLE_ENDIAN)#if   (CPU == ARMARCH4)    return    "wrSbcArm7 - ARM7TDMI (ARM)";#elif (CPU == ARMARCH4_T)    return    "wrSbcArm7 - ARM7TDMI (Thumb)";#else#error CPU not supported#endif /* (CPU == ARMARCH4) */#else /*(_BYTE_ORDER == _LITTLE_ENDIAN)*/#if   (CPU == ARMARCH4)    return    "wrSbcArm7 - ARM7TDMI (ARM) Big Endian";#elif (CPU == ARMARCH4_T)    return    "wrSbcArm7 - ARM7TDMI (Thumb) Big Endian";#else#error CPU not supported#endif /* (CPU == ARMARCH4) */#endif /*(_BYTE_ORDER == _LITTLE_ENDIAN)*/    }/******************************************************************************** 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 concatenated 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);    }/*port_init*/#define HAL_WRITE_UINT32( _register_, _value_ ) \        (*((volatile unsigned int *)(_register_)) = (_value_))void sysPortInit(void){	/* PORT A GROUP */	/*  BIT 9	8	7	6	5	4	3	2	1	0	*/	/*  A24	  A23	A22	A21	A20	A19	A18	A17	A16	A0		*/	      	/*  1		1	1	1	1	1	1	1	1	1	*/	HAL_WRITE_UINT32(S3C44B0X_PCONA, 0x3ff);		/* PORT B GROUP */	/* BIT 10   9    8       7      6        5     4     3     2     1     0    			*/	/*     /CS5 /CS4 /CS3    /CS2   /CS1     nWBE3 nWBE2 /SRAS /SCAS SCLS  SCKE 			*/	/*     NC   NC   RTL8019 USBD12 NV_Flash NC    NC    Sdram Sdram Sdram Sdram			*/	/*     0,   0,   1,      1,     1,       0,    0,    1,    1,    1,    1    			*/	HAL_WRITE_UINT32(S3C44B0X_PDATB, 0x1cf);	HAL_WRITE_UINT32(S3C44B0X_PCONB, 0x1cf);    	/* PORT C GROUP */	/* BUSWIDTH=16 													*/	/*  PC15		14		13		12		11		10		9		8	*/	/*	o		o		RXD1	TXD1	o		o		o		o	*/	/*	NC		NC		Uart1	Uart1	NC		NC		NC		NC	*/	/*   01		01		11		11		01		01		01		01	*/	/*  PC7		6		5		4		3		2		1		0	*/	/*   o		o		o		o		o		o		o		o	*/	/*   NC		NC		NC		NC		NFALE 	NFCLE 	NFCE 	NFRB*/	/*   01		01		01		01		01		01		01		00	*/	HAL_WRITE_UINT32(S3C44B0X_PDATC, 0x0001);	/* All IO is low */	HAL_WRITE_UINT32(S3C44B0X_PCONC, 0x5f555554);		HAL_WRITE_UINT32(S3C44B0X_PUPC, 0x3000);	/* PULL UP RESISTOR should be enabled to I/O */	/* PORT D GROUP */	/*  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	*/	HAL_WRITE_UINT32(S3C44B0X_PDATD, 0x55);	HAL_WRITE_UINT32(S3C44B0X_PCOND, 0xaaaa);		HAL_WRITE_UINT32(S3C44B0X_PUPD, 0x00);	/*These pins must be set only after CPU's internal LCD controller is enable */		/*PORT E GROUP */ 	/*  Bit 8		7	6	5	4	3	2	1	0			2		1		0		*/	/*	ENDLAN		LED3	LED2	LED1	LED0	BEEP	RXD0	TXD0	CLKOUT	*/ 	/*      00		01		01		01		01		01		10		10		01		*/	HAL_WRITE_UINT32(S3C44B0X_PDATE, 0x357);	HAL_WRITE_UINT32(S3C44B0X_PCONE, 0x556b);	HAL_WRITE_UINT32(S3C44B0X_PUPE,	0x6);		/* PORT F GROUP */	/*  Bit8		7		6		5		 4		3		2		1		0		*/   	/*  IISCLK	IISDI	IISDO	IISLRCK	Input	Input	Input	IICSDA	IICSCL	*/	/*	100		100		100		100		00		00		00		10		10		*/	HAL_WRITE_UINT32(S3C44B0X_PDATF, 0x0);	HAL_WRITE_UINT32(S3C44B0X_PCONF, 0x24900a);	HAL_WRITE_UINT32(S3C44B0X_PUPF, 0x1d3);	/*PORT G GROUP */	/*  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       */	HAL_WRITE_UINT32(S3C44B0X_PDATG, 0xff);	HAL_WRITE_UINT32(S3C44B0X_PCONG, 0x00c0);	HAL_WRITE_UINT32(S3C44B0X_PUPG, 0x00);	/* should be enabled  */	HAL_WRITE_UINT32(S3C44B0X_SPUCR, 0x7);  /* D15-D0 pull-up disable */	/*所有的外部硬件中断为低电平触发*/	HAL_WRITE_UINT32(S3C44B0X_EXTINT, 0x4000);}void sysHwdInit(void){	HAL_WRITE_UINT32(S3C44B0X_SYSCFG, S3C44B0X_SYSCFG_CM_0R_8C | S3C44B0X_SYSCFG_WE);	HAL_WRITE_UINT32(S3C44B0X_NCACHBE0, (unsigned int)(Non_Cache_End>>12)<<16)|(Non_Cache_Start>>12);}extern void excEnterUndef(void);extern void excEnterSwi(void);extern void excEnterPrefetchAbort(void);extern void excEnterDataAbort(void);extern void intEnt(void);typedef struct {     UINT32  vector;     VOIDFUNCPTR  func;} exc_tbl_t;#define SYS_EXC_NUM     5LOCAL exc_tbl_t sysExcTbl[SYS_EXC_NUM] = {    {VEC_BASE_ADRS+0x04,    excEnterUndef},    {VEC_BASE_ADRS+0x08,    excEnterSwi},    {VEC_BASE_ADRS+0x0c,    excEnterPrefetchAbort},    {VEC_BASE_ADRS+0x10,    excEnterDataAbort},    {VEC_BASE_ADRS+0x18,    intEnt}};void sysExcTblSet(void){    int i;        for (i = 0; i < SYS_EXC_NUM; ++i) {       *(UINT32 *)(sysExcTbl[i].vector) = (UINT32)0xe59ff0f4;                                                       /* ldr pc, pc + 0xfc */       *(UINT32 *)(sysExcTbl[i].vector + 0xfc) = (UINT32)(sysExcTbl[i].func);    }}/******************************************************************************** sysHwInit - initialize the CPU board hardware** This routine initializes various features of the hardware.* Normally, it is called from usrInit() in usrConfig.c.** NOTE: This routine should not be called directly by the user.** RETURNS: N/A*/void sysHwInit (void)    {    /* install the IRQ/SVC interrupt stack splitting routine */    _func_armIntStackSplit = sysIntStackSplit;#ifdef INCLUDE_LCD    sysLcdInit(); /* initialize the LCD panel */    sysLcdWriteString("   WindRiver    ", 1, 1);    #if (_BYTE_ORDER == _LITTLE_ENDIAN)#if   (CPU == ARMARCH4)    sysLcdWriteString("   SBC ARM7     ", 2, 1);#else  /* ARMARCH4 */    sysLcdWriteString("   SBC ARM7 (t) ", 2, 1);#endif  /* ARMARCH4 */#else /* (_BYTE_ORDER == _LITTLE_ENDIAN) */#if   (CPU == ARMARCH4)    sysLcdWriteString("  SBC ARM7 (BE) ", 2, 1);#else  /* ARMARCH4 */    sysLcdWriteString("  SBC ARM7 (tBE)", 2, 1);#endif  /* ARMARCH4 */#endif /* (_BYTE_ORDER == _LITTLE_ENDIAN) */#endif /*INCLUDE_LCD*/	sysExcTblSet(); 	sysPortInit();	sysHwdInit();#ifdef INCLUDE_LED    sysLedInit(); /* initialize the LED */#endif    /* Set the MAC address based on DIP setting     * The least significant byte of the address is changed to     * the value of the user DIP switch setting. SW4-D0 is the     * least significant bit of this byte.  We invert the bits     * so Open=0.     *//*    sysSngks32cMacAddr[5] = ~READ_USERDIP();*/#ifdef  FORCE_DEFAULT_BOOT_LINE    strncpy(sysBootLine,DEFAULT_BOOT_LINE,strlen(DEFAULT_BOOT_LINE)+1);#elif defined INCLUDE_VWARE_LAUNCH    sysVwareBuildBootLine((char*)&ne2000EnetAddr);#endif /* FORCE_DEFAULT_BOOT_LINE */    sysSerialHwInit ();      /* initialize serial data structure */    }/******************************************************************************** sysHwInit2 - additional system configuration and initialization** This routine connects system interrupts and does any additional* configuration necessary.** RETURNS: N/A** NOMANUAL** Note: this is called from sysClkConnect() in the timer driver.*/void sysHwInit2 (void)    {    /* initialize the interrupt library and interrupt driver */    intLibInit (S3C44B0X_INTNUMLEVELS, S3C44B0X_INTNUMLEVELS, INT_MODE);    sngks32cIntDevInit();    /* connect sys clock interrupt and auxiliary clock interrupt */    (void)intConnect (INUM_TO_IVEC (INT_VEC_TIMER5), sysClkInt, 0);    (void)intConnect (INUM_TO_IVEC (INT_VEC_TIMER4), sysAuxClkInt, 0);    /* connect serial interrupt */    sysSerialHwInit2();    }/******************************************************************************** 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 * physTop = NULL;    if (physTop == NULL)        {#ifdef LOCAL_MEM_AUTOSIZE        /* If auto-sizing is possible, this would be the spot.  */#    error   "Dynamic memory sizing not supported"#else        /* Don't do autosizing, if size is given */        physTop = (char *)(LOCAL_MEM_LOCAL_ADRS + LOCAL_MEM_SIZE);#endif /* LOCAL_MEM_AUTOSIZE */        }    return physTop;    }/******************************************************************************** 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.  It is usually called* only by reboot() -- which services ^X -- and bus errors at interrupt* level.  However, in some circumstances, the user may wish to introduce a* new <startType> to enable special boot ROM facilities.** RETURNS: Does not return.*/STATUS sysToMonitor    (    int startType    /* passed to ROM to tell it how to boot */    )    {    FUNCPTR     pRom;    UINT32 *    p = (UINT32 *)ROM_TEXT_ADRS;#ifdef INCLUDE_SNG44BSP_END    END_OBJ *   pEnd;#endif

⌨️ 快捷键说明

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