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

📄 syslib.c

📁 powerPC866 系列平台BSP移植开发的参考代码
💻 C
📖 第 1 页 / 共 4 页
字号:

    /* See if the command has been accepted. */

    while (*CPCR(immrVal) & CPM_CR_FLG)
        {}

    return;
    }
#ifdef	INCLUDE_SCC_HDLC   /* add scc hdlc end by Jin*/
/*****************************************************************************
* Function:		sysEnetAddrSet
* Author:		Jin
* Description:  Set all the END device mac addr
* Parameters:   char * pName	network interface name
				int		unit 	network interface unit
    			UINT8 *	addr	mac address to set
* Returns:      OK or ERROR
*****************************************************************************/
STATUS sysEnetAddrSet
    (
	INT8 	*pName,	
	INT32	unit, 
    UINT8 	*addr
    )
    {
	void * pCookie;
	if(unit==0)
		bcopy((const char *)addr, (char *)sysScc3EnetAddr,ENET_ADDR_SIZE);
	else
		bcopy((const char *)addr, (char *)sysScc4EnetAddr,ENET_ADDR_SIZE);

/*	ipDetach(unit, (char *)pName);*/
	pCookie = (void *)muxTkCookieGet((char *)pName, unit);
	if( muxIoctl((void *)pCookie, EIOCSADDR, (char *)addr) == ERROR )
		return (ERROR);
/*
	ipAttach(unit, (char *)pName);*/
    return (OK);
    }


/*******************************************************************************
*
* sysSccEnetDisable - 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 sysSccEnetDisable
    (
    int unit    /* not used - only slave SCC3 is wired to port */
    )
    {
    EPCFG *cfg = getEpCfg();

    /* Use the common definitions that are the same across all boards */
#ifdef INCLUDE_BCSR
    *(char*)BCSR &= (~(COMMON_BCSR_ETHEN | COMMON_BCSR_ETHLPBK)) >> 24;  /* disable Ethernet device */
    *(char*)BCSR |= (COMMON_BCSR_COLTEST | COMMON_BCSR_FULLDPLX) >> 24;
#endif
	if (unit ==0)
    	*PCPAR(vxImmrGet()) &= ~(PC_ENET_TENA_852);    /* set port C -> RTS3 = TENA~ */
	else 
		*PCPAR(vxImmrGet()) &= ~0x0008; 	/* set port C -> RTS4 = TENA~ */
    }


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

void sysSccEnetIntDisable
    (
    int		unit
    )
{
    EPCFG *cfg = getEpCfg();

   	/* use SCC3 */
	if (unit == 0)
   		*CIMR(vxImmrGet()) &= ~CIMR_SCC3;
   	else
   		*CIMR(vxImmrGet()) &= ~CIMR_SCC4;
}

/*******************************************************************************
*
* 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 sysSccEnetEnable
    (
    int		unit    /* not used */
    )
    {
    int immrVal = vxImmrGet();

	*PAPAR(immrVal) |= 0xf0f0;
	*PADIR(immrVal) &= 0x0f0f;
	*PAODR(immrVal) &= 0x000f;

	/* connect clk5~8 to scc3 4 */
	*SICR(immrVal) &= 0x0000ffff;
	*SICR(immrVal) |= 0x3d340000;

#if 0
	/* route SCC3 for 10Base Ethernet; disable SCC serial port xcvr */
#ifdef INCLUDE_BCSR
	*BCSR4 &= ~(EP852_BCSR_SCCSEL | EP852_BCSR_SCCENXCVR);
#endif
	
	/* set port pins */
    *PAPAR(immrVal) |= (PA_ENET_RXD_852  | PA_ENET_TXD_852);
    *PADIR(immrVal) &= ~(PA_ENET_RXD_852 | PA_ENET_TXD_852);
	*PAODR(immrVal) &= ~(PA_ENET_RXD_852 | PA_ENET_TXD_852);

    *PAPAR(immrVal) |= (PA_ENET_TCLK_852  | PA_ENET_RCLK_852);
    *PADIR(immrVal) &= ~(PA_ENET_TCLK_852 | PA_ENET_RCLK_852);
	*PAODR(immrVal) &= ~(PA_ENET_TCLK_852 | PA_ENET_RCLK_852);

    *PCPAR(immrVal) &= ~(PC_ENET_CLSN_852 | PC_ENET_RENA_852);
    *PCDIR(immrVal) &= ~(PC_ENET_CLSN_852 | PC_ENET_RENA_852);
    *PCSO(immrVal)  |= (PC_ENET_CLSN_852  | PC_ENET_RENA_852);

    /* Clear SCC3 Clock Sources and set NMSI */
    *SICR(immrVal)  &= ~(SICR_ENET_MASK_852);

    /* Set SCC3 Clock Sources to Rx: CLK6, and TX: CLK5 */
    *SICR(immrVal)  |= SICR_ENET_CLKRT_852;

    /* U-BUS arbitration priority 5 (BR5) */
    *SDCR(immrVal) = 0x0001;

  /* Enable Ethernet and Disable Full Duplex Mode */
#ifdef INCLUDE_BCSR
    *(char*)BCSR &= (~(COMMON_BCSR_ETHEN | COMMON_BCSR_ETHLPBK | COMMON_BCSR_COLTEST | COMMON_BCSR_FULLDPLX)) >> 24;
    *(char*)BCSR |= (COMMON_BCSR_ETHEN | COMMON_BCSR_COLTEST | COMMON_BCSR_FULLDPLX) >> 24;
#endif

  	/*PC13=RTS3~ */
    *PCPAR(immrVal) |= (PC_ENET_TENA_852);
    *PCDIR(immrVal) &= ~(PC_ENET_TENA_852);
    *PCSO(immrVal)  &= ~(PC_ENET_TENA_852);
#endif

    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 sysSccEnetAddrGet
    (
    int		unit,   /* not used - only slave SCC3 is wired to port */
    UINT8 *	addr
    )
    {
    if(unit == 0)
    	bcopy ((char *)sysScc3EnetAddr, (char *)addr, sizeof(sysScc3EnetAddr));
	else
    	bcopy ((char *)sysScc4EnetAddr, (char *)addr, sizeof(sysScc4EnetAddr));

    return (OK);
    }

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

STATUS sysSccEnetCommand
    (
    int		unit,
    UINT16	command
    )
    {
    EPCFG *cfg  = getEpCfg();
    int	immrVal = vxImmrGet();

   	/* use SCC3 */
    while (*CPCR(immrVal) & CPM_CR_FLG);
    *CPCR(immrVal) = CPM_CR_CHANNEL_SCC3 | 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 sysSccEnetIntEnable
    (
    int		unit
    )
    {
    EPCFG *cfg  = getEpCfg();
	if (unit == 0)
   		*CIMR(vxImmrGet()) |= CIMR_SCC3;
   	else
   		*CIMR(vxImmrGet()) |= CIMR_SCC4;

    }

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

void sysSccEnetIntClear
    (
    int		unit
    )
    {
    EPCFG *cfg  = getEpCfg();
	if(unit == 0)
   		*CISR(vxImmrGet()) = CISR_SCC3;
   	else 
   		*CISR(vxImmrGet()) = CISR_SCC4;

    }

/*******************************************************************************
*
* sysCpmAttach - attach wrapper
*
*/
STATUS sysSccAttach
    (
    int unit
    )

    {
    ipAttach (unit, SCC_DEV_NAME);
    if (unit ==0){
    	ifMaskSet("hdlc0", 0xffffff00);
		ifAddrSet("hdlc0", "192.168.0.2");
		hostAdd("hdlc0","192.168.0.2");
	}
	else{
		ifMaskSet("hdlc1", 0xffffff00);
		ifAddrSet("hdlc1", "192.168.1.2");
		hostAdd("hdlc1","192.168.1.2");
	}

    return (OK);
    }

#endif	/* INCLUDE_SCC_HDLC */


#ifdef	INCLUDE_CPM
/*******************************************************************************
*
* 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    /* not used - only slave SCC3 is wired to port */
    )
    {
    EPCFG *cfg = getEpCfg();

    /* Use the common definitions that are the same across all boards */
#ifdef INCLUDE_BCSR
    *(char*)BCSR &= (~(COMMON_BCSR_ETHEN | COMMON_BCSR_ETHLPBK)) >> 24;  /* disable Ethernet device */
    *(char*)BCSR |= (COMMON_BCSR_COLTEST | COMMON_BCSR_FULLDPLX) >> 24;
#endif

    *PCPAR(vxImmrGet()) &= ~(PC_ENET_TENA_852);    /* set port C -> RTS3 = TENA~ */
    }


/*******************************************************************************
*
* 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
    )
    {
    EPCFG *cfg = getEpCfg();

   	/* use SCC3 */
   	*CIMR(vxImmrGet()) &= ~CIMR_SCC3;
}

/*******************************************************************************
*
* 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    /* not used */
    )
    {
    int immrVal = vxImmrGet();

	/* route SCC3 for 10Base Ethernet; disable SCC serial port xcvr */
#ifdef INCLUDE_BCSR
	*BCSR4 &= ~(EP852_BCSR_SCCSEL | EP852_BCSR_SCCENXCVR);
#endif
	
	/* set port pins */
    *PAPAR(immrVal) |= (PA_ENET_RXD_852  | PA_ENET_TXD_852);
    *PADIR(immrVal) &= ~(PA_ENET_RXD_852 | PA_ENET_TXD_852);
    *PAODR(immrVal) &= ~(PA_ENET_RXD_852 | PA_ENET_TXD_852);

    *PAPAR(immrVal) |= (PA_ENET_TCLK_852  | PA_ENET_RCLK_852);
    *PADIR(immrVal) &= ~(PA_ENET_TCLK_852 | PA_ENET_RCLK_852);
    *PAODR(immrVal) &= ~(PA_ENET_TCLK_852 | PA_ENET_RCLK_852);

    *PCPAR(immrVal) &= ~(PC_ENET_CLSN_852 | PC_ENET_RENA_852);
    *PCDIR(immrVal) &= ~(PC_ENET_CLSN_852 | PC_ENET_RENA_852);
    *PCSO(immrVal)  |= (PC_ENET_CLSN_852  | PC_ENET_RENA_852);

    /* Clear SCC3 Clock Sources and set NMSI */
    *SICR(immrVal)  &= ~(SICR_ENET_MASK_852);

    /* Set SCC3 Clock Sources to Rx: CLK6, and TX: CLK5 */
    *SICR(immrVal)  |= SICR_ENET_CLKRT_852;

    /* U-BUS arbitration priority 5 (BR5) */
    *SDCR(immrVal) = 0x0001;

    /* Enable Ethernet and Disable Full Duplex Mode */
#ifdef INCLUDE_BCSR
    *(char*)BCSR &= (~(COMMON_BCSR_ETHEN | COMMON_BCSR_ETHLPBK | COMMON_BCSR_COLTEST | COMMON_BCSR_FULLDPLX)) >> 24;
    *(char*)BCSR |= (COMMON_BCSR_ETHEN | COMMON_BCSR_COLTEST | COMMON_BCSR_FULLDPLX) >> 24;
#endif

    /* PC13=RTS3~ */
    *PCPAR(immrVal) |= (PC_ENET_TENA_852);
    *PCDIR(immrVal) &= ~(PC_ENET_TENA_852);
    *PCSO(immrVal)  &= ~(PC_ENET_TENA_852);

    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 SCC3 is wired to port */
    UINT8 *	addr
    )
    {
    bcopy ((char *) sysCpmEnetAddr, (char *) addr, sizeof (sysCpmEnetAddr));

    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
    )
    {
    EPCFG *cfg  = getEpCfg();
    int	immrVal = vxImmrGet();

   	/* use SCC3 */
    while (*CPCR(immrVal) & CPM_CR_FLG);
    *CPCR(immrVal) = CPM_CR_CHANNEL_SCC3 | 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
    )
    {
    EPCFG *cfg  = getEpCfg();

   	*CIMR(vxImmrGet()) |= CIMR_SCC3;

    }

/*******************************************************************************
*
* 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
    )
    {
    EPCFG *cfg  = getEpCfg();

⌨️ 快捷键说明

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