📄 sysserial.c
字号:
/* sysSerial.c - MPC860 SMC UART BSP serial device initialization */
/* Copyright 1984-1996 Wind River Systems, Inc. */
#include "copyright_wrs.h"
/*
modification history
--------------------
01d,06nov96,tpr replaced SYS_CPU_FREQ by BRGCLK_FREQ.
01c,20jun96,tpr added sysSerialReset().
01b,28may96,dzb tweaked setting of portB registers.
01a,19apr86,cah created
*/
#include "vxWorks.h"
#include "iv.h"
#include "intLib.h"
#include "config.h"
#include "sysLib.h"
#include "drv/sio/ppc860Sio.h"
#include "drv/multi/ppc860Cpm.h"
#include "860pc.h"
static PPC860SMC_CHAN ppc860Chan;
/******************************************************************************
*
* 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.
*
* Data Parameter Ram layout:
*
* -----------------------------
* | | DPRAM base (address = 0)
* | |
* | |
* | |
* |---------------------------|
* | 8 bytes per descriptor | Tx(SMC) Buffer Descriptor (0x2200)
* |---------------------------|
* | |
* |---------------------------|
* | 16 descriptors @ | Rx(SMC) Buffer Descriptors (0x2210)
* | 8 bytes per descriptor |
* | |
* |---------------------------| end Rx(SMC) BDs (0x2290)
* | |
* |---------------------------|
* | 80 bytes allowed | Tx(SMC) Buffer (0x2300 + DPRAM base address)
* |---------------------------|
* | one receive char/buffer | Rx(SMC) Buffer (0x2380 + DPRAM base address)
* |---------------------------|
* | |
* |---------------------------|
* | 8 bytes per descriptor | Tx(SCC) Buffer Descriptor (0x2400)
* |---------------------------|
* | |
* |---------------------------|
* | 16 descriptors @ | Rx(SCC) Buffer Descriptors (0x2410)
* | 8 bytes per descriptor |
* | |
* |---------------------------| end Rx(SCC) BDs (0x2490)
* | |
* |---------------------------|
* | 80 bytes allowed | Tx(SCC) Buffer (0x2500 + DPRAM base address)
* |---------------------------|
* | one receive char/buffer | Rx(SCC) Buffer (0x2580 + DPRAM base address)
* |---------------------------|
* | |
* |---------------------------|
* | 128 bytes of parameter | SCC1 Parameter Area(0x1c00)
* | info |
* |---------------------------|
* | |
* |---------------------------|
* | 128 bytes of parameter | SCC2 Parameter Area(0x1d00)
* | info |
* |---------------------------|
* | |
* |---------------------------|
* | 128 bytes of parameter | SCC3 Parameter Area(0x1e00)
* | info |
* |---------------------------|
* | 34 bytes of parameter info| SMC1 Parameter Area (0x1e80)
* | including Rx and Tx BD |
* | pointers, func codes |
* | etc... |
* |---------------------------|
* | |
* |---------------------------|
* | 128 bytes of parameter | SCC4 Parameter Area(0x1f00)
* | info |
* |---------------------------|
* | |
*
*
* RETURNS: N/A
*/
void sysSerialHwInit (void)
{
/* enable serial I/O on the board */
/* XXX here was BSCR setup !!! */
/* intialize the chips device(SMC UART) descriptors */
ppc860Chan.clockRate = BRGCLK_FREQ; /* BRGCLK freq (Hz) */
ppc860Chan.regBase = vxImmrGet(); /* IMMR reg has base adr */
ppc860Chan.bgrNum = 1; /* use BRG1 */
ppc860Chan.uart.smcNum = 1; /* SMC1 wired for rs232 */
ppc860Chan.uart.txBdNum = 1; /* use 1 transmit BD */
ppc860Chan.uart.rxBdNum = 0x10; /* use 16 receive BD */
ppc860Chan.uart.txBdBase = (SMC_BUF *) 0x2200; /* transmit BD base adrs */
ppc860Chan.uart.rxBdBase = (SMC_BUF *) 0x2210; /* receive BD base adrs */
ppc860Chan.uart.txBufBase = (u_char *)
(MPC860_DPRAM_BASE(ppc860Chan.regBase) + 0x300);
/* tx buf base */
ppc860Chan.uart.rxBufBase = (u_char *)
(MPC860_DPRAM_BASE(ppc860Chan.regBase) + 0x380);
/* rx buf base */
ppc860Chan.uart.txBufSize = 0x1; /* transmit buffer size */
ppc860Chan.uart.pSmc = (SMC *) ((UINT32)
PPC860_DPR_SMC1( MPC860_DPRAM_BASE(ppc860Chan.regBase) ));
/* DPRAM addr of SMC1 params */
ppc860Chan.uart.pSmcReg =
(SMC_REG *) ((UINT32) MPC860_SMCMR1(ppc860Chan.regBase));
/* SMCMR1 for SMC1 */
ppc860Chan.pBaud = (UINT32 *) MPC860_BRGC1(ppc860Chan.regBase);
ppc860Chan.channelMode = 0;
*MPC860_PBPAR(ppc860Chan.regBase) = 0xC0; /* select RS232 pins */
*MPC860_SDCR(ppc860Chan.regBase) = 1; /* */
/* reset the chip */
ppc860DevInit(&ppc860Chan);
}
/******************************************************************************
*
* 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)
{
/* connect serial interrupts */
(void) intConnect (IV_SMC1, (VOIDFUNCPTR) ppc860Int, (int) &ppc860Chan);
*CIMR(vxImmrGet()) |= CIMR_SMC1; /* limited to SMC1 */
}
/******************************************************************************
*
* 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)
return ((SIO_CHAN *) &ppc860Chan);
else
return ((SIO_CHAN *) ERROR);
}
/*******************************************************************************
*
* sysSerialReset - reset the serail device
*
* This function calls sysSerialHwInit() to reset the serail device
*
* RETURNS: N/A
*
*/
void sysSerialReset (void)
{
sysSerialHwInit ();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -