www.pudn.com > nxplpc2204bsp.rar > sysSerial.c


/* sysSerial.c - Samsung SBC ARM7 serial device initialization */ 
 
/* Copyright 1984-2001 Wind River Systems, Inc. */ 
#include "copyright_wrs.h" 
 
#include "vxWorks.h" 
#include "iv.h" 
#include "intLib.h" 
#include "config.h" 
#include "sysLib.h" 
#include "lpc2210Sio.h" 
 
#include "wrSbcArm7.h" 
 
#include "lpc2210Sio.c" 
 
/* device initialization structure */ 
 
typedef struct 
{ 
    UINT  intLevel; 
    UINT32 *baseAdrs; 
    UINT  regSpace; 
} SBCARM7_CHAN_PARAS; 
 
 
/* Local data structures */ 
 
LOCAL SBCARM7_CHAN_PARAS devParas[] = 
{ 
    {INT_LVL_UART0, (UINT32 *)SERIAL_0_BASE_ADR} 
}; 
  
LOCAL LPC2210_CHAN lpc2210Chan[N_SBCARM7_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 [] = 
{ 
    &lpc2210Chan[0].sio, /* /tyCo/0 */ 
}; 
 
 
/* forward declarations */ 
 
/****************************************************************************** 
* 
* 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; 
 
    for (i = 0; i < N_SBCARM7_UART_CHANNELS; i++) 
    { 
        lpc2210Chan[i].regs = devParas[i].baseAdrs; 
        lpc2210Chan[i].baudRate = CONSOLE_BAUD_RATE; 
        lpc2210Chan[i].intLevel = devParas[i].intLevel; 
 
        /* 
         * Initialize driver functions, getTxChar, putRcvChar and channelMode 
         * and initialize UART 
         */ 
 
        lpc2210DevInit(&lpc2210Chan[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() may call malloc().  
*  
* RETURNS: N/A  
* 
* SEE ALSO: sysHwInit2() 
*/ 
 
void sysSerialHwInit2 (void) 
{ 
    int i; 
 
    for (i = 0; i < N_SBCARM7_UART_CHANNELS; i++) 
    { 
        /* 
         * Connect and enable the interrupt. 
         * We would like to check the return value from this and log a message 
         * if it failed. However, logLib has not been initialized yet, so we 
         * cannot log a message, so there's little point in checking it. 
         */ 
 
        (void) intConnect (INUM_TO_IVEC(lpc2210Chan[i].intLevel), 
                           lpc2210UARTInt, (int)&lpc2210Chan[i] ); 
 
        lpc2210DevInit2(&lpc2210Chan[i]); 
    } 
} 
 
/****************************************************************************** 
* 
* 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 to the bootroms. 
* 
* RETURNS: N/A. 
*/ 
 
void sysSerialReset (void) 
{ 
    int i; 
 
    for (i = 0; i < N_SBCARM7_UART_CHANNELS; i++) 
    { 
        /* disable serial interrupts */ 
        intDisable (devParas[i].intLevel); 
    } 
}