sysSerial.c
资源名称:idt438.rar [点击查看]
上传用户:yingyi0918
上传日期:2022-06-26
资源大小:214k
文件大小:5k
源码类别:
VxWorks
开发平台:
C/C++
- /* sysSerial.c - BSP serial device initialization */
- /* Copyright 1984-2002 Wind River Systems, Inc. */
- #include "copyright_wrs.h"
- /*
- * This file has been developed or significantly modified by the
- * MIPS Center of Excellence Dedicated Engineering Staff.
- * This notice is as per the MIPS Center of Excellence Master Partner
- * Agreement, do not remove this notice without checking first with
- * WR/Platforms MIPS Center of Excellence engineering management.
- */
- /*
- modification history
- --------------------
- 01b,12jul02,d_c Make base address offset for endianness a #define
- 01a,19Jun02,d_c Code from IDT modified to approach C of E standards.
- */
- /*
- DESCRIPTION
- This module contains all the functions needed to initialize the serial device
- */
- /*includes */
- #include "copyright_wrs.h"
- #include "vxWorks.h"
- #include "arch/mips/ivMips.h"
- #include "intLib.h"
- #include "config.h"
- #include "sysLib.h"
- #include "drv/sio/ns16552Sio.h"
- /*typedefs*/
- /* device initialization structure */
- typedef struct
- {
- int intNum ;
- ULONG baseAdrs; /* Register base address */
- } NS16550_DEV_PARAMS;
- /* Local data structures */
- static NS16550_CHAN ns16550Chan[N_UART_CHANNELS];
- /* Device paramters: Note that UART_ENDIAN_OFFSET is added to the base
- * addresses to account for endianness. The device is inherently
- * little endian.
- */
- static NS16550_DEV_PARAMS devParams[N_UART_CHANNELS] =
- {
- {COM1_INT_NUM, UART0_BASE + UART_ENDIAN_OFFSET},
- };
- /******************************************************************************
- *
- * 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)
- {
- int chan; /* Serial channel */
- for (chan = 0; chan < N_UART_CHANNELS; chan++)
- {
- ns16550Chan[chan].regs = (UINT8 *)devParams[chan].baseAdrs;
- ns16550Chan[chan].level = devParams[chan].intNum;
- ns16550Chan[chan].regDelta = UART_REG_ADDR_INTERVAL;
- ns16550Chan[chan].baudRate = UART_DEFAULT_BAUD_RATE;
- ns16550Chan[chan].xtal = NS16550_XTAL_FREQ;
- ns16550DevInit (&ns16550Chan[chan]);
- sysWbFlush ();
- }
- }
- /******************************************************************************
- *
- * sysSerialInt - BSP specific serial device ISR
- *
- *
- * This function is the BSP Specific serial device Interrupt Service Routine
- *
- * RETURNS: N/A
- */
- void sysSerialInt
- (
- int chan /*serial channel */
- )
- {
- ns16550Int (&ns16550Chan[chan]);
- }
- /******************************************************************************
- *
- * 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)
- {
- int chan; /*channel */
- for (chan = 0; chan < N_UART_CHANNELS; chan++)
- {
- intConnect (INUM_TO_IVEC(devParams[chan].intNum), sysSerialInt, chan);
- }
- /* connect serial interrupts */
- INTERRUPT.i5.imask &= ~(UART0_GENERAL_INTR_MASK);
- sysWbFlush ();
- }
- /******************************************************************************
- *
- * sysSerialHwReset - reset the serial controllers
- *
- * Shutdown all controllers capable of generating interrupts, especially
- * controllers using DMA to transfer channel command blocks. Most Bug
- * monitors presume that a hardware reset precedes entry to the monitor
- * code.
- *
- * RETURNS: N/A.
- */
- VOID sysSerialHwReset (void)
- {
- int iCount; /*index counter */
- for (iCount = 0; iCount < N_UART_CHANNELS; iCount++)
- ns16550DevInit (&ns16550Chan[iCount]);
- }
- /******************************************************************************
- *
- * 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 /* serial channel */
- )
- {
- if (channel < 0 || channel >= NELEMENTS(ns16550Chan))
- return (SIO_CHAN *)ERROR;
- return ((SIO_CHAN *) &ns16550Chan[channel]);
- }