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

📄 syslib.c

📁 860最小系统的bsp
💻 C
📖 第 1 页 / 共 2 页
字号:
        
	    * TBSCR(immrVal) = TBSCR_TBE ;
        
	    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.
*
* Not applicable for the busless 860Ads.
*
* RETURNS: N/A
*
* SEE ALSO: sysProcNumGet()
*
*/

void sysProcNumSet
    (
    int 	procNum			/* processor number */
    )
{
    sysProcNum = procNum;
}





/******************************************************************************
*
* sysLocalToBusAdrs - convert a local address to a bus address
*
* This routine gets the VMEbus address that accesses a specified local
* memory address.
*
* Not applicable for the 860Ads
*
* RETURNS: ERROR, always.
*
* SEE ALSO: sysBusToLocalAdrs()
*/
 
STATUS sysLocalToBusAdrs
    (
    int 	adrsSpace,	/* bus address space where busAdrs resides */
    char *	localAdrs,	/* local address to convert */ 
    char **	pBusAdrs	/* where to return bus address */ 
    )
{
    return (ERROR);
}





/******************************************************************************
*
* sysBusToLocalAdrs - convert a bus address to a local address
*
* This routine gets the local address that accesses a specified VMEbus
* physical memory address.
*
* Not applicable for the 860Ads
*
* RETURNS: ERROR, always.
*
* SEE ALSO: sysLocalToBusAdrs()
*/

STATUS sysBusToLocalAdrs
    (
     int  	adrsSpace, 	/* bus address space where busAdrs resides */
     char *	busAdrs,   	/* bus address to convert */
     char **	pLocalAdrs 	/* where to return local address */
    )
{
    return (ERROR);
}





/******************************************************************************
*
* sysBusTas - test and set a location across the bus
*
* This routine does an atomic test-and-set operation across the backplane.
*
* Not applicable for the 860Ads.
*
* RETURNS: FALSE, always.
*
* SEE ALSO: vxTas()
*/

BOOL sysBusTas
    (
     char *	adrs		/* address to be tested-and-set */
    )
{
    return (FALSE);
}





/******************************************************************************
*
* sysBusClearTas - test and clear 
*
* This routine is a null function.
*
* RETURNS: N/A
*/

void sysBusClearTas
    (
     volatile char * address	/* address to be tested-and-cleared */
    )
{
} 





/*******************************************************************************
*
* sysCpmEnetDisable - disable the Ethernet controller
*
* This routine is expected to perform any target specific functions required
* to disable the Ethernet controller.  This usually involves disabling the
* Transmit Enable (TENA) signal.
*
* RETURNS: N/A
*/

void sysCpmEnetDisable
    (
    int         unit   /*only scc1 be utilized*/
    )
{
   	*PBPAR(vxImmrGet()) &= ~(0x00001000);    /*PB19*/
    
}





/*******************************************************************************
*
* sysCpmEnetIntDisable - disable the Ethernet interface interrupt
*
* This routine disable the interrupt for the Ethernet interface specified
* by <unit>.
*
* RETURNS: N/A.
*/

void sysCpmEnetIntDisable
    (
    int		unit
    )
{
    
	*CIMR(vxImmrGet()) &= ~CIMR_SCC1;     /*禁止中断*/

}





#ifdef	INCLUDE_CPM
/*******************************************************************************
*
* sysCpmEnetEnable - enable the Ethernet controller
*
* This routine is expected to perform any target specific functions required
* to enable the Ethernet controller.  These functions typically include
* enabling the Transmit Enable signal (TENA) and connecting the transmit
* and receive clocks to the SCC.
*
* RETURNS: OK, or ERROR if the Ethernet controller cannot be enabled.
*/

STATUS sysCpmEnetEnable
    (
    int		unit    /*  used  SCC1 is wired to port */
    )
{
    int immrVal = vxImmrGet();
   
	
	*PAPAR(immrVal) |= 0x0a03;     /*和原理图对应*/
	*PADIR(immrVal) &= ~(0x0a03); /**/
	
	/*PA14,PA15----E-TXD(O),E-RXD(I)*/
	/*PA4,PA6------E-TCLK(I),E-RCLK(I)*/
	/*PAPAR对应位为1*/
	/*PADIR对应位为0*/

	*PCPAR(immrVal) &= ~(0x0030);
	*PCDIR(immrVal) &= ~(0x0030);
	*PCSO(immrVal)  |= 0x0030;
	/*PC10,PC11-----E-CD(I),E-COL(I)*/
	/*PCPAR对应位位0*/
	/*PCDIR对应位为0*/
	/*PCSO对应位为1*/
     

	*SICR(immrVal)  |=( 0x0000002f);            /* connect SCC1 clocks ,clk4(t)$clk2(r)*/
	                                             /* r1cs=0b101,t1cs=0b111*/
	*SICR(immrVal)  &= ~(0x00000040);          /* NMSI mode */
	
	*PBPAR(immrVal) |= 0x00001000;      /* set port B 19 -> *RTS1 = TENA */
	*PBDIR(immrVal) |= 0x00001000;
	
    return (OK);
}





