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

📄 epca.c

📁 linux和2410结合开发 用他可以生成2410所需的zImage文件
💻 C
📖 第 1 页 / 共 5 页
字号:
/* 	Copyright (C) 1996  Digi International. 	For technical support please email digiLinux@dgii.com or	call Digi tech support at (612) 912-3456	Much of this design and code came from epca.c which was 	copyright (C) 1994, 1995 Troy De Jongh, and subsquently 	modified by David Nugent, Christoph Lameter, Mike McLagan.   	This program 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 of the License, or 	(at your option) any later version. 	This program 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 this program; if not, write to the Free Software 	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.--------------------------------------------------------------------------- *//* See README.epca for change history --DAT*/#include <linux/config.h>#include <linux/module.h>#include <linux/kernel.h>#include <linux/types.h>#include <linux/init.h>#include <linux/serial.h>#include <linux/delay.h>#include <linux/ctype.h>#include <linux/tty.h>#include <linux/tty_flip.h>#include <linux/slab.h>#include <linux/ioport.h>#include <asm/uaccess.h>#include <asm/io.h>#ifdef CONFIG_PCI#define ENABLE_PCI#endif /* CONFIG_PCI */#define putUser(arg1, arg2) put_user(arg1, (unsigned long *)arg2)#define getUser(arg1, arg2) get_user(arg1, (unsigned int *)arg2)#ifdef ENABLE_PCI#include <linux/pci.h>#include "digiPCI.h"#endif /* ENABLE_PCI */#include "digi1.h"#include "digiFep1.h"#include "epca.h"#include "epcaconfig.h"#if BITS_PER_LONG != 32#  error FIXME: this driver only works on 32-bit platforms#endif/* ---------------------- Begin defines ------------------------ */#define VERSION            "1.3.0.1-LK"/* This major needs to be submitted to Linux to join the majors list */#define DIGIINFOMAJOR       35  /* For Digi specific ioctl */ #define MIN(a,b)	((a) < (b) ? (a) : (b))#define MAXCARDS 7#define epcaassert(x, msg)  if (!(x)) epca_error(__LINE__, msg)#define PFX "epca: "/* ----------------- Begin global definitions ------------------- */static char mesg[100];static int pc_refcount, nbdevs, num_cards, liloconfig;static int digi_poller_inhibited = 1 ;static int setup_error_code;static int invalid_lilo_config;/* -----------------------------------------------------------------------	MAXBOARDS is typically 12, but ISA and EISA cards are restricted to 	7 below.--------------------------------------------------------------------------*/static struct board_info boards[MAXBOARDS];/* ------------- Begin structures used for driver registeration ---------- */struct tty_driver pc_driver;struct tty_driver pc_callout;struct tty_driver pc_info;/* The below structures are used to initialize the tty_driver structures. *//*	-------------------------------------------------------------------------	Note : MAX_ALLOC is currently limited to 0x100.  This restriction is 	placed on us by Linux not Digi.----------------------------------------------------------------------------*/static struct tty_struct *pc_table[MAX_ALLOC];static struct termios *pc_termios[MAX_ALLOC];static struct termios *pc_termios_locked[MAX_ALLOC];/* ------------------ Begin Digi specific structures -------------------- *//* ------------------------------------------------------------------------	digi_channels represents an array of structures that keep track of	each channel of the Digi product.  Information such as transmit and	receive pointers, termio data, and signal definitions (DTR, CTS, etc ...)	are stored here.  This structure is NOT used to overlay the cards 	physical channel structure.-------------------------------------------------------------------------- */  static struct channel digi_channels[MAX_ALLOC];/* ------------------------------------------------------------------------	card_ptr is an array used to hold the address of the	first channel structure of each card.  This array will hold	the addresses of various channels located in digi_channels.-------------------------------------------------------------------------- */static struct channel *card_ptr[MAXCARDS];static struct timer_list epca_timer;/* ---------------------- Begin function prototypes --------------------- *//* ----------------------------------------------------------------------	Begin generic memory functions.  These functions will be alias	(point at) more specific functions dependent on the board being	configured.----------------------------------------------------------------------- */	#ifdef MODULEint                init_module(void);void               cleanup_module(void);#endif /* MODULE */static inline void memwinon(struct board_info *b, unsigned int win);static inline void memwinoff(struct board_info *b, unsigned int win);static inline void globalwinon(struct channel *ch);static inline void rxwinon(struct channel *ch);static inline void txwinon(struct channel *ch);static inline void memoff(struct channel *ch);static inline void assertgwinon(struct channel *ch);static inline void assertmemoff(struct channel *ch);/* ---- Begin more 'specific' memory functions for cx_like products --- */static inline void pcxem_memwinon(struct board_info *b, unsigned int win);static inline void pcxem_memwinoff(struct board_info *b, unsigned int win);static inline void pcxem_globalwinon(struct channel *ch);static inline void pcxem_rxwinon(struct channel *ch);static inline void pcxem_txwinon(struct channel *ch);static inline void pcxem_memoff(struct channel *ch);/* ------ Begin more 'specific' memory functions for the pcxe ------- */static inline void pcxe_memwinon(struct board_info *b, unsigned int win);static inline void pcxe_memwinoff(struct board_info *b, unsigned int win);static inline void pcxe_globalwinon(struct channel *ch);static inline void pcxe_rxwinon(struct channel *ch);static inline void pcxe_txwinon(struct channel *ch);static inline void pcxe_memoff(struct channel *ch);/* ---- Begin more 'specific' memory functions for the pc64xe and pcxi ---- *//* Note : pc64xe and pcxi share the same windowing routines */static inline void pcxi_memwinon(struct board_info *b, unsigned int win);static inline void pcxi_memwinoff(struct board_info *b, unsigned int win);static inline void pcxi_globalwinon(struct channel *ch);static inline void pcxi_rxwinon(struct channel *ch);static inline void pcxi_txwinon(struct channel *ch);static inline void pcxi_memoff(struct channel *ch);/* - Begin 'specific' do nothing memory functions needed for some cards - */static inline void dummy_memwinon(struct board_info *b, unsigned int win);static inline void dummy_memwinoff(struct board_info *b, unsigned int win);static inline void dummy_globalwinon(struct channel *ch);static inline void dummy_rxwinon(struct channel *ch);static inline void dummy_txwinon(struct channel *ch);static inline void dummy_memoff(struct channel *ch);static inline void dummy_assertgwinon(struct channel *ch);static inline void dummy_assertmemoff(struct channel *ch);/* ------------------- Begin declare functions ----------------------- */static inline struct channel *verifyChannel(register struct tty_struct *);static inline void pc_sched_event(struct channel *, int);static void epca_error(int, char *);static void pc_close(struct tty_struct *, struct file *);static void shutdown(struct channel *);static void pc_hangup(struct tty_struct *);static void pc_put_char(struct tty_struct *, unsigned char);static int pc_write_room(struct tty_struct *);static int pc_chars_in_buffer(struct tty_struct *);static void pc_flush_buffer(struct tty_struct *);static void pc_flush_chars(struct tty_struct *);static int block_til_ready(struct tty_struct *, struct file *,                           struct channel *);static int pc_open(struct tty_struct *, struct file *);static void post_fep_init(unsigned int crd);static void epcapoll(unsigned long);static void doevent(int);static void fepcmd(struct channel *, int, int, int, int, int);static unsigned termios2digi_h(struct channel *ch, unsigned);static unsigned termios2digi_i(struct channel *ch, unsigned);static unsigned termios2digi_c(struct channel *ch, unsigned);static void epcaparam(struct tty_struct *, struct channel *);static void receive_data(struct channel *);static int pc_ioctl(struct tty_struct *, struct file *,                    unsigned int, unsigned long);static void pc_set_termios(struct tty_struct *, struct termios *);static void do_softint(void *);static void pc_stop(struct tty_struct *);static void pc_start(struct tty_struct *);static void pc_throttle(struct tty_struct * tty);static void pc_unthrottle(struct tty_struct *tty);static void digi_send_break(struct channel *ch, int msec);static void setup_empty_event(struct tty_struct *tty, struct channel *ch);void epca_setup(char *, int *);void console_print(const char *);static int get_termio(struct tty_struct *, struct termio *);static int pc_write(struct tty_struct *, int, const unsigned char *, int);int pc_init(void);#ifdef ENABLE_PCIstatic int init_PCI(void);#endif /* ENABLE_PCI *//* ------------------------------------------------------------------	Table of functions for each board to handle memory.  Mantaining 	parallelism is a *very* good idea here.  The idea is for the 	runtime code to blindly call these functions, not knowing/caring    	about the underlying hardware.  This stuff should contain no	conditionals; if more functionality is needed a different entry	should be established.  These calls are the interface calls and 	are the only functions that should be accessed.  Anyone caught	making direct calls deserves what they get.-------------------------------------------------------------------- */static inline void memwinon(struct board_info *b, unsigned int win){	(b->memwinon)(b, win);}static inline void memwinoff(struct board_info *b, unsigned int win){	(b->memwinoff)(b, win);}static inline void globalwinon(struct channel *ch){	(ch->board->globalwinon)(ch);}static inline void rxwinon(struct channel *ch){	(ch->board->rxwinon)(ch);}static inline void txwinon(struct channel *ch){	(ch->board->txwinon)(ch);}static inline void memoff(struct channel *ch){	(ch->board->memoff)(ch);}static inline void assertgwinon(struct channel *ch){	(ch->board->assertgwinon)(ch);}static inline void assertmemoff(struct channel *ch){	(ch->board->assertmemoff)(ch);}/* ---------------------------------------------------------	PCXEM windowing is the same as that used in the PCXR 	and CX series cards.------------------------------------------------------------ */static inline void pcxem_memwinon(struct board_info *b, unsigned int win){        outb_p(FEPWIN|win, (int)b->port + 1);}static inline void pcxem_memwinoff(struct board_info *b, unsigned int win){	outb_p(0, (int)b->port + 1);}static inline void pcxem_globalwinon(struct channel *ch){	outb_p( FEPWIN, (int)ch->board->port + 1);}static inline void pcxem_rxwinon(struct channel *ch){	outb_p(ch->rxwin, (int)ch->board->port + 1);}static inline void pcxem_txwinon(struct channel *ch){	outb_p(ch->txwin, (int)ch->board->port + 1);}static inline void pcxem_memoff(struct channel *ch){	outb_p(0, (int)ch->board->port + 1);}/* ----------------- Begin pcxe memory window stuff ------------------ */static inline void pcxe_memwinon(struct board_info *b, unsigned int win){               outb_p(FEPWIN | win, (int)b->port + 1);}static inline void pcxe_memwinoff(struct board_info *b, unsigned int win){	outb_p(inb((int)b->port) & ~FEPMEM,	           (int)b->port + 1);	outb_p(0, (int)b->port + 1);}static inline void pcxe_globalwinon(struct channel *ch){	outb_p( FEPWIN, (int)ch->board->port + 1);}static inline void pcxe_rxwinon(struct channel *ch){		outb_p(ch->rxwin, (int)ch->board->port + 1);}static inline void pcxe_txwinon(struct channel *ch){		outb_p(ch->txwin, (int)ch->board->port + 1);}static inline void pcxe_memoff(struct channel *ch){	outb_p(0, (int)ch->board->port);	outb_p(0, (int)ch->board->port + 1);}/* ------------- Begin pc64xe and pcxi memory window stuff -------------- */static inline void pcxi_memwinon(struct board_info *b, unsigned int win){               outb_p(inb((int)b->port) | FEPMEM, (int)b->port);}static inline void pcxi_memwinoff(struct board_info *b, unsigned int win){	outb_p(inb((int)b->port) & ~FEPMEM, (int)b->port);}static inline void pcxi_globalwinon(struct channel *ch){	outb_p(FEPMEM, (int)ch->board->port);}static inline void pcxi_rxwinon(struct channel *ch){		outb_p(FEPMEM, (int)ch->board->port);}static inline void pcxi_txwinon(struct channel *ch){		outb_p(FEPMEM, (int)ch->board->port);}static inline void pcxi_memoff(struct channel *ch){	outb_p(0, (int)ch->board->port);}static inline void pcxi_assertgwinon(struct channel *ch){	epcaassert(inb((int)ch->board->port) & FEPMEM, "Global memory off");}static inline void pcxi_assertmemoff(struct channel *ch){	epcaassert(!(inb((int)ch->board->port) & FEPMEM), "Memory on");}/* ----------------------------------------------------------------------	Not all of the cards need specific memory windowing routines.  Some	cards (Such as PCI) needs no windowing routines at all.  We provide	these do nothing routines so that the same code base can be used.	The driver will ALWAYS call a windowing routine if it thinks it needs	to; regardless of the card.  However, dependent on the card the routine	may or may not do anything.---------------------------------------------------------------------------*/static inline void dummy_memwinon(struct board_info *b, unsigned int win){}static inline void dummy_memwinoff(struct board_info *b, unsigned int win){}static inline void dummy_globalwinon(struct channel *ch){}static inline void dummy_rxwinon(struct channel *ch){}static inline void dummy_txwinon(struct channel *ch){}

⌨️ 快捷键说明

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