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

📄 sx.c

📁 这是一个SIGMA方案的PMP播放器的UCLINUX程序,可播放DVD,VCD,CD MP3...有很好的参考价值.
💻 C
📖 第 1 页 / 共 5 页
字号:
/* sx.c -- driver for the Specialix SX series cards.  * *  This driver will also support the older SI, and XIO cards. * * *   (C) 1998 - 2000  R.E.Wolff@BitWizard.nl * *  Simon Allen (simonallen@cix.compulink.co.uk) wrote a previous *  version of this driver. Some fragments may have been copied. (none *  yet :-) * * Specialix pays for the development and support of this driver. * Please DO contact support@specialix.co.uk if you require * support. But please read the documentation (sx.txt) first. * * * *      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. * * Revision history: * $Log: /EM85xx/uClinux-2.4/drivers/char/sx.c $* * 1     6/07/02 12:35p Fabrice * Revision 1.33  2000/03/09 10:00:00  pvdl,wolff * - Fixed module and port counting * - Fixed signal handling * - Fixed an Ooops *  * Revision 1.32  2000/03/07 09:00:00  wolff,pvdl * - Fixed some sx_dprintk typos * - added detection for an invalid board/module configuration * * Revision 1.31  2000/03/06 12:00:00  wolff,pvdl * - Added support for EISA * * Revision 1.30  2000/01/21 17:43:06  wolff * - Added support for SX+ * * Revision 1.26  1999/08/05 15:22:14  wolff * - Port to 2.3.x * - Reformatted to Linus' liking. * * Revision 1.25  1999/07/30 14:24:08  wolff * Had accidentally left "gs_debug" set to "-1" instead of "off" (=0). * * Revision 1.24  1999/07/28 09:41:52  wolff * - I noticed the remark about use-count straying in sx.txt. I checked *   sx_open, and found a few places where that could happen. I hope it's *   fixed now. * * Revision 1.23  1999/07/28 08:56:06  wolff * - Fixed crash when sx_firmware run twice. * - Added sx_slowpoll as a module parameter (I guess nobody really wanted *   to change it from the default... ) * - Fixed a stupid editing problem I introduced in 1.22. * - Fixed dropping characters on a termios change. * * Revision 1.22  1999/07/26 21:01:43  wolff * Russell Brown noticed that I had overlooked 4 out of six modem control * signals in sx_getsignals. Ooops. * * Revision 1.21  1999/07/23 09:11:33  wolff * I forgot to free dynamically allocated memory when the driver is unloaded. * * Revision 1.20  1999/07/20 06:25:26  wolff * The "closing wait" wasn't honoured. Thanks to James Griffiths for * reporting this. * * Revision 1.19  1999/07/11 08:59:59  wolff * Fixed an oops in close, when an open was pending. Changed the memtest * a bit. Should also test the board in word-mode, however my card fails the * memtest then. I still have to figure out what is wrong... * * Revision 1.18  1999/06/10 09:38:42  wolff * Changed the format of the firmware revision from %04x to %x.%02x . * * Revision 1.17  1999/06/04 09:44:35  wolff * fixed problem: reference to pci stuff when config_pci was off... * Thanks to Jorge Novo for noticing this. * * Revision 1.16  1999/06/02 08:30:15  wolff * added/removed the workaround for the DCD bug in the Firmware. * A bit more debugging code to locate that... * * Revision 1.15  1999/06/01 11:35:30  wolff * when DCD is left low (floating?), on TA's the firmware first tells us * that DCD is high, but after a short while suddenly comes to the * conclusion that it is low. All this would be fine, if it weren't that * Unix requires us to send a "hangup" signal in that case. This usually * all happens BEFORE the program has had a chance to ioctl the device * into clocal mode.. * * Revision 1.14  1999/05/25 11:18:59  wolff * Added PCI-fix. * Added checks for return code of sx_sendcommand. * Don't issue "reconfig" if port isn't open yet. (bit us on TA modules...) * * Revision 1.13  1999/04/29 15:18:01  wolff * Fixed an "oops" that showed on SuSE 6.0 systems. * Activate DTR again after stty 0. * * Revision 1.12  1999/04/29 07:49:52  wolff * Improved "stty 0" handling a bit. (used to change baud to 9600 assuming *     the connection would be dropped anyway. That is not always the case, *     and confuses people). * Told the card to always monitor the modem signals. * Added support for dynamic  gs_debug adjustments. * Now tells the rest of the system the number of ports. * * Revision 1.11  1999/04/24 11:11:30  wolff * Fixed two stupid typos in the memory test. * * Revision 1.10  1999/04/24 10:53:39  wolff * Added some of Christian's suggestions. * Fixed an HW_COOK_IN bug (ISIG was not in I_OTHER. We used to trust the * card to send the signal to the process.....) * * Revision 1.9  1999/04/23 07:26:38  wolff * Included Christian Lademann's 2.0 compile-warning fixes and interrupt *    assignment redesign. * Cleanup of some other stuff. * * Revision 1.8  1999/04/16 13:05:30  wolff * fixed a DCD change unnoticed bug. * * Revision 1.7  1999/04/14 22:19:51  wolff * Fixed typo that showed up in 2.0.x builds (get_user instead of Get_user!) * * Revision 1.6  1999/04/13 18:40:20  wolff * changed misc-minor to 161, as assigned by HPA. * * Revision 1.5  1999/04/13 15:12:25  wolff * Fixed use-count leak when "hangup" occurred. * Added workaround for a stupid-PCIBIOS bug. * * * Revision 1.4  1999/04/01 22:47:40  wolff * Fixed < 1M linux-2.0 problem. * (vremap isn't compatible with ioremap in that case) * * Revision 1.3  1999/03/31 13:45:45  wolff * Firmware loading is now done through a separate IOCTL. * * Revision 1.2  1999/03/28 12:22:29  wolff * rcs cleanup * * Revision 1.1  1999/03/28 12:10:34  wolff * Readying for release on 2.0.x (sorry David, 1.01 becomes 1.1 for RCS).  * * Revision 0.12  1999/03/28 09:20:10  wolff * Fixed problem in 0.11, continueing cleanup. * * Revision 0.11  1999/03/28 08:46:44  wolff * cleanup. Not good. * * Revision 0.10  1999/03/28 08:09:43  wolff * Fixed loosing characters on close. * * Revision 0.9  1999/03/21 22:52:01  wolff * Ported back to 2.2.... (minor things) * * Revision 0.8  1999/03/21 22:40:33  wolff * Port to 2.0 * * Revision 0.7  1999/03/21 19:06:34  wolff * Fixed hangup processing. * * Revision 0.6  1999/02/05 08:45:14  wolff * fixed real_raw problems. Inclusion into kernel imminent. * * Revision 0.5  1998/12/21 23:51:06  wolff * Snatched a nasty bug: sx_transmit_chars was getting re-entered, and it * shouldn't have. THATs why I want to have transmit interrupts even when * the buffer is empty. * * Revision 0.4  1998/12/17 09:34:46  wolff * PPP works. ioctl works. Basically works! * * Revision 0.3  1998/12/15 13:05:18  wolff * It works! Wow! Gotta start implementing IOCTL and stuff.... * * Revision 0.2  1998/12/01 08:33:53  wolff * moved over to 2.1.130 * * Revision 0.1  1998/11/03 21:23:51  wolff * Initial revision. Detects SX card. * * */#define RCS_ID "$Id: sx.c,v 1.33 2000/03/08 10:01:02 wolff, pvdl Exp $"#define RCS_REV "$Revision: 1 $"#include <linux/module.h>#include <linux/config.h> #include <linux/kdev_t.h>#include <asm/io.h>#include <linux/kernel.h>#include <linux/sched.h>#include <linux/ioport.h>#include <linux/interrupt.h>#include <linux/errno.h>#include <linux/tty.h>#include <linux/tty_flip.h>#include <linux/mm.h>#include <linux/serial.h>#include <linux/fcntl.h>#include <linux/major.h>#include <linux/delay.h>#include <linux/tqueue.h>#include <linux/version.h>#include <linux/pci.h>#include <linux/slab.h>#include <linux/init.h>#include <linux/miscdevice.h>/* The 3.0.0 version of sxboards/sxwindow.h  uses BYTE and WORD.... */#define BYTE u8#define WORD u16/* .... but the 3.0.4 version uses _u8 and _u16. */#define _u8 u8#define _u16 u16#include "sxboards.h"#include "sxwindow.h"#include <linux/compatmac.h>#include <linux/generic_serial.h>#include "sx.h"/* I don't think that this driver can handle more than 256 ports on   one machine. You'll have to increase the number of boards in sx.h   if you want more than 4 boards.  *//* Why the hell am I defining these here? */#define SX_TYPE_NORMAL 1#define SX_TYPE_CALLOUT 2#ifndef PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8#define PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8 0x2000#endifstatic struct pci_device_id sx_pci_tbl[] = {	{ PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8, PCI_ANY_ID, PCI_ANY_ID },	{ 0 }};MODULE_DEVICE_TABLE(pci, sx_pci_tbl);/* Configurable options:    (Don't be too sure that it'll work if you toggle them) *//* Am I paranoid or not ? ;-) */#undef SX_PARANOIA_CHECK/* 20 -> 2000 per second. The card should rate-limit interrupts at 100   Hz, but it is user configurable. I don't recommend going above 1000   Hz. The interrupt ratelimit might trigger if the interrupt is   shared with a very active other device. */#define IRQ_RATE_LIMIT 20/* Sharing interrupts is possible now. If the other device wants more   than 2000 interrupts per second, we'd gracefully decline further   interrupts. That's not what we want. On the other hand, if the   other device interrupts 2000 times a second, don't use the SX   interrupt. Use polling. */#undef IRQ_RATE_LIMIT#if 0/* Not implemented *//*  * The following defines are mostly for testing purposes. But if you need * some nice reporting in your syslog, you can define them also. */#define SX_REPORT_FIFO#define SX_REPORT_OVERRUN#endif /* Function prototypes */static void sx_disable_tx_interrupts (void * ptr); static void sx_enable_tx_interrupts (void * ptr); static void sx_disable_rx_interrupts (void * ptr); static void sx_enable_rx_interrupts (void * ptr); static int  sx_get_CD (void * ptr); static void sx_shutdown_port (void * ptr);static int  sx_set_real_termios (void  *ptr);static void sx_hungup (void  *ptr);static void sx_close (void  *ptr);static int sx_chars_in_buffer (void * ptr);static int sx_init_board (struct sx_board *board);static int sx_init_portstructs (int nboards, int nports);static int sx_fw_ioctl (struct inode *inode, struct file *filp,                        unsigned int cmd, unsigned long arg);static int sx_init_drivers(void);static struct tty_driver sx_driver, sx_callout_driver;static struct tty_struct * sx_table[SX_NPORTS];static struct termios ** sx_termios;static struct termios ** sx_termios_locked;static struct sx_board boards[SX_NBOARDS];static struct sx_port *sx_ports;static int sx_refcount;static int sx_initialized;static int sx_nports;static int sx_debug;/* You can have the driver poll your card.     - Set sx_poll to 1 to poll every timer tick (10ms on Intel).       This is used when the card cannot use an interrupt for some reason.    - set sx_slowpoll to 100 to do an extra poll once a second (on Intel). If       the driver misses an interrupt (report this if it DOES happen to you!)      everything will continue to work....  */static int sx_poll = 1;static int sx_slowpoll;/* The card limits the number of interrupts per second.    At 115k2 "100" should be sufficient.    If you're using higher baudrates, you can increase this... */static int sx_maxints = 100;/* These are the only open spaces in my computer. Yours may have more   or less.... -- REW    duh: Card at 0xa0000 is possible on HP Netserver?? -- pvdl*/static int sx_probe_addrs[]= {0xc0000, 0xd0000, 0xe0000,                               0xc8000, 0xd8000, 0xe8000};static int si_probe_addrs[]= {0xc0000, 0xd0000, 0xe0000,                               0xc8000, 0xd8000, 0xe8000, 0xa0000};#define NR_SX_ADDRS (sizeof(sx_probe_addrs)/sizeof (int))#define NR_SI_ADDRS (sizeof(si_probe_addrs)/sizeof (int))/* Set the mask to all-ones. This alas, only supports 32 interrupts.    Some architectures may need more. */static int sx_irqmask = -1;MODULE_PARM(sx_probe_addrs, "i");MODULE_PARM(si_probe_addrs, "i");MODULE_PARM(sx_poll, "i");MODULE_PARM(sx_slowpoll, "i");MODULE_PARM(sx_maxints, "i");MODULE_PARM(sx_debug, "i");MODULE_PARM(sx_irqmask, "i");MODULE_LICENSE("GPL");static struct real_driver sx_real_driver = {	sx_disable_tx_interrupts,	sx_enable_tx_interrupts,	sx_disable_rx_interrupts,	sx_enable_rx_interrupts,	sx_get_CD,	sx_shutdown_port, 	sx_set_real_termios, 	sx_chars_in_buffer,	sx_close,	sx_hungup,};/*    This driver can spew a whole lot of debugging output at you. If you   need maximum performance, you should disable the DEBUG define. To   aid in debugging in the field, I'm leaving the compile-time debug   features enabled, and disable them "runtime". That allows me to   instruct people with problems to enable debugging without requiring   them to recompile... */#define DEBUG#ifdef DEBUG#define sx_dprintk(f, str...) if (sx_debug & f) printk (str)#else#define sx_dprintk(f, str...) /* nothing */#endif#define func_enter() sx_dprintk (SX_DEBUG_FLOW, "sx: enter " __FUNCTION__ "\n")#define func_exit()  sx_dprintk (SX_DEBUG_FLOW, "sx: exit  " __FUNCTION__ "\n")#define func_enter2() sx_dprintk (SX_DEBUG_FLOW, "sx: enter " __FUNCTION__ \                                  "(port %d)\n", port->line)/*  *  Firmware loader driver specific routines * */static struct file_operations sx_fw_fops = {	owner:		THIS_MODULE,	ioctl:		sx_fw_ioctl,};static struct miscdevice sx_fw_device = {	SXCTL_MISC_MINOR, "sxctl", &sx_fw_fops};#ifdef SX_PARANOIA_CHECK/* This doesn't work. Who's paranoid around here? Not me! */static inline int sx_paranoia_check(struct sx_port const * port,				    kdev_t device, const char *routine){	static const char *badmagic =	  KERN_ERR "sx: Warning: bad sx port magic number for device %s in %s\n";

⌨️ 快捷键说明

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