sysSerial.c
资源名称:ixp425BSP.rar [点击查看]
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:5k
源码类别:
VxWorks
开发平台:
C/C++
- /* sysSerial.c - IXP425 UART bsp serial device initialization */
- /* Copyright 2002 Wind River Systems, Inc. */
- #include "copyright_wrs.h"
- /*
- modification history
- --------------------
- 01a,05jun02,jb initial version...
- */
- /*
- DESCRIPTION
- Serial initialisation routines.
- */
- #include "vxWorks.h"
- #include "iv.h"
- #include "intLib.h"
- #include "config.h"
- #include "sysLib.h"
- #include "ixp425.h"
- #include "ixp425Sio.h"
- #include "ixp425Sio.c"
- /*
- * UART2 should not be used as a very low level debug port therefore only enable it
- * if debug support is turned off.
- */
- #ifdef INCLUDE_UART2_SUPPORT
- #ifdef INCLUDE_IXP425_UART_DEBUG
- #undef INCLUDE_UART2_SUPPORT
- #endif
- #endif /* INCLUDE_UART2_SUPPORT */
- /* local data */
- static IXP425_SIO_CHAN ixp425Chan[IXP425_NUM_UARTS];
- /******************************************************************************
- *
- * sysSerialHwInit - initialize the BSP serial devices to a quiesent state
- *
- * This routine initializes the BSP serial device descriptors and puts the
- * devices in a quiesent state. It is called from sysHwInit() with
- * interrupts locked.
- *
- * RETURNS: N/A
- */
- void sysSerialHwInit (void)
- {
- /* intialize the chips device descriptors */
- #ifdef INCLUDE_UART1_SUPPORT
- ixp425Chan[0].regs = (UINT8 *)IXP425_UART1_BASE;
- ixp425Chan[0].level = INT_VEC_UART1;
- ixp425Chan[0].regDelta = IXP425_UART_REG_DELTA;
- ixp425Chan[0].xtal = IXP425_UART_XTAL;
- ixp425Chan[0].baudRate = UART_DEFAULT_BAUD;
- ixp425Chan[0].options = 0;
- #endif
- #ifdef INCLUDE_UART2_SUPPORT
- ixp425Chan[1].regs = (UINT8 *)IXP425_UART2_BASE;
- ixp425Chan[1].level = INT_VEC_UART2;
- ixp425Chan[1].regDelta = IXP425_UART_REG_DELTA;
- ixp425Chan[1].xtal = IXP425_UART_XTAL;
- ixp425Chan[1].baudRate = UART_DEFAULT_BAUD;
- ixp425Chan[1].options = 0;
- #endif
- /* reset the chips */
- #ifdef INCLUDE_UART1_SUPPORT
- ixp425SioDevInit (&ixp425Chan[0]);
- #endif
- #ifdef INCLUDE_UART2_SUPPORT
- ixp425SioDevInit (&ixp425Chan[1]);
- #endif
- }
- /******************************************************************************
- *
- * sysSerialHwInit2 - connect BSP serial device interrupts
- *
- * This routine connects the BSP serial device interrupts. It is called from
- * sysHwInit2(). Serial device interrupts could not be connected in
- * sysSerialHwInit() because the kernel memory allocator was not initialized
- * at that point, and intConnect() calls malloc().
- *
- * RETURNS: N/A
- */
- void sysSerialHwInit2 (void)
- {
- /* now connect the serial device interrupts */
- #ifdef INCLUDE_UART1_SUPPORT
- (void) intConnect ((VOIDFUNCPTR *)((UINT32)ixp425Chan[0].level),
- (VOIDFUNCPTR) ixp425SioInt, (int)&ixp425Chan[0]);
- #endif
- #ifdef INCLUDE_UART2_SUPPORT
- (void) intConnect ((VOIDFUNCPTR *)((UINT32)ixp425Chan[1].level),
- (VOIDFUNCPTR) ixp425SioInt, (int)&ixp425Chan[1]);
- #endif
- #ifdef INCLUDE_UART1_SUPPORT
- /* Enable the UART interrupt */
- intEnable (ixp425Chan[0].level);
- #endif
- #ifdef INCLUDE_UART2_SUPPORT
- intEnable (ixp425Chan[1].level);
- #endif
- }
- /******************************************************************************
- *
- * sysSerialChanGet - get the SIO_CHAN device associated with a serial channel
- *
- * This routine gets the SIO_CHAN device associated with a specified serial
- * channel.
- *
- * RETURNS: A pointer to the SIO_CHAN structure for the channel, or ERROR
- * if the channel is invalid.
- */
- SIO_CHAN * sysSerialChanGet
- (
- int channel
- )
- {
- switch (channel)
- {
- #ifdef INCLUDE_UART1_SUPPORT
- case 0:
- return ((SIO_CHAN *)&ixp425Chan[0]);
- #endif
- #ifdef INCLUDE_UART2_SUPPORT
- case 1:
- return ((SIO_CHAN *)&ixp425Chan[1]);
- #endif
- default:
- return ((SIO_CHAN *)ERROR);
- }
- }
- /******************************************************************************
- *
- * sysSerialReset - reset the sio devices to a quiet state
- *
- * Reset all devices to prevent them from generating interrupts.
- *
- * This is called from sysToMonitor() to shutdown the system gracefully
- * before transferring control to the boot ROM.
- *
- * RETURNS: N/A.
- */
- void sysSerialReset (void)
- {
- /* Disable the UART interrupt */
- #ifdef INCLUDE_UART1_SUPPORT
- intDisable (ixp425Chan[0].level);
- #endif
- #ifdef INCLUDE_UART2_SUPPORT
- intDisable (ixp425Chan[1].level);
- #endif
- }
- /******************************************************************************
- *
- * sysSerialShow - display serial statistics
- *
- * RETURNS: N/A.
- */
- void sysSerialShow ()
- {
- int i=0;
- for (i=0; i<IXP425_NUM_UARTS; i++)
- {
- printf("nChannel (%d):", i);
- ixp425SioStatsShow(&ixp425Chan[i]);
- }
- }