Commit 008dda0c authored by Linus Torvalds's avatar Linus Torvalds

Import 1.1.29

parent 379932d2
VERSION = 1
PATCHLEVEL = 1
SUBLEVEL = 28
SUBLEVEL = 29
all: Version zImage
......
This README belongs to release 2.2 of the SoundBlaster Pro (Matsushita,
This README belongs to release 2.3 of the SoundBlaster Pro (Matsushita,
Kotobuki, Panasonic, CreativeLabs) CD-ROM driver for Linux.
The driver is able to drive the whole family of IDE-style
......@@ -48,12 +48,16 @@ CDplayer and WorkBone - tell me if it is not compatible with other software.
With the "new" drive family CR-562 and CR-563, the reading of audio frames is
possible. This is currently implemented by an IOCTL function which reads only
up to 4 frames of 2352 bytes at once. Reading more than 1 frame at once gives
very poor quality. Reading the same frame a second time gives different data;
it seems that the drive is out-of-sync at the beginning. See the program
example below. This lack has to get corrected by higher level software.
up to 4 frames of 2352 bytes at once. Reading more than 1 frame at once misses
some chunks at each frame boundary. Reading the same frame a second time gives
different data; the frame data start at a different position. But all read
bytes are valid, and we always read 98 consecutive chunks (of 24 Bytes) as a
frame. This lack has to get corrected by higher level software which reads the
same frame again and tries to find and eliminate overlapping chunks
(24-byte-pieces).
The transfer rate with reading audio (1-frame-pieces) is as slow as 32 kB/sec.
This could be better reading bigger chunks, but the out-of-sync parts occur at
This could be better reading bigger chunks, but the "missing" chunks occur at
the beginning of each single frame.
The software interface possibly may change a bit the day the SCSI driver
supports it too.
......@@ -234,15 +238,20 @@ The following little program will copy track 2 of an audio CD into the file
* (c) 1994 Eberhard Moenkeberg <emoenke@gwdg.de>
* may be used & enhanced freely
*
* Due to non-existent sync bytes at the beginning of each audio frame,
* it is currently a kind of fortune if two consecutive frames fit together.
* Usually, they overlap, or a little piece is missing. This has to get
* fixed by higher-level software (reading until an overlap occurs, and then
* eliminate the overlapping bytes). Possibly the first read bytes of each
* frame must get discarded because they are read before we got synchronized.
*
* Due to non-existent sync bytes at the beginning of each audio frame (or due
* to a firmware bug within all known drives?), it is currently a kind of
* fortune if two consecutive frames fit together.
* Usually, they overlap, or a little piece is missing. This happens in units
* of 24-byte chunks. It has to get fixed by higher-level software (reading
* until an overlap occurs, and then eliminate the overlapping chunks).
* ftp.gwdg.de:/pub/linux/misc/cdda2wav-sbpcd.*.tar.gz holds an example of
* such an algorithm.
* This example program further is missing to obtain the SubChannel data
* which belong to each frame.
*
* This is only an example of the low-level access routine. The read data are
* pure 16-bit CDDA values; they have to get converted to make sound out of
* them.
*/
#include <stdio.h>
#include <sys/ioctl.h>
......@@ -283,9 +292,10 @@ main(int argc, char *argv[])
* get and display all TocEntries
*/
fprintf(stdout, "getting TocEntries...\n");
for (i=1;i<=hdr.cdth_trk1;i++)
for (i=1;i<=hdr.cdth_trk1+1;i++)
{
entry[i].cdte_track = i;
if (i!=hdr.cdth_trk1+1) entry[i].cdte_track = i;
else entry[i].cdte_track = CDROM_LEADOUT;
entry[i].cdte_format = CDROM_LBA;
err=ioctl(drive, CDROMREADTOCENTRY, &entry[i]);
if (err!=0)
......@@ -323,7 +333,7 @@ entry[track+1].cdte_addr.lba=190;
exit (-1);
}
arg.addr.lba=entry[track].cdte_addr.lba;
arg.addr_format=CDROM_LBA; /* CDROM_MSF is still buggy, I know that */
arg.addr_format=CDROM_LBA; /* CDROM_MSF would be possible here, too. */
arg.nframes=1;
arg.buf=&buffer[0];
limit=entry[track+1].cdte_addr.lba;
......@@ -347,7 +357,7 @@ entry[track+1].cdte_addr.lba=190;
}
/*===================== end program ========================================*/
At ftp.gwdg.de:/pub/linux/misc/cdda2wav-sbpcd.tar.gz is an adapted version of
At ftp.gwdg.de:/pub/linux/misc/cdda2wav-sbpcd.*.tar.gz is an adapted version of
Heiko Eissfeldt's digital-audio to .WAV converter (the original is there, too).
This is preliminary, as Heiko himself will care about it.
......@@ -355,11 +365,7 @@ This is preliminary, as Heiko himself will care about it.
Known problems:
---------------
Currently, the detection of disk change or removal does not work as good as it
should.
The "door (un)lock" commands get done at every "(u)mount" (only the "new"
drives support it), but after an unlock, locking again does not work properly.
Currently, the detection of disk change or removal is actively disabled.
All attempts to read the UPC/EAN code result in a stream of zeroes. All my
drives are telling there is no UPC/EAN code on disk or there is, but it is an
......
......@@ -304,6 +304,7 @@ static void end_request(int uptodate)
CURRENT = req->next;
if ((p = req->waiting) != NULL) {
req->waiting = NULL;
p->swapping = 0;
p->state = TASK_RUNNING;
if (p->counter > current->counter)
need_resched = 1;
......
......@@ -184,8 +184,11 @@ static void hd_out(unsigned int drive,unsigned int nsect,unsigned int sect,
{
unsigned short port;
if (drive>1 || head>15)
panic("Trying to write bad sector");
if (drive>1 || head>15) {
printk("bad drive mapping, trying to access drive=%d, cyl=%d, head=%d, sect=%d\n",
drive, cyl, head, sect);
panic("harddisk driver problem");
}
#if (HD_DELAY > 0)
while (read_timer() - last_req < HD_DELAY)
/* nothing */;
......
......@@ -327,8 +327,12 @@ void ll_rw_page(int rw, int dev, int page, char * buffer)
req->waiting = current;
req->bh = NULL;
req->next = NULL;
current->swapping = 1;
current->state = TASK_SWAPPING;
add_request(major+blk_dev,req);
/* The I/O may have inadvertently chagned the task state.
Make sure we really wait until the I/O is done */
if (current->swapping) current->state = TASK_SWAPPING;
schedule();
}
......@@ -462,8 +466,12 @@ void ll_rw_swap_file(int rw, int dev, unsigned int *b, int nb, char *buf)
req->waiting = current;
req->bh = NULL;
req->next = NULL;
current->swapping = 1;
current->state = TASK_UNINTERRUPTIBLE;
add_request(major+blk_dev,req);
/* The I/O may have inadvertently chagned the task state.
Make sure we really wait until the I/O is done */
if (current->swapping) current->state = TASK_UNINTERRUPTIBLE;
schedule();
}
}
......
......@@ -5,7 +5,7 @@
* and for "no-sound" interfaces like Lasermate and the
* Panasonic CI-101P.
*
* NOTE: This is release 2.2.
* NOTE: This is release 2.3.
* It works with my SbPro & drive CR-521 V2.11 from 2/92
* and with the new CR-562-B V0.75 on a "naked" Panasonic
* CI-101P interface. And vice versa.
......@@ -108,10 +108,14 @@
*
* 2.1 Found bug with multisession CDs (accessing frame 16).
* "read audio" works now with address type CDROM_MSF, too.
* Bigger audio frame buffer: allows reading max. 4 frames at time; but
* reading more than one frame at once gives poor quality.
* Bigger audio frame buffer: allows reading max. 4 frames at time; this
* gives a significant speedup, but reading more than one frame at once
* gives missing chunks at each single frame boundary.
*
* 2.2
* 2.2 Kernel interface cleanups: timers, init, setup, media check.
*
* 2.3 Let "door lock" and "eject" live together.
* Implemented "close tray" (done automatically during open).
*
* TODO
*
......@@ -188,7 +192,7 @@
#include "blk.h"
#define VERSION "2.2 Eberhard Moenkeberg <emoenke@gwdg.de>"
#define VERSION "2.3 Eberhard Moenkeberg <emoenke@gwdg.de>"
#define SBPCD_DEBUG
......@@ -224,22 +228,18 @@
*/
#if !(SBPCD_ISSUE-1)
#define DO_SBPCD_REQUEST(a) do_sbpcd_request(a)
#define SBPCD_SETUP(a,b) sbpcd_setup(a,b)
#define SBPCD_INIT(a,b) sbpcd_init(a,b)
#endif
#if !(SBPCD_ISSUE-2)
#define DO_SBPCD_REQUEST(a) do_sbpcd2_request(a)
#define SBPCD_SETUP(a,b) sbpcd2_setup(a,b)
#define SBPCD_INIT(a,b) sbpcd2_init(a,b)
#endif
#if !(SBPCD_ISSUE-3)
#define DO_SBPCD_REQUEST(a) do_sbpcd3_request(a)
#define SBPCD_SETUP(a,b) sbpcd3_setup(a,b)
#define SBPCD_INIT(a,b) sbpcd3_init(a,b)
#endif
#if !(SBPCD_ISSUE-4)
#define DO_SBPCD_REQUEST(a) do_sbpcd4_request(a)
#define SBPCD_SETUP(a,b) sbpcd4_setup(a,b)
#define SBPCD_INIT(a,b) sbpcd4_init(a,b)
#endif
/*==========================================================================*/
......@@ -1269,9 +1269,14 @@ static int DriveReset(void)
if (!st_caddy_in) break;
}
while (!st_diskok);
#if 000
DriveStruct[d].CD_changed=1;
i=DiskInfo();
if (i<0) return (-2);
#endif
if ((st_door_closed) && (st_caddy_in))
{
i=DiskInfo();
if (i<0) return (-2);
}
return (0);
}
/*==========================================================================*/
......@@ -1311,6 +1316,21 @@ static int yy_LockDoor(char lock)
return (i);
}
/*==========================================================================*/
static int yy_CloseTray(void)
{
int i;
if (!new_drive) return (0);
DPRINTF((DBG_LCK,"SBPCD: yy_CloseTray (drive %d)\n", d));
clr_cmdbuf();
drvcmd[0]=0x07;
flags_cmd_out=f_putcmd|f_respo2|f_ResponseStatus|f_obey_p_check;
response_count=0;
i=cmd_out();
return (i);
}
/*==========================================================================*/
static int xx_ReadSubQ(void)
{
int i,j;
......@@ -1608,10 +1628,12 @@ static int xx_ReadTocEntry(int num)
DriveStruct[d].TocEnt_format=infobuf[3];
if (new_drive) i=4;
else i=5;
DriveStruct[d].TocEnt_address=make32(make16(0,infobuf[i]),make16(infobuf[i+1],infobuf[i+2]));
DriveStruct[d].TocEnt_address=make32(make16(0,infobuf[i]),
make16(infobuf[i+1],infobuf[i+2]));
DPRINTF((DBG_TOC,"SBPCD: TocEntry: %02X %02X %02X %02X %08X\n",
DriveStruct[d].TocEnt_nixbyte,DriveStruct[d].TocEnt_ctl_adr,DriveStruct[d].TocEnt_number,
DriveStruct[d].TocEnt_format,DriveStruct[d].TocEnt_address));
DriveStruct[d].TocEnt_nixbyte, DriveStruct[d].TocEnt_ctl_adr,
DriveStruct[d].TocEnt_number, DriveStruct[d].TocEnt_format,
DriveStruct[d].TocEnt_address));
return (0);
}
/*==========================================================================*/
......@@ -2527,7 +2549,11 @@ static int sbpcd_ioctl(struct inode *inode, struct file *file, u_int cmd,
DriveStruct[d].CD_changed=0xFF;
DriveStruct[d].diskstate_flags=0;
#endif WORKMAN
do i=yy_LockDoor(0);
while (i!=0);
DriveStruct[d].open_count=0; /* to get it locked next time again */
i=yy_SpinDown();
DPRINTF((DBG_IOX,"SBPCD: ioctl: yy_SpinDown returned %d.\n", i));
if (i<0) return (-EIO);
DriveStruct[d].audio_state=0;
return (0);
......@@ -3193,6 +3219,10 @@ static int sbpcd_open(struct inode *ip, struct file *fp)
}
switch_drive(i);
flags_cmd_out |= f_respo2;
xx_ReadStatus(); /* command: give 1-byte status */
i=ResponseStatus();
if (!st_door_closed) yy_CloseTray();
if (!st_spinning) xx_SpinUp();
flags_cmd_out |= f_respo2;
......@@ -3207,7 +3237,7 @@ static int sbpcd_open(struct inode *ip, struct file *fp)
if (!st_door_closed||!st_caddy_in)
{
printk("SBPCD: sbpcd_open: no disk in drive\n");
return (-EIO);
return (-ENXIO);
}
/*
......@@ -3245,7 +3275,7 @@ static void sbpcd_release(struct inode * ip, struct file * file)
switch_drive(i);
DriveStruct[d].sbp_first_frame=DriveStruct[d].sbp_last_frame=-1;
fsync_dev(ip->i_rdev); /* nonsense if read only device? */
sync_dev(ip->i_rdev); /* nonsense if read only device? */
invalidate_buffers(ip->i_rdev);
DriveStruct[d].diskstate_flags &= ~cd_size_bit;
......@@ -3254,11 +3284,14 @@ static void sbpcd_release(struct inode * ip, struct file * file)
*/
DPRINTF((DBG_LCK,"SBPCD: open_count: %d -> %d\n",
DriveStruct[d].open_count,DriveStruct[d].open_count-1));
if (--DriveStruct[d].open_count==0)
if (DriveStruct[d].open_count!=0) /* CDROMEJECT may have been done */
{
do
i=yy_LockDoor(0);
while (i!=0);
if (--DriveStruct[d].open_count==0)
{
do
i=yy_LockDoor(0);
while (i!=0);
}
}
}
/*==========================================================================*/
......@@ -3305,7 +3338,7 @@ static struct file_operations sbpcd_fops =
#if (SBPCD_ISSUE-1)
static
#endif
void SBPCD_SETUP(char *s, int *p)
void sbpcd_setup(char *s, int *p)
{
DPRINTF((DBG_INI,"SBPCD: sbpcd_setup called with %04X,%s\n",p[1], s));
sbpro_type=0;
......@@ -3422,7 +3455,7 @@ unsigned long SBPCD_INIT(u_long mem_start, u_long mem_end)
if (autoprobe[port_index+1]==0) type=str_lm;
else if (autoprobe[port_index+1]==1) type=str_sb;
else type=str_sp;
SBPCD_SETUP(type, addr);
sbpcd_setup(type, addr);
DPRINTF((DBG_INF,"SBPCD: Trying to detect a %s CD-ROM drive at 0x%X.\n",
type, CDo_command));
......
/* ac3200.c: A driver for the Ansel Communications EISA ethernet adaptor. */
/*
Written 1993, 1994 by Donald Becker.
Copyright 1993 United States Government as represented by the Director,
National Security Agency. This software may only be used and distributed
according to the terms of the GNU Public License as modified by SRC,
incorporated herein by reference.
The author may be reached as becker@cesdis.gsfc.nasa.gov, or
C/O Supercomputing Research Ctr., 17100 Science Dr., Bowie MD 20715
This is driver for the Ansel Communications Model 3200 EISA Ethernet LAN
Adapter. The programming information is from the users manual, as related
by glee@ardnassak.math.clemson.edu.
*/
static char *version =
"ac3200.c:v0.03 2/6/94 Donald Becker (becker@super.org)\n";
#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/string.h>
#include <asm/system.h>
#include <asm/io.h>
#include <linux/netdevice.h>
#include "8390.h"
/* Offsets from the base address. */
#define AC_NIC_BASE 0x00
#define AC_SA_PROM 0x16 /* The station address PROM. */
#define AC_ADDR0 0x00 /* Prefix station address values. */
#define AC_ADDR1 0x40 /* !!!!These are just guesses!!!! */
#define AC_ADDR2 0x90
#define AC_ID_PORT 0xC80
#define AC_EISA_ID 0x0110d305
#define AC_RESET_PORT 0xC84
#define AC_RESET 0x00
#define AC_ENABLE 0x01
#define AC_CONFIG 0xC90 /* The configuration port. */
/* Decoding of the configuration register. */
static unsigned char config2irqmap[8] = {15, 12, 11, 10, 9, 7, 5, 3};
static int addrmap[8] =
{0xFF0000, 0xFE0000, 0xFD0000, 0xFFF0000, 0xFFE0000, 0xFFC0000, 0xD0000, 0 };
static char *port_name[4] = { "10baseT", "invalid", "AUI", "10base2"};
#define config2irq(configval) config2irqmap[((configval) >> 3) & 7]
#define config2mem(configval) addrmap[(configval) & 7]
#define config2name(configval) port_name[((configval) >> 6) & 3]
/* First and last 8390 pages. */
#define AC_START_PG 0x00 /* First page of 8390 TX buffer */
#define AC_STOP_PG 0x80 /* Last page +1 of the 8390 RX ring */
int ac3200_probe(struct device *dev);
static int ac_probe1(int ioaddr, struct device *dev);
static int ac_open(struct device *dev);
static void ac_reset_8390(struct device *dev);
static int ac_block_input(struct device *dev, int count,
char *buf, int ring_offset);
static void ac_block_output(struct device *dev, const int count,
const unsigned char *buf, const int start_page);
static int ac_close_card(struct device *dev);
/* Probe for the AC3200.
The AC3200 can be identified by either the EISA configuration registers,
or the unique value in the station address PROM.
*/
int ac3200_probe(struct device *dev)
{
unsigned short ioaddr = dev->base_addr;
if (ioaddr > 0x1ff) /* Check a single specified location. */
return ac_probe1(ioaddr, dev);
else if (ioaddr > 0) /* Don't probe at all. */
return ENXIO;
/* If you have a pre-pl15 machine you should delete this line. */
if ( ! EISA_bus)
return ENXIO;
for (ioaddr = 0x1000; ioaddr < 0x9000; ioaddr += 0x1000)
if (ac_probe1(ioaddr, dev) == 0)
return 0;
return ENODEV;
}
static int ac_probe1(int ioaddr, struct device *dev)
{
int i;
#ifndef final_version
printk("AC3200 ethercard probe at %#3x:", ioaddr);
for(i = 0; i < 6; i++)
printk(" %02x", inb(ioaddr + AC_SA_PROM + i));
#endif
/* !!!!The values of AC_ADDRn (see above) should be corrected when we
find out the correct station address prefix!!!! */
if (inb(ioaddr + AC_SA_PROM + 0) != AC_ADDR0
|| inb(ioaddr + AC_SA_PROM + 1) != AC_ADDR1
|| inb(ioaddr + AC_SA_PROM + 2) != AC_ADDR2 ) {
#ifndef final_version
printk(" not found (invalid prefix).\n");
#endif
return ENODEV;
}
/* The correct probe method is to check the EISA ID. */
for (i = 0; i < 4; i++)
if (inl(ioaddr + AC_ID_PORT) != AC_EISA_ID) {
printk("EISA ID mismatch, %8x vs %8x.\n",
inl(ioaddr + AC_EISA_ID), AC_EISA_ID);
return ENODEV;
}
for(i = 0; i < ETHER_ADDR_LEN; i++)
dev->dev_addr[i] = inb(ioaddr + AC_SA_PROM + i);
#ifndef final_version
printk("\nAC3200 ethercard configuration register is %#02x,"
" EISA ID %02x %02x %02x %02x.\n", inb(ioaddr + AC_CONFIG),
inb(ioaddr + AC_ID_PORT + 0), inb(ioaddr + AC_ID_PORT + 1),
inb(ioaddr + AC_ID_PORT + 2), inb(ioaddr + AC_ID_PORT + 3));
#endif
/* Assign and snarf the interrupt now. */
if (dev->irq == 0)
dev->irq = config2irq(inb(ioaddr + AC_CONFIG));
else if (dev->irq == 2)
dev->irq = 9;
if (irqaction (dev->irq, &ei_sigaction)) {
printk (" unable to get IRQ %d.\n", dev->irq);
return 0;
}
dev->base_addr = ioaddr;
#ifdef notyet
if (dev->mem_start) { /* Override the value from the board. */
for (i = 0; i < 7; i++)
if (addrmap[i] == dev->mem_start)
break;
if (i >= 7)
i = 0;
outb((inb(ioaddr + AC_CONFIG) & ~7) | i, ioaddr + AC_CONFIG);
}
#endif
dev->if_port = inb(ioaddr + AC_CONFIG) >> 6;
dev->mem_start = config2mem(inb(ioaddr + AC_CONFIG));
dev->rmem_start = dev->mem_start + TX_PAGES*256;
dev->mem_end = dev->rmem_end = dev->mem_start
+ (AC_STOP_PG - AC_START_PG)*256;
ethdev_init(dev);
ei_status.name = "AC3200";
ei_status.tx_start_page = AC_START_PG;
ei_status.rx_start_page = AC_START_PG + TX_PAGES;
ei_status.stop_page = AC_STOP_PG;
ei_status.word16 = 1;
printk("\n%s: AC3200 at %#x, IRQ %d, %s port, shared memory at %#x-%#x.\n",
dev->name, ioaddr, dev->irq, port_name[dev->if_port],
dev->mem_start, dev->mem_end-1);
if (ei_debug > 0)
printk(version);
ei_status.reset_8390 = &ac_reset_8390;
ei_status.block_input = &ac_block_input;
ei_status.block_output = &ac_block_output;
dev->open = &ac_open;
dev->stop = &ac_close_card;
NS8390_init(dev, 0);
return 0;
}
static int ac_open(struct device *dev)
{
#ifdef notyet
/* Someday we may enable the IRQ and shared memory here. */
int ioaddr = dev->base_addr;
if (irqaction(dev->irq, &ei_sigaction))
return -EAGAIN;
#endif
return ei_open(dev);
}
static void ac_reset_8390(struct device *dev)
{
ushort ioaddr = dev->base_addr;
outb(AC_RESET, ioaddr + AC_RESET_PORT);
if (ei_debug > 1) printk("resetting AC3200, t=%d...", jiffies);
ei_status.txing = 0;
outb(AC_ENABLE, ioaddr + AC_RESET_PORT);
if (ei_debug > 1) printk("reset done\n");
return;
}
/* Block input and output are easy on shared memory ethercards, the only
complication is when the ring buffer wraps. */
static int ac_block_input(struct device *dev, int count, char *buf,
int ring_offset)
{
long xfer_start = dev->mem_start + ring_offset - (AC_START_PG<<8);
if (xfer_start + count > dev->rmem_end) {
/* We must wrap the input move. */
int semi_count = dev->rmem_end - xfer_start;
memcpy(buf, (char*)xfer_start, semi_count);
count -= semi_count;
memcpy(buf + semi_count, (char *)dev->rmem_start, count);
return dev->rmem_start + count;
}
memcpy(buf, (char*)xfer_start, count);
return ring_offset + count;
}
static void ac_block_output(struct device *dev, int count,
const unsigned char *buf, int start_page)
{
long shmem = dev->mem_start + ((start_page - AC_START_PG)<<8);
memcpy((unsigned char *)shmem, buf, count);
}
static int ac_close_card(struct device *dev)
{
dev->start = 0;
dev->tbusy = 1;
if (ei_debug > 1)
printk("%s: Shutting down ethercard.\n", dev->name);
#ifdef notyet
/* We should someday disable shared memory and interrupts. */
outb(0x00, ioaddr + 6); /* Disable interrupts. */
free_irq(dev->irq);
irq2dev_map[dev->irq] = 0;
#endif
NS8390_init(dev, 0);
return 0;
}
/*
* Local variables:
* compile-command: "gcc -D__KERNEL__ -I/usr/src/linux/net/inet -Wall -Wstrict-prototypes -O6 -m486 -c ac3200.c"
* version-control: t
* kept-new-versions: 5
* tab-width: 4
* End:
*/
/* znet.c: An Zenith Z-Note ethernet driver for linux. */
static char *version = "znet.c:v0.04 5/10/94 becker@cesdis.gsfc.nasa.gov\n";
/*
Written by Donald Becker.
The author may be reached as becker@cesdis.gsfc.nasa.gov.
This driver is based on the Linux skeleton driver. The copyright of the
skeleton driver is held by the United States Government, as represented
by DIRNSA, and it is released under the GPL.
Thanks to Mike Hollick for alpha testing and suggestions.
References:
The Crynwr packet driver.
"82593 CSMA/CD Core LAN Controller" Intel datasheet, 1992
Intel Microcommunications Databook, Vol. 1, 1990.
As usual with Intel, the documentation is incomplete and inaccurate.
I had to read the Crynwr packet driver to figure out how to actually
use the i82593, and guess at what register bits matched the loosely
related i82586.
Theory of Operation
The i82593 used in the Zenith Z-Note series operates using two(!) slave
DMA channels, one interrupt, and one 8-bit I/O port.
While there several ways to configure '593 DMA system, I chose the one
that seemed commesurate with the highest system performance in the face
of moderate interrupt latency: Both DMA channels are configued as
recirculating ring buffers, with one channel (#0) dedicated to Rx and
the other channel (#1) to Tx and configuration. (Note that this is
different than the Crynwr driver, where the Tx DMA channel is initialized
before each operation. That approach simplifies operation and Tx error
recovery, but requires additional I/O in normal operation and precludes
transmit buffer chaining.)
Both rings are set to 8192 bytes using {TX,RX}_RING_SIZE. This provides
a reasonable ring size for Rx, while simplifying DMA buffer allocation --
DMA buffers must not cross a 128K boundary. (In truth the size selection
was influenced by my lack of '593 documentation. I thus was constrained
to use the Crynwr '593 initialization table, which sets the Rx ring size
to 8K.)
Despite my usual low opinion about Intel-designed parts, I must admit
that the bulk data handling of the i82593 is a good design for
an integrated system, like a laptop, where using two slave DMA channels
doesn't pose a problem. I still take issue with using only a single I/O
port. In the same controlled environment there are essentially no
limitations on I/O space, and using multiple locations would eliminate
the need for multiple operations when looking at status registers,
setting the Rx ring boundary, or switching to promiscuous mode.
I also question Zenith's selection of the '593: one of the advertised
advantages of earlier Intel parts was that if you figured out the magic
initialization incantation you could use the same part on many different
network types. Zenith's use of the "FriendlyNet" (sic) connector rather
than an on-board transceiver leads me to believe that they were planning
to take advantage of this. But, uhmmm, the '593 omits all but ethernet
functionality from the serial subsystem.
*/
#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/string.h>
#include <linux/ptrace.h>
#include <linux/errno.h>
#include <linux/interrupt.h>
#include <asm/system.h>
#include <asm/bitops.h>
#include <asm/io.h>
#include <asm/dma.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include <linux/if_arp.h>
#ifndef HAVE_AUTOIRQ
/* From auto_irq.c, in ioport.h for later versions. */
extern void autoirq_setup(int waittime);
extern int autoirq_report(int waittime);
/* The map from IRQ number (as passed to the interrupt handler) to
'struct device'. */
extern struct device *irq2dev_map[16];
#endif
#ifndef HAVE_ALLOC_SKB
#define alloc_skb(size, priority) (struct sk_buff *) kmalloc(size,priority)
#define kfree_skbmem(addr, size) kfree_s(addr,size);
#endif
#ifndef ZNET_DEBUG
#define ZNET_DEBUG 3
#endif
static unsigned int znet_debug = ZNET_DEBUG;
/* The DMA modes we need aren't in <dma.h>. */
#define DMA_RX_MODE 0x14 /* Auto init, I/O to mem, ++, demand. */
#define DMA_TX_MODE 0x18 /* Auto init, Mem to I/O, ++, demand. */
#define dma_page_eq(ptr1, ptr2) ((long)(ptr1)>>17 == (long)(ptr2)>>17)
#define DMA_BUF_SIZE 8192
#define RX_BUF_SIZE 8192
#define TX_BUF_SIZE 8192
/* Commands to the i82593 channel 0. */
#define CMD0_CHNL_0 0x00
#define CMD0_CHNL_1 0x10 /* Switch to channel 1. */
#define CMD0_NOP (CMD0_CHNL_0)
#define CMD0_PORT_1 CMD0_CHNL_1
#define CMD1_PORT_0 1
#define CMD0_IA_SETUP 1
#define CMD0_CONFIGURE 2
#define CMD0_MULTICAST_LIST 3
#define CMD0_TRANSMIT 4
#define CMD0_DUMP 6
#define CMD0_DIAGNOSE 7
#define CMD0_Rx_ENABLE 8
#define CMD0_Rx_DISABLE 10
#define CMD0_Rx_STOP 11
#define CMD0_RETRANSMIT 12
#define CMD0_ABORT 13
#define CMD0_RESET 14
#define CMD0_ACK 0x80
#define CMD0_STAT0 (0 << 5)
#define CMD0_STAT1 (1 << 5)
#define CMD0_STAT2 (2 << 5)
#define CMD0_STAT3 (3 << 5)
#define net_local znet_private
struct znet_private {
int rx_dma, tx_dma;
struct enet_statistics stats;
/* The starting, current, and end pointers for the packet buffers. */
ushort *rx_start, *rx_cur, *rx_end;
ushort *tx_start, *tx_cur, *tx_end;
ushort tx_buf_len; /* Tx buffer lenght, in words. */
};
/* Only one can be built-in;-> */
static struct znet_private zn;
static ushort dma_buffer1[DMA_BUF_SIZE/2];
static ushort dma_buffer2[DMA_BUF_SIZE/2];
static ushort dma_buffer3[DMA_BUF_SIZE/2 + 8];
/* The configuration block. What an undocumented nightmare. The first
set of values are those suggested (without explaination) for ethernet
in the Intel 82586 databook. The rest appear to be completely undocumented,
except for cryptic notes in the Crynwr packet driver. This driver uses
the Crynwr values verbatim. */
static unsigned char i593_init[] = {
0xAA, /* 0: 16-byte input & 80-byte output FIFO. */
/* threshhold, 96-byte FIFO, 82593 mode. */
0x88, /* 1: Continuous w/interrupts, 128-clock DMA.*/
0x2E, /* 2: 8-byte preamble, NO address insertion, */
/* 6-byte Ethernet address, loopback off.*/
0x00, /* 3: Default priorities & backoff methods. */
0x60, /* 4: 96-bit interframe spacing. */
0x00, /* 5: 512-bit slot time (low-order). */
0xF2, /* 6: Slot time (high-order), 15 COLL retries. */
0x00, /* 7: Promisc-off, broadcast-on, default CRC. */
0x00, /* 8: Default carrier-sense, collision-detect. */
0x40, /* 9: 64-byte minimum frame length. */
0x5F, /* A: Type/length checks OFF, no CRC input,
"jabber" termination, etc. */
0x00, /* B: Full-duplex disabled. */
0x3F, /* C: Default multicast addresses & backoff. */
0x07, /* D: Default IFS retriggering. */
0x31, /* E: Internal retransmit, drop "runt" packets,
synchr. DRQ deassertion, 6 status bytes. */
0x22, /* F: Receive ring-buffer size (8K),
receive-stop register enable. */
};
struct netidblk {
char magic[8]; /* The magic number (string) "NETIDBLK" */
unsigned char netid[8]; /* The physical station address */
char nettype, globalopt;
char vendor[8]; /* The machine vendor and product name. */
char product[8];
char irq1, irq2; /* Interrupts, only one is currently used. */
char dma1, dma2;
short dma_mem_misc[8]; /* DMA buffer locations (unused in Linux). */
short iobase1, iosize1;
short iobase2, iosize2; /* Second iobase unused. */
char driver_options; /* Misc. bits */
char pad;
};
int znet_probe(struct device *dev);
static int znet_open(struct device *dev);
static int znet_send_packet(struct sk_buff *skb, struct device *dev);
static void znet_interrupt(int reg_ptr);
static void znet_rx(struct device *dev);
static int znet_close(struct device *dev);
static struct enet_statistics *net_get_stats(struct device *dev);
static void set_multicast_list(struct device *dev, int num_addrs, void *addrs);
static void hardware_init(struct device *dev);
static int do_command(short ioaddr, int command, int length, ushort *buffer);
static int wait_for_done(short ioaddr);
static void update_stop_hit(short ioaddr, unsigned short rx_stop_offset);
#ifdef notdef
static struct sigaction znet_sigaction = { &znet_interrupt, 0, 0, NULL, };
#endif
/* The Z-Note probe is pretty easy. The NETIDBLK exists in the safe-to-probe
BIOS area. We just scan for the signature, and pull the vital parameters
out of the structure. */
int znet_probe(struct device *dev)
{
int i;
struct netidblk *netinfo;
char *p;
/* This code scans the region 0xf0000 to 0xfffff for a "NETIDBLK". */
for(p = (char *)0xf0000; p < (char *)0x100000; p++)
if (*p == 'N' && strncmp(p, "NETIDBLK", 8) == 0)
break;
if (p >= (char *)0x100000) {
if (znet_debug > 1)
printk("No Z-Note ethernet adaptor found.\n");
return ENODEV;
}
netinfo = (struct netidblk *)p;
dev->base_addr = netinfo->iobase1;
dev->irq = netinfo->irq1;
printk("%s: ZNET at %#3x,", dev->name, dev->base_addr);
/* The station address is in the "netidblk" at 0x0f0000. */
for (i = 0; i < 6; i++)
printk(" %2.2x", dev->dev_addr[i] = netinfo->netid[i]);
printk(", using IRQ %d DMA %d and %d.\n", dev->irq, netinfo->dma1,
netinfo->dma2);
if (znet_debug > 1) {
printk("%s: vendor '%16.16s' IRQ1 %d IRQ2 %d DMA1 %d DMA2 %d.\n",
dev->name, netinfo->vendor,
netinfo->irq1, netinfo->irq2,
netinfo->dma1, netinfo->dma2);
printk("%s: iobase1 %#x size %d iobase2 %#x size %d net type %2.2x.\n",
dev->name, netinfo->iobase1, netinfo->iosize1,
netinfo->iobase2, netinfo->iosize2, netinfo->nettype);
}
if (znet_debug > 0)
printk(version);
dev->priv = (void *) &zn;
zn.rx_dma = netinfo->dma1;
zn.tx_dma = netinfo->dma2;
/* These should never fail. You can't add devices to a sealed box! */
if (request_irq(dev->irq, &znet_interrupt)
|| request_dma(zn.rx_dma)
|| request_dma(zn.tx_dma)) {
printk("Not opened -- resource busy?!?\n");
return EBUSY;
}
irq2dev_map[dev->irq] = dev;
/* Allocate buffer memory. We can cross a 128K boundary, so we
must be careful about the allocation. It's easiest to waste 8K. */
if (dma_page_eq(dma_buffer1, &dma_buffer1[RX_BUF_SIZE/2-1]))
zn.rx_start = dma_buffer1;
else
zn.rx_start = dma_buffer2;
if (dma_page_eq(dma_buffer3, &dma_buffer3[RX_BUF_SIZE/2-1]))
zn.tx_start = dma_buffer3;
else
zn.tx_start = dma_buffer2;
zn.rx_end = zn.rx_start + RX_BUF_SIZE/2;
zn.tx_buf_len = TX_BUF_SIZE/2;
zn.tx_end = zn.tx_start + zn.tx_buf_len;
/* The ZNET-specific entries in the device structure. */
dev->open = &znet_open;
dev->hard_start_xmit = &znet_send_packet;
dev->stop = &znet_close;
dev->get_stats = net_get_stats;
#ifdef HAVE_MULTICAST
dev->set_multicast_list = &set_multicast_list;
#endif
/* Fill in the generic field of the device structure. */
for (i = 0; i < DEV_NUMBUFFS; i++)
dev->buffs[i] = NULL;
dev->hard_header = eth_header;
dev->add_arp = eth_add_arp;
dev->queue_xmit = dev_queue_xmit;
dev->rebuild_header = eth_rebuild_header;
dev->type_trans = eth_type_trans;
dev->type = ARPHRD_ETHER;
dev->hard_header_len = ETH_HLEN;
dev->mtu = 1500; /* eth_mtu */
dev->addr_len = ETH_ALEN;
for (i = 0; i < ETH_ALEN; i++) {
dev->broadcast[i]=0xff;
}
/* New-style flags. */
dev->flags = IFF_BROADCAST;
dev->family = AF_INET;
dev->pa_addr = 0;
dev->pa_brdaddr = 0;
dev->pa_mask = 0;
dev->pa_alen = sizeof(unsigned long);
return 0;
}
static int znet_open(struct device *dev)
{
int ioaddr = dev->base_addr;
if (znet_debug > 2)
printk("%s: znet_open() called.\n", dev->name);
/* Turn on the 82501 SIA, using zenith-specific magic. */
outb(0x10, 0xe6); /* Select LAN control register */
outb(inb(0xe7) | 0x84, 0xe7); /* Turn on LAN power (bit 2). */
/* According to the Crynwr driver we should wait 50 msec. for the
LAN clock to stabilize. My experiments indicates that the '593 can
be initialized immediately. The delay is probably needed for the
DC-to-DC converter to come up to full voltage, and for the oscillator
to be spot-on at 20Mhz before transmitting.
Until this proves to be a problem we rely on the higher layers for the
delay and save allocating a timer entry. */
/* This follows the packet driver's lead, and checks for success. */
if (inb(ioaddr) != 0x10 && inb(ioaddr) != 0x00)
printk("%s: Problem turning on the transceiver power.\n", dev->name);
dev->tbusy = 0;
dev->interrupt = 0;
hardware_init(dev);
dev->start = 1;
return 0;
}
static int znet_send_packet(struct sk_buff *skb, struct device *dev)
{
int ioaddr = dev->base_addr;
if (znet_debug > 4)
printk("%s: ZNet_send_packet(%d).\n", dev->name, dev->tbusy);
/* Transmitter timeout, could be a serious problems. */
if (dev->tbusy) {
ushort event, tx_status, rx_offset, state;
int tickssofar = jiffies - dev->trans_start;
if (tickssofar < 10)
return 1;
outb(CMD0_STAT0, ioaddr); event = inb(ioaddr);
outb(CMD0_STAT1, ioaddr); tx_status = inw(ioaddr);
outb(CMD0_STAT2, ioaddr); rx_offset = inw(ioaddr);
outb(CMD0_STAT3, ioaddr); state = inb(ioaddr);
printk("%s: transmit timed out, status %02x %04x %04x %02x,"
" resetting.\n", dev->name, event, tx_status, rx_offset, state);
if (tx_status == 0x0400)
printk("%s: Tx carrier error, check transceiver cable.\n",
dev->name);
outb(CMD0_RESET, ioaddr);
hardware_init(dev);
}
if (skb == NULL) {
dev_tint(dev);
return 0;
}
/* Fill in the ethernet header. */
if (!skb->arp && dev->rebuild_header(skb+1, dev)) {
skb->dev = dev;
arp_queue (skb);
return 0;
}
/* Check that the part hasn't reset itself, probably from suspend. */
outb(CMD0_STAT0, ioaddr);
if (inw(ioaddr) == 0x0010
&& inw(ioaddr) == 0x0000
&& inw(ioaddr) == 0x0010)
hardware_init(dev);
/* Block a timer-based transmit from overlapping. This could better be
done with atomic_swap(1, dev->tbusy), but set_bit() works as well. */
if (set_bit(0, (void*)&dev->tbusy) != 0)
printk("%s: Transmitter access conflict.\n", dev->name);
else {
short length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
unsigned char *buf = (void *)(skb+1);
ushort *tx_link = zn.tx_cur - 1;
ushort rnd_len = (length + 1)>>1;
{
short dma_port = ((zn.tx_dma&3)<<2) + IO_DMA2_BASE;
unsigned addr = inb(dma_port);
addr |= inb(dma_port) << 8;
addr <<= 1;
if (((int)zn.tx_cur & 0x1ffff) != addr)
printk("Address mismatch at Tx: %#x vs %#x.\n",
(int)zn.tx_cur & 0xffff, addr);
zn.tx_cur = (ushort *)(((int)zn.tx_cur & 0xfe0000) | addr);
}
if (zn.tx_cur >= zn.tx_end)
zn.tx_cur = zn.tx_start;
*zn.tx_cur++ = length;
if (zn.tx_cur + rnd_len + 1 > zn.tx_end) {
int semi_cnt = (zn.tx_end - zn.tx_cur)<<1; /* Cvrt to byte cnt. */
memcpy(zn.tx_cur, buf, semi_cnt);
rnd_len -= semi_cnt>>1;
memcpy(zn.tx_start, buf + semi_cnt, length - semi_cnt);
zn.tx_cur = zn.tx_start + rnd_len;
} else {
memcpy(zn.tx_cur, buf, skb->len);
zn.tx_cur += rnd_len;
}
*zn.tx_cur++ = 0;
cli(); {
*tx_link = CMD0_TRANSMIT + CMD0_CHNL_1;
/* Is this always safe to do? */
outb(CMD0_TRANSMIT + CMD0_CHNL_1,ioaddr);
} sti();
dev->trans_start = jiffies;
if (znet_debug > 4)
printk("%s: Transmitter queued, length %d.\n", dev->name, length);
}
dev_kfree_skb(skb, FREE_WRITE);
return 0;
}
/* The ZNET interrupt handler. */
static void znet_interrupt(int reg_ptr)
{
int irq = -(((struct pt_regs *)reg_ptr)->orig_eax+2);
struct device *dev = irq2dev_map[irq];
int ioaddr;
int boguscnt = 20;
if (dev == NULL) {
printk ("znet_interrupt(): IRQ %d for unknown device.\n", irq);
return;
}
dev->interrupt = 1;
ioaddr = dev->base_addr;
outb(CMD0_STAT0, ioaddr);
do {
ushort status = inb(ioaddr);
if (znet_debug > 5) {
ushort result, rx_ptr, running;
outb(CMD0_STAT1, ioaddr);
result = inw(ioaddr);
outb(CMD0_STAT2, ioaddr);
rx_ptr = inw(ioaddr);
outb(CMD0_STAT3, ioaddr);
running = inb(ioaddr);
printk("%s: interrupt, status %02x, %04x %04x %02x serial %d.\n",
dev->name, status, result, rx_ptr, running, boguscnt);
}
if ((status & 0x80) == 0)
break;
if ((status & 0x0F) == 4) { /* Transmit done. */
struct net_local *lp = (struct net_local *)dev->priv;
int tx_status;
outb(CMD0_STAT1, ioaddr);
tx_status = inw(ioaddr);
/* It's undocumented, but tx_status seems to match the i82586. */
if (tx_status & 0x2000) {
lp->stats.tx_packets++;
lp->stats.collisions += tx_status & 0xf;
} else {
if (tx_status & 0x0600) lp->stats.tx_carrier_errors++;
if (tx_status & 0x0100) lp->stats.tx_fifo_errors++;
if (!(tx_status & 0x0040)) lp->stats.tx_heartbeat_errors++;
if (tx_status & 0x0020) lp->stats.tx_aborted_errors++;
/* ...and the catch-all. */
if (tx_status | 0x0760 != 0x0760)
lp->stats.tx_errors++;
}
dev->tbusy = 0;
mark_bh(INET_BH); /* Inform upper layers. */
}
if ((status & 0x40)
|| (status & 0x0f) == 11) {
znet_rx(dev);
}
/* Clear the interrupts we've handled. */
outb(CMD0_ACK,ioaddr);
} while (boguscnt--);
dev->interrupt = 0;
return;
}
static void znet_rx(struct device *dev)
{
struct net_local *lp = (struct net_local *)dev->priv;
int ioaddr = dev->base_addr;
int boguscount = 1;
short next_frame_end_offset = 0; /* Offset of next frame start. */
short *cur_frame_end;
short cur_frame_end_offset;
outb(CMD0_STAT2, ioaddr);
cur_frame_end_offset = inw(ioaddr);
if (cur_frame_end_offset == zn.rx_cur - zn.rx_start) {
printk("%s: Interrupted, but nothing to receive, offset %03x.\n",
dev->name, cur_frame_end_offset);
return;
}
/* Use same method as the Crynwr driver: construct a forward list in
the same area of the backwards links we now have. This allows us to
pass packets to the upper layers in the order they were received --
important for fast-path sequential operations. */
while (zn.rx_start + cur_frame_end_offset != zn.rx_cur
&& ++boguscount < 5) {
unsigned short hi_cnt, lo_cnt, hi_status, lo_status;
int count, status;
if (cur_frame_end_offset < 4) {
/* Oh no, we have a special case: the frame trailer wraps around
the end of the ring buffer. We've saved space at the end of
the ring buffer for just this problem. */
memcpy(zn.rx_end, zn.rx_start, 8);
cur_frame_end_offset += (RX_BUF_SIZE/2);
}
cur_frame_end = zn.rx_start + cur_frame_end_offset - 4;
lo_status = *cur_frame_end++;
hi_status = *cur_frame_end++;
status = ((hi_status & 0xff) << 8) + (lo_status & 0xff);
lo_cnt = *cur_frame_end++;
hi_cnt = *cur_frame_end++;
count = ((hi_cnt & 0xff) << 8) + (lo_cnt & 0xff);
if (znet_debug > 5)
printk("Constructing trailer at location %03x, %04x %04x %04x %04x"
" count %#x status %04x.\n",
cur_frame_end_offset<<1, lo_status, hi_status, lo_cnt, hi_cnt,
count, status);
cur_frame_end[-4] = status;
cur_frame_end[-3] = next_frame_end_offset;
cur_frame_end[-2] = count;
next_frame_end_offset = cur_frame_end_offset;
cur_frame_end_offset -= ((count + 1)>>1) + 3;
if (cur_frame_end_offset < 0)
cur_frame_end_offset += RX_BUF_SIZE/2;
};
/* Now step forward through the list. */
do {
ushort *this_rfp_ptr = zn.rx_start + next_frame_end_offset;
int status = this_rfp_ptr[-4];
int pkt_len = this_rfp_ptr[-2];
if (znet_debug > 5)
printk("Looking at trailer ending at %04x status %04x length %03x"
" next %04x.\n", next_frame_end_offset<<1, status, pkt_len,
this_rfp_ptr[-3]<<1);
/* Once again we must assume that the i82586 docs apply. */
if ( ! (status & 0x2000)) { /* There was an error. */
lp->stats.rx_errors++;
if (status & 0x0800) lp->stats.rx_crc_errors++;
if (status & 0x0400) lp->stats.rx_frame_errors++;
if (status & 0x0200) lp->stats.rx_over_errors++; /* Wrong. */
if (status & 0x0100) lp->stats.rx_fifo_errors++;
if (status & 0x0080) lp->stats.rx_length_errors++;
} else if (pkt_len > 1536) {
lp->stats.rx_length_errors++;
} else {
/* Malloc up new buffer. */
int sksize = sizeof(struct sk_buff) + pkt_len;
struct sk_buff *skb;
skb = alloc_skb(sksize, GFP_ATOMIC);
if (skb == NULL) {
if (znet_debug)
printk("%s: Memory squeeze, dropping packet.\n", dev->name);
lp->stats.rx_dropped++;
break;
}
skb->mem_len = sksize;
skb->mem_addr = skb;
skb->len = pkt_len;
skb->dev = dev;
if (&zn.rx_cur[(pkt_len+1)>>1] > zn.rx_end) {
int semi_cnt = (zn.rx_end - zn.rx_cur)<<1;
memcpy((unsigned char *) (skb + 1), zn.rx_cur, semi_cnt);
memcpy((unsigned char *) (skb + 1) + semi_cnt, zn.rx_start,
pkt_len - semi_cnt);
} else {
memcpy((unsigned char *) (skb + 1), zn.rx_cur, pkt_len);
if (znet_debug > 6) {
unsigned int *packet = (unsigned int *) (skb + 1);
printk("Packet data is %08x %08x %08x %08x.\n", packet[0],
packet[1], packet[2], packet[3]);
}
}
#ifdef HAVE_NETIF_RX
netif_rx(skb);
#else
skb->lock = 0;
if (dev_rint((unsigned char*)skb, pkt_len, IN_SKBUFF, dev) != 0) {
kfree_s(skb, sksize);
lp->stats.rx_dropped++;
break;
}
#endif
lp->stats.rx_packets++;
}
zn.rx_cur = this_rfp_ptr;
if (zn.rx_cur >= zn.rx_end)
zn.rx_cur -= RX_BUF_SIZE/2;
update_stop_hit(ioaddr, (zn.rx_cur - zn.rx_start)<<1);
next_frame_end_offset = this_rfp_ptr[-3];
if (next_frame_end_offset == 0) /* Read all the frames? */
break; /* Done for now */
this_rfp_ptr = zn.rx_start + next_frame_end_offset;
} while (--boguscount);
/* If any worth-while packets have been received, dev_rint()
has done a mark_bh(INET_BH) for us and will work on them
when we get to the bottom-half routine. */
return;
}
/* The inverse routine to znet_open(). */
static int znet_close(struct device *dev)
{
int ioaddr = dev->base_addr;
dev->tbusy = 1;
dev->start = 0;
outb(CMD0_RESET, ioaddr); /* CMD0_RESET */
disable_dma(zn.rx_dma);
disable_dma(zn.tx_dma);
free_irq(dev->irq);
if (znet_debug > 1)
printk("%s: Shutting down ethercard.\n", dev->name);
/* Turn off transceiver power. */
outb(0x10, 0xe6); /* Select LAN control register */
outb(inb(0xe7) & ~0x84, 0xe7); /* Turn on LAN power (bit 2). */
return 0;
}
/* Get the current statistics. This may be called with the card open or
closed. */
static struct enet_statistics *net_get_stats(struct device *dev)
{
struct net_local *lp = (struct net_local *)dev->priv;
return &lp->stats;
}
#ifdef HAVE_MULTICAST
/* Set or clear the multicast filter for this adaptor.
num_addrs == -1 Promiscuous mode, receive all packets
num_addrs == 0 Normal mode, clear multicast list
num_addrs > 0 Multicast mode, receive normal and MC packets, and do
best-effort filtering.
As a side effect this routine must also initialize the device parameters.
This is taken advantage of in open().
N.B. that we change i593_init[] in place. This (properly) makes the
mode change persistent, but must be changed if this code is moved to
a multiple adaptor environment.
*/
static void set_multicast_list(struct device *dev, int num_addrs, void *addrs)
{
short ioaddr = dev->base_addr;
if (num_addrs < 0) {
/* Enable promiscuous mode */
i593_init[7] &= ~3; i593_init[7] |= 1;
i593_init[13] &= ~8; i593_init[13] |= 8;
} else if (num_addrs > 0) {
/* Enable accept-all-multicast mode */
i593_init[7] &= ~3; i593_init[7] |= 0;
i593_init[13] &= ~8; i593_init[13] |= 8;
} else { /* Enable normal mode. */
i593_init[7] &= ~3; i593_init[7] |= 0;
i593_init[13] &= ~8; i593_init[13] |= 0;
}
*zn.tx_cur++ = sizeof(i593_init);
memcpy(zn.tx_cur, i593_init, sizeof(i593_init));
zn.tx_cur += sizeof(i593_init)/2;
outb(CMD0_CONFIGURE+CMD0_CHNL_1, ioaddr);
#ifdef not_tested
if (num_addrs > 0) {
int addrs_len = 6*num_addrs;
*zn.tx_cur++ = addrs_len;
memcpy(zn.tx_cur, addrs, addrs_len);
outb(CMD0_MULTICAST_LIST+CMD0_CHNL_1, ioaddr);
zn.tx_cur += addrs_len>>1;
}
#endif
}
#endif
void show_dma(void)
{
short dma_port = ((zn.tx_dma&3)<<2) + IO_DMA2_BASE;
unsigned addr = inb(dma_port);
addr |= inb(dma_port) << 8;
printk("Addr: %04x cnt:%3x...", addr<<1,
get_dma_residue(zn.tx_dma));
}
/* Initialize the hardware. We have to do this when the board is open()ed
or when we come out of suspend mode. */
static void hardware_init(struct device *dev)
{
short ioaddr = dev->base_addr;
zn.rx_cur = zn.rx_start;
zn.tx_cur = zn.tx_start;
/* Reset the chip, and start it up. */
outb(CMD0_RESET, ioaddr);
cli(); { /* Protect against a DMA flip-flop */
disable_dma(zn.rx_dma); /* reset by an interrupting task. */
clear_dma_ff(zn.rx_dma);
set_dma_mode(zn.rx_dma, DMA_RX_MODE);
set_dma_addr(zn.rx_dma, (unsigned int) zn.rx_start);
set_dma_count(zn.rx_dma, RX_BUF_SIZE);
enable_dma(zn.rx_dma);
/* Now set up the Tx channel. */
disable_dma(zn.tx_dma);
clear_dma_ff(zn.tx_dma);
set_dma_mode(zn.tx_dma, DMA_TX_MODE);
set_dma_addr(zn.tx_dma, (unsigned int) zn.tx_start);
set_dma_count(zn.tx_dma, zn.tx_buf_len<<1);
enable_dma(zn.tx_dma);
} sti();
if (znet_debug > 1)
printk("%s: Initializing the i82593, tx buf %p... ", dev->name,
zn.tx_start);
/* Do an empty configure command, just like the Crynwr driver. This
resets to chip to its default values. */
*zn.tx_cur++ = 0;
*zn.tx_cur++ = 0;
printk("stat:%02x ", inb(ioaddr)); show_dma();
outb(CMD0_CONFIGURE+CMD0_CHNL_1, ioaddr);
*zn.tx_cur++ = sizeof(i593_init);
memcpy(zn.tx_cur, i593_init, sizeof(i593_init));
zn.tx_cur += sizeof(i593_init)/2;
printk("stat:%02x ", inb(ioaddr)); show_dma();
outb(CMD0_CONFIGURE+CMD0_CHNL_1, ioaddr);
*zn.tx_cur++ = 6;
memcpy(zn.tx_cur, dev->dev_addr, 6);
zn.tx_cur += 3;
printk("stat:%02x ", inb(ioaddr)); show_dma();
outb(CMD0_IA_SETUP + CMD0_CHNL_1, ioaddr);
printk("stat:%02x ", inb(ioaddr)); show_dma();
update_stop_hit(ioaddr, 8192);
if (znet_debug > 1) printk("enabling Rx.\n");
outb(CMD0_Rx_ENABLE+CMD0_CHNL_0, ioaddr);
dev->tbusy = 0;
}
#ifdef notdef
foo()
{
/*do_command(ioaddr, CMD0_CONFIGURE+CMD0_CHNL_1, sizeof(i593_init) + 2,
zn.tx_buffer);*/
/*do_command(ioaddr, CMD0_CONFIGURE+CMD0_CHNL_1, 32, zn.tx_buffer);*/
/*outb(CMD0_CONFIGURE+CMD0_CHNL_1, ioaddr);*/
if (znet_debug > 1) printk("Set Address... ");
*zn.tx_cur++ = 6;
memcpy(zn.tx_cur, dev->dev_addr, 6);
zn.tx_cur += 3;
outb(CMD0_IA_SETUP + CMD0_CHNL_1, ioaddr);
{
unsigned stop_time = jiffies + 3;
while (jiffies < stop_time);
}
if (znet_debug > 2) {
short dma_port = ((zn.tx_dma&3)<<2) + IO_DMA2_BASE;
unsigned addr = inb(dma_port);
addr |= inb(dma_port) << 8;
printk("Terminal addr is %04x, cnt. %03x...", addr<<1,
get_dma_residue(zn.tx_dma));
}
*zn.tx_cur++ = 6;
memcpy(zn.tx_cur, dev->dev_addr, 6);
zn.tx_cur += 3;
outb(CMD0_IA_SETUP + CMD0_CHNL_1, ioaddr);
{
unsigned stop_time = jiffies + 2;
while (jiffies < stop_time);
}
if (znet_debug > 2) {
short dma_port = ((zn.tx_dma&3)<<2) + IO_DMA2_BASE;
unsigned addr = inb(dma_port);
addr |= inb(dma_port) << 8;
printk("Terminal addr is %04x, cnt. %03x...", addr<<1,
get_dma_residue(zn.tx_dma));
}
wait_for_done(ioaddr);
if (znet_debug > 1) printk("Set Mode... ");
set_multicast_list(dev, 0, 0);
{
unsigned stop_time = jiffies + 3;
while (jiffies < stop_time);
}
if (znet_debug > 2) {
short dma_port = ((zn.tx_dma&3)<<2) + IO_DMA2_BASE;
unsigned addr = inb(dma_port);
addr |= inb(dma_port) << 8;
printk("Terminal addr is %04x, cnt. %03x...", addr<<1,
get_dma_residue(zn.tx_dma));
}
if (znet_debug > 2) {
int i;
outb(CMD0_DUMP+CMD0_CHNL_0, ioaddr);
printk("Dumping state:");
for (i = 0; i < 16; i++)
printk(" %04x", *zn.rx_cur++);
printk("\n :");
for (;i < 32; i++)
printk(" %04x", *zn.rx_cur++);
printk("\n");
wait_for_done(ioaddr);
}
}
static int do_command(short ioaddr, int command, int length, ushort *buffer)
{
/* This isn't needed, but is here for safety. */
outb(CMD0_NOP+CMD0_STAT3,ioaddr);
if (inb(ioaddr) & 3)
printk("znet: do_command() while the i82593 is busy.\n");
cli();
disable_dma(zn.tx_dma);
clear_dma_ff(zn.tx_dma);
set_dma_mode(zn.tx_dma,DMA_MODE_WRITE);
set_dma_addr(zn.tx_dma,(unsigned int) zn.tx_start);
set_dma_count(zn.tx_dma,length);
sti();
enable_dma(zn.tx_dma);
outb(command, ioaddr);
return 0;
}
/* wait_for_done - this is a blatent rip-off of the wait_for_done routine
** from the Crynwr packet driver. It does not work correctly - doesn't
** acknowledge the interrupts it gets or something. It does determine
** when the command is done, or if there are none executing, though...
** -Mike
*/
static int wait_for_done(short ioaddr)
{
unsigned int stat;
unsigned stop_time = jiffies + 10;
int ticks = 0;
/* check to see if we are busy */
outb(CMD0_NOP+CMD0_STAT3,ioaddr);
stat = inb(ioaddr);
/* check if busy */
if ((stat&3)==0) {
if (znet_debug > 5)
printk("wait_for_done(): Not busy, status %02x.\n", stat);
return 0;
}
while (jiffies < stop_time) {
/* now check */
outb(CMD0_NOP+CMD0_STAT3,ioaddr);
stat = inb(ioaddr);
if ((stat&3)==0) {
if (znet_debug > 5)
printk("Command completed after %d ticks status %02x.\n",
ticks, stat);
outb((CMD0_NOP|CMD0_ACK),ioaddr);
return 0;
}
ticks++;
}
outb(CMD0_ABORT, ioaddr);
if (znet_debug)
printk("wait_for_done: command not ACK'd, status %02x after abort %02x.\n",
stat, inb(ioaddr));
/* should re-initialize here... */
return 1;
}
#endif /* notdef */
static void update_stop_hit(short ioaddr, unsigned short rx_stop_offset)
{
outb(CMD0_PORT_1, ioaddr);
if (znet_debug > 5)
printk("Updating stop hit with value %02x.\n",
(rx_stop_offset >> 6) | 0x80);
outb((rx_stop_offset >> 6) | 0x80, ioaddr);
outb(CMD1_PORT_0, ioaddr);
}
/*
* Local variables:
* compile-command: "gcc -D__KERNEL__ -I/usr/src/linux/net/inet -Wall -Wstrict-prototypes -O6 -m486 -c znet.c"
* version-control: t
* kept-new-versions: 5
* c-indent-level: 4
* tab-width: 4
* End:
*/
......@@ -220,7 +220,7 @@ static void scan_scsis (struct Scsi_Host * shpnt)
int dev, lun, type;
unsigned char scsi_cmd [12];
unsigned char scsi_result [256];
Scsi_Device * SDpnt;
Scsi_Device * SDpnt, *SDtail;
Scsi_Cmnd SCmd;
++in_scan;
......@@ -229,6 +229,10 @@ static void scan_scsis (struct Scsi_Host * shpnt)
SCmd.next = NULL;
SCmd.prev = NULL;
SDpnt = (Scsi_Device *) scsi_init_malloc(sizeof (Scsi_Device));
SDtail = scsi_devices;
if(scsi_devices) {
while(SDtail->next) SDtail = SDtail->next;
}
shpnt->host_queue = &SCmd; /* We need this so that
commands can time out */
......@@ -465,8 +469,13 @@ static void scan_scsis (struct Scsi_Host * shpnt)
while (SCmd.request.dev != 0xfffe);
};
SDpnt->next = scsi_devices;
scsi_devices = SDpnt;
/* Add this device to the linked list at the end */
if(SDtail)
SDtail->next = SDpnt;
else
scsi_devices = SDpnt;
SDtail = SDpnt;
++NR_SCSI_DEVICES;
SDpnt = (Scsi_Device *) scsi_init_malloc(sizeof (Scsi_Device));
/* Some scsi devices cannot be polled for lun != 0
......
......@@ -556,6 +556,7 @@ static void end_scsi_request(Scsi_Cmnd * SCpnt, int uptodate, int sectors)
DEVICE_OFF(req->dev);
if ((p = req->waiting) != NULL) {
req->waiting = NULL;
p->swapping = 0;
p->state = TASK_RUNNING;
if (p->counter > current->counter)
need_resched = 1;
......@@ -585,20 +586,17 @@ static void end_scsi_request(Scsi_Cmnd * SCpnt, int uptodate, int sectors)
#endif
#define SCSI_SLEEP(QUEUE, CONDITION) { \
long old_state; \
if (CONDITION) { \
struct wait_queue wait = { current, NULL}; \
add_wait_queue(QUEUE, &wait); \
sleep_repeat: \
old_state = current->state; \
current->state = TASK_UNINTERRUPTIBLE; \
if (CONDITION) { \
schedule(); \
goto sleep_repeat; \
} \
remove_wait_queue(QUEUE, &wait); \
if (current->state == TASK_UNINTERRUPTIBLE) \
current->state = old_state; \
current->state = TASK_RUNNING; \
}; }
#endif
......@@ -17,7 +17,10 @@
#define CD_MINS 74 /* max. minutes per CD */
#define CD_SECS 60 /* seconds per minute */
#define CD_FRAMES 75 /* frames per second */
#define CD_CHUNK_SIZE 24 /* lowest-level "data bytes piece" */
#define CD_NUM_OF_CHUNKS 98 /* chunks per frame */
#define CD_FRAMESIZE 2048 /* bytes per frame, cooked mode */
#define CD_FRAMESIZE_RAW0 2336 /* bytes per frame, "raw" mode */
#define CD_FRAMESIZE_XA 2340 /* bytes per frame, "xa" mode */
#define CD_FRAMESIZE_RAW 2352 /* bytes per frame, "raw" mode */
#define CD_FRAMESIZE_SUB 96 /* subchannel data size */
......
......@@ -264,6 +264,7 @@ struct task_struct {
unsigned long personality;
int dumpable:1;
int did_exec:1;
volatile int swapping:1;
int pid,pgrp,session,leader;
int groups[NGROUPS];
/*
......@@ -331,7 +332,7 @@ struct task_struct {
/* schedlink */ &init_task,&init_task, \
/* signals */ {{ 0, },}, \
/* stack */ 0,(unsigned long) &init_kernel_stack, \
/* ec,brk... */ 0,0,0,0,0, \
/* ec,brk... */ 0,0,0,0,0,0, \
/* pid etc.. */ 0,0,0,0, \
/* suppl grps*/ {NOGROUP,}, \
/* proc links*/ &init_task,&init_task,NULL,NULL,NULL,NULL, \
......
......@@ -188,6 +188,7 @@ asmlinkage int sys_fork(struct pt_regs regs)
(*p->binfmt->use_count)++;
p->did_exec = 0;
p->swapping = 0;
p->kernel_stack_page = 0;
p->state = TASK_UNINTERRUPTIBLE;
p->flags &= ~(PF_PTRACED|PF_TRACESYS);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment