quicc_smc_serial.c

来自「eCos操作系统源码」· C语言 代码 · 共 1,104 行 · 第 1/4 页

C
1,104
字号
//==========================================================================////      io/serial/powerpc/quicc_smc_serial.c////      PowerPC QUICC (SMC/SCC) Serial I/O Interface Module (interrupt driven)////==========================================================================//####ECOSGPLCOPYRIGHTBEGIN####// -------------------------------------------// This file is part of eCos, the Embedded Configurable Operating System.// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.// Copyright (C) 2003 Gary Thomas//// eCos is free software; you can redistribute it and/or modify it under// the terms of the GNU General Public License as published by the Free// Software Foundation; either version 2 or (at your option) any later version.//// eCos is distributed in the hope that it will be useful, but WITHOUT ANY// WARRANTY; without even the implied warranty of MERCHANTABILITY or// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License// for more details.//// You should have received a copy of the GNU General Public License along// with eCos; if not, write to the Free Software Foundation, Inc.,// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.//// As a special exception, if other files instantiate templates or use macros// or inline functions from this file, or you compile this file and link it// with other works to produce a work based on this file, this file does not// by itself cause the resulting work to be covered by the GNU General Public// License. However the source code for this file must still be made available// in accordance with section (3) of the GNU General Public License.//// This exception does not invalidate any other reasons why a work based on// this file might be covered by the GNU General Public License.//// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.// at http://sources.redhat.com/ecos/ecos-license/// -------------------------------------------//####ECOSGPLCOPYRIGHTEND####//==========================================================================//#####DESCRIPTIONBEGIN####//// Author(s):    gthomas// Contributors: gthomas// Date:         1999-06-20// Purpose:      QUICC SMC Serial I/O module (interrupt driven version)// Description: ////####DESCRIPTIONEND####////==========================================================================#include <pkgconf/system.h>#include <pkgconf/io_serial.h>#include <pkgconf/io.h>#include <cyg/io/io.h>#include <cyg/hal/hal_intr.h>#include <cyg/io/devtab.h>#include <cyg/io/serial.h>#include <cyg/infra/diag.h>#include <cyg/hal/hal_cache.h>#include <cyg/hal/quicc/ppc8xx.h>#include CYGBLD_HAL_PLATFORM_H#ifdef CYGPKG_IO_SERIAL_POWERPC_QUICC_SMC#include "quicc_smc_serial.h"typedef struct quicc_sxx_serial_info {    CYG_ADDRWORD          channel;                   // Which channel SMCx/SCCx    short                 int_num;                   // Interrupt number    short                 type;                      // Channel type - SCC or SMC    unsigned long         *brg;                      // Which baud rate generator    void                  *pram;                     // Parameter RAM pointer    void                  *ctl;                      // SMC/SCC control registers    volatile struct cp_bufdesc     *txbd, *rxbd;     // Next Tx,Rx descriptor to use    struct cp_bufdesc     *tbase, *rbase;            // First Tx,Rx descriptor    int                   txsize, rxsize;            // Length of individual buffers    cyg_interrupt         serial_interrupt;    cyg_handle_t          serial_interrupt_handle;} quicc_sxx_serial_info;static bool quicc_sxx_serial_init(struct cyg_devtab_entry *tab);static bool quicc_sxx_serial_putc(serial_channel *chan, unsigned char c);static Cyg_ErrNo quicc_sxx_serial_lookup(struct cyg_devtab_entry **tab,                                    struct cyg_devtab_entry *sub_tab,                                   const char *name);static unsigned char quicc_sxx_serial_getc(serial_channel *chan);static Cyg_ErrNo quicc_sxx_serial_set_config(serial_channel *chan,                                             cyg_uint32 key, const void *xbuf,                                             cyg_uint32 *len);static void quicc_sxx_serial_start_xmit(serial_channel *chan);static void quicc_sxx_serial_stop_xmit(serial_channel *chan);static cyg_uint32 quicc_sxx_serial_ISR(cyg_vector_t vector, cyg_addrword_t data);static void       quicc_sxx_serial_DSR(cyg_vector_t vector, cyg_ucount32 count, cyg_addrword_t data);static SERIAL_FUNS(quicc_sxx_serial_funs,                    quicc_sxx_serial_putc,                    quicc_sxx_serial_getc,                   quicc_sxx_serial_set_config,                   quicc_sxx_serial_start_xmit,                   quicc_sxx_serial_stop_xmit    );#ifdef CYGPKG_IO_SERIAL_POWERPC_QUICC_SMC_SMC1static quicc_sxx_serial_info quicc_sxx_serial_info_smc1 = {    QUICC_CPM_SMC1,                 // Channel indicator    CYGNUM_HAL_INTERRUPT_CPM_SMC1,  // interrupt    _SMC_CHAN};#if CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SMC1_BUFSIZE > 0static unsigned char quicc_smc_serial_out_buf_smc1[CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SMC1_BUFSIZE];static unsigned char quicc_smc_serial_in_buf_smc1[CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SMC1_BUFSIZE];static SERIAL_CHANNEL_USING_INTERRUPTS(quicc_sxx_serial_channel_smc1,                                       quicc_sxx_serial_funs,                                        quicc_sxx_serial_info_smc1,                                       CYG_SERIAL_BAUD_RATE(CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SMC1_BAUD),                                       CYG_SERIAL_STOP_DEFAULT,                                       CYG_SERIAL_PARITY_DEFAULT,                                       CYG_SERIAL_WORD_LENGTH_DEFAULT,                                       CYG_SERIAL_FLAGS_DEFAULT,                                       &quicc_smc_serial_out_buf_smc1[0], sizeof(quicc_smc_serial_out_buf_smc1),                                       &quicc_smc_serial_in_buf_smc1[0], sizeof(quicc_smc_serial_in_buf_smc1)    );#elsestatic SERIAL_CHANNEL(quicc_sxx_serial_channel_smc1,                      quicc_sxx_serial_funs,                       quicc_sxx_serial_info_smc1,                      CYG_SERIAL_BAUD_RATE(CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SMC1_BAUD),                      CYG_SERIAL_STOP_DEFAULT,                      CYG_SERIAL_PARITY_DEFAULT,                      CYG_SERIAL_WORD_LENGTH_DEFAULT,                      CYG_SERIAL_FLAGS_DEFAULT    );#endifstatic unsigned char quicc_smc1_txbuf[CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SMC1_TxNUM*CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SMC1_TxSIZE] __attribute__((aligned(HAL_DCACHE_LINE_SIZE)));static unsigned char quicc_smc1_rxbuf[CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SMC1_RxNUM*CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SMC1_RxSIZE] __attribute__((aligned(HAL_DCACHE_LINE_SIZE)));DEVTAB_ENTRY(quicc_smc_serial_io_smc1,              CYGDAT_IO_SERIAL_POWERPC_QUICC_SMC_SMC1_NAME,             0,                     // Does not depend on a lower level interface             &cyg_io_serial_devio,              quicc_sxx_serial_init,              quicc_sxx_serial_lookup,     // Serial driver may need initializing             &quicc_sxx_serial_channel_smc1    );#endif //  CYGPKG_IO_SERIAL_POWERPC_QUICC_SMC_SMC1#ifdef CYGPKG_IO_SERIAL_POWERPC_QUICC_SMC_SMC2static quicc_sxx_serial_info quicc_sxx_serial_info_smc2 = {    QUICC_CPM_SMC2,                     // Channel indicator    CYGNUM_HAL_INTERRUPT_CPM_SMC2_PIP,  // interrupt    _SMC_CHAN};#if CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SMC2_BUFSIZE > 0static unsigned char quicc_smc_serial_out_buf_smc2[CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SMC2_BUFSIZE];static unsigned char quicc_smc_serial_in_buf_smc2[CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SMC2_BUFSIZE];static SERIAL_CHANNEL_USING_INTERRUPTS(quicc_sxx_serial_channel_smc2,                                       quicc_sxx_serial_funs,                                        quicc_sxx_serial_info_smc2,                                       CYG_SERIAL_BAUD_RATE(CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SMC2_BAUD),                                       CYG_SERIAL_STOP_DEFAULT,                                       CYG_SERIAL_PARITY_DEFAULT,                                       CYG_SERIAL_WORD_LENGTH_DEFAULT,                                       CYG_SERIAL_FLAGS_DEFAULT,                                       &quicc_smc_serial_out_buf_smc2[0], sizeof(quicc_smc_serial_out_buf_smc2),                                       &quicc_smc_serial_in_buf_smc2[0], sizeof(quicc_smc_serial_in_buf_smc2)    );#elsestatic SERIAL_CHANNEL(quicc_sxx_serial_channel_smc2,                      quicc_sxx_serial_funs,                       quicc_sxx_serial_info_smc2,                      CYG_SERIAL_BAUD_RATE(CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SMC2_BAUD),                      CYG_SERIAL_STOP_DEFAULT,                      CYG_SERIAL_PARITY_DEFAULT,                      CYG_SERIAL_WORD_LENGTH_DEFAULT,                      CYG_SERIAL_FLAGS_DEFAULT    );#endifstatic unsigned char quicc_smc2_txbuf[CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SMC2_TxNUM*CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SMC2_TxSIZE] __attribute__((aligned(HAL_DCACHE_LINE_SIZE)));static unsigned char quicc_smc2_rxbuf[CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SMC2_RxNUM*CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SMC2_RxSIZE] __attribute__((aligned(HAL_DCACHE_LINE_SIZE)));DEVTAB_ENTRY(quicc_smc_serial_io_smc2,              CYGDAT_IO_SERIAL_POWERPC_QUICC_SMC_SMC2_NAME,             0,                     // Does not depend on a lower level interface             &cyg_io_serial_devio,              quicc_sxx_serial_init,              quicc_sxx_serial_lookup,     // Serial driver may need initializing             &quicc_sxx_serial_channel_smc2    );#endif //  CYGPKG_IO_SERIAL_POWERPC_QUICC_SMC_SMC2#ifdef CYGPKG_IO_SERIAL_POWERPC_QUICC_SMC_SCC1static quicc_sxx_serial_info quicc_sxx_serial_info_scc1 = {    QUICC_CPM_SCC1,                     // Channel indicator    CYGNUM_HAL_INTERRUPT_CPM_SCC1,      // interrupt    _SCC_CHAN};#if CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SCC1_BUFSIZE > 0static unsigned char quicc_smc_serial_out_buf_scc1[CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SCC1_BUFSIZE];static unsigned char quicc_smc_serial_in_buf_scc1[CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SCC1_BUFSIZE];static SERIAL_CHANNEL_USING_INTERRUPTS(quicc_sxx_serial_channel_scc1,                                       quicc_sxx_serial_funs,                                        quicc_sxx_serial_info_scc1,                                       CYG_SERIAL_BAUD_RATE(CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SCC1_BAUD),                                       CYG_SERIAL_STOP_DEFAULT,                                       CYG_SERIAL_PARITY_DEFAULT,                                       CYG_SERIAL_WORD_LENGTH_DEFAULT,                                       CYG_SERIAL_FLAGS_DEFAULT,                                       &quicc_smc_serial_out_buf_scc1[0], sizeof(quicc_smc_serial_out_buf_scc1),                                       &quicc_smc_serial_in_buf_scc1[0], sizeof(quicc_smc_serial_in_buf_scc1)    );#elsestatic SERIAL_CHANNEL(quicc_sxx_serial_channel_scc1,                      quicc_sxx_serial_funs,                       quicc_sxx_serial_info_scc1,                      CYG_SERIAL_BAUD_RATE(CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SCC1_BAUD),                      CYG_SERIAL_STOP_DEFAULT,                      CYG_SERIAL_PARITY_DEFAULT,                      CYG_SERIAL_WORD_LENGTH_DEFAULT,                      CYG_SERIAL_FLAGS_DEFAULT    );#endifstatic unsigned char quicc_scc1_txbuf[CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SCC1_TxNUM*CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SCC1_TxSIZE] __attribute__((aligned(HAL_DCACHE_LINE_SIZE)));static unsigned char quicc_scc1_rxbuf[CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SCC1_RxNUM*CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SCC1_RxSIZE] __attribute__((aligned(HAL_DCACHE_LINE_SIZE)));DEVTAB_ENTRY(quicc_smc_serial_io_scc1,              CYGDAT_IO_SERIAL_POWERPC_QUICC_SMC_SCC1_NAME,             0,                     // Does not depend on a lower level interface             &cyg_io_serial_devio,              quicc_sxx_serial_init,              quicc_sxx_serial_lookup,     // Serial driver may need initializing             &quicc_sxx_serial_channel_scc1    );#endif //  CYGPKG_IO_SERIAL_POWERPC_QUICC_SMC_SCC1#ifdef CYGPKG_IO_SERIAL_POWERPC_QUICC_SMC_SCC2static quicc_sxx_serial_info quicc_sxx_serial_info_scc2 = {    QUICC_CPM_SCC2,                     // Channel indicator    CYGNUM_HAL_INTERRUPT_CPM_SCC2,      // interrupt    _SCC_CHAN};#if CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SCC2_BUFSIZE > 0static unsigned char quicc_smc_serial_out_buf_scc2[CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SCC2_BUFSIZE];static unsigned char quicc_smc_serial_in_buf_scc2[CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SCC2_BUFSIZE];static SERIAL_CHANNEL_USING_INTERRUPTS(quicc_sxx_serial_channel_scc2,                                       quicc_sxx_serial_funs,                                        quicc_sxx_serial_info_scc2,                                       CYG_SERIAL_BAUD_RATE(CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SCC2_BAUD),                                       CYG_SERIAL_STOP_DEFAULT,                                       CYG_SERIAL_PARITY_DEFAULT,                                       CYG_SERIAL_WORD_LENGTH_DEFAULT,                                       CYG_SERIAL_FLAGS_DEFAULT,                                       &quicc_smc_serial_out_buf_scc2[0], sizeof(quicc_smc_serial_out_buf_scc2),                                       &quicc_smc_serial_in_buf_scc2[0], sizeof(quicc_smc_serial_in_buf_scc2)    );#elsestatic SERIAL_CHANNEL(quicc_sxx_serial_channel_scc2,                      quicc_sxx_serial_funs,                       quicc_sxx_serial_info_scc2,                      CYG_SERIAL_BAUD_RATE(CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SCC2_BAUD),                      CYG_SERIAL_STOP_DEFAULT,                      CYG_SERIAL_PARITY_DEFAULT,                      CYG_SERIAL_WORD_LENGTH_DEFAULT,                      CYG_SERIAL_FLAGS_DEFAULT    );#endifstatic unsigned char quicc_scc2_txbuf[CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SCC2_TxNUM*CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SCC2_TxSIZE] __attribute__((aligned(HAL_DCACHE_LINE_SIZE)));static unsigned char quicc_scc2_rxbuf[CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SCC2_RxNUM*CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SCC2_RxSIZE] __attribute__((aligned(HAL_DCACHE_LINE_SIZE)));

⌨️ 快捷键说明

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