Commit 6cc56834 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by David S. Miller

isdn: remove spellcaster driver

The 'sc' ISDN driver relies on using readl() to access ISA I/O memory.
This has been deprecated and produced warnings since linux-2.3.23,
disabled by default since 2.4.10 and finally removed in 2.6.5.

I found this because the compiling the driver for ARM produces
a warning:

In file included from ../drivers/isdn/sc/includes.h:8:0,
                 from ../drivers/isdn/sc/init.c:13:
../arch/arm/include/asm/io.h:115:21: note: expected 'const volatile void *' but argument is of type 'long unsigned int'

It is pretty clear that this driver has not been used for a long time
and there is no point fixing it now, so let's remove it.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2f7a791c
......@@ -10,7 +10,6 @@ obj-$(CONFIG_ISDN_DIVERSION) += divert/
obj-$(CONFIG_ISDN_DRV_HISAX) += hisax/
obj-$(CONFIG_ISDN_DRV_ICN) += icn/
obj-$(CONFIG_ISDN_DRV_PCBIT) += pcbit/
obj-$(CONFIG_ISDN_DRV_SC) += sc/
obj-$(CONFIG_ISDN_DRV_LOOP) += isdnloop/
obj-$(CONFIG_ISDN_DRV_ACT2000) += act2000/
obj-$(CONFIG_HYSDN) += hysdn/
......
......@@ -130,8 +130,6 @@ source "drivers/isdn/icn/Kconfig"
source "drivers/isdn/pcbit/Kconfig"
source "drivers/isdn/sc/Kconfig"
source "drivers/isdn/act2000/Kconfig"
endmenu
......
config ISDN_DRV_SC
tristate "Spellcaster support"
depends on ISA
help
This enables support for the Spellcaster BRI ISDN boards. This
driver currently builds only in a modularized version.
To build it, choose M here: the module will be called sc.
See <file:Documentation/isdn/README.sc> for more information.
# Makefile for the sc ISDN device driver
# Each configuration option enables a list of files.
obj-$(CONFIG_ISDN_DRV_SC) += sc.o
# Multipart objects.
sc-y := shmem.o init.o packet.o command.o event.o \
ioctl.o interrupt.o message.o timer.o
/* $Id: card.h,v 1.1.10.1 2001/09/23 22:24:59 kai Exp $
*
* Driver parameters for SpellCaster ISA ISDN adapters
*
* Copyright (C) 1996 SpellCaster Telecommunications Inc.
*
* This software may be used and distributed according to the terms
* of the GNU General Public License, incorporated herein by reference.
*
* For more information, please contact gpl-info@spellcast.com or write:
*
* SpellCaster Telecommunications Inc.
* 5621 Finch Avenue East, Unit #3
* Scarborough, Ontario Canada
* M1B 2T9
* +1 (416) 297-8565
* +1 (416) 297-6433 Facsimile
*/
#ifndef CARD_H
#define CARD_H
/*
* We need these if they're not already included
*/
#include <linux/timer.h>
#include <linux/time.h>
#include <linux/isdnif.h>
#include <linux/irqreturn.h>
#include "message.h"
#include "scioc.h"
/*
* Amount of time to wait for a reset to complete
*/
#define CHECKRESET_TIME msecs_to_jiffies(4000)
/*
* Amount of time between line status checks
*/
#define CHECKSTAT_TIME msecs_to_jiffies(8000)
/*
* The maximum amount of time to wait for a message response
* to arrive. Use exclusively by send_and_receive
*/
#define SAR_TIMEOUT msecs_to_jiffies(10000)
/*
* Macro to determine is a card id is valid
*/
#define IS_VALID_CARD(x) ((x >= 0) && (x <= cinst))
/*
* Per channel status and configuration
*/
typedef struct {
int l2_proto;
int l3_proto;
char dn[50];
unsigned long first_sendbuf; /* Offset of first send buffer */
unsigned int num_sendbufs; /* Number of send buffers */
unsigned int free_sendbufs; /* Number of free sendbufs */
unsigned int next_sendbuf; /* Next sequential buffer */
char eazlist[50]; /* Set with SETEAZ */
char sillist[50]; /* Set with SETSIL */
int eazclear; /* Don't accept calls if TRUE */
} bchan;
/*
* Everything you want to know about the adapter ...
*/
typedef struct {
int model;
int driverId; /* LL Id */
char devicename[20]; /* The device name */
isdn_if *card; /* ISDN4Linux structure */
bchan *channel; /* status of the B channels */
char nChannels; /* Number of channels */
unsigned int interrupt; /* Interrupt number */
int iobase; /* I/O Base address */
int ioport[MAX_IO_REGS]; /* Index to I/O ports */
int shmem_pgport; /* port for the exp mem page reg. */
int shmem_magic; /* adapter magic number */
unsigned int rambase; /* Shared RAM base address */
unsigned int ramsize; /* Size of shared memory */
RspMessage async_msg; /* Async response message */
int want_async_messages; /* Snoop the Q ? */
unsigned char seq_no; /* Next send seq. number */
struct timer_list reset_timer; /* Check reset timer */
struct timer_list stat_timer; /* Check startproc timer */
unsigned char nphystat; /* Latest PhyStat info */
unsigned char phystat; /* Last PhyStat info */
HWConfig_pl hwconfig; /* Hardware config info */
char load_ver[11]; /* CommManage Version string */
char proc_ver[11]; /* CommEngine Version */
int StartOnReset; /* Indicates startproc after reset */
int EngineUp; /* Indicates CommEngine Up */
int trace_mode; /* Indicate if tracing is on */
spinlock_t lock; /* local lock */
} board;
extern board *sc_adapter[];
extern int cinst;
void memcpy_toshmem(int card, void *dest, const void *src, size_t n);
void memcpy_fromshmem(int card, void *dest, const void *src, size_t n);
int get_card_from_id(int driver);
int indicate_status(int card, int event, ulong Channel, char *Data);
irqreturn_t interrupt_handler(int interrupt, void *cardptr);
int sndpkt(int devId, int channel, int ack, struct sk_buff *data);
void rcvpkt(int card, RspMessage *rcvmsg);
int command(isdn_ctrl *cmd);
int reset(int card);
int startproc(int card);
int send_and_receive(int card, unsigned int procid, unsigned char type,
unsigned char class, unsigned char code,
unsigned char link, unsigned char data_len,
unsigned char *data, RspMessage *mesgdata, int timeout);
void flushreadfifo(int card);
int sendmessage(int card, unsigned int procid, unsigned int type,
unsigned int class, unsigned int code, unsigned int link,
unsigned int data_len, unsigned int *data);
int receivemessage(int card, RspMessage *rspmsg);
int sc_ioctl(int card, scs_ioctl *data);
int setup_buffers(int card, int c);
void sc_check_reset(unsigned long data);
void check_phystat(unsigned long data);
#endif /* CARD_H */
/* $Id: command.c,v 1.4.10.1 2001/09/23 22:24:59 kai Exp $
*
* Copyright (C) 1996 SpellCaster Telecommunications Inc.
*
* This software may be used and distributed according to the terms
* of the GNU General Public License, incorporated herein by reference.
*
* For more information, please contact gpl-info@spellcast.com or write:
*
* SpellCaster Telecommunications Inc.
* 5621 Finch Avenue East, Unit #3
* Scarborough, Ontario Canada
* M1B 2T9
* +1 (416) 297-8565
* +1 (416) 297-6433 Facsimile
*/
#include <linux/module.h>
#include "includes.h" /* This must be first */
#include "hardware.h"
#include "message.h"
#include "card.h"
#include "scioc.h"
static int dial(int card, unsigned long channel, setup_parm setup);
static int hangup(int card, unsigned long channel);
static int answer(int card, unsigned long channel);
static int clreaz(int card, unsigned long channel);
static int seteaz(int card, unsigned long channel, char *);
static int setl2(int card, unsigned long arg);
static int setl3(int card, unsigned long arg);
static int acceptb(int card, unsigned long channel);
#ifdef DEBUG
/*
* Translate command codes to strings
*/
static char *commands[] = { "ISDN_CMD_IOCTL",
"ISDN_CMD_DIAL",
"ISDN_CMD_ACCEPTB",
"ISDN_CMD_ACCEPTB",
"ISDN_CMD_HANGUP",
"ISDN_CMD_CLREAZ",
"ISDN_CMD_SETEAZ",
NULL,
NULL,
NULL,
"ISDN_CMD_SETL2",
NULL,
"ISDN_CMD_SETL3",
NULL,
NULL,
NULL,
NULL,
NULL, };
/*
* Translates ISDN4Linux protocol codes to strings for debug messages
*/
static char *l3protos[] = { "ISDN_PROTO_L3_TRANS" };
static char *l2protos[] = { "ISDN_PROTO_L2_X75I",
"ISDN_PROTO_L2_X75UI",
"ISDN_PROTO_L2_X75BUI",
"ISDN_PROTO_L2_HDLC",
"ISDN_PROTO_L2_TRANS" };
#endif
int get_card_from_id(int driver)
{
int i;
for (i = 0; i < cinst; i++) {
if (sc_adapter[i]->driverId == driver)
return i;
}
return -ENODEV;
}
/*
* command
*/
int command(isdn_ctrl *cmd)
{
int card;
card = get_card_from_id(cmd->driver);
if (!IS_VALID_CARD(card)) {
pr_debug("Invalid param: %d is not a valid card id\n", card);
return -ENODEV;
}
/*
* Dispatch the command
*/
switch (cmd->command) {
case ISDN_CMD_IOCTL:
{
unsigned long cmdptr;
scs_ioctl ioc;
memcpy(&cmdptr, cmd->parm.num, sizeof(unsigned long));
if (copy_from_user(&ioc, (scs_ioctl __user *)cmdptr,
sizeof(scs_ioctl))) {
pr_debug("%s: Failed to verify user space 0x%lx\n",
sc_adapter[card]->devicename, cmdptr);
return -EFAULT;
}
return sc_ioctl(card, &ioc);
}
case ISDN_CMD_DIAL:
return dial(card, cmd->arg, cmd->parm.setup);
case ISDN_CMD_HANGUP:
return hangup(card, cmd->arg);
case ISDN_CMD_ACCEPTD:
return answer(card, cmd->arg);
case ISDN_CMD_ACCEPTB:
return acceptb(card, cmd->arg);
case ISDN_CMD_CLREAZ:
return clreaz(card, cmd->arg);
case ISDN_CMD_SETEAZ:
return seteaz(card, cmd->arg, cmd->parm.num);
case ISDN_CMD_SETL2:
return setl2(card, cmd->arg);
case ISDN_CMD_SETL3:
return setl3(card, cmd->arg);
default:
return -EINVAL;
}
return 0;
}
/*
* start the onboard firmware
*/
int startproc(int card)
{
int status;
if (!IS_VALID_CARD(card)) {
pr_debug("Invalid param: %d is not a valid card id\n", card);
return -ENODEV;
}
/*
* send start msg
*/
status = sendmessage(card, CMPID, cmReqType2,
cmReqClass0,
cmReqStartProc,
0, 0, NULL);
pr_debug("%s: Sent startProc\n", sc_adapter[card]->devicename);
return status;
}
/*
* Dials the number passed in
*/
static int dial(int card, unsigned long channel, setup_parm setup)
{
int status;
char Phone[48];
if (!IS_VALID_CARD(card)) {
pr_debug("Invalid param: %d is not a valid card id\n", card);
return -ENODEV;
}
/*extract ISDN number to dial from eaz/msn string*/
strcpy(Phone, setup.phone);
/*send the connection message*/
status = sendmessage(card, CEPID, ceReqTypePhy,
ceReqClass1,
ceReqPhyConnect,
(unsigned char)channel + 1,
strlen(Phone),
(unsigned int *)Phone);
pr_debug("%s: Dialing %s on channel %lu\n",
sc_adapter[card]->devicename, Phone, channel + 1);
return status;
}
/*
* Answer an incoming call
*/
static int answer(int card, unsigned long channel)
{
if (!IS_VALID_CARD(card)) {
pr_debug("Invalid param: %d is not a valid card id\n", card);
return -ENODEV;
}
if (setup_buffers(card, channel + 1)) {
hangup(card, channel + 1);
return -ENOBUFS;
}
indicate_status(card, ISDN_STAT_BCONN, channel, NULL);
pr_debug("%s: Answered incoming call on channel %lu\n",
sc_adapter[card]->devicename, channel + 1);
return 0;
}
/*
* Hangup up the call on specified channel
*/
static int hangup(int card, unsigned long channel)
{
int status;
if (!IS_VALID_CARD(card)) {
pr_debug("Invalid param: %d is not a valid card id\n", card);
return -ENODEV;
}
status = sendmessage(card, CEPID, ceReqTypePhy,
ceReqClass1,
ceReqPhyDisconnect,
(unsigned char)channel + 1,
0,
NULL);
pr_debug("%s: Sent HANGUP message to channel %lu\n",
sc_adapter[card]->devicename, channel + 1);
return status;
}
/*
* Set the layer 2 protocol (X.25, HDLC, Raw)
*/
static int setl2(int card, unsigned long arg)
{
int status = 0;
int protocol, channel;
if (!IS_VALID_CARD(card)) {
pr_debug("Invalid param: %d is not a valid card id\n", card);
return -ENODEV;
}
protocol = arg >> 8;
channel = arg & 0xff;
sc_adapter[card]->channel[channel].l2_proto = protocol;
/*
* check that the adapter is also set to the correct protocol
*/
pr_debug("%s: Sending GetFrameFormat for channel %d\n",
sc_adapter[card]->devicename, channel + 1);
status = sendmessage(card, CEPID, ceReqTypeCall,
ceReqClass0,
ceReqCallGetFrameFormat,
(unsigned char)channel + 1,
1,
(unsigned int *)protocol);
if (status)
return status;
return 0;
}
/*
* Set the layer 3 protocol
*/
static int setl3(int card, unsigned long channel)
{
int protocol = channel >> 8;
if (!IS_VALID_CARD(card)) {
pr_debug("Invalid param: %d is not a valid card id\n", card);
return -ENODEV;
}
sc_adapter[card]->channel[channel].l3_proto = protocol;
return 0;
}
static int acceptb(int card, unsigned long channel)
{
if (!IS_VALID_CARD(card)) {
pr_debug("Invalid param: %d is not a valid card id\n", card);
return -ENODEV;
}
if (setup_buffers(card, channel + 1))
{
hangup(card, channel + 1);
return -ENOBUFS;
}
pr_debug("%s: B-Channel connection accepted on channel %lu\n",
sc_adapter[card]->devicename, channel + 1);
indicate_status(card, ISDN_STAT_BCONN, channel, NULL);
return 0;
}
static int clreaz(int card, unsigned long arg)
{
if (!IS_VALID_CARD(card)) {
pr_debug("Invalid param: %d is not a valid card id\n", card);
return -ENODEV;
}
strcpy(sc_adapter[card]->channel[arg].eazlist, "");
sc_adapter[card]->channel[arg].eazclear = 1;
pr_debug("%s: EAZ List cleared for channel %lu\n",
sc_adapter[card]->devicename, arg + 1);
return 0;
}
static int seteaz(int card, unsigned long arg, char *num)
{
if (!IS_VALID_CARD(card)) {
pr_debug("Invalid param: %d is not a valid card id\n", card);
return -ENODEV;
}
strcpy(sc_adapter[card]->channel[arg].eazlist, num);
sc_adapter[card]->channel[arg].eazclear = 0;
pr_debug("%s: EAZ list for channel %lu set to: %s\n",
sc_adapter[card]->devicename, arg + 1,
sc_adapter[card]->channel[arg].eazlist);
return 0;
}
int reset(int card)
{
unsigned long flags;
if (!IS_VALID_CARD(card)) {
pr_debug("Invalid param: %d is not a valid card id\n", card);
return -ENODEV;
}
indicate_status(card, ISDN_STAT_STOP, 0, NULL);
if (sc_adapter[card]->EngineUp) {
del_timer(&sc_adapter[card]->stat_timer);
}
sc_adapter[card]->EngineUp = 0;
spin_lock_irqsave(&sc_adapter[card]->lock, flags);
init_timer(&sc_adapter[card]->reset_timer);
sc_adapter[card]->reset_timer.function = sc_check_reset;
sc_adapter[card]->reset_timer.data = card;
sc_adapter[card]->reset_timer.expires = jiffies + CHECKRESET_TIME;
add_timer(&sc_adapter[card]->reset_timer);
spin_unlock_irqrestore(&sc_adapter[card]->lock, flags);
outb(0x1, sc_adapter[card]->ioport[SFT_RESET]);
pr_debug("%s: Adapter Reset\n", sc_adapter[card]->devicename);
return 0;
}
void flushreadfifo(int card)
{
while (inb(sc_adapter[card]->ioport[FIFO_STATUS]) & RF_HAS_DATA)
inb(sc_adapter[card]->ioport[FIFO_READ]);
}
/* $Id: event.c,v 1.4.8.1 2001/09/23 22:24:59 kai Exp $
*
* Copyright (C) 1996 SpellCaster Telecommunications Inc.
*
* This software may be used and distributed according to the terms
* of the GNU General Public License, incorporated herein by reference.
*
* For more information, please contact gpl-info@spellcast.com or write:
*
* SpellCaster Telecommunications Inc.
* 5621 Finch Avenue East, Unit #3
* Scarborough, Ontario Canada
* M1B 2T9
* +1 (416) 297-8565
* +1 (416) 297-6433 Facsimile
*/
#include "includes.h"
#include "hardware.h"
#include "message.h"
#include "card.h"
#ifdef DEBUG
static char *events[] = { "ISDN_STAT_STAVAIL",
"ISDN_STAT_ICALL",
"ISDN_STAT_RUN",
"ISDN_STAT_STOP",
"ISDN_STAT_DCONN",
"ISDN_STAT_BCONN",
"ISDN_STAT_DHUP",
"ISDN_STAT_BHUP",
"ISDN_STAT_CINF",
"ISDN_STAT_LOAD",
"ISDN_STAT_UNLOAD",
"ISDN_STAT_BSENT",
"ISDN_STAT_NODCH",
"ISDN_STAT_ADDCH",
"ISDN_STAT_CAUSE" };
#endif
int indicate_status(int card, int event, ulong Channel, char *Data)
{
isdn_ctrl cmd;
#ifdef DEBUG
pr_debug("%s: Indicating event %s on Channel %d\n",
sc_adapter[card]->devicename, events[event - 256], Channel);
#endif
if (Data != NULL) {
pr_debug("%s: Event data: %s\n", sc_adapter[card]->devicename,
Data);
switch (event) {
case ISDN_STAT_BSENT:
memcpy(&cmd.parm.length, Data, sizeof(cmd.parm.length));
break;
case ISDN_STAT_ICALL:
memcpy(&cmd.parm.setup, Data, sizeof(cmd.parm.setup));
break;
default:
strlcpy(cmd.parm.num, Data, sizeof(cmd.parm.num));
}
}
cmd.command = event;
cmd.driver = sc_adapter[card]->driverId;
cmd.arg = Channel;
return sc_adapter[card]->card->statcallb(&cmd);
}
/*
* Hardware specific macros, defines and structures
*
* This software may be used and distributed according to the terms
* of the GNU General Public License, incorporated herein by reference.
*
*/
#ifndef HARDWARE_H
#define HARDWARE_H
#include <asm/param.h> /* For HZ */
/*
* General hardware parameters common to all ISA adapters
*/
#define MAX_CARDS 4 /* The maximum number of cards to
control or probe for. */
#define SIGNATURE 0x87654321 /* Board reset signature */
#define SIG_OFFSET 0x1004 /* Where to find signature in shared RAM */
#define TRACE_OFFSET 0x1008 /* Trace enable word offset in shared RAM */
#define BUFFER_OFFSET 0x1800 /* Beginning of buffers */
/* I/O Port parameters */
#define IOBASE_MIN 0x180 /* Lowest I/O port address */
#define IOBASE_MAX 0x3C0 /* Highest I/O port address */
#define IOBASE_OFFSET 0x20 /* Inter-board I/O port gap used during
probing */
#define FIFORD_OFFSET 0x0
#define FIFOWR_OFFSET 0x400
#define FIFOSTAT_OFFSET 0x1000
#define RESET_OFFSET 0x2800
#define PG0_OFFSET 0x3000 /* Offset from I/O Base for Page 0 register */
#define PG1_OFFSET 0x3400 /* Offset from I/O Base for Page 1 register */
#define PG2_OFFSET 0x3800 /* Offset from I/O Base for Page 2 register */
#define PG3_OFFSET 0x3C00 /* Offset from I/O Base for Page 3 register */
#define FIFO_READ 0 /* FIFO Read register */
#define FIFO_WRITE 1 /* FIFO Write rgister */
#define LO_ADDR_PTR 2 /* Extended RAM Low Addr Pointer */
#define HI_ADDR_PTR 3 /* Extended RAM High Addr Pointer */
#define NOT_USED_1 4
#define FIFO_STATUS 5 /* FIFO Status Register */
#define NOT_USED_2 6
#define MEM_OFFSET 7
#define SFT_RESET 10 /* Reset Register */
#define EXP_BASE 11 /* Shared RAM Base address */
#define EXP_PAGE0 12 /* Shared RAM Page0 register */
#define EXP_PAGE1 13 /* Shared RAM Page1 register */
#define EXP_PAGE2 14 /* Shared RAM Page2 register */
#define EXP_PAGE3 15 /* Shared RAM Page3 register */
#define IRQ_SELECT 16 /* IRQ selection register */
#define MAX_IO_REGS 17 /* Total number of I/O ports */
/* FIFO register values */
#define RF_HAS_DATA 0x01 /* fifo has data */
#define RF_QUART_FULL 0x02 /* fifo quarter full */
#define RF_HALF_FULL 0x04 /* fifo half full */
#define RF_NOT_FULL 0x08 /* fifo not full */
#define WF_HAS_DATA 0x10 /* fifo has data */
#define WF_QUART_FULL 0x20 /* fifo quarter full */
#define WF_HALF_FULL 0x40 /* fifo half full */
#define WF_NOT_FULL 0x80 /* fifo not full */
/* Shared RAM parameters */
#define SRAM_MIN 0xC0000 /* Lowest host shared RAM address */
#define SRAM_MAX 0xEFFFF /* Highest host shared RAM address */
#define SRAM_PAGESIZE 0x4000 /* Size of one RAM page (16K) */
/* Shared RAM buffer parameters */
#define BUFFER_SIZE 0x800 /* The size of a buffer in bytes */
#define BUFFER_BASE BUFFER_OFFSET /* Offset from start of shared RAM
where buffer start */
#define BUFFERS_MAX 16 /* Maximum number of send/receive
buffers per channel */
#define HDLC_PROTO 0x01 /* Frame Format for Layer 2 */
#define BRI_BOARD 0
#define POTS_BOARD 1
#define PRI_BOARD 2
/*
* Specific hardware parameters for the DataCommute/BRI
*/
#define BRI_CHANNELS 2 /* Number of B channels */
#define BRI_BASEPG_VAL 0x98
#define BRI_MAGIC 0x60000 /* Magic Number */
#define BRI_MEMSIZE 0x10000 /* Amount of RAM (64K) */
#define BRI_PARTNO "72-029"
#define BRI_FEATURES ISDN_FEATURE_L2_HDLC | ISDN_FEATURE_L3_TRANS;
/*
* Specific hardware parameters for the DataCommute/PRI
*/
#define PRI_CHANNELS 23 /* Number of B channels */
#define PRI_BASEPG_VAL 0x88
#define PRI_MAGIC 0x20000 /* Magic Number */
#define PRI_MEMSIZE 0x100000 /* Amount of RAM (1M) */
#define PRI_PARTNO "72-030"
#define PRI_FEATURES ISDN_FEATURE_L2_HDLC | ISDN_FEATURE_L3_TRANS;
/*
* Some handy macros
*/
/* Determine if a channel number is valid for the adapter */
#define IS_VALID_CHANNEL(y, x) ((x > 0) && (x <= sc_adapter[y]->channels))
#endif
/*
* This software may be used and distributed according to the terms
* of the GNU General Public License, incorporated herein by reference.
*
*/
#include <linux/errno.h>
#include <asm/io.h>
#include <linux/delay.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/mm.h>
#include <linux/ioport.h>
#include <linux/timer.h>
#include <linux/wait.h>
#include <linux/isdnif.h>
This diff is collapsed.
/* $Id: interrupt.c,v 1.4.8.3 2001/09/23 22:24:59 kai Exp $
*
* Copyright (C) 1996 SpellCaster Telecommunications Inc.
*
* This software may be used and distributed according to the terms
* of the GNU General Public License, incorporated herein by reference.
*
* For more information, please contact gpl-info@spellcast.com or write:
*
* SpellCaster Telecommunications Inc.
* 5621 Finch Avenue East, Unit #3
* Scarborough, Ontario Canada
* M1B 2T9
* +1 (416) 297-8565
* +1 (416) 297-6433 Facsimile
*/
#include "includes.h"
#include "hardware.h"
#include "message.h"
#include "card.h"
#include <linux/interrupt.h>
/*
*
*/
irqreturn_t interrupt_handler(int dummy, void *card_inst)
{
RspMessage rcvmsg;
int channel;
int card = (int)(unsigned long) card_inst;
if (!IS_VALID_CARD(card)) {
pr_debug("Invalid param: %d is not a valid card id\n", card);
return IRQ_NONE;
}
pr_debug("%s: Entered Interrupt handler\n",
sc_adapter[card]->devicename);
/*
* Pull all of the waiting messages off the response queue
*/
while (!receivemessage(card, &rcvmsg)) {
/*
* Push the message to the adapter structure for
* send_and_receive to snoop
*/
if (sc_adapter[card]->want_async_messages)
memcpy(&(sc_adapter[card]->async_msg),
&rcvmsg, sizeof(RspMessage));
channel = (unsigned int) rcvmsg.phy_link_no;
/*
* Trap Invalid request messages
*/
if (IS_CM_MESSAGE(rcvmsg, 0, 0, Invalid)) {
pr_debug("%s: Invalid request Message, rsp_status = %d\n",
sc_adapter[card]->devicename,
rcvmsg.rsp_status);
break;
}
/*
* Check for a linkRead message
*/
if (IS_CE_MESSAGE(rcvmsg, Lnk, 1, Read))
{
pr_debug("%s: Received packet 0x%x bytes long at 0x%lx\n",
sc_adapter[card]->devicename,
rcvmsg.msg_data.response.msg_len,
rcvmsg.msg_data.response.buff_offset);
rcvpkt(card, &rcvmsg);
continue;
}
/*
* Handle a write acknoledgement
*/
if (IS_CE_MESSAGE(rcvmsg, Lnk, 1, Write)) {
pr_debug("%s: Packet Send ACK on channel %d\n",
sc_adapter[card]->devicename,
rcvmsg.phy_link_no);
sc_adapter[card]->channel[rcvmsg.phy_link_no - 1].free_sendbufs++;
continue;
}
/*
* Handle a connection message
*/
if (IS_CE_MESSAGE(rcvmsg, Phy, 1, Connect))
{
unsigned int callid;
setup_parm setup;
pr_debug("%s: Connect message: line %d: status %d: cause 0x%x\n",
sc_adapter[card]->devicename,
rcvmsg.phy_link_no,
rcvmsg.rsp_status,
rcvmsg.msg_data.byte_array[2]);
memcpy(&callid, rcvmsg.msg_data.byte_array, sizeof(int));
if (callid >= 0x8000 && callid <= 0xFFFF)
{
pr_debug("%s: Got Dial-Out Rsp\n",
sc_adapter[card]->devicename);
indicate_status(card, ISDN_STAT_DCONN,
(unsigned long)rcvmsg.phy_link_no - 1, NULL);
}
else if (callid >= 0x0000 && callid <= 0x7FFF)
{
int len;
pr_debug("%s: Got Incoming Call\n",
sc_adapter[card]->devicename);
len = strlcpy(setup.phone, &(rcvmsg.msg_data.byte_array[4]),
sizeof(setup.phone));
if (len >= sizeof(setup.phone))
continue;
len = strlcpy(setup.eazmsn,
sc_adapter[card]->channel[rcvmsg.phy_link_no - 1].dn,
sizeof(setup.eazmsn));
if (len >= sizeof(setup.eazmsn))
continue;
setup.si1 = 7;
setup.si2 = 0;
setup.plan = 0;
setup.screen = 0;
indicate_status(card, ISDN_STAT_ICALL, (unsigned long)rcvmsg.phy_link_no - 1, (char *)&setup);
indicate_status(card, ISDN_STAT_DCONN, (unsigned long)rcvmsg.phy_link_no - 1, NULL);
}
continue;
}
/*
* Handle a disconnection message
*/
if (IS_CE_MESSAGE(rcvmsg, Phy, 1, Disconnect))
{
pr_debug("%s: disconnect message: line %d: status %d: cause 0x%x\n",
sc_adapter[card]->devicename,
rcvmsg.phy_link_no,
rcvmsg.rsp_status,
rcvmsg.msg_data.byte_array[2]);
indicate_status(card, ISDN_STAT_BHUP, (unsigned long)rcvmsg.phy_link_no - 1, NULL);
indicate_status(card, ISDN_STAT_DHUP, (unsigned long)rcvmsg.phy_link_no - 1, NULL);
continue;
}
/*
* Handle a startProc engine up message
*/
if (IS_CM_MESSAGE(rcvmsg, 5, 0, MiscEngineUp)) {
pr_debug("%s: Received EngineUp message\n",
sc_adapter[card]->devicename);
sc_adapter[card]->EngineUp = 1;
sendmessage(card, CEPID, ceReqTypeCall, ceReqClass0, ceReqCallGetMyNumber, 1, 0, NULL);
sendmessage(card, CEPID, ceReqTypeCall, ceReqClass0, ceReqCallGetMyNumber, 2, 0, NULL);
init_timer(&sc_adapter[card]->stat_timer);
sc_adapter[card]->stat_timer.function = check_phystat;
sc_adapter[card]->stat_timer.data = card;
sc_adapter[card]->stat_timer.expires = jiffies + CHECKSTAT_TIME;
add_timer(&sc_adapter[card]->stat_timer);
continue;
}
/*
* Start proc response
*/
if (IS_CM_MESSAGE(rcvmsg, 2, 0, StartProc)) {
pr_debug("%s: StartProc Response Status %d\n",
sc_adapter[card]->devicename,
rcvmsg.rsp_status);
continue;
}
/*
* Handle a GetMyNumber Rsp
*/
if (IS_CE_MESSAGE(rcvmsg, Call, 0, GetMyNumber)) {
strlcpy(sc_adapter[card]->channel[rcvmsg.phy_link_no - 1].dn,
rcvmsg.msg_data.byte_array,
sizeof(rcvmsg.msg_data.byte_array));
continue;
}
/*
* PhyStatus response
*/
if (IS_CE_MESSAGE(rcvmsg, Phy, 2, Status)) {
unsigned int b1stat, b2stat;
/*
* Covert the message data to the adapter->phystat code
*/
b1stat = (unsigned int) rcvmsg.msg_data.byte_array[0];
b2stat = (unsigned int) rcvmsg.msg_data.byte_array[1];
sc_adapter[card]->nphystat = (b2stat >> 8) | b1stat; /* endian?? */
pr_debug("%s: PhyStat is 0x%2x\n",
sc_adapter[card]->devicename,
sc_adapter[card]->nphystat);
continue;
}
/*
* Handle a GetFramFormat
*/
if (IS_CE_MESSAGE(rcvmsg, Call, 0, GetFrameFormat)) {
if (rcvmsg.msg_data.byte_array[0] != HDLC_PROTO) {
unsigned int proto = HDLC_PROTO;
/*
* Set board format to HDLC if it wasn't already
*/
pr_debug("%s: current frame format: 0x%x, will change to HDLC\n",
sc_adapter[card]->devicename,
rcvmsg.msg_data.byte_array[0]);
sendmessage(card, CEPID, ceReqTypeCall,
ceReqClass0,
ceReqCallSetFrameFormat,
(unsigned char)channel + 1,
1, &proto);
}
continue;
}
/*
* Hmm...
*/
pr_debug("%s: Received unhandled message (%d,%d,%d) link %d\n",
sc_adapter[card]->devicename,
rcvmsg.type, rcvmsg.class, rcvmsg.code,
rcvmsg.phy_link_no);
} /* while */
pr_debug("%s: Exiting Interrupt Handler\n",
sc_adapter[card]->devicename);
return IRQ_HANDLED;
}
This diff is collapsed.
/* $Id: message.c,v 1.5.8.2 2001/09/23 22:24:59 kai Exp $
*
* functions for sending and receiving control messages
*
* Copyright (C) 1996 SpellCaster Telecommunications Inc.
*
* This software may be used and distributed according to the terms
* of the GNU General Public License, incorporated herein by reference.
*
* For more information, please contact gpl-info@spellcast.com or write:
*
* SpellCaster Telecommunications Inc.
* 5621 Finch Avenue East, Unit #3
* Scarborough, Ontario Canada
* M1B 2T9
* +1 (416) 297-8565
* +1 (416) 297-6433 Facsimile
*/
#include <linux/sched.h>
#include "includes.h"
#include "hardware.h"
#include "message.h"
#include "card.h"
/*
* receive a message from the board
*/
int receivemessage(int card, RspMessage *rspmsg)
{
DualPortMemory *dpm;
unsigned long flags;
if (!IS_VALID_CARD(card)) {
pr_debug("Invalid param: %d is not a valid card id\n", card);
return -EINVAL;
}
pr_debug("%s: Entered receivemessage\n",
sc_adapter[card]->devicename);
/*
* See if there are messages waiting
*/
if (inb(sc_adapter[card]->ioport[FIFO_STATUS]) & RF_HAS_DATA) {
/*
* Map in the DPM to the base page and copy the message
*/
spin_lock_irqsave(&sc_adapter[card]->lock, flags);
outb((sc_adapter[card]->shmem_magic >> 14) | 0x80,
sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]);
dpm = (DualPortMemory *) sc_adapter[card]->rambase;
memcpy_fromio(rspmsg, &(dpm->rsp_queue[dpm->rsp_tail]),
MSG_LEN);
dpm->rsp_tail = (dpm->rsp_tail + 1) % MAX_MESSAGES;
inb(sc_adapter[card]->ioport[FIFO_READ]);
spin_unlock_irqrestore(&sc_adapter[card]->lock, flags);
/*
* Tell the board that the message is received
*/
pr_debug("%s: Received Message seq:%d pid:%d time:%d cmd:%d "
"cnt:%d (type,class,code):(%d,%d,%d) "
"link:%d stat:0x%x\n",
sc_adapter[card]->devicename,
rspmsg->sequence_no,
rspmsg->process_id,
rspmsg->time_stamp,
rspmsg->cmd_sequence_no,
rspmsg->msg_byte_cnt,
rspmsg->type,
rspmsg->class,
rspmsg->code,
rspmsg->phy_link_no,
rspmsg->rsp_status);
return 0;
}
return -ENOMSG;
}
/*
* send a message to the board
*/
int sendmessage(int card,
unsigned int procid,
unsigned int type,
unsigned int class,
unsigned int code,
unsigned int link,
unsigned int data_len,
unsigned int *data)
{
DualPortMemory *dpm;
ReqMessage sndmsg;
unsigned long flags;
if (!IS_VALID_CARD(card)) {
pr_debug("Invalid param: %d is not a valid card id\n", card);
return -EINVAL;
}
/*
* Make sure we only send CEPID messages when the engine is up
* and CMPID messages when it is down
*/
if (sc_adapter[card]->EngineUp && procid == CMPID) {
pr_debug("%s: Attempt to send CM message with engine up\n",
sc_adapter[card]->devicename);
return -ESRCH;
}
if (!sc_adapter[card]->EngineUp && procid == CEPID) {
pr_debug("%s: Attempt to send CE message with engine down\n",
sc_adapter[card]->devicename);
return -ESRCH;
}
memset(&sndmsg, 0, MSG_LEN);
sndmsg.msg_byte_cnt = 4;
sndmsg.type = type;
sndmsg.class = class;
sndmsg.code = code;
sndmsg.phy_link_no = link;
if (data_len > 0) {
if (data_len > MSG_DATA_LEN)
data_len = MSG_DATA_LEN;
memcpy(&(sndmsg.msg_data), data, data_len);
sndmsg.msg_byte_cnt = data_len + 8;
}
sndmsg.process_id = procid;
sndmsg.sequence_no = sc_adapter[card]->seq_no++ % 256;
/*
* wait for an empty slot in the queue
*/
while (!(inb(sc_adapter[card]->ioport[FIFO_STATUS]) & WF_NOT_FULL))
udelay(1);
/*
* Disable interrupts and map in shared memory
*/
spin_lock_irqsave(&sc_adapter[card]->lock, flags);
outb((sc_adapter[card]->shmem_magic >> 14) | 0x80,
sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]);
dpm = (DualPortMemory *) sc_adapter[card]->rambase; /* Fix me */
memcpy_toio(&(dpm->req_queue[dpm->req_head]), &sndmsg, MSG_LEN);
dpm->req_head = (dpm->req_head + 1) % MAX_MESSAGES;
outb(sndmsg.sequence_no, sc_adapter[card]->ioport[FIFO_WRITE]);
spin_unlock_irqrestore(&sc_adapter[card]->lock, flags);
pr_debug("%s: Sent Message seq:%d pid:%d time:%d "
"cnt:%d (type,class,code):(%d,%d,%d) "
"link:%d\n ",
sc_adapter[card]->devicename,
sndmsg.sequence_no,
sndmsg.process_id,
sndmsg.time_stamp,
sndmsg.msg_byte_cnt,
sndmsg.type,
sndmsg.class,
sndmsg.code,
sndmsg.phy_link_no);
return 0;
}
int send_and_receive(int card,
unsigned int procid,
unsigned char type,
unsigned char class,
unsigned char code,
unsigned char link,
unsigned char data_len,
unsigned char *data,
RspMessage *mesgdata,
int timeout)
{
int retval;
int tries;
if (!IS_VALID_CARD(card)) {
pr_debug("Invalid param: %d is not a valid card id\n", card);
return -EINVAL;
}
sc_adapter[card]->want_async_messages = 1;
retval = sendmessage(card, procid, type, class, code, link,
data_len, (unsigned int *) data);
if (retval) {
pr_debug("%s: SendMessage failed in SAR\n",
sc_adapter[card]->devicename);
sc_adapter[card]->want_async_messages = 0;
return -EIO;
}
tries = 0;
/* wait for the response */
while (tries < timeout) {
schedule_timeout_interruptible(1);
pr_debug("SAR waiting..\n");
/*
* See if we got our message back
*/
if ((sc_adapter[card]->async_msg.type == type) &&
(sc_adapter[card]->async_msg.class == class) &&
(sc_adapter[card]->async_msg.code == code) &&
(sc_adapter[card]->async_msg.phy_link_no == link)) {
/*
* Got it!
*/
pr_debug("%s: Got ASYNC message\n",
sc_adapter[card]->devicename);
memcpy(mesgdata, &(sc_adapter[card]->async_msg),
sizeof(RspMessage));
sc_adapter[card]->want_async_messages = 0;
return 0;
}
tries++;
}
pr_debug("%s: SAR message timeout\n", sc_adapter[card]->devicename);
sc_adapter[card]->want_async_messages = 0;
return -ETIME;
}
/* $Id: message.h,v 1.1.10.1 2001/09/23 22:24:59 kai Exp $
*
* Copyright (C) 1996 SpellCaster Telecommunications Inc.
*
* structures, macros and defines useful for sending
* messages to the adapter
*
* This software may be used and distributed according to the terms
* of the GNU General Public License, incorporated herein by reference.
*
* For more information, please contact gpl-info@spellcast.com or write:
*
* SpellCaster Telecommunications Inc.
* 5621 Finch Avenue East, Unit #3
* Scarborough, Ontario Canada
* M1B 2T9
* +1 (416) 297-8565
* +1 (416) 297-6433 Facsimile
*/
/*
* Board message macros, defines and structures
*/
#ifndef MESSAGE_H
#define MESSAGE_H
#define MAX_MESSAGES 32 /* Maximum messages that can be
queued */
#define MSG_DATA_LEN 48 /* Maximum size of message payload */
#define MSG_LEN 64 /* Size of a message */
#define CMPID 0 /* Loader message process ID */
#define CEPID 64 /* Firmware message process ID */
/*
* Macro to determine if a message is a loader message
*/
#define IS_CM_MESSAGE(mesg, tx, cx, dx) \
((mesg.type == cmRspType##tx) \
&& (mesg.class == cmRspClass##cx) \
&& (mesg.code == cmRsp##dx))
/*
* Macro to determine if a message is a firmware message
*/
#define IS_CE_MESSAGE(mesg, tx, cx, dx) \
((mesg.type == ceRspType##tx) \
&& (mesg.class == ceRspClass##cx) \
&& (mesg.code == ceRsp##tx##dx))
/*
* Loader Request and Response Messages
*/
/* message types */
#define cmReqType1 1
#define cmReqType2 2
#define cmRspType0 0
#define cmRspType1 1
#define cmRspType2 2
#define cmRspType5 5
/* message classes */
#define cmReqClass0 0
#define cmRspClass0 0
/* message codes */
#define cmReqHWConfig 1 /* 1,0,1 */
#define cmReqMsgLpbk 2 /* 1,0,2 */
#define cmReqVersion 3 /* 1,0,3 */
#define cmReqLoadProc 1 /* 2,0,1 */
#define cmReqStartProc 2 /* 2,0,2 */
#define cmReqReadMem 6 /* 2,0,6 */
#define cmRspHWConfig cmReqHWConfig
#define cmRspMsgLpbk cmReqMsgLpbk
#define cmRspVersion cmReqVersion
#define cmRspLoadProc cmReqLoadProc
#define cmRspStartProc cmReqStartProc
#define cmRspReadMem cmReqReadMem
#define cmRspMiscEngineUp 1 /* 5,0,1 */
#define cmRspInvalid 0 /* 0,0,0 */
/*
* Firmware Request and Response Messages
*/
/* message types */
#define ceReqTypePhy 1
#define ceReqTypeLnk 2
#define ceReqTypeCall 3
#define ceReqTypeStat 1
#define ceRspTypeErr 0
#define ceRspTypePhy ceReqTypePhy
#define ceRspTypeLnk ceReqTypeLnk
#define ceRspTypeCall ceReqTypeCall
#define ceRspTypeStat ceReqTypeStat
/* message classes */
#define ceReqClass0 0
#define ceReqClass1 1
#define ceReqClass2 2
#define ceReqClass3 3
#define ceRspClass0 ceReqClass0
#define ceRspClass1 ceReqClass1
#define ceRspClass2 ceReqClass2
#define ceRspClass3 ceReqClass3
/* message codes (B) = BRI only, (P) = PRI only, (V) = POTS only */
#define ceReqPhyProcInfo 1 /* 1,0,1 */
#define ceReqPhyConnect 1 /* 1,1,1 */
#define ceReqPhyDisconnect 2 /* 1,1,2 */
#define ceReqPhySetParams 3 /* 1,1,3 (P) */
#define ceReqPhyGetParams 4 /* 1,1,4 (P) */
#define ceReqPhyStatus 1 /* 1,2,1 */
#define ceReqPhyAcfaStatus 2 /* 1,2,2 (P) */
#define ceReqPhyChCallState 3 /* 1,2,3 (P) */
#define ceReqPhyChServState 4 /* 1,2,4 (P) */
#define ceReqPhyRLoopBack 1 /* 1,3,1 */
#define ceRspPhyProcInfo ceReqPhyProcInfo
#define ceRspPhyConnect ceReqPhyConnect
#define ceRspPhyDisconnect ceReqPhyDisconnect
#define ceRspPhySetParams ceReqPhySetParams
#define ceRspPhyGetParams ceReqPhyGetParams
#define ceRspPhyStatus ceReqPhyStatus
#define ceRspPhyAcfaStatus ceReqPhyAcfaStatus
#define ceRspPhyChCallState ceReqPhyChCallState
#define ceRspPhyChServState ceReqPhyChServState
#define ceRspPhyRLoopBack ceReqphyRLoopBack
#define ceReqLnkSetParam 1 /* 2,0,1 */
#define ceReqLnkGetParam 2 /* 2,0,2 */
#define ceReqLnkGetStats 3 /* 2,0,3 */
#define ceReqLnkWrite 1 /* 2,1,1 */
#define ceReqLnkRead 2 /* 2,1,2 */
#define ceReqLnkFlush 3 /* 2,1,3 */
#define ceReqLnkWrBufTrc 4 /* 2,1,4 */
#define ceReqLnkRdBufTrc 5 /* 2,1,5 */
#define ceRspLnkSetParam ceReqLnkSetParam
#define ceRspLnkGetParam ceReqLnkGetParam
#define ceRspLnkGetStats ceReqLnkGetStats
#define ceRspLnkWrite ceReqLnkWrite
#define ceRspLnkRead ceReqLnkRead
#define ceRspLnkFlush ceReqLnkFlush
#define ceRspLnkWrBufTrc ceReqLnkWrBufTrc
#define ceRspLnkRdBufTrc ceReqLnkRdBufTrc
#define ceReqCallSetSwitchType 1 /* 3,0,1 */
#define ceReqCallGetSwitchType 2 /* 3,0,2 */
#define ceReqCallSetFrameFormat 3 /* 3,0,3 */
#define ceReqCallGetFrameFormat 4 /* 3,0,4 */
#define ceReqCallSetCallType 5 /* 3,0,5 */
#define ceReqCallGetCallType 6 /* 3,0,6 */
#define ceReqCallSetSPID 7 /* 3,0,7 (!P) */
#define ceReqCallGetSPID 8 /* 3,0,8 (!P) */
#define ceReqCallSetMyNumber 9 /* 3,0,9 (!P) */
#define ceReqCallGetMyNumber 10 /* 3,0,10 (!P) */
#define ceRspCallSetSwitchType ceReqCallSetSwitchType
#define ceRspCallGetSwitchType ceReqCallSetSwitchType
#define ceRspCallSetFrameFormat ceReqCallSetFrameFormat
#define ceRspCallGetFrameFormat ceReqCallGetFrameFormat
#define ceRspCallSetCallType ceReqCallSetCallType
#define ceRspCallGetCallType ceReqCallGetCallType
#define ceRspCallSetSPID ceReqCallSetSPID
#define ceRspCallGetSPID ceReqCallGetSPID
#define ceRspCallSetMyNumber ceReqCallSetMyNumber
#define ceRspCallGetMyNumber ceReqCallGetMyNumber
#define ceRspStatAcfaStatus 2
#define ceRspStat
#define ceRspErrError 0 /* 0,0,0 */
/*
* Call Types
*/
#define CALLTYPE_64K 0
#define CALLTYPE_56K 1
#define CALLTYPE_SPEECH 2
#define CALLTYPE_31KHZ 3
/*
* Link Level data contains a pointer to and the length of
* a buffer in shared RAM. Used by LnkRead and LnkWrite message
* types. Part of RspMsgStruct and ReqMsgStruct.
*/
typedef struct {
unsigned long buff_offset;
unsigned short msg_len;
} LLData;
/*
* Message payload template for an HWConfig message
*/
typedef struct {
char st_u_sense;
char powr_sense;
char sply_sense;
unsigned char asic_id;
long ram_size;
char serial_no[13];
char part_no[13];
char rev_no[2];
} HWConfig_pl;
/*
* A Message
*/
struct message {
unsigned char sequence_no;
unsigned char process_id;
unsigned char time_stamp;
unsigned char cmd_sequence_no; /* Rsp messages only */
unsigned char reserved1[3];
unsigned char msg_byte_cnt;
unsigned char type;
unsigned char class;
unsigned char code;
unsigned char phy_link_no;
unsigned char rsp_status; /* Rsp messages only */
unsigned char reseved2[3];
union {
unsigned char byte_array[MSG_DATA_LEN];
LLData response;
HWConfig_pl HWCresponse;
} msg_data;
};
typedef struct message ReqMessage; /* Request message */
typedef struct message RspMessage; /* Response message */
/*
* The first 5010 bytes of shared memory contain the message queues,
* indexes and other data. This structure is its template
*/
typedef struct {
volatile ReqMessage req_queue[MAX_MESSAGES];
volatile RspMessage rsp_queue[MAX_MESSAGES];
volatile unsigned char req_head;
volatile unsigned char req_tail;
volatile unsigned char rsp_head;
volatile unsigned char rsp_tail;
volatile unsigned long signature;
volatile unsigned long trace_enable;
volatile unsigned char reserved[4];
} DualPortMemory;
#endif
/* $Id: packet.c,v 1.5.8.1 2001/09/23 22:24:59 kai Exp $
*
* Copyright (C) 1996 SpellCaster Telecommunications Inc.
*
* This software may be used and distributed according to the terms
* of the GNU General Public License, incorporated herein by reference.
*
* For more information, please contact gpl-info@spellcast.com or write:
*
* SpellCaster Telecommunications Inc.
* 5621 Finch Avenue East, Unit #3
* Scarborough, Ontario Canada
* M1B 2T9
* +1 (416) 297-8565
* +1 (416) 297-6433 Facsimile
*/
#include "includes.h"
#include "hardware.h"
#include "message.h"
#include "card.h"
int sndpkt(int devId, int channel, int ack, struct sk_buff *data)
{
LLData ReqLnkWrite;
int status;
int card;
unsigned long len;
card = get_card_from_id(devId);
if (!IS_VALID_CARD(card)) {
pr_debug("invalid param: %d is not a valid card id\n", card);
return -ENODEV;
}
pr_debug("%s: sndpkt: frst = 0x%lx nxt = %d f = %d n = %d\n",
sc_adapter[card]->devicename,
sc_adapter[card]->channel[channel].first_sendbuf,
sc_adapter[card]->channel[channel].next_sendbuf,
sc_adapter[card]->channel[channel].free_sendbufs,
sc_adapter[card]->channel[channel].num_sendbufs);
if (!sc_adapter[card]->channel[channel].free_sendbufs) {
pr_debug("%s: out of TX buffers\n",
sc_adapter[card]->devicename);
return -EINVAL;
}
if (data->len > BUFFER_SIZE) {
pr_debug("%s: data overflows buffer size (data > buffer)\n",
sc_adapter[card]->devicename);
return -EINVAL;
}
ReqLnkWrite.buff_offset = sc_adapter[card]->channel[channel].next_sendbuf *
BUFFER_SIZE + sc_adapter[card]->channel[channel].first_sendbuf;
ReqLnkWrite.msg_len = data->len; /* sk_buff size */
pr_debug("%s: writing %d bytes to buffer offset 0x%lx\n",
sc_adapter[card]->devicename,
ReqLnkWrite.msg_len, ReqLnkWrite.buff_offset);
memcpy_toshmem(card, (char *)ReqLnkWrite.buff_offset, data->data, ReqLnkWrite.msg_len);
/*
* sendmessage
*/
pr_debug("%s: sndpkt size=%d, buf_offset=0x%lx buf_indx=%d\n",
sc_adapter[card]->devicename,
ReqLnkWrite.msg_len, ReqLnkWrite.buff_offset,
sc_adapter[card]->channel[channel].next_sendbuf);
status = sendmessage(card, CEPID, ceReqTypeLnk, ceReqClass1, ceReqLnkWrite,
channel + 1, sizeof(LLData), (unsigned int *)&ReqLnkWrite);
len = data->len;
if (status) {
pr_debug("%s: failed to send packet, status = %d\n",
sc_adapter[card]->devicename, status);
return -1;
}
else {
sc_adapter[card]->channel[channel].free_sendbufs--;
sc_adapter[card]->channel[channel].next_sendbuf =
++sc_adapter[card]->channel[channel].next_sendbuf ==
sc_adapter[card]->channel[channel].num_sendbufs ? 0 :
sc_adapter[card]->channel[channel].next_sendbuf;
pr_debug("%s: packet sent successfully\n", sc_adapter[card]->devicename);
dev_kfree_skb(data);
indicate_status(card, ISDN_STAT_BSENT, channel, (char *)&len);
}
return len;
}
void rcvpkt(int card, RspMessage *rcvmsg)
{
LLData newll;
struct sk_buff *skb;
if (!IS_VALID_CARD(card)) {
pr_debug("invalid param: %d is not a valid card id\n", card);
return;
}
switch (rcvmsg->rsp_status) {
case 0x01:
case 0x02:
case 0x70:
pr_debug("%s: error status code: 0x%x\n",
sc_adapter[card]->devicename, rcvmsg->rsp_status);
return;
case 0x00:
if (!(skb = dev_alloc_skb(rcvmsg->msg_data.response.msg_len))) {
printk(KERN_WARNING "%s: rcvpkt out of memory, dropping packet\n",
sc_adapter[card]->devicename);
return;
}
skb_put(skb, rcvmsg->msg_data.response.msg_len);
pr_debug("%s: getting data from offset: 0x%lx\n",
sc_adapter[card]->devicename,
rcvmsg->msg_data.response.buff_offset);
memcpy_fromshmem(card,
skb_put(skb, rcvmsg->msg_data.response.msg_len),
(char *)rcvmsg->msg_data.response.buff_offset,
rcvmsg->msg_data.response.msg_len);
sc_adapter[card]->card->rcvcallb_skb(sc_adapter[card]->driverId,
rcvmsg->phy_link_no - 1, skb);
case 0x03:
/*
* Recycle the buffer
*/
pr_debug("%s: buffer size : %d\n",
sc_adapter[card]->devicename, BUFFER_SIZE);
/* memset_shmem(card, rcvmsg->msg_data.response.buff_offset, 0, BUFFER_SIZE); */
newll.buff_offset = rcvmsg->msg_data.response.buff_offset;
newll.msg_len = BUFFER_SIZE;
pr_debug("%s: recycled buffer at offset 0x%lx size %d\n",
sc_adapter[card]->devicename,
newll.buff_offset, newll.msg_len);
sendmessage(card, CEPID, ceReqTypeLnk, ceReqClass1, ceReqLnkRead,
rcvmsg->phy_link_no, sizeof(LLData), (unsigned int *)&newll);
}
}
int setup_buffers(int card, int c)
{
unsigned int nBuffers, i, cBase;
unsigned int buffer_size;
LLData RcvBuffOffset;
if (!IS_VALID_CARD(card)) {
pr_debug("invalid param: %d is not a valid card id\n", card);
return -ENODEV;
}
/*
* Calculate the buffer offsets (send/recv/send/recv)
*/
pr_debug("%s: setting up channel buffer space in shared RAM\n",
sc_adapter[card]->devicename);
buffer_size = BUFFER_SIZE;
nBuffers = ((sc_adapter[card]->ramsize - BUFFER_BASE) / buffer_size) / 2;
nBuffers = nBuffers > BUFFERS_MAX ? BUFFERS_MAX : nBuffers;
pr_debug("%s: calculating buffer space: %d buffers, %d big\n",
sc_adapter[card]->devicename,
nBuffers, buffer_size);
if (nBuffers < 2) {
pr_debug("%s: not enough buffer space\n",
sc_adapter[card]->devicename);
return -1;
}
cBase = (nBuffers * buffer_size) * (c - 1);
pr_debug("%s: channel buffer offset from shared RAM: 0x%x\n",
sc_adapter[card]->devicename, cBase);
sc_adapter[card]->channel[c - 1].first_sendbuf = BUFFER_BASE + cBase;
sc_adapter[card]->channel[c - 1].num_sendbufs = nBuffers / 2;
sc_adapter[card]->channel[c - 1].free_sendbufs = nBuffers / 2;
sc_adapter[card]->channel[c - 1].next_sendbuf = 0;
pr_debug("%s: send buffer setup complete: first=0x%lx n=%d f=%d, nxt=%d\n",
sc_adapter[card]->devicename,
sc_adapter[card]->channel[c - 1].first_sendbuf,
sc_adapter[card]->channel[c - 1].num_sendbufs,
sc_adapter[card]->channel[c - 1].free_sendbufs,
sc_adapter[card]->channel[c - 1].next_sendbuf);
/*
* Prep the receive buffers
*/
pr_debug("%s: adding %d RecvBuffers:\n",
sc_adapter[card]->devicename, nBuffers / 2);
for (i = 0; i < nBuffers / 2; i++) {
RcvBuffOffset.buff_offset =
((sc_adapter[card]->channel[c - 1].first_sendbuf +
(nBuffers / 2) * buffer_size) + (buffer_size * i));
RcvBuffOffset.msg_len = buffer_size;
pr_debug("%s: adding RcvBuffer #%d offset=0x%lx sz=%d bufsz:%d\n",
sc_adapter[card]->devicename,
i + 1, RcvBuffOffset.buff_offset,
RcvBuffOffset.msg_len, buffer_size);
sendmessage(card, CEPID, ceReqTypeLnk, ceReqClass1, ceReqLnkRead,
c, sizeof(LLData), (unsigned int *)&RcvBuffOffset);
}
return 0;
}
#ifndef __ISDN_SC_SCIOC_H__
#define __ISDN_SC_SCIOC_H__
/*
* This software may be used and distributed according to the terms
* of the GNU General Public License, incorporated herein by reference.
*/
/*
* IOCTL Command Codes
*/
#define SCIOCLOAD 0x01 /* Load a firmware record */
#define SCIOCRESET 0x02 /* Perform hard reset */
#define SCIOCDEBUG 0x03 /* Set debug level */
#define SCIOCREV 0x04 /* Get driver revision(s) */
#define SCIOCSTART 0x05 /* Start the firmware */
#define SCIOCGETSWITCH 0x06 /* Get switch type */
#define SCIOCSETSWITCH 0x07 /* Set switch type */
#define SCIOCGETSPID 0x08 /* Get channel SPID */
#define SCIOCSETSPID 0x09 /* Set channel SPID */
#define SCIOCGETDN 0x0A /* Get channel DN */
#define SCIOCSETDN 0x0B /* Set channel DN */
#define SCIOCTRACE 0x0C /* Toggle trace mode */
#define SCIOCSTAT 0x0D /* Get line status */
#define SCIOCGETSPEED 0x0E /* Set channel speed */
#define SCIOCSETSPEED 0x0F /* Set channel speed */
#define SCIOCLOOPTST 0x10 /* Perform loopback test */
typedef struct {
int device;
int channel;
unsigned long command;
void __user *dataptr;
} scs_ioctl;
/* Size of strings */
#define SCIOC_SPIDSIZE 49
#define SCIOC_DNSIZE SCIOC_SPIDSIZE
#define SCIOC_REVSIZE SCIOC_SPIDSIZE
#define SCIOC_SRECSIZE 49
typedef struct {
unsigned long tx_good;
unsigned long tx_bad;
unsigned long rx_good;
unsigned long rx_bad;
} ChLinkStats;
typedef struct {
char spid[49];
char dn[49];
char call_type;
char phy_stat;
ChLinkStats link_stats;
} BRIStat;
typedef BRIStat POTStat;
typedef struct {
char call_type;
char call_state;
char serv_state;
char phy_stat;
ChLinkStats link_stats;
} PRIStat;
typedef char PRIInfo;
typedef char BRIInfo;
typedef char POTInfo;
typedef struct {
char acfa_nos;
char acfa_ais;
char acfa_los;
char acfa_rra;
char acfa_slpp;
char acfa_slpn;
char acfa_fsrf;
} ACFAStat;
typedef struct {
unsigned char modelid;
char serial_no[13];
char part_no[13];
char load_ver[11];
char proc_ver[11];
int iobase;
long rambase;
char irq;
long ramsize;
char interface;
char switch_type;
char l1_status;
char l2_status;
ChLinkStats dch_stats;
ACFAStat AcfaStats;
union {
PRIStat pristats[23];
BRIStat bristats[2];
POTStat potsstats[2];
} status;
union {
PRIInfo priinfo;
BRIInfo briinfo;
POTInfo potsinfo;
} info;
} boardInfo;
#endif /* __ISDN_SC_SCIOC_H__ */
/* $Id: shmem.c,v 1.2.10.1 2001/09/23 22:24:59 kai Exp $
*
* Copyright (C) 1996 SpellCaster Telecommunications Inc.
*
* Card functions implementing ISDN4Linux functionality
*
* This software may be used and distributed according to the terms
* of the GNU General Public License, incorporated herein by reference.
*
* For more information, please contact gpl-info@spellcast.com or write:
*
* SpellCaster Telecommunications Inc.
* 5621 Finch Avenue East, Unit #3
* Scarborough, Ontario Canada
* M1B 2T9
* +1 (416) 297-8565
* +1 (416) 297-6433 Facsimile
*/
#include "includes.h" /* This must be first */
#include "hardware.h"
#include "card.h"
/*
*
*/
void memcpy_toshmem(int card, void *dest, const void *src, size_t n)
{
unsigned long flags;
unsigned char ch;
unsigned long dest_rem = ((unsigned long) dest) % 0x4000;
if (!IS_VALID_CARD(card)) {
pr_debug("Invalid param: %d is not a valid card id\n", card);
return;
}
if (n > SRAM_PAGESIZE)
return;
/*
* determine the page to load from the address
*/
ch = (unsigned long) dest / SRAM_PAGESIZE;
pr_debug("%s: loaded page %d\n", sc_adapter[card]->devicename, ch);
/*
* Block interrupts and load the page
*/
spin_lock_irqsave(&sc_adapter[card]->lock, flags);
outb(((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80,
sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]);
memcpy_toio((void __iomem *)(sc_adapter[card]->rambase + dest_rem), src, n);
spin_unlock_irqrestore(&sc_adapter[card]->lock, flags);
pr_debug("%s: set page to %#x\n", sc_adapter[card]->devicename,
((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80);
pr_debug("%s: copying %zu bytes from %#lx to %#lx\n",
sc_adapter[card]->devicename, n,
(unsigned long) src,
sc_adapter[card]->rambase + ((unsigned long) dest % 0x4000));
}
/*
* Reverse of above
*/
void memcpy_fromshmem(int card, void *dest, const void *src, size_t n)
{
unsigned long flags;
unsigned char ch;
if (!IS_VALID_CARD(card)) {
pr_debug("Invalid param: %d is not a valid card id\n", card);
return;
}
if (n > SRAM_PAGESIZE) {
return;
}
/*
* determine the page to load from the address
*/
ch = (unsigned long) src / SRAM_PAGESIZE;
pr_debug("%s: loaded page %d\n", sc_adapter[card]->devicename, ch);
/*
* Block interrupts and load the page
*/
spin_lock_irqsave(&sc_adapter[card]->lock, flags);
outb(((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80,
sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]);
memcpy_fromio(dest, (void *)(sc_adapter[card]->rambase +
((unsigned long) src % 0x4000)), n);
spin_unlock_irqrestore(&sc_adapter[card]->lock, flags);
pr_debug("%s: set page to %#x\n", sc_adapter[card]->devicename,
((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80);
/* pr_debug("%s: copying %d bytes from %#x to %#x\n",
sc_adapter[card]->devicename, n,
sc_adapter[card]->rambase + ((unsigned long) src %0x4000), (unsigned long) dest); */
}
#if 0
void memset_shmem(int card, void *dest, int c, size_t n)
{
unsigned long flags;
unsigned char ch;
if (!IS_VALID_CARD(card)) {
pr_debug("Invalid param: %d is not a valid card id\n", card);
return;
}
if (n > SRAM_PAGESIZE) {
return;
}
/*
* determine the page to load from the address
*/
ch = (unsigned long) dest / SRAM_PAGESIZE;
pr_debug("%s: loaded page %d\n", sc_adapter[card]->devicename, ch);
/*
* Block interrupts and load the page
*/
spin_lock_irqsave(&sc_adapter[card]->lock, flags);
outb(((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80,
sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]);
memset_io(sc_adapter[card]->rambase +
((unsigned long) dest % 0x4000), c, n);
pr_debug("%s: set page to %#x\n", sc_adapter[card]->devicename,
((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80);
spin_unlock_irqrestore(&sc_adapter[card]->lock, flags);
}
#endif /* 0 */
/* $Id: timer.c,v 1.3.6.1 2001/09/23 22:24:59 kai Exp $
*
* Copyright (C) 1996 SpellCaster Telecommunications Inc.
*
* This software may be used and distributed according to the terms
* of the GNU General Public License, incorporated herein by reference.
*
* For more information, please contact gpl-info@spellcast.com or write:
*
* SpellCaster Telecommunications Inc.
* 5621 Finch Avenue East, Unit #3
* Scarborough, Ontario Canada
* M1B 2T9
* +1 (416) 297-8565
* +1 (416) 297-6433 Facsimile
*/
#include "includes.h"
#include "hardware.h"
#include "message.h"
#include "card.h"
/*
* Write the proper values into the I/O ports following a reset
*/
static void setup_ports(int card)
{
outb((sc_adapter[card]->rambase >> 12), sc_adapter[card]->ioport[EXP_BASE]);
/* And the IRQ */
outb((sc_adapter[card]->interrupt | 0x80),
sc_adapter[card]->ioport[IRQ_SELECT]);
}
/*
* Timed function to check the status of a previous reset
* Must be very fast as this function runs in the context of
* an interrupt handler.
*
* Setup the ioports for the board that were cleared by the reset.
* Then, check to see if the signate has been set. Next, set the
* signature to a known value and issue a startproc if needed.
*/
void sc_check_reset(unsigned long data)
{
unsigned long flags;
unsigned long sig;
int card = (unsigned int) data;
pr_debug("%s: check_timer timer called\n",
sc_adapter[card]->devicename);
/* Setup the io ports */
setup_ports(card);
spin_lock_irqsave(&sc_adapter[card]->lock, flags);
outb(sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport],
(sc_adapter[card]->shmem_magic >> 14) | 0x80);
sig = (unsigned long) *((unsigned long *)(sc_adapter[card]->rambase + SIG_OFFSET));
/* check the signature */
if (sig == SIGNATURE) {
flushreadfifo(card);
spin_unlock_irqrestore(&sc_adapter[card]->lock, flags);
/* See if we need to do a startproc */
if (sc_adapter[card]->StartOnReset)
startproc(card);
} else {
pr_debug("%s: No signature yet, waiting another %lu jiffies.\n",
sc_adapter[card]->devicename, CHECKRESET_TIME);
mod_timer(&sc_adapter[card]->reset_timer, jiffies + CHECKRESET_TIME);
spin_unlock_irqrestore(&sc_adapter[card]->lock, flags);
}
}
/*
* Timed function to check the status of a previous reset
* Must be very fast as this function runs in the context of
* an interrupt handler.
*
* Send check sc_adapter->phystat to see if the channels are up
* If they are, tell ISDN4Linux that the board is up. If not,
* tell IADN4Linux that it is up. Always reset the timer to
* fire again (endless loop).
*/
void check_phystat(unsigned long data)
{
unsigned long flags;
int card = (unsigned int) data;
pr_debug("%s: Checking status...\n", sc_adapter[card]->devicename);
/*
* check the results of the last PhyStat and change only if
* has changed drastically
*/
if (sc_adapter[card]->nphystat && !sc_adapter[card]->phystat) { /* All is well */
pr_debug("PhyStat transition to RUN\n");
pr_info("%s: Switch contacted, transmitter enabled\n",
sc_adapter[card]->devicename);
indicate_status(card, ISDN_STAT_RUN, 0, NULL);
}
else if (!sc_adapter[card]->nphystat && sc_adapter[card]->phystat) { /* All is not well */
pr_debug("PhyStat transition to STOP\n");
pr_info("%s: Switch connection lost, transmitter disabled\n",
sc_adapter[card]->devicename);
indicate_status(card, ISDN_STAT_STOP, 0, NULL);
}
sc_adapter[card]->phystat = sc_adapter[card]->nphystat;
/* Reinitialize the timer */
spin_lock_irqsave(&sc_adapter[card]->lock, flags);
mod_timer(&sc_adapter[card]->stat_timer, jiffies + CHECKSTAT_TIME);
spin_unlock_irqrestore(&sc_adapter[card]->lock, flags);
/* Send a new cePhyStatus message */
sendmessage(card, CEPID, ceReqTypePhy, ceReqClass2,
ceReqPhyStatus, 0, 0, NULL);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment