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

📄 aha152x.c

📁 GNU Mach 微内核源代码, 基于美国卡内基美隆大学的 Mach 研究项目
💻 C
📖 第 1 页 / 共 5 页
字号:
/* aha152x.c -- Adaptec AHA-152x driver * Author: J黵gen E. Fischer, fischer@et-inf.fho-emden.de * Copyright 1993, 1994, 1995, 1996 J黵gen E. Fischer * * * This driver is based on *   fdomain.c -- Future Domain TMC-16x0 driver * which is *   Copyright 1992, 1993 Rickard E. Faith (faith@cs.unc.edu) * * * 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, 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. * * * $Id: aha152x.c,v 1.1 1999/04/26 05:44:22 tb Exp $ * * $Log: aha152x.c,v $ * Revision 1.1  1999/04/26 05:44:22  tb * 1999-04-12  OKUJI Yoshinori  <okuji@kuicr.kyoto-u.ac.jp> * * 	* linux/dev/drivers/block/ide.c (init_hwif_data) [MACH]: Print Mach * 	device name instead of Linux one. * 	* linux/dev/drivers/block/genhd.c (disk_name): Likewise. * 	* linux/dev/drivers/scsi/sd.c (sd_init_onedisk): Likewise. * 	(sd_detect): Likewise. * 	* linux/dev/drivers/sr.c (sr_detect): Likewise. * 	(get_sectorsize): Likewise. * * 1999-02-04  OKUJI Yoshinori  <okuji@kuicr.kyoto-u.ac.jp> * * 	* device/kmsg.c (kmsginit): Add a missing semicolon. * 	(kmsggetstat): Fix typos, * 	DEV_GET_DEVICE_SIZE -> DEV_GET_SIZE_DEVICE_SIZE and * 	DEV_GET_RECORD_SIZE -> DEV_GET_SIZE_RECORD_SIZE. * 	(kmsg_putchar): Fix a typo kmsg_done_init -> kmsg_init_done. * 	* linux/dev/glue/block.c (device_get_status): Allocate a hd_geometry * 	on the stack. * 	* linux/dev/drivers/block/ide.c: New file. * 	* linux/dev/drivers/scsi/sd_ioctl.c: New file. * * Revision 1.18  1996/09/07 20:10:40  fischer * - fixed can_queue handling (multiple outstanding commands working again) * * Revision 1.17  1996/08/17 16:05:14  fischer * - biosparam improved * - interrupt verification * - updated documentation * - cleanups * * Revision 1.16  1996/06/09 00:04:56  root * - added configuration symbols for insmod (aha152x/aha152x1) * * Revision 1.15  1996/04/30 14:52:06  fischer * - proc info fixed * - support for extended translation for >1GB disks * * Revision 1.14  1996/01/17  15:11:20  fischer * - fixed lockup in MESSAGE IN phase after reconnection * * Revision 1.13  1996/01/09  02:15:53  fischer * - some cleanups * - moved request_irq behind controller initialization *   (to avoid spurious interrupts) * * Revision 1.12  1995/12/16  12:26:07  fischer * - barrier()s added * - configurable RESET delay added * * Revision 1.11  1995/12/06  21:18:35  fischer * - some minor updates * * Revision 1.10  1995/07/22  19:18:45  fischer * - support for 2 controllers * - started synchronous data transfers (not working yet) * * Revision 1.9  1995/03/18  09:20:24  root * - patches for PCMCIA and modules * * Revision 1.8  1995/01/21  22:07:19  root * - snarf_region => request_region * - aha152x_intr interface change * * Revision 1.7  1995/01/02  23:19:36  root * - updated COMMAND_SIZE to cmd_len * - changed sti() to restore_flags() * - fixed some #ifdef which generated warnings * * Revision 1.6  1994/11/24  20:35:27  root * - problem with odd number of bytes in fifo fixed * * Revision 1.5  1994/10/30  14:39:56  root * - abort code fixed * - debugging improved * * Revision 1.4  1994/09/12  11:33:01  root * - irqaction to request_irq * - abortion updated * * Revision 1.3  1994/08/04  13:53:05  root * - updates for mid-level-driver changes * - accept unexpected BUSFREE phase as error condition * - parity check now configurable * * Revision 1.2  1994/07/03  12:56:36  root * - cleaned up debugging code * - more tweaking on reset delays * - updated abort/reset code (pretty untested...) * * Revision 1.1  1994/05/28  21:18:49  root * - update for mid-level interface change (abort-reset) * - delays after resets adjusted for some slow devices * * Revision 1.0  1994/03/25  12:52:00  root * - Fixed "more data than expected" problem * - added new BIOS signatures * * Revision 0.102  1994/01/31  20:44:12  root * - minor changes in insw/outsw handling * * Revision 0.101  1993/12/13  01:16:27  root * - fixed STATUS phase (non-GOOD stati were dropped sometimes; *   fixes problems with CD-ROM sector size detection & media change) * * Revision 0.100  1993/12/10  16:58:47  root * - fix for unsuccessful selections in case of non-continuous id assignments *   on the scsi bus. * * Revision 0.99  1993/10/24  16:19:59  root * - fixed DATA IN (rare read errors gone) * * Revision 0.98  1993/10/17  12:54:44  root * - fixed some recent fixes (shame on me) * - moved initialization of scratch area to aha152x_queue * * Revision 0.97  1993/10/09  18:53:53  root * - DATA IN fixed. Rarely left data in the fifo. * * Revision 0.96  1993/10/03  00:53:59  root * - minor changes on DATA IN * * Revision 0.95  1993/09/24  10:36:01  root * - change handling of MSGI after reselection * - fixed sti/cli * - minor changes * * Revision 0.94  1993/09/18  14:08:22  root * - fixed bug in multiple outstanding command code * - changed detection * - support for kernel command line configuration * - reset corrected * - changed message handling * * Revision 0.93  1993/09/15  20:41:19  root * - fixed bugs with multiple outstanding commands * * Revision 0.92  1993/09/13  02:46:33  root * - multiple outstanding commands work (no problems with IBM drive) * * Revision 0.91  1993/09/12  20:51:46  root * added multiple outstanding commands * (some problem with this $%&? IBM device remain) * * Revision 0.9  1993/09/12  11:11:22  root * - corrected auto-configuration * - changed the auto-configuration (added some '#define's) * - added support for dis-/reconnection * * Revision 0.8  1993/09/06  23:09:39  root * - added support for the drive activity light * - minor changes * * Revision 0.7  1993/09/05  14:30:15  root * - improved phase detection * - now using the new snarf_region code of 0.99pl13 * * Revision 0.6  1993/09/02  11:01:38  root * first public release; added some signatures and biosparam() * * Revision 0.5  1993/08/30  10:23:30  root * fixed timing problems with my IBM drive * * Revision 0.4  1993/08/29  14:06:52  root * fixed some problems with timeouts due incomplete commands * * Revision 0.3  1993/08/28  15:55:03  root * writing data works too.  mounted and worked on a dos partition * * Revision 0.2  1993/08/27  22:42:07  root * reading data works.  Mounted a msdos partition. * * Revision 0.1  1993/08/25  13:38:30  root * first "damn thing doesn't work" version * * Revision 0.0  1993/08/14  19:54:25  root * empty function bodies; detect() works. * * **************************************************************************  DESCRIPTION: This is the Linux low-level SCSI driver for Adaptec AHA-1520/1522 SCSI host adapters. CONFIGURATION ARGUMENTS:  IOPORT        base io address                           (0x340/0x140)  IRQ           interrupt level                           (9-12; default 11)  SCSI_ID       scsi id of controller                     (0-7; default 7)  RECONNECT     allow targets to disconnect from the bus  (0/1; default 1 [on])  PARITY        enable parity checking                    (0/1; default 1 [on])  SYNCHRONOUS   enable synchronous transfers              (0/1; default 0 [off])                (NOT WORKING YET)  DELAY:        bus reset delay                           (default 100)  EXT_TRANS:    enable extended translation               (0/1: default 0 [off])                (see NOTES below) COMPILE TIME CONFIGURATION (put into AHA152X in drivers/scsi/Makefile): -DAUTOCONF   use configuration the controller reports (AHA-152x only) -DSKIP_BIOSTEST   Don't test for BIOS signature (AHA-1510 or disabled BIOS) -DSETUP0="{ IOPORT, IRQ, SCSI_ID, RECONNECT, PARITY, SYNCHRONOUS, DELAY, EXT_TRANS }"   override for the first controller     -DSETUP1="{ IOPORT, IRQ, SCSI_ID, RECONNECT, PARITY, SYNCHRONOUS, DELAY, EXT_TRANS }"   override for the second controller LILO COMMAND LINE OPTIONS: aha152x=<IOPORT>[,<IRQ>[,<SCSI-ID>[,<RECONNECT>[,<PARITY>[,<SYNCHRONOUS>[,<DELAY> [,<EXT_TRANS]]]]]]] The normal configuration can be overridden by specifying a command line. When you do this, the BIOS test is skipped. Entered values have to be valid (known).  Don't use values that aren't supported under normal operation.  If you think that you need other values: contact me. For two controllers use the aha152x statement twice. SYMBOLS FOR MODULE CONFIGURATION:   aha152x=IOPORT,IRQ,SCSI_ID,RECONNECT,PARITY,SYNCHRONOUS,DELAY,EXT_TRANS    configuration override of first controller   aha152x1=IOPORT,IRQ,SCSI_ID,RECONNECT,PARITY,SYNCHRONOUS,DELAY,EXT_TRANS    configuration override of second controller NOTES ON EXT_TRANS:  SCSI uses block numbers to address blocks/sectors on a device. The BIOS uses a cylinder/head/sector addressing scheme (C/H/S) scheme instead.  DOS expects a BIOS or driver that understands this C/H/S addressing. The number of cylinders/heads/sectors is called geometry and is required as base for requests in C/H/S adressing.  SCSI only knows about the total capacity of disks in blocks (sectors). Therefore the SCSI BIOS/DOS driver has to calculate a logical/virtual geometry just to be able to support that addressing scheme.  The geometry returned by the SCSI BIOS is a pure calculation and has nothing to do with the real/physical geometry of the disk (which is usually irrelevant anyway). Basically this has no impact at all on Linux, because it also uses block instead of C/H/S addressing.  Unfortunately C/H/S addressing is also used in the partition table and therefore every operating system has to know the right geometry to be able to interpret it. Moreover there are certain limitations to the C/H/S addressing scheme, namely the address space is limited to upto 255 heads, upto 63 sectors and a maximum of 1023 cylinders. The AHA-1522 BIOS calculates the geometry by fixing the number of heads to 64, the number of sectors to 32 and by calculating the number of cylinders by dividing the capacity reported by the disk by 64*32 (1 MB). This is considered to be the default translation. With respect to the limit of 1023 cylinders using C/H/S you can only address the first GB of your disk in the partition table.  Therefore BIOSes of some newer controllers based on the AIC-6260/6360 support extended translation.  This means that the BIOS uses 255 for heads, 63 for sectors and then divides the capacity of the disk by 255*63 (about 8 MB), as soon it sees a disk greater than 1 GB.  That results in a maximum of about 8 GB adressable diskspace in the partition table (but there are already bigger disks out there today). To make it even more complicated the translation mode might/might not be configurable in certain BIOS setups. This driver does some more or less failsafe guessing to get the geometry right in most cases: - for disks<1GB: use default translation (C/32/64) - for disks>1GB:   - take current geometry from the partition table     (using scsicam_bios_param and accept only `valid' geometries,      ie. either (C/32/64) or (C/63/255)).  This can be extended      translation even if it's not enabled in the driver.   - if that fails, take extended translation if enabled by override,     kernel or module parameter, otherwise take default translation and     ask the user for verification.  This might on not yet partitioned     disks or REFERENCES USED: "AIC-6260 SCSI Chip Specification", Adaptec Corporation. "SCSI COMPUTER SYSTEM INTERFACE - 2 (SCSI-2)", X3T9.2/86-109 rev. 10h "Writing a SCSI device driver for Linux", Rik Faith (faith@cs.unc.edu) "Kernel Hacker's Guide", Michael K. Johnson (johnsonm@sunsite.unc.edu) "Adaptec 1520/1522 User's Guide", Adaptec Corporation.  Michael K. Johnson (johnsonm@sunsite.unc.edu) Drew Eckhardt (drew@cs.colorado.edu) Eric Youngdale (ericy@cais.com)  special thanks to Eric Youngdale for the free(!) supplying the documentation on the chip. **************************************************************************/#ifdef MACH#define AUTOCONF	1#endif#ifdef PCMCIA#define MODULE#endif#include <linux/module.h>#ifdef PCMCIA#undef MODULE#endif#include <linux/sched.h>#include <asm/io.h>#include <linux/blk.h>#include "scsi.h"#include "sd.h"#include "hosts.h"#include "constants.h"#include <asm/system.h>#include <linux/errno.h>#include <linux/string.h>#include <linux/wait.h>#include <linux/ioport.h>#include <linux/proc_fs.h>#include "aha152x.h"#include <linux/stat.h>#include <scsi/scsicam.h>struct proc_dir_entry proc_scsi_aha152x = {    PROC_SCSI_AHA152X, 7, "aha152x",    S_IFDIR | S_IRUGO | S_IXUGO, 2};/* DEFINES *//* For PCMCIA cards, always use AUTOCONF */#if defined(PCMCIA) || defined(MODULE)#if !defined(AUTOCONF)#define AUTOCONF#endif#endif#if !defined(AUTOCONF) && !defined(SETUP0)#error define AUTOCONF or SETUP0#endif#if defined(DEBUG_AHA152X)#undef  SKIP_PORTS              /* don't display ports */#undef  DEBUG_QUEUE             /* debug queue() */#undef  DEBUG_RESET             /* debug reset() */#undef  DEBUG_INTR              /* debug intr() */#undef  DEBUG_SELECTION         /* debug selection part in intr() */#undef  DEBUG_MSGO              /* debug message out phase in intr() */#undef  DEBUG_MSGI              /* debug message in phase in intr() */#undef  DEBUG_STATUS            /* debug status phase in intr() */#undef  DEBUG_CMD               /* debug command phase in intr() */#undef  DEBUG_DATAI             /* debug data in phase in intr() */#undef  DEBUG_DATAO             /* debug data out phase in intr() */#undef  DEBUG_ABORT             /* debug abort() */#undef  DEBUG_DONE              /* debug done() */#undef  DEBUG_BIOSPARAM         /* debug biosparam() */#undef  DEBUG_RACE              /* debug race conditions */#undef  DEBUG_PHASES            /* debug phases (useful to trace) */#undef  DEBUG_QUEUES            /* debug reselection *//* recently used for debugging */#if 0#endif#define DEBUG_SELECTION#define DEBUG_PHASES#define DEBUG_RESET#define DEBUG_ABORT#define DEBUG_DEFAULT (debug_reset|debug_abort)#endif/* END OF DEFINES */extern unsigned long loops_per_sec;#define DELAY_DEFAULT 100/* some additional "phases" for getphase() */#define P_BUSFREE  1#define P_PARITY   2/* possible irq range */#define IRQ_MIN 9#define IRQ_MAX 12#define IRQS    IRQ_MAX-IRQ_MIN+1enum {  not_issued   = 0x0001,  in_selection = 0x0002,  disconnected = 0x0004,  aborted      = 0x0008,  sent_ident   = 0x0010,

⌨️ 快捷键说明

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