@@ -105,7+105,7 @@ EXPORT_SYMBOL(alpha_read_fp_reg); EXPORT_SYMBOL(alpha_write_fp_reg);
/* In-kernel system calls. */
-EXPORT_SYMBOL(__kernel_thread);
+EXPORT_SYMBOL(kernel_thread);
EXPORT_SYMBOL(sys_open);
EXPORT_SYMBOL(sys_dup);
EXPORT_SYMBOL(sys_exit);
#include <linux/config.h>
#include <linux/kernel.h>
-#include <linux/tasks.h>
+#include <linux/threads.h>
#include <linux/smp.h>
#include <linux/smp_lock.h>
#include <linux/init.h>
*/
#define PF_PTRACED 0x00000010
+#define CLONE_VM 0x00000100
+
/*
* This defines the normal kernel pt-regs layout.
*
@@ -225,21+227,23 @@ kernel_clone: .end kernel_clone
/*
- * __kernel_thread(clone_flags, fn, arg)
+ * kernel_thread(fn, arg, clone_flags)
*/
.align 3
-.globl __kernel_thread
-.ent __kernel_thread
-__kernel_thread:
+.globl kernel_thread
+.ent kernel_thread
+kernel_thread:
ldgp $29,0($27) /* we can be called from a module */
.frame $30, 4*8, $26
subq $30,4*8,$30
stq $10,16($30)
stq $9,8($30)
+ lda $0,CLONE_VM
stq $26,0($30)
.prologue 1
- mov $17,$9 /* save fn */
- mov $18,$10 /* save arg */
+ mov $16,$9 /* save fn */
+ mov $17,$10 /* save arg */
+ or $18,$0,$16 /* shuffle flags to front; add CLONE_VM. */
bsr $26,kernel_clone
bne $20,1f /* $20 is non-zero in child */
ldq $26,0($30)
@@ -257,7+261,7 @@ __kernel_thread: mov $0,$16
mov $31,$26
jsr $31,sys_exit
-.end __kernel_thread
+.end kernel_thread
/*
* __kernel_execve(path, argv, envp, regs)
@@ -45,6+45,7 @@ SECTIONS
/* Global data */
_data = .;
+ .data.cacheline_aligned : { *(.data.cacheline_aligned) }
.rodata : { *(.rodata) }
.data : { *(.data) CONSTRUCTORS }
.got : { *(.got) }
@@ -548,6+548,11 @@ static int apm_set_power_state(u_short state) */
#define HARD_IDLE_TIMEOUT (HZ/3)
+/* This should wake up kapmd and ask it to slow the CPU */
+#define powermanagement_idle() do { } while (0)
+
+extern int hlt_counter;
+
/*
* This is the idle thing.
*/
@@ -907,12+907,17 @@ static void __init pcibios_fixup_io_addr(struct pci_dev *dev, int idx) if ((try & PCI_BASE_ADDRESS_IO_MASK) != addr) {
addr = 0;
printk("PCI: Address setup failed, got %04x\n", try);
- } else
- dev->base_address[idx] = try;
+ } else {
+ struct resource *res = dev->resource + idx;
+ res->start = addr;
+ res->end = addr + size - 1;
+ res->flags |= PCI_BASE_ADDRESS_IO_MASK;
+ }
}
if (!addr) {
pcibios_write_config_dword(bus, devfn, reg, 0);
- dev->base_address[idx] = 0;
+ dev->resource[idx].start = 0;
+ dev->resource[idx].flags = 0;
}
pcibios_write_config_word(bus, devfn, PCI_COMMAND, cmd);
}
@@ -939,7+944,7 @@ static void __init pcibios_fixup_ghosts(struct pci_bus *b) e->vendor == d->vendor &&
e->device == d->device &&
e->class == d->class &&
- !memcmp(e->base_address, d->base_address, sizeof(e->base_address)))
+ !memcmp(e->resource, d->resource, sizeof(e->resource)))
break;
if (!e)
return;
@@ -1060,7+1065,7 @@ static void __init pci_fixup_umc_ide(struct pci_dev *d) int i;
for(i=0; i<4; i++)
- d->base_address[i] |= PCI_BASE_ADDRESS_SPACE_IO;
+ d->resource[i].flags |= PCI_BASE_ADDRESS_SPACE_IO;
}
struct dev_ex {
@@ -1112,11+1117,12 @@ static void __init pcibios_fixup_devices(void) */
has_io = has_mem = 0;
for(i=0; i<6; i++) {
- unsigned long a = dev->base_address[i];
+ struct resource *res = dev->resource + i;
+ unsigned long a = res->flags;
if (a & PCI_BASE_ADDRESS_SPACE_IO) {
+ unsigned long addr = res->start;
has_io = 1;
- a &= PCI_BASE_ADDRESS_IO_MASK;
- if (!a || a == PCI_BASE_ADDRESS_IO_MASK)
+ if (!addr || addr == PCI_BASE_ADDRESS_IO_MASK)
pcibios_fixup_io_addr(dev, i);
} else if (a & PCI_BASE_ADDRESS_MEM_MASK)
has_mem = 1;
@@ -255,9+255,9 @@ __setup("noapic", ioapic_setup); static int __init ioapic_pirq_setup(char *str)
{
int i, max;
- int ints[11];
+ int ints[MAX_PIRQS+1];
- get_options(str, ints);
+ get_options(str, MAX_PIRQS+1, ints);
for (i = 0; i < MAX_PIRQS; i++)
pirq_entries[i] = -1;
@@ -470,7+470,6 @@ static void show(char * str) int i;
unsigned long *stack;
int cpu = smp_processor_id();
- extern char *get_options(char *str, int *ints);
printk("\n%s, CPU %d:\n", str, cpu);
printk("irq: %d [%d %d]\n",
@@ -51,15+51,6 @@ spinlock_t semaphore_wake_lock = SPIN_LOCK_UNLOCKED;
asmlinkage void ret_from_fork(void) __asm__("ret_from_fork");
-/*
- * We'll get there..
- */
-#ifdef CONFIG_APM
-#define powermanagement_idle() do { } while (0)
-#else
-#define powermanagement_idle() do { } while (0)
-#endif
-
static int hlt_counter=0;
void disable_hlt(void)
@@ -182,11+182,7 @@ __setup("nosmp", nosmp);
static int __init maxcpus(char *str)
{
- int ints[11];
-
- get_options(str, ints);
- if (ints[0] > 0)
- max_cpus = ints[1];
+ get_option(&str, &max_cpus);
return 1;
}
*/
#include <linux/config.h>
-#include <asm/init.h>
+#include <linux/init.h>
#include <asm/dec/machtype.h>
#ifdef CONFIG_ZS
#include <linux/param.h>
#include <asm/mipsregs.h>
#include <asm/bootinfo.h>
-#include <asm/init.h>
+#include <linux/init.h>
#include <asm/irq.h>
#include <asm/reboot.h>
*/
#include <asm/bootinfo.h>
-#include <asm/init.h>
+#include <linux/init.h>
static void wbflush_kn01(void);
static void wbflush_kn210(void);
#include <linux/stddef.h>
#include <linux/reboot.h>
#include <linux/nvram.h>
-#include <asm/init.h>
+#include <linux/init.h>
#include <asm/ptrace.h>
#include <asm/io.h>
#include <asm/pgtable.h>
#include <asm/spinlock.h>
#include <asm/hardirq.h>
#include <asm/softirq.h>
-#include <asm/init.h>
+#include <linux/init.h>
#include <asm/io.h>
#include <asm/prom.h>
-/* $Id: trampoline.S,v 1.12 1998/03/19 15:36:38 jj Exp $
+/* $Id: trampoline.S,v 1.13 1999/08/04 03:19:15 davem Exp $
* trampoline.S: SMP cpu boot-up trampoline code.
*
* Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
* Copyright (C) 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
*/
+#include <linux/init.h>
#include <asm/cprefix.h>
#include <asm/head.h>
#include <asm/psr.h>
#include <asm/ptrace.h>
#include <asm/vaddrs.h>
#include <asm/contregs.h>
-#include <asm/init.h>
.globl C_LABEL(sun4m_cpu_startup), C_LABEL(__smp4m_processor_id)
.globl C_LABEL(sun4d_cpu_startup), C_LABEL(__smp4d_processor_id)
-/* $Id: asyncd.c,v 1.15 1999/07/04 04:35:50 davem Exp $
+/* $Id: asyncd.c,v 1.16 1999/08/04 03:19:16 davem Exp $
* The asyncd kernel daemon. This handles paging on behalf of
* processes that receive page faults due to remote (async) memory
* accesses.
-# $Id: config.in,v 1.71 1999/07/30 09:35:13 davem Exp $
+# $Id: config.in,v 1.72 1999/08/04 03:19:17 davem Exp $
# For a description of the syntax of this configuration file,
# see the Configure script.
#
-/* $Id: process.c,v 1.98 1999/08/02 08:39:35 davem Exp $
+/* $Id: process.c,v 1.99 1999/08/04 03:19:20 davem Exp $
* arch/sparc64/kernel/process.c
*
* Copyright (C) 1995, 1996 David S. Miller (davem@caip.rutgers.edu)
@@ -48,6+48,8 @@ SECTIONS __initcall_end = .;
. = ALIGN(8192);
__init_end = .;
+ . = ALIGN(64);
+ .data.cacheline_aligned : { *(.data-cacheline_aligned) }
__bss_start = .;
.sbss : { *(.sbss) *(.scommon) }
.bss :
@@ -4063,10+4063,13 @@ static struct param_table { { "L40SX", 0, &print_unex, 0, 0 } };
#define FLOPPY_SETUP
-void __init floppy_setup(char *str, int *ints)
+void __init floppy_setup(char *str)
{
int i;
int param;
+ int ints[11];
+
+ str = get_options(str,ARRAY_SIZE(ints),ints);
if (str) {
for (i=0; i< ARRAY_SIZE(config_params); i++){
if (strcmp(str,config_params[i].name) == 0){
@@ -4358,8+4361,6 @@ static void floppy_release_irq_and_dma(void)
#ifdef MODULE
-extern char *get_options(char *str, int *ints);
-
char *floppy=NULL;
static void __init parse_floppy_cfg_string(char *cfg)
@@ -4374,18+4375,17 @@ static void __init parse_floppy_cfg_string(char *cfg) cfg++;
}
if(*ptr)
- floppy_setup(get_options(ptr,ints),ints);
+ floppy_setup(ptr);
}
}
-static void __init mod_setup(char *pattern, void (*setup)(char *, int *))
+static void __init mod_setup(char *pattern, void (*setup)(char *))
{
unsigned long i;
char c;
int j;
int match;
char buffer[100];
- int ints[11];
int length = strlen(pattern)+1;
match=0;
@@ -4400,7+4400,7 @@ static void __init mod_setup(char *pattern, void (*setup)(char *, int *)) if (!c || c == ' ' || c == '\t'){
if (j){
buffer[j] = '\0';
- setup(get_options(buffer,ints),ints);
+ setup(buffer);
}
j=0;
} else
@@ -231,15+231,17 @@ __initfunc(static unsigned int ide_special_settings (struct pci_dev *dev, const {
int i;
unsigned short pcicmd = 0;
- unsigned long hpt34xIoBase = dev->base_address[4] & PCI_BASE_ADDRESS_IO_MASK;
+ unsigned long hpt34xIoBase = dev->resource[4].start;
pci_write_config_byte(dev, 0x80, 0x00);
- dev->base_address[0] = (hpt34xIoBase + 0x20);
- dev->base_address[1] = (hpt34xIoBase + 0x34);
- dev->base_address[2] = (hpt34xIoBase + 0x28);
- dev->base_address[3] = (hpt34xIoBase + 0x3c);
+
+ /* FIXME - this is too ugly, and looks senseless. Why not just use resource[4]? */
+ dev->resource[0].start = (hpt34xIoBase + 0x20);
+ dev->resource[1].start = (hpt34xIoBase + 0x34);
+ dev->resource[2].start = (hpt34xIoBase + 0x28);
+ dev->resource[3].start = (hpt34xIoBase + 0x3c);
for(i=0; i<4; i++)
- dev->base_address[i] |= PCI_BASE_ADDRESS_SPACE_IO;
+ dev->resource[i].flags |= PCI_BASE_ADDRESS_SPACE_IO;
pci_read_config_word(dev, PCI_COMMAND, &pcicmd);
if (!(pcicmd & PCI_COMMAND_MEMORY)) {
@@ -346,11+348,15 @@ __initfunc(static int ide_setup_pci_baseregs (struct pci_dev *dev, const char *n /*
* Setup base registers for IDE command/control spaces for each interface:
*/
- for (reg = 0; reg < 4; reg++)
- if (!dev->base_address[reg]) {
+ for (reg = 0; reg < 4; reg++) {
+ struct resource *res = dev->resource + reg;
+ if (!(res->flags & PCI_BASE_ADDRESS_SPACE_IO))
+ continue;
+ if (!res->start) {
printk("%s: Missing I/O address #%d\n", name, reg);
return 1;
}
+ }
return 0;
}
@@ -447,8+453,9 @@ check_if_enabled: if (e->reg && (pci_read_config_byte(dev, e->reg, &tmp) || (tmp & e->mask) != e->val))
continue; /* port not enabled */
if ((dev->class >> 8) != PCI_CLASS_STORAGE_IDE || (dev->class & (port ? 4 : 1)) != 0) {
- ctl = dev->base_address[(2*port)+1] & PCI_BASE_ADDRESS_IO_MASK;
- base = dev->base_address[2*port] & ~7;
+ /* FIXME! This really should check that it really gets the IO/MEM part right! */
+ ctl = dev->resource[(2*port)+1].start;
+ base = dev->resource[2*port].start;
}
if ((ctl && !base) || (base && !ctl)) {
printk("%s: inconsistent baseregs (BIOS) for port %d, skipping\n", d->name, port);
endif
endif
-
-ifeq ($(CONFIG_HFMODEM),y)
-ALL_SUB_DIRS += hfmodem
-SUB_DIRS += hfmodem
-O_OBJS += hfmodem/hfmodem.o
-else
- ifeq ($(CONFIG_HFMODEM),m)
- ALL_SUB_DIRS += hfmodem
- MOD_SUB_DIRS += hfmodem
- endif
-
-endif
-
include $(TOPDIR)/Rules.make
fastdep:
+++ /dev/null
-comment 'Misc. hamradio protocols'
-dep_tristate 'Shortwave radio modem driver' CONFIG_HFMODEM $CONFIG_PARPORT
-if [ "$CONFIG_HFMODEM" != "n" ]; then
- bool ' HFmodem support for Soundblaster and compatible cards' CONFIG_HFMODEM_SBC
- bool ' HFmodem support for WSS and Crystal cards' CONFIG_HFMODEM_WSS
-fi
+++ /dev/null
-#
-# Makefile for the hfmodem device driver.
-#
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definitions are now inherited from the
-# parent makes..
-#
-
-O_TARGET := hfmodem.o
-
-O_OBJS := refclock.o modem.o main.o
-ifeq ($(CONFIG_HFMODEM_SBC),y)
-O_OBJS += sbc.o
-endif
-ifeq ($(CONFIG_HFMODEM_WSS),y)
-O_OBJS += wss.o
-endif
-
-M_OBJS := $(O_TARGET)
-
-all: all_targets
-.PHONY: all
-
-gentbl: gentbl.c
- $(HOSTCC) $(HOSTCFLAGS) $< -o $@ -lm
-
-TBLHDR := tables.h
-
-tables.h: gentbl
- ./gentbl > $@
-
-fastdep: $(TBLHDR)
-
-include $(TOPDIR)/Rules.make
+++ /dev/null
-/*****************************************************************************/
-
-/*
- * gentbl.c -- Linux soundcard HF FSK driver,
- * Table generator.
- *
- * Copyright (C) 1997 Thomas Sailer (sailer@ife.ee.ethz.ch)
- * Swiss Federal Institute of Technology (ETH), Electronics Lab
- *
- * 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.
- *
- *
- */
-
-/*****************************************************************************/
-
-/* This is compiled with HOSTCC - do not include any <linux/foo.h> headers. */
-#include <math.h>
-#include <stdio.h>
-
-/* --------------------------------------------------------------------- */
-
-#define SINTABBITS 9
-#define SINTABSIZE (1<<SINTABBITS)
-
-/* --------------------------------------------------------------------- */
-
-static void gensintbl(void)
-{
- int i;
-
- printf("#define SINTABBITS %d\n#define SINTABSIZE (1<<SINTABBITS)\n"
- "\nstatic short isintab[SINTABSIZE+SINTABSIZE/4] = {\n\t", SINTABBITS);
- for (i = 0; i < (SINTABSIZE+SINTABSIZE/4); i++) {
- printf("%6d", (int)(32767.0 * sin(2.0 * M_PI / SINTABSIZE * i)));
- if (i < (SINTABSIZE+SINTABSIZE/4)-1) {
- if ((i & 7) == 7)
- printf(",\n\t");
- else
- printf(",");
- }
- }
- printf("\n};\n\n");
-}
-
-/* --------------------------------------------------------------------- */
-
-int main(int argc, char *argv[])
-{
- printf("/*\n * This file is automatically generated by %s, DO NOT EDIT!\n*/\n\n",
- argv[0]);
- gensintbl();
- exit(0);
-}
-
-/* --------------------------------------------------------------------- */
-
+++ /dev/null
-/*****************************************************************************/
-
-/*
- * main.c -- Linux soundcard HF FSK driver.
- *
- * Copyright (C) 1997 Thomas Sailer (sailer@ife.ee.ethz.ch)
- * Swiss Federal Institute of Technology (ETH), Electronics Lab
- *
- * 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.
- *
- * Command line options (insmod command line)
- *
- * History:
- * 0.1 15.04.97 Adapted from baycom.c and made network driver interface
- * 0.2 05.07.97 All floating point stuff thrown out due to Linus' rantings :)
- *
- */
-
-/*****************************************************************************/
-
-
-#include <linux/config.h> /* for CONFIG_HFMODEM_WSS and CONFIG_HFMODEM_SBC */
-#include <linux/module.h>
-
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/malloc.h>
-#include <linux/errno.h>
-#include <linux/miscdevice.h>
-#include <linux/ioport.h>
-#include <linux/hfmodem.h>
-
-#include <asm/io.h>
-#include <asm/segment.h>
-#include <asm/system.h>
-#include <asm/irq.h>
-#include <asm/dma.h>
-
-/* --------------------------------------------------------------------- */
-
-/*
- * currently this module is supposed to support both module styles, i.e.
- * the old one present up to about 2.1.9, and the new one functioning
- * starting with 2.1.21. The reason is I have a kit allowing to compile
- * this module also under 2.0.x which was requested by several people.
- * This will go in 2.2
- */
-#include <linux/version.h>
-
-#if LINUX_VERSION_CODE >= 0x20100
-#include <asm/uaccess.h>
-#else
-#include <linux/mm.h>
-
-#undef put_user
-#undef get_user
-
-#define put_user(x,ptr) ({ __put_user((unsigned long)(x),(ptr),sizeof(*(ptr))); 0; })
-#define get_user(x,ptr) ({ x = ((__typeof__(*(ptr)))__get_user((ptr),sizeof(*(ptr)))); 0; })
-
-extern inline int copy_from_user(void *to, const void *from, unsigned long n)
-{
- int i = verify_area(VERIFY_READ, from, n);
- if (i)
- return i;
- memcpy_fromfs(to, from, n);
- return 0;
-}
-
-extern inline int copy_to_user(void *to, const void *from, unsigned long n)
-{
- int i = verify_area(VERIFY_WRITE, to, n);
- if (i)
- return i;
- memcpy_tofs(to, from, n);
- return 0;
-}
-#endif
-
-#if LINUX_VERSION_CODE >= 0x20123
-#include <linux/init.h>
-#else
-#define __init
-#define __initdata
-#define __initfunc(x) x
-#endif
-
-/* --------------------------------------------------------------------- */
-
-/*static*/ const char hfmodem_drvname[] = "hfmodem";
-static const char hfmodem_drvinfo[] = KERN_INFO "hfmodem: (C) 1997 Thomas Sailer, HB9JNX/AE4WA\n"
-KERN_INFO "hfmodem: version 0.2 compiled " __TIME__ " " __DATE__ "\n";
-
-/* --------------------------------------------------------------------- */
-/*
- * currently we support only one device
- */
-
-struct hfmodem_state hfmodem_state[NR_DEVICE];
-
-/* --------------------------------------------------------------------- */
-/*
- * ===================== port checking routines ========================
- */
-
-
-#define UART_RBR(iobase) (iobase+0)
-#define UART_THR(iobase) (iobase+0)
-#define UART_IER(iobase) (iobase+1)
-#define UART_IIR(iobase) (iobase+2)
-#define UART_FCR(iobase) (iobase+2)
-#define UART_LCR(iobase) (iobase+3)
-#define UART_MCR(iobase) (iobase+4)
-#define UART_LSR(iobase) (iobase+5)
-#define UART_MSR(iobase) (iobase+6)
-#define UART_SCR(iobase) (iobase+7)
-#define UART_DLL(iobase) (iobase+0)
-#define UART_DLM(iobase) (iobase+1)
-
-#define SER_EXTENT 8
-
-#define LPT_DATA(iobase) (iobase+0)
-#define LPT_STATUS(iobase) (iobase+1)
-#define LPT_CONTROL(iobase) (iobase+2)
-#define LPT_IRQ_ENABLE 0x10
-
-#define MIDI_DATA(iobase) (iobase)
-#define MIDI_STATUS(iobase) (iobase+1)
-#define MIDI_READ_FULL 0x80 /* attention: negative logic!! */
-#define MIDI_WRITE_EMPTY 0x40 /* attention: negative logic!! */
-
-#define MIDI_EXTENT 2
-
-#define SP_SER 1
-#define SP_PAR 2
-#define SP_MIDI 4
-
-/* --------------------------------------------------------------------- */
-
-static void parptt_wakeup(void *handle)
-{
- struct hfmodem_state *dev = (struct hfmodem_state *)handle;
-
- printk(KERN_DEBUG "%s: parptt: why am I being woken up?\n", hfmodem_drvname);
- if (!parport_claim(dev->ptt_out.pardev))
- printk(KERN_DEBUG "%s: parptt: I'm broken.\n", hfmodem_drvname);
-}
-
-/* --------------------------------------------------------------------- */
-static int __init check_lpt(struct hfmodem_state *dev, unsigned int iobase)
-{
- struct parport *pp = parport_enumerate();
-
- while (pp && pp->base != iobase)
- pp = pp->next;
- if (!pp)
- return 0;
- if (!(dev->ptt_out.pardev = parport_register_device(pp, hfmodem_drvname, NULL, parptt_wakeup,
- NULL, PARPORT_DEV_EXCL, dev)))
- return 0;
- return 1;
-}
-
-/* --------------------------------------------------------------------- */
-
-enum uart { c_uart_unknown, c_uart_8250, c_uart_16450, c_uart_16550, c_uart_16550A };
-static const char *uart_str[] __initdata = { "unknown", "8250", "16450", "16550", "16550A" };
-
-static enum uart __init check_uart(unsigned int iobase)
-{
- unsigned char b1,b2,b3;
- enum uart u;
- enum uart uart_tab[] = { c_uart_16450, c_uart_unknown, c_uart_16550, c_uart_16550A };
-
- if (iobase <= 0 || iobase > 0x1000-SER_EXTENT)
- return c_uart_unknown;
- if (check_region(iobase, SER_EXTENT))
- return c_uart_unknown;
- b1 = inb(UART_MCR(iobase));
- outb(b1 | 0x10, UART_MCR(iobase)); /* loopback mode */
- b2 = inb(UART_MSR(iobase));
- outb(0x1a, UART_MCR(iobase));
- b3 = inb(UART_MSR(iobase)) & 0xf0;
- outb(b1, UART_MCR(iobase)); /* restore old values */
- outb(b2, UART_MSR(iobase));
- if (b3 != 0x90)
- return c_uart_unknown;
- inb(UART_RBR(iobase));
- inb(UART_RBR(iobase));
- outb(0x01, UART_FCR(iobase)); /* enable FIFOs */
- u = uart_tab[(inb(UART_IIR(iobase)) >> 6) & 3];
- if (u == c_uart_16450) {
- outb(0x5a, UART_SCR(iobase));
- b1 = inb(UART_SCR(iobase));
- outb(0xa5, UART_SCR(iobase));
- b2 = inb(UART_SCR(iobase));
- if ((b1 != 0x5a) || (b2 != 0xa5))
- u = c_uart_8250;
- }
- return u;
-}
-
-/* --------------------------------------------------------------------- */
-
-static int __init check_midi(unsigned int iobase)
-{
- unsigned long timeout;
- unsigned long flags;
- unsigned char b;
-
- if (iobase <= 0 || iobase > 0x1000-MIDI_EXTENT)
- return 0;
- if (check_region(iobase, MIDI_EXTENT))
- return 0;
- timeout = jiffies + (HZ / 100);
- while (inb(MIDI_STATUS(iobase)) & MIDI_WRITE_EMPTY)
- if ((signed)(jiffies - timeout) > 0)
- return 0;
- save_flags(flags);
- cli();
- outb(0xff, MIDI_DATA(iobase));
- b = inb(MIDI_STATUS(iobase));
- restore_flags(flags);
- if (!(b & MIDI_WRITE_EMPTY))
- return 0;
- while (inb(MIDI_STATUS(iobase)) & MIDI_WRITE_EMPTY)
- if ((signed)(jiffies - timeout) > 0)
- return 0;
- return 1;
-}
-
-/* --------------------------------------------------------------------- */
-
-static void output_status(struct hfmodem_state *dev, int ptt)
-{
- int dcd = 0;
-
- ptt = !!ptt;
- if (dev->ptt_out.flags & SP_SER) {
- outb(dcd | (ptt << 1), UART_MCR(dev->ptt_out.seriobase));
- outb(0x40 & (-ptt), UART_LCR(dev->ptt_out.seriobase));
- }
- if (dev->ptt_out.flags & SP_PAR) {
- outb(ptt | (dcd << 1), LPT_DATA(dev->ptt_out.pariobase));
- }
- if (dev->ptt_out.flags & SP_MIDI && ptt) {
- outb(0, MIDI_DATA(dev->ptt_out.midiiobase));
- }
-}
-
-/* --------------------------------------------------------------------- */
-
-static void __init output_check(struct hfmodem_state *dev)
-{
- enum uart u = c_uart_unknown;
-
- if (((u = check_uart(dev->ptt_out.seriobase))) != c_uart_unknown)
- printk(KERN_INFO "%s: PTT output: uart found at address 0x%x type %s\n",
- hfmodem_drvname, dev->ptt_out.seriobase, uart_str[u]);
- else {
- if (dev->ptt_out.seriobase > 0)
- printk(KERN_WARNING "%s: PTT output: no uart found at address 0x%x\n",
- hfmodem_drvname, dev->ptt_out.seriobase);
- dev->ptt_out.seriobase = 0;
- }
- if (check_lpt(dev, dev->ptt_out.pariobase))
- printk(KERN_INFO "%s: PTT output: parallel port found at address 0x%x\n",
- hfmodem_drvname, dev->ptt_out.pariobase);
- else {
- if (dev->ptt_out.pariobase > 0)
- printk(KERN_WARNING "%s: PTT output: no parallel port found at address 0x%x\n",
- hfmodem_drvname, dev->ptt_out.pariobase);
- dev->ptt_out.pariobase = 0;
- dev->ptt_out.pardev = NULL;
- }
- if (dev->ptt_out.midiiobase > 0 && dev->ptt_out.midiiobase <= 0x1000-MIDI_EXTENT &&
- check_midi(dev->ptt_out.midiiobase))
- printk(KERN_INFO "%s: PTT output: midi port found at address 0x%x\n",
- hfmodem_drvname, dev->ptt_out.midiiobase);
- else {
- if (dev->ptt_out.midiiobase > 0)
- printk(KERN_WARNING "%s: PTT output: no midi port found at address 0x%x\n",
- hfmodem_drvname, dev->ptt_out.midiiobase);
- dev->ptt_out.midiiobase = 0;
- }
-}
-
-/* --------------------------------------------------------------------- */
-
-static void output_open(struct hfmodem_state *dev)
-{
- dev->ptt_out.flags = 0;
- if (dev->ptt_out.seriobase > 0) {
- if (!check_region(dev->ptt_out.seriobase, SER_EXTENT)) {
- request_region(dev->ptt_out.seriobase, SER_EXTENT, "hfmodem ser ptt");
- dev->ptt_out.flags |= SP_SER;
- outb(0, UART_IER(dev->ptt_out.seriobase));
- /* 5 bits, 1 stop, no parity, no break, Div latch access */
- outb(0x80, UART_LCR(dev->ptt_out.seriobase));
- outb(0, UART_DLM(dev->ptt_out.seriobase));
- outb(1, UART_DLL(dev->ptt_out.seriobase)); /* as fast as possible */
- /* LCR and MCR set by output_status */
- } else
- printk(KERN_WARNING "%s: PTT output: serial port at 0x%x busy\n",
- hfmodem_drvname, dev->ptt_out.seriobase);
- }
- if (dev->ptt_out.pariobase > 0) {
- if (parport_claim(dev->ptt_out.pardev))
- printk(KERN_WARNING "%s: PTT output: parallel port at 0x%x busy\n",
- hfmodem_drvname, dev->ptt_out.pariobase);
- else
- dev->ptt_out.flags |= SP_PAR;
- }
- if (dev->ptt_out.midiiobase > 0) {
- if (!check_region(dev->ptt_out.midiiobase, MIDI_EXTENT)) {
- request_region(dev->ptt_out.midiiobase, MIDI_EXTENT, "hfmodem midi ptt");
- dev->ptt_out.flags |= SP_MIDI;
- } else
- printk(KERN_WARNING "%s: PTT output: midi port at 0x%x busy\n",
- hfmodem_drvname, dev->ptt_out.midiiobase);
- }
- output_status(dev, 0);
- printk(KERN_INFO "%s: PTT output:", hfmodem_drvname);
- if (dev->ptt_out.flags & SP_SER)
- printk(" serial interface at 0x%x", dev->ptt_out.seriobase);
- if (dev->ptt_out.flags & SP_PAR)
- printk(" parallel interface at 0x%x", dev->ptt_out.pariobase);
- if (dev->ptt_out.flags & SP_MIDI)
- printk(" mpu401 (midi) interface at 0x%x", dev->ptt_out.midiiobase);
- if (!dev->ptt_out.flags)
- printk(" none");
- printk("\n");
-}
-
-/* --------------------------------------------------------------------- */
-
-static void output_close(struct hfmodem_state *dev)
-{
- /* release regions used for PTT output */
- output_status(dev, 0);
- if (dev->ptt_out.flags & SP_SER)
- release_region(dev->ptt_out.seriobase, SER_EXTENT);
- if (dev->ptt_out.flags & SP_PAR)
- parport_release(dev->ptt_out.pardev);
- if (dev->ptt_out.flags & SP_MIDI)
- release_region(dev->ptt_out.midiiobase, MIDI_EXTENT);
- dev->ptt_out.flags = 0;
-}
-
-/* --------------------------------------------------------------------- */
-
-#define INC_SAMPLE (1000000/HFMODEM_SRATE)
-#define INC_FRAGMENT (HFMODEM_FRAGSAMPLES*1000000/HFMODEM_SRATE)
-#define SIZE (HFMODEM_FRAGSAMPLES*HFMODEM_NUMFRAGS)
-
-static void hfmodem_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
- struct hfmodem_state *dev = (struct hfmodem_state *)dev_id;
- unsigned int dmaptr;
- __s16 *s;
- unsigned int curfrag, nfrags;
- int i;
- hfmodem_time_t l1time;
-
- dmaptr = dev->scops->intack(dev);
- l1time = hfmodem_refclock_current(dev, ((SIZE+dmaptr-dev->dma.last_dmaptr) % SIZE) *
- INC_SAMPLE, 1);
- curfrag = (dev->dma.last_dmaptr = dmaptr) / HFMODEM_FRAGSAMPLES;
- l1time -= INC_SAMPLE * (SIZE+dmaptr-dev->dma.fragptr*HFMODEM_FRAGSAMPLES) % SIZE;
- sti();
- /*
- * handle receiving
- */
- if (dev->dma.ptt_frames <= 0) {
- while (dev->dma.fragptr != curfrag) {
- if (dev->dma.fragptr < HFMODEM_EXCESSFRAGS) {
- s = dev->dma.buf + SIZE + HFMODEM_FRAGSAMPLES * dev->dma.fragptr;
- memcpy(s, s - SIZE, HFMODEM_FRAGSIZE);
- } else
- s = dev->dma.buf + HFMODEM_FRAGSAMPLES * dev->dma.fragptr;
- if (dev->sbuf.kbuf && dev->sbuf.kptr && dev->sbuf.rem > 0) {
- i = HFMODEM_FRAGSAMPLES;
- if (i > dev->sbuf.rem)
- i = dev->sbuf.rem;
- memcpy(dev->sbuf.kptr, s, i * sizeof(s[0]));
- dev->sbuf.rem -= i;
- dev->sbuf.kptr += i;
- }
- hfmodem_input_samples(dev, l1time, INC_SAMPLE, s);
- l1time += INC_FRAGMENT;
- dev->dma.fragptr++;
- if (dev->dma.fragptr >= HFMODEM_NUMFRAGS)
- dev->dma.fragptr = 0;
- }
- /*
- * check for output
- */
- if (hfmodem_next_tx_event(dev, l1time) > (long)INC_FRAGMENT/2)
- goto int_return;
- /*
- * start output
- */
- output_status(dev, 1);
- dev->scops->prepare_output(dev);
- dev->dma.last_dmaptr = 0;
- /*
- * clock adjust
- */
- l1time = hfmodem_refclock_current(dev, 0, 0);
- /*
- * fill first two fragments
- */
- dev->dma.ptt_frames = 1;
- for (i = 0; i < 2 && i < HFMODEM_NUMFRAGS; i++)
- if (hfmodem_output_samples(dev, l1time+i*INC_FRAGMENT, INC_SAMPLE,
- dev->dma.buf+i*HFMODEM_FRAGSAMPLES))
- dev->dma.ptt_frames = i + 1;
- dev->dma.lastfrag = 0;
- dev->scops->trigger_output(dev);
- /*
- * finish already pending rx requests
- */
- hfmodem_finish_pending_rx_requests(dev);
- goto int_return;
- }
- /*
- * handle transmitting
- */
- nfrags = HFMODEM_NUMFRAGS + curfrag - dev->dma.lastfrag;
- dev->dma.lastfrag = curfrag;
- if (nfrags >= HFMODEM_NUMFRAGS)
- nfrags -= HFMODEM_NUMFRAGS;
- dev->dma.ptt_frames -= nfrags;
- if (dev->dma.ptt_frames < 0)
- dev->dma.ptt_frames = 0;
- while (dev->dma.ptt_frames < HFMODEM_NUMFRAGS && dev->dma.ptt_frames < 4 &&
- hfmodem_output_samples(dev, l1time+dev->dma.ptt_frames*INC_FRAGMENT,
- INC_SAMPLE, dev->dma.buf + HFMODEM_FRAGSAMPLES *
- ((curfrag + dev->dma.ptt_frames) % HFMODEM_NUMFRAGS)))
- dev->dma.ptt_frames++;
- if (dev->dma.ptt_frames > 0)
- goto int_return;
- /*
- * start receiving
- */
- output_status(dev, 0);
- dev->dma.last_dmaptr = 0;
- dev->dma.lastfrag = 0;
- dev->dma.fragptr = 0;
- dev->dma.ptt_frames = 0;
- dev->scops->prepare_input(dev);
- dev->scops->trigger_input(dev);
- hfmodem_refclock_current(dev, 0, 0); /* needed to reset the time difference */
-int_return:
- hfmodem_wakeup(dev);
-}
-
-/* --------------------------------------------------------------------- */
-
-static int hfmodem_close(struct inode *inode, struct file *file)
-{
- struct hfmodem_state *dev = &hfmodem_state[0];
-
- if (!dev->active)
- return -EPERM;
- dev->active = 0;
- dev->scops->stop(dev);
- free_irq(dev->io.irq, dev);
- disable_dma(dev->io.dma);
- free_dma(dev->io.dma);
- release_region(dev->io.base_addr, dev->scops->extent);
- kfree_s(dev->dma.buf, HFMODEM_FRAGSIZE * (HFMODEM_NUMFRAGS+HFMODEM_EXCESSFRAGS));
- hfmodem_clear_rq(dev);
- if (dev->sbuf.kbuf) {
- kfree_s(dev->sbuf.kbuf, dev->sbuf.size);
- dev->sbuf.kbuf = dev->sbuf.kptr = NULL;
- dev->sbuf.size = dev->sbuf.rem = 0;
- }
- output_close(dev);
- MOD_DEC_USE_COUNT;
- return 0;
-}
-
-/* --------------------------------------------------------------------- */
-
-static int hfmodem_open(struct inode *inode, struct file *file)
-{
- struct hfmodem_state *dev = &hfmodem_state[0];
-
- if (dev->active)
- return -EBUSY;
- if (!dev->scops)
- return -EPERM;
- /*
- * clear vars
- */
- memset(&dev->l1, 0, sizeof(dev->l1));
- dev->dma.last_dmaptr = 0;
- dev->dma.lastfrag = 0;
- dev->dma.fragptr = 0;
- dev->dma.ptt_frames = 0;
- /*
- * allocate memory
- */
- if (!(dev->dma.buf = kmalloc(HFMODEM_FRAGSIZE * (HFMODEM_NUMFRAGS+HFMODEM_EXCESSFRAGS), GFP_KERNEL | GFP_DMA)))
- return -ENOMEM;
- /*
- * allocate resources
- */
- if (request_dma(dev->io.dma, hfmodem_drvname)) {
- kfree_s(dev->dma.buf, HFMODEM_FRAGSIZE * (HFMODEM_NUMFRAGS+HFMODEM_EXCESSFRAGS));
- return -EBUSY;
- }
- if (request_irq(dev->io.irq, hfmodem_interrupt, SA_INTERRUPT, hfmodem_drvname, dev)) {
- free_dma(dev->io.dma);
- kfree_s(dev->dma.buf, HFMODEM_FRAGSIZE * (HFMODEM_NUMFRAGS+HFMODEM_EXCESSFRAGS));
- return -EBUSY;
- }
- request_region(dev->io.base_addr, dev->scops->extent, hfmodem_drvname);
-
- /* clear requests */
- dev->active++;
- MOD_INC_USE_COUNT;
- hfmodem_refclock_init(dev);
- output_open(dev);
- dev->scops->init(dev);
- dev->scops->prepare_input(dev);
- dev->scops->trigger_input(dev);
- return 0;
-}
-
-/* --------------------------------------------------------------------- */
-
-static struct file_operations hfmodem_fops = {
- NULL, /* hfmodem_seek */
- NULL, /* hfmodem_read */
- NULL, /* hfmodem_write */
- NULL, /* hfmodem_readdir */
-#if LINUX_VERSION_CODE >= 0x20100
- hfmodem_poll, /* hfmodem_poll */
-#else
- hfmodem_select, /* hfmodem_select */
-#endif
- hfmodem_ioctl, /* hfmodem_ioctl */
- NULL, /* hfmodem_mmap */
- hfmodem_open, /* hfmodem_open */
- NULL, /* flush */
- hfmodem_close, /* hfmodem_close */
- NULL, /* hfmodem_fsync */
- NULL, /* hfmodem_fasync */
- NULL, /* hfmodem_check_media_change */
- NULL /* hfmodem_revalidate */
-};
-
-/* --------------------------------------------------------------------- */
-
-static struct miscdevice hfmodem_device = {
- HFMODEM_MINOR, hfmodem_drvname, &hfmodem_fops
-};
-
-/* --------------------------------------------------------------------- */
-
-#ifdef MODULE
-
-/*
- * Command line parameters
- */
-
-static int hw = 0;
-static unsigned int iobase = 0x220;
-static unsigned int irq = 7;
-static unsigned int dma = 1;
-
-static unsigned int serio = 0;
-static unsigned int pario = 0;
-static unsigned int midiio = 0;
-
-#if LINUX_VERSION_CODE >= 0x20115
-
-MODULE_PARM(hw, "i");
-MODULE_PARM_DESC(hw, "hardware type: 0=SBC, 1=WSS");
-MODULE_PARM(iobase, "i");
-MODULE_PARM_DESC(iobase, "io base address");
-MODULE_PARM(irq, "i");
-MODULE_PARM_DESC(irq, "interrupt number");
-MODULE_PARM(dma, "i");
-MODULE_PARM_DESC(dma, "dma number (>=4 for SB16/32/64/etc, <=3 for the rest)");
-MODULE_PARM(serio, "i");
-MODULE_PARM_DESC(serio, "address of serial port to output PTT");
-MODULE_PARM(pario, "i");
-MODULE_PARM_DESC(pario, "address of parallel port to output PTT");
-MODULE_PARM(midiio, "i");
-MODULE_PARM_DESC(midiio, "address of midi (MPU401) port to output PTT");
-
-MODULE_AUTHOR("Thomas M. Sailer, sailer@ife.ee.ethz.ch, hb9jnx@hb9w.che.eu");
-MODULE_DESCRIPTION("HF FSK modem code");
-
-/* these are the module parameters from refclock.c */
-
-MODULE_PARM(scale_tvusec, "i");
-MODULE_PARM_DESC(scale_tvusec, "Scaling value for the tv_usec field (can be obta
-ined by refclock)");
-
-#ifdef __i386__
-MODULE_PARM(scale_rdtsc, "i");
-MODULE_PARM_DESC(scale_rdtsc, "Scaling value for the rdtsc counter (can be obtai
-ned by refclock)");
-MODULE_PARM(rdtsc_ok, "i");
-MODULE_PARM_DESC(rdtsc_ok, "Set to 0 to disable the use of the rdtsc instruction
-");
-#endif /* __i386__ */
-
-#endif
-
-int __init init_module(void)
-{
- int i;
-
- printk(hfmodem_drvinfo);
- memset(hfmodem_state, 0, sizeof(hfmodem_state));
- memset(hfmodem_correlator_cache, 0, sizeof(hfmodem_correlator_cache));
- hfmodem_state[0].io.base_addr = iobase;
- hfmodem_state[0].io.irq = irq;
- hfmodem_state[0].io.dma = dma;
- hfmodem_state[0].ptt_out.seriobase = serio;
- hfmodem_state[0].ptt_out.pariobase = pario;
- hfmodem_state[0].ptt_out.midiiobase = midiio;
- init_waitqueue_head(&hfmodem_state[0].wait);
- hfmodem_refclock_probe();
- output_check(&hfmodem_state[0]);
-#if defined(CONFIG_HFMODEM_WSS) && defined(CONFIG_HFMODEM_SBC)
- if (hw)
- i = hfmodem_wssprobe(&hfmodem_state[0]);
- else
- i = hfmodem_sbcprobe(&hfmodem_state[0]);
-#else
- i = -EINVAL;
-#ifdef CONFIG_HFMODEM_WSS
- i = hfmodem_wssprobe(&hfmodem_state[0]);
-#endif
-#ifdef CONFIG_HFMODEM_SBC
- i = hfmodem_sbcprobe(&hfmodem_state[0]);
-#endif
-#endif
- if (i)
- return i;
- if ((i = misc_register(&hfmodem_device))) {
- printk(KERN_ERR "%s: cannot register misc device\n", hfmodem_drvname);
- return i;
- }
- return 0;
-}
-
-void cleanup_module(void)
-{
- struct hfmodem_state *dev = &hfmodem_state[0];
-
- if (dev->ptt_out.pariobase > 0)
- parport_unregister_device(dev->ptt_out.pardev);
- misc_deregister(&hfmodem_device);
-}
-
-#else /* MODULE */
-/* --------------------------------------------------------------------- */
-
-static int hw = 0;
-
-void __init hfmodem_setup(char *str, int *ints)
-{
- if (ints[0] < 7) {
- printk(KERN_WARNING "%s: setup: too few parameters\n", hfmodem_drvname);
- return;
- }
- memset(hfmodem_state, 0, sizeof(hfmodem_state));
- memset(hfmodem_correlator_cache, 0, sizeof(hfmodem_correlator_cache));
- hw = ints[1];
- hfmodem_state[0].io.base_addr = ints[2];
- hfmodem_state[0].io.irq = ints[3];
- hfmodem_state[0].io.dma = ints[4];
- if (ints[0] >= 8)
- hfmodem_state[0].ptt_out.seriobase = ints[5];
- if (ints[0] >= 9)
- hfmodem_state[0].ptt_out.pariobase = ints[6];
- if (ints[0] >= 10)
- hfmodem_state[0].ptt_out.midiiobase = ints[7];
- hfmodem_refclock_setscale(ints[ints[0]-2], ints[ints[0]-1], ints[ints[0]]);
-}
-
-void __init hfmodem_init(void)
-{
- int i;
-
- printk(hfmodem_drvinfo);
- init_waitqueue_head(&hfmode_state[0].wait);
- hfmodem_refclock_probe();
- output_check(&hfmodem_state[0]);
-#if defined(CONFIG_HFMODEM_WSS) && defined(CONFIG_HFMODEM_SBC)
- if (hw)
- i = hfmodem_wssprobe(&hfmodem_state[0]);
- else
- i = hfmodem_sbcprobe(&hfmodem_state[0]);
-#else
- i = -EINVAL;
-#ifdef CONFIG_HFMODEM_WSS
- i = hfmodem_wssprobe(&hfmodem_state[0]);
-#endif
-#ifdef CONFIG_HFMODEM_SBC
- i = hfmodem_sbcprobe(&hfmodem_state[0]);
-#endif
-#endif
- if (i) {
- printk(KERN_ERR "%s: soundcard probe failed\n", hfmodem_drvname);
- return;
- }
- if ((i = misc_register(&hfmodem_device))) {
- printk(KERN_ERR "%s: cannot register misc device\n", hfmodem_drvname);
- return;
- }
-}
-
-/* --------------------------------------------------------------------- */
-#endif /* MODULE */
+++ /dev/null
-/*****************************************************************************/
-
-/*
- * modem.c -- Linux soundcard HF FSK driver,
- * Modem code.
- *
- * Copyright (C) 1997 Thomas Sailer (sailer@ife.ee.ethz.ch)
- * Swiss Federal Institute of Technology (ETH), Electronics Lab
- *
- * 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.
- *
- *
- */
-
-/*****************************************************************************/
-
-
-#include <linux/wait.h>
-#include <linux/malloc.h>
-#include <linux/hfmodem.h>
-
-/* --------------------------------------------------------------------- */
-
-/*
- * currently this module is supposed to support both module styles, i.e.
- * the old one present up to about 2.1.9, and the new one functioning
- * starting with 2.1.21. The reason is I have a kit allowing to compile
- * this module also under 2.0.x which was requested by several people.
- * This will go in 2.2
- */
-#include <linux/version.h>
-
-#if LINUX_VERSION_CODE >= 0x20100
-#include <asm/uaccess.h>
-#else
-#include <asm/segment.h>
-#include <linux/mm.h>
-
-#undef put_user
-#undef get_user
-
-#define put_user(x,ptr) ({ __put_user((unsigned long)(x),(ptr),sizeof(*(ptr))); 0; })
-#define get_user(x,ptr) ({ x = ((__typeof__(*(ptr)))__get_user((ptr),sizeof(*(ptr)))); 0; })
-
-extern inline int copy_from_user(void *to, const void *from, unsigned long n)
-{
- int i = verify_area(VERIFY_READ, from, n);
- if (i)
- return i;
- memcpy_fromfs(to, from, n);
- return 0;
-}
-
-extern inline int copy_to_user(void *to, const void *from, unsigned long n)
-{
- int i = verify_area(VERIFY_WRITE, to, n);
- if (i)
- return i;
- memcpy_tofs(to, from, n);
- return 0;
-}
-#endif
-
-#if LINUX_VERSION_CODE >= 0x20123
-#include <linux/init.h>
-#else
-#define __init
-#define __initdata
-#define __initfunc(x) x
-#endif
-
-/* --------------------------------------------------------------------- */
-
-struct hfmodem_correlator_cache hfmodem_correlator_cache[HFMODEM_CORRELATOR_CACHE];
-
-/* --------------------------------------------------------------------- */
-
-#include "tables.h"
-
-#define M_PI 3.14159265358979323846 /* pi */
-
-/* --------------------------------------------------------------------- */
-
-extern __inline__ int isimplecos(unsigned int arg)
-{
- return isintab[((arg+0x4000) >> (16-SINTABBITS)) & (SINTABSIZE-1)];
-}
-
-extern __inline__ int isimplesin(unsigned int arg)
-{
- return isintab[(arg >> (16-SINTABBITS)) & (SINTABSIZE-1)];
-}
-
-/* --------------------------------------------------------------------- */
-
-extern __inline__ int itblcos(unsigned int arg)
-{
- unsigned int x;
- int dx;
- int s, c;
-
- x = (arg + (0x8000 >> SINTABBITS)) & (0xffffu & (0xffffu << (16-SINTABBITS)));
- dx = arg - x;
- x >>= (16-SINTABBITS);
- c = isintab[x+(0x4000 >> (16-SINTABBITS))];
- s = isintab[x];
- return c - ((s * dx * (int)(M_PI*64.0)) >> 21);
-}
-
-/* --------------------------------------------------------------------- */
-
-extern __inline__ void itblcossin(unsigned int arg, int *cos, int *sin)
-{
- unsigned int x;
- int dx;
- int s, c;
-
- x = (arg + (0x8000 >> SINTABBITS)) & (0xffffu & (0xffffu << (16-SINTABBITS)));
- dx = arg - x;
- x >>= (16-SINTABBITS);
- c = isintab[x+(0x4000 >> (16-SINTABBITS))];
- s = isintab[x];
- *cos = c - ((s * dx * (int)(M_PI*64.0)) >> 21);
- *sin = s + ((c * dx * (int)(M_PI*64.0)) >> 21);
-}
-
-/* --------------------------------------------------------------------- */
-
-static unsigned short random_seed;
-
-extern __inline__ unsigned short random_num(void)
-{
- random_seed = 28629 * random_seed + 157;
- return random_seed;
-}
-
-/* --------------------------------------------------------------------- */
-/*
- * correlator cache routines
- */
-
-extern __inline__ void cc_lock(unsigned int u)
-{
- if (u >= HFMODEM_CORRELATOR_CACHE)
- return;
- hfmodem_correlator_cache[u].refcnt++;
-}
-
-extern __inline__ void cc_unlock(unsigned int u)
-{
- if (u >= HFMODEM_CORRELATOR_CACHE)
- return;
- if ((--hfmodem_correlator_cache[u].refcnt) <= 0) {
- unsigned int i;
-
- for (i = 0; i < HFMODEM_CORRELATOR_CACHE; i++)
- if (hfmodem_correlator_cache[i].lru < 32767)
- hfmodem_correlator_cache[i].lru++;
- hfmodem_correlator_cache[u].lru = 0;
- hfmodem_correlator_cache[u].refcnt = 0;
- }
-}
-
-
-/* --------------------------------------------------------------------- */
-
-extern __inline__ unsigned int cc_lookup(unsigned short phinc0, unsigned short phinc1)
-{
- unsigned int j;
-
- /* find correlator cache entry */
- for (j = 0; j < HFMODEM_CORRELATOR_CACHE; j++)
- if (hfmodem_correlator_cache[j].phase_incs[0] == phinc0 &&
- hfmodem_correlator_cache[j].phase_incs[1] == phinc1)
- return j;
- return ~0;
-}
-
-/* --------------------------------------------------------------------- */
-
-extern __inline__ unsigned int cc_replace(void)
-{
- unsigned int j, k = HFMODEM_CORRELATOR_CACHE;
- int l = -1;
-
- for (j = 0; j < HFMODEM_CORRELATOR_CACHE; j++)
- if (hfmodem_correlator_cache[j].refcnt <= 0 && hfmodem_correlator_cache[j].lru > l) {
- k = j;
- l = hfmodem_correlator_cache[j].lru;
- }
- if (k < HFMODEM_CORRELATOR_CACHE)
- return k;
- printk(KERN_ERR "%s: modem: out of filter coefficient cache entries\n", hfmodem_drvname);
- return random_num() % HFMODEM_CORRELATOR_CACHE;
-}
-
-/* --------------------------------------------------------------------- */
-
-#define SH1 8 /* min. ceil(log2(L1CORR_LEN)) - (31-(2*15-1)) */
-#define SH2 (3*15-2*SH1)
-
-#ifdef __i386__
-
-extern __inline__ int icorr(int n, const int *coeff, const short *inp)
-{
- int ret, rethi, tmp1 = 0, tmp2 = 0;
-
- __asm__("\n1:\n\t"
- "movswl (%0),%%eax\n\t"
- "imull (%1)\n\t"
- "subl $2,%0\n\t"
- "addl $4,%1\n\t"
- "addl %%eax,%3\n\t"
- "adcl %%edx,%4\n\t"
- "decl %2\n\t"
- "jne 1b\n\t"
- : "=&S" (inp), "=&D" (coeff), "=&c" (n), "=m" (tmp1), "=m" (tmp2)
- : "0" (inp), "1" (coeff), "2" (n)
- : "ax", "dx");
- __asm__("shrdl %2,%1,%0\n\t"
- "# sarl %2,%1\n\t"
- : "=&r" (ret), "=&r" (rethi)
- : "i" (SH1), "0" (tmp1), "1" (tmp2));
-
-
- return ret;
-}
-
-#else /* __i386__ */
-
-extern __inline__ int icorr(int n, const int *coeff, const short *inp)
-{
- long long sum = 0;
- int i;
-
- for (i = n; i > 0; i--, coeff++, inp--)
- sum += (*coeff) * (*inp);
- sum >>= SH1;
- return sum;
-}
-
-#endif /* __i386__ */
-
-/* --------------------------------------------------------------------- */
-
-extern __inline__ long long isqr(int x) __attribute__ ((const));
-
-extern __inline__ long long isqr(int x)
-{
- return ((long long)x) * ((long long)x);
-}
-
-/* --------------------------------------------------------------------- */
-
-extern __inline__ hfmodem_soft_t do_filter(struct hfmodem_l1_rxslot *slot, short *s)
-{
- unsigned int cc = slot->corr_cache;
- long long ll;
-
- if (cc >= HFMODEM_CORRELATOR_CACHE) {
- printk(KERN_ERR "do_filter: correlator cache index overrange\n");
- return 0;
- }
- ll = isqr(icorr(slot->corrlen, hfmodem_correlator_cache[cc].correlator[1][0], s)) +
- isqr(icorr(slot->corrlen, hfmodem_correlator_cache[cc].correlator[1][1], s)) -
- isqr(icorr(slot->corrlen, hfmodem_correlator_cache[cc].correlator[0][0], s)) -
- isqr(icorr(slot->corrlen, hfmodem_correlator_cache[cc].correlator[0][1], s));
- ll >>= SH2;
- return (ll * slot->scale) >> 23;
-}
-
-/* --------------------------------------------------------------------- */
-
-static void cc_prepare(struct hfmodem_l1_rxslot *slot, unsigned short phinc0, unsigned short phinc1)
-{
- unsigned int j, k, l, ph, phinc;
-
- slot->scale = (1<<23) / (slot->corrlen*slot->corrlen);
-
- j = cc_lookup(phinc0, phinc1);
- if (j >= HFMODEM_CORRELATOR_CACHE) {
- j = cc_replace();
- /* calculate the correlator values */
- printk(KERN_DEBUG "%s: corr cache calc: %u phases: 0x%04x 0x%04x\n",
- hfmodem_drvname, j, phinc0, phinc1);
- hfmodem_correlator_cache[j].phase_incs[0] = phinc0;
- hfmodem_correlator_cache[j].phase_incs[1] = phinc1;
- for (k = 0; k < 2; k++) {
- phinc = hfmodem_correlator_cache[j].phase_incs[k];
- for (ph = l = 0; l < HFMODEM_MAXCORRLEN; l++, ph = (ph + phinc) & 0xffff)
- itblcossin(ph, &hfmodem_correlator_cache[j].correlator[k][0][l],
- &hfmodem_correlator_cache[j].correlator[k][1][l]);
- }
- hfmodem_correlator_cache[j].refcnt = 0;
-
-#if 0
- printk(KERN_DEBUG "%s: corr: %u ph: 0x%04x 0x%04x\n", hfmodem_drvname, j,
- hfmodem_correlator_cache[j].phase_incs[0],
- hfmodem_correlator_cache[j].phase_incs[1]);
- for (l = 0; l < HFMODEM_MAXCORRLEN; l++)
- printk(KERN_DEBUG "%s: corr: %6d %6d %6d %6d\n", hfmodem_drvname,
- hfmodem_correlator_cache[j].correlator[0][0][l],
- hfmodem_correlator_cache[j].correlator[0][1][l],
- hfmodem_correlator_cache[j].correlator[1][0][l],
- hfmodem_correlator_cache[j].correlator[1][1][l]);
-#endif
- }
- slot->corr_cache = j;
- cc_lock(j);
-}
-
-/* --------------------------------------------------------------------- */
-
-void hfmodem_clear_rq(struct hfmodem_state *dev)
-{
- unsigned long flags;
- unsigned int i;
-
- save_flags(flags);
- cli();
- for (i = 0; i < HFMODEM_NUMRXSLOTS; i++) {
- if (dev->l1.rxslots[i].state == ss_unused)
- continue;
- dev->l1.rxslots[i].state = ss_unused;
- kfree_s(dev->l1.rxslots[i].data, dev->l1.rxslots[i].nbits * sizeof(hfmodem_soft_t));
- }
- for (i = 0; i < HFMODEM_NUMTXSLOTS; i++) {
- if (dev->l1.txslots[i].state == ss_unused)
- continue;
- dev->l1.txslots[i].state = ss_unused;
- kfree_s(dev->l1.txslots[i].data, (dev->l1.txslots[i].nbits + 7) >> 3);
- }
- for (i = 0; i < HFMODEM_CORRELATOR_CACHE; i++)
- hfmodem_correlator_cache[i].refcnt = 0;
- restore_flags(flags);
-}
-
-/* --------------------------------------------------------------------- */
-
-int hfmodem_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
-{
- struct hfmodem_state *dev = &hfmodem_state[0];
- struct hfmodem_ioctl_fsk_tx_request txrq;
- struct hfmodem_ioctl_fsk_rx_request rxrq;
- struct hfmodem_ioctl_mixer_params mix;
- struct hfmodem_ioctl_sample_params spar;
- unsigned long flags;
- unsigned int len;
- int ret, i, idx;
- void *data, *userdata;
- hfmodem_id_t id;
- hfmodem_time_t tm = 0;
-
- if (!dev->active)
- return -EBUSY;
- switch(cmd) {
- default:
- return -EINVAL;
-
- case HFMODEM_IOCTL_FSKTXREQUEST:
- if ((ret = copy_from_user(&txrq, (void *)arg, sizeof(txrq))))
- return ret;
- if (txrq.nbits > HFMODEM_MAXBITS)
- return -EINVAL;
- len = (txrq.nbits + 7) >> 3;
- if (!(data = kmalloc(len, GFP_KERNEL)))
- return -ENOMEM;
- if (copy_from_user(data, txrq.data, len)) {
- kfree_s(data, len);
- return -EFAULT;
- }
- save_flags(flags);
- cli();
- for (i = 0; i < HFMODEM_NUMTXSLOTS && dev->l1.txslots[i].state != ss_unused; i++);
- if (i >= HFMODEM_NUMTXSLOTS) {
- restore_flags(flags);
- kfree_s(data, len);
- return -EBUSY;
- }
- dev->l1.txslots[i].state = ss_ready;
- dev->l1.txslots[i].tstart = txrq.tstart;
- dev->l1.txslots[i].tinc = txrq.tinc;
- dev->l1.txslots[i].data = data;
- dev->l1.txslots[i].nbits = txrq.nbits;
- dev->l1.txslots[i].cntbits = 0;
- dev->l1.txslots[i].inv = txrq.inv ? 0xff : 0;
- dev->l1.txslots[i].id = txrq.id;
- dev->l1.txslots[i].phase_incs[0] = ((txrq.freq[0]*0x10000+(HFMODEM_SRATE/2))/HFMODEM_SRATE)
- & 0xffff;
- dev->l1.txslots[i].phase_incs[1] = ((txrq.freq[1]*0x10000+(HFMODEM_SRATE/2))/HFMODEM_SRATE)
- & 0xffff;
- restore_flags(flags);
- return 0;
-
- case HFMODEM_IOCTL_FSKRXREQUEST:
- if ((ret = copy_from_user(&rxrq, (void *)arg, sizeof(rxrq))))
- return ret;
- if (rxrq.nbits > HFMODEM_MAXBITS)
- return -EINVAL;
- if (rxrq.baud < HFMODEM_MINBAUD || rxrq.baud > HFMODEM_MAXBAUD)
- return -EINVAL;
- len = rxrq.nbits * sizeof(hfmodem_soft_t);
- if (verify_area(VERIFY_WRITE, rxrq.data, len))
- return -EFAULT;
- if (!(data = kmalloc(len, GFP_KERNEL)))
- return -ENOMEM;
- save_flags(flags);
- cli();
- for (i = 0; i < HFMODEM_NUMRXSLOTS && dev->l1.rxslots[i].state != ss_unused; i++);
- if (i >= HFMODEM_NUMRXSLOTS) {
- restore_flags(flags);
- kfree_s(data, len);
- return -EBUSY;
- }
- dev->l1.rxslots[i].state = ss_ready;
- dev->l1.rxslots[i].tstart = rxrq.tstart;
- dev->l1.rxslots[i].tinc = rxrq.tinc;
- dev->l1.rxslots[i].data = data;
- dev->l1.rxslots[i].userdata = rxrq.data;
- dev->l1.rxslots[i].nbits = rxrq.nbits;
- dev->l1.rxslots[i].cntbits = 0;
- dev->l1.rxslots[i].id = rxrq.id;
- dev->l1.rxslots[i].corrlen = HFMODEM_SRATE/rxrq.baud;
- cc_prepare(dev->l1.rxslots+i,
- ((rxrq.freq[0]*0x10000+(HFMODEM_SRATE/2))/HFMODEM_SRATE) & 0xffff,
- ((rxrq.freq[1]*0x10000+(HFMODEM_SRATE/2))/HFMODEM_SRATE) & 0xffff);
- restore_flags(flags);
- return 0;
-
- case HFMODEM_IOCTL_CLEARRQ:
- hfmodem_clear_rq(dev);
- return 0;
-
- case HFMODEM_IOCTL_GETCURTIME:
- return put_user(dev->l1.last_time + 20000L, (hfmodem_time_t *)arg); /* heuristic */
-
- case HFMODEM_IOCTL_WAITRQ:
- save_flags(flags);
- cli();
- ret = 0;
- for (idx = -1, i = 0; i < HFMODEM_NUMRXSLOTS; i++) {
- if (dev->l1.rxslots[i].state == ss_unused)
- continue;
- if (dev->l1.rxslots[i].state != ss_retired) {
- ret++;
- continue;
- }
- if (idx < 0 || (signed)(tm - dev->l1.rxslots[i].tstart) > 0) {
- idx = i;
- tm = dev->l1.rxslots[i].tstart;
- }
- }
- if (idx >= 0) {
- cc_unlock(dev->l1.rxslots[idx].corr_cache);
- id = dev->l1.rxslots[idx].id;
- data = dev->l1.rxslots[idx].data;
- userdata = dev->l1.rxslots[idx].userdata;
- len = dev->l1.rxslots[idx].nbits * sizeof(hfmodem_soft_t);
- dev->l1.rxslots[idx].state = ss_unused;
- restore_flags(flags);
- ret = copy_to_user(userdata, data, len);
- kfree_s(data, len);
- return (put_user(id, (hfmodem_id_t *)arg)) ? -EFAULT : ret;
- }
- for (idx = -1, i = 0; i < HFMODEM_NUMTXSLOTS; i++) {
- if (dev->l1.txslots[i].state == ss_unused)
- continue;
- if (dev->l1.txslots[i].state != ss_retired) {
- ret++;
- continue;
- }
- if (idx < 0 || (signed)(tm - dev->l1.txslots[i].tstart) > 0) {
- idx = i;
- tm = dev->l1.txslots[i].tstart;
- }
- }
- if (idx >= 0) {
- id = dev->l1.txslots[idx].id;
- data = dev->l1.txslots[idx].data;
- len = (dev->l1.txslots[idx].nbits + 7) >> 3;
- dev->l1.txslots[idx].state = ss_unused;
- restore_flags(flags);
- kfree_s(data, len);
- return put_user(id, (hfmodem_id_t *)arg);
- }
- restore_flags(flags);
- return ret ? -EAGAIN : -EPIPE;
-
- case HFMODEM_IOCTL_MIXERPARAMS:
- if ((ret = copy_from_user(&mix, (void *)arg, sizeof(mix))))
- return ret;
- dev->scops->mixer(dev, mix.src, mix.igain, mix.ogain);
- return 0;
-
- case HFMODEM_IOCTL_SAMPLESTART:
- save_flags(flags);
- cli();
- if (dev->sbuf.kbuf)
- kfree_s(dev->sbuf.kbuf, dev->sbuf.size);
- dev->sbuf.kbuf = dev->sbuf.kptr = NULL;
- dev->sbuf.size = dev->sbuf.rem = 0;
- restore_flags(flags);
- if ((ret = copy_from_user(&spar, (void *)arg, sizeof(spar))))
- return ret;
- if (spar.len == 0)
- return 0;
- if (spar.len < 2 || spar.len > 8192)
- return -EINVAL;
- if (verify_area(VERIFY_WRITE, spar.data, spar.len * sizeof(__s16)))
- return -EFAULT;
- if (!(dev->sbuf.kbuf = kmalloc(spar.len * sizeof(__s16), GFP_KERNEL)))
- return -ENOMEM;
- save_flags(flags);
- cli();
- dev->sbuf.kptr = dev->sbuf.kbuf;
- dev->sbuf.size = spar.len * sizeof(__s16);
- dev->sbuf.rem = spar.len;
- dev->sbuf.ubuf = spar.data;
- restore_flags(flags);
- return 0;
-
- case HFMODEM_IOCTL_SAMPLEFINISHED:
- save_flags(flags);
- cli();
- if (dev->sbuf.rem > 0) {
- restore_flags(flags);
- return -EAGAIN;
- }
- if (!dev->sbuf.kbuf || !dev->sbuf.size) {
- restore_flags(flags);
- return -EPIPE;
- }
- restore_flags(flags);
- ret = copy_to_user(dev->sbuf.ubuf, dev->sbuf.kbuf, dev->sbuf.size);
- kfree_s(dev->sbuf.kbuf, dev->sbuf.size);
- dev->sbuf.kbuf = dev->sbuf.kptr = NULL;
- dev->sbuf.size = dev->sbuf.rem = 0;
- return ret;
- }
-}
-
-/* --------------------------------------------------------------------- */
-
-#if LINUX_VERSION_CODE >= 0x20100
-
-unsigned int hfmodem_poll(struct file *file, poll_table *wait)
-{
- struct hfmodem_state *dev = &hfmodem_state[0];
- unsigned long flags;
- int i, cnt1, cnt2;
-
- poll_wait(file, &dev->wait, wait);
- save_flags(flags);
- cli();
- for (i = cnt1 = cnt2 = 0; i < HFMODEM_NUMTXSLOTS; i++) {
- if (dev->l1.txslots[i].state == ss_retired)
- cnt1++;
- if (dev->l1.txslots[i].state != ss_unused)
- cnt2++;
- }
- for (i = 0; i < HFMODEM_NUMRXSLOTS; i++) {
- if (dev->l1.rxslots[i].state == ss_retired)
- cnt1++;
- if (dev->l1.rxslots[i].state != ss_unused)
- cnt2++;
- }
- restore_flags(flags);
- if (cnt1 || !cnt2)
- return POLLIN | POLLRDNORM;
- return 0;
-}
-
-#else
-
-int hfmodem_select(struct inode *inode, struct file *file, int sel_type, select_table *wait)
-{
- struct hfmodem_state *dev = &hfmodem_state[0];
- unsigned long flags;
- int i, cnt1, cnt2;
-
- if (sel_type == SEL_IN) {
- save_flags(flags);
- cli();
- for (i = cnt1 = cnt2 = 0; i < HFMODEM_NUMTXSLOTS; i++) {
- if (dev->l1.txslots[i].state == ss_retired)
- cnt1++;
- if (dev->l1.txslots[i].state != ss_unused)
- cnt2++;
- }
- for (i = 0; i < HFMODEM_NUMRXSLOTS; i++) {
- if (dev->l1.rxslots[i].state == ss_retired)
- cnt1++;
- if (dev->l1.rxslots[i].state != ss_unused)
- cnt2++;
- }
- restore_flags(flags);
- if (cnt1 || !cnt2)
- return 1;
- select_wait(&dev->wait, wait);
- }
- return 0;
-}
-
-#endif
-
-/* --------------------------------------------------------------------- */
-
-extern __inline__ unsigned int l1fsk_phinc(struct hfmodem_l1_txslot *txs, unsigned int nbit)
-{
- return txs->phase_incs[!!((txs->data[nbit >> 3] ^ txs->inv) & (1 << (nbit & 7)))];
-}
-
-/* --------------------------------------------------------------------- */
-
-void hfmodem_input_samples(struct hfmodem_state *dev, hfmodem_time_t tstart,
- hfmodem_time_t tinc, __s16 *samples)
-{
- hfmodem_time_t tst, tend;
- __s16 *s;
- int i, j;
- hfmodem_soft_t sample;
-
- dev->l1.last_time = tstart + (HFMODEM_FRAGSAMPLES-1) * tinc;
- for (i = 0; i < HFMODEM_NUMRXSLOTS; i++) {
- struct hfmodem_l1_rxslot *rxs = dev->l1.rxslots + i;
-
- if (rxs->state == ss_unused || rxs->state == ss_retired)
- continue;
- tst = tstart - (rxs->corrlen-1) * tinc;
- tend = tst + (HFMODEM_FRAGSAMPLES-1) * tinc;
- if (rxs->state == ss_ready) {
- if ((signed)(rxs->tstart - tend) > 0)
- continue;
- rxs->state = ss_oper;
- }
- for (s = samples, j = 0; j < HFMODEM_FRAGSAMPLES; j++, s++, tst += tinc)
- if ((signed)(rxs->tstart - tst) <= 0) {
- sample = do_filter(rxs, s);
- while ((signed)(rxs->tstart - tst) <= 0 &&
- rxs->cntbits < rxs->nbits) {
- rxs->data[rxs->cntbits] = sample;
- rxs->cntbits++;
- rxs->tstart += rxs->tinc;
- }
- if (rxs->cntbits >= rxs->nbits) {
- rxs->state = ss_retired;
- break;
- }
- }
- }
-}
-
-/* --------------------------------------------------------------------- */
-
-extern __inline__ unsigned int output_one_sample(struct hfmodem_state *dev, hfmodem_time_t tm)
-{
- int i, j, k;
- struct hfmodem_l1_txslot *txs;
- /*
- * first activate new output slots
- */
- for (j = -1, i = 0; i < HFMODEM_NUMTXSLOTS; i++) {
- txs = dev->l1.txslots + i;
- if (txs->state == ss_ready && (signed)(txs->tstart - tm) <= 0) {
- for (k = 0; k < HFMODEM_NUMTXSLOTS; k++) {
- if (dev->l1.txslots[k].state != ss_oper)
- continue;
- dev->l1.txslots[k].state = ss_retired;
- }
- txs->state = ss_oper;
- txs->tstart += txs->tinc;
- txs->phinc = l1fsk_phinc(txs, 0);
- txs->cntbits = 1;
- };
- if (txs->state != ss_oper)
- continue;
- j = i;
- }
- if (j < 0 || j >= HFMODEM_NUMTXSLOTS)
- return 0;
- /*
- * calculate the current slot
- */
- txs = dev->l1.txslots + j;
- while ((signed)(txs->tstart - tm) <= 0) {
- if (txs->cntbits >= txs->nbits) {
- txs->state = ss_retired;
- return 0;
- }
- txs->tstart += txs->tinc;
- txs->phinc = l1fsk_phinc(txs, txs->cntbits);
- txs->cntbits++;
- }
- return txs->phinc;
-}
-
-/* --------------------------------------------------------------------- */
-
-int hfmodem_output_samples(struct hfmodem_state *dev, hfmodem_time_t tstart,
- hfmodem_time_t tinc, __s16 *samples)
-{
- int i, j;
- hfmodem_time_t tend = tstart + (HFMODEM_FRAGSAMPLES-1) * tinc;
-
- for (i = 0; i < HFMODEM_NUMTXSLOTS; i++) {
- if (dev->l1.txslots[i].state == ss_oper)
- break;
- if (dev->l1.txslots[i].state == ss_ready &&
- (signed)(dev->l1.txslots[i].tstart - tend) <= 0)
- break;
- }
- if (i >= HFMODEM_NUMTXSLOTS)
- return 0;
- for (j = 0; j < HFMODEM_FRAGSAMPLES; j++, tstart += tinc, samples++) {
- *samples = isimplecos(dev->l1.tx_phase);
- dev->l1.tx_phase += output_one_sample(dev, tstart);
- }
- return 1;
-}
-
-/* --------------------------------------------------------------------- */
-
-long hfmodem_next_tx_event(struct hfmodem_state *dev, hfmodem_time_t curr)
-{
- long diff = LONG_MAX, t;
- int i;
-
- for (i = 0; i < HFMODEM_NUMTXSLOTS; i++) {
- if (dev->l1.txslots[i].state == ss_oper)
- if (diff > 0)
- diff = 0;
- if (dev->l1.txslots[i].state == ss_ready) {
- t = dev->l1.txslots[i].tstart - curr;
- if (t < diff)
- diff = t;
- }
- }
- return diff;
-}
-
-/* --------------------------------------------------------------------- */
-
-void hfmodem_finish_pending_rx_requests(struct hfmodem_state *dev)
-{
- int i;
-
- for (i = 0; i < HFMODEM_NUMRXSLOTS; i++) {
- if (dev->l1.rxslots[i].state != ss_oper)
- continue;
- while (dev->l1.rxslots[i].cntbits < dev->l1.rxslots[i].nbits) {
- dev->l1.rxslots[i].data[dev->l1.rxslots[i].cntbits] = 0;
- dev->l1.rxslots[i].cntbits++;
- }
- dev->l1.rxslots[i].state = ss_retired;
- }
-}
-
-/* --------------------------------------------------------------------- */
-
-void hfmodem_wakeup(struct hfmodem_state *dev)
-{
- int i, cnt1, cnt2;
-
- for (i = cnt1 = cnt2 = 0; i < HFMODEM_NUMTXSLOTS; i++) {
- if (dev->l1.txslots[i].state == ss_retired)
- cnt1++;
- if (dev->l1.txslots[i].state != ss_unused)
- cnt2++;
- }
- for (i = 0; i < HFMODEM_NUMRXSLOTS; i++) {
- if (dev->l1.rxslots[i].state == ss_retired)
- cnt1++;
- if (dev->l1.rxslots[i].state != ss_unused)
- cnt2++;
- }
- if (cnt1 || !cnt2)
- wake_up_interruptible(&dev->wait);
-}
-
-/* --------------------------------------------------------------------- */
+++ /dev/null
-/*****************************************************************************/
-
-/*
- * refclock.c -- Linux soundcard HF FSK driver,
- * Reference clock routines.
- *
- * Copyright (C) 1997 Thomas Sailer (sailer@ife.ee.ethz.ch)
- * Swiss Federal Institute of Technology (ETH), Electronics Lab
- *
- * 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.
- *
- *
- */
-
-/*****************************************************************************/
-
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/time.h>
-#include <linux/hfmodem.h>
-#include <asm/processor.h>
-
-/* --------------------------------------------------------------------- */
-
-/*
- * currently this module is supposed to support both module styles, i.e.
- * the old one present up to about 2.1.9, and the new one functioning
- * starting with 2.1.21. The reason is I have a kit allowing to compile
- * this module also under 2.0.x which was requested by several people.
- * This will go in 2.2
- */
-#include <linux/version.h>
-
-#if LINUX_VERSION_CODE >= 0x20123
-#include <linux/init.h>
-#else
-#define __init
-#define __initdata
-#define __initfunc(x) x
-#endif
-
-/* --------------------------------------------------------------------- */
-/*
- * command line params
- */
-
-static unsigned int scale_tvusec = 1UL<<24;
-
-#ifdef __i386__
-static unsigned int scale_rdtsc = 0;
-static int rdtsc_ok = 1;
-#endif /* __i386__ */
-
-/* --------------------------------------------------------------------- */
-
-#ifdef __i386__
-static void __init i386_capability(void)
-{
- if (boot_cpu_data.x86_capability & X86_FEATURE_TSC)
- rdtsc_ok = 1;
- else
- printk(KERN_INFO "%s: cpu does not support the rdtsc instruction\n", hfmodem_drvname);
-}
-#endif /* __i386__ */
-
-/* --------------------------------------------------------------------- */
-
-void __init hfmodem_refclock_probe(void)
-{
-#ifdef __i386__
- if (rdtsc_ok) {
- rdtsc_ok = 0;
- i386_capability();
- if (rdtsc_ok) {
- unsigned int tmp0, tmp1, tmp2, tmp3;
- __asm__("rdtsc" : "=a" (tmp0), "=d" (tmp1));
- __asm__("rdtsc" : "=a" (tmp2), "=d" (tmp3));
- if (tmp0 == tmp2 && tmp1 == tmp3) {
- rdtsc_ok = 0;
- printk(KERN_WARNING "%s: rdtsc unusable, does not change\n",
- hfmodem_drvname);
- }
- }
- }
- printk(KERN_INFO "%s: using %s as timing source\n", hfmodem_drvname,
- rdtsc_ok ? "rdtsc" : "gettimeofday");
-#endif /* __i386__ */
-}
-
-/* --------------------------------------------------------------------- */
-
-void hfmodem_refclock_init(struct hfmodem_state *dev)
-{
- struct timeval tv;
-
- dev->clk.lasttime = 0;
-#ifdef __i386__
- if (rdtsc_ok) {
- __asm__("rdtsc;" : "=&d" (dev->clk.starttime_hi), "=&a" (dev->clk.starttime_lo));
- return;
- }
-#endif /* __i386__ */
- do_gettimeofday(&tv);
- dev->clk.last_tvusec = tv.tv_usec;
- dev->clk.time_cnt = 0;
-}
-
-/* --------------------------------------------------------------------- */
-
-hfmodem_time_t hfmodem_refclock_current(struct hfmodem_state *dev, hfmodem_time_t expected, int exp_valid)
-{
- struct timeval tv;
- hfmodem_time_t curtime;
- long diff;
-
-#ifdef __i386__
- if (rdtsc_ok) {
- unsigned int tmp0, tmp1;
- unsigned int tmp2, tmp3;
-
- __asm__("rdtsc;\n\t"
- "subl %2,%%eax\n\t"
- "sbbl %3,%%edx\n\t" : "=&a" (tmp0), "=&d" (tmp1)
- : "m" (dev->clk.starttime_lo), "m" (dev->clk.starttime_hi) : "ax", "dx");
- __asm__("mull %1" : "=d" (tmp2) : "m" (scale_rdtsc), "a" (tmp0) : "ax");
- __asm__("mull %1" : "=a" (tmp3) : "m" (scale_rdtsc), "a" (tmp1) : "dx");
- curtime = tmp2 + tmp3;
- goto time_known;
- }
-#endif /* __i386__ */
- do_gettimeofday(&tv);
- dev->clk.time_cnt += (unsigned)(1000000 + tv.tv_usec - dev->clk.last_tvusec) % 1000000;
- dev->clk.last_tvusec = tv.tv_usec;
- curtime = (dev->clk.time_cnt * scale_tvusec) >> 24;
- time_known:
- if (exp_valid && abs(diff = (curtime - dev->clk.lasttime - expected)) >= 1000)
- printk(KERN_DEBUG "%s: refclock adjustment %ld more than 1ms\n",
- hfmodem_drvname, diff);
- return (dev->clk.lasttime = curtime);
-}
-
-/* --------------------------------------------------------------------- */
+++ /dev/null
-/*****************************************************************************/
-
-/*
- * sbc.c -- Linux soundcard HF FSK driver,
- * Soundblaster specific functions.
- *
- * Copyright (C) 1997 Thomas Sailer (sailer@ife.ee.ethz.ch)
- * Swiss Federal Institute of Technology (ETH), Electronics Lab
- *
- * 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.
- *
- *
- */
-
-/*****************************************************************************/
-
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/delay.h>
-#include <linux/errno.h>
-#include <linux/sched.h>
-#include <linux/ioport.h>
-#include <linux/hfmodem.h>
-
-#include <asm/io.h>
-#include <asm/dma.h>
-
-/* --------------------------------------------------------------------- */
-/*
- * the sbc converter's registers
- */
-#define DSP_RESET(iobase) (iobase+0x6)
-#define DSP_READ_DATA(iobase) (iobase+0xa)
-#define DSP_WRITE_DATA(iobase) (iobase+0xc)
-#define DSP_WRITE_STATUS(iobase) (iobase+0xc)
-#define DSP_DATA_AVAIL(iobase) (iobase+0xe)
-#define DSP_MIXER_ADDR(iobase) (iobase+0x4)
-#define DSP_MIXER_DATA(iobase) (iobase+0x5)
-#define DSP_INTACK_16BIT(iobase) (iobase+0xf)
-#define SBC_EXTENT 16
-
-/* --------------------------------------------------------------------- */
-/*
- * SBC commands
- */
-
-#define SBC_OUTPUT 0x14
-#define SBC_INPUT 0x24
-#define SBC_BLOCKSIZE 0x48
-#define SBC_HI_OUTPUT 0x91
-#define SBC_HI_INPUT 0x99
-#define SBC_LO_OUTPUT_AUTOINIT 0x1c
-#define SBC_LO_INPUT_AUTOINIT 0x2c
-#define SBC_HI_OUTPUT_AUTOINIT 0x90
-#define SBC_HI_INPUT_AUTOINIT 0x98
-#define SBC_IMMED_INT 0xf2
-#define SBC_GET_REVISION 0xe1
-#define ESS_GET_REVISION 0xe7
-#define ESS_EXTENDED_MODE 0xc6
-#define SBC_SPEAKER_ON 0xd1
-#define SBC_SPEAKER_OFF 0xd3
-#define SBC_DMA_ON 0xd0
-#define SBC_DMA_OFF 0xd4
-#define SBC_SAMPLE_RATE 0x40
-#define SBC_SAMPLE_RATE_OUT 0x41
-#define SBC_SAMPLE_RATE_IN 0x42
-#define SBC_MONO_8BIT 0xa0
-#define SBC_MONO_16BIT 0xa4
-#define SBC_STEREO_8BIT 0xa8
-#define SBC_STEREO_16BIT 0xac
-
-#define SBC4_OUT8_AI 0xc6
-#define SBC4_IN8_AI 0xce
-#define SBC4_MODE_UNS_MONO 0x00
-#define SBC4_MODE_SIGN_MONO 0x10
-
-#define SBC4_OUT16_AI 0xb6
-#define SBC4_IN16_AI 0xbe
-#define SBC4_OUT16_AI_NO_FIFO 0xb4
-#define SBC4_IN16_AI_NO_FIFO 0xbc
-
-/* --------------------------------------------------------------------- */
-
-extern const struct hfmodem_scops sbc4_scops;
-extern const struct hfmodem_scops ess_scops;
-
-/* --------------------------------------------------------------------- */
-
-static int reset_dsp(struct hfmodem_state *dev)
-{
- int i;
-
- outb(1, DSP_RESET(dev->io.base_addr));
- udelay(3);
- outb(0, DSP_RESET(dev->io.base_addr));
- for (i = 0; i < 0xffff; i++)
- if (inb(DSP_DATA_AVAIL(dev->io.base_addr)) & 0x80)
- if (inb(DSP_READ_DATA(dev->io.base_addr)) == 0xaa)
- return 1;
- return 0;
-}
-
-/* --------------------------------------------------------------------- */
-
-static void write_dsp(struct hfmodem_state *dev, unsigned char data)
-{
- int i;
-
- for (i = 0; i < 0xffff; i++)
- if (!(inb(DSP_WRITE_STATUS(dev->io.base_addr)) & 0x80)) {
- outb(data, DSP_WRITE_DATA(dev->io.base_addr));
- return;
- }
-}
-
-/* --------------------------------------------------------------------- */
-
-static int read_dsp(struct hfmodem_state *dev, unsigned char *data)
-{
- int i;
-
- if (!data)
- return 0;
- for (i = 0; i < 0xffff; i++)
- if (inb(DSP_DATA_AVAIL(dev->io.base_addr)) & 0x80) {
- *data = inb(DSP_READ_DATA(dev->io.base_addr));
- return 1;
- }
- return 0;
-}
-
-/* --------------------------------------------------------------------- */
-
-static void write_ess(struct hfmodem_state *dev, unsigned char reg, unsigned char data)
-{
- write_dsp(dev, reg);
- write_dsp(dev, data);
-}
-
-/* --------------------------------------------------------------------- */
-
-static int read_ess(struct hfmodem_state *dev, unsigned char reg, unsigned char *data)
-{
- write_dsp(dev, 0xc0);
- write_dsp(dev, reg);
- return read_dsp(dev, data);
-}
-
-/* --------------------------------------------------------------------- */
-
-static int reset_ess(struct hfmodem_state *dev)
-{
- int i;
-
- outb(3, DSP_RESET(dev->io.base_addr)); /* reset FIFOs too */
- udelay(3);
- outb(0, DSP_RESET(dev->io.base_addr));
- for (i = 0; i < 0xffff; i++)
- if (inb(DSP_DATA_AVAIL(dev->io.base_addr)) & 0x80)
- if (inb(DSP_READ_DATA(dev->io.base_addr)) == 0xaa) {
- write_dsp(dev, ESS_EXTENDED_MODE);
- return 1;
- }
- return 0;
-}
-
-/* --------------------------------------------------------------------- */
-
-static int config_resources(struct hfmodem_state *dev)
-{
- unsigned char irqreg = 0, dmareg = 0, realirq, realdma;
- unsigned long flags;
-
- switch (dev->io.irq) {
- case 2:
- case 9:
- irqreg |= 0x01;
- break;
-
- case 5:
- irqreg |= 0x02;
- break;
-
- case 7:
- irqreg |= 0x04;
- break;
-
- case 10:
- irqreg |= 0x08;
- break;
-
- default:
- return -ENODEV;
- }
-
- switch (dev->io.dma) {
- case 0:
- dmareg |= 0x01;
- break;
-
- case 1:
- dmareg |= 0x02;
- break;
-
- case 3:
- dmareg |= 0x08;
- break;
-
- case 5:
- dmareg |= 0x20;
- break;
-
- case 6:
- dmareg |= 0x40;
- break;
-
- case 7:
- dmareg |= 0x80;
- break;
-
- default:
- return -ENODEV;
- }
- save_flags(flags);
- cli();
- outb(0x80, DSP_MIXER_ADDR(dev->io.base_addr));
- outb(irqreg, DSP_MIXER_DATA(dev->io.base_addr));
- realirq = inb(DSP_MIXER_DATA(dev->io.base_addr));
- outb(0x81, DSP_MIXER_ADDR(dev->io.base_addr));
- outb(dmareg, DSP_MIXER_DATA(dev->io.base_addr));
- realdma = inb(DSP_MIXER_DATA(dev->io.base_addr));
- restore_flags(flags);
- if ((~realirq) & irqreg || (~realdma) & dmareg) {
- printk(KERN_ERR "%s: sbc resource registers cannot be set; PnP device "
- "and IRQ/DMA specified wrongly?\n", hfmodem_drvname);
- return -EINVAL;
- }
- return 0;
-}
-
-/* --------------------------------------------------------------------- */
-
-extern __inline__ void sbc_int_ack_8bit(struct hfmodem_state *dev)
-{
- inb(DSP_DATA_AVAIL(dev->io.base_addr));
-}
-
-/* --------------------------------------------------------------------- */
-
-extern __inline__ void sbc_int_ack_16bit(struct hfmodem_state *dev)
-{
- inb(DSP_INTACK_16BIT(dev->io.base_addr));
-}
-
-/* --------------------------------------------------------------------- */
-
-static void set_mixer(struct hfmodem_state *dev, unsigned char reg, unsigned char data)
-{
- outb(reg, DSP_MIXER_ADDR(dev->io.base_addr));
- outb(data, DSP_MIXER_DATA(dev->io.base_addr));
-}
-
-/* --------------------------------------------------------------------- */
-
-int hfmodem_sbcprobe(struct hfmodem_state *dev)
-{
- unsigned char revhi, revlo, essrevhi, essrevlo, tmp;
- int ret;
-
- if (dev->io.base_addr <= 0 || dev->io.base_addr > 0x1000-SBC_EXTENT ||
- dev->io.irq < 2 || dev->io.irq > 15 || dev->io.dma > 7 || dev->io.dma == 2)
- return -ENXIO;
- if (check_region(dev->io.base_addr, SBC_EXTENT))
- return -EACCES;
- /*
- * check if a card is available
- */
- if (!reset_dsp(dev)) {
- printk(KERN_ERR "%s: sbc: no card at io address 0x%x\n",
- hfmodem_drvname, dev->io.base_addr);
- return -ENODEV;
- }
- set_mixer(dev, 0, 0); /* reset mixer */
- write_dsp(dev, SBC_GET_REVISION);
- if (!read_dsp(dev, &revhi) || !read_dsp(dev, &revlo))
- return -ENODEV;
- printk(KERN_INFO "%s: SoundBlaster DSP revision %d.%02d\n", hfmodem_drvname, revhi, revlo);
- if (revhi == 3 && revlo == 1) {
- write_dsp(dev, ESS_GET_REVISION);
- if (!read_dsp(dev, &essrevhi) || !read_dsp(dev, &essrevlo))
- return -ENODEV;
- if (essrevhi == 0x48 && (essrevlo & 0xf0) == 0x80) {
- printk(KERN_INFO "%s: ESS ES488 AudioDrive (rev %d): unsupported.\n",
- hfmodem_drvname, essrevlo & 0x0f);
- return -ENODEV;
- }
- if (essrevhi == 0x68 && (essrevlo & 0xf0) == 0x80) {
- printk(KERN_INFO "%s: ESS ES%s688 AudioDrive (rev %d)\n",
- hfmodem_drvname, ((essrevlo & 0x0f) >= 8) ? "1" : "", essrevlo & 0x0f);
- if (dev->io.dma > 3) {
- printk(KERN_INFO "%s: DMA number out of range\n", hfmodem_drvname);
- return -ENXIO;
- }
- printk(KERN_INFO "%s: ess: irq: ", hfmodem_drvname);
- read_ess(dev, 0xb1, &tmp);
- switch (tmp & 0xf) {
- case 0:
- printk("2, 9, \"all others\"");
- break;
-
- case 5:
- printk("5");
- break;
-
- case 10:
- printk("7");
- break;
-
- case 15:
- printk("10");
- break;
-
- default:
- printk("unknown (%d)", tmp & 0xf);
- break;
- }
- printk(" dma: ");
- read_ess(dev, 0xb2, &tmp);
- switch (tmp & 0xf) {
- case 0:
- printk("\"all others\"");
- break;
-
- case 5:
- printk("0");
- break;
-
- case 10:
- printk("1");
- break;
-
- case 15:
- printk("3");
- break;
-
- default:
- printk("unknown (%d)", tmp & 0xf);
- break;
- }
- printk("\n");
- dev->scops = &ess_scops;
- return 0;
- }
- }
- if (revhi < 4) {
- printk(KERN_INFO "%s: at least SB16 required\n", hfmodem_drvname);
- return -ENODEV;
- }
- if (dev->io.dma < 4) {
- printk(KERN_INFO "%s: DMA number out of range\n", hfmodem_drvname);
- return -ENXIO;
- }
- if ((ret = config_resources(dev)))
- return ret;
- dev->scops = &sbc4_scops;
- return 0;
-}
-
-/* --------------------------------------------------------------------- */
-
-static void sbc4_init(struct hfmodem_state *dev)
-{
-}
-
-/* --------------------------------------------------------------------- */
-
-static void sbc4_prepare_input(struct hfmodem_state *dev)
-{
- unsigned long flags;
-
- if (!reset_dsp(dev)) {
- printk(KERN_ERR "%s: sbc: cannot reset sb dsp\n", hfmodem_drvname);
- return;
- }
- save_flags(flags);
- cli();
- disable_dma(dev->io.dma);
- clear_dma_ff(dev->io.dma);
- set_dma_mode(dev->io.dma, DMA_MODE_READ | DMA_MODE_AUTOINIT);
- set_dma_addr(dev->io.dma, virt_to_bus(dev->dma.buf));
- set_dma_count(dev->io.dma, HFMODEM_NUMFRAGS * HFMODEM_FRAGSIZE);
- enable_dma(dev->io.dma);
- sbc_int_ack_16bit(dev);
- write_dsp(dev, SBC_SAMPLE_RATE_IN); /* set sampling rate */
- write_dsp(dev, HFMODEM_SRATE >> 8);
- write_dsp(dev, HFMODEM_SRATE & 0xff);
- write_dsp(dev, SBC_SPEAKER_OFF);
- restore_flags(flags);
-}
-
-/* --------------------------------------------------------------------- */
-
-static void sbc4_trigger_input(struct hfmodem_state *dev)
-{
- unsigned long flags;
-
- save_flags(flags);
- cli();
- write_dsp(dev, SBC4_IN16_AI_NO_FIFO);
- write_dsp(dev, SBC4_MODE_UNS_MONO);
- write_dsp(dev, (HFMODEM_FRAGSAMPLES-1) & 0xff);
- write_dsp(dev, (HFMODEM_FRAGSAMPLES-1) >> 8);
- restore_flags(flags);
-}
-
-/* --------------------------------------------------------------------- */
-
-static void sbc4_prepare_output(struct hfmodem_state *dev)
-{
- unsigned long flags;
-
- if (!reset_dsp(dev)) {
- printk(KERN_ERR "%s: sbc: cannot reset sb dsp\n", hfmodem_drvname);
- return;
- }
- save_flags(flags);
- cli();
- disable_dma(dev->io.dma);
- clear_dma_ff(dev->io.dma);
- set_dma_mode(dev->io.dma, DMA_MODE_WRITE | DMA_MODE_AUTOINIT);
- set_dma_addr(dev->io.dma, virt_to_bus(dev->dma.buf));
- set_dma_count(dev->io.dma, HFMODEM_NUMFRAGS * HFMODEM_FRAGSIZE);
- enable_dma(dev->io.dma);
- sbc_int_ack_16bit(dev);
- write_dsp(dev, SBC_SAMPLE_RATE_OUT); /* set sampling rate */
- write_dsp(dev, HFMODEM_SRATE >> 8);
- write_dsp(dev, HFMODEM_SRATE & 0xff);
- write_dsp(dev, SBC_SPEAKER_ON);
- restore_flags(flags);
-}
-
-/* --------------------------------------------------------------------- */
-
-static void sbc4_trigger_output(struct hfmodem_state *dev)
-{
- unsigned long flags;
-
- save_flags(flags);
- cli();
- write_dsp(dev, SBC4_OUT16_AI_NO_FIFO);
- write_dsp(dev, SBC4_MODE_UNS_MONO);
- write_dsp(dev, (HFMODEM_FRAGSAMPLES-1) & 0xff);
- write_dsp(dev, (HFMODEM_FRAGSAMPLES-1) >> 8);
- restore_flags(flags);
-}
-
-/* --------------------------------------------------------------------- */
-
-static void sbc4_stop(struct hfmodem_state *dev)
-{
- reset_dsp(dev);
-}
-
-/* --------------------------------------------------------------------- */
-
-static unsigned int sbc4_intack(struct hfmodem_state *dev)
-{
- unsigned int dmaptr;
- unsigned long flags;
- unsigned char intsrc;
-
- save_flags(flags);
- cli();
- outb(0x82, DSP_MIXER_ADDR(dev->io.base_addr));
- intsrc = inb(DSP_MIXER_DATA(dev->io.base_addr));
- if (intsrc & 0x01)
- sbc_int_ack_8bit(dev);
- if (intsrc & 0x02)
- sbc_int_ack_16bit(dev);
- disable_dma(dev->io.dma);
- clear_dma_ff(dev->io.dma);
- dmaptr = get_dma_residue(dev->io.dma);
- enable_dma(dev->io.dma);
- restore_flags(flags);
- if (dmaptr == 0 || dmaptr > HFMODEM_NUMFRAGS * HFMODEM_FRAGSIZE)
- dmaptr = HFMODEM_NUMFRAGS * HFMODEM_FRAGSIZE;
- return (HFMODEM_NUMFRAGS * HFMODEM_FRAGSIZE - dmaptr) / 2;
-}
-
-/* --------------------------------------------------------------------- */
-
-static void sbc4_mixer(struct hfmodem_state *dev, int src, int igain, int ogain)
-{
- unsigned long flags;
- static const unsigned char srcbits[3] = { 0x18, 0x01, 0x06 };
-
- save_flags(flags);
- cli();
- if (src >= 0 && src <= 2) {
- set_mixer(dev, 0x3d, srcbits[src]);
- set_mixer(dev, 0x3e, srcbits[src]);
- }
- if (ogain >= 0 && ogain <= 255) {
- set_mixer(dev, 0x30, ogain);
- set_mixer(dev, 0x31, ogain);
- }
- if (igain >= 0 && igain <= 255) {
- set_mixer(dev, 0x36, igain);
- set_mixer(dev, 0x37, igain);
- set_mixer(dev, 0x38, igain);
- set_mixer(dev, 0x39, igain);
- set_mixer(dev, 0x3a, igain);
- }
- set_mixer(dev, 0x32, 0xff);
- set_mixer(dev, 0x33, 0xff);
- set_mixer(dev, 0x34, 0);
- set_mixer(dev, 0x35, 0);
- set_mixer(dev, 0x3b, 0); /* pc spkr vol */
- set_mixer(dev, 0x3c, 0); /* output src */
- set_mixer(dev, 0x3f, 0); /* inp gain */
- set_mixer(dev, 0x40, 0);
- set_mixer(dev, 0x41, 0); /* outp gain */
- set_mixer(dev, 0x42, 0);
- set_mixer(dev, 0x43, 1); /* mic agc off */
- set_mixer(dev, 0x44, 8<<4); /* treble */
- set_mixer(dev, 0x45, 8<<4);
- set_mixer(dev, 0x46, 8<<4); /* bass */
- set_mixer(dev, 0x47, 8<<4);
- restore_flags(flags);
-}
-
-/* --------------------------------------------------------------------- */
-
-static void ess_prepare_input(struct hfmodem_state *dev)
-{
- unsigned long flags;
- unsigned char tmp;
-
- if (!reset_ess(dev)) {
- printk(KERN_ERR "%s: sbc: cannot reset ess dsp\n", hfmodem_drvname);
- return;
- }
- save_flags(flags);
- cli();
- disable_dma(dev->io.dma);
- clear_dma_ff(dev->io.dma);
- set_dma_mode(dev->io.dma, DMA_MODE_READ | DMA_MODE_AUTOINIT);
- set_dma_addr(dev->io.dma, virt_to_bus(dev->dma.buf));
- set_dma_count(dev->io.dma, HFMODEM_NUMFRAGS * HFMODEM_FRAGSIZE);
- enable_dma(dev->io.dma);
- sbc_int_ack_8bit(dev);
- write_ess(dev, 0xa1, 128 - (397700 + HFMODEM_SRATE/2) / HFMODEM_SRATE);
- /*
- * Set filter divider register
- * Rolloff at 90% of the half sampling rate
- */
- write_ess(dev, 0xa2, 256-(7160000 / (82 * (HFMODEM_SRATE * 9 / 20))));
- write_dsp(dev, SBC_SPEAKER_OFF);
- write_ess(dev, 0xb8, 0x0e); /* Auto init DMA mode */
- read_ess(dev, 0xa8, &tmp);
- write_ess(dev, 0xa8, (tmp & ~0x03) | 2); /* Mono */
- write_ess(dev, 0xb9, 2); /* Demand mode (4 bytes/DMA request) */
- /* 16 bit mono */
- write_ess(dev, 0xb7, 0x71);
- write_ess(dev, 0xb7, 0xf4);
-
- read_ess(dev, 0xb1, &tmp);
- write_ess(dev, 0xb1, (tmp & 0x0f) | 0x50);
- read_ess(dev, 0xb2, &tmp);
- write_ess(dev, 0xb2, (tmp & 0x0f) | 0x50);
-
- write_ess(dev, 0xa4, (unsigned char) ((-HFMODEM_FRAGSIZE) & 0xff));
- write_ess(dev, 0xa5, (unsigned char) (((-HFMODEM_FRAGSIZE) >> 8) & 0xff));
- restore_flags(flags);
-}
-
-/* --------------------------------------------------------------------- */
-
-static void ess_trigger_input(struct hfmodem_state *dev)
-{
- unsigned long flags;
- unsigned char tmp;
-
- save_flags(flags);
- cli();
- read_ess(dev, 0xb8, &tmp);
- write_ess(dev, 0xb8, tmp | 0x0f); /* Go */
- restore_flags(flags);
-}
-
-/* --------------------------------------------------------------------- */
-
-void ess_prepare_output(struct hfmodem_state *dev)
-{
- unsigned long flags;
- unsigned char tmp;
-
- if (!reset_ess(dev)) {
- printk(KERN_ERR "%s: sbc: cannot reset ess dsp\n", hfmodem_drvname);
- return;
- }
- save_flags(flags);
- cli();
- disable_dma(dev->io.dma);
- clear_dma_ff(dev->io.dma);
- set_dma_mode(dev->io.dma, DMA_MODE_WRITE | DMA_MODE_AUTOINIT);
- set_dma_addr(dev->io.dma, virt_to_bus(dev->dma.buf));
- set_dma_count(dev->io.dma, HFMODEM_NUMFRAGS * HFMODEM_FRAGSIZE);
- enable_dma(dev->io.dma);
- sbc_int_ack_8bit(dev);
- write_ess(dev, 0xa1, 128 - (397700 + HFMODEM_SRATE/2) / HFMODEM_SRATE);
- /*
- * Set filter divider register
- * Rolloff at 90% of the half sampling rate
- */
- write_ess(dev, 0xa2, 256-(7160000 / (82 * (HFMODEM_SRATE * 9 / 20))));
- write_ess(dev, 0xb8, 0x04); /* Auto init DMA mode */
- read_ess(dev, 0xa8, &tmp);
- write_ess(dev, 0xa8, (tmp & ~0x03) | 2); /* Mono */
- write_ess(dev, 0xb9, 2); /* Demand mode (4 bytes/DMA request) */
- /* 16 bit mono */
- write_ess(dev, 0xb6, 0x00);
- write_ess(dev, 0xb7, 0x71);
- write_ess(dev, 0xb7, 0xf4);
-
- read_ess(dev, 0xb1, &tmp);
- write_ess(dev, 0xb1, (tmp & 0x0f) | 0x50);
- read_ess(dev, 0xb2, &tmp);
- write_ess(dev, 0xb2, (tmp & 0x0f) | 0x50);
-
- write_ess(dev, 0xa4, (unsigned char) ((-HFMODEM_FRAGSIZE) & 0xff));
- write_ess(dev, 0xa5, (unsigned char) (((-HFMODEM_FRAGSIZE) >> 8) & 0xff));
-
- write_dsp(dev, SBC_SPEAKER_ON);
- restore_flags(flags);
-}
-
-/* --------------------------------------------------------------------- */
-
-void ess_trigger_output(struct hfmodem_state *dev)
-{
- unsigned long flags;
- unsigned char tmp;
-
- save_flags(flags);
- cli();
- read_ess(dev, 0xb8, &tmp);
- write_ess(dev, 0xb8, tmp | 0x05); /* Go */
- restore_flags(flags);
-}
-
-/* --------------------------------------------------------------------- */
-
-unsigned int ess_intack(struct hfmodem_state *dev)
-{
- unsigned int dmaptr;
- unsigned long flags;
- unsigned char st;
-#if 0
- static unsigned int cnt = 0;
-#endif
-
- save_flags(flags);
- cli();
- st = inb(DSP_WRITE_STATUS(dev->io.base_addr));
- sbc_int_ack_8bit(dev);
- disable_dma(dev->io.dma);
- clear_dma_ff(dev->io.dma);
- dmaptr = get_dma_residue(dev->io.dma);
- enable_dma(dev->io.dma);
- restore_flags(flags);
-#if 0
- cnt = (cnt + 1) & 0x3f;
- if (!cnt)
- printk(KERN_DEBUG "%s: ess: FIFO: full:%c empty:%c half empty:%c IRQ: cpu:%c half empty:%c DMA:%c\n",
- hfmodem_drvname, '1'-!(st&0x20), '1'-!(st&0x10), '1'-!(st&0x8),
- '1'-!(st&0x4), '1'-!(st&0x2), '1'-!(st&0x1));
-#endif
- if (st & 0x20) /* FIFO full, 256 bytes */
- dmaptr += 256;
- else if (!(st & 0x10)) /* FIFO not empty, assume half full 128 bytes */
- dmaptr += 128;
- if (dmaptr > HFMODEM_NUMFRAGS * HFMODEM_FRAGSIZE)
- dmaptr -= HFMODEM_NUMFRAGS * HFMODEM_FRAGSIZE;
- if (dmaptr == 0 || dmaptr > HFMODEM_NUMFRAGS * HFMODEM_FRAGSIZE)
- dmaptr = HFMODEM_NUMFRAGS * HFMODEM_FRAGSIZE;
- return (HFMODEM_NUMFRAGS * HFMODEM_FRAGSIZE - dmaptr) / 2;
-}
-
-/* --------------------------------------------------------------------- */
-
-static void ess_mixer(struct hfmodem_state *dev, int src, int igain, int ogain)
-{
- unsigned long flags;
-
- save_flags(flags);
- cli();
- if (src >= 0 && src <= 2)
- set_mixer(dev, 0x0c, ((src+3) & 3) << 1);
- if (ogain >= 0 && ogain <= 255)
- set_mixer(dev, 0x22, (ogain & 0xf0) | ((ogain >> 4) & 0xf));
- if (igain >= 0 && igain <= 255) {
- set_mixer(dev, 0x36, igain);
- set_mixer(dev, 0x37, igain);
- set_mixer(dev, 0x38, igain);
- set_mixer(dev, 0x39, igain);
- set_mixer(dev, 0x3a, igain);
- }
- set_mixer(dev, 0x4, 0xff);
- set_mixer(dev, 0xe, 0x0);
- set_mixer(dev, 0x26, 0);
- set_mixer(dev, 0x28, 0);
- set_mixer(dev, 0x2e, 0);
- restore_flags(flags);
-}
-
-/* --------------------------------------------------------------------- */
-
-static const struct hfmodem_scops sbc4_scops = {
- SBC_EXTENT, sbc4_init, sbc4_prepare_input, sbc4_trigger_input,
- sbc4_prepare_output, sbc4_trigger_output, sbc4_stop, sbc4_intack, sbc4_mixer
-};
-
-static const struct hfmodem_scops ess_scops = {
- SBC_EXTENT, sbc4_init, ess_prepare_input, ess_trigger_input,
- ess_prepare_output, ess_trigger_output, sbc4_stop, ess_intack, ess_mixer
-};
-
-/* --------------------------------------------------------------------- */
+++ /dev/null
-/*****************************************************************************/
-
-/*
- * wss.c -- Linux soundcard HF FSK driver,
- * WindowsSoundSystem specific functions.
- *
- * Copyright (C) 1997 Thomas Sailer (sailer@ife.ee.ethz.ch)
- * Swiss Federal Institute of Technology (ETH), Electronics Lab
- *
- * 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.
- *
- *
- */
-
-/*****************************************************************************/
-
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/delay.h>
-#include <linux/errno.h>
-#include <linux/sched.h>
-#include <linux/ioport.h>
-
-#include <asm/io.h>
-#include <asm/dma.h>
-
-#include <linux/hfmodem.h>
-
-/* --------------------------------------------------------------------- */
-
-#define WSS_CONFIG(iobase) (iobase+0)
-#define WSS_STATUS(iobase) (iobase+3)
-#define WSS_CODEC_IA(iobase) (iobase+4)
-#define WSS_CODEC_ID(iobase) (iobase+5)
-#define WSS_CODEC_STATUS(iobase) (iobase+6)
-#define WSS_CODEC_DATA(iobase) (iobase+7)
-
-#define WSS_EXTENT 8
-
-/* --------------------------------------------------------------------- */
-
-extern const struct hfmodem_scops wss_scops;
-
-/* --------------------------------------------------------------------- */
-
-static void write_codec(struct hfmodem_state *dev, unsigned char idx,
- unsigned char data)
-{
- int timeout = 900000;
-
- /* wait until codec ready */
- while (timeout > 0 && inb(WSS_CODEC_IA(dev->io.base_addr)) & 0x80)
- timeout--;
- outb(idx, WSS_CODEC_IA(dev->io.base_addr));
- outb(data, WSS_CODEC_ID(dev->io.base_addr));
-}
-
-/* --------------------------------------------------------------------- */
-
-static unsigned char read_codec(struct hfmodem_state *dev, unsigned char idx)
-{
- int timeout = 900000;
-
- /* wait until codec ready */
- while (timeout > 0 && inb(WSS_CODEC_IA(dev->io.base_addr)) & 0x80)
- timeout--;
- outb(idx & 0x1f, WSS_CODEC_IA(dev->io.base_addr));
- return inb(WSS_CODEC_ID(dev->io.base_addr));
-}
-
-/* --------------------------------------------------------------------- */
-
-extern __inline__ void wss_ack_int(struct hfmodem_state *dev)
-{
- outb(0, WSS_CODEC_STATUS(dev->io.base_addr));
-}
-
-/* --------------------------------------------------------------------- */
-
-static int wss_srate_tab[16] = {
- 8000, 5510, 16000, 11025, 27420, 18900, 32000, 22050,
- -1, 37800, -1, 44100, 48000, 33075, 9600, 6620
-};
-
-static int wss_srate_index(int srate)
-{
- int i;
-
- for (i = 0; i < (sizeof(wss_srate_tab)/sizeof(wss_srate_tab[0])); i++)
- if (srate == wss_srate_tab[i] && wss_srate_tab[i] > 0)
- return i;
- return -1;
-}
-
-/* --------------------------------------------------------------------- */
-
-static int wss_set_codec_fmt(struct hfmodem_state *dev, unsigned char fmt)
-{
- unsigned long time;
- unsigned long flags;
-
- save_flags(flags);
- cli();
- /* Clock and data format register */
- write_codec(dev, 0x48, fmt);
- /* MCE and interface config reg */
- write_codec(dev, 0x49, 0xc);
- outb(0xb, WSS_CODEC_IA(dev->io.base_addr)); /* leave MCE */
- /*
- * wait for ACI start
- */
- time = 1000;
- while (!(read_codec(dev, 0x0b) & 0x20))
- if (!(--time)) {
- printk(KERN_WARNING "%s: ad1848 auto calibration timed out (1)\n",
- hfmodem_drvname);
- restore_flags(flags);
- return -1;
- }
- /*
- * wait for ACI end
- */
- sti();
- time = jiffies + HZ/4;
- while ((read_codec(dev, 0x0b) & 0x20) && ((signed)(jiffies - time) < 0));
- restore_flags(flags);
- if ((signed)(jiffies - time) >= 0) {
- printk(KERN_WARNING "%s: ad1848 auto calibration timed out (2)\n",
- hfmodem_drvname);
- return -1;
- }
- return 0;
-}
-
-/* --------------------------------------------------------------------- */
-
-static int wss_init_codec(struct hfmodem_state *dev)
-{
- unsigned char tmp, revwss, revid;
- static const signed char irqtab[16] = {
- -1, -1, 0x10, -1, -1, -1, -1, 0x08, -1, 0x10, 0x18, 0x20, -1, -1, -1, -1
- };
- static const signed char dmatab[4] = { 1, 2, -1, 3 };
- int fmt;
-
- if ((fmt = wss_srate_index(HFMODEM_SRATE)) < 0) {
- printk(KERN_ERR "%s: WSS: sampling rate not supported\n", hfmodem_drvname);
- return -1;
- }
- fmt &= 0x0f;
-#ifdef __BIG_ENDIAN
- fmt |= 0xc0;
-#else /* __BIG_ENDIAN */
- fmt |= 0x40;
-#endif /* __BIG_ENDIAN */
- tmp = inb(WSS_STATUS(dev->io.base_addr));
- if ((tmp & 0x3f) != 0x04 && (tmp & 0x3f) != 0x00 &&
- (tmp & 0x3f) != 0x0f) {
- printk(KERN_WARNING "%s: WSS card id register not found, "
- "address 0x%x, ID register 0x%02x\n", hfmodem_drvname,
- dev->io.base_addr, (int)tmp);
- /* return -1; */
- revwss = 0;
- } else {
- if ((tmp & 0x80) && ((dev->io.dma == 0) || ((dev->io.irq >= 8) && (dev->io.irq != 9)))) {
- printk(KERN_ERR "%s: WSS: DMA0 and/or IRQ8..IRQ15 "
- "(except IRQ9) cannot be used on an 8bit "
- "card\n", hfmodem_drvname);
- return -1;
- }
- if (dev->io.irq > 15 || irqtab[dev->io.irq] == -1) {
- printk(KERN_ERR "%s: WSS: invalid interrupt %d\n",
- hfmodem_drvname, (int)dev->io.irq);
- return -1;
- }
- if (dev->io.dma > 3 || dmatab[dev->io.dma] == -1) {
- printk(KERN_ERR "%s: WSS: invalid dma channel %d\n",
- hfmodem_drvname, (int)dev->io.dma);
- return -1;
- }
- tmp = irqtab[dev->io.irq] | dmatab[dev->io.dma];
- /* irq probe */
- outb((tmp & 0x38) | 0x40, WSS_CONFIG(dev->io.base_addr));
- if (!(inb(WSS_STATUS(dev->io.base_addr)) & 0x40)) {
- outb(0, WSS_CONFIG(dev->io.base_addr));
- printk(KERN_ERR "%s: WSS: IRQ%d is not free!\n",
- hfmodem_drvname, dev->io.irq);
- }
- outb(tmp, WSS_CONFIG(dev->io.base_addr));
- revwss = inb(WSS_STATUS(dev->io.base_addr)) & 0x3f;
- }
- /*
- * initialize the codec
- */
- write_codec(dev, 9, 0);
- write_codec(dev, 12, 0);
- write_codec(dev, 0, 0x45);
- if (read_codec(dev, 0) != 0x45)
- goto codec_err;
- write_codec(dev, 0, 0xaa);
- if (read_codec(dev, 0) != 0xaa)
- goto codec_err;
- if (wss_set_codec_fmt(dev, fmt))
- goto codec_err;
- write_codec(dev, 0, 0x40); /* left input control */
- write_codec(dev, 1, 0x40); /* right input control */
- write_codec(dev, 2, 0x80); /* left aux#1 input control */
- write_codec(dev, 3, 0x80); /* right aux#1 input control */
- write_codec(dev, 4, 0x80); /* left aux#2 input control */
- write_codec(dev, 5, 0x80); /* right aux#2 input control */
- write_codec(dev, 6, 0x80); /* left dac control */
- write_codec(dev, 7, 0x80); /* right dac control */
- write_codec(dev, 0xa, 0x2); /* pin control register */
- write_codec(dev, 0xd, 0x0); /* digital mix control */
- revid = read_codec(dev, 0xc) & 0xf;
- /*
- * print revisions
- */
- printk(KERN_INFO "%s: WSS revision %d, CODEC revision %d\n",
- hfmodem_drvname, (int)revwss, (int)revid);
- return 0;
- codec_err:
- outb(0, WSS_CONFIG(dev->io.base_addr));
- printk(KERN_ERR "%s: no WSS soundcard found at address 0x%x\n",
- hfmodem_drvname, dev->io.base_addr);
- return -1;
-}
-
-/* --------------------------------------------------------------------- */
-
-int hfmodem_wssprobe(struct hfmodem_state *dev)
-{
- if (dev->io.base_addr <= 0 || dev->io.base_addr > 0x1000-WSS_EXTENT ||
- dev->io.irq < 2 || dev->io.irq > 15 || dev->io.dma > 3 || dev->io.dma == 2)
- return -ENXIO;
- if (check_region(dev->io.base_addr, WSS_EXTENT))
- return -EACCES;
- /*
- * check if a card is available
- */
- if (wss_init_codec(dev)) {
- printk(KERN_ERR "%s: sbc: no card at io address 0x%x\n",
- hfmodem_drvname, dev->io.base_addr);
- return -ENODEV;
- }
- dev->scops = &wss_scops;
- return 0;
-}
-
-/* --------------------------------------------------------------------- */
-
-static void wss_init(struct hfmodem_state *dev)
-{
- wss_init_codec(dev);
-}
-
-/* --------------------------------------------------------------------- */
-
-static void wss_stop(struct hfmodem_state *dev)
-{
- unsigned long flags;
- unsigned char oldcodecmode;
- long abrt;
-
- save_flags(flags);
- cli();
- /*
- * perform the final DMA sequence to disable the codec request
- */
- oldcodecmode = read_codec(dev, 9);
- write_codec(dev, 9, 0xc); /* disable codec */
- wss_ack_int(dev);
- if (read_codec(dev, 11) & 0x10) {
- disable_dma(dev->io.dma);
- clear_dma_ff(dev->io.dma);
- set_dma_mode(dev->io.dma, (oldcodecmode & 1) ?
- (DMA_MODE_WRITE | DMA_MODE_AUTOINIT) : (DMA_MODE_READ | DMA_MODE_AUTOINIT));
- set_dma_addr(dev->io.dma, virt_to_bus(dev->dma.buf));
- set_dma_count(dev->io.dma, HFMODEM_NUMFRAGS * HFMODEM_FRAGSIZE);
- enable_dma(dev->io.dma);
- abrt = 0;
- while ((read_codec(dev, 11) & 0x10) || ((++abrt) >= 0x10000));
- }
- disable_dma(dev->io.dma);
- restore_flags(flags);
-}
-
-/* --------------------------------------------------------------------- */
-
-static void wss_prepare_input(struct hfmodem_state *dev)
-{
- unsigned long flags;
-
- wss_stop(dev);
- save_flags(flags);
- cli();
- disable_dma(dev->io.dma);
- clear_dma_ff(dev->io.dma);
- set_dma_mode(dev->io.dma, DMA_MODE_READ | DMA_MODE_AUTOINIT);
- set_dma_addr(dev->io.dma, virt_to_bus(dev->dma.buf));
- set_dma_count(dev->io.dma, HFMODEM_NUMFRAGS * HFMODEM_FRAGSIZE);
- enable_dma(dev->io.dma);
- write_codec(dev, 15, (HFMODEM_FRAGSAMPLES-1) & 0xff);
- write_codec(dev, 14, (HFMODEM_FRAGSAMPLES-1) >> 8);
- restore_flags(flags);
-}
-
-/* --------------------------------------------------------------------- */
-
-static void wss_trigger_input(struct hfmodem_state *dev)
-{
- unsigned long flags;
-
- save_flags(flags);
- cli();
- write_codec(dev, 9, 0x0e);
- restore_flags(flags);
-}
-
-/* --------------------------------------------------------------------- */
-
-static void wss_prepare_output(struct hfmodem_state *dev)
-{
- unsigned long flags;
-
- wss_stop(dev);
- save_flags(flags);
- cli();
- disable_dma(dev->io.dma);
- clear_dma_ff(dev->io.dma);
- set_dma_mode(dev->io.dma, DMA_MODE_WRITE | DMA_MODE_AUTOINIT);
- set_dma_addr(dev->io.dma, virt_to_bus(dev->dma.buf));
- set_dma_count(dev->io.dma, HFMODEM_NUMFRAGS * HFMODEM_FRAGSIZE);
- enable_dma(dev->io.dma);
- write_codec(dev, 15, (HFMODEM_FRAGSAMPLES-1) & 0xff);
- write_codec(dev, 14, (HFMODEM_FRAGSAMPLES-1) >> 8);
- restore_flags(flags);
-}
-
-/* --------------------------------------------------------------------- */
-
-static void wss_trigger_output(struct hfmodem_state *dev)
-{
- unsigned long flags;
-
- save_flags(flags);
- cli();
- write_codec(dev, 9, 0x0d);
- restore_flags(flags);
-}
-
-/* --------------------------------------------------------------------- */
-
-static unsigned int wss_intack(struct hfmodem_state *dev)
-{
- unsigned int dmaptr, nums;
- unsigned long flags;
-
- save_flags(flags);
- cli();
- wss_ack_int(dev);
- disable_dma(dev->io.dma);
- clear_dma_ff(dev->io.dma);
- dmaptr = get_dma_residue(dev->io.dma);
- if (dmaptr == 0 || dmaptr > HFMODEM_NUMFRAGS * HFMODEM_FRAGSIZE)
- dmaptr = HFMODEM_NUMFRAGS * HFMODEM_FRAGSIZE;
- nums = (((dmaptr - 1) % HFMODEM_FRAGSIZE) - 1) / 2;
- write_codec(dev, 15, nums & 0xff);
- write_codec(dev, 14, nums >> 8);
- enable_dma(dev->io.dma);
- restore_flags(flags);
- return (HFMODEM_NUMFRAGS * HFMODEM_FRAGSIZE - dmaptr) / 2;
-}
-
-/* --------------------------------------------------------------------- */
-
-static void wss_mixer(struct hfmodem_state *dev, int src, int igain, int ogain)
-{
- unsigned long flags;
- static const unsigned char srctoreg[3] = { 1, 2, 0 };
- static const unsigned char regtosrc[4] = { 2, 0, 1, 0 };
- unsigned char tmp;
-
- save_flags(flags);
- cli();
- tmp = read_codec(dev, 0x00);
- if (src < 0 || src > 2)
- src = regtosrc[(tmp >> 6) & 3];
- if (igain < 0 || igain > 255) {
- if (src == 1)
- igain = ((tmp & 0xf) + ((tmp & 0x20) ? 13 : 0)) << 3;
- else
- igain = (tmp & 0xf) << 4;
- }
- if (src == 1) {
- if (igain > (28<<3))
- tmp = 0x2f;
- else if (igain >= (13<<3))
- tmp = 0x20 + (((igain >> 3) - 13) & 0xf);
- else
- tmp = (igain >> 3) & 0xf;
- } else
- tmp = (igain >> 4) & 0xf;
- tmp |= srctoreg[src] << 6;
- write_codec(dev, 0, tmp);
- write_codec(dev, 1, tmp);
- if (ogain > 0 && ogain <= 255) {
- tmp = 63 - (ogain >> 2);
- write_codec(dev, 6, tmp);
- write_codec(dev, 7, tmp);
- } else if (ogain == 0) {
- write_codec(dev, 6, 0x80);
- write_codec(dev, 7, 0x80);
- }
- restore_flags(flags);
-}
-
-/* --------------------------------------------------------------------- */
-
-static const struct hfmodem_scops wss_scops = {
- WSS_EXTENT, wss_init, wss_prepare_input, wss_trigger_input,
- wss_prepare_output, wss_trigger_output, wss_stop, wss_intack, wss_mixer
-};
-
-/* --------------------------------------------------------------------- */
#include <asm/pmu.h>
#include <asm/uaccess.h>
#include <asm/hydra.h>
-#include <asm/init.h>
+#include <linux/init.h>
EXPORT_SYMBOL(adb_controller);
EXPORT_SYMBOL(adb_client_list);
#include <asm/adb.h>
#include <asm/cuda.h>
#include <asm/pmu.h>
-#include <asm/init.h>
+#include <linux/init.h>
#include <linux/kbd_kern.h>
#include <linux/kbd_ll.h>
#include <asm/hydra.h>
#include <asm/irq.h>
#include <asm/system.h>
-#include <asm/init.h>
+#include <linux/init.h>
struct preg {
unsigned char r;
#ifdef CONFIG_KGDB
#include <asm/kgdb.h>
#endif
-#include <asm/init.h>
+#include <linux/init.h>
#include "macserial.h"
#include <asm/io.h>
#include <asm/feature.h>
#include <asm/mediabay.h>
-#include <asm/init.h>
+#include <linux/init.h>
#undef MB_USE_INTERRUPTS
#include <asm/io.h>
#include <asm/pgtable.h>
#include <asm/system.h>
-#include <asm/init.h>
+#include <linux/init.h>
static volatile unsigned char *via;
#include <asm/io.h>
#include <asm/pgtable.h>
#include <asm/system.h>
-#include <asm/init.h>
+#include <linux/init.h>
#include <asm/irq.h>
#include <asm/feature.h>
#include <asm/uaccess.h>
@@ -563,9+563,9 @@ int eepro100_init(struct device *dev) {
struct pci_dev *pdev = pci_find_slot(pci_bus, pci_device_fn);
#ifdef USE_IO
- pciaddr = pdev->base_address[1]; /* Use [0] to mem-map */
+ pciaddr = pdev->resource[1].start;
#else
- pciaddr = pdev->base_address[0];
+ pciaddr = pdev->resource[0].start;
#endif
irq = pdev->irq;
}
@@ -16,7+16,7 @@ tristate 'BAYCOM ser12 halfduplex driver for AX.25' CONFIG_BAYCOM_SER_HDX dep_tristate 'BAYCOM picpar and par96 driver for AX.25' CONFIG_BAYCOM_PAR $CONFIG_PARPORT
dep_tristate 'BAYCOM epp driver for AX.25' CONFIG_BAYCOM_EPP $CONFIG_PARPORT
-tristate 'Soundcard modem driver' CONFIG_SOUNDMODEM
+dep_tristate 'Soundcard modem driver' CONFIG_SOUNDMODEM $CONFIG_PARPORT
if [ "$CONFIG_SOUNDMODEM" != "n" ]; then
bool ' soundmodem support for Soundblaster and compatible cards' CONFIG_SOUNDMODEM_SBC
bool ' soundmodem support for WSS and Crystal cards' CONFIG_SOUNDMODEM_WSS
* Integrated FPGA EPP modem configuration routines
* 0.3 11.05.98 Took FPGA config out and moved it into a separate program
* 0.4 26.07.99 Adapted to new lowlevel parport driver interface
+ * 0.5 03.08.99 adapt to Linus' new __setup/__initcall
+ * removed some pre-2.2 kernel compatibility cruft
*
*/
#include <linux/config.h>
#include <linux/module.h>
#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/ptrace.h>
-#include <linux/socket.h>
-#include <linux/sched.h>
-#include <linux/interrupt.h>
-#include <linux/ioport.h>
-#include <linux/in.h>
+#include <linux/init.h>
#include <linux/string.h>
+#include <linux/tqueue.h>
+#include <linux/fs.h>
#include <linux/parport.h>
-#include <linux/bitops.h>
-#include <asm/system.h>
-#include <asm/io.h>
-#include <asm/processor.h>
-#include <linux/delay.h>
-#include <linux/errno.h>
-#include <linux/netdevice.h>
+#include <asm/uaccess.h>
#include <linux/if_arp.h>
-//#include <net/ax25dev.h>
-#include <linux/kmod.h>
#include <linux/hdlcdrv.h>
#include <linux/baycom.h>
#include <linux/soundmodem.h>
/* --------------------------------------------------------------------- */
-/*
- * currently this module is supposed to support both module styles, i.e.
- * the old one present up to about 2.1.9, and the new one functioning
- * starting with 2.1.21. The reason is I have a kit allowing to compile
- * this module also under 2.0.x which was requested by several people.
- * This will go in 2.2
- */
-#include <linux/version.h>
-
-#if LINUX_VERSION_CODE >= 0x20100
-#include <asm/uaccess.h>
-#else
-#include <asm/segment.h>
-#include <linux/mm.h>
-
-#undef put_user
-#undef get_user
-
-#define put_user(x,ptr) ({ __put_user((unsigned long)(x),(ptr),sizeof(*(ptr))); 0; })
-#define get_user(x,ptr) ({ x = ((__typeof__(*(ptr)))__get_user((ptr),sizeof(*(ptr)))); 0; })
-
-extern inline int copy_from_user(void *to, const void *from, unsigned long n)
-{
- int i = verify_area(VERIFY_READ, from, n);
- if (i)
- return i;
- memcpy_fromfs(to, from, n);
- return 0;
-}
-
-extern inline int copy_to_user(void *to, const void *from, unsigned long n)
-{
- int i = verify_area(VERIFY_WRITE, to, n);
- if (i)
- return i;
- memcpy_tofs(to, from, n);
- return 0;
-}
-#endif
-
-#if LINUX_VERSION_CODE >= 0x20123
-#include <linux/init.h>
-#else
-#define __init
-#define __initdata
-#define __initfunc(x) x
-#endif
-
-/* --------------------------------------------------------------------- */
-
#define BAYCOM_DEBUG
#define BAYCOM_MAGIC 19730510
@@ -148,8+88,8 @@ static const char paranoia_str[] = KERN_ERR /* --------------------------------------------------------------------- */
static const char bc_drvname[] = "baycom_epp";
-static const char bc_drvinfo[] = KERN_INFO "baycom_epp: (C) 1998 Thomas Sailer, HB9JNX/AE4WA\n"
-KERN_INFO "baycom_epp: version 0.4 compiled " __TIME__ " " __DATE__ "\n";
+static const char bc_drvinfo[] = KERN_INFO "baycom_epp: (C) 1998-1999 Thomas Sailer, HB9JNX/AE4WA\n"
+KERN_INFO "baycom_epp: version 0.5 compiled " __TIME__ " " __DATE__ "\n";
/* --------------------------------------------------------------------- */
@@ -157,11+97,6 @@ KERN_INFO "baycom_epp: version 0.4 compiled " __TIME__ " " __DATE__ "\n";
static struct device baycom_device[NR_PORTS];
-static struct {
- const char *mode;
- int iobase;
-} baycom_ports[NR_PORTS] = { { NULL, 0 }, };
-
/* --------------------------------------------------------------------- */
/* EPP status register */
@@ -1477,7+1412,18 @@ static int baycom_probe(struct device *dev)
/* --------------------------------------------------------------------- */
-__initfunc(int baycom_epp_init(void))
+/*
+ * command line settable parameters
+ */
+static const char *mode[NR_PORTS] = { "", };
+static int iobase[NR_PORTS] = { 0x378, };
+
+/* --------------------------------------------------------------------- */
+
+#ifndef MODULE
+static
+#endif
+int __init init_module(void)
{
struct device *dev;
int i, found = 0;
@@ -1490,10+1436,10 @@ __initfunc(int baycom_epp_init(void)) */
for (i = 0; i < NR_PORTS; i++) {
dev = baycom_device+i;
- if (!baycom_ports[i].mode)
+ if (!mode[i])
set_hw = 0;
if (!set_hw)
- baycom_ports[i].iobase = 0;
+ iobase[i] = 0;
memset(dev, 0, sizeof(struct device));
if (!(bc = dev->priv = kmalloc(sizeof(struct baycom_state), GFP_KERNEL)))
return -ENOMEM;
@@ -1513,7+1459,7 @@ __initfunc(int baycom_epp_init(void)) dev->init = baycom_probe;
dev->start = 0;
dev->tbusy = 1;
- dev->base_addr = baycom_ports[i].iobase;
+ dev->base_addr = iobase[i];
dev->irq = 0;
dev->dma = 0;
if (register_netdev(dev)) {
@@ -1521,7+1467,7 @@ __initfunc(int baycom_epp_init(void)) kfree(dev->priv);
return -ENXIO;
}
- if (set_hw && baycom_setmode(bc, baycom_ports[i].mode))
+ if (set_hw && baycom_setmode(bc, mode[i]))
set_hw = 0;
found++;
}
@@ -1534,39+1480,14 @@ __initfunc(int baycom_epp_init(void))
#ifdef MODULE
-/*
- * command line settable parameters
- */
-static const char *mode[NR_PORTS] = { "epp", };
-static int iobase[NR_PORTS] = { 0x378, };
-
-#if LINUX_VERSION_CODE >= 0x20115
-
-MODULE_PARM(mode, "s");
-MODULE_PARM_DESC(mode, "baycom operating mode; epp");
-MODULE_PARM(iobase, "i");
+MODULE_PARM(mode, "1-" __MODULE_STRING(NR_PORTS) "s");
+MODULE_PARM_DESC(mode, "baycom operating mode");
+MODULE_PARM(iobase, "1-" __MODULE_STRING(NR_PORTS) "i");
MODULE_PARM_DESC(iobase, "baycom io base address");
MODULE_AUTHOR("Thomas M. Sailer, sailer@ife.ee.ethz.ch, hb9jnx@hb9w.che.eu");
MODULE_DESCRIPTION("Baycom epp amateur radio modem driver");
-#endif
-
-__initfunc(int init_module(void))
-{
- int i;
-
- for (i = 0; (i < NR_PORTS) && (mode[i]); i++) {
- baycom_ports[i].mode = mode[i];
- baycom_ports[i].iobase = iobase[i];
- }
- if (i < NR_PORTS-1)
- baycom_ports[i+1].mode = NULL;
- return baycom_epp_init();
-}
-
-/* --------------------------------------------------------------------- */
-
void cleanup_module(void)
{
struct device *dev;
@@ -1587,27+1508,30 @@ void cleanup_module(void) }
#else /* MODULE */
-/* --------------------------------------------------------------------- */
+
/*
- * format: baycom=io,mode
- * mode: epp
+ * format: baycom_epp=io,mode
+ * mode: fpga config options
*/
-__initfunc(void baycom_epp_setup(char *str, int *ints))
+static int __init baycom_epp_setup(char *str)
{
- int i;
+ static unsigned __initdata nr_dev = 0;
+ int ints[11];
- for (i = 0; (i < NR_PORTS) && (baycom_ports[i].mode); i++);
- if ((i >= NR_PORTS) || (ints[0] < 1)) {
- printk(KERN_INFO "%s: too many or invalid interface "
- "specifications\n", bc_drvname);
- return;
- }
- baycom_ports[i].mode = str;
- baycom_ports[i].iobase = ints[1];
- if (i < NR_PORTS-1)
- baycom_ports[i+1].mode = NULL;
+ if (nr_dev >= NR_PORTS)
+ return 0;
+ str = get_options(str, ints);
+ if (ints[0] < 1)
+ return 0;
+ mode[nr_dev] = str;
+ iobase[nr_dev] = ints[1];
+ nr_dev++;
+ return 1;
}
+__setup("baycom_epp=", baycom_epp_setup);
+__initcall(init_module);
+
#endif /* MODULE */
/* --------------------------------------------------------------------- */
/*
* baycom_par.c -- baycom par96 and picpar radio modem driver.
*
- * Copyright (C) 1997 Thomas Sailer (sailer@ife.ee.ethz.ch)
+ * Copyright (C) 1996-1999 Thomas Sailer (sailer@ife.ee.ethz.ch)
*
* 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
* 0.3 26.04.97 init code/data tagged
* 0.4 08.07.97 alternative ser12 decoding algorithm (uses delta CTS ints)
* 0.5 11.11.97 split into separate files for ser12/par96
+ * 0.6 03.08.99 adapt to Linus' new __setup/__initcall
+ * removed some pre-2.2 kernel compatibility cruft
*/
/*****************************************************************************/
+#include <linux/config.h>
+#include <linux/version.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <asm/system.h>
#include <asm/bitops.h>
#include <asm/io.h>
+#include <asm/uaccess.h>
+#include <linux/init.h>
#include <linux/delay.h>
#include <linux/errno.h>
#include <linux/netdevice.h>
/* --------------------------------------------------------------------- */
-/*
- * currently this module is supposed to support both module styles, i.e.
- * the old one present up to about 2.1.9, and the new one functioning
- * starting with 2.1.21. The reason is I have a kit allowing to compile
- * this module also under 2.0.x which was requested by several people.
- * This will go in 2.2
- */
-#include <linux/version.h>
-
-#if LINUX_VERSION_CODE >= 0x20100
-#include <asm/uaccess.h>
-#else
-#include <asm/segment.h>
-#include <linux/mm.h>
-
-#undef put_user
-#undef get_user
-
-#define put_user(x,ptr) ({ __put_user((unsigned long)(x),(ptr),sizeof(*(ptr))); 0; })
-#define get_user(x,ptr) ({ x = ((__typeof__(*(ptr)))__get_user((ptr),sizeof(*(ptr)))); 0; })
-
-extern __inline__ int copy_from_user(void *to, const void *from, unsigned long n)
-{
- int i = verify_area(VERIFY_READ, from, n);
- if (i)
- return i;
- memcpy_fromfs(to, from, n);
- return 0;
-}
-
-extern __inline__ int copy_to_user(void *to, const void *from, unsigned long n)
-{
- int i = verify_area(VERIFY_WRITE, to, n);
- if (i)
- return i;
- memcpy_tofs(to, from, n);
- return 0;
-}
-#endif
-
-#if LINUX_VERSION_CODE >= 0x20123
-#include <linux/init.h>
-#else
-#define __init
-#define __initdata
-#define __initfunc(x) x
-#endif
-
-/* --------------------------------------------------------------------- */
-
#define BAYCOM_DEBUG
/*
@@ -143,8+99,8 @@ extern __inline__ int copy_to_user(void *to, const void *from, unsigned long n) /* --------------------------------------------------------------------- */
static const char bc_drvname[] = "baycom_par";
-static const char bc_drvinfo[] = KERN_INFO "baycom_par: (C) 1997 Thomas Sailer, HB9JNX/AE4WA\n"
-KERN_INFO "baycom_par: version 0.5 compiled " __TIME__ " " __DATE__ "\n";
+static const char bc_drvinfo[] = KERN_INFO "baycom_par: (C) 1996-1999 Thomas Sailer, HB9JNX/AE4WA\n"
+KERN_INFO "baycom_par: version 0.6 compiled " __TIME__ " " __DATE__ "\n";
/* --------------------------------------------------------------------- */
@@ -152,11+108,6 @@ KERN_INFO "baycom_par: version 0.5 compiled " __TIME__ " " __DATE__ "\n";
static struct device baycom_device[NR_PORTS];
-static struct {
- const char *mode;
- int iobase;
-} baycom_ports[NR_PORTS] = { { NULL, 0 }, };
-
/* --------------------------------------------------------------------- */
#define SER12_EXTENT 8
@@ -533,14+484,24 @@ static int baycom_ioctl(struct device *dev, struct ifreq *ifr,
/* --------------------------------------------------------------------- */
-int __init baycom_par_init(void)
+/*
+ * command line settable parameters
+ */
+static const char *mode[NR_PORTS] = { "picpar", };
+static int iobase[NR_PORTS] = { 0x378, };
+
+/* --------------------------------------------------------------------- */
+
+#ifndef MODULE
+static
+#endif
+int __init init_module(void)
{
int i, j, found = 0;
char set_hw = 1;
struct baycom_state *bc;
char ifname[HDLCDRV_IFNAMELEN];
-
printk(bc_drvinfo);
/*
* register net devices
@@ -549,16+510,15 @@ int __init baycom_par_init(void) struct device *dev = baycom_device+i;
sprintf(ifname, "bcp%d", i);
- if (!baycom_ports[i].mode)
+ if (!mode[i])
set_hw = 0;
if (!set_hw)
- baycom_ports[i].iobase = 0;
- j = hdlcdrv_register_hdlcdrv(dev, &par96_ops,
- sizeof(struct baycom_state),
- ifname, baycom_ports[i].iobase, 0, 0);
+ iobase[i] = 0;
+ j = hdlcdrv_register_hdlcdrv(dev, &par96_ops, sizeof(struct baycom_state),
+ ifname, iobase[i], 0, 0);
if (!j) {
bc = (struct baycom_state *)dev->priv;
- if (set_hw && baycom_setmode(bc, baycom_ports[i].mode))
+ if (set_hw && baycom_setmode(bc, mode[i]))
set_hw = 0;
found++;
} else {
@@ -575,14+535,6 @@ int __init baycom_par_init(void)
#ifdef MODULE
-/*
- * command line settable parameters
- */
-static const char *mode[NR_PORTS] = { "picpar", };
-static int iobase[NR_PORTS] = { 0x378, };
-
-#if LINUX_VERSION_CODE >= 0x20115
-
MODULE_PARM(mode, "1-" __MODULE_STRING(NR_PORTS) "s");
MODULE_PARM_DESC(mode, "baycom operating mode; eg. par96 or picpar");
MODULE_PARM(iobase, "1-" __MODULE_STRING(NR_PORTS) "i");
@@ -591,23+543,6 @@ MODULE_PARM_DESC(iobase, "baycom io base address"); MODULE_AUTHOR("Thomas M. Sailer, sailer@ife.ee.ethz.ch, hb9jnx@hb9w.che.eu");
MODULE_DESCRIPTION("Baycom par96 and picpar amateur radio modem driver");
-#endif
-
-int __init init_module(void)
-{
- int i;
-
- for (i = 0; (i < NR_PORTS) && (mode[i]); i++) {
- baycom_ports[i].mode = mode[i];
- baycom_ports[i].iobase = iobase[i];
- }
- if (i < NR_PORTS-1)
- baycom_ports[i+1].mode = NULL;
- return baycom_par_init();
-}
-
-/* --------------------------------------------------------------------- */
-
void cleanup_module(void)
{
int i;
@@ -627,27+562,30 @@ void cleanup_module(void) }
#else /* MODULE */
-/* --------------------------------------------------------------------- */
+
/*
* format: baycom_par=io,mode
* mode: par96,picpar
*/
-void __init baycom_par_setup(char *str, int *ints)
+static int __init baycom_par_setup(char *str)
{
- int i;
-
- for (i = 0; (i < NR_PORTS) && (baycom_ports[i].mode); i++);
- if ((i >= NR_PORTS) || (ints[0] < 1)) {
- printk(KERN_INFO "%s: too many or invalid interface "
- "specifications\n", bc_drvname);
- return;
- }
- baycom_ports[i].mode = str;
- baycom_ports[i].iobase = ints[1];
- if (i < NR_PORTS-1)
- baycom_ports[i+1].mode = NULL;
+ static unsigned __initdata nr_dev = 0;
+ int ints[11];
+
+ if (nr_dev >= NR_PORTS)
+ return 0;
+ str = get_options(str, ints);
+ if (ints[0] < 1)
+ return 0;
+ mode[nr_dev] = str;
+ iobase[nr_dev] = ints[1];
+ nr_dev++;
+ return 1;
}
+__setup("baycom_par=", baycom_par_setup);
+__initcall(init_module);
+
#endif /* MODULE */
/* --------------------------------------------------------------------- */
/*
* baycom_ser_fdx.c -- baycom ser12 fullduplex radio modem driver.
*
- * Copyright (C) 1997-1998 Thomas Sailer (sailer@ife.ee.ethz.ch)
+ * Copyright (C) 1996-1999 Thomas Sailer (sailer@ife.ee.ethz.ch)
*
* 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
* 0.6 24.01.98 Thorsten Kranzkowski, dl8bcu and Thomas Sailer:
* reduced interrupt load in transmit case
* reworked receiver
+ * 0.7 03.08.99 adapt to Linus' new __setup/__initcall
*/
/*****************************************************************************/
+#include <linux/config.h>
+#include <linux/version.h>
#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/types.h>
-#include <linux/fcntl.h>
-#include <linux/interrupt.h>
#include <linux/ioport.h>
-#include <linux/in.h>
#include <linux/string.h>
#include <linux/init.h>
-#include <linux/bitops.h>
#include <asm/uaccess.h>
-#include <asm/system.h>
#include <asm/io.h>
-#include <linux/delay.h>
-#include <linux/errno.h>
-#include <linux/netdevice.h>
#include <linux/hdlcdrv.h>
#include <linux/baycom.h>
-#include <linux/version.h>
/* --------------------------------------------------------------------- */
/* --------------------------------------------------------------------- */
static const char bc_drvname[] = "baycom_ser_fdx";
-static const char bc_drvinfo[] = KERN_INFO "baycom_ser_fdx: (C) 1997-1998 Thomas Sailer, HB9JNX/AE4WA\n"
-KERN_INFO "baycom_ser_fdx: version 0.6 compiled " __TIME__ " " __DATE__ "\n";
+static const char bc_drvinfo[] = KERN_INFO "baycom_ser_fdx: (C) 1996-1999 Thomas Sailer, HB9JNX/AE4WA\n"
+KERN_INFO "baycom_ser_fdx: version 0.7 compiled " __TIME__ " " __DATE__ "\n";
/* --------------------------------------------------------------------- */
@@ -106,11+97,6 @@ KERN_INFO "baycom_ser_fdx: version 0.6 compiled " __TIME__ " " __DATE__ "\n";
static struct device baycom_device[NR_PORTS];
-static struct {
- char *mode;
- int iobase, irq, baud;
-} baycom_ports[NR_PORTS] = { { NULL, 0, 0 }, };
-
/* --------------------------------------------------------------------- */
#define RBR(iobase) (iobase+0)
@@ -605,7+591,20 @@ static int baycom_ioctl(struct device *dev, struct ifreq *ifr,
/* --------------------------------------------------------------------- */
-int __init baycom_ser_fdx_init(void)
+/*
+ * command line settable parameters
+ */
+static char *mode[NR_PORTS] = { "ser12*", };
+static int iobase[NR_PORTS] = { 0x3f8, };
+static int irq[NR_PORTS] = { 4, };
+static int baud[NR_PORTS] = { [0 ... NR_PORTS-1] = 1200 };
+
+/* --------------------------------------------------------------------- */
+
+#ifndef MODULE
+static
+#endif
+int __init init_module(void)
{
int i, j, found = 0;
char set_hw = 1;
@@ -621,19+620,17 @@ int __init baycom_ser_fdx_init(void) struct device *dev = baycom_device+i;
sprintf(ifname, "bcsf%d", i);
- if (!baycom_ports[i].mode)
+ if (!mode[i])
set_hw = 0;
if (!set_hw)
- baycom_ports[i].iobase = baycom_ports[i].irq = 0;
- j = hdlcdrv_register_hdlcdrv(dev, &ser12_ops,
- sizeof(struct baycom_state),
- ifname, baycom_ports[i].iobase,
- baycom_ports[i].irq, 0);
+ iobase[i] = irq[i] = 0;
+ j = hdlcdrv_register_hdlcdrv(dev, &ser12_ops, sizeof(struct baycom_state),
+ ifname, iobase[i], irq[i], 0);
if (!j) {
bc = (struct baycom_state *)dev->priv;
- if (set_hw && baycom_setmode(bc, baycom_ports[i].mode))
+ if (set_hw && baycom_setmode(bc, mode[i]))
set_hw = 0;
- bc->baud = baycom_ports[i].baud;
+ bc->baud = baud[i];
found++;
} else {
printk(KERN_WARNING "%s: cannot register net device\n",
@@ -649,16+646,6 @@ int __init baycom_ser_fdx_init(void)
#ifdef MODULE
-/*
- * command line settable parameters
- */
-static char *mode[NR_PORTS] = { "ser12*", };
-static int iobase[NR_PORTS] = { 0x3f8, };
-static int irq[NR_PORTS] = { 4, };
-static int baud[NR_PORTS] = { [0 ... NR_PORTS-1] = 1200 };
-
-#if LINUX_VERSION_CODE >= 0x20115
-
MODULE_PARM(mode, "1-" __MODULE_STRING(NR_PORTS) "s");
MODULE_PARM_DESC(mode, "baycom operating mode; * for software DCD");
MODULE_PARM(iobase, "1-" __MODULE_STRING(NR_PORTS) "i");
@@ -671,25+658,6 @@ MODULE_PARM_DESC(baud, "baycom baud rate (300 to 4800)"); MODULE_AUTHOR("Thomas M. Sailer, sailer@ife.ee.ethz.ch, hb9jnx@hb9w.che.eu");
MODULE_DESCRIPTION("Baycom ser12 full duplex amateur radio modem driver");
-#endif
-
-int __init init_module(void)
-{
- int i;
-
- for (i = 0; (i < NR_PORTS) && (mode[i]); i++) {
- baycom_ports[i].mode = mode[i];
- baycom_ports[i].iobase = iobase[i];
- baycom_ports[i].irq = irq[i];
- baycom_ports[i].baud = baud[i];
- }
- if (i < NR_PORTS-1)
- baycom_ports[i+1].mode = NULL;
- return baycom_ser_fdx_init();
-}
-
-/* --------------------------------------------------------------------- */
-
void cleanup_module(void)
{
int i;
@@ -709,33+677,34 @@ void cleanup_module(void) }
#else /* MODULE */
-/* --------------------------------------------------------------------- */
+
/*
* format: baycom_ser_fdx=io,irq,mode
* mode: [*]
* * indicates sofware DCD
*/
-void __init baycom_ser_fdx_setup(char *str, int *ints)
+static int __init baycom_ser_fdx_setup(char *str)
{
- int i;
-
- for (i = 0; (i < NR_PORTS) && (baycom_ports[i].mode); i++);
- if ((i >= NR_PORTS) || (ints[0] < 2)) {
- printk(KERN_INFO "%s: too many or invalid interface "
- "specifications\n", bc_drvname);
- return;
- }
- baycom_ports[i].mode = str;
- baycom_ports[i].iobase = ints[1];
- baycom_ports[i].irq = ints[2];
+ static unsigned __initdata nr_dev = 0;
+ int ints[11];
+
+ if (nr_dev >= NR_PORTS)
+ return 0;
+ str = get_options(str, ints);
+ if (ints[0] < 2)
+ return 0;
+ mode[nr_dev] = str;
+ iobase[nr_dev] = ints[1];
+ irq[nr_dev] = ints[2];
if (ints[0] >= 3)
- baycom_ports[i].baud = ints[3];
- else
- baycom_ports[i].baud = 1200;
- if (i < NR_PORTS-1)
- baycom_ports[i+1].mode = NULL;
+ baud[nr_dev] = ints[3];
+ nr_dev++;
+ return 1;
}
+__setup("baycom_ser_fdx=", baycom_ser_fdx_setup);
+__initcall(init_module);
+
#endif /* MODULE */
/* --------------------------------------------------------------------- */
/*
* baycom_ser_hdx.c -- baycom ser12 halfduplex radio modem driver.
*
- * Copyright (C) 1997 Thomas Sailer (sailer@ife.ee.ethz.ch)
+ * Copyright (C) 1996-1999 Thomas Sailer (sailer@ife.ee.ethz.ch)
*
* 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
* 0.4 08.07.97 alternative ser12 decoding algorithm (uses delta CTS ints)
* 0.5 11.11.97 ser12/par96 split into separate files
* 0.6 14.04.98 cleanups
+ * 0.7 03.08.99 adapt to Linus' new __setup/__initcall
*/
/*****************************************************************************/
+#include <linux/config.h>
+#include <linux/version.h>
#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/types.h>
-#include <linux/fcntl.h>
-#include <linux/interrupt.h>
#include <linux/ioport.h>
-#include <linux/in.h>
#include <linux/string.h>
#include <linux/init.h>
#include <asm/uaccess.h>
-#include <asm/system.h>
-#include <asm/bitops.h>
#include <asm/io.h>
-#include <linux/delay.h>
-#include <linux/errno.h>
-#include <linux/netdevice.h>
#include <linux/hdlcdrv.h>
#include <linux/baycom.h>
-#include <linux/version.h>
/* --------------------------------------------------------------------- */
/* --------------------------------------------------------------------- */
static const char bc_drvname[] = "baycom_ser_hdx";
-static const char bc_drvinfo[] = KERN_INFO "baycom_ser_hdx: (C) 1997-1998 Thomas Sailer, HB9JNX/AE4WA\n"
-KERN_INFO "baycom_ser_hdx: version 0.6 compiled " __TIME__ " " __DATE__ "\n";
+static const char bc_drvinfo[] = KERN_INFO "baycom_ser_hdx: (C) 1996-1999 Thomas Sailer, HB9JNX/AE4WA\n"
+KERN_INFO "baycom_ser_hdx: version 0.7 compiled " __TIME__ " " __DATE__ "\n";
/* --------------------------------------------------------------------- */
@@ -95,11+86,6 @@ KERN_INFO "baycom_ser_hdx: version 0.6 compiled " __TIME__ " " __DATE__ "\n";
static struct device baycom_device[NR_PORTS];
-static struct {
- char *mode;
- int iobase, irq;
-} baycom_ports[NR_PORTS] = { { NULL, 0, 0 }, };
-
/* --------------------------------------------------------------------- */
#define RBR(iobase) (iobase+0)
@@ -643,7+629,19 @@ static int baycom_ioctl(struct device *dev, struct ifreq *ifr,
/* --------------------------------------------------------------------- */
-int __init baycom_ser_hdx_init(void)
+/*
+ * command line settable parameters
+ */
+static char *mode[NR_PORTS] = { "ser12*", };
+static int iobase[NR_PORTS] = { 0x3f8, };
+static int irq[NR_PORTS] = { 4, };
+
+/* --------------------------------------------------------------------- */
+
+#ifndef MODULE
+static
+#endif
+int __init init_module(void)
{
int i, j, found = 0;
char set_hw = 1;
@@ -659,17+657,15 @@ int __init baycom_ser_hdx_init(void) struct device *dev = baycom_device+i;
sprintf(ifname, "bcsh%d", i);
- if (!baycom_ports[i].mode)
+ if (!mode[i])
set_hw = 0;
if (!set_hw)
- baycom_ports[i].iobase = baycom_ports[i].irq = 0;
- j = hdlcdrv_register_hdlcdrv(dev, &ser12_ops,
- sizeof(struct baycom_state),
- ifname, baycom_ports[i].iobase,
- baycom_ports[i].irq, 0);
+ iobase[i] = irq[i] = 0;
+ j = hdlcdrv_register_hdlcdrv(dev, &ser12_ops, sizeof(struct baycom_state),
+ ifname, iobase[i], irq[i], 0);
if (!j) {
bc = (struct baycom_state *)dev->priv;
- if (set_hw && baycom_setmode(bc, baycom_ports[i].mode))
+ if (set_hw && baycom_setmode(bc, mode[i]))
set_hw = 0;
found++;
} else {
@@ -686,15+682,6 @@ int __init baycom_ser_hdx_init(void)
#ifdef MODULE
-/*
- * command line settable parameters
- */
-static char *mode[NR_PORTS] = { "ser12*", };
-static int iobase[NR_PORTS] = { 0x3f8, };
-static int irq[NR_PORTS] = { 4, };
-
-#if LINUX_VERSION_CODE >= 0x20115
-
MODULE_PARM(mode, "1-" __MODULE_STRING(NR_PORTS) "s");
MODULE_PARM_DESC(mode, "baycom operating mode; * for software DCD");
MODULE_PARM(iobase, "1-" __MODULE_STRING(NR_PORTS) "i");
@@ -705,24+692,6 @@ MODULE_PARM_DESC(irq, "baycom irq number"); MODULE_AUTHOR("Thomas M. Sailer, sailer@ife.ee.ethz.ch, hb9jnx@hb9w.che.eu");
MODULE_DESCRIPTION("Baycom ser12 half duplex amateur radio modem driver");
-#endif
-
-int __init init_module(void)
-{
- int i;
-
- for (i = 0; (i < NR_PORTS) && (mode[i]); i++) {
- baycom_ports[i].mode = mode[i];
- baycom_ports[i].iobase = iobase[i];
- baycom_ports[i].irq = irq[i];
- }
- if (i < NR_PORTS-1)
- baycom_ports[i+1].mode = NULL;
- return baycom_ser_hdx_init();
-}
-
-/* --------------------------------------------------------------------- */
-
void cleanup_module(void)
{
int i;
@@ -742,29+711,32 @@ void cleanup_module(void) }
#else /* MODULE */
-/* --------------------------------------------------------------------- */
+
/*
- * format: baycom_ser_=io,irq,mode
+ * format: baycom_ser_hdx=io,irq,mode
* mode: [*]
* * indicates sofware DCD
*/
-void __init baycom_ser_hdx_setup(char *str, int *ints)
+static int __init baycom_ser_hdx_setup(char *str)
{
- int i;
+ static unsigned __initdata nr_dev = 0;
+ int ints[11];
- for (i = 0; (i < NR_PORTS) && (baycom_ports[i].mode); i++);
- if ((i >= NR_PORTS) || (ints[0] < 2)) {
- printk(KERN_INFO "%s: too many or invalid interface "
- "specifications\n", bc_drvname);
- return;
- }
- baycom_ports[i].mode = str;
- baycom_ports[i].iobase = ints[1];
- baycom_ports[i].irq = ints[2];
- if (i < NR_PORTS-1)
- baycom_ports[i+1].mode = NULL;
+ if (nr_dev >= NR_PORTS)
+ return 0;
+ str = get_options(str, ints);
+ if (ints[0] < 2)
+ return 0;
+ mode[nr_dev] = str;
+ iobase[nr_dev] = ints[1];
+ irq[nr_dev] = ints[2];
+ nr_dev++;
+ return 1;
}
+__setup("baycom_ser_hdx=", baycom_ser_hdx_setup);
+__initcall(init_module);
+
#endif /* MODULE */
/* --------------------------------------------------------------------- */
/*
* hdlcdrv.c -- HDLC packet radio network driver.
*
- * Copyright (C) 1996-1998 Thomas Sailer (sailer@ife.ee.ethz.ch)
+ * Copyright (C) 1996-1999 Thomas Sailer (sailer@ife.ee.ethz.ch)
*
* 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
* 0.5 30.07.97 made HDLC buffers bigger (solves a problem with the
* soundmodem driver)
* 0.6 05.04.98 add spinlocks
+ * 0.7 03.08.99 removed some old compatibility cruft
*/
/*****************************************************************************/
@@ -516,11+517,7 @@ static int hdlcdrv_set_mac_address(struct device *dev, void *addr)
/* --------------------------------------------------------------------- */
-#if LINUX_VERSION_CODE >= 0x20119
static struct net_device_stats *hdlcdrv_get_stats(struct device *dev)
-#else
-static struct enet_statistics *hdlcdrv_get_stats(struct device *dev)
-#endif
{
struct hdlcdrv_state *sm;
@@ -695,9+692,6 @@ static int hdlcdrv_ioctl(struct device *dev, struct ifreq *ifr, int cmd) bi.data.ocs.ptt = hdlcdrv_ptt(s);
bi.data.ocs.dcd = s->hdlcrx.dcd;
bi.data.ocs.ptt_keyed = s->ptt_keyed;
-#if LINUX_VERSION_CODE < 0x20100
- bi.data.ocs.stats = s->stats;
-#endif
break;
case HDLCDRVCTL_CALIBRATE:
@@ -900,48+894,25 @@ int hdlcdrv_unregister_hdlcdrv(struct device *dev)
/* --------------------------------------------------------------------- */
-#if LINUX_VERSION_CODE >= 0x20115
-
EXPORT_SYMBOL(hdlcdrv_receiver);
EXPORT_SYMBOL(hdlcdrv_transmitter);
EXPORT_SYMBOL(hdlcdrv_arbitrate);
EXPORT_SYMBOL(hdlcdrv_register_hdlcdrv);
EXPORT_SYMBOL(hdlcdrv_unregister_hdlcdrv);
-#else
-
-static struct symbol_table hdlcdrv_syms = {
-#include <linux/symtab_begin.h>
- X(hdlcdrv_receiver),
- X(hdlcdrv_transmitter),
- X(hdlcdrv_arbitrate),
- X(hdlcdrv_register_hdlcdrv),
- X(hdlcdrv_unregister_hdlcdrv),
-#include <linux/symtab_end.h>
-};
-
-#endif
-
/* --------------------------------------------------------------------- */
#ifdef MODULE
-#if LINUX_VERSION_CODE >= 0x20115
-
MODULE_AUTHOR("Thomas M. Sailer, sailer@ife.ee.ethz.ch, hb9jnx@hb9w.che.eu");
MODULE_DESCRIPTION("Packet Radio network interface HDLC encoder/decoder");
-#endif
-
/* --------------------------------------------------------------------- */
int __init init_module(void)
{
printk(KERN_INFO "hdlcdrv: (C) 1996 Thomas Sailer HB9JNX/AE4WA\n");
- printk(KERN_INFO "hdlcdrv: version 0.6 compiled " __TIME__ " " __DATE__ "\n");
-#if LINUX_VERSION_CODE < 0x20115
- register_symtab(&hdlcdrv_syms);
-#endif
+ printk(KERN_INFO "hdlcdrv: version 0.7 compiled " __TIME__ " " __DATE__ "\n");
return 0;
}
/*
* sm.c -- soundcard radio modem driver.
*
- * Copyright (C) 1996-1998 Thomas Sailer (sailer@ife.ee.ethz.ch)
+ * Copyright (C) 1996-1999 Thomas Sailer (sailer@ife.ee.ethz.ch)
*
* 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
* 0.6 16.04.97 init code/data tagged
* 0.7 30.07.97 fixed halfduplex interrupt handlers/hotfix for CS423X
* 0.8 14.04.98 cleanups
+ * 0.9 03.08.99 adapt to Linus' new __setup/__initcall
+ * use parport lowlevel drivers instead of directly writing to a parallel port
+ * removed some pre-2.2 kernel compatibility cruft
*/
/*****************************************************************************/
#include <linux/config.h>
+#include <linux/version.h>
#include <linux/module.h>
-#include <linux/ptrace.h>
-#include <linux/types.h>
-#include <linux/fcntl.h>
#include <linux/ioport.h>
-#include <linux/net.h>
-#include <linux/in.h>
#include <linux/string.h>
#include <linux/init.h>
+#include <linux/parport.h>
#include <asm/uaccess.h>
-#include <asm/system.h>
-#include <asm/io.h>
-#include <asm/bitops.h>
-#include <linux/delay.h>
-#include <linux/errno.h>
-#include <linux/version.h>
#include "sm.h"
/* --------------------------------------------------------------------- */
/*static*/ const char sm_drvname[] = "soundmodem";
-static const char sm_drvinfo[] = KERN_INFO "soundmodem: (C) 1996-1998 Thomas Sailer, HB9JNX/AE4WA\n"
-KERN_INFO "soundmodem: version 0.8 compiled " __TIME__ " " __DATE__ "\n";
+static const char sm_drvinfo[] = KERN_INFO "soundmodem: (C) 1996-1999 Thomas Sailer, HB9JNX/AE4WA\n"
+KERN_INFO "soundmodem: version 0.9 compiled " __TIME__ " " __DATE__ "\n";
/* --------------------------------------------------------------------- */
@@ -146,17+140,8 @@ static const struct hardware_info *sm_hardware_table[] = {
#define NR_PORTS 4
-/* --------------------------------------------------------------------- */
-
static struct device sm_device[NR_PORTS];
-static struct {
- char *mode;
- int iobase, irq, dma, dma2, seriobase, pariobase, midiiobase;
-} sm_ports[NR_PORTS] = {
- { NULL, -1, 0, 0, 0, -1, -1, -1 },
-};
-
/* --------------------------------------------------------------------- */
#define UART_RBR(iobase) (iobase+0)
@@ -174,13+159,6 @@ static struct {
#define SER_EXTENT 8
-#define LPT_DATA(iobase) (iobase+0)
-#define LPT_STATUS(iobase) (iobase+1)
-#define LPT_CONTROL(iobase) (iobase+2)
-#define LPT_IRQ_ENABLE 0x10
-
-#define LPT_EXTENT 3
-
#define MIDI_DATA(iobase) (iobase)
#define MIDI_STATUS(iobase) (iobase+1)
#define MIDI_READ_FULL 0x80 /* attention: negative logic!! */
@@ -202,47+180,10 @@ static struct { #define SP_PAR 2
#define SP_MIDI 4
-/* --------------------------------------------------------------------- */
/*
* ===================== port checking routines ========================
*/
-/*
- * returns 0 if ok and != 0 on error;
- * the same behaviour as par96_check_lpt in baycom.c
- */
-
-/*
- * returns 0 if ok and != 0 on error;
- * the same behaviour as par96_check_lpt in baycom.c
- */
-
-static int check_lpt(unsigned int iobase)
-{
- unsigned char b1,b2;
- int i;
-
- if (iobase <= 0 || iobase > 0x1000-LPT_EXTENT)
- return 0;
- if (check_region(iobase, LPT_EXTENT))
- return 0;
- b1 = inb(LPT_DATA(iobase));
- b2 = inb(LPT_CONTROL(iobase));
- outb(0xaa, LPT_DATA(iobase));
- i = inb(LPT_DATA(iobase)) == 0xaa;
- outb(0x55, LPT_DATA(iobase));
- i &= inb(LPT_DATA(iobase)) == 0x55;
- outb(0x0a, LPT_CONTROL(iobase));
- i &= (inb(LPT_CONTROL(iobase)) & 0xf) == 0x0a;
- outb(0x05, LPT_CONTROL(iobase));
- i &= (inb(LPT_CONTROL(iobase)) & 0xf) == 0x05;
- outb(b1, LPT_DATA(iobase));
- outb(b2, LPT_CONTROL(iobase));
- return !i;
-}
-
-/* --------------------------------------------------------------------- */
-
enum uart { c_uart_unknown, c_uart_8250,
c_uart_16450, c_uart_16550, c_uart_16550A};
static const char *uart_str[] =
@@ -326,12+267,10 @@ void sm_output_status(struct sm_state *sm) outb(dcd | (ptt << 1), UART_MCR(sm->hdrv.ptt_out.seriobase));
outb(0x40 & (-ptt), UART_LCR(sm->hdrv.ptt_out.seriobase));
}
- if (sm->hdrv.ptt_out.flags & SP_PAR) {
- outb(ptt | (dcd << 1), LPT_DATA(sm->hdrv.ptt_out.pariobase));
- }
- if (sm->hdrv.ptt_out.flags & SP_MIDI && hdlcdrv_ptt(&sm->hdrv)) {
+ if (sm->hdrv.ptt_out.flags & SP_PAR && sm->pardev && sm->pardev->port)
+ parport_write_data(sm->pardev->port, ptt | (dcd << 1));
+ if (sm->hdrv.ptt_out.flags & SP_MIDI && hdlcdrv_ptt(&sm->hdrv))
outb(0, MIDI_DATA(sm->hdrv.ptt_out.midiiobase));
- }
}
/* --------------------------------------------------------------------- */
@@ -339,6+278,7 @@ void sm_output_status(struct sm_state *sm) static void sm_output_open(struct sm_state *sm)
{
enum uart u = c_uart_unknown;
+ struct parport *pp = NULL;
sm->hdrv.ptt_out.flags = 0;
if (sm->hdrv.ptt_out.seriobase > 0 &&
@@ -353,11+293,27 @@ static void sm_output_open(struct sm_state *sm) outb(1, UART_DLL(sm->hdrv.ptt_out.seriobase)); /* as fast as possible */
/* LCR and MCR set by output_status */
}
- if (sm->hdrv.ptt_out.pariobase > 0 &&
- sm->hdrv.ptt_out.pariobase <= 0x1000-LPT_EXTENT &&
- !check_lpt(sm->hdrv.ptt_out.pariobase)) {
- sm->hdrv.ptt_out.flags |= SP_PAR;
- request_region(sm->hdrv.ptt_out.pariobase, LPT_EXTENT, "sm par ptt");
+ sm->pardev = NULL;
+ if (sm->hdrv.ptt_out.pariobase > 0) {
+ pp = parport_enumerate();
+ while (pp && pp->base != sm->hdrv.ptt_out.pariobase)
+ pp = pp->next;
+ if (!pp)
+ printk(KERN_WARNING "%s: parport at address 0x%x not found\n", sm_drvname, sm->hdrv.ptt_out.pariobase);
+ else {
+ sm->pardev = parport_register_device(pp, sm->hdrv.ifname, NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL);
+ if (!sm->pardev) {
+ pp = NULL;
+ printk(KERN_WARNING "%s: cannot register parport device (address 0x%x)\n", sm_drvname, sm->hdrv.ptt_out.pariobase);
+ } else {
+ if (parport_claim(sm->pardev)) {
+ parport_unregister_device(sm->pardev);
+ sm->pardev = NULL;
+ printk(KERN_WARNING "%s: cannot claim parport at address 0x%x\n", sm_drvname, sm->hdrv.ptt_out.pariobase);
+ } else
+ sm->hdrv.ptt_out.flags |= SP_PAR;
+ }
+ }
}
if (sm->hdrv.ptt_out.midiiobase > 0 &&
sm->hdrv.ptt_out.midiiobase <= 0x1000-MIDI_EXTENT &&
@@ -390,8+346,10 @@ static void sm_output_close(struct sm_state *sm) sm_output_status(sm);
if (sm->hdrv.ptt_out.flags & SP_SER)
release_region(sm->hdrv.ptt_out.seriobase, SER_EXTENT);
- if (sm->hdrv.ptt_out.flags & SP_PAR)
- release_region(sm->hdrv.ptt_out.pariobase, LPT_EXTENT);
+ if (sm->hdrv.ptt_out.flags & SP_PAR && sm->pardev) {
+ parport_release(sm->pardev);
+ parport_unregister_device(sm->pardev);
+ }
if (sm->hdrv.ptt_out.flags & SP_MIDI)
release_region(sm->hdrv.ptt_out.midiiobase, MIDI_EXTENT);
sm->hdrv.ptt_out.flags = 0;
@@ -639,11+597,24 @@ static int sm_ioctl(struct device *dev, struct ifreq *ifr,
/* --------------------------------------------------------------------- */
-#ifdef MODULE
-static int __init sm_init(void)
-#else /* MODULE */
-int __init sm_init(void)
-#endif /* MODULE */
+/*
+ * command line settable parameters
+ */
+static char *mode[NR_PORTS] = { [0 ... NR_PORTS-1] = NULL };
+static int iobase[NR_PORTS] = { [0 ... NR_PORTS-1] = -1 };
+static int irq[NR_PORTS] = { [0 ... NR_PORTS-1] = -1 };
+static int dma[NR_PORTS] = { [0 ... NR_PORTS-1] = -1 };
+static int dma2[NR_PORTS] = { [0 ... NR_PORTS-1] = -1 };
+static int serio[NR_PORTS] = { [0 ... NR_PORTS-1] = 0 };
+static int pario[NR_PORTS] = { [0 ... NR_PORTS-1] = 0 };
+static int midiio[NR_PORTS] = { [0 ... NR_PORTS-1] = 0 };
+
+/* --------------------------------------------------------------------- */
+
+#ifndef MODULE
+static
+#endif
+int __init init_module(void)
{
int i, j, found = 0;
char set_hw = 1;
@@ -658,25+629,39 @@ int __init sm_init(void) struct device *dev = sm_device+i;
sprintf(ifname, "sm%d", i);
- if (!sm_ports[i].mode)
+ if (!mode[i])
set_hw = 0;
+ else {
+ if (!strncmp(mode[i], "sbc", 3)) {
+ if (iobase[i] == -1)
+ iobase[i] = 0x220;
+ if (irq[i] == -1)
+ irq[i] = 5;
+ if (dma[i] == -1)
+ dma[i] = 1;
+ } else {
+ if (iobase[i] == -1)
+ iobase[i] = 0x530;
+ if (irq[i] == -1)
+ irq[i] = 11;
+ if (dma[i] == -1)
+ dma[i] = 1;
+ }
+ }
if (!set_hw)
- sm_ports[i].iobase = sm_ports[i].irq = 0;
- j = hdlcdrv_register_hdlcdrv(dev, &sm_ops, sizeof(struct sm_state),
- ifname, sm_ports[i].iobase,
- sm_ports[i].irq, sm_ports[i].dma);
+ iobase[i] = irq[i] = 0;
+ j = hdlcdrv_register_hdlcdrv(dev, &sm_ops, sizeof(struct sm_state), ifname, iobase[i], irq[i], dma[i]);
if (!j) {
sm = (struct sm_state *)dev->priv;
- sm->hdrv.ptt_out.dma2 = sm_ports[i].dma2;
- sm->hdrv.ptt_out.seriobase = sm_ports[i].seriobase;
- sm->hdrv.ptt_out.pariobase = sm_ports[i].pariobase;
- sm->hdrv.ptt_out.midiiobase = sm_ports[i].midiiobase;
- if (set_hw && sethw(dev, sm, sm_ports[i].mode))
+ sm->hdrv.ptt_out.dma2 = dma2[i];
+ sm->hdrv.ptt_out.seriobase = serio[i];
+ sm->hdrv.ptt_out.pariobase = pario[i];
+ sm->hdrv.ptt_out.midiiobase = midiio[i];
+ if (set_hw && sethw(dev, sm, mode[i]))
set_hw = 0;
found++;
} else {
- printk(KERN_WARNING "%s: cannot register net device\n",
- sm_drvname);
+ printk(KERN_WARNING "%s: cannot register net device\n", sm_drvname);
}
}
if (!found)
@@ -688,67+673,26 @@ int __init sm_init(void)
#ifdef MODULE
-/*
- * command line settable parameters
- */
-static char *mode = NULL;
-static int iobase = -1;
-static int irq = -1;
-static int dma = -1;
-static int dma2 = -1;
-static int serio = 0;
-static int pario = 0;
-static int midiio = 0;
-
-#if LINUX_VERSION_CODE >= 0x20115
-
-MODULE_PARM(mode, "s");
+MODULE_PARM(mode, "1-" __MODULE_STRING(NR_PORTS) "s");
MODULE_PARM_DESC(mode, "soundmodem operating mode; eg. sbc:afsk1200 or wss:fsk9600");
-MODULE_PARM(iobase, "i");
+MODULE_PARM(iobase, "1-" __MODULE_STRING(NR_PORTS) "i");
MODULE_PARM_DESC(iobase, "soundmodem base address");
-MODULE_PARM(irq, "i");
+MODULE_PARM(irq, "1-" __MODULE_STRING(NR_PORTS) "i");
MODULE_PARM_DESC(irq, "soundmodem interrupt");
-MODULE_PARM(dma, "i");
+MODULE_PARM(dma, "1-" __MODULE_STRING(NR_PORTS) "i");
MODULE_PARM_DESC(dma, "soundmodem dma channel");
-MODULE_PARM(dma2, "i");
+MODULE_PARM(dma2, "1-" __MODULE_STRING(NR_PORTS) "i");
MODULE_PARM_DESC(dma2, "soundmodem 2nd dma channel; full duplex only");
-MODULE_PARM(serio, "i");
+MODULE_PARM(serio, "1-" __MODULE_STRING(NR_PORTS) "i");
MODULE_PARM_DESC(serio, "soundmodem PTT output on serial port");
-MODULE_PARM(pario, "i");
+MODULE_PARM(pario, "1-" __MODULE_STRING(NR_PORTS) "i");
MODULE_PARM_DESC(pario, "soundmodem PTT output on parallel port");
-MODULE_PARM(midiio, "i");
+MODULE_PARM(midiio, "1-" __MODULE_STRING(NR_PORTS) "i");
MODULE_PARM_DESC(midiio, "soundmodem PTT output on midi port");
MODULE_AUTHOR("Thomas M. Sailer, sailer@ife.ee.ethz.ch, hb9jnx@hb9w.che.eu");
MODULE_DESCRIPTION("Soundcard amateur radio modem driver");
-#endif
-
-int __init init_module(void)
-{
- if (mode) {
- if (iobase == -1)
- iobase = (!strncmp(mode, "sbc", 3)) ? 0x220 : 0x530;
- if (irq == -1)
- irq = (!strncmp(mode, "sbc", 3)) ? 5 : 11;
- if (dma == -1)
- dma = 1;
- }
- sm_ports[0].mode = mode;
- sm_ports[0].iobase = iobase;
- sm_ports[0].irq = irq;
- sm_ports[0].dma = dma;
- sm_ports[0].dma2 = dma2;
- sm_ports[0].seriobase = serio;
- sm_ports[0].pariobase = pario;
- sm_ports[0].midiiobase = midiio;
- sm_ports[1].mode = NULL;
-
- return sm_init();
-}
-
-/* --------------------------------------------------------------------- */
-
void cleanup_module(void)
{
int i;
@@ -770,35+714,43 @@ void cleanup_module(void) }
#else /* MODULE */
-/* --------------------------------------------------------------------- */
+
/*
- * format: sm=io,irq,dma[,dma2[,serio[,pario]]],mode
+ * format: soundmodem=io,irq,dma[,dma2[,serio[,pario]]],mode
* mode: hw:modem
* hw: sbc, wss, wssfdx
* modem: afsk1200, fsk9600
*/
-void __init sm_setup(char *str, int *ints)
+static int __init sm_setup(char *str)
{
- int i;
+ static unsigned __initdata nr_dev = 0;
+ int ints[11];
- for (i = 0; (i < NR_PORTS) && (sm_ports[i].mode); i++);
- if ((i >= NR_PORTS) || (ints[0] < 3)) {
- printk(KERN_INFO "%s: too many or invalid interface "
- "specifications\n", sm_drvname);
- return;
- }
- sm_ports[i].mode = str;
- sm_ports[i].iobase = ints[1];
- sm_ports[i].irq = ints[2];
- sm_ports[i].dma = ints[3];
- sm_ports[i].dma2 = (ints[0] >= 4) ? ints[4] : 0;
- sm_ports[i].seriobase = (ints[0] >= 5) ? ints[5] : 0;
- sm_ports[i].pariobase = (ints[0] >= 6) ? ints[6] : 0;
- sm_ports[i].midiiobase = (ints[0] >= 7) ? ints[7] : 0;
- if (i < NR_PORTS-1)
- sm_ports[i+1].mode = NULL;
+ if (nr_dev >= NR_PORTS)
+ return 0;
+ str = get_options(str, ints);
+ mode[nr_dev] = str;
+ if (ints[0] >= 1)
+ iobase[nr_dev] = ints[1];
+ if (ints[0] >= 2)
+ irq[nr_dev] = ints[2];
+ if (ints[0] >= 3)
+ dma[nr_dev] = ints[3];
+ if (ints[0] >= 4)
+ dma2[nr_dev] = ints[4];
+ if (ints[0] >= 5)
+ serio[nr_dev] = ints[5];
+ if (ints[0] >= 6)
+ pario[nr_dev] = ints[6];
+ if (ints[0] >= 7)
+ midiio[nr_dev] = ints[7];
+ nr_dev++;
+ return 1;
}
+__setup("soundmodem=", sm_setup);
+__initcall(init_module);
+
#endif /* MODULE */
/* --------------------------------------------------------------------- */
/*
* sm.h -- soundcard radio modem driver internal header.
*
- * Copyright (C) 1996-1998 Thomas Sailer (sailer@ife.ee.ethz.ch)
+ * Copyright (C) 1996-1999 Thomas Sailer (sailer@ife.ee.ethz.ch)
*
* 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
#include <linux/soundmodem.h>
#include <asm/processor.h>
#include <linux/bitops.h>
+#include <linux/parport.h>
#define SM_DEBUG
@@ -50,6+51,8 @@ struct sm_state {
const struct hardware_info *hwdrv;
+ struct pardevice *pardev;
+
/*
* Hardware (soundcard) access routines state
*/
@@ -11,7+11,7 @@ if [ "$CONFIG_PARPORT" != "n" ]; then if [ "$CONFIG_PARPORT_PC" != "n" ]; then
bool ' Use FIFO/DMA if available' CONFIG_PARPORT_PC_FIFO
fi
- if [ "$CONFIG_PARPORT_PC" = y ]; then
+ if [ "$CONFIG_PARPORT_PC" = "y" ]; then
# Don't bother with this if parport_pc is a module; it only affects
# the presence or not of some __init's, which are no-ops for modules.
bool ' Support for PCMCIA management for PC-style ports' CONFIG_PARPORT_PC_PCMCIA
#include <linux/config.h>
#include <linux/module.h>
#include <linux/threads.h>
-
+#include <linux/string.h>
#include <linux/parport.h>
#include <linux/errno.h>
#include <linux/kernel.h>
@@ -28,71+28,86 @@ extern int parport_pc_init(int *io, int *io_hi, int *irq, int *dma);
static int parport_setup_ptr __initdata = 0;
-__initfunc(void parport_setup(char *str, int *ints))
+/*
+ * Acceptable parameters:
+ *
+ * parport=0
+ * parport=auto
+ * parport=0xBASE[,IRQ[,DMA]]
+ *
+ * IRQ/DMA may be numeric or 'auto' or 'none'
+ */
+static int __init parport_setup (char *str)
{
- if (ints[0] == 0) {
- if (str && !strncmp(str, "auto", 4)) {
- irq[0] = PARPORT_IRQ_AUTO;
- dma[0] = PARPORT_DMA_AUTO;
- }
- else if (str)
- printk (KERN_ERR "parport: `%s': huh?\n", str);
- else
- printk (KERN_ERR "parport: parport=.. what?\n");
-
- return;
- }
- else if (ints[1] == 0) {
+ char *endptr;
+ char *sep;
+ int val;
+
+ if (!str || !*str || (*str == '0' && !*(str+1))) {
/* Disable parport if "parport=0" in cmdline */
- io[0] = PARPORT_DISABLE;
- return;
+ io[0] = PARPORT_DISABLE;
+ return 0;
}
- if (parport_setup_ptr < PARPORT_MAX) {
- char *sep;
- io[parport_setup_ptr] = ints[1];
- irq[parport_setup_ptr] = PARPORT_IRQ_NONE;
- dma[parport_setup_ptr] = PARPORT_DMA_NONE;
- if (ints[0] > 1) {
- irq[parport_setup_ptr] = ints[2];
- if (ints[0] > 2) {
- dma[parport_setup_ptr] = ints[3];
- goto done;
- }
+ if (!strncmp (str, "auto", 4)) {
+ irq[0] = PARPORT_IRQ_AUTO;
+ dma[0] = PARPORT_DMA_AUTO;
+ return 0;
+ }
- if (str == NULL)
- goto done;
+ val = simple_strtoul (str, &endptr, 0);
+ if (endptr == str) {
+ printk (KERN_WARNING "parport=%s not understood\n", str);
+ return 1;
+ }
- goto dma_from_str;
- }
- else if (str == NULL)
- goto done;
- else if (!strncmp(str, "auto", 4))
+ if (parport_setup_ptr == PARPORT_MAX) {
+ printk(KERN_ERR "parport=%s ignored, too many ports\n", str);
+ return 1;
+ }
+
+ io[parport_setup_ptr] = val;
+ irq[parport_setup_ptr] = PARPORT_IRQ_NONE;
+ dma[parport_setup_ptr] = PARPORT_DMA_NONE;
+
+ sep = strchr (str, ',');
+ if (sep++) {
+ if (!strncmp (sep, "auto", 4))
irq[parport_setup_ptr] = PARPORT_IRQ_AUTO;
- else if (strncmp(str, "none", 4) != 0) {
- printk(KERN_ERR "parport: bad irq `%s'\n", str);
- return;
+ else if (strncmp (sep, "none", 4)) {
+ val = simple_strtoul (sep, &endptr, 0);
+ if (endptr == sep) {
+ printk (KERN_WARNING
+ "parport=%s: irq not understood\n",
+ str);
+ return 1;
+ }
+ irq[parport_setup_ptr] = val;
}
+ }
- if ((sep = strchr(str, ',')) == NULL) goto done;
- str = sep+1;
- dma_from_str:
- if (!strncmp(str, "auto", 4))
+ sep = strchr (sep, ',');
+ if (sep++) {
+ if (!strncmp (sep, "auto", 4))
dma[parport_setup_ptr] = PARPORT_DMA_AUTO;
- else if (strncmp(str, "none", 4) != 0) {
- char *ep;
- dma[parport_setup_ptr] = simple_strtoul(str, &ep, 0);
- if (ep == str) {
- printk(KERN_ERR "parport: bad dma `%s'\n",
- str);
- return;
+ else if (strncmp (sep, "none", 4)) {
+ val = simple_strtoul (sep, &endptr, 0);
+ if (endptr == sep) {
+ printk (KERN_WARNING
+ "parport=%s: dma not understood\n",
+ str);
+ return 1;
}
+ dma[parport_setup_ptr] = val;
}
- done:
- parport_setup_ptr++;
- } else
- printk(KERN_ERR "parport=%s ignored, too many ports\n", str);
+ }
+
+ parport_setup_ptr++;
+ return 0;
}
+
+__setup ("parport=", parport_setup);
+
#endif
#ifdef MODULE
@@ -113,7+128,7 @@ void cleanup_module(void)
#else
-__initfunc(int parport_init(void))
+int __init parport_init (void)
{
if (io[0] == PARPORT_DISABLE)
return 1;
@@ -139,6+154,9 @@ __initfunc(int parport_init(void)) #endif
return 0;
}
+
+__initcall (parport_init);
+
#endif
/* Exported symbols for modules. */
@@ -48,10+48,6 @@ static unsigned char control_pc_to_amiga(unsigned char control) {
unsigned char ret = 0;
- if (control & PARPORT_CONTROL_DIRECTION) /* XXX: What is this? */
- ;
- if (control & PARPORT_CONTROL_INTEN) /* XXX: What is INTEN? */
- ;
if (control & PARPORT_CONTROL_SELECT) /* XXX: What is SELECP? */
;
if (control & PARPORT_CONTROL_INIT) /* INITP */
@@ -66,9+62,9 @@ static unsigned char control_pc_to_amiga(unsigned char control)
static unsigned char control_amiga_to_pc(unsigned char control)
{
- return PARPORT_CONTROL_INTEN | PARPORT_CONTROL_SELECT |
+ return PARPORT_CONTROL_SELECT |
PARPORT_CONTROL_AUTOFD | PARPORT_CONTROL_STROBE;
- /* fake value: interrupt enable, select in, no reset,
+ /* fake value: select in, no reset,
no autolf, no strobe - seems to be closest the wiring diagram */
}
@@ -127,12+123,6 @@ static unsigned char status_amiga_to_pc(unsigned char status) return ret;
}
-static void amiga_write_status( struct parport *p, unsigned char status)
-{
-DPRINTK("write_status %02x\n",status);
- ciab.pra |= (ciab.pra & 0xf8) | status_pc_to_amiga(status);
-}
-
static unsigned char amiga_read_status(struct parport *p)
{
unsigned char status;
@@ -142,12+132,6 @@ DPRINTK("read_status %02x\n", status); return status;
}
-static void amiga_change_mode( struct parport *p, int m)
-{
- /* XXX: This port only has one mode, and I am
- not sure about the corresponding PC-style mode*/
-}
-
/* as this ports irq handling is already done, we use a generic funktion */
static void amiga_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{
@@ -155,7+139,7 @@ static void amiga_interrupt(int irq, void *dev_id, struct pt_regs *regs) }
-static void amiga_init_state(struct parport_state *s)
+static void amiga_init_state(struct pardevice *dev, struct parport_state *s)
{
s->u.amiga.data = 0;
s->u.amiga.datadir = 255;
@@ -261,9+245,6 @@ __initfunc(int parport_amiga_init(void)) return 0;
}
- if (parport_probe_hook)
- (*parport_probe_hook)(p);
-
parport_announce_port (p);
return 1;
@@ -1648,7+1648,8 @@ struct parport *__maybe_init parport_pc_probe_port (unsigned long int base, p->name, p->dma);
p->dma = PARPORT_DMA_NONE;
} else {
- priv->dma_buf = (char *) __get_dma_pages(GFP_KERNEL, 0);
+ priv->dma_buf =
+ (char *)__get_dma_pages(GFP_KERNEL, 0);
if (! priv->dma_buf) {
printk (KERN_WARNING "%s: "
"cannot get buffer for DMA, "
@@ -15,7+15,7 @@ L_TARGET := pci.a ifeq ($(CONFIG_MODULES),y)
O_TARGET = pci_syms.o
OX_OBJS = pcisyms.o
-O_OBJS = pci.o
+O_OBJS = pci.o names.o
L_OBJS := pci_syms.o
else
L_OBJS := pci.o
ifdef CONFIG_PROC_FS
L_OBJS += proc.o
-ifdef CONFIG_PCI_OLD_PROC
-L_OBJS += oldproc.o
-endif
endif
ifdef CONFIG_PCI_QUIRKS
#include <linux/sched.h>
#include <linux/init.h>
#include <linux/proc_fs.h>
-#include <asm/page.h>
-#ifdef CONFIG_PROC_FS
+#include <asm/page.h>
struct pci_dev_info {
unsigned short vendor; /* vendor id */
@@ -34,7+33,7 @@ struct pci_dev_info { * Use binary search for lookup. If you add a device make sure
* it is sequential by both vendor and device id.
*/
-struct pci_dev_info dev_info[] = {
+static __initdata struct pci_dev_info dev_info[] = {
DEVICE( COMPAQ, COMPAQ_1280, "QVision 1280/p"),
DEVICE( COMPAQ, COMPAQ_SMART2P, "Smart-2/P RAID Controller"),
DEVICE( COMPAQ, COMPAQ_NETEL100,"Netelligent 10/100"),
@@ -594,7+593,7 @@ struct pci_dev_info dev_info[] = { /*
* device_info[] is sorted so we can use binary search
*/
-static struct pci_dev_info *pci_lookup_dev(unsigned int vendor, unsigned int dev)
+static struct pci_dev_info * __init pci_lookup_dev(unsigned int vendor, unsigned int dev)
{
int min = 0,
max = sizeof(dev_info)/sizeof(dev_info[0]) - 1;
@@ -628,6+627,20 @@ static struct pci_dev_info *pci_lookup_dev(unsigned int vendor, unsigned int dev }
}
+__init void pci_namedevice(struct pci_dev *dev)
+{
+ struct pci_dev_info *info;
+
+ info = pci_lookup_dev(dev->vendor, dev->device);
+ if (info) {
+ strcpy(dev->name, info->name);
+ return;
+ }
+ sprintf(dev->name, "PCI<%d:%04x> %04x:%04x", dev->bus->number, dev->devfn, dev->vendor, dev->device);
+}
+
+#ifdef CONFIG_PROC_FS
+
static const char *pci_strclass (unsigned int class)
{
switch (class >> 8) {
@@ -849,15+862,6 @@ static const char *pci_strvendor(unsigned int vendor) }
-static const char *pci_strdev(unsigned int vendor, unsigned int device)
-{
- struct pci_dev_info *info;
-
- info = pci_lookup_dev(vendor, device);
- return info ? info->name : "Unknown device";
-}
-
-
/*
* Convert some of the configuration space registers of the device at
* address (bus,devfn) into a string (possibly several lines each).
@@ -866,7+870,6 @@ static const char *pci_strdev(unsigned int vendor, unsigned int device) */
static int sprint_dev_config(struct pci_dev *dev, char *buf, int size)
{
- unsigned long base;
unsigned int class_rev, bus, devfn;
unsigned short vendor, device, status;
unsigned char bist, latency, min_gnt, max_lat;
@@ -895,13+898,7 @@ static int sprint_dev_config(struct pci_dev *dev, char *buf, int size) }
len += sprintf(buf + len, " %s: %s %s (rev %d).\n ",
pci_strclass(class_rev >> 8), pci_strvendor(vendor),
- pci_strdev(vendor, device), class_rev & 0xff);
-
- if (!pci_lookup_dev(vendor, device)) {
- len += sprintf(buf + len,
- "Vendor id=%x. Device id=%x.\n ",
- vendor, device);
- }
+ dev->name, class_rev & 0xff);
switch (status & PCI_STATUS_DEVSEL_MASK) {
case PCI_STATUS_DEVSEL_FAST: str = "Fast devsel. "; break;
@@ -955,27+952,31 @@ static int sprint_dev_config(struct pci_dev *dev, char *buf, int size) }
for (reg = 0; reg < 6; reg++) {
+ struct resource *res = dev->resource + reg;
+ unsigned long base, end, flags;
+
if (len + 40 > size) {
return -1;
}
- base = dev->base_address[reg];
- if (!base)
+ base = res->start;
+ end = res->end;
+ flags = res->flags;
+ if (!flags)
continue;
- if (base & PCI_BASE_ADDRESS_SPACE_IO) {
+ if (flags & PCI_BASE_ADDRESS_SPACE_IO) {
len += sprintf(buf + len,
"\n I/O at 0x%lx [0x%lx].",
- base & PCI_BASE_ADDRESS_IO_MASK,
- dev->base_address[reg]);
+ base, end);
} else {
const char *pref, *type = "unknown";
- if (base & PCI_BASE_ADDRESS_MEM_PREFETCH) {
+ if (flags & PCI_BASE_ADDRESS_MEM_PREFETCH) {
pref = "P";
} else {
pref = "Non-p";
}
- switch (base & PCI_BASE_ADDRESS_MEM_TYPE_MASK) {
+ switch (flags & PCI_BASE_ADDRESS_MEM_TYPE_MASK) {
case PCI_BASE_ADDRESS_MEM_TYPE_32:
type = "32 bit"; break;
case PCI_BASE_ADDRESS_MEM_TYPE_1M:
@@ -986,8+987,8 @@ static int sprint_dev_config(struct pci_dev *dev, char *buf, int size) len += sprintf(buf + len,
"\n %srefetchable %s memory at "
"0x%lx [0x%lx].", pref, type,
- base & PCI_BASE_ADDRESS_MEM_MASK,
- dev->base_address[reg]);
+ base,
+ end);
}
}
@@ -143,25+143,56 @@ void __init pci_read_bases(struct pci_dev *dev, unsigned int howmany) unsigned int reg;
u32 l;
- for(reg=0; reg<howmany; reg++) {
+ for(reg=0; reg < howmany; reg++) {
+ struct resource *res = dev->resource + reg;
+ unsigned int mask, newval, size;
+
+ res->name = dev->name;
pci_read_config_dword(dev, PCI_BASE_ADDRESS_0 + (reg << 2), &l);
if (l == 0xffffffff)
continue;
- dev->base_address[reg] = l;
+
+ pci_write_config_dword(dev, PCI_BASE_ADDRESS_0 + (reg << 2), 0xffffffff);
+ pci_read_config_dword(dev, PCI_BASE_ADDRESS_0 + (reg << 2), &newval);
+ pci_write_config_dword(dev, PCI_BASE_ADDRESS_0 + (reg << 2), l);
+
+ mask = PCI_BASE_ADDRESS_MEM_MASK;
+ if (l & PCI_BASE_ADDRESS_SPACE_IO)
+ mask = PCI_BASE_ADDRESS_IO_MASK;
+
+ newval &= mask;
+ if (!newval)
+ continue;
+
+ res->start = l & mask;
+ res->flags = l & ~mask;
+
+ size = 1;
+ do {
+ size <<= 1;
+ } while (!(size & newval));
+ res->end = res->start + size - 1;
+
+ /* 64-bit memory? */
if ((l & (PCI_BASE_ADDRESS_SPACE | PCI_BASE_ADDRESS_MEM_TYPE_MASK))
== (PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_64)) {
+ unsigned int high;
reg++;
- pci_read_config_dword(dev, PCI_BASE_ADDRESS_0 + (reg << 2), &l);
- if (l) {
+ pci_read_config_dword(dev, PCI_BASE_ADDRESS_0 + (reg << 2), &high);
+ if (high) {
#if BITS_PER_LONG == 64
- dev->base_address[reg-1] |= ((unsigned long) l) << 32;
+ res->start |= ((unsigned long) high) << 32;
#else
printk("PCI: Unable to handle 64-bit address for device %02x:%02x\n",
dev->bus->number, dev->devfn);
- dev->base_address[reg-1] = 0;
+ res->flags = 0;
+ res->start = 0;
+ res->end = 0;
+ continue;
#endif
}
}
+ request_resource((l & PCI_BASE_ADDRESS_SPACE_IO) ? &ioport_resource : &iomem_resource, res);
}
}
@@ -202,6+233,7 @@ unsigned int __init pci_scan_bus(struct pci_bus *bus) dev->devfn = devfn;
dev->vendor = l & 0xffff;
dev->device = (l >> 16) & 0xffff;
+ pci_namedevice(dev);
/* non-destructively determine if device can be a master: */
pcibios_read_config_byte(bus->number, devfn, PCI_COMMAND, &cmd);
@@ -247,14+247,15 @@ get_pci_dev_info(char *buf, char **start, off_t pos, int count, int wr) dev->vendor,
dev->device,
dev->irq);
- for(i=0; i<6; i++)
+ for(i=0; i<6; i++) {
len += sprintf(buf+len,
#if BITS_PER_LONG == 32
"\t%08lx",
#else
"\t%016lx",
#endif
- dev->base_address[i]);
+ dev->resource[i].start | (dev->resource[i].flags & 0xf));
+ }
len += sprintf(buf+len,
#if BITS_PER_LONG == 32
"\t%08lx",
@@ -1484,19+1484,16 @@ static void cs4231_start_output(struct sparcaudio_driver *drv, __u8 * buffer, cs4231_chip->perchip_info.play.active = 1;
cs4231_chip->playing_count = 0;
+ cs4231_playintr(drv);
if ((cs4231_chip->regs->dmacsr & APC_PPAUSE) ||
!(cs4231_chip->regs->dmacsr & APC_PDMA_READY)) {
- cs4231_chip->regs->dmacsr &= ~APC_XINT_PLAY;
- cs4231_chip->regs->dmacsr &= ~APC_PPAUSE;
-
- cs4231_playintr(drv);
-
- cs4231_chip->regs->dmacsr |= APC_PLAY_SETUP;
+ cs4231_chip->regs->dmacsr &= ~(APC_XINT_PLAY | APC_PPAUSE);
+ cs4231_chip->regs->dmacsr |= APC_GENL_INT | APC_XINT_ENA | APC_XINT_PLAY
+ | APC_XINT_GENL | APC_XINT_PENA | APC_PDMA_READY;
cs4231_enable_play(drv);
-
+
cs4231_ready(drv);
- } else
- cs4231_playintr(drv);
+ }
}
#ifdef EB4231_SUPPORT
@@ -1547,8+1544,11 @@ static void cs4231_stop_output(struct sparcaudio_driver *drv) cs4231_chip->output_next_dma_handle = 0;
cs4231_chip->output_next_dma_size = 0;
}
-#if 0 /* Not safe without shutting off the DMA controller as well. -DaveM */
+#if 1 /* Not safe without shutting off the DMA controller as well. -DaveM */
/* Else subsequent speed setting changes are ignored by the chip. */
+ cs4231_chip->regs->dmacsr &= ~(APC_GENL_INT | APC_XINT_ENA | APC_XINT_PLAY
+ | APC_XINT_GENL | APC_PDMA_READY
+ | APC_XINT_PENA );
cs4231_disable_play(drv);
#endif
}
@@ -1897,7+1897,7 @@ void cs4231_interrupt(int irq, void *dev_id, struct pt_regs *regs) */
if (dummy & APC_PLAY_INT) {
- if (dummy & APC_XINT_PNVA) {
+ if (dummy & APC_XINT_PEMP) {
cs4231_chip->perchip_info.play.samples +=
cs4231_length_to_samplecount(&(cs4231_chip->perchip_info.play),
cs4231_chip->playlen);
pci_get_base_address(struct pci_dev *pdev, int index, u_long *base)
)
{
- *base = pdev->base_address[index++];
- if ((*base & 0x7) == 0x4) {
-#if BITS_PER_LONG > 32
- *base |= (((u_long)pdev->base_address[index]) << 32);
-#endif
+ /* FIXME! This is just unbelieably horrible backwards compatibility code */
+ struct resource *res = pdev->resource + index;
+
+ *base = res->start | (res->flags & 0xf);
+ if ((res->flags & 0x7) == 0x4) {
++index;
}
- return index;
+ return index+1;
}
#endif
dep_tristate 'C-Media PCI (CMI8338/8378)' CONFIG_SOUND_CMPCI $CONFIG_SOUND
dep_tristate 'Ensoniq AudioPCI (ES1370)' CONFIG_SOUND_ES1370 $CONFIG_SOUND
-if [ "$CONFIG_SOUND_ES1370" = "y" ]; then
- bool 'Joystick support at boot time' CONFIG_SOUND_ES1370_JOYPORT_BOOT
-fi
dep_tristate 'Creative Ensoniq AudioPCI 97 (ES1371)' CONFIG_SOUND_ES1371 $CONFIG_SOUND
-if [ "$CONFIG_SOUND_ES1371" = "y" ]; then
- bool 'Joystick support at boot time' CONFIG_SOUND_ES1371_JOYPORT_BOOT
- if [ "$CONFIG_SOUND_ES1371_JOYPORT_BOOT" = "y" ]; then
- hex 'Gameport I/O 200,208,210,218' CONFIG_SOUND_ES1371_GAMEPORT 200
- fi
-fi
dep_tristate 'S3 SonicVibes' CONFIG_SOUND_SONICVIBES $CONFIG_SOUND
dep_tristate 'Support for Turtle Beach MultiSound Classic, Tahiti, Monterey' CONFIG_SOUND_MSNDCLAS $CONFIG_SOUND
* 28.06.99 0.24 Add pci_set_master
* 02.08.99 0.25 Added workaround for the "phantom write" bug first
* documented by Dave Sharpless from Anchor Games
+ * 03.08.99 0.26 adapt to Linus' new __setup/__initcall
+ * added kernel command line option "es1370=joystick[,lineout[,micbias]]"
+ * removed CONFIG_SOUND_ES1370_JOYPORT_BOOT kludge
*
* some important things missing in Ensoniq documentation:
*
@@ -2293,11+2296,8 @@ static /*const*/ struct file_operations es1370_midi_fops = {
/* maximum number of devices */
#define NR_DEVICE 5
-#ifdef CONFIG_SOUND_ES1370_JOYPORT_BOOT
-static int joystick[NR_DEVICE] = { 1, 0, };
-#else
+
static int joystick[NR_DEVICE] = { 0, };
-#endif
static int lineout[NR_DEVICE] = { 0, };
static int micbias[NR_DEVICE] = { 0, };
@@ -2319,11+2319,10 @@ static struct initvol { { SOUND_MIXER_WRITE_OGAIN, 0x4040 }
};
-#ifdef MODULE
-int __init init_module(void)
-#else
-int __init init_es1370(void)
+#ifndef MODULE
+static
#endif
+int __init init_module(void)
{
struct es1370_state *s;
struct pci_dev *pcidev = NULL;
@@ -2332,7+2331,7 @@ int __init init_es1370(void)
if (!pci_present()) /* No PCI bus in this machine! */
return -ENODEV;
- printk(KERN_INFO "es1370: version v0.25 time " __TIME__ " " __DATE__ "\n");
+ printk(KERN_INFO "es1370: version v0.26 time " __TIME__ " " __DATE__ "\n");
while (index < NR_DEVICE &&
(pcidev = pci_find_device(PCI_VENDOR_ID_ENSONIQ, PCI_DEVICE_ID_ENSONIQ_ES1370, pcidev))) {
if (pcidev->base_address[0] == 0 ||
@@ -2474,4+2473,29 @@ void cleanup_module(void) printk(KERN_INFO "es1370: unloading\n");
}
+#else /* MODULE */
+
+/* format is: es1370=[joystick[,lineout[,micbias]]] */
+
+static int __init es1370_setup(char *str)
+{
+ static unsigned __initdata nr_dev = 0;
+ int ints[11];
+
+ if (nr_dev >= NR_DEVICE)
+ return 0;
+ get_options(str, ints);
+ if (ints[0] >= 1)
+ joystick[nr_dev] = ints[1];
+ if (ints[0] >= 2)
+ lineout[nr_dev] = ints[2];
+ if (ints[0] >= 3)
+ micbias[nr_dev] = ints[3];
+ nr_dev++;
+ return 1;
+}
+
+__setup("es1370=", es1370_setup);
+__initcall(init_module);
+
#endif /* MODULE */
* 15.06.99 0.12 Fix bad allocation bug.
* Thanks to Deti Fliegl <fliegl@in.tum.de>
* 28.06.99 0.13 Add pci_set_master
+ * 03.08.99 0.14 adapt to Linus' new __setup/__initcall
+ * added kernel command line option "es1371=joystickaddr"
+ * removed CONFIG_SOUND_ES1371_JOYPORT_BOOT kludge
*
*/
@@ -2694,13+2697,7 @@ static /*const*/ struct file_operations es1371_midi_fops = { /* maximum number of devices */
#define NR_DEVICE 5
-#if CONFIG_SOUND_ES1371_JOYPORT_BOOT
-static int joystick[NR_DEVICE] = {
-CONFIG_SOUND_ES1371_GAMEPORT
-, 0, };
-#else
static int joystick[NR_DEVICE] = { 0, };
-#endif
/* --------------------------------------------------------------------- */
@@ -2723,11+2720,10 @@ static struct initvol { { SOUND_MIXER_WRITE_IGAIN, 0x4040 }
};
-#ifdef MODULE
-int __init init_module(void)
-#else
-int __init init_es1371(void)
+#ifndef MODULE
+static
#endif
+int __init init_module(void)
{
struct es1371_state *s;
struct pci_dev *pcidev = NULL;
@@ -2736,7+2732,7 @@ int __init init_es1371(void)
if (!pci_present()) /* No PCI bus in this machine! */
return -ENODEV;
- printk(KERN_INFO "es1371: version v0.13 time " __TIME__ " " __DATE__ "\n");
+ printk(KERN_INFO "es1371: version v0.14 time " __TIME__ " " __DATE__ "\n");
while (index < NR_DEVICE &&
(pcidev = pci_find_device(PCI_VENDOR_ID_ENSONIQ, PCI_DEVICE_ID_ENSONIQ_ES1371, pcidev))) {
if (pcidev->base_address[0] == 0 ||
@@ -2918,4+2914,25 @@ void cleanup_module(void) printk(KERN_INFO "es1371: unloading\n");
}
+#else /* MODULE */
+
+/* format is: es1371=[joystick] */
+
+static int __init es1371_setup(char *str)
+{
+ static unsigned __initdata nr_dev = 0;
+ int ints[11];
+
+ if (nr_dev >= NR_DEVICE)
+ return 0;
+ get_options(str, ints);
+ if (ints[0] >= 1)
+ joystick[nr_dev] = ints[1];
+ nr_dev++;
+ return 1;
+}
+
+__setup("es1371=", es1371_setup);
+__initcall(init_module);
+
#endif /* MODULE */
#include <linux/config.h>
#include <linux/module.h>
-#include <asm/init.h>
+#include <linux/init.h>
#define USE_SEQ_MACROS
#define USE_SIMPLE_MACROS
*/
#include <linux/config.h>
#include <linux/delay.h>
-#include <asm/init.h>
+#include <linux/init.h>
#include "sound_config.h"
#include "sound_firmware.h"
* 15.06.99 0.15 Fix bad allocation bug.
* Thanks to Deti Fliegl <fliegl@in.tum.de>
* 28.06.99 0.16 Add pci_set_master
+ * 03.08.99 0.17 adapt to Linus' new __setup/__initcall
+ * added kernel command line options "sonicvibes=reverb" and "sonicvibesdmaio=dmaioaddr"
*
*/
@@ -2312,11+2314,10 @@ static struct initvol { { SOUND_MIXER_WRITE_PCM, 0x4040 }
};
-#ifdef MODULE
-int __init init_module(void)
-#else
-int __init init_sonicvibes(void)
+#ifndef MODULE
+static
#endif
+int __init init_module(void)
{
struct sv_state *s;
struct pci_dev *pcidev = NULL;
@@ -2325,7+2326,7 @@ int __init init_sonicvibes(void)
if (!pci_present()) /* No PCI bus in this machine! */
return -ENODEV;
- printk(KERN_INFO "sv: version v0.16 time " __TIME__ " " __DATE__ "\n");
+ printk(KERN_INFO "sv: version v0.17 time " __TIME__ " " __DATE__ "\n");
#if 0
if (!(wavetable_mem = __get_free_pages(GFP_KERNEL, 20-PAGE_SHIFT)))
printk(KERN_INFO "sv: cannot allocate 1MB of contiguous nonpageable memory for wavetable data\n");
@@ -2525,8+2526,8 @@ void cleanup_module(void) synchronize_irq();
inb(s->ioenh + SV_CODEC_STATUS); /* ack interrupts */
wrindir(s, SV_CIENABLE, 0); /* disable DMAA and DMAC */
- //outb(0, s->iodmaa + SV_DMA_RESET);
- //outb(0, s->iodmac + SV_DMA_RESET);
+ /*outb(0, s->iodmaa + SV_DMA_RESET);*/
+ /*outb(0, s->iodmac + SV_DMA_RESET);*/
free_irq(s->irq, s);
release_region(s->iodmac, SV_EXTENT_DMA);
release_region(s->iodmaa, SV_EXTENT_DMA);
@@ -2544,4+2545,40 @@ void cleanup_module(void) printk(KERN_INFO "sv: unloading\n");
}
+#else /* MODULE */
+
+/* format is: sonicvibes=[reverb] sonicvibesdmaio=dmaioaddr */
+
+static int __init sonicvibes_setup(char *str)
+{
+ static unsigned __initdata nr_dev = 0;
+ int ints[11];
+
+ if (nr_dev >= NR_DEVICE)
+ return 0;
+ get_options(str, ints);
+ if (ints[0] >= 1)
+ reverb[nr_dev] = ints[1];
+#if 0
+ if (ints[0] >= 2)
+ wavetable[nr_dev] = ints[2];
+#endif
+ nr_dev++;
+ return 1;
+}
+
+static int __init sonicvibesdmaio_setup(char *str)
+{
+ int ints[11];
+
+ get_options(str, ints);
+ if (ints[0] >= 1)
+ dmaio = ints[1];
+ return 1;
+}
+
+__setup("sonicvibes=", sonicvibes_setup);
+__setup("sonicvibesdmaio=", sonicvibesdmaio_setup);
+__initcall(init_module);
+
#endif /* MODULE */
@@ -52,15+52,6 @@ struct sound_unit struct sound_unit *next;
};
-#ifdef CONFIG_SOUND_SONICVIBES
-extern int init_sonicvibes(void);
-#endif
-#ifdef CONFIG_SOUND_ES1370
-extern int init_es1370(void);
-#endif
-#ifdef CONFIG_SOUND_ES1371
-extern int init_es1371(void);
-#endif
#ifdef CONFIG_SOUND_MSNDCLAS
extern int msnd_classic_init(void);
#endif
@@ -395,18+386,9 @@ int soundcore_init(void) /*
* Now init non OSS drivers
*/
-#ifdef CONFIG_SOUND_SONICVIBES
- init_sonicvibes();
-#endif
#ifdef CONFIG_SOUND_CMPCI
init_cmpci();
#endif
-#ifdef CONFIG_SOUND_ES1370
- init_es1370();
-#endif
-#ifdef CONFIG_SOUND_ES1371
- init_es1371();
-#endif
#ifdef CONFIG_SOUND_MSNDCLAS
msnd_classic_init();
#endif
*/
#include <linux/string.h>
-#include <asm/init.h>
+#include <linux/init.h>
#include <asm/addrspace.h>
#include <asm/errno.h>
#include <asm/dec/machtype.h>
@@ -1148,11+1148,13 @@ try_again: */
no_grow:
if (head) {
+ spin_lock(&unused_list_lock);
do {
bh = head;
head = head->b_this_page;
- put_unused_buffer_head(bh);
+ __put_unused_buffer_head(bh);
} while (head);
+ spin_unlock(&unused_list_lock);
/* Wake up any waiters ... */
wake_up(&buffer_wait);
@@ -1201,8+1203,8 @@ static int create_page_buffers(int rw, struct page *page, kdev_t dev, int b[], i PAGE_BUG(page);
/*
* Allocate async buffer heads pointing to this page, just for I/O.
- * They show up in the buffer hash table and are registered in
- * page->buffers.
+ * They don't show up in the buffer hash table, but they *are*
+ * registered in page->buffers.
*/
head = create_buffers(page_address(page), size, 1);
if (page->buffers)
@@ -1858,7+1860,6 @@ int block_read_full_page(struct file * file, struct page * page) blocks = PAGE_SIZE >> inode->i_sb->s_blocksize_bits;
iblock = page->offset >> inode->i_sb->s_blocksize_bits;
page->owner = (void *)-1;
- head = page->buffers;
bh = head;
nr = 0;
@@ -651,8+651,8 @@ static struct proc_dir_entry proc_root_ioports = { S_IFREG | S_IRUGO, 1, 0, 0,
0, &proc_array_inode_operations
};
-static struct proc_dir_entry proc_root_memory = {
- PROC_MEMORY, 6, "memory",
+static struct proc_dir_entry proc_root_iomem = {
+ PROC_MEMORY, 6, "iomem",
S_IFREG | S_IRUGO, 1, 0, 0,
0, &proc_array_inode_operations
};
@@ -744,7+744,7 @@ __initfunc(void proc_root_init(void)) proc_register(&proc_root, &proc_root_fs);
proc_register(&proc_root, &proc_root_dma);
proc_register(&proc_root, &proc_root_ioports);
- proc_register(&proc_root, &proc_root_memory);
+ proc_register(&proc_root, &proc_root_iomem);
proc_register(&proc_root, &proc_root_cmdline);
#ifdef CONFIG_RTC
proc_register(&proc_root, &proc_root_rtc);
@@ -1166,6+1166,7 @@ void __init mount_root(void) if (MAJOR(ROOT_DEV) == FLOPPY_MAJOR) {
#ifdef CONFIG_BLK_DEV_RAM
extern int rd_doload;
+ extern void rd_load_secondary(void);
#endif
floppy_eject();
#ifndef CONFIG_BLK_DEV_RAM
#define L1_CACHE_ALIGN(x) (((x)+(L1_CACHE_BYTES-1))&~(L1_CACHE_BYTES-1))
#define SMP_CACHE_BYTES L1_CACHE_BYTES
+#ifdef MODULE
+#define __cacheline_aligned __attribute__((__aligned__(L1_CACHE_BYTES)))
+#else
+#define __cacheline_aligned \
+ __attribute__((__aligned__(L1_CACHE_BYTES), \
+ __section__(".data.cacheline_aligned")))
+#endif
+
#endif
/* Initially just a straight copy of the i386 code. */
-#include <linux/tasks.h>
+#include <linux/threads.h>
#ifndef __SMP__
extern int __local_irq_count;
-#ifndef _ALPHA_INIT_H
-#define _ALPHA_INIT_H
-
-#ifndef MODULE
-
-#define __init __attribute__ ((__section__ (".text.init")))
-#define __initdata __attribute__ ((__section__ (".data.init")))
-#define __initfunc(__arginit) \
- __arginit __init; \
- __arginit
-
-/* For assembly routines */
-#define __INIT .section .text.init,"ax"
-#define __FINIT .previous
-#define __INITDATA .section .data.init,"a"
-
-#define __cacheline_aligned __attribute__((__aligned__(32)))
-
-/*
- * Used for initialization calls.
- */
-
-typedef int (*initcall_t)(void);
-
-extern initcall_t __initcall_start, __initcall_end;
-
-#define __initcall(fn) \
- static __attribute__ ((unused, __section__ (".initcall.init"))) \
- initcall_t __initcall_##fn = fn
-
-/*
- * Used for kernel command line parameter setup.
- */
-
-struct kernel_param {
- const char *str;
- int (*setup_func)(char *);
-};
-
-extern struct kernel_param __setup_start, __setup_end;
-
-#define __setup(str, fn) \
- static __attribute__ ((__section__ (".data.init"))) \
- char __setup_str_##fn[] = str; \
- static __attribute__ ((unused, __section__ (".setup.init"))) \
- struct kernel_param __setup_##fn = { __setup_str_##fn, fn }
-
-#endif /* MODULE */
-#endif /* _ALPHA_INIT_H */
+#error "<asm/init.h> should never be used - use <linux/init.h> instead"
@@ -111,14+111,15 @@ extern inline unsigned long thread_saved_pc(struct thread_struct *t) return 0;
}
-/*
- * Do necessary setup to start up a newly executed thread.
- */
+/* Do necessary setup to start up a newly executed thread. */
extern void start_thread(struct pt_regs *, unsigned long, unsigned long);
/* Free all resources held by a thread. */
extern void release_thread(struct task_struct *);
+/* Create a kernel thread without removing it from tasklists. */
+extern long kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
+
#define copy_segments(tsk, mm) do { } while (0)
#define release_segments(mm) do { } while (0)
#define forget_segments() do { } while (0)
@@ -496,13+496,6 @@ type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, type6 arg6)\ #include <linux/string.h>
#include <linux/signal.h>
-extern long __kernel_thread(unsigned long, int (*)(void *), void *);
-
-static inline long kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
-{
- return __kernel_thread(flags | CLONE_VM, fn, arg);
-}
-
extern void sys_idle(void);
static inline void idle(void)
{
#define SMP_CACHE_BYTES L1_CACHE_BYTES
+#ifdef MODULE
+#define __cacheline_aligned __attribute__((__aligned__(L1_CACHE_BYTES)))
+#else
+#define __cacheline_aligned \
+ __attribute__((__aligned__(L1_CACHE_BYTES), \
+ __section__(".data.cacheline_aligned")))
+#endif
+
#endif
-/* $Id: floppy.h,v 1.18 1999/03/21 10:51:38 davem Exp $
+/* $Id: floppy.h,v 1.19 1999/08/03 08:01:15 davem Exp $
* asm-sparc64/floppy.h: Sparc specific parts of the Floppy driver.
*
* Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
@@ -548,6+548,7 @@ __initfunc(static unsigned long sun_floppy_init(void)) #ifdef CONFIG_PCI
struct linux_ebus *ebus;
struct linux_ebus_device *edev = 0;
+ unsigned long auxio_reg;
for_each_ebus(ebus) {
for_each_ebusdev(edev, ebus) {
@@ -576,6+577,12 @@ __initfunc(static unsigned long sun_floppy_init(void)) sun_fdc = (struct sun_flpy_controller *)edev->base_address[0];
FLOPPY_IRQ = edev->irqs[0];
+ /* Make sure the high density bit is set, some systems
+ * (most notably Ultra5/Ultra10) come up with it clear.
+ */
+ auxio_reg = edev->base_address[2];
+ writel(readl(auxio_reg)|0x2, auxio_reg);
+
sun_pci_fd_ebus_dma = (struct linux_ebus_dma *)
edev->base_address[1];
sun_pci_fd_reset_dma();
-#ifndef _SPARC_INIT_H
-#define _SPARC_INIT_H
-
-typedef int (*initcall_t)(void);
-
-extern initcall_t __initcall_start, __initcall_end;
-
-struct kernel_param {
- const char *str;
- int (*setup_func)(char *);
-};
-
-extern struct kernel_param __setup_start, __setup_end;
-
-/* Used for initialization calls.. */
-#define __initcall(fn) \
- static __attribute__ ((unused,__section__ (".initcall.init"))) initcall_t __initcall_##fn = fn
-
-/* Used for kernel command line parameter setup */
-#define __setup(str, fn) \
- static __attribute__ ((unused,__section__ (".setup.init"))) struct kernel_param __setup_##fn = { str, fn }
-
-
-#define __init __attribute__ ((__section__ (".text.init")))
-#define __initdata __attribute__ ((__section__ (".data.init")))
-#define __initfunc(__arginit) \
- __arginit __init; \
- __arginit
-/* For assembly routines */
-#define __INIT .section ".text.init",#alloc,#execinstr
-#define __FINIT .previous
-#define __INITDATA .section ".data.init",#alloc,#write
-
-#define __cacheline_aligned __attribute__ ((aligned (64)))
-
-#endif
+#error "<asm/init.h> should never be used - use <linux/init.h> instead"
-/* $Id: parport.h,v 1.2 1999/07/31 04:48:13 ecd Exp $
+/* $Id: parport.h,v 1.3 1999/08/04 03:20:03 davem Exp $
* parport.h: sparc64 specific parport initialization and dma.
*
* Copyright (C) 1999 Eddie C. Dost (ecd@skynet.be)
-/* $Id: processor.h,v 1.56 1999/07/30 09:31:20 davem Exp $
+/* $Id: processor.h,v 1.57 1999/08/04 03:20:05 davem Exp $
* include/asm-sparc64/processor.h
*
* Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
@@ -203,6+203,8 @@ do { \ /* Free all resources held by a thread. */
#define release_thread(tsk) do { } while(0)
+extern pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
+
#define copy_segments(tsk, mm) do { } while (0)
#define release_segments(mm) do { } while (0)
#define forget_segments() do { } while (0)
-/* $Id: system.h,v 1.52 1999/08/02 08:39:59 davem Exp $ */
+/* $Id: system.h,v 1.53 1999/08/03 05:16:14 davem Exp $ */
#ifndef __SPARC64_SYSTEM_H
#define __SPARC64_SYSTEM_H
@@ -125,6+125,7 @@ extern __inline__ void flushw_user(void)
#define flush_user_windows flushw_user
#define flush_register_windows flushw_all
+#define prepare_to_switch flushw_all
/* See what happens when you design the chip correctly?
*
-/* $Id: unistd.h,v 1.30 1999/07/31 04:05:24 ecd Exp $ */
+/* $Id: unistd.h,v 1.31 1999/08/04 03:20:06 davem Exp $ */
#ifndef _SPARC64_UNISTD_H
#define _SPARC64_UNISTD_H
@@ -430,8+430,6 @@ static __inline__ pid_t wait(int * wait_stat) return waitpid(-1,wait_stat,0);
}
-extern pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
-
#endif /* __KERNEL_SYSCALLS__ */
#ifdef __KERNEL__
@@ -94,9+94,6 @@ extern struct kernel_param __setup_start, __setup_end; #define __FINIT .previous
#define __INITDATA .section ".data.init","aw"
-#define __cacheline_aligned __attribute__ \
- ((__section__ (".data.cacheline_aligned")))
-
#define module_init(x) __initcall(x);
#define module_exit(x) /* nothing */
@@ -107,18+104,24 @@ extern struct kernel_param __setup_start, __setup_end; #define __initdata
#define __exitdata
#define __initfunc(__arginit) __arginit
-#defint __initcall
+#define __initcall
/* For assembly routines */
#define __INIT
#define __FINIT
#define __INITDATA
+/* Not sure what version aliases were introduced in, but certainly in 2.95. */
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
+#define module_init(x) int init_module(void) __attribute__((alias(#x)));
+#define module_exit(x) void cleanup_module(void) __attribute__((alias(#x)));
+#else
#define module_init(x) int init_module(void) { return x(); }
#define module_exit(x) void cleanup_module(void) { x(); }
+#endif
#endif
-#if __GNUC__ >= 2 && __GNUC_MINOR__ >= 8
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)
#define __initlocaldata __initdata
#else
#define __initlocaldata
@@ -49,7+49,8 @@ extern unsigned long simple_strtoul(const char *,char **,unsigned int); extern long simple_strtol(const char *,char **,unsigned int);
extern int sprintf(char * buf, const char * fmt, ...);
extern int vsprintf(char *buf, const char *, va_list);
-extern char *get_options(char *str, int *ints);
+extern int get_option(char **str, int *pint);
+extern char *get_options(char *str, int nints, int *ints);
extern int session_of_pgrp(int pgrp);
#include <linux/types.h>
#include <linux/config.h>
+#include <linux/ioport.h>
/*
* There is one pci_dev structure for each slot-number/function-number
@@ -1208,6+1209,8 @@ struct pci_dev { unsigned int class; /* 3 bytes: (base,sub,prog-if) */
unsigned int hdr_type; /* PCI header type */
unsigned int master : 1; /* set if device is master capable */
+
+ char name[32];
/*
* In theory, the irq level can be read from configuration
* space and all would be fine. However, old PCI chips don't
@@ -1224,7+1227,7 @@ struct pci_dev { /* Base registers for this device, can be adjusted by
* pcibios_fixup() as necessary.
*/
- unsigned long base_address[6];
+ struct resource resource[6];
unsigned long rom_address;
};
@@ -118,23+118,48 @@ char *execute_command = NULL; static char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
static char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
-char *get_options(char *str, int *ints)
+/*
+ * Read an int from an option string; if available accept a subsequent
+ * comma as well.
+ *
+ * Return values:
+ * 0 : no int in string
+ * 1 : int found, no subsequent comma
+ * 2 : int found including a subsequent comma
+ */
+int get_option(char **str, int *pint)
{
- char *cur = str;
- int i=1;
+ char *cur = *str;
- while (cur && (*cur=='-' || isdigit(*cur)) && i <= 10) {
- ints[i++] = simple_strtol(cur,NULL,0);
- if ((cur = strchr(cur,',')) != NULL)
- cur++;
- }
+ if (!cur || !(*cur)) return 0;
+ *pint = simple_strtol(cur,str,0);
+ if (cur==*str) return 0;
+ if (**str==',') {
+ (*str)++;
+ return 2;
+ }
+
+ return 1;
+}
+
+char *get_options(char *str, int nints, int *ints)
+{
+ int res,i=1;
+
+ while (i<nints) {
+ res = get_option(&str, ints+i);
+ if (res==0) break;
+ i++;
+ if (res==1) break;
+ }
ints[0] = i-1;
- return(cur);
+ return(str);
}
static int __init profile_setup(char *str)
{
- prof_shift = simple_strtol(str,NULL,0);
+ int par;
+ if (get_option(&str,&par)) prof_shift = par;
return 1;
}
@@ -76,6+76,7 @@ EXPORT_SYMBOL(request_module); #ifdef CONFIG_MODULES
EXPORT_SYMBOL(get_module_symbol);
#endif
+EXPORT_SYMBOL(get_option);
EXPORT_SYMBOL(get_options);
/* process memory management */
@@ -108,6+109,7 @@ EXPORT_SYMBOL(high_memory); EXPORT_SYMBOL(vmtruncate);
EXPORT_SYMBOL(find_vma);
EXPORT_SYMBOL(get_unmapped_area);
+EXPORT_SYMBOL(init_mm);
/* filesystem internal functions */
EXPORT_SYMBOL(in_group_p);
@@ -56,12+56,10 @@ static int __init console_setup(char *str) char name[sizeof(c->name)];
char *s, *options;
int i, idx;
- int ints[11];
/*
* Decode str into name, index, options.
*/
- str = get_options(str, ints);
if (str[0] >= '0' && str[0] <= '9') {
strcpy(name, "ttyS");
strncpy(name + 4, str, sizeof(name) - 5);
@@ -167,20+167,20 @@ void __release_region(struct resource *parent, unsigned long start, unsigned lon #define MAXRESERVE 4
static int __init reserve_setup(char *str)
{
- int i;
+ int opt = 2, io_start, io_num;
static int reserved = 0;
static struct resource reserve[MAXRESERVE];
- int ints[11];
- get_options(str, ints);
-
- for (i = 1; i < ints[0]; i += 2) {
+ while (opt==2) {
int x = reserved;
+
+ if (get_option (&str, &io_start) != 2) break;
+ if (get_option (&str, &io_num) == 0) break;
if (x < MAXRESERVE) {
struct resource *res = reserve + x;
res->name = "reserved";
- res->start = ints[i];
- res->end = res->start + ints[i] - 1;
+ res->start = io_start;
+ res->end = io_start + io_num - 1;
res->child = NULL;
if (request_resource(&ioport_resource, res) == 0)
reserved = x+1;
@@ -294,11+294,15 @@ int shrink_mmap(int priority, int gfp_mask)
/* Is it a buffer page? */
if (page->buffers) {
- int mem = page->inode ? 0 : PAGE_CACHE_SIZE;
spin_unlock(&pagecache_lock);
if (!try_to_free_buffers(page))
goto unlock_continue;
- atomic_sub(mem, &buffermem);
+ /* page was locked, inode can't go away under us */
+ if (!page->inode)
+ {
+ atomic_sub(PAGE_CACHE_SIZE, &buffermem);
+ goto made_progress;
+ }
spin_lock(&pagecache_lock);
}
@@ -26,7+26,6 @@ if [ "$CONFIG_HAMRADIO" != "n" ] ; then fi
fi
- source drivers/char/hfmodem/Config.in
fi
endmenu
@@ -1856,11+1856,6 @@ extern int scc_init(void); extern void sdla_setup(void);
extern void dlci_setup(void);
extern int dmascc_init(void);
-extern int sm_init(void);
-
-extern int baycom_ser_fdx_init(void);
-extern int baycom_ser_hdx_init(void);
-extern int baycom_par_init(void);
extern int lapbeth_init(void);
extern void arcnet_init(void);
@@ -1932,18+1927,6 @@ __initfunc(int net_dev_init(void)) #if defined(CONFIG_SDLA)
sdla_setup();
#endif
-#if defined(CONFIG_BAYCOM_PAR)
- baycom_par_init();
-#endif
-#if defined(CONFIG_BAYCOM_SER_FDX)
- baycom_ser_fdx_init();
-#endif
-#if defined(CONFIG_BAYCOM_SER_HDX)
- baycom_ser_hdx_init();
-#endif
-#if defined(CONFIG_SOUNDMODEM)
- sm_init();
-#endif
#if defined(CONFIG_LAPBETHER)
lapbeth_init();
#endif
#include <asm/system.h>
#include <asm/checksum.h>
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
static int __init eth_setup(char *str)
{
- int ints[11];
+ int ints[5];
struct device *d;
- str = get_options(str, ints);
+ str = get_options(str, ARRAY_SIZE(ints), ints);
if (!str || !*str)
return 0;