📄 sysserial.c
字号:
/* sysSerial.c - BSP serial device initialization *//* Copyright 1984-2002 Wind River Systems, Inc. *//*modification history--------------------01d,21apr02,gtf Modified for sbc7410 bsp.01c,09nov01,g_h Remove include "wrPpmc74xx.h"01b,23oct01,g_h Cleaning for T2.2 01a,17nov98,est adopted from sysSerial Template */#include "vxWorks.h"#include "iv.h"#include "intLib.h"#include "config.h"#include "sysLib.h"#include "drv/sio/ns16552Sio.h"#include "sysGt64260IntrCtl.h"/* defines */#define UART_REG(reg,chan) \ (devParas[chan].baseAdrs + (reg*devParas[chan].regSpace))/* typedefs *//* device initialization structure */typedef struct { USHORT vector; /* Interrupt vector */ ULONG baseAdrs; /* Register base address */ USHORT regSpace; /* Address Interval */ USHORT intLevel; /* Interrupt level */ } NS16550_CHAN_PARAS;/* locals *//* Local data structures */LOCAL NS16550_CHAN ns16550Chan[N_UART_CHANNELS];LOCAL NS16550_CHAN_PARAS devParas[] = { { COM1_INT_VEC, COM1_BASE_ADR, UART_REG_ADDR_INTERVAL, COM1_INT_LVL}};/***************************************************************************** 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** SEE ALSO: sysHwInit()*/void sysSerialHwInit ( void ) { int i; UINT32 temp ; for ( i = 0; i < N_UART_CHANNELS; i++ ) { sysGt64260MuxedIntDisable(GPP_INT_TYPE, 4); /* pin 4 */ ns16550Chan[i].regs = (UINT8*)devParas[i].baseAdrs; ns16550Chan[i].level = devParas[i].vector; ns16550Chan[i].ier = 0; ns16550Chan[i].lcr = 0; ns16550Chan[i].pad1 = 0; ns16550Chan[i].channelMode = 0; ns16550Chan[i].regDelta = devParas[i].regSpace; ns16550Chan[i].baudRate = CONSOLE_BAUD_RATE; ns16550Chan[i].xtal = UART_XTAL_FREQ; ns16550DevInit (&ns16550Chan[i]); /* setup modem control lines */ *((UINT8*)UART_REG(MCR,i)) = (UINT8)0x8 ; EIEIO; } /* NOTE: only 1 UART channel on wrSbc7410. */ /* setup mpp4/gpp4 register for uart int */ GT64260_REG_RD(MPP_CTRL0, &temp); /* GPP[4] */ temp &= ~0x000f0000 ; GT64260_REG_WR(MPP_CTRL0, temp); /* setup gpp port */ GT64260_REG_RD(GPP_INT_MASK, &temp); /* pin 4, int masked */ temp &= ~0x00000010 ; GT64260_REG_WR(GPP_INT_MASK, temp); GT64260_REG_RD(GPP_INT_CAUSE, &temp); /* pin 4, int cleared */ temp &= ~0x00000010 ; GT64260_REG_WR(GPP_INT_CAUSE, temp); GT64260_REG_RD(GPP_IO_CTRL, &temp); /* pin 4, input */ temp &= ~0x00000010 ; GT64260_REG_WR(GPP_IO_CTRL, temp); GT64260_REG_RD(GPP_LVL_CTRL, &temp); /* pin 4, active high per schematic */ temp &= ~0x00000010 ; GT64260_REG_WR(GPP_LVL_CTRL, temp); return; }/***************************************************************************** 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** SEE ALSO: sysHwInit2()*/void sysSerialHwInit2 ( void ) { int i; /* connect serial interrupts */ for ( i = 0; i < N_UART_CHANNELS; i++ ) { if ( ns16550Chan[i].level ) { intConnect (INUM_TO_IVEC ((int ) ns16550Chan[i].level), ns16550Int, (int)&ns16550Chan[i] ); sysGt64260MuxedIntEnable(GPP_INT_TYPE, 4); /* pin 4 */ } } return; }/******************************************************************************** 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 i; for ( i = 0; i < N_UART_CHANNELS; i++ ) ns16550DevInit (&ns16550Chan[i]); return; }/******************************************************************************** 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 ) { if ( (channel < 0) || (channel >= NELEMENTS(ns16550Chan)) ) return((SIO_CHAN *)ERROR); return((SIO_CHAN *) &ns16550Chan[channel]); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -