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

📄 bspcfg.c

📁 这是ARM在Vxworks的驱动源代码
💻 C
字号:
/***********************************************************************/
/*                                                                     */
/*   MODULE:  bsps/ylwknife/bspcfg.c                                   */
/*   DATE:    98/10/22                                                 */
/*   PURPOSE: BSP code which is compiled when executable image is      */
/*            built                                                    */
/*                                                                     */
/***********************************************************************/
#include "vxworks.h"
#include "time.h"
#include "common/ds1338rtc.h"
#include "config.h"
void vectorSetup(void)
{
#if 0
unsigned long ProcType; 
unsigned long msrORval;

ProcType = BspCpuType() & 0xFF;

/*---------------------------------------------------------------------*/
/* User may want to catch up the Machine check exceptions and MMU      */
/* error exception by using bspSetjmp/bspLongjmp. To make it possible, */
/* we don't directly jump to the pROBE+ exception handler. We will call*/
/* SysAccessExcept. In this routine, we will check if bspLongjmp is to */
/* be called or not. If not, the code will try to call the secondary   */
/* handler. The secondary handler is set by SysSetVectorExt(). If no   */
/* secondary handler exists, it will call crash routine specfied by    */
/* bspSetCrashHndl(). The secondary handler normally is a pROBE+       */
/* exception handler. At this time, pROBE+ is  not configured yet,     */
/* so we don't set the secondary handlers here.                        */
/*---------------------------------------------------------------------*/
#ifdef SelfProcessException
    SysSetVector(V_MACH_CK,  SysCallExcpCHndl, VT_REG, MSR_ME | MSR_FP, 0);
    SysSetVector(V_DA,       SysCallExcpCHndl, VT_REG, 0, 0);
    SysSetVector(V_IA,       SysCallExcpCHndl, VT_REG, 0, 0);

    SysSetVector(V_ALIGN,   SysCallExcpCHndl, VT_REG, 0, 0);
    SysSetVector(V_PROGRAM, SysCallExcpCHndl, VT_REG, 0, 0);
    SysSetVector(V_FLOAT,   SysCallExcpCHndl, VT_REG, 0, 0);

    SysSetVector(V_SEI821, SysCallExcpCHndl, VT_REG, 0, 0);
    SysSetVector(V_ITLB821_ERR, SysCallExcpCHndl, VT_REG, 0, 0);
    SysSetVector(V_DTLB821_ERR, SysCallExcpCHndl, VT_REG, 0, 0);
    SysSetVector(V_ITLB821_MISS, SysCallExcpCHndl, VT_REG, 0, 0);
    SysSetVector(V_DTLB821_MISS, SysCallExcpCHndl, VT_REG, 0, 0);
#endif
bspSetSysCrashHndl(pssCrashHndl);
#ifdef SelfProcessException
	bspSetSysExcpCHndl( doexcpthandle); 
#endif

msrORval = 0;
#if (BSP_FPU == YES)
msrORval = MSR_FP | MSR_FE0 | MSR_FE1;
#endif
 
SysSetVector(V_INTRPT,  GenIsr, VT_STACK, msrORval, 0);
SysSetVector(V_DCRMNTR, GenIsr, VT_STACK, msrORval, 0);
#endif
}

/***********************************************************************/
/* pssCrashHndl: print location of exception on system crash           */
/*                                                                     */
/*      INPUTS: progCount = IP value                                   */
/*              vector = exception vector                              */
/*                                                                     */
/*     RETURNS: none                                                   */
/*     OUTPUTS: none                                                   */
/*     NOTE(S):                                                        */
/*                                                                     */
/***********************************************************************/
void pssCrashHndl(ULONG progCount, ULONG vector)
{
   Print("Exception %x at IP %x\n", vector, progCount);
}


