📄 sysserial.c
字号:
/* sysSerial.c - BSP serial device initialization *//* Copyright 1984-2001 Wind River Systems, Inc. *//*modification history--------------------01d,26apr02,gjc Fixing FP register SPR #75385 #7533301c,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 "ns16552Sio.h"#include "ns16550Sio.c" /* 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; for (i = 0; i < N_UART_CHANNELS; i++) { intDisable (devParas[i].intLevel); ns16550Chan[i].regs = (UX50 *)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 = DEFAULT_BAUD_RATE; ns16550Chan[i].xtal = UART_XTAL_FREQ; ns16550DevInit (&ns16550Chan[i]); /* setup modem control lines */ ns16550Chan[i].regs->MCR = 0x08; EIEIO; } 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] ); intEnable (devParas[i].intLevel); } } 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 + -