📄 sysserial.c
字号:
/* sysSerial.c - BSP serial device initialization */
/* Copyright 1984-2001 Wind River Systems, Inc. */
#include "copyright_wrs.h"
/*
modification history
--------------------
01c,17jul01,g_h changed to use the dynamic DPRAM memory allocation
01b,26apr99,elk added SMC2.
01a,05mar99,elk adopted from sysSerial/estMDP8xx (ver 01a).
*/
#include "vxWorks.h"
#include "intLib.h"
#include "config.h"
#include "sysLib.h"
#include "sys82xxDpramLib.h"
#include "smc8260Sio.h"
/* Chuck (PTR Group) Added: */
#include "sc28l198.h"
#include "m8260Brg.h"
#include "m8260IOPort.h"
/* Defines */
#if !defined(M8260_CMXSCR)
#define M8260_CMXSCR(base) (CAST(VUINT32 *)((base) + 0x11B08))
#endif
/* Global data */
#define N_SMC_SIO_CHANNELS 1
static PPC8260SMC_CHAN ppcSMCChn[N_SMC_SIO_CHANNELS] ;
/* External References */
IMPORT int sysBaudClkFreq(void);
/******************************************************************************
*
* 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;
UINT32 dpram1_base;
UINT32 allocatedAdrs;
for (i = 0; i < N_SMC_SIO_CHANNELS; i++)
{
/*
* intialize the chips device descriptors.
*/
ppcSMCChn[i].regBase = vxImmrGet() ; /* IMMR reg has base adr */
ppcSMCChn[i].clockRate = sysBaudClkFreq(); /* Baud clock freq (Hz) */
/* Chuck (PTR Group) changed SMC BRG from (1+i) to (7+1) */
/* so SCC's can use BRG1-4. */
ppcSMCChn[i].bgrNum = 7 + i ; /* use BRGx */
ppcSMCChn[i].uart.smcNum = 1 + i ; /* SMCx wired for rs232 */
ppcSMCChn[i].uart.txBdNum = 1 ; /* use 1 transmit BD */
ppcSMCChn[i].uart.rxBdNum = 0x10 ; /* use 16 receive BD */
/* transmit BD base adrs */
if((allocatedAdrs = (0x0000ffff & (UINT32)sys82xxDpramAlignedMalloc(8,8))) != NULL)
ppcSMCChn[i].uart.txBdBase = (SMC_BUF *) allocatedAdrs;
else
{
sysToMonitor (BOOT_NO_AUTOBOOT);
}
/* receive BD base adrs */
if((allocatedAdrs = (0x0000ffff & (UINT32)sys82xxDpramAlignedMalloc(128,8))) != NULL)
ppcSMCChn[i].uart.rxBdBase = (SMC_BUF *) allocatedAdrs;
else
{
sysToMonitor (BOOT_NO_AUTOBOOT);
}
ppcSMCChn[i].uart.txBufSize = 0x1 ; /* transmit buffer size */
dpram1_base = MPC8260_DPRAM1_BASE( ppcSMCChn[i].regBase );
if((allocatedAdrs = (UINT32)sys82xxDpramAlignedMalloc(0x80,2)) != NULL)
ppcSMCChn[i].uart.txBufBase = (u_char *) allocatedAdrs;
else
{
sysToMonitor (BOOT_NO_AUTOBOOT);
}
if((allocatedAdrs = (UINT32)sys82xxDpramAlignedMalloc(0x80,2)) != NULL)
ppcSMCChn[i].uart.rxBufBase = (u_char *)allocatedAdrs;
else
{
sysToMonitor (BOOT_NO_AUTOBOOT);
}
if((allocatedAdrs = (0x0000ffff & (UINT32)sys82xxDpramAlignedMalloc(0x34,64))) != NULL)
*PPC8260_DPR_SMC1(dpram1_base + (0x100 * i)) = allocatedAdrs;
else
{
sysToMonitor (BOOT_NO_AUTOBOOT);
}
/* DPRAM address of SMCx parameter RAM. */
ppcSMCChn[i].uart.pSmc = (SMC *) ( (UINT32)
(*PPC8260_DPR_SMC1(dpram1_base + (0x100 * i)) + ppcSMCChn[i].regBase) );
/*
* SMCMR1 for SMC1.
*/
ppcSMCChn[i].uart.pSmcReg =
(SMC_REG *) ( (UINT32) SMCMR1( ppcSMCChn[i].regBase + (0x10 * i)) ) ;
ppcSMCChn[i].pBaud = (VINT32*)(ppcSMCChn[i].regBase +
M8260_BRGC_N_BASE(ppcSMCChn[i].bgrNum));
ppcSMCChn[i].channelMode = 0;
/*
* reset the device.
*/
smc8260DevInit( &ppcSMCChn[i] ) ;
}
}
/******************************************************************************
*
* 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 )
{
UINT32 immrVal = vxImmrGet();
int i;
for (i = 0; i < N_SMC_SIO_CHANNELS; i++)
{
/* */
/* Connect SMC serial interrupts */
/* */
*SMCE1( immrVal + (0x10 * i) ) = *SMCE1( immrVal + (0x10 * i) ) ;
(void) intConnect( INUM_TO_IVEC(4 + (1 * i)),
(VOIDFUNCPTR) smc8260Int, (int) &ppcSMCChn[i] ) ;
/*
* Enable SMCi interrupts.
*/
*M8260_SIMR_L( immrVal ) |= (0x00001000 >> i);
}
}
/* Chuck (PTR Group) Added: */
void sysSerialSC28L198DrvInit(void)
{
/* Initialize the SC28L198 Octarts.
*/
sc28l198Drv();
}
/* Chuck (PTR Group) Added: */
void sysSerialSC28L198CreateDevs(int boardID)
{
int chan;
int numChans;
char chanName[20];
/* Create all of the SC28L198 channels.
*/
if (boardID == 2) /* Note ID 2 == SBC3 */
{
numChans = SC28L198_NUM_CHANNELS_SBC3;
}
else
{
numChans = SC28L198_NUM_CHANNELS_SBC4;
}
for(chan=0; chan<numChans; chan++)
{
sprintf(chanName,"/sio/%d",chan);
if( sc28l198DevCreate(chanName, chan, 9600, 8, 1, "NONE")==ERROR )
{
logMsg("Error opening SC28L198 channel %d\n",chan,0,0,0,0,0);
}
/* Give logMsg() a chance to output */
taskDelay(sysClkRateGet()/10);
}
}
/******************************************************************************
*
* 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 - [0, 1] */
)
{
/* */
/* Check the parameters for validity. */
/* */
if ( channel >= N_SMC_SIO_CHANNELS )
{
return( (SIO_CHAN *) ERROR ) ;
}
/* */
/* Return a pointer to the private space (NOTE SMC ONLY). */
/* */
return( (SIO_CHAN *) &ppcSMCChn[channel] ) ;
}
/*******************************************************************************
*
* 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 + -