/*******************************************************************************
*
* sysCpmEnetAddrGet - get the hardware Ethernet address
*
* This routine provides the six byte Ethernet hardware address that will be
* used by each individual Ethernet device unit.  This routine must copy
* the six byte address to the space provided by <addr>.
*
* RETURNS: OK, or ERROR if the Ethernet address cannot be returned.
*/

STATUS sysCpmEnetAddrGet
    (
    int		unit,   /* not used - only slave SCC1 is wired to port */
    UINT8 *	addr
    )
{
    char i;
    if(*(UINT8*)(ENET_MAC_ADDR_FLAG)==ENET_MAC_ADDR_OK)
    {
	 bcopy ((char *)0x307c0002, (char *) addr, 6);
    }
    else
    {
       for(i=0;i<6;i++)
       addr[i]=0xff;
    }
    return (OK);
}





/*******************************************************************************
*
* sysCpmEnetCommand - issue a command to the Ethernet interface controller
*
* RETURNS: OK, or ERROR if the Ethernet controller could not be restarted.
*/

STATUS sysCpmEnetCommand
    (
    int		unit,
    UINT16	command
    )
{
    int	immrVal = vxImmrGet();
  
	while (*CPCR(immrVal) & CPM_CR_FLG);
	 *CPCR(immrVal) = CPM_CR_CHANNEL_SCC1 | command | CPM_CR_FLG;
	while (*CPCR(immrVal) & CPM_CR_FLG);

    return (OK);
}





/*******************************************************************************
*
* sysCpmEnetIntEnable - enable the Ethernet interface interrupt
*
* This routine enable the interrupt for the Ethernet interface specified
* by <unit>.
*
* RETURNS: N/A.
*/

void sysCpmEnetIntEnable
    (
    int		unit
    )
{
	*CIMR(vxImmrGet()) |= CIMR_SCC1;
}





/*******************************************************************************
*
* sysCpmEnetIntClear - clear the Ethernet interface interrupt
*
* This routine clears the interrupt for the Ethernet interface specified
* by <unit>.
*
* RETURNS: N/A.
*/

void sysCpmEnetIntClear
    (
    int		unit
    )
{
	*CISR(vxImmrGet()) = CISR_SCC1;
}





/*******************************************************************************
*
* sysCpmAttach - attach wrapper
*
*/

STATUS sysCpmAttach
    (
    int         unit,           /* unit number */
    SCC *       pScc,           /* address of SCC parameter RAM */
    SCC_REG *   pSccReg,        /* address of SCC registers */
    VOIDFUNCPTR * ivec,         /* interrupt vector offset */
    SCC_BUF *   txBdBase,       /* transmit buffer descriptor base address */
    SCC_BUF *   rxBdBase,       /* receive buffer descriptor base address */
    int         txBdNum,        /* number of transmit buffer descriptors */
    int         rxBdNum,        /* number of receive buffer descriptors */
    UINT8 *     bufBase         /* address of memory pool; NONE = malloc it */
    )
{
    
	return (cpmattach(unit, pScc, pSccReg, ivec, 
			  txBdBase, rxBdBase, txBdNum, rxBdNum, bufBase));
}
#endif	/* INCLUDE_CPM */




void sysNetHwInit( void )
/*
网络初始化
参数:无
返回值:无
*/
{
    sysCpmEnetDisable(0);	
    sysCpmEnetIntDisable(0);
}





void sysNetHwInit2( void )
/*
网络初始化
参数:无
返回值:无
*/
{

}





void sysNetSwitch( void )
{
	*(UINT16*)(0x7020000)=0x2400;
	*(UINT16*)(0x7020002)=0x1100;
	*(UINT16*)(0x7000000)=0x0068;
	*(UINT16*)(0x7000000)=0x0008;
	*(UINT16*)(0x700000e)=0x0033;
	*(UINT16*)(0x7006814)=0x340e;
	*(UINT16*)(0x700681c)=0x340a;
	*(UINT16*)(0x7007000)=0x60aa;
	*(UINT16*)(0x7007002)=0x60ff;
	*(UINT16*)(0x7007004)=0x60bd;
	*(UINT16*)(0x7007006)=0x60ff;
	*(UINT16*)(0x7007010)=0x60ff;
	*(UINT16*)(0x7007012)=0x60aa;
	*(UINT16*)(0x7007014)=0x60ff;
	*(UINT16*)(0x7007016)=0x60aa;
	*(UINT16*)(0x7007020)=0x60aa;
	*(UINT16*)(0x7007022)=0x60ff;
	*(UINT16*)(0x7007024)=0x60aa;
	*(UINT16*)(0x7007026)=0x60ff;
}

⌨️ 快捷键说明

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