⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sysserial.c

📁 wind river提供的MPC8260的BSP典型代码
💻 C
字号:
/* sysSerial.c - BSP serial device initialization *//* Copyright 1984-2001 Wind River Systems, Inc. *//*modification history--------------------01c,17jul01,g_h  changed to use the dynamic DPRAM memory allocation01b,26apr99,elk  added SMC2.01a,05mar99,elk  adopted from sysSerial/estMDP8xx (ver 01a).*/#include "vxWorks.h"#include "iv.h"#include "intLib.h"#include "config.h"#include "sysLib.h"#include "drv/mem/m82xxDpramLib.h"#include "smc8260Sio.h"#include "drv/sio/m8260Cp.h"#include "drv/sio/m8260CpmMux.h"#include "drv/mem/m8260Siu.h"#include "drv/intrCtl/m8260IntrCtl.h"#include "smc8260Sio.c"/* Global data    */static PPC8260SMC_CHAN ppcChn[N_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** SEE ALSO: sysHwInit()*/ void sysSerialHwInit    (     void     )    {    int    i;    UINT32 dpram1Base;    UINT32 allocatedAdrs;    for (i = 0; i < N_SIO_CHANNELS; i++)         {         /*          * intialize the chips device descriptors.          */         ppcChn[i].regBase        = vxImmrGet ()       ; /* IMMR reg has base adr */         ppcChn[i].clockRate      = sysBaudClkFreq ()  ; /* Baud clock freq (Hz)  */         ppcChn[i].bgrNum         = 1 + i              ; /* use BRGx              */         ppcChn[i].uart.smcNum    = 1 + i              ; /* SMCx wired for rs232  */         ppcChn[i].uart.txBdNum   = 1                  ; /* use 1 transmit BD     */         ppcChn[i].uart.rxBdNum   = 0x10               ; /* use 16 receive BD     */         /* transmit BD base adrs */	 if ((allocatedAdrs = (0x0000ffff & (UINT32)m82xxDpramAlignedMalloc (8,8))) != 0)	      ppcChn[i].uart.txBdBase  = (SMC_BUF *) allocatedAdrs;	 else	     {	     sysToMonitor (BOOT_NO_AUTOBOOT);	     }         /* receive BD base adrs  */         if ((allocatedAdrs = (0x0000ffff & (UINT32)m82xxDpramAlignedMalloc (128,8))) != 0)	     ppcChn[i].uart.rxBdBase  = (SMC_BUF *) allocatedAdrs;         else	     {	     sysToMonitor (BOOT_NO_AUTOBOOT);             }         ppcChn[i].uart.txBufSize = 0x1                ; /* transmit buffer size  */         dpram1Base = MPC8260_DPRAM1_BASE( ppcChn[i].regBase );         if ((allocatedAdrs = (UINT32)m82xxDpramAlignedMalloc (0x80,2)) != 0)	     ppcChn[i].uart.txBufBase = (u_char *) allocatedAdrs;	else            {	    sysToMonitor (BOOT_NO_AUTOBOOT);	    }	if ((allocatedAdrs = (UINT32)m82xxDpramAlignedMalloc (0x80,2)) != 0)	    ppcChn[i].uart.rxBufBase = (u_char *)allocatedAdrs;	else	    {	    sysToMonitor (BOOT_NO_AUTOBOOT);	    }	if ((allocatedAdrs = (0x0000ffff & (UINT32)m82xxDpramAlignedMalloc (0x34,64))) != 0)            *PPC8260_DPR_SMC1(dpram1Base + (0x100 * i)) = allocatedAdrs;	else	    {	    sysToMonitor (BOOT_NO_AUTOBOOT);	    }          /* DPRAM address of SMCx parameter RAM. */        ppcChn[i].uart.pSmc = (SMC *) ( (UINT32)        (*PPC8260_DPR_SMC1(dpram1Base + (0x100 * i)) + ppcChn[i].regBase) );                                                          /*         * SMCMR1 for SMC1.         */        ppcChn[i].uart.pSmcReg =         (SMC_REG *) ( (UINT32) SMCMR1( ppcChn[i].regBase + (0x10 * i)) ) ;        ppcChn[i].pBaud = (VINT32 *) BRGC1(ppcChn[i].regBase + (0x4 * i)) ;        ppcChn[i].channelMode = 0                                       ;        /*         * reset the device.         */        smc8260DevInit ( &ppcChn[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** SEE ALSO: sysHwInit2()*/ void sysSerialHwInit2    (     void     )    {    UINT32 immrVal = vxImmrGet ();    int i;    for (i = 0; i < N_SIO_CHANNELS; i++)        {        /* Connect serial interrupts */        *SMCE1( immrVal + (0x10 * i) ) = *SMCE1( immrVal + (0x10 * i) ) ;        (void) intConnect ( INUM_TO_IVEC(4 + (1 * i)), (VOIDFUNCPTR) smc8260Int, (int) &ppcChn[i] ) ;        /*         * Enable SMCi interrupts.         */        *M8260_SIMR_L( immrVal ) |= (0x00001000 >> i);        }     }/******************************************************************************** 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_SIO_CHANNELS )        {	return( (SIO_CHAN *) ERROR ) ;        }    /*                                                                      */    /* Return a pointer to the private space.                               */    /*                                                                      */    return( (SIO_CHAN *) &ppcChn[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 + -