?? syslib.c
字號:
* * 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 */ ) { } #ifdef INCLUDE_CPM_END/********************************************************************************* 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 SCC1 is wired to port */ ) { *BCSR1 |= BCSR1_ETHN_EN_L; /* disable Ethernet device */ /* If running an 823, use SCC2 */ if (((*BCSR3 & BCSR3_DBID_MASK) == BCSR3_823DB_MASK) || ((*BCSR3 & BCSR3_DBID_MASK) == BCSR3_850SARDB_MASK) || ((*BCSR3 & BCSR3_DBID_MASK) == BCSR3_850DB_MASK)) { *PBPAR(vxImmrIsbGet()) &= ~PB18; /* set port B -> RTS2 = *TENA */ } else *PBPAR(vxImmrIsbGet()) &= ~PB19; /* set port B -> RTS1 = *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 ) { /* If running an 823, use SCC2 */ if (((*BCSR3 & BCSR3_DBID_MASK) == BCSR3_823DB_MASK) || ((*BCSR3 & BCSR3_DBID_MASK) == BCSR3_850SARDB_MASK) || ((*BCSR3 & BCSR3_DBID_MASK) == BCSR3_850DB_MASK)) { *CIMR(vxImmrIsbGet()) &= ~CIMR_SCC2; } else *CIMR(vxImmrIsbGet()) &= ~CIMR_SCC1; }/********************************************************************************* 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 - only slave SCC1 is wired to port */ ) { int immrVal = vxImmrIsbGet(); /* If running an 823, use SCC2 */ if (((*BCSR3 & BCSR3_DBID_MASK) == BCSR3_823DB_MASK) || ((*BCSR3 & BCSR3_DBID_MASK) == BCSR3_850SARDB_MASK) || ((*BCSR3 & BCSR3_DBID_MASK) == BCSR3_850DB_MASK)) { *SICR(immrVal) &= ~0xff00; if((*BCSR3 & BCSR3_DBID_MASK) == BCSR3_850SARDB_MASK) { *PAPAR(immrVal) |= (PA04 | PA06 | PA12 | PA13); *PADIR(immrVal) &= ~(PA04 | PA06 | PA12 | PA13); *SICR(immrVal) |= 0x2f00; /*-------------------------------------------------------------*/ /* Make sure that 68160 is enabled for normal operation */ /* */ /* BCSR4 TWISTED_PAIR_QET -> MC68160 TPSQEL pin */ /* BCSR4 TWISTED_PAIR_FD -> MC68160 TPFLDL pin */ /* BCSR4 ETH_LOOP_DIAG -> MC68160 ETHLOOP pin */ /*-------------------------------------------------------------*/ *BCSR4 &= ~BCSR4_ETHLOOP; *BCSR4 |= (BCSR4_TFPLDL_L | BCSR4_TPSQEL_L); /*-------------------------------------------------------------*/ /* NOTE: Since the Ethernet, RS232 and InfraRed are multiplexed*/ /* only one can be used at any time. Since Ethernet is */ /* enabled on SCC2 channel, RS232 and InfraRead are */ /* disabled */ /*-------------------------------------------------------------*/ *BCSR1 |= (BCSR1_RS232_2_EN_L | BCSR1_IR_EN_L); } else { *PAPAR(immrVal) |= (PA05 | PA06 | PA12 | PA13); *PADIR(immrVal) &= ~(PA05 | PA06 | PA12 | PA13); *SICR(immrVal) |= 0x2e00; /* connect SCC2 clocks */ *BCSR4 &= ~(BCSR4_ETHLOOP | BCSR4_TFPLDL_L | BCSR4_TPSQEL_L | BCSR4_MODEM_EN_L | BCSR4_DATA_VOICE_L); } *PAODR(immrVal) &= ~PA12; *BCSR1 &= ~(BCSR1_ETHN_EN_L); *PCPAR(immrVal) &= ~(PC08 | PC09); *PCDIR(immrVal) &= ~(PC08 | PC09); *PCSO(immrVal) |= (PC08 | PC09); *PBPAR(immrVal) |= PB18; /* set port B -> *RTS2 = TENA *//* 0x00002000; */ *PBDIR(immrVal) |= PB18;/* 0x00002000; */ } else { *PAPAR(immrVal) |= (PA06 | PA07 | PA14 | PA15); *PADIR(immrVal) &= ~(PA06 | PA07 | PA14 | PA15); *PCPAR(immrVal) &= ~(PC10 | PC11); *PCDIR(immrVal) &= ~(PC10 | PC11); *PCSO(immrVal) |= (PC10 | PC11); *PCDIR(immrVal) |= (PC04 | PC05 | PC06 | PC07); *PCDAT(immrVal) |= (PC05 | PC06); *PCDAT(immrVal) &= ~(PC04 | PC07); *SICR(immrVal) |= 0x2c; /* connect SCC1 clocks */ *SICR(immrVal) &= ~(0x40); /* NMSI mode */ *BCSR1 &= ~(BCSR1_ETHN_EN_L); /* enable Ethernet */ *PBPAR(immrVal) |= PB19; /* set port B -> *RTS1 = TENA */ *PBDIR(immrVal) |= PB19; } 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 ) { 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 ) { UINT32 immrVal = vxImmrIsbGet() ; /* If running an 823, use SCC2 */ if (((*BCSR3 & BCSR3_DBID_MASK) == BCSR3_823DB_MASK) || ((*BCSR3 & BCSR3_DBID_MASK) == BCSR3_850SARDB_MASK) || ((*BCSR3 & BCSR3_DBID_MASK) == BCSR3_850DB_MASK)) { while (*CPCR(immrVal) & CPM_CR_FLG); *CPCR(immrVal) = (VUINT16)(CPM_CR_CHANNEL_SCC2 | command | CPM_CR_FLG); while (*CPCR(immrVal) & CPM_CR_FLG); } else { while (*CPCR(immrVal) & CPM_CR_FLG); *CPCR(immrVal) = (VUINT16)(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 ) { /* If running an 823, use SCC2 */ if (((*BCSR3 & BCSR3_DBID_MASK) == BCSR3_823DB_MASK) || ((*BCSR3 & BCSR3_DBID_MASK) == BCSR3_850SARDB_MASK) || ((*BCSR3 & BCSR3_DBID_MASK) == BCSR3_850DB_MASK)) { *CIMR(vxImmrIsbGet()) |= CIMR_SCC2; } else *CIMR(vxImmrIsbGet()) |= 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 ) { /* If running an 823, use SCC2 */ if (((*BCSR3 & BCSR3_DBID_MASK) == BCSR3_823DB_MASK) || ((*BCSR3 & BCSR3_DBID_MASK) == BCSR3_850SARDB_MASK) || ((*BCSR3 & BCSR3_DBID_MASK) == BCSR3_850DB_MASK)) { *CISR(vxImmrIsbGet()) = CISR_SCC2; } else *CISR(vxImmrIsbGet()) = CISR_SCC1; }#endif /* INCLUDE_CPM_END */#ifdef INCLUDE_MOT_FEC/********************************************************************************* sysFecEnetEnable - enable the MII interface of the Fast Ethernet controller** This routine is expected to perform any target specific functions required* to enable the Ethernet device and the MII interface of the Fast Ethernet * controller. These functions include setting the MII-compliant signals on * Port D and disabling the IRQ7 signal.** This routine does not enable the 7-wire serial interface.** RETURNS: OK, or ERROR if the Fast Ethernet controller cannot be enabled.*/STATUS sysFecEnetEnable ( UINT32 motCpmAddr /* base address of the on-chip RAM */ ) { int intLevel = intLock(); /* enable the Ethernet device for the FEC */ *BCSR4 |= (BCSR4_FETH_RST | BCSR4_FETH_CFG0 | BCSR4_FETH_FDE); *BCSR4 &= ~BCSR4_UUFDIS; /* introduce a little delay */ taskDelay (sysClkRateGet ()); /* mask IRQ7 off, as it is shared with MII_TX_CLK */ *SIMASK (motCpmAddr) &= ~SIMASK_IRM7; /* also clear any pending interrupt */ *SIPEND (motCpmAddr) |= SIPEND_IRQ7; /* * set the arbitration level for the FEC. Do not enable * FEC aggressive mode. */ *SDCR (motCpmAddr) |= SDCR_FAID_BR6; /* set Port D to use MII signals */ *PDPAR (motCpmAddr) = 0x1fff;#ifdef MPC860_REVD *PDDIR (motCpmAddr) = 0x1fff;#else *PDDIR (motCpmAddr) = 0x1c58;#endif /* MPC860_REVD */ intUnlock (intLevel); return (OK); }/********************************************************************************* sysFecEnetDisable - disable MII interface to the Fast Ethernet controller** This routine is expected to perform any target specific functions required* to disable the Ethernet device and the MII interface to the Fast Ethernet * controller. This involves restoring the default values for all the Port * D signals.** RETURNS: OK, always.*/STATUS sysFecEnetDisable ( UINT32 motCpmAddr /* base address of the on-chip RAM */ ) { int intLevel = intLock(); /* disable the Ethernet device for the FEC */ *BCSR4 |= BCSR4_UUFDIS; /* configure all Port D pins as general purpose input pins */ *PDPAR (motCpmAddr) = 0; *PDDIR (motCpmAddr) = 0; intUnlock (intLevel); return (OK); }/********************************************************************************* sysFecEnetAddrGet - get the hardware Ethernet address** This routine provides the six byte Ethernet hardware address that will be* used by each individual Fast 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 sysFecEnetAddrGet ( UINT32 motCpmAddr, /* base address of the on-chip RAM */ UCHAR * addr /* where to copy the Ethernet address */ ) { bcopy ((char *) sysFecEnetAddr, (char *) addr, sizeof (sysFecEnetAddr)); return (OK); }#endif /* INCLUDE_MOT_FEC */
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -