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

📄 sysserial.c

📁 Tornado的源代码资源包
💻 C
字号:
/* sysSerial.c - serial device initialisation */

/* Copyright 1999 ARM Limited */

/*
modification history
--------------------
01b,15jul99,jpd  minor comments changes.
01a,25jun99,jpd  created.
*/


/* includes */

#include "vxWorks.h"
#include "iv.h"
#include "intLib.h"
#include "config.h"
#include "sysLib.h"
#include "s3c2410Sio.h"

#include "s3c2410Sio.c"



extern void ASM_s2410SioInt();
extern STATUS S2410_intConnect();
#ifdef INCLUDE_SERIAL

/* device initialisation structure */

typedef struct
    {
    UINT	vector;
    UINT32 *	baseAdrs;
    UINT	intLevel;
    } S2410_CHAN_PARAS;


/* Local data structures */

LOCAL S2410_CHAN_PARAS devParas[] =
    {
	{INT_LVL_UART0,(UINT32 *)aULCON0, INT_LVL_UART0 },
	{INT_LVL_UART1,(UINT32 *)aULCON1, INT_LVL_UART1 }
    };

 S2410_SIO_CHAN s2410SioChan[N_2410BP_UART_CHANNELS];

/*
 * Array of pointers to all serial channels configured in system.
 * See sioChanGet(). It is this array that maps channel pointers
 * to standard device names.  The first entry will become "/tyCo/0",
 * the second "/tyCo/1", and so forth.
 */

SIO_CHAN * sysSioChans [] =
    {
    &s2410SioChan[0].sio	/* /tyCo/0 */

    };

/******************************************************************************
*
* sysSerialHwInit - initialise the BSP serial devices to a quiescent state
*
* This routine initialises the BSP serial device descriptors and puts the
* devices in a quiescent 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_2410BP_UART_CHANNELS; i++)
	{
	s2410SioChan[i].regs = devParas[i].baseAdrs;
	s2410SioChan[i].baudRate = CONSOLE_BAUD_RATE;
	s2410SioChan[i].xtal = UART_XTAL_FREQ;   /*UART所使用的源时钟频率PCLK = 202.8/4MHz*/
	s2410SioChan[i].level = devParas[i].intLevel;
	
	/*
	 * Initialise driver functions, getTxChar, putRcvChar and channelMode
	 * and otherwise initialise UART
	 */
	s2410SioDevInit(&s2410SioChan[i]);
	}
    }

/******************************************************************************
*
* sysSerialHwInit2 - connect BSP serial device interrupts
*
* This routine connects the BSP serial device interrupts.  It is called from
* sysHwInit2().  Serial device interrupts cannot be connected in
* sysSerialHwInit() because the kernel memory allocator was not
* initialised at that point, and intConnect() may call malloc().
*
* RETURNS: N/A
*
* SEE ALSO: sysHwInit2()
*/

void sysSerialHwInit2 (void)
    {
    int i;
    
    for (i = 0; i < N_2410BP_UART_CHANNELS; i++)
	{
	/*
	 * We would like to check the return value from this and log a message
	 * if it failed. However, logLib has not been initialised yet, so we
	 * cannot log a message, so there's little point in checking it.
	 */

	/* connect interrupts */

	(void) intConnect (INUM_TO_IVEC(devParas[i].vector),s2410SioInt,0);

	}

    }

/******************************************************************************
*
* sysSerialChanGet - get the SIO_CHAN device associated with a serial channel
*
* This routine returns a pointer to the SIO_CHAN device associated
* with a specified serial channel.  It is called by usrRoot() to obtain
* pointers when creating the system serial devices, `/tyCo/x'.  It
* is also used by the WDB agent to locate its 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 >= (int) (NELEMENTS(sysSioChans)) )
	return (SIO_CHAN *) ERROR;

    return sysSioChans[channel];
    }

/******************************************************************************
*
* sysSerialReset - reset the sio devices to a quiet state
*
* Reset all devices to prevent them from generating interrupts.
*
* This is called from sysToMonitor() to shutdown the system gracefully
* before transferring control to the boot ROM.
*
* RETURNS: N/A.
*/

void sysSerialReset (void)
    {
    int i;

    for (i = 0; i < N_2410BP_UART_CHANNELS; i++)
	{
	/* disable interrupts */
	intDisable (devParas[i].intLevel);
	}

    return;
    }
#endif /* INCLUDE_SERIAL */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -