📄 sysserial16550.c
字号:
/* sysSerial.c - cetCvme603/4 BSP serial device initialization *//* Copyright 1984-1997 Wind River Systems, Inc. */#include "copyright_wrs.h"/* 注意:可能要把sysSerialHwInit (2)移到usrSerial.c中一块执行。*//*modification history--------------------01g,12may97,dmb Changed 'static' to LOCAL. Added returns.01f,12dec96,tpr removed intEnable() prototype. Now defined in intLib.h.01e,04nov96,dat chg'd EIEIO() to EIEIO for compatibility01d,21aug96,dat added init of Modem Ctrl Reg to 0x8.01c,06jun96,dmb moved to 16550 support instead of 825001b,07mar96,dmb replaced sysIntEnablePIC() with intEnable().01a,28nov95,tpr written based on ev386ex/sysSerial.c 01e version.*/#include "vxWorks.h"#include "iv.h"#include "intLib.h"#include "config.h"#include "sysLib.h"#include "drv/sio/ns16552Sio.h"/* 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;#ifdef INCLUDE_PC_CONSOLE /* if key board and VGA console needed */#include "serial/pcConsole.c"#include "serial/m6845Vga.c"#if (PC_KBD_TYPE == PC_PS2_101_KBD) /* 101 KEY PS/2 */#include "serial/i8042Kbd.c"#else#include "serial/i8048Kbd.c" /* 83 KEY PC/PCXT/PORTABLE */#endif /* (PC_KBD_TYPE == PC_XT_83_KBD) */#endif /* INCLUDE_PC_CONSOLE *//* 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}, {COM2_INT_VEC, COM2_BASE_ADR, UART_REG_ADDR_INTERVAL, COM2_INT_LVL} };#define UART_REG(reg,chan) \ (devParas[chan].baseAdrs + reg * devParas[chan].regSpace)/******************************************************************************** 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 i; for (i = 0; i < N_UART_CHANNELS; i++) { sysIntDisablePIC (devParas[i].intLevel); /*使中断不能*/ 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; /* such as INT, POLL modes */ ns16550Chan[i].regDelta = devParas[i].regSpace; /* register address spacing */ ns16550Chan[i].baudRate = 9600; ns16550Chan[i].xtal = 1843200; /* UART clock frequency */ ns16550DevInit (&ns16550Chan[i]); /*intialize an NS16550 channel */ /* setup modem control lines */ *(UCHAR *)UART_REG(MCR,i) = 0x8;/* EIEIO;*//*2002-12-6 9:51;3g;donleo ;not defined*/ } 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*/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] ); sysIntEnablePIC (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 /* serial 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 + -