/drivers/char/epca.c
https://bitbucket.org/evzijst/gittest · C · 3789 lines · 2187 code · 907 blank · 695 comment · 349 complexity · c77d8deab6ed1b0737609a564245fc5a MD5 · raw file
Large files are truncated click here to view the full file
- /*
-
- 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 <linux/interrupt.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 __user *)arg2)
- #define getUser(arg1, arg2) get_user(arg1, (unsigned __user *)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 MAXCARDS 7
- #define epcaassert(x, msg) if (!(x)) epca_error(__LINE__, msg)
- #define PFX "epca: "
- /* ----------------- Begin global definitions ------------------- */
- static char mesg[100];
- static int 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 ---------- */
- static struct tty_driver *pc_driver;
- static struct tty_driver *pc_info;
- /* ------------------ 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.
- ----------------------------------------------------------------------- */
-
- 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 int info_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 __user *);
- static int pc_write(struct tty_struct *, const unsigned char *, int);
- int pc_init(void);
- #ifdef ENABLE_PCI
- static 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)
- {
- }
- 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 verifyChannel function ----------------------- */
- static inline struct channel *verifyChannel(register struct tty_struct *tty)
- { /* Begin verifyChannel */
- /* --------------------------------------------------------------------
- This routine basically provides a sanity check. It insures that
- the channel returned is within the proper range of addresses as
- well as properly initialized. If some bogus info gets passed in
- through tty->driver_data this should catch it.
- --------------------------------------------------------------------- */
- if (tty)
- { /* Begin if tty */
- register struct channel *ch = (struct channel *)tty->driver_data;
- if ((ch >= &digi_channels[0]) && (ch < &digi_channels[nbdevs]))
- {
- if (ch->magic == EPCA_MAGIC)
- return ch;
- }
- } /* End if tty */
- /* Else return a NULL for invalid */
- return NULL;
- } /* End verifyChannel */
- /* ------------------ Begin pc_sched_event ------------------------- */
- static inline void pc_sched_event(struct channel *ch, int event)
- { /* Begin pc_sched_event */
- /* ----------------------------------------------------------------------
- We call this to schedule interrupt processing on some event. The
- kernel sees our request and calls the related routine in OUR driver.
- -------------------------------------------------------------------------*/
- ch->event |= 1 << event;
- schedule_work(&ch->tqueue);
- } /* End pc_sched_event */
- /* ------------------ Begin epca_error ------------------------- */
- static void epca_error(int line, char *msg)
- { /* Begin epca_error */
- printk(KERN_ERR "epca_error (Digi): line = %d %s\n",line,msg);
- return;
- } /* End epca_error */
- /* ------------------ Begin pc_close ------------------------- */
- static void pc_close(struct tty_struct * tty, struct file * filp)
- { /* Begin pc_close */
- struct channel *ch;
- unsigned long flags;
- /* ---------------------------------------------------------
- verifyChannel returns the channel from the tty struct
- if it is valid. This serves as a sanity check.
- ------------------------------------------------------------- */
- if ((ch = verifyChannel(tty)) != NULL)
- { /* Begin if ch != NULL */
- save_flags(flags);
- cli();
- if (tty_hung_up_p(filp))
- {
- restore_flags(flags);
- return;
- }
- /* Check to see if the channel is open more than once */
- if (ch->count-- > 1)
- { /* Begin channel is open more than once */
- /* -------------------------------------------------------------
- Return without doing anything. Someone might still be using
- the channel.
- ---------------------------------------------------------------- */
- restore_flags(flags);
- return;
- } /* End channel is open more than once */
- /* Port open only once go ahead with shutdown & reset */
- if (ch->count < 0)
- {
- ch->count = 0;
- }
- /* ---------------------------------------------------------------
- Let the rest of the driver know the channel is being closed.
- This becomes important if an open is attempted before close
- is finished.
- ------------------------------------------------------------------ */
- ch->asyncflags |= ASYNC_CLOSING;
-
- tty->closing = 1;
- if (ch->asyncflags & ASYNC_INITIALIZED)
- {
- /* Setup an event to indicate when the transmit buffer empties */
- setup_empty_event(tty, ch);
- tty_wait_until_sent(tty, 3000); /* 30 seconds timeout */
- }
-
- if (tty->driver->flush_buffer)
- tty->driver->flush_buffer(tty);
- tty_ldisc_flush(tty);
- shutdown(ch);
- tty->closing = 0;
- ch->event = 0;
- ch->tty = NULL;
- if (ch->blocked_open)
- { /* Begin if blocked_open */
- if (ch->close_delay)
- {
- msleep_interruptible(jiffies_to_msecs(ch->close_delay));
- }
- wake_up_interruptible(&ch->open_wait);
- } /* End if blocked_open */
- ch->asyncflags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_INITIALIZED |
- ASYNC_CLOSING);
- wake_up_interruptible(&ch->close_wait);
- restore_flags(flags);
- } /* End if ch != NULL */
- } /* End pc_close */
- /* ------------------ Begin shutdown ------------------------- */
- static void shutdown(struct channel *ch)
- { /* Begin shutdown */
- unsigned long flags;
- struct tty_struct *tty;
- volatile struct board_chan *bc;
- if (!(ch->asyncflags & ASYNC_INITIALIZED))
- return;
- save_flags(flags);
- cli();
- globalwinon(ch);
- bc = ch->brdchan;
- /* ------------------------------------------------------------------
- In order for an event to be generated on the receipt of data the
- idata flag must be set. Since we are shutting down, this is not
- necessary clear this flag.
- --------------------------------------------------------------------- */
- if (bc)
- bc->idata = 0;
- tty = ch->tty;
- /* ----------------------------------------------------------------
- If we're a modem control device and HUPCL is on, drop RTS & DTR.
- ------------------------------------------------------------------ */
- if (tty->termios->c_cflag & HUPCL)
- {
- ch->omodem &= ~(ch->m_rts | ch->m_dtr);
- fepcmd(ch, SETMODEM, 0, ch->m_dtr | ch->m_rts, 10, 1);
- }
- memoff(ch);
- /* ------------------------------------------------------------------
- The channel has officialy been closed. The next time it is opened
- it will have to reinitialized. Set a flag to indicate this.
- ---------------------------------------------------------------------- */
- /* Prevent future Digi programmed interrupts from coming active */
- ch->asyncflags &= ~ASYNC_INITIALIZED;
- restore_flags(flags);
- } /* End shutdown */
- /* ------------------ Begin pc_hangup ------------------------- */
- static void pc_hangup(struct tty_struct *tty)
- { /* Begin pc_hangup */
- struct channel *ch;
-
- /* ---------------------------------------------------------
- verifyChannel returns the channel from the tty struct
- if it is valid. This serves as a sanity check.
- ------------------------------------------------------------- */
- if ((ch = verifyChannel(tty)) != NULL)
- { /* Begin if ch != NULL */
- unsigned long flags;
- save_flags(flags);
- cli();
- if (tty->driver->flush_buffer)
- tty->driver->flush_buffer(tty);
- tty_ldisc_flush(tty);
- shutdown(ch);
- ch->tty = NULL;
- ch->event = 0;
- ch->count = 0;
- restore_flags(flags);
- ch->asyncflags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_INITIALIZED);
- wake_up_interruptible(&ch->open_wait);
- } /* End if ch != NULL */
- } /* End pc_hangup */
- /* ------------------ Begin pc_write ------------------------- */
- static int pc_write(struct tty_struct * tty,
- const unsigned char *buf, int bytesAvailable)
- { /* Begin pc_write */
- register unsigned int head, tail;
- register int dataLen;
- register int size;
- register int amountCopied;
- struct channel *ch;
- unsigned long flags;
- int remain;
- volatile struct board_chan *bc;
- /* ----------------------------------------------------------------
- pc_write is primarily called directly by the kernel routine
- tty_write (Though it can also be called by put_char) found in
- tty_io.c. pc_write is passed a line discipline buffer where
- the data to be written out is stored. The line discipline
- implementation itself is done at the kernel level and is not
- brought into the driver.
- ------------------------------------------------------------------- */
- /* ---------------------------------------------------------
- verifyChannel returns the channel from the tty struct
- if it is valid. This serves as a sanity check.
- ------------------------------------------------------------- */
- if ((ch = verifyChannel(tty)) == NULL)
- return 0;
- /* Make a pointer to the channel data structure found on the board. */
- bc = ch->brdchan;
- size = ch->txbufsize;
- amountCopied = 0;
- save_flags(flags);
- cli();
- globalwinon(ch);
- head = bc->tin & (size - 1);
- tail = bc->tout;
- if (tail != bc->tout)
- tail = bc->tout;
- tail &= (size - 1);
- /* If head >= tail, head has not wrapped around. */
- if (head >= tail)
- { /* Begin head has not wrapped */
- /* ---------------------------------------------------------------
- remain (much like dataLen above) represents the total amount of
- space available on the card for data. Here dataLen represents
- the space existing between the head pointer and the end of
- buffer. This is important because a memcpy cannot be told to
- automatically wrap around when it hits the buffer end.
- ------------------------------------------------------------------ */
- dataLen = size - head;
- remain = size - (head - tail) - 1;
- } /* End head has not wrapped */
- else
- { /* Begin head has wrapped around */
- remain = tail - head - 1;
- dataLen = remain;
- } /* End head has wrapped around */
- /* -------------------------------------------------------------------
- Check the space on the card. If we have more data than
- space; reduce the amount of data to fit the space.
- ---------------------------------------------------------------------- */
- bytesAvailable = min(remain, bytesAvailable);
- txwinon(ch);
- while (bytesAvailable > 0)
- { /* Begin while there is data to copy onto card */
- /* -----------------------------------------------------------------
- If head is not wrapped, the below will make sure the first
- data copy fills to the end of card buffer.
- ------------------------------------------------------------------- */
- dataLen = min(bytesAvailable, dataLen);
- memcpy(ch->txptr + head, buf, dataLen);
- buf += dataLen;
- head += dataLen;
- amountCopied += dataLen;
- bytesAvailable -= dataLen;
- if (head >= size)
- {
- head = 0;
- dataLen = tail;
- }
- } /* End while there is data to copy onto card */
- ch->statusflags |= TXBUSY;
- globalwinon(ch);
- bc->tin = head;
- if ((ch->statusflags & LOWWAIT) == 0)
- {
- ch->statusflags |= LOWWAIT;
- bc->ilow = 1;
- }
- memoff(ch);
- restore_flags(flags);
- return(amountCopied);
- } /* End pc_write */
- /* ------------------ Begin pc_put_char ------------------------- */
- static void pc_put_char(struct tty_struct *tty, unsigned char c)
- { /* Begin pc_put_char */
-
- pc_write(tty, &c, 1);
- return;
- } /* End pc_put_char */
- /* ------------------ Begin pc_write_room ------------------------- */
- static int pc_write_room(struct tty_struct *tty)
- { /* Begin pc_write_room */
- int remain;
- struct channel *ch;
- unsigned long flags;
- unsigned int head, tail;
- volatile struct board_chan *bc;
- remain = 0;
- /* ---------------------------------------------------------
- verifyChannel returns the channel from the tty struct
- if it is valid. This serves as a sanity check.
- ------------------------------------------------------------- */
- if ((ch = verifyChannel(tty)) != NULL)
- {
- save_flags(flags);
- cli();
- globalwinon(ch);
- bc = ch->brdchan;
- head = bc->tin & (ch->txbufsize - 1);
- tail = bc->tout;
- if (tail != bc->tout)
- tail = bc->tout;
- /* Wrap tail if necessary */
- tail &= (ch->txbufsize - 1);
- if ((remain = tail - head - 1) < 0 )
- remain += ch->txbufsize;
- if (remain && (ch->statusflags & LOWWAIT) == 0)
- {
- ch->statusflags |= LOWWAIT;
- bc->ilow = 1;
- }
- memoff(ch);
- restore_flags(flags);
- }
- /* Return how much room is left on card */
- return remain;
- } /* End pc_write_room */
- /* ------------------ Begin pc_chars_in_buffer ---------------------- */
- static int pc_chars_in_buffer(struct tty_struct *tty)
- { /* Begin pc_chars_in_buffer */
- int chars;
- unsigned int ctail, head, tail;
- int remain;
- unsigned long flags;
- struct channel *ch;
- volatile struct board_chan *bc;
- /* ---------------------------------------------------------
- verifyChannel returns the channel from the tty struct
- if it is valid. This serves as a sanity check.
- ------------------------------------------------------------- */
- if ((ch = verifyChannel(tty)) == NULL)
- return(0);
- save_flags(flags);
- cli();
- globalwinon(ch);
- bc = ch->brdchan;
- tail = bc->tout;
- head = bc->tin;
- ctail = ch->mailbox->cout;
- if (tail == head && ch->mailbox->cin == ctail && bc->tbusy == 0)
- chars = 0;
- else
- { /* Begin if some space on the card has been used */
- head = bc->tin & (ch->txbufsize - 1);
- tail &= (ch->txbufsize - 1);
- /* --------------------------------------------------------------
- The logic here is basically opposite of the above pc_write_room
- here we are finding the amount of bytes in the buffer filled.
- Not the amount of bytes empty.
- ------------------------------------------------------------------- */
- if ((remain = tail - head - 1) < 0 )
- remain += ch->txbufsize;
- chars = (int)(ch->txbufsize - remain);
- /* -------------------------------------------------------------
- Make it possible to wakeup anything waiting for output
- in tty_ioctl.c, etc.
- If not already set. Setup an event to indicate when the
- transmit buffer empties
- ----------------------------------------------------------------- */
- if (!(ch->statusflags & EMPTYWAIT))
- setup_empty_event(tty,ch);
- } /* End if some space on the card has been used */
- memoff(ch);
- restore_flags(flags);
- /* Return number of characters residing on card. */
- return(chars);
- } /* End pc_chars_in_buffer */
- /* ------------------ Begin pc_flush_buffer ---------------------- */
- static void pc_flush_buffer(struct tty_struct *tty)
- { /* Begin pc_flush_buffer */
- unsigned int tail;
- unsigned long flags;
- struct channel *ch;
- volatile struct board_chan *bc;
- /* ---------------------------------------------------------
- verifyChannel returns the channel from the tty struct
- if it is valid. This serves as a sanity check.
- ------------------------------------------------------------- */
- if ((ch = verifyChannel(tty)) == NULL)
- return;
- save_flags(flags);
- cli();
- globalwinon(ch);
- bc = ch->brdchan;
- tail = bc->tout;
- /* Have FEP move tout pointer; effectively flushing transmit buffer */
- fepcmd(ch, STOUT, (unsigned) tail, 0, 0, 0);
- memoff(ch);
- restore_flags(flags);
- wake_up_interruptible(&tty->write_wait);
- tty_wakeup(tty);
- } /* End pc_flush_buffer */
- /* ------------------ Begin pc_flush_chars ---------------------- */
- static void pc_flush_chars(struct tty_struct *tty)
- { /* Begin pc_flush_chars */
- struct channel * ch;
- /* ---------------------------------------------------------
- verifyChannel returns the channel from the tty struct
- if it is valid. This serves as a sanity check.
- ------------------------------------------------------------- */
- if ((ch = verifyChannel(tty)) != NULL)
- {
- unsigned long flags;
- save_flags(flags);
- cli();
- /* ----------------------------------------------------------------
- If not already set and the transmitter is busy setup an event
- to indicate when the transmit empties.
- ------------------------------------------------------------------- */
- if ((ch->statusflags & TXBUSY) && !(ch->statusflags & EMPTYWAIT))
- setup_empty_event(tty,ch);
- restore_flags(flags);
- }
- } /* End pc_flush_chars */
- /* ------------------ Begin block_til_ready ---------------------- */
- static int block_til_ready(struct tty_struct *tty,
- struct file *filp, struct channel *ch)
- { /* Begin block_til_ready */
- DECLARE_WAITQUEUE(wait,current);
- int retval, do_clocal = 0;
- unsigned long flags;
- if (tty_hung_up_p(filp))
- {
- if (ch->asyncflags & ASYNC_HUP_NOTIFY)
- retval = -EAGAIN;
- else
- retval = -ERESTARTSYS;
- return(retval);
- }
- /* -----------------------------------------------------------------
- If the device is in the middle of being closed, then block
- until it's done, and then try again.
- -------------------------------------------------------------------- */
- if (ch->asyncflags & ASYNC_CLOSING)
- {
- interruptible_sleep_on(&ch->close_wait);
- if (ch->asyncflags & ASYNC_HUP_NOTIFY)
- return -EAGAIN;
- else
- return -ERESTARTSYS;
- }
- if (filp->f_flags & O_NONBLOCK)
- {
- /* -----------------------------------------------------------------
- If non-blocking mode is set, then make the check up front
- and then exit.
- -------------------------------------------------------------------- */
- ch->asyncflags |= ASYNC_NORMAL_ACTIVE;
- return 0;
- }
- if (tty->termios->c_cflag & CLOCAL)
- do_clocal = 1;
-
- /* Block waiting for the carrier detect and the line to become free */
-
- retval = 0;
- add_wait_queue(&ch->open_wait, &wait);
- save_flags(flags);
- cli();
- /* We dec count so that pc_close will know when to free things */
- if (!tty_hung_up_p(filp))
- ch->count--;
- restore_flags(flags);
- ch->blocked_open++;
- while(1)
- { /* Begin forever while */
- set_current_state(TASK_INTERRUPTIBLE);
- if (tty_hung_up_p(filp) ||
- !(ch->asyncflags & ASYNC_INITIALIZED))
- {
- if (ch->asyncflags & ASYNC_HUP_NOTIFY)
- retval = -EAGAIN;
- else
- retval = -ERESTARTSYS;
- break;
- }
- if (!(ch->asyncflags & ASYNC_CLOSING) &&
- (do_clocal || (ch->imodem & ch->dcd)))
- break;
- if (signal_pending(current))
- {
- retval = -ERESTARTSYS;
- break;
- }
- /* ---------------------------------------------------------------
- Allow someone else to be scheduled. We will occasionally go
- through this loop until one of the above conditions change.
- The below schedule call will allow other processes to enter and
- prevent this loop from hogging the cpu.
- ------------------------------------------------------------------ */
- schedule();
- } /* End forever while */
- current->state = TASK_RUNNING;
- remove_wait_queue(&ch->open_wait, &wait);
- cli();
- if (!tty_hung_up_p(filp))
- ch->count++;
- restore_flags(flags);
- ch->blocked_open--;
- if (retval)
- return retval;
- ch->asyncflags |= ASYNC_NORMAL_ACTIVE;
- return 0;
- } /* End block_til_ready */
- /* ------------------ Begin pc_open ---------------------- */
- static int pc_open(struct tty_struct *tty, struct file * filp)
- { /* Begin pc_open */
- struct channel *ch;
- unsigned long flags;
- int line, retval, boardnum;
- volatile struct board_chan *bc;
- volatile unsigned int head;
- line = tty->index;
- if (line < 0 || line >= nbdevs)
- {
- printk(KERN_ERR "<Error> - pc_open : line out of range in pc_open\n");
- tty->driver_data = NULL;
- return(-ENODEV);
- }
- ch = &digi_channels[line];
- boardnum = ch->boardnum;
- /* Check status of board configured in system. */
- /* -----------------------------------------------------------------
- I check to see if the epca_setup routine detected an user error.
- It might be better to put this in pc_init, but for the moment it
- goes here.
- ---------------------------------------------------------------------- */
- if (invalid_lilo_config)
- {
- if (setup_error_code & INVALID_BOARD_TYPE)
- printk(KERN_ERR "<Error> - pc_open: Invalid board type specified in LILO command\n");
- if (setup_error_code & INVALID_NUM_PORTS)
- printk(KERN_ERR "<Error> - pc_open: Invalid number of ports specified in LILO command\n");
- if (setup_error_code & INVALID_MEM_BASE)
- printk(KERN_ERR "<Error> - pc_open: Invalid board memory address specified in LILO command\n");
- if (setup_error_code & INVALID_PORT_BASE)
- printk(KERN_ERR "<Error> - pc_open: Invalid board port address specified in LILO command\n");
- if (setup_error_code & INVALID_BOARD_STATUS)
- printk(KERN_ERR "<Error> - pc_open: Invalid board status specified in LILO command\n");
- if (setup_error_code & INVALID_ALTPIN)
- printk(KERN_ERR "<Error> - pc_open: Invalid board altpin specified in LILO command\n");
- tty->driver_data = NULL; /* Mark this device as 'down' */
- return(-ENODEV);
- }
- if ((boardnum >= num_cards) || (boards[boardnum].status == DISABLED))
- {
- tty->driver_data = NULL; /* Mark this device as 'down' */
- return(-ENODEV);
- }
-
- if (( bc = ch->brdchan) == 0)
- {
- tty->driver_data = NULL;
- return(-ENODEV);
- }
- /* ------------------------------------------------------------------
- Every time a channel is opened, increment a counter. This is
- necessary because we do not wish to flush and shutdown the channel
- until the last app holding the channel open, closes it.
- --------------------------------------------------------------------- */
- ch->count++;
- /* ----------------------------------------------------------------
- Set a kernel structures pointer to our local channel
- structure. This way we can get to it when passed only
- a tty struct.
- ------------------------------------------------------------------ */
- tty->driver_data = ch;
-
- /* ----------------------------------------------------------------
- If this is the first time the channel has been opened, initialize
- the tty->termios struct otherwise let pc_close handle it.
- -------------------------------------------------------------------- */
- save_flags(flags);
- cli();
- globalwinon(ch);
- ch->statusflags = 0;
- /* Save boards current modem status */
- ch->imodem = bc->mstat;
- /* ----------------------------------------------------------------
- Set receive head and tail ptrs to each other. This indicates
- no data available to read.
- ----------------------------------------------------------------- */
- head = bc->rin;
- bc->rout = head;
- /* Set the channels associated tty structure */
- ch->tty = tty;
- /* -----------------------------------------------------------------
- The below routine generally sets up parity, baud, flow control
- issues, etc.... It effect both control flags and input flags.
- -------------------------------------------------------------------- */
- epcaparam(tty,ch);
- ch->asyncflags |= ASYNC_INITIALIZED;
- memoff(ch);
- restore_flags(flags);
- retval = block_til_ready(tty, filp, ch);
- if (retval)
- {
- return retval;
- }
- /* -------------------------------------------------------------
- Set this again in case a hangup set it to zero while this
- open() was waiting for the line...
- --------------------------------------------------------------- */
- ch->tty = tty;
- save_flags(flags);
- cli();
- globalwinon(ch);
- /* Enable Digi Data events */
- bc->idata = 1;
- memoff(ch);
- restore_flags(flags);
- return 0;
- } /* End pc_open */
- #ifdef MODULE
- static int __init epca_module_init(void)
- { /* Begin init_module */
- unsigned long flags;
- save_flags(flags);
- cli();
- pc_init();
- restore_flags(flags);
- return(0);
- }
- module_init(epca_module_init);
- #endif
- #ifdef ENABLE_PCI
- static struct pci_driver epca_driver;
- #endif
- #ifdef MODULE
- /* -------------------- Begin cleanup_module ---------------------- */
- static void __exit epca_module_exit(void)
- {
- int count, crd;
- struct board_info *bd;
- struct channel *ch;
- unsigned long flags;
- del_timer_sync(&epca_timer);
- save_flags(flags);
- cli();
- if ((tty_unregister_driver(pc_driver)) ||
- (tty_unregister_driver(pc_info)))
- {
- printk(KERN_WARNING "<Error> - DIGI : cleanup_module failed to un-register tty driver\n");
- restore_flags(flags);
- return;
- }
- put_tty_driver(pc_driver);
- put_tty_driver(pc_info);
- for (crd = 0; crd < num_cards; crd++)
- { /* Begin for each card */
- bd = &boards[crd];
- if (!bd)
- { /* Begin sanity check */
- printk(KERN_ERR "<Error> - Digi : cleanup_module failed\n");
- return;
- } /* End sanity check */
- ch = card_ptr[crd];
- for (count = 0; count < bd->numports; count++, ch++)
- { /* Begin for each port */
- if (ch)
- {
- if (ch->tty)
- tty_hangup(ch->tty);
- kfree(ch->tmp_buf);
- }
- } /* End for each port */
- } /* End for each card */
- #ifdef ENABLE_PCI
- pci_unregister_driver (&epca_driver);
- #endif
- restore_flags(flags);
- }
- module_exit(epca_module_exit);
- #endif /* MODULE */
- static struct tty_operations pc_ops = {
- .open = pc_open,
- .close = pc_close,
- .write = pc_write,
- .write_room = pc_write_room,
- .flush_buffer = pc_flush_buffer,
- .chars_in_buffer = pc_chars_in_buffer,
- .flush_chars = pc_flush_chars,
- .put_char = pc_put_char,
- .ioctl = pc_ioctl,
- .set_termios = pc_set_termios,
- .stop = pc_stop,
- .start = pc_start,
- .throttle = pc_throttle,
- .unthrottle = pc_unthrottle,
- .hangup = pc_hangup,
- };
- static int info_open(struct tty_struct *tty, struct file * filp)
- {
- return 0;
- }
- static struct tty_operations info_ops = {
- .open = info_open,
- .ioctl = info_ioctl,
- };
- /* ------------------ Begin pc_init ---------------------- */
- int __init pc_init(void)
- { /* Begin pc_init */
- /* ----------------------------------------------------------------
- pc_init is called by the operating system during boot up prior to
- any open calls being made. In the older versions of Linux (Prior
- to 2.0.0) an entry is made into tty_io.c. A pointer to the last
- memory location (from kernel space) used (kmem_start) is passed
- to pc_init. It is pc_inits responsibility to modify this value
- for any memory that the Digi driver might need and then return
- this value to the operating system. For example if the driver
- wishes to allocate 1K of kernel memory, pc_init would return
- (kmem_start + 1024). This memory (Between kmem_start and kmem_start
- + 1024) would then be available for use exclusively by the driver.
- In this case our driver does not allocate any of this kernel
- memory.
- ------------------------------------------------------------------*/
- ulong flags;
- int crd;
- struct board_info *bd;
- unsigned char board_id = 0;
- #ifdef ENABLE_PCI
- int pci_boards_found, pci_count;
- pci_count = 0;
- #endif /* ENABLE_PCI */
- pc_driver = alloc_tty_driver(MAX_ALLOC);
- if (!pc_driver)
- return -ENOMEM;
- pc_info = alloc_tty_driver(MAX_ALLOC);
- if (!pc_info) {
- put_tty_driver(pc_driver);
- return -ENOMEM;
- }
- /* -----------------------------------------------------------------------
- If epca_setup has not been ran by LILO set num_cards to defaults; copy
- board structure defined by digiConfig into drivers board structure.
- Note : If LILO has ran epca_setup then epca_setup will handle defining
- num_cards as well as copying the data into the board structure.
- -------------------------------------------------------------------------- */
- if (!liloconfig)
- { /* Begin driver has been configured via. epcaconfig */
- nbdevs = NBDEVS;
- num_cards = NUMCARDS;
- memcpy((void *)&boards, (void *)&static_boards,
- (sizeof(struct board_info) * NUMCARDS));
- } /* End driver has been configured via. epcaconfig */
- /* -----------------------------------------------------------------
- Note : If lilo was used to configure the driver and the
- ignore epcaconfig option was choosen (digiepca=2) then
- nbdevs and num_cards will equal 0 at this point. This is
- okay; PCI cards will still be picked up if detected.
- --------------------------------------------------------------------- */
- /* -----------------------------------------------------------
- Set up interrupt, we will worry about memory allocation in
- post_fep_init.
- --------------------------------------------------------------- */
- printk(KERN_INFO "DIGI epca driver version %s loaded.\n",VERSION);
- #ifdef ENABLE_PCI
- /* ------------------------------------------------------------------
- NOTE : This code assumes that the number of ports found in
- the boards array is correct. This could be wrong if
- the card in question is PCI (And therefore has no ports
- entry in the boards structure.) The rest of the
- information will be valid for PCI because the beginning
- of pc_init scans for PCI and determines i/o and base
- memory addresses. I am not sure if it is possible to
- read the number of ports supported by the card prior to
- it being booted (Since that is the state it is in when
- pc_init is run). Because it is not possible to query the
- number of supported ports until after the card has booted;
- we are required to calculate the card_ptrs as the card is
- is initialized (Inside post_fep_init). The negative thing
- about this approach is that digiDload's call to GET_INFO
- will have a bad port value. (Since this is called prior
- to post_fep_init.)
- --------------------------------------------------------------------- */
-
- pci_boards_found = 0;
- if(num_cards < MAXBOARDS)
- pci_boards_found += init_PCI();
- num_cards += pci_boards_found;
- #endif /* ENABLE_PCI */
- pc_driver->owner = THIS_MODULE;
- pc_driver->name = "ttyD";
- pc_driver->devfs_name = "tts/D";
- pc_driver->major = DIGI_MAJOR;
- pc_driver->minor_start = 0;
- pc_driver->type = TTY_DRIVER_TYPE_SERIAL;
- pc_driver->subtype = SERIAL_TYPE_NORMAL;
- pc_driver->init_termios = tty_std_termios;
- pc_driver->init_termios.c_iflag = 0;
- pc_driver->init_termios.c_oflag = 0;
- pc_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL;
- pc_driver->init_termios.c_lflag = 0;
- pc_driver->flags = TTY_DRIVER_REAL_RAW;
- tty_set_operations(pc_driver, &pc_ops);
- pc_info->owner = THIS_MODULE;
- pc_info->name = "digi_ctl";
- pc_info->major = DIGIINFOMAJOR;
- pc_info->minor_start = 0;
- pc_info->type = TTY_DRIVER_TYPE_SERIAL;
- pc_info->subtype = SERIAL_TYPE_INFO;
- pc_info->init_termios = tty_std_termios;
- pc_info->init_termios.c_iflag = 0;
- pc_info->init_termios.c_oflag = 0;
- pc_info->init_termios.c_lflag = 0;
- pc_info->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL;
- pc_info->flags = TTY_DRIVER_REAL_RAW;
- tty_set_operations(pc_info, &info_ops);
- save_flags(flags);
- cli();
- for (crd = 0; crd < num_cards; crd++)
- { /* Begin for each card */
- /* ------------------------------------------------------------------
- This is where the appropriate memory handlers for the hardware is
- set. Everything at runtime blindly jumps through these vectors.
- ---------------------------------------------------------------------- */
- /* defined in epcaconfig.h */
- bd = &boards[crd];
- switch (bd->type)
- { /* Begin switch on bd->type {board type} */
- case PCXEM:
- case EISAXEM:
- bd->memwinon = pcxem_memwinon ;
- bd->memwinoff = pcxem_memwinoff ;
- bd->globalwinon = pcxem_globalwinon ;
- bd->txwinon = pcxem_txwinon ;
- bd->rxwinon = pcxem_rxwinon ;
- bd->memoff = pcxem_memoff ;
- bd->assertgwinon = dummy_assertgwinon;
- bd->assertmemoff = dummy_assertmemoff;
- break;
- case PCIXEM:
- case PCIXRJ:
- case PCIXR:
- bd->memwinon = dummy_memwinon;
- bd->memwinoff = dummy_memwinoff;
- bd->globalwinon = dummy_globalwinon;
- bd->txwinon = dummy_txwinon;
- bd->rxwinon = dummy_rxwinon;
- bd->memoff = dummy_memoff;
- bd->assertgwinon = dummy_assertgwinon;
- bd->assertmemoff = dummy_assertmemoff;
- break;
- case PCXE:
- case PCXEVE:
- bd->memwinon = pcxe_memwinon;
- bd->memwinoff = pcxe_memwinoff;
- bd->globalwinon = pcxe_globalwinon;
- bd->txwinon = pcxe_txwinon;
- bd->rxwinon = pcxe_rxwinon;
- bd->memoff = pcxe_memoff;
- bd->assertgwinon = dummy_assertgwinon;
- bd->assertmemoff = dummy_assertmemoff;
- break;
- case PCXI:
- case PC64XE:
- bd->memwinon = pcxi_memwinon;
- bd->memwinoff = pcxi_memwinoff;
- bd->globalwinon = pcxi_globalwinon;
- bd->txwinon = pcxi_txwinon;
- bd->rxwinon = pcxi_rxwinon;
- bd->memoff = pcxi_memoff;
- bd->assertgwinon = pcxi_assertgwinon;
- bd->assertmemoff = pcxi_assertmemoff;
- break;
- default:
- break;
- } /* End switch on bd->type */
- /* ---------------------------------------------------------------
- Some cards need a memory segment to be defined for use in
- transmit and receive windowing operations. These boards
- are listed in the below switch. In the case of the XI the
- amount of memory on the board is variable so the memory_seg
- is also variable. This code determines what they segment
- should be.
- ----------------------------------------------------------------- */
- switch (bd->type)
- { /* Begin switch on bd->type {board type} */
- case PCXE:
- case PCXEVE:
- case PC64XE:
- bd->memory_seg = 0xf000;
- break;
- case PCXI:
- board_id = inb((int)bd->port);
- if ((board_id & 0x1) == 0x1)
- { /* Begin it's an XI card */
- /* Is it a 64K board */
- if ((board_id & 0x30) == 0)
- bd->memory_seg = 0xf000;
- /* Is it a 128K board */
- if ((board_id & 0x30) == 0x10)
- bd->memory_seg = 0xe000;
- /* Is is a 256K board */
- if ((board_id & 0x30) == 0x20)
- bd->memory_seg = 0xc000;
- /* Is it a 512K board */
- if ((board_id & 0x30) == 0x30)
- bd->memory_seg = 0x8000;
- } /* End it is an XI card */
- else
- {
- printk(KERN_ERR "<Error> - Board at 0x%x doesn't appear to be an XI\n",(int)bd->port);
- }
- break;
- } /* End switch on bd->type */
- } /* End for each card */
- if (tty_register_driver(pc_driver))
- panic("Couldn't register Digi PC/ driver");
- if (tty_register_driver(pc_info))
- panic("Couldn't register Digi PC/ info ");
- /* -------------------------------------------------------------------
- Start up the poller to check for events on all enabled boards
- ---------------------------------------------------------------------- */
- init_timer(&epca_timer);
- epca_timer.function = epcapoll;
- mod_timer(&epca_timer, jiffies + HZ/25);
- restore_flags(flags);
- return 0;
- } /* End pc_init */
- /* ------------------ Begin post_fep_init ---------------------- */
- static void post_fep_init(unsigned int crd)
- { /* Begin post_fep_init */
- int i;
- unchar *memaddr;
- volatile struct global_data *gd;
- struct board_info *bd;
- volatile struct board_chan *bc;
- struct channel *ch;
- int shrinkmem = 0, lowwater ;
-
- /* -------------------------------------------------------------
- This call is made by the user via. the ioctl call DIGI_INIT.
- It is responsible for setting up all the card specific stuff.
- ---------------------------------------------------------------- */
- bd = &boards[crd];
- /* -----------------------------------------------------------------
- If this is a PCI board, get the port info. Remember PCI cards
- do not have entries into the epcaconfig.h file, so we can't get
- the number of ports from it. Unfortunetly, this means that anyone
- doing a DIGI_GETINFO before the board has booted will get an invalid
- number of ports returned (It should return 0). Calls to DIGI_GETINFO
- after DIGI_INIT has been called will return the proper values.
- ------------------------------------------------------------------- */
- if (bd->type >= PCIXEM) /* If the board in question is PCI */
- { /* Begin get PCI number of ports */
- /* --------------------------------------------------------------------
- Below we use XEMPORTS as a memory offset regardless of which PCI
- card it is. This is because all of the supported PCI cards have
- the same memory offset for the channel data. This will have to be
- changed if we ever develop a PCI/XE card. NOTE : The FEP manual
- states that the port offset is 0xC22 as opposed to 0xC02. This is
- only true for PC/XE, and PC/XI cards; not for the XEM, or CX series.
- On the PCI cards the number of ports is determined by reading a
- ID PROM located in the box attached to the card. The card can then
- determine the index the id to determine the number of ports available.
- (FYI - The id should be located at 0x1ac (And may use up to 4 bytes
- if the box in question is a XEM or CX)).
- ------------------------------------------------------------------------ */
- bd->numports = (unsigned short)*(unsigned char *)bus_to_virt((unsigned long)
- (bd->re_map_membase + XEMPORTS));
-
- epcaassert(bd->numports <= 64,"PCI returned a invalid number of ports");
- nbdevs += (bd->numports);
- } /* End get PCI number of ports */
- if (crd != 0)
- card_ptr[crd] = card_ptr[crd-1] + boards[crd-1].numports;
- else
- card_ptr[crd] = &digi_channels[crd]; /* <- For card 0 only */
- ch = card_ptr[crd];
- epcaassert(ch <= &digi_channels[nbdevs - 1], "ch out of range");
- memaddr = (unchar *)bd->re_map_membase;
- /*
- The below command is necessary because newer kernels (2.1.x and
- up) do not have a 1:1 virtual to physical mapping. The below
- call adjust…