/*
* This file contains the device dependent part of an experimental disk
* and tape driver for the Adaptec 154x SCSI Host Adapter family, written
* by James da Silva (jds@cs.umd.edu).
*
* I wrote this driver using the technical documentation for the AHA available
* from the Adaptec BBS at 1-408-945-7727, and from the SCSI standard drafts
* available on NCR's SCSI BBS at 1-316-636-8700. I suggest you get both
* these documents if you want to understand and hack this code.
*
* This code has been extensively modified by Kees J. Bot (kjb@cs.vu.nl) to
* a point that James will barely recognize it as his. It is completely
* remodeled and doubled in both size and functionality. It is no longer
* considered experimental either.
*
* The supported device numbers are as follows:
* # Name Device
* 0 sd0 disk 0, entire disk
* 1 sd1 disk 0, partition 1
* 2 sd2 disk 0, partition 2
* 3 sd3 disk 0, partition 3
* 4 sd4 disk 0, partition 4
* 5 sd5 disk 1, entire disk
* 6 sd6 disk 1, partition 1
* .. .... ....
* 39 sd39 disk 7, partition 4
*
* 64 nrst0 tape 0, no rewind
* 65 rst0 tape 0, rewind
* 66 nrst1 tape 1, no rewind
* .. .... ....
* 79 rst7 tape 7, rewind
*
* 128 sd1a disk 0, partition 1, subpartition 1
* 129 sd1b disk 0, partition 1, subpartition 2
* ... .... ....
* 255 sd39d disk 7, partition 4, subpartition 4
*
* The translation of device numbers to targets and logical units is very
* simple: The target is the same as the disk or tape number, the logical
* unit is always zero. Devices with logical unit numbers other then zero
* are virtually extinct. If you happen to have such a dinosaur device,
* then you can reprogram (e.g.) sd35 and st7 to target 0, lun 1 from the
* Boot Monitor with 'sd35=0,1'.
*
*
* The file contains one entry point:
*
* aha_scsi_task: main entry when system is brought up
*
*
* Changes:
* 5 May 1992 by Kees J. Bot: device dependent/independent split.
* 7 Jul 1992 by Kees J. Bot: speedup & features.
* 28 Dec 1992 by Kees J. Bot: completely remodeled & virtual memory.
* 18 Sep 1994 by Kees J. Bot: removed "send 2 commands at once" junk.
*/
#include "kernel.h"
#include "driver.h"
#include "drvlib.h"
#if ENABLE_ADAPTEC_SCSI
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/mtio.h>
#include "assert.h"
INIT_ASSERT
#ifndef AHA_DEBUG
#define AHA_DEBUG 0 /* 1=print all SCSI errors | 2=dump ccb
* 4=show request | 8=dump scsi cmd
*/
#endif
/* AHA-154x port addresses */
#define AHA_BASEREG 0x330 /* default base port address of AHA registers */
#define AHA_CNTLREG aha_basereg+0 /* Control Register - write only */
#define AHA_STATREG aha_basereg+0 /* Status Register - read only */
#define AHA_DATAREG aha_basereg+1 /* Data Register - read/write */
#define AHA_INTRREG aha_basereg+2 /* Interrupt Flags - read only */
/* control register bits */
#define AHA_HRST 0x80 /* bit 7 - Hard Reset */
#define AHA_SRST 0x40 /* bit 6 - Soft Reset */
#define AHA_IRST 0x20 /* bit 5 - Interrupt Reset */
#define AHA_SCRST 0x10 /* bit 4 - SCSI Bus Reset */
/* 0x08 * bit 3 - Reserved (set to 0) */
/* 0x04 * bit 2 - Reserved (set to 0) */
/* 0x02 * bit 1 - Reserved (set to 0) */
/* 0x01 * bit 0 - Reserved (set to 0) */
/* status register bits */
#define AHA_STST 0x80 /* bit 7 - Self Test in Progress */
#define AHA_DIAGF 0x40 /* bit 6 - Internal Diagnostic Failure */
#define AHA_INIT 0x20 /* bit 5 - Mailbox Initialization Required */
#define AHA_IDLE 0x10 /* bit 4 - SCSI Host Adapter Idle */
#define AHA_CDF 0x08 /* bit 3 - Command/Data Out Port Full */
#define AHA_DF 0x04 /* bit 2 - Data In Port Full */
/* 0x02 * bit 1 - Reserved */
#define AHA_INVDCMD 0x01 /* bit 0 - Invalid Host Adapter Command */
/* interrupt flags register bits */
#define AHA_ANYINT 0x80 /* bit 7 - Any Interrupt */
/* 0x40 * bit 6 - Reserved */
/* 0x20 * bit 5 - Reserved */
/* 0x10 * bit 4 - Reserved */
#define AHA_SCRD 0x08 /* bit 3 - SCSI Reset Detected */
#define AHA_HACC 0x04 /* bit 2 - Host Adapter Command Complete */
#define AHA_MBOE 0x02 /* bit 1 - Mailbox Out Empty */
#define AHA_MBIF 0x01 /* bit 0 - Mailbox In Full */
/* AHA board models */
#define AHA1540 0x30
#define AHA1540A 0x41
#define AHA1640 0x42
#define AHA1740 0x43
#define AHA1540C 0x44
#define AHA1540CF 0x45
#define BT545 0x20 /* BusLogic */
/* AHA Command Codes */
#define AHACOM_INITBOX 0x01 /* Mailbox Initialization */
#define AHACOM_STARTSCSI 0x02 /* Start SCSI Command */
#define AHACOM_HAINQUIRY 0x04 /* Host Adapter Inquiry */
#define AHACOM_SETIMEOUT 0x06 /* Set SCSI selection time out value */
#define AHACOM_BUSON 0x07 /* Set DMA bus on time */
#define AHACOM_BUSOFF 0x08 /* Set DMA bus off time */
#define AHACOM_SPEED 0x09 /* Set DMA transfer speed */
#define AHACOM_INSTALLED 0x0A /* Return Installed Devices */
#define AHACOM_GETCONFIG 0x0B /* Return Configuration Data */
#define AHACOM_GETSETUP 0x0D /* Return Setup Data */
#define AHACOM_EXTBIOS 0x28 /* Return Extended BIOS Info */
#define AHACOM_MBOX_ENABLE 0x29 /* Enable Mailbox Interface */
/* AHA Mailbox Out Codes */
#define AHA_MBOXFREE 0x00 /* Mailbox is Free */
#define AHA_MBOXSTART 0x01 /* Start Command */
#define AHA_MBOXABORT 0x02 /* Abort Command */
/* AHA Mailbox In Codes */
#define AHA_MBOXOK 0x01 /* Command Completed Successfully */
#define AHA_MBOXERR 0x04 /* Command Completed with Error */
/* Basic types */
typedef unsigned char byte;
typedef byte big16[2]; /* 16 bit big-endian values */
typedef byte big24[3]; /* AHA uses 24 bit, big-endian values! */
typedef byte big32[4]; /* Group 1 SCSI commands use 32 bit big-endian values */
/* AHA Mailbox structure */
typedef struct {
byte status; /* Command or Status byte */
big24 ccbptr; /* pointer to Command Control Block */
} mailbox_t;
/* SCSI Group 0 Command Descriptor Block structure */
typedef union {
struct { /* Disk i/o commands */
byte d_scsi_op; /* SCSI Operation Code */
# define SCSI_UNITRDY 0x00 /* Test Unit Ready */
# define SCSI_REWIND 0x01 /* Rewind */
# define SCSI_REQSENSE 0x03 /* Request sense */
# define SCSI_RDLIMITS 0x05 /* Read Block Limits Opcode */
# define SCSI_READ 0x08 /* Group 0 Read Opcode */
# define SCSI_WRITE 0x0A /* Group 0 Write Opcode */
# define SCSI_WREOF 0x10 /* Write File Marks */
# define SCSI_SPACE 0x11 /* Space over filemarks/blocks */
# define SCSI_INQUIRY 0x12 /* Group 0 Inquiry Opcode */
# define SCSI_MDSELECT 0x15 /* Group 0 Mode Select Opcode */
# define SCSI_ERASE 0x19 /* Erase Tape */
# define SCSI_MDSENSE 0x1A /* Group 0 Mode Sense Opcode */
# define SCSI_STRTSTP 0x1B /* Start/Stop */
# define SCSI_LOADUNLD 0x1B /* Load/Unload */
big24 d_lba; /* LUN and logical block address */
byte d_nblocks; /* Transfer size in blocks */
byte d_control; /* Reserved and link bit fields, set to 0 */
} d;
struct { /* Tape i/o commands */
byte t_scsi_op; /* SCSI Operation Code */
byte t_fixed; /* Fixed length? */
big24 t_trlength; /* Transfer length */
byte t_control; /* reserved and link bit fields, set to 0 */
} t;
} cdb0_t;
#define scsi_op d.d_scsi_op
#define lba d.d_lba
#define nblocks d.d_nblocks
#define fixed t.t_fixed
#define trlength t.t_trlength
#define control d.d_control
/* SCSI Group 1 Command Descriptor Block structure */
typedef union {
struct { /* Disk i/o commands */
byte d_scsi_op; /* SCSI Operation Code */
# define SCSI_CAPACITY 0x25 /* Read Capacity */
# define SCSI_READ1 0x28 /* Group 1 Read Opcode */
# define SCSI_WRITE1 0x2A /* Group 1 Write Opcode */
byte d_lunra; /* LUN etc. */
big32 d_lba; /* Logical Block Address */
byte reserved;
big16 d_nblocks; /* transfer size in blocks */
byte d_control; /* reserved and link bit fields, set to 0 */
} d;
} cdb1_t;
#define lunra d.d_lunra
/* SCSI Request Sense Information */
typedef struct {
byte errc; /
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
minix-sys.rar_minix_minix3 (1457个子文件)
flexdoc.1 64KB
ash.1 36KB
bc.1 31KB
acd.1 22KB
flex.1 20KB
cawf.1 19KB
patch.1 17KB
telnet.1 11KB
host.1 10KB
yap.1 10KB
sz.1 7KB
sh.1 7KB
remsync.1 5KB
stty.1 5KB
ic.1 4KB
cc.1 4KB
install.1 4KB
man.1 4KB
elvis.1 4KB
ref.1 4KB
vol.1 4KB
ls.1 3KB
mkfs.1 3KB
synctree.1 3KB
ctags.1 3KB
mt.1 3KB
rlogin.1 3KB
bsfilt.1 3KB
yacc.1 2KB
rz.1 2KB
rcp.1 2KB
find.1 2KB
term.1 2KB
chmod.1 2KB
finger.1 2KB
rsh.1 2KB
mail.1 2KB
date.1 2KB
cdplay.1 2KB
join.1 2KB
chmem.1 2KB
make.1 2KB
fsck.1 2KB
diff.1 2KB
elvrec.1 2KB
ed.1 2KB
dd.1 2KB
cut.1 2KB
cp.1 2KB
format.1 2KB
sort.1 2KB
gather.1 2KB
svc.1 2KB
ar.1 2KB
ps.1 2KB
lp.1 1KB
calendar.1 1KB
mref.1 1KB
paste.1 1KB
test.1 1KB
anm.1 1KB
ifdef.1 1KB
tget.1 1KB
ln.1 1KB
uue.1 1KB
compress.1 1KB
grep.1 1KB
tar.1 1KB
at.1 1KB
mkproto.1 1KB
dosdir.1 1KB
modem.1 1KB
btoa.1 1KB
hostaddr.1 1KB
nm.1 1KB
mv.1 1KB
uname.1 1KB
postmort.1 1KB
uniq.1 1KB
mixer.1 1KB
pr.1 1KB
od.1 1020B
chgrp.1 1011B
passwd.1 1008B
readall.1 1003B
unshar.1 999B
treecmp.1 996B
fgrep.1 985B
template.1 964B
cgrep.1 954B
tail.1 947B
last.1 930B
who.1 895B
rm.1 891B
isodir.1 890B
sed.1 890B
su.1 875B
kill.1 866B
mkdir.1 863B
write.1 859B
共 1457 条
- 1
- 2
- 3
- 4
- 5
- 6
- 15
资源评论
林当时
- 粉丝: 97
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功