/***********************************************************************/
/* BspSetup: Setup BSP configuration                                   */
/*                                                                     */
/*      INPUTS: FreeMemPtr pointer to free memory area that can be     */
/*                used to allocate memory for the BSP.                 */
/*              NodeCfg pointer to the systems node configuration      */
/*                that can be used to see what and how components      */
/*                are configured into the system.                      */
/*                This will not be used.                               */
/*                                                                     */
/*     RETURNS: An updated pointer to free memory                      */
/*     OUTPUTS: NONE                                                   */
/*     NOTE(S): This function will be called from configs/std/sysinit.c*/
/*              SysInit function.  The call to BspSetup happens        */
/*              BEFORE ANY COMPONENT IS INITIALIZED therefore it       */
/*              cannot call any system calls or services.              */
/*                                                                     */
/***********************************************************************/
extern int ixp_wdb_port; 

UCHAR *BspSetup(unsigned char *freeMemPtr)
{

#ifdef INCLUDE_WDB
	ixp_wdb_port = 1;
#else
	ixp_wdb_port = -1;
#endif

	freeMemPtr = SetupIxp400EthDriver(freeMemPtr);
	return freeMemPtr;
}
/***********************************************************************/
/* SetupLanParams : Associates virtual LAN enteries to physical lan    */
/*                  channels                                           */
/*                                                                     */
/* INPUTS: no_of_packets : Each type is allocated based on             */
/*         this parameter.                                             */
/*         FreeMemPtr:     Allocation starts from here.                */
/*         low_watermark: Inform pNA+ if no of Rx buffers left in NI   */
/*                        reach this value.                            */
/* OUTPUTS: Updated value of FreeMemPtr.                               */
/*                                                                     */
/*                                                                     */
/***********************************************************************/
UCHAR *SetupLanParams(ULONG no_of_packets, UCHAR *freememptr,
                                ULONG low_watermark)
{


	return (freememptr);
}

/*******************************************************************/
/* lighten_panel_led: To lighten LED of panel                      */
/*                                                                 */
/*      INPUTS:                                                    */
/*                                                                 */
/*     RETURNS:                                                    */
/*                                                                 */
/*******************************************************************/
void lighten_panel_led(void)
{

}
void rtc_init(void)
{
	RTC_TIME rtc_time;
	struct tm tm ;		/* ANSII time format */
	struct timespec tv ;	/* POSIX time */

	if  (RtcTime(&rtc_time,RTC_GET))	/*RTC not available*/
	{
		/* convert this to ANSI time */
		tm.tm_sec       = 0;
		tm.tm_min       = 0;
		tm.tm_hour      = 0;
		tm.tm_mday      = 1;
		tm.tm_mon       = 0;
		tm.tm_year      =  2004-1900;
		tm.tm_wday = 0 ;
		tm.tm_yday = 0 ;
		tm.tm_isdst = 0 ;
	}else
	{
		/* convert this to ANSI time */
		tm.tm_sec       = rtc_time.sec;
		tm.tm_min       = rtc_time.minute;
		tm.tm_hour      = rtc_time.hour;
		tm.tm_mday      = rtc_time.day;
		tm.tm_mon       = rtc_time.mon-1;
		tm.tm_year      = rtc_time.year-1900;
		tm.tm_wday = 0 ;
		tm.tm_yday = 0 ;
		tm.tm_isdst = 0 ;
	}
	
	/* convert ANSI to POSIX */
	tv.tv_sec = mktime( &tm );
	tv.tv_nsec = 0;

	/* set system time */
	clock_settime( CLOCK_REALTIME, &tv );
}
void rtc_set(ULONG date,ULONG time)
{

	RTC_TIME rtc_time;
	struct tm tm ;		/* ANSII time format */
    	struct timespec tv ;	/* POSIX time */

 	tm.tm_year=((date>>16)&0xFFFF)-1900;
	tm.tm_mon=((date>>8)&0xFF)-1;
	tm.tm_mday=(date)&0xFF;
	tm.tm_hour=(time>>16)&0xFFFF;
	tm.tm_min=(time>>8)&0xFF;
	tm.tm_sec=(time)&0xFF;
    	tm.tm_wday = 0 ;
    	tm.tm_yday = 0 ;
    	tm.tm_isdst = 0 ;

       /* convert ANSI to POSIX */
       tv.tv_sec = mktime( &tm );
       tv.tv_nsec = 0;
   
       /* set system time */
       clock_settime( CLOCK_REALTIME, &tv );

	/*tm_set(date, time, 0);*/
	memset(&rtc_time,0,sizeof(RTC_TIME));
	rtc_time.year=(date>>16)&0xFFFF;
	rtc_time.mon=(date>>8)&0xFF;
	rtc_time.day=(date)&0xFF;
	rtc_time.hour=(time>>16)&0xFFFF;
	rtc_time.minute=(time>>8)&0xFF;
	rtc_time.sec=(time)&0xFF;
	RtcTime(&rtc_time,RTC_SET);
}
void rtc_get(ULONG *date,ULONG *rtime)
{
	RTC_TIME rtc_time;
	time_t t;
	struct tm tm_t;

	if (RtcTime(&rtc_time,RTC_GET))/*RTC not available*/
	{
	
		time(&t);
		localtime_r(&t,&tm_t);
		*date = ((tm_t.tm_year+1900) <<16)+((tm_t.tm_mon+1) <<8)+tm_t.tm_mday;
		*rtime = (tm_t.tm_hour<< 16) + (tm_t.tm_min	<< 8)+tm_t.tm_sec;
	}else
	{
		*date = (rtc_time.year << 16) + (rtc_time.mon << 8) + rtc_time.day;
		*rtime = (rtc_time.hour<< 16) + (rtc_time.minute << 8)+rtc_time.sec;
	}
}


int check_logic(UCHAR input)
{
/*Print("check_logic(%d) called, return 0 always\n", input);*/
return 0;
}

int CardTable_init(void)
{

#if 0
	PCI_LOC     *pci;
	ULONG     index,slot,type,mcardindex;
	ULONG     d2s;
	int   mcardslotnum; 
	ULONG port;
	struct _CardTable* card;

	if((card=get_CardTable_entry())==NULL)
		return -1;
	switch (sys_get_router_type())
       {

       case ROUTER_TYPE_7208:
   	
       		card->Type = CARDTYPE_7208_MCARD;
       		card->Slots = 8;
       		break;
	case ROUTER_TYPE_3860:
	   	
       		card->Type = CARDTYPE_3860_MCARD;
       		card->Slots = 6;
       		break;

       default:  
           	card->Type=CARDTYPE_7208_MCARD;
 	       card->Slots=8;
 	       break;        
       }	
	card->flags|=CARDTABLE_MCARD;
	card->Descr=cardDescr[card->Type];
	card->Serial=0;
	card->HwVersion="";
	card->SwVersion="";
	card->SlotNumber=0;
	card->ContainedByIndex=0;
	card->OperStats=2;
	mcardindex=card->Index;
	mcardslotnum=card->Slots;
for(slot=1;slot<=mcardslotnum;slot++){
    index = 0;     
    while (pci = PciGetNextDev(&index, 0)) {
         d2s=GetSlotIndexByDevice(pci->device, pci->bus);        
        if(slot==d2s){
			switch(pci->dev_vend){
			case AM79C973_IDS:
				if(BspGetPortNumber(slot) == 2)
					type=CARDTYPE_2ETHRJ_100M;
				else if(BspGetPortNumber(slot) ==1)
					type = CARDTYPE_1ETHRJ_100M;
				else
					type = CARDTYPE_NONE;
				break;
			case PCI9080_IDS:
			{
			ULONG * ba;			
			UCHAR vstr;
			#define ESCC8_ASYNC16_VSTR_OFFSET  1588 
			/* read pcibar0 */
			ba = (ULONG*)PciCfgRead(pci, (PCI_BASE_ADDR0)<<2, PCI_REG_32BIT);
			ba = (ULONG*)PciBase2CpuAddr((ULONG)ba, pci->hostBridge);
			/* read offset 6C to determine if it is 16-async card */
			/*MODIFIED BY WANGZHIWEI FOR SUPPORT 3660 ESCC-ASYNC8  2001-6-7    */
			if (!( ba[0x6C/4] & BRD_CPU2DEV_LONG(0x00020000) )){

		          port = BspGetPortNumber(slot);
	                 if(port == 16)
	                	type = CARDTYPE_16ASYN;
	                 else if(port == 8)
	                   	type= CARDTYPE_8ASYN;
	                 else
	                   	type= CARDTYPE_NONE;
			}else
			   {
				type=CARDTYPE_8ASYN_SYN;
			  }
			}			  
			break;

			case PCIBRIDGE_IDS:
				port = BspGetPortNumber(slot);
                 		if(port == 16)
                			type = CARDTYPE_16ASYN;
                 		else if(port == 8)
                   			type= CARDTYPE_8ASYN;
                 		else
                   		type= CARDTYPE_NONE;
				break;

			case  Bt8474_IDS:
				port = BspGetPortNumber(slot);
				if(port == 4)
					type=CARDTYPE_4E1PRI;  /* need get port number, 2ce1 */
				else if(port == 2)
					type = CARDTYPE_2E1PRI;
				else
					type = CARDTYPE_NONE;
				break;
			case Bt8472_IDS:			   
				type=CARDTYPE_1E1PRI;
				break;
			/*MODIFIED BY WANGZHIWEI FOR SUPPORT 3660 4T  2001-6-7    */	
			case PCI9054_IDS_TTTT:
			    type=CARDTYPE_4ASYN_SYN;
			    break;
			case PCI9054_IDS_TEB:
				type = CARDTYPE_TEB;
				break;
			case PCI9054_IDS_TTE:
				type = CARDTYPE_TTE;
				break;
			case PCI9054_IDS_TTB:
				type = CARDTYPE_TTB;
				break;
			case PCI9052_IDS:
				type = CARDTYPE_4_BRI;
				break;
			case PCI9052_IDS_2:
				port = BspGetPortNumber(slot);
				if(port == 12)
					type = CARDTYPE_12_MODEM; 
				else if(port == 6)
					type = CARDTYPE_6_MODEM;
				else
					type = CARDTYPE_NONE;
				break;
			case PCI9054_IDS_4UE1:
				type = CARDTYPE_4_UE1;
				break;

			case DS31256_ID:
				{
					ULONG * ba;	
					UCHAR	key;

					if  (pci->function==1)
					{
						ba = (ULONG*)PciCfgRead(pci, (PCI_BASE_ADDR0)<<2, PCI_REG_32BIT);
						ba = (ULONG*)PciBase2CpuAddr((ULONG)ba, pci->hostBridge);
						
						key = *(UCHAR *)ba;		

						key &= 0x1f;
						if(key == 0x01)		/*DSE3 Module*/
						{
							type = CARDTYPE_1E3;				
						}
						if(key == 0x02)	/*DS16E1 Module*/
						{
							type = CARDTYPE_16E1PRI;		        			
						}
						if(key == 0x03)	/*DS8E1 Module*/
						{
							type = CARDTYPE_8E1PRI;		        			
						}
						if(key == 0x04)	/*DS4E1 Module*/
						{
							type = CARDTYPE_4E1PRI;		        			
						}

					}
					else
						type=CARDTYPE_NONE;	
					break;
				}
			case POSPMC_IDS:
				type=CARDTYPE_1POS;	
				break;

			case CX28500_IDS:
				type=CARDTYPE_1CPOS;	
				break;

			default:
				type=CARDTYPE_NONE;				
				break;
			};
			if(type!=CARDTYPE_NONE){
				if((card=get_CardTable_entry())==NULL)
				  {  
					return -1;
				   }	
				card->Type=type;									
				card->Descr=cardDescr[card->Type];		
				card->Serial=0;
				card->HwVersion="";
				card->SwVersion="";
				card->SlotNumber=slot;
				card->ContainedByIndex=mcardindex;
				card->OperStats=2;
				card->Slots=0;
				break;
			 /*BREAK IS PLACED HERE BY WANGZHIWEI FOR SUPPORT 3660 2001-6-7*/ 	
			}		 		
		}
	}/*while*/	
}/*for*/
#endif
	return 0;

}

⌨️ 快捷键说明

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