Catch up with NetBSD/pc98.
o Much cleanly separate NetBSD(XS) / FreeBSD(CAM) codes. o Improve tagged queing support (full QTAG). o Improve quirk support. o Improve parity error retry. o Impliment wide negotheation. o Cmd link support. o Add copyright of CAM part. o Change for CAM_NEW_TRAN_CODE. o Work around for buggy KME UJDCD450. o stg: add disconnet condition. o nsp: use suspend I/O. and more. I thank Honda-san. conf/options.pc98: add CT_USE_RELOCATE_OFFSET and CT_BUS_WEIGHT dev/{ct,ncv,nsp,stg}/*_{pccard,isa}.c: add splcam() before calling attach/detach functions. Tested by: bsd-nomads Obtained from: NetBSD/pc98
This commit is contained in:
parent
9516fbd6d9
commit
b45f9c03c7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=79697
File diff suppressed because it is too large
Load Diff
@ -1,15 +1,21 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NecBSD: scsi_low.h,v 1.24 1999/07/23 21:00:05 honda Exp $ */
|
||||
/* $NecBSD: scsi_low.h,v 1.24.10.5 2001/06/26 07:31:46 honda Exp $ */
|
||||
/* $NetBSD$ */
|
||||
|
||||
#define SCSI_LOW_DIAGNOSTIC
|
||||
#define SCSI_LOW_ALT_QTAG_ALLOCATE
|
||||
|
||||
/*
|
||||
* [NetBSD for NEC PC-98 series]
|
||||
* Copyright (c) 1995, 1996, 1997, 1998
|
||||
* Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000, 2001
|
||||
* NetBSD/pc98 porting staff. All rights reserved.
|
||||
* Copyright (c) 1995, 1996, 1997, 1998
|
||||
* Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000, 2001
|
||||
* Naofumi HONDA. All rights reserved.
|
||||
*
|
||||
* [Ported for FreeBSD CAM]
|
||||
* Copyright (c) 2000, 2001
|
||||
* MITSUNAGA Noriaki, NOKUBI Hirotaka and TAKAHASHI Yoshihiro.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -38,12 +44,28 @@
|
||||
#ifndef _SCSI_LOW_H_
|
||||
#define _SCSI_LOW_H_
|
||||
|
||||
#ifdef __NetBSD__
|
||||
/*================================================
|
||||
* Scsi low OSDEP
|
||||
* (All os depend structures should be here!)
|
||||
================================================*/
|
||||
/******** interface ******************************/
|
||||
#ifdef __NetBSD__
|
||||
#define SCSI_LOW_INTERFACE_XS
|
||||
#endif /* __NetBSD__ */
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#define SCSI_LOW_INTERFACE_CAM
|
||||
#define CAM
|
||||
#endif /* __FreeBSD__ */
|
||||
|
||||
/******** includes *******************************/
|
||||
#ifdef __NetBSD__
|
||||
#include <i386/Cbus/dev/scsi_dvcfg.h>
|
||||
#endif
|
||||
#ifdef __FreeBSD__
|
||||
#include <dev/isa/ccbque.h>
|
||||
#endif /* __NetBSD__ */
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#include <sys/device_port.h>
|
||||
#define CAM
|
||||
#include <cam/cam.h>
|
||||
#include <cam/cam_ccb.h>
|
||||
#include <cam/cam_sim.h>
|
||||
@ -51,9 +73,99 @@
|
||||
#include <cam/cam_debug.h>
|
||||
|
||||
#include <cam/scsi/scsi_dvcfg.h>
|
||||
#endif
|
||||
#include <i386/isa/ccbque.h>
|
||||
#endif /* __FreeBSD__ */
|
||||
|
||||
/* user configuration flags defs */
|
||||
/******** functions macro ************************/
|
||||
#ifdef __NetBSD__
|
||||
#define SCSI_LOW_DEBUGGER(dev) Debugger()
|
||||
#define SCSI_LOW_DELAY(mu) delay((mu))
|
||||
#define SCSI_LOW_SPLSCSI splbio
|
||||
#define SCSI_LOW_BZERO(pt, size) memset((pt), 0, (size))
|
||||
#endif /* __NetBSD__ */
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#undef MSG_IDENTIFY
|
||||
#define SCSI_LOW_DEBUGGER(dev) Debugger((dev))
|
||||
#define SCSI_LOW_DELAY(mu) DELAY((mu))
|
||||
#define SCSI_LOW_SPLSCSI splcam
|
||||
#define SCSI_LOW_BZERO(pt, size) bzero((pt), (size))
|
||||
#endif /* __FreeBSD__ */
|
||||
|
||||
/******** os depend interface structures **********/
|
||||
#ifdef __NetBSD__
|
||||
typedef struct scsipi_sense_data scsi_low_osdep_sense_data_t;
|
||||
|
||||
struct scsi_low_osdep_interface {
|
||||
struct device si_dev;
|
||||
|
||||
struct scsipi_link *si_splp;
|
||||
};
|
||||
|
||||
struct scsi_low_osdep_targ_interface {
|
||||
};
|
||||
|
||||
struct scsi_low_osdep_lun_interface {
|
||||
u_int sloi_quirks;
|
||||
};
|
||||
#endif /* __NetBSD__ */
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
typedef struct scsi_sense_data scsi_low_osdep_sense_data_t;
|
||||
|
||||
struct scsi_low_osdep_interface {
|
||||
DEVPORT_DEVICE si_dev;
|
||||
|
||||
struct cam_sim *sim;
|
||||
struct cam_path *path;
|
||||
|
||||
int si_poll_count;
|
||||
|
||||
struct callout_handle engage_ch;
|
||||
struct callout_handle timeout_ch;
|
||||
#ifdef SCSI_LOW_POWFUNC
|
||||
struct callout_handle recover_ch;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct scsi_low_osdep_targ_interface {
|
||||
};
|
||||
|
||||
struct scsi_low_osdep_lun_interface {
|
||||
};
|
||||
#endif /* __FreeBSD__ */
|
||||
|
||||
/******** os depend interface functions *************/
|
||||
struct slccb;
|
||||
struct scsi_low_softc;
|
||||
#define SCSI_LOW_TIMEOUT_STOP 0
|
||||
#define SCSI_LOW_TIMEOUT_START 1
|
||||
#define SCSI_LOW_TIMEOUT_CH_IO 0
|
||||
#define SCSI_LOW_TIMEOUT_CH_ENGAGE 1
|
||||
#define SCSI_LOW_TIMEOUT_CH_RECOVER 2
|
||||
|
||||
struct scsi_low_osdep_funcs {
|
||||
int (*scsi_low_osdep_attach) \
|
||||
__P((struct scsi_low_softc *));
|
||||
int (*scsi_low_osdep_world_start) \
|
||||
__P((struct scsi_low_softc *));
|
||||
int (*scsi_low_osdep_dettach) \
|
||||
__P((struct scsi_low_softc *));
|
||||
int (*scsi_low_osdep_ccb_setup) \
|
||||
__P((struct scsi_low_softc *, struct slccb *));
|
||||
int (*scsi_low_osdep_done) \
|
||||
__P((struct scsi_low_softc *, struct slccb *));
|
||||
void (*scsi_low_osdep_timeout) \
|
||||
__P((struct scsi_low_softc *, int, int));
|
||||
};
|
||||
|
||||
/*================================================
|
||||
* Generic Scsi Low header file
|
||||
* (All os depend structures should be above!)
|
||||
================================================*/
|
||||
/*************************************************
|
||||
* Scsi low definitions
|
||||
*************************************************/
|
||||
#define SCSI_LOW_SYNC DVF_SCSI_SYNC
|
||||
#define SCSI_LOW_DISC DVF_SCSI_DISC
|
||||
#define SCSI_LOW_WAIT DVF_SCSI_WAIT
|
||||
@ -71,21 +183,22 @@
|
||||
#ifndef SCSI_LOW_NTARGETS
|
||||
#define SCSI_LOW_NTARGETS 8
|
||||
#endif /* SCSI_LOW_NTARGETS */
|
||||
#define SCSI_LOW_NCCB 32
|
||||
#define SCSI_LOW_NCCB 128
|
||||
|
||||
#define SCSI_LOW_MAX_MSGLEN 16
|
||||
#define SCSI_LOW_MAX_RETRY 3
|
||||
#define SCSI_LOW_MAX_SELECTION_RETRY 10
|
||||
|
||||
/* timeout control macro */
|
||||
#define SCSI_LOW_MIN_TOUT 24
|
||||
#define SCSI_LOW_TIMEOUT_CHECK_INTERVAL 4
|
||||
#define SCSI_LOW_TIMEOUT_HZ 10
|
||||
#define SCSI_LOW_MIN_TOUT 12
|
||||
#define SCSI_LOW_TIMEOUT_CHECK_INTERVAL 1
|
||||
#define SCSI_LOW_POWDOWN_TC 15
|
||||
#define SCSI_LOW_MAX_PHCHANGES 256
|
||||
#define SCSI2_RESET_DELAY 5000000
|
||||
|
||||
/* max synch period */
|
||||
#ifndef SCSI_LOW_MAX_SYNCH_SPEED
|
||||
#define SCSI_LOW_MAX_SYNCH_SPEED (100) /* 10.0M */
|
||||
#endif /* !SCSI_LOW_MAX_SYNCH_SPEED */
|
||||
/* msg */
|
||||
#define SCSI_LOW_MAX_MSGLEN 32
|
||||
#define SCSI_LOW_MSG_LOG_DATALEN 8
|
||||
|
||||
/*************************************************
|
||||
* Scsi Data Pointer
|
||||
@ -98,31 +211,14 @@ struct sc_p {
|
||||
u_int8_t *scp_cmd;
|
||||
int scp_cmdlen;
|
||||
|
||||
u_int scp_direction;
|
||||
u_int8_t scp_direction;
|
||||
#define SCSI_LOW_RWUNK (-1)
|
||||
#define SCSI_LOW_WRITE 0
|
||||
#define SCSI_LOW_READ 1
|
||||
u_int8_t scp_status;
|
||||
u_int8_t scp_spare[2];
|
||||
};
|
||||
|
||||
#define SCSI_LOW_SETUP_PHASE(ti, phase) \
|
||||
{ \
|
||||
if ((ti)->ti_phase != (phase)) \
|
||||
{ \
|
||||
(ti)->ti_ophase = ti->ti_phase; \
|
||||
(ti)->ti_phase = (phase); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SCSI_LOW_SETUP_MSGPHASE(slp, PHASE) \
|
||||
{ \
|
||||
(slp)->sl_msgphase = (PHASE); \
|
||||
}
|
||||
|
||||
#define SCSI_LOW_TARGET_ASSERT_ATN(slp) \
|
||||
{ \
|
||||
(ti)->ti_tflags |= TARG_ASSERT_ATN; \
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
* Command Control Block Structure
|
||||
*************************************************/
|
||||
@ -135,97 +231,163 @@ struct targ_info;
|
||||
struct slccb {
|
||||
TAILQ_ENTRY(slccb) ccb_chain;
|
||||
|
||||
#ifdef CAM
|
||||
union ccb *ccb;
|
||||
struct buf *bp;
|
||||
#else
|
||||
struct scsipi_xfer *xs; /* scsi upper */
|
||||
#endif
|
||||
void *osdep; /* os depend structure */
|
||||
|
||||
struct targ_info *ti; /* targ_info */
|
||||
struct lun_info *li; /* lun info */
|
||||
scsi_low_tag_t ccb_tag; /* tag */
|
||||
struct buf *bp; /* io bufs */
|
||||
|
||||
scsi_low_tag_t ccb_tag; /* effective qtag */
|
||||
scsi_low_tag_t ccb_otag; /* allocated qtag */
|
||||
|
||||
/*****************************************
|
||||
* Scsi data pointers (original and saved)
|
||||
*****************************************/
|
||||
struct sc_p ccb_scp; /* given */
|
||||
struct sc_p ccb_sscp; /* saved scsi data pointer */
|
||||
int ccb_datalen; /* transfered data counter */
|
||||
|
||||
#ifdef SCSI_LOW_SUPPORT_USER_MSGOUT
|
||||
u_int8_t msgout[SCSI_LOW_MAX_MSGLEN]; /* scsi msgout */
|
||||
u_int msgoutlen;
|
||||
#endif /* SCSI_LOW_SUPPORT_USER_MSGOUT */
|
||||
/*****************************************
|
||||
* Msgout
|
||||
*****************************************/
|
||||
u_int ccb_msgoutflag;
|
||||
u_int ccb_omsgoutflag;
|
||||
|
||||
/*****************************************
|
||||
* Error or Timeout counters
|
||||
*****************************************/
|
||||
u_int ccb_flags;
|
||||
#define CCB_SENSE 0x01
|
||||
#define CCB_INTERNAL 0x0001
|
||||
#define CCB_SENSE 0x0002
|
||||
#define CCB_CLEARQ 0x0004
|
||||
#define CCB_DISCQ 0x0008
|
||||
#define CCB_STARTQ 0x0010
|
||||
#define CCB_POLLED 0x0100 /* polling ccb */
|
||||
#define CCB_NORETRY 0x0200 /* do NOT retry */
|
||||
#define CCB_AUTOSENSE 0x0400 /* do a sence after CA */
|
||||
#define CCB_URGENT 0x0800 /* an urgent ccb */
|
||||
#define CCB_NOSDONE 0x1000 /* do not call an os done routine */
|
||||
#define CCB_SCSIIO 0x2000 /* a normal scsi io coming from upper layer */
|
||||
#define CCB_SILENT 0x4000 /* no terminate messages */
|
||||
|
||||
u_int ccb_error;
|
||||
|
||||
int ccb_rcnt; /* retry counter */
|
||||
int ccb_selrcnt; /* selection retry counter */
|
||||
int ccb_tc; /* timer counter */
|
||||
int ccb_tcmax; /* max timeout */
|
||||
|
||||
/*****************************************
|
||||
* Sense data buffer
|
||||
*****************************************/
|
||||
#ifdef __NetBSD__
|
||||
struct scsipi_sense ccb_sense_cmd;
|
||||
struct scsipi_sense_data ccb_sense;
|
||||
#endif
|
||||
#ifdef __FreeBSD__
|
||||
struct scsi_sense ccb_sense_cmd;
|
||||
struct scsi_sense_data ccb_sense;
|
||||
#endif
|
||||
u_int8_t ccb_scsi_cmd[12];
|
||||
scsi_low_osdep_sense_data_t ccb_sense;
|
||||
};
|
||||
|
||||
/* ccb assert */
|
||||
#ifdef __NetBSD__
|
||||
#include <dev/isa/ccbque.h>
|
||||
#endif
|
||||
#ifdef __FreeBSD__
|
||||
#include <i386/isa/ccbque.h>
|
||||
#endif
|
||||
/*************************************************
|
||||
* Slccb functions
|
||||
*************************************************/
|
||||
GENERIC_CCB_ASSERT(scsi_low, slccb)
|
||||
|
||||
/*************************************************
|
||||
* Target structures
|
||||
* Target and Lun structures
|
||||
*************************************************/
|
||||
struct scsi_low_softc;
|
||||
LIST_HEAD(scsi_low_softc_tab, scsi_low_softc);
|
||||
TAILQ_HEAD(targ_info_tab, targ_info);
|
||||
LIST_HEAD(lun_info_tab, lun_info);
|
||||
|
||||
struct lun_info {
|
||||
struct scsi_low_osdep_lun_interface li_sloi;
|
||||
|
||||
int li_lun;
|
||||
struct targ_info *li_ti; /* my target */
|
||||
|
||||
LIST_ENTRY(lun_info) lun_chain; /* targ_info link */
|
||||
|
||||
int li_disc; /* num disconnects */
|
||||
struct slccbtab li_discq; /* disconnect queue */
|
||||
|
||||
/*
|
||||
* qtag control
|
||||
*/
|
||||
int li_maxnexus;
|
||||
int li_maxnqio;
|
||||
int li_nqio;
|
||||
int li_disc;
|
||||
|
||||
#define SCSI_LOW_MAXNEXUS (sizeof(u_int) * NBBY)
|
||||
u_int li_qtagbits;
|
||||
|
||||
#ifdef SCSI_LOW_ALT_QTAG_ALLOCATE
|
||||
u_int8_t li_qtagarray[SCSI_LOW_MAXNEXUS];
|
||||
u_int li_qd;
|
||||
#endif /* SCSI_LOW_ALT_QTAG_ALLOCATE */
|
||||
|
||||
#define SCSI_LOW_QFLAG_CA_QCLEAR 0x01
|
||||
u_int li_qflags;
|
||||
|
||||
/*
|
||||
* lun state
|
||||
*/
|
||||
#define UNIT_SLEEP 0x00
|
||||
#define UNIT_START 0x01
|
||||
#define UNIT_SYNCH 0x02
|
||||
#define UNIT_WIDE 0x03
|
||||
#define UNIT_OK 0x04
|
||||
#define UNIT_NEGSTART UNIT_SYNCH
|
||||
#define SCSI_LOW_LUN_SLEEP 0x00
|
||||
#define SCSI_LOW_LUN_START 0x01
|
||||
#define SCSI_LOW_LUN_INQ 0x02
|
||||
#define SCSI_LOW_LUN_MODEQ 0x03
|
||||
#define SCSI_LOW_LUN_OK 0x04
|
||||
u_int li_state; /* target lun state */
|
||||
u_int li_maxstate; /* max state */
|
||||
|
||||
/*
|
||||
* lun control flags
|
||||
*/
|
||||
u_int li_flags; /* real control flags */
|
||||
u_int li_cfgflags; /* given target cfgflags */
|
||||
u_int li_quirks; /* given target quirk */
|
||||
u_int li_flags_valid; /* valid flags */
|
||||
#define SCSI_LOW_LUN_FLAGS_USER_VALID 0x0001
|
||||
#define SCSI_LOW_LUN_FLAGS_DISK_VALID 0x0002
|
||||
#define SCSI_LOW_LUN_FLAGS_QUIRKS_VALID 0x0004
|
||||
#define SCSI_LOW_LUN_FLAGS_ALL_VALID \
|
||||
(SCSI_LOW_LUN_FLAGS_USER_VALID | \
|
||||
SCSI_LOW_LUN_FLAGS_DISK_VALID | SCSI_LOW_LUN_FLAGS_QUIRKS_VALID)
|
||||
|
||||
u_int li_flags; /* real lun control flags */
|
||||
u_int li_cfgflags; /* lun control flags given by user */
|
||||
u_int li_diskflags; /* lun control flags given by hardware info */
|
||||
u_int li_quirks; /* lun control flags given by upper layer */
|
||||
|
||||
/* inq buffer */
|
||||
struct scsi_low_inq_data {
|
||||
u_int8_t sd_type;
|
||||
u_int8_t sd_sp1;
|
||||
u_int8_t sd_version;
|
||||
u_int8_t sd_resp;
|
||||
u_int8_t sd_len;
|
||||
u_int8_t sd_sp2[2];
|
||||
u_int8_t sd_support;
|
||||
} __attribute__((packed)) li_inq;
|
||||
|
||||
/* modeq buffer */
|
||||
struct scsi_low_mode_sense_data {
|
||||
u_int8_t sms_header[4];
|
||||
struct {
|
||||
u_int8_t cmp_page;
|
||||
u_int8_t cmp_length;
|
||||
u_int8_t cmp_rlec;
|
||||
u_int8_t cmp_qc;
|
||||
u_int8_t cmp_eca;
|
||||
u_int8_t cmp_spare[3];
|
||||
} __attribute__((packed)) sms_cmp;
|
||||
|
||||
} li_sms;
|
||||
};
|
||||
|
||||
struct scsi_low_msg_log {
|
||||
int slml_ptr;
|
||||
struct {
|
||||
u_int8_t msg[2];
|
||||
} slml_msg[SCSI_LOW_MSG_LOG_DATALEN];
|
||||
};
|
||||
|
||||
struct targ_info {
|
||||
struct scsi_low_osdep_targ_interface ti_slti;
|
||||
|
||||
TAILQ_ENTRY(targ_info) ti_chain; /* targ_info link */
|
||||
|
||||
struct scsi_low_softc *ti_sc; /* our softc */
|
||||
@ -237,21 +399,13 @@ struct targ_info {
|
||||
struct lun_info_tab ti_litab; /* lun chain */
|
||||
|
||||
/*
|
||||
* Nexus
|
||||
* total disconnected nexus
|
||||
*/
|
||||
struct slccb *ti_nexus; /* current nexus */
|
||||
struct lun_info *ti_li; /* current nexus lun_info */
|
||||
|
||||
/*
|
||||
* Target status
|
||||
*/
|
||||
#define TARG_ASSERT_ATN 0x01
|
||||
u_int ti_tflags; /* target state I */
|
||||
int ti_disc;
|
||||
|
||||
/*
|
||||
* Scsi phase control
|
||||
*/
|
||||
struct slccbtab ti_discq; /* disconnect queue */
|
||||
|
||||
#define PH_NULL 0x00
|
||||
#define PH_ARBSTART 0x01
|
||||
@ -267,24 +421,13 @@ struct targ_info {
|
||||
u_int ti_phase; /* scsi phase */
|
||||
u_int ti_ophase; /* old scsi phase */
|
||||
|
||||
/*
|
||||
* Status in
|
||||
*/
|
||||
u_int8_t ti_status; /* status in */
|
||||
|
||||
/*
|
||||
* Msg in
|
||||
*/
|
||||
u_int ti_msginptr; /* msgin ptr */
|
||||
u_int ti_msginlen; /* expected msg length */
|
||||
int ti_msgin_parity_error; /* parity error detected */
|
||||
u_int8_t ti_msgin[SCSI_LOW_MAX_MSGLEN]; /* msgin buffer */
|
||||
u_int ti_sphase;
|
||||
|
||||
#ifdef SCSI_LOW_DIAGNOSTIC
|
||||
#define MSGIN_HISTORY_LEN 5
|
||||
u_int8_t ti_msgin_history[MSGIN_HISTORY_LEN];
|
||||
int ti_msgin_hist_pointer;
|
||||
#endif /* SCSI_LOW_DIAGNOSTIC */
|
||||
|
||||
/*
|
||||
* Msg out
|
||||
@ -293,15 +436,21 @@ struct targ_info {
|
||||
u_int ti_omsgflags; /* msgs asserted */
|
||||
u_int ti_emsgflags; /* a msg currently asserted */
|
||||
#define SCSI_LOW_MSG_RESET 0x00000001
|
||||
#define SCSI_LOW_MSG_ABORT 0x00000002
|
||||
#define SCSI_LOW_MSG_REJECT 0x00000004
|
||||
#define SCSI_LOW_MSG_PARITY 0x00000008
|
||||
#define SCSI_LOW_MSG_ERROR 0x00000010
|
||||
#define SCSI_LOW_MSG_IDENTIFY 0x00000020
|
||||
#define SCSI_LOW_MSG_SYNCH 0x00000040
|
||||
#define SCSI_LOW_MSG_WIDE 0x00000080
|
||||
#define SCSI_LOW_MSG_USER 0x00000100
|
||||
#define SCSI_LOW_MSG_NOOP 0x00000200
|
||||
#define SCSI_LOW_MSG_REJECT 0x00000002
|
||||
#define SCSI_LOW_MSG_PARITY 0x00000004
|
||||
#define SCSI_LOW_MSG_ERROR 0x00000008
|
||||
#define SCSI_LOW_MSG_IDENTIFY 0x00000010
|
||||
#define SCSI_LOW_MSG_ABORT 0x00000020
|
||||
#define SCSI_LOW_MSG_TERMIO 0x00000040
|
||||
#define SCSI_LOW_MSG_SIMPLE_QTAG 0x00000080
|
||||
#define SCSI_LOW_MSG_ORDERED_QTAG 0x00000100
|
||||
#define SCSI_LOW_MSG_HEAD_QTAG 0x00000200
|
||||
#define SCSI_LOW_MSG_ABORT_QTAG 0x00000400
|
||||
#define SCSI_LOW_MSG_CLEAR_QTAG 0x00000800
|
||||
#define SCSI_LOW_MSG_WIDE 0x00001000
|
||||
#define SCSI_LOW_MSG_SYNCH 0x00002000
|
||||
#define SCSI_LOW_MSG_NOOP 0x00004000
|
||||
#define SCSI_LOW_MSG_LAST 0x00008000
|
||||
#define SCSI_LOW_MSG_ALL 0xffffffff
|
||||
|
||||
/* msgout buffer */
|
||||
@ -309,75 +458,108 @@ struct targ_info {
|
||||
u_int ti_msgoutlen; /* msgout strlen */
|
||||
|
||||
/*
|
||||
* synch and wide data
|
||||
* target initialize msgout
|
||||
*/
|
||||
u_int ti_setup_msg; /* setup msgout requests */
|
||||
u_int ti_setup_msg_done;
|
||||
|
||||
/*
|
||||
* synch and wide data info
|
||||
*/
|
||||
u_int ti_flags_valid; /* valid flags */
|
||||
#define SCSI_LOW_TARG_FLAGS_USER_VALID 0x0001
|
||||
#define SCSI_LOW_TARG_FLAGS_DISK_VALID 0x0002
|
||||
#define SCSI_LOW_TARG_FLAGS_QUIRKS_VALID 0x0004
|
||||
#define SCSI_LOW_TARG_FLAGS_ALL_VALID \
|
||||
(SCSI_LOW_TARG_FLAGS_USER_VALID | \
|
||||
SCSI_LOW_TARG_FLAGS_DISK_VALID | SCSI_LOW_TARG_FLAGS_QUIRKS_VALID)
|
||||
|
||||
u_int ti_diskflags; /* given target disk flags */
|
||||
u_int ti_quirks; /* given target quirk */
|
||||
|
||||
struct synch {
|
||||
u_int8_t offset;
|
||||
u_int8_t period;
|
||||
} ti_maxsynch; /* synch data */
|
||||
} ti_osynch, ti_maxsynch; /* synch data */
|
||||
|
||||
u_int ti_width;
|
||||
#define SCSI_LOW_BUS_WIDTH_8 0
|
||||
#define SCSI_LOW_BUS_WIDTH_16 1
|
||||
#define SCSI_LOW_BUS_WIDTH_32 2
|
||||
u_int ti_owidth, ti_width;
|
||||
|
||||
/*
|
||||
* lun info size.
|
||||
*/
|
||||
int ti_lunsize;
|
||||
|
||||
#ifdef SCSI_LOW_DIAGNOSTIC
|
||||
struct scsi_low_msg_log ti_log_msgout;
|
||||
struct scsi_low_msg_log ti_log_msgin;
|
||||
#endif /* SCSI_LOW_DIAGNOSTIC */
|
||||
};
|
||||
|
||||
/*************************************************
|
||||
* COMMON HEADER STRUCTURE
|
||||
*************************************************/
|
||||
struct scsi_low_softc;
|
||||
struct proc;
|
||||
typedef struct scsi_low_softc *sc_low_t;
|
||||
|
||||
#define SCSI_LOW_START_OK 0
|
||||
#define SCSI_LOW_START_FAIL 1
|
||||
#define SCSI_LOW_INFO_ALLOC 0
|
||||
#define SCSI_LOW_INFO_REVOKE 1
|
||||
#define SCSI_LOW_INFO_DEALLOC 2
|
||||
#define SCSI_LOW_POWDOWN 1
|
||||
#define SCSI_LOW_ENGAGE 2
|
||||
|
||||
#define SC_LOW_INIT_T (int (*) __P((sc_low_t, int)))
|
||||
#define SC_LOW_BUSRST_T (void (*) __P((sc_low_t)))
|
||||
#define SC_LOW_TARG_INIT_T (int (*) __P((sc_low_t, struct targ_info *)))
|
||||
#define SC_LOW_TARG_INIT_T (int (*) __P((sc_low_t, struct targ_info *, int)))
|
||||
#define SC_LOW_LUN_INIT_T (int (*) __P((sc_low_t, struct targ_info *, struct lun_info *, int)))
|
||||
#define SC_LOW_SELECT_T (int (*) __P((sc_low_t, struct slccb *)))
|
||||
#define SC_LOW_ATTEN_T (void (*) __P((sc_low_t)))
|
||||
#define SC_LOW_NEXUS_T (int (*) __P((sc_low_t, struct targ_info *)))
|
||||
#define SC_LOW_NEXUS_T (int (*) __P((sc_low_t)))
|
||||
#define SC_LOW_MSG_T (int (*) __P((sc_low_t, struct targ_info *, u_int)))
|
||||
#define SC_LOW_POLL_T (int (*) __P((void *)))
|
||||
#define SC_LOW_POWER_T (int (*) __P((sc_low_t, u_int)))
|
||||
#define SC_LOW_TIMEOUT_T (int (*) __P((sc_low_t)))
|
||||
|
||||
struct scsi_low_funcs {
|
||||
int (*scsi_low_init) __P((sc_low_t, int));
|
||||
void (*scsi_low_bus_reset) __P((sc_low_t));
|
||||
int (*scsi_low_targ_init) __P((sc_low_t, struct targ_info *));
|
||||
|
||||
int (*scsi_low_targ_init) __P((sc_low_t, struct targ_info *, int));
|
||||
int (*scsi_low_lun_init) __P((sc_low_t, struct targ_info *, struct lun_info *, int));
|
||||
int (*scsi_low_start_bus) __P((sc_low_t, struct slccb *));
|
||||
int (*scsi_low_establish_nexus) __P((sc_low_t, struct targ_info *));
|
||||
|
||||
int (*scsi_low_establish_lun_nexus) __P((sc_low_t));
|
||||
int (*scsi_low_establish_ccb_nexus) __P((sc_low_t));
|
||||
void (*scsi_low_attention) __P((sc_low_t));
|
||||
int (*scsi_low_msg) __P((sc_low_t, struct targ_info *, u_int));
|
||||
|
||||
int (*scsi_low_timeout) __P((sc_low_t));
|
||||
int (*scsi_low_poll) __P((void *));
|
||||
|
||||
#define SCSI_LOW_POWDOWN 1
|
||||
#define SCSI_LOW_ENGAGE 2
|
||||
int (*scsi_low_power) __P((sc_low_t, u_int));
|
||||
int (*scsi_low_ioctl) __P((sc_low_t, u_long, caddr_t, int, struct proc *));
|
||||
};
|
||||
|
||||
/*************************************************
|
||||
* SCSI LOW SOFTC
|
||||
*************************************************/
|
||||
struct scsi_low_softc {
|
||||
DEVPORT_DEVICE sl_dev;
|
||||
/* os depend structure */
|
||||
struct scsi_low_osdep_interface sl_si;
|
||||
#define sl_dev sl_si.si_dev
|
||||
struct scsi_low_osdep_funcs *sl_osdep_fp;
|
||||
u_char sl_xname[16];
|
||||
|
||||
/* upper interface */
|
||||
#ifdef CAM
|
||||
struct cam_sim *sim;
|
||||
struct cam_path *path;
|
||||
#else
|
||||
struct scsipi_link sl_link;
|
||||
#endif
|
||||
/* our chain */
|
||||
LIST_ENTRY(scsi_low_softc) sl_chain;
|
||||
|
||||
/* my targets */
|
||||
struct targ_info *sl_ti[SCSI_LOW_NTARGETS];
|
||||
struct targ_info_tab sl_titab;
|
||||
|
||||
/* current active nexus */
|
||||
/* current active T_L_Q nexus */
|
||||
struct targ_info *sl_Tnexus; /* Target nexus */
|
||||
struct lun_info *sl_Lnexus; /* Lun nexus */
|
||||
struct slccb *sl_Qnexus; /* Qtag nexus */
|
||||
int sl_nexus_call;
|
||||
struct targ_info *sl_nexus;
|
||||
|
||||
/* ccb start queue */
|
||||
struct slccbtab sl_start;
|
||||
@ -385,29 +567,45 @@ struct scsi_low_softc {
|
||||
/* retry limit and phase change counter */
|
||||
int sl_max_retry;
|
||||
int sl_ph_count;
|
||||
int sl_timeout_count;
|
||||
|
||||
/* selection & total num disconnect targets */
|
||||
int sl_nio;
|
||||
int sl_disc;
|
||||
struct targ_info *sl_selid;
|
||||
int sl_retry_sel;
|
||||
struct slccb *sl_selid;
|
||||
|
||||
/* scsi phased suggested by scsi msg */
|
||||
/* attention */
|
||||
int sl_atten; /* ATN asserted */
|
||||
int sl_clear_atten; /* negate ATN required */
|
||||
|
||||
/* scsi phase suggested by scsi msg */
|
||||
u_int sl_msgphase;
|
||||
#define MSGPH_NULL 0x00 /* no msg */
|
||||
#define MSGPH_DISC 0x01 /* disconnect msg */
|
||||
#define MSGPH_CMDC 0x02 /* cmd complete msg */
|
||||
#define MSGPH_ABORT 0x03 /* abort seq */
|
||||
#define MSGPH_TERM 0x04 /* current io terminate */
|
||||
#define MSGPH_LCTERM 0x05 /* cmd link terminated */
|
||||
#define MSGPH_RESET 0x06 /* reset target */
|
||||
|
||||
/* error */
|
||||
#define FATALIO 0x01 /* generic io error & retry io */
|
||||
#define ABORTIO 0x02 /* generic io error & terminate io */
|
||||
#define TIMEOUTIO 0x04 /* watch dog timeout */
|
||||
#define SELTIMEOUTIO 0x08 /* selection timeout */
|
||||
#define PDMAERR 0x10 /* dma xfer error */
|
||||
#define MSGERR 0x20 /* msgsys error */
|
||||
#define PARITYERR 0x40 /* parity error */
|
||||
#define BUSYERR 0x80 /* target busy error */
|
||||
#define CMDREJECT 0x100 /* cmd reject error */
|
||||
#define SCSI_LOW_ERRORBITS "\020\009cmdrej\008busy\007parity\006msgerr\005pdmaerr\004seltimeout\003timeout\002abort\001fatal"
|
||||
u_int sl_error; /* error flags */
|
||||
u_int sl_error; /* error flags */
|
||||
#define FATALIO 0x0001 /* generic io error & retry io */
|
||||
#define ABORTIO 0x0002 /* generic io error & terminate io */
|
||||
#define TIMEOUTIO 0x0004 /* watch dog timeout */
|
||||
#define SELTIMEOUTIO 0x0008 /* selection timeout */
|
||||
#define PDMAERR 0x0010 /* dma xfer error */
|
||||
#define MSGERR 0x0020 /* msgsys error */
|
||||
#define PARITYERR 0x0040 /* parity error */
|
||||
#define BUSYERR 0x0080 /* target busy error */
|
||||
#define STATERR 0x0100 /* status error */
|
||||
#define UACAERR 0x0200 /* target CA state, no sense check */
|
||||
#define SENSEIO 0x1000 /* cmd not excuted but sense data ok */
|
||||
#define SENSEERR 0x2000 /* cmd not excuted and sense data bad */
|
||||
#define UBFERR 0x4000 /* unexpected bus free */
|
||||
#define PENDINGIO 0x8000 /* ccb start not yet */
|
||||
#define SCSI_LOW_ERRORBITS "\020\017ubferr\016senseerr\015senseio\012uacaerr\011staterr\010busy\007parity\006msgerr\005pdmaerr\004seltimeout\003timeout\002abort\001fatal"
|
||||
|
||||
/* current scsi data pointer */
|
||||
struct sc_p sl_scp;
|
||||
@ -419,18 +617,28 @@ struct scsi_low_softc {
|
||||
|
||||
/* configuration flags */
|
||||
u_int sl_flags;
|
||||
#define HW_POWDOWN 0x01
|
||||
#define HW_RESUME 0x02
|
||||
#define HW_PDMASTART 0x04
|
||||
#define HW_INACTIVE 0x08
|
||||
#define HW_POWERCTRL 0x10
|
||||
#define HW_POWDOWN 0x0001
|
||||
#define HW_RESUME 0x0002
|
||||
#define HW_PDMASTART 0x0004
|
||||
#define HW_INACTIVE 0x0008
|
||||
#define HW_POWERCTRL 0x0010
|
||||
#define HW_INITIALIZING 0x0020
|
||||
#define HW_READ_PADDING 0x1000
|
||||
#define HW_WRITE_PADDING 0x2000
|
||||
|
||||
u_int sl_cfgflags;
|
||||
#define CFG_NODISC 0x01
|
||||
#define CFG_NOPARITY 0x02
|
||||
#define CFG_NOATTEN 0x04
|
||||
#define CFG_ASYNC 0x08
|
||||
#define CFG_MSGUNIFY 0x10
|
||||
#define CFG_NODISC 0x0001
|
||||
#define CFG_NOPARITY 0x0002
|
||||
#define CFG_NOATTEN 0x0004
|
||||
#define CFG_ASYNC 0x0008
|
||||
#define CFG_NOQTAG 0x0010
|
||||
|
||||
int sl_show_result;
|
||||
#define SHOW_SYNCH_NEG 0x0001
|
||||
#define SHOW_WIDE_NEG 0x0002
|
||||
#define SHOW_CALCF_RES 0x0010
|
||||
#define SHOW_PROBE_RES 0x0020
|
||||
#define SHOW_ALL_NEG -1
|
||||
|
||||
/* host informations */
|
||||
u_int sl_hostid;
|
||||
@ -441,16 +649,12 @@ struct scsi_low_softc {
|
||||
/* interface functions */
|
||||
struct scsi_low_funcs *sl_funcs;
|
||||
|
||||
#if defined(__i386__)
|
||||
/* targinfo size */
|
||||
int sl_targsize;
|
||||
|
||||
#if defined(i386) || defined(__i386__)
|
||||
u_int sl_irq; /* XXX */
|
||||
#endif /* i386 */
|
||||
#ifdef __FreeBSD__
|
||||
struct callout_handle engage_ch;
|
||||
struct callout_handle timeout_ch;
|
||||
#ifdef SCSI_LOW_POWFUNC
|
||||
struct callout_handle recover_ch;
|
||||
#endif
|
||||
#endif /* __FreeBSD__ */
|
||||
};
|
||||
|
||||
/*************************************************
|
||||
@ -459,26 +663,49 @@ struct scsi_low_softc {
|
||||
/*
|
||||
* Scsi low attachment function.
|
||||
*/
|
||||
int scsi_low_attach __P((struct scsi_low_softc *, int, int, int, int));
|
||||
int scsi_low_attach __P((struct scsi_low_softc *, int, int, int, int, int));
|
||||
int scsi_low_dettach __P((struct scsi_low_softc *));
|
||||
|
||||
/*
|
||||
* Scsi low interface activate or deactivate functions
|
||||
*/
|
||||
int scsi_low_is_busy __P((struct scsi_low_softc *));
|
||||
int scsi_low_activate __P((struct scsi_low_softc *));
|
||||
int scsi_low_deactivate __P((struct scsi_low_softc *));
|
||||
|
||||
/*
|
||||
* Scsi phase "bus service" functions.
|
||||
* These functions are corresponding to each scsi bus phaeses.
|
||||
*/
|
||||
/* nexus abort (selection failed) */
|
||||
void scsi_low_clear_nexus __P((struct scsi_low_softc *, struct targ_info *));
|
||||
/* bus idle phase (other initiators or targets release bus) */
|
||||
void scsi_low_bus_idle __P((struct scsi_low_softc *));
|
||||
|
||||
/* arbitration and selection phase */
|
||||
void scsi_low_arbit_fail __P((struct scsi_low_softc *, struct slccb *));
|
||||
static __inline void scsi_low_arbit_win __P((struct scsi_low_softc *));
|
||||
|
||||
/* msgout phase */
|
||||
int scsi_low_msgout __P((struct scsi_low_softc *, struct targ_info *));
|
||||
#define SCSI_LOW_MSGOUT_INIT 0x00000001
|
||||
#define SCSI_LOW_MSGOUT_UNIFY 0x00000002
|
||||
int scsi_low_msgout __P((struct scsi_low_softc *, struct targ_info *, u_int));
|
||||
|
||||
/* msgin phase */
|
||||
void scsi_low_msgin __P((struct scsi_low_softc *, struct targ_info *, u_int8_t));
|
||||
#define SCSI_LOW_DATA_PE 0x80000000
|
||||
int scsi_low_msgin __P((struct scsi_low_softc *, struct targ_info *, u_int));
|
||||
|
||||
/* statusin phase */
|
||||
static __inline int scsi_low_statusin __P((struct scsi_low_softc *, struct targ_info *, u_int));
|
||||
|
||||
/* data phase */
|
||||
int scsi_low_data __P((struct scsi_low_softc *, struct targ_info *, struct buf **, int));
|
||||
static __inline void scsi_low_data_finish __P((struct scsi_low_softc *));
|
||||
|
||||
/* cmd phase */
|
||||
int scsi_low_cmd __P((struct scsi_low_softc *, struct targ_info *));
|
||||
|
||||
/* reselection phase */
|
||||
struct targ_info *scsi_low_reselected __P((struct scsi_low_softc *, u_int));
|
||||
|
||||
/* disconnection phase */
|
||||
int scsi_low_disconnected __P((struct scsi_low_softc *, struct targ_info *));
|
||||
|
||||
@ -495,52 +722,70 @@ int scsi_low_restart __P((struct scsi_low_softc *, int, u_char *));
|
||||
*/
|
||||
/* print current status */
|
||||
void scsi_low_print __P((struct scsi_low_softc *, struct targ_info *));
|
||||
/* timeout utility (only in used scsi_low_pisa) */
|
||||
void scsi_low_timeout __P((void *));
|
||||
#define SCSI2_RESET_DELAY 5000000
|
||||
#define TWIDDLEWAIT 10000
|
||||
|
||||
/* bus reset utility */
|
||||
void scsi_low_bus_reset __P((struct scsi_low_softc *));
|
||||
|
||||
/*************************************************
|
||||
* Inline utility
|
||||
* Message macro defs
|
||||
*************************************************/
|
||||
static __inline u_int8_t scsi_low_identify __P((struct targ_info *ti));
|
||||
static __inline void scsi_low_attention __P((struct scsi_low_softc *, struct targ_info *));
|
||||
static __inline int scsi_low_is_msgout_continue __P((struct targ_info *));
|
||||
#define SCSI_LOW_SETUP_PHASE(ti, phase) \
|
||||
{ \
|
||||
(ti)->ti_ophase = ti->ti_phase; \
|
||||
(ti)->ti_phase = (phase); \
|
||||
}
|
||||
|
||||
#define SCSI_LOW_SETUP_MSGPHASE(slp, PHASE) \
|
||||
{ \
|
||||
(slp)->sl_msgphase = (PHASE); \
|
||||
}
|
||||
|
||||
#define SCSI_LOW_ASSERT_ATN(slp) \
|
||||
{ \
|
||||
(slp)->sl_atten = 1; \
|
||||
}
|
||||
|
||||
#define SCSI_LOW_DEASSERT_ATN(slp) \
|
||||
{ \
|
||||
(slp)->sl_atten = 0; \
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
* Inline functions
|
||||
*************************************************/
|
||||
static __inline void scsi_low_attention __P((struct scsi_low_softc *));
|
||||
static __inline int scsi_low_is_msgout_continue __P((struct targ_info *, u_int));
|
||||
static __inline int scsi_low_assert_msg __P((struct scsi_low_softc *, struct targ_info *, u_int, int));
|
||||
static __inline void scsi_low_arbit_win __P((struct scsi_low_softc *, struct targ_info *));
|
||||
static __inline int scsi_low_is_disconnect_ok __P((struct slccb *));
|
||||
|
||||
static __inline int
|
||||
scsi_low_is_msgout_continue(ti)
|
||||
scsi_low_is_msgout_continue(ti, mask)
|
||||
struct targ_info *ti;
|
||||
u_int mask;
|
||||
{
|
||||
|
||||
return (ti->ti_msgflags != 0);
|
||||
return ((ti->ti_msgflags & (~mask)) != 0);
|
||||
}
|
||||
|
||||
static __inline u_int8_t
|
||||
scsi_low_identify(ti)
|
||||
struct targ_info *ti;
|
||||
static __inline int
|
||||
scsi_low_is_disconnect_ok(cb)
|
||||
struct slccb *cb;
|
||||
{
|
||||
u_int8_t msg;
|
||||
struct lun_info *li = ti->ti_li;
|
||||
|
||||
msg = (li->li_flags & SCSI_LOW_DISC) ? 0xc0 : 0x80;
|
||||
msg |= li->li_lun;
|
||||
return msg;
|
||||
return ((cb->li->li_flags & SCSI_LOW_DISC) != 0 &&
|
||||
(cb->ccb_flags & (CCB_SENSE | CCB_CLEARQ)) == 0);
|
||||
}
|
||||
|
||||
#define ID_MSG_SETUP(ti) (scsi_low_identify(ti))
|
||||
|
||||
static __inline void
|
||||
scsi_low_attention(slp, ti)
|
||||
scsi_low_attention(slp)
|
||||
struct scsi_low_softc *slp;
|
||||
struct targ_info *ti;
|
||||
{
|
||||
|
||||
if (slp->sl_atten != 0)
|
||||
return;
|
||||
|
||||
(*slp->sl_funcs->scsi_low_attention) (slp);
|
||||
SCSI_LOW_TARGET_ASSERT_ATN(slp);
|
||||
SCSI_LOW_ASSERT_ATN(slp);
|
||||
}
|
||||
|
||||
static __inline int
|
||||
@ -553,19 +798,46 @@ scsi_low_assert_msg(slp, ti, msg, now)
|
||||
|
||||
ti->ti_msgflags |= msg;
|
||||
if (now != 0)
|
||||
scsi_low_attention(slp, ti);
|
||||
scsi_low_attention(slp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static __inline void
|
||||
scsi_low_arbit_win(slp, ti)
|
||||
scsi_low_arbit_win(slp)
|
||||
struct scsi_low_softc *slp;
|
||||
struct targ_info *ti;
|
||||
{
|
||||
|
||||
slp->sl_selid = NULL;
|
||||
}
|
||||
|
||||
static __inline void
|
||||
scsi_low_data_finish(slp)
|
||||
struct scsi_low_softc *slp;
|
||||
{
|
||||
|
||||
if (slp->sl_Qnexus != NULL)
|
||||
{
|
||||
slp->sl_Qnexus->ccb_datalen = slp->sl_scp.scp_datalen;
|
||||
}
|
||||
}
|
||||
|
||||
static __inline int
|
||||
scsi_low_statusin(slp, ti, c)
|
||||
struct scsi_low_softc *slp;
|
||||
struct targ_info *ti;
|
||||
u_int c;
|
||||
{
|
||||
|
||||
slp->sl_ph_count ++;
|
||||
if ((c & SCSI_LOW_DATA_PE) != 0)
|
||||
{
|
||||
scsi_low_assert_msg(slp, ti, SCSI_LOW_MSG_ERROR, 0);
|
||||
return EIO;
|
||||
}
|
||||
slp->sl_scp.scp_status = (u_int8_t) c;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
* Message out defs
|
||||
*************************************************/
|
||||
@ -577,7 +849,9 @@ scsi_low_arbit_win(slp, ti)
|
||||
#define ST_INTERGOOD 0x10
|
||||
#define ST_INTERMET 0x14
|
||||
#define ST_CONFLICT 0x18
|
||||
#define ST_CMDTERM 0x22
|
||||
#define ST_QUEFULL 0x28
|
||||
#define ST_UNKNOWN 0xff
|
||||
|
||||
#define MSG_COMP 0x00
|
||||
#define MSG_EXTEND 0x01
|
||||
@ -601,10 +875,12 @@ scsi_low_arbit_win(slp, ti)
|
||||
#define MSG_LCOMP 0x0a
|
||||
#define MSG_LCOMP_F 0x0b
|
||||
#define MSG_RESET 0x0c
|
||||
#ifdef __FreeBSD__
|
||||
#undef MSG_IDENTIFY
|
||||
#endif
|
||||
#define MSG_IDENTIFY 0x80
|
||||
|
||||
#define OS_DEPEND(s) (s)
|
||||
#define MSG_ABORT_QTAG 0x0d
|
||||
#define MSG_CLEAR_QTAG 0x0e
|
||||
#define MSG_TERM_IO 0x11
|
||||
#define MSG_SIMPLE_QTAG 0x20
|
||||
#define MSG_HEAD_QTAG 0x21
|
||||
#define MSG_ORDERED_QTAG 0x22
|
||||
#define MSG_IDENTIFY 0x80
|
||||
#define MSG_IDENTIFY_DISCPRIV 0x40
|
||||
#endif /* !_SCSI_LOW_H_ */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NecBSD: scsi_low_pisa.c,v 1.13 1998/11/26 14:26:11 honda Exp $ */
|
||||
/* $NecBSD: scsi_low_pisa.c,v 1.13.18.1 2001/06/08 06:27:48 honda Exp $ */
|
||||
/* $NetBSD$ */
|
||||
|
||||
/*
|
||||
@ -33,25 +33,16 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __NetBSD__
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#ifdef __NetBSD__
|
||||
#include <sys/disklabel.h>
|
||||
#endif
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version >= 500001
|
||||
#include <sys/bio.h>
|
||||
#endif
|
||||
#include <sys/buf.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/device_port.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/errno.h>
|
||||
|
||||
#ifdef __NetBSD__
|
||||
#include <machine/bus.h>
|
||||
#include <machine/intr.h>
|
||||
#endif
|
||||
|
||||
#ifdef __NetBSD__
|
||||
#include <dev/isa/isareg.h>
|
||||
#include <dev/isa/isavar.h>
|
||||
|
||||
@ -68,93 +59,44 @@
|
||||
#include <i386/Cbus/dev/scsi_low_pisa.h>
|
||||
|
||||
#define SCSIBUS_RESCAN
|
||||
#else
|
||||
#ifdef __FreeBSD__
|
||||
#include <cam/scsi/scsi_low.h>
|
||||
#include <cam/scsi/scsi_low_pisa.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
int
|
||||
scsi_low_deactivate(struct scsi_low_softc *sc)
|
||||
{
|
||||
#else
|
||||
#ifdef __NetBSD__
|
||||
int
|
||||
scsi_low_deactivate(dh)
|
||||
scsi_low_deactivate_pisa(dh)
|
||||
pisa_device_handle_t dh;
|
||||
{
|
||||
struct scsi_low_softc *sc = PISA_DEV_SOFTC(dh);
|
||||
#endif
|
||||
#endif
|
||||
sc->sl_flags |= HW_INACTIVE;
|
||||
|
||||
#ifdef __NetBSD__
|
||||
#ifdef SCSI_LOW_POWFUNC
|
||||
untimeout(scsi_low_recover, sc);
|
||||
#endif /* SCSI_LOW_POWFUNC */
|
||||
untimeout(scsi_low_timeout, sc);
|
||||
#else
|
||||
#ifdef __FreeBSD__
|
||||
#ifdef SCSI_LOW_POWFUNC
|
||||
untimeout(scsi_low_recover, sc, sc->recover_ch);
|
||||
#endif /* SCSI_LOW_POWFUNC */
|
||||
untimeout(scsi_low_timeout, sc, sc->timeout_ch);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (scsi_low_deactivate(sc) != 0)
|
||||
return EBUSY;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
int
|
||||
scsi_low_activate(struct scsi_low_softc *sc, int flags)
|
||||
{
|
||||
#else
|
||||
#ifdef __NetBSD__
|
||||
int
|
||||
scsi_low_activate(dh)
|
||||
scsi_low_activate_pisa(dh)
|
||||
pisa_device_handle_t dh;
|
||||
{
|
||||
struct scsi_low_softc *sc = PISA_DEV_SOFTC(dh);
|
||||
slot_device_res_t dr = PISA_RES_DR(dh);
|
||||
#endif
|
||||
#endif
|
||||
int error;
|
||||
|
||||
sc->sl_flags &= ~HW_INACTIVE;
|
||||
#ifdef __FreeBSD__
|
||||
sc->sl_cfgflags = ((sc->sl_cfgflags & 0xffff0000) |
|
||||
(flags & 0x00ff));
|
||||
#else /* __NetBSD__ */
|
||||
sc->sl_cfgflags = DVCFG_MKCFG(DVCFG_MAJOR(sc->sl_cfgflags), \
|
||||
DVCFG_MINOR(PISA_DR_DVCFG(dr)));
|
||||
sc->sl_irq = PISA_DR_IRQ(dr);
|
||||
#endif
|
||||
|
||||
if ((error = scsi_low_restart(sc, SCSI_LOW_RESTART_HARD, NULL)) != 0)
|
||||
{
|
||||
sc->sl_flags |= HW_INACTIVE;
|
||||
return error;
|
||||
}
|
||||
if (scsi_low_activate(sc) != 0)
|
||||
return EBUSY;
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
sc->timeout_ch =
|
||||
#endif
|
||||
timeout(scsi_low_timeout, sc, SCSI_LOW_TIMEOUT_CHECK_INTERVAL * hz);
|
||||
/* rescan the scsi bus */
|
||||
#ifdef SCSIBUS_RESCAN
|
||||
if (PISA_RES_EVENT(dh) == PISA_EVENT_INSERT &&
|
||||
TAILQ_FIRST(&sc->sl_start) == NULL)
|
||||
scsi_probe_busses((int) sc->sl_link.scsipi_scsi.scsibus, -1, -1);
|
||||
if (scsi_low_is_busy(sc) == 0 &&
|
||||
PISA_RES_EVENT(dh) == PISA_EVENT_INSERT)
|
||||
scsi_probe_busses((int) sc->sl_si.si_splp->scsipi_scsi.scsibus,
|
||||
-1, -1);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __NetBSD__
|
||||
int
|
||||
scsi_low_notify(dh, ev)
|
||||
scsi_low_notify_pisa(dh, ev)
|
||||
pisa_device_handle_t dh;
|
||||
pisa_event_t ev;
|
||||
{
|
||||
@ -163,7 +105,7 @@ scsi_low_notify(dh, ev)
|
||||
switch(ev)
|
||||
{
|
||||
case PISA_EVENT_QUERY_SUSPEND:
|
||||
if (TAILQ_FIRST(&sc->sl_start) != NULL)
|
||||
if (scsi_low_is_busy(sc) != 0)
|
||||
return SD_EVENT_STATUS_BUSY;
|
||||
break;
|
||||
|
||||
@ -172,4 +114,43 @@ scsi_low_notify(dh, ev)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif /* __NetBSD__ */
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#if __FreeBSD_version >= 500001
|
||||
#include <sys/bio.h>
|
||||
#endif
|
||||
#include <sys/buf.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/device_port.h>
|
||||
|
||||
#include <cam/scsi/scsi_low.h>
|
||||
#include <cam/scsi/scsi_low_pisa.h>
|
||||
|
||||
int
|
||||
scsi_low_deactivate_pisa(sc)
|
||||
struct scsi_low_softc *sc;
|
||||
{
|
||||
|
||||
if (scsi_low_deactivate(sc) != 0)
|
||||
return EBUSY;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
scsi_low_activate_pisa(sc, flags)
|
||||
struct scsi_low_softc *sc;
|
||||
int flags;
|
||||
{
|
||||
|
||||
sc->sl_cfgflags = ((sc->sl_cfgflags & 0xffff0000) |
|
||||
(flags & 0x00ff));
|
||||
|
||||
if (scsi_low_activate(sc) != 0)
|
||||
return EBUSY;
|
||||
return 0;
|
||||
}
|
||||
#endif /* __FreeBSD__ */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NecBSD: scsi_low_pisa.h,v 1.3 1999/04/15 01:35:57 kmatsuda Exp $ */
|
||||
/* $NecBSD: scsi_low_pisa.h,v 1.3.14.1 2001/06/08 06:27:49 honda Exp $ */
|
||||
/* $NetBSD$ */
|
||||
|
||||
/*
|
||||
@ -34,13 +34,14 @@
|
||||
#ifndef _SCSI_LOW_PISA_H_
|
||||
#define _SCSI_LOW_PISA_H_
|
||||
|
||||
#ifdef __NetBSD__
|
||||
int scsi_low_activate __P((pisa_device_handle_t));
|
||||
int scsi_low_deactivate __P((pisa_device_handle_t));
|
||||
int scsi_low_notify __P((pisa_device_handle_t, pisa_event_t));
|
||||
#endif
|
||||
#ifdef __FreeBSD__
|
||||
int scsi_low_activate __P((struct scsi_low_softc *, int));
|
||||
int scsi_low_deactivate __P((struct scsi_low_softc *));
|
||||
#endif
|
||||
#ifdef __NetBSD__
|
||||
int scsi_low_activate_pisa __P((pisa_device_handle_t));
|
||||
int scsi_low_deactivate_pisa __P((pisa_device_handle_t));
|
||||
int scsi_low_notify_pisa __P((pisa_device_handle_t, pisa_event_t));
|
||||
#endif /* __NetBSD__ */
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
int scsi_low_activate_pisa __P((struct scsi_low_softc *, int));
|
||||
int scsi_low_deactivate_pisa __P((struct scsi_low_softc *));
|
||||
#endif /* __FreeBSD__ */
|
||||
#endif /* !_SCSI_LOW_PISA_H_ */
|
||||
|
@ -188,6 +188,10 @@ NDGBPORTS opt_dgb.h
|
||||
SCSI_BOUNCE_SIZE opt_bs.h
|
||||
BS_TARG_SAFEMODE opt_bs.h
|
||||
|
||||
# ct driver options
|
||||
CT_USE_RELOCATE_OFFSET opt_ct.h
|
||||
CT_BUS_WEIGHT opt_ct.h
|
||||
|
||||
# npx options
|
||||
FPU_ERROR_BROKEN opt_npx.h
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NecBSD: bshw_machdep.c,v 1.8 1999/07/23 20:54:00 honda Exp $ */
|
||||
/* $NecBSD: bshw_machdep.c,v 1.8.12.6 2001/06/29 06:28:05 honda Exp $ */
|
||||
/* $NetBSD$ */
|
||||
|
||||
/*
|
||||
* [NetBSD for NEC PC-98 series]
|
||||
* Copyright (c) 1994, 1995, 1996, 1997, 1998, 1999
|
||||
* Copyright (c) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
|
||||
* NetBSD/pc98 porting staff. All rights reserved.
|
||||
*
|
||||
* Copyright (c) 1994, 1995, 1996, 1997, 1998, 1999
|
||||
* Copyright (c) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
|
||||
* Naofumi HONDA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -39,18 +39,19 @@
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/disklabel.h>
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version > 500001
|
||||
#include <sys/bio.h>
|
||||
#endif /* __ FreeBSD__ */
|
||||
#include <sys/buf.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/device_port.h>
|
||||
#include <sys/errno.h>
|
||||
|
||||
#include <vm/vm.h>
|
||||
#include <vm/pmap.h>
|
||||
|
||||
#ifdef __NetBSD__
|
||||
#include <sys/device.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
#include <machine/intr.h>
|
||||
|
||||
@ -66,6 +67,7 @@
|
||||
|
||||
#include <dev/ic/wd33c93reg.h>
|
||||
#include <i386/Cbus/dev/ct/ctvar.h>
|
||||
#include <i386/Cbus/dev/ct/ct_machdep.h>
|
||||
#include <i386/Cbus/dev/ct/bshwvar.h>
|
||||
#endif /* __NetBSD__ */
|
||||
|
||||
@ -73,7 +75,6 @@
|
||||
#include <machine/bus.h>
|
||||
#include <machine/clock.h>
|
||||
#include <machine/md_var.h>
|
||||
#include <machine/pmap.h>
|
||||
|
||||
#include <machine/dvcfg.h>
|
||||
#include <machine/physio_proc.h>
|
||||
@ -82,32 +83,50 @@
|
||||
|
||||
#include <dev/ic/wd33c93reg.h>
|
||||
#include <dev/ct/ctvar.h>
|
||||
#include <dev/ct/ct_machdep.h>
|
||||
#include <dev/ct/bshwvar.h>
|
||||
|
||||
#include <vm/pmap.h>
|
||||
#endif /* __FreeBSD__ */
|
||||
|
||||
#define BSHW_IO_CONTROL_FLAGS 0
|
||||
|
||||
u_int bshw_io_control = BSHW_IO_CONTROL_FLAGS;
|
||||
int bshw_data_read_bytes = 4096;
|
||||
int bshw_data_write_bytes = 4096;
|
||||
|
||||
/*********************************************************
|
||||
* OS dep part
|
||||
*********************************************************/
|
||||
#ifdef __NetBSD__
|
||||
#define BSHW_PAGE_SIZE NBPG
|
||||
#endif /* __NetBSD__ */
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#define BSHW_PAGE_SIZE PAGE_SIZE
|
||||
typedef unsigned long vaddr_t;
|
||||
#endif /* __FreeBSD__ */
|
||||
|
||||
/*********************************************************
|
||||
* GENERIC MACHDEP FUNCTIONS
|
||||
*********************************************************/
|
||||
void
|
||||
bshw_synch_setup(ct, li)
|
||||
bshw_synch_setup(ct, ti)
|
||||
struct ct_softc *ct;
|
||||
struct lun_info *li;
|
||||
struct targ_info *ti;
|
||||
{
|
||||
struct scsi_low_softc *slp = &ct->sc_sclow;
|
||||
struct targ_info *ti = slp->sl_nexus;
|
||||
bus_space_tag_t bst = ct->sc_iot;
|
||||
bus_space_handle_t bsh = ct->sc_ioh;
|
||||
struct ct_bus_access_handle *chp = &ct->sc_ch;
|
||||
struct ct_targ_info *cti = (void *) ti;
|
||||
struct bshw_softc *bs = ct->ct_hw;
|
||||
struct bshw *hw = bs->sc_hw;
|
||||
|
||||
if (hw->sregaddr == 0)
|
||||
if (hw->hw_sregaddr == 0)
|
||||
return;
|
||||
|
||||
ct_cr_write_1(bst, bsh, hw->sregaddr + ti->ti_id, cti->cti_syncreg);
|
||||
ct_cr_write_1(chp, hw->hw_sregaddr + ti->ti_id, cti->cti_syncreg);
|
||||
if (hw->hw_flags & BSHW_DOUBLE_DMACHAN)
|
||||
{
|
||||
ct_cr_write_1(bst, bsh, hw->sregaddr + ti->ti_id + 8,
|
||||
ct_cr_write_1(chp, hw->hw_sregaddr + ti->ti_id + 8,
|
||||
cti->cti_syncreg);
|
||||
}
|
||||
}
|
||||
@ -117,8 +136,7 @@ bshw_bus_reset(ct)
|
||||
struct ct_softc *ct;
|
||||
{
|
||||
struct scsi_low_softc *slp = &ct->sc_sclow;
|
||||
bus_space_tag_t bst = ct->sc_iot;
|
||||
bus_space_handle_t bsh = ct->sc_ioh;
|
||||
struct ct_bus_access_handle *chp = &ct->sc_ch;
|
||||
struct bshw_softc *bs = ct->ct_hw;
|
||||
struct bshw *hw = bs->sc_hw;
|
||||
bus_addr_t offs;
|
||||
@ -126,53 +144,52 @@ bshw_bus_reset(ct)
|
||||
int i;
|
||||
|
||||
/* open hardware busmaster mode */
|
||||
if (hw->dma_init != NULL && ((*hw->dma_init)(ct)) != 0)
|
||||
if (hw->hw_dma_init != NULL && ((*hw->hw_dma_init)(ct)) != 0)
|
||||
{
|
||||
printf("%s change mode using external DMA (%x)\n",
|
||||
slp->sl_xname, (u_int)ct_cr_read_1(bst, bsh, 0x37));
|
||||
printf("%s: change mode using external DMA (%x)\n",
|
||||
slp->sl_xname, (u_int)ct_cr_read_1(chp, 0x37));
|
||||
}
|
||||
|
||||
/* clear hardware synch registers */
|
||||
offs = hw->sregaddr;
|
||||
offs = hw->hw_sregaddr;
|
||||
if (offs != 0)
|
||||
{
|
||||
for (i = 0; i < 8; i ++, offs ++)
|
||||
{
|
||||
ct_cr_write_1(bst, bsh, offs, 0);
|
||||
ct_cr_write_1(chp, offs, 0);
|
||||
if ((hw->hw_flags & BSHW_DOUBLE_DMACHAN) != 0)
|
||||
ct_cr_write_1(bst, bsh, offs + 8, 0);
|
||||
ct_cr_write_1(chp, offs + 8, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* disable interrupt & assert reset */
|
||||
regv = ct_cr_read_1(bst, bsh, wd3s_mbank);
|
||||
regv = ct_cr_read_1(chp, wd3s_mbank);
|
||||
regv |= MBR_RST;
|
||||
regv &= ~MBR_IEN;
|
||||
ct_cr_write_1(bst, bsh, wd3s_mbank, regv);
|
||||
ct_cr_write_1(chp, wd3s_mbank, regv);
|
||||
|
||||
delay(500000);
|
||||
SCSI_LOW_DELAY(500000);
|
||||
|
||||
/* reset signal off */
|
||||
regv &= ~MBR_RST;
|
||||
ct_cr_write_1(bst, bsh, wd3s_mbank, regv);
|
||||
ct_cr_write_1(chp, wd3s_mbank, regv);
|
||||
|
||||
/* interrupt enable */
|
||||
regv |= MBR_IEN;
|
||||
ct_cr_write_1(bst, bsh, wd3s_mbank, regv);
|
||||
ct_cr_write_1(chp, wd3s_mbank, regv);
|
||||
}
|
||||
|
||||
/* probe */
|
||||
int
|
||||
bshw_read_settings(bst, bsh, bs)
|
||||
bus_space_tag_t bst;
|
||||
bus_space_handle_t bsh;
|
||||
bshw_read_settings(chp, bs)
|
||||
struct ct_bus_access_handle *chp;
|
||||
struct bshw_softc *bs;
|
||||
{
|
||||
static int irq_tbl[] = { 3, 5, 6, 9, 12, 13 };
|
||||
|
||||
bs->sc_hostid = (ct_cr_read_1(bst, bsh, wd3s_auxc) & AUXCR_HIDM);
|
||||
bs->sc_irq = irq_tbl[(ct_cr_read_1(bst, bsh, wd3s_auxc) >> 3) & 7];
|
||||
bs->sc_drq = bus_space_read_1(bst, bsh, cmd_port) & 3;
|
||||
bs->sc_hostid = (ct_cr_read_1(chp, wd3s_auxc) & AUXCR_HIDM);
|
||||
bs->sc_irq = irq_tbl[(ct_cr_read_1(chp, wd3s_auxc) >> 3) & 7];
|
||||
bs->sc_drq = ct_cmdp_read_1(chp) & 3;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -194,18 +211,17 @@ bshw_read_settings(bst, bsh, bs)
|
||||
#define SF_RDY 0x10
|
||||
|
||||
static __inline void bshw_lc_smit_start __P((struct ct_softc *, int, u_int));
|
||||
static int bshw_lc_smit_fstat __P((struct ct_softc *, int, int));
|
||||
static __inline void bshw_lc_smit_stop __P((struct ct_softc *));
|
||||
static int bshw_lc_smit_fstat __P((struct ct_softc *, int, int));
|
||||
|
||||
static __inline void
|
||||
bshw_lc_smit_stop(ct)
|
||||
struct ct_softc *ct;
|
||||
{
|
||||
bus_space_tag_t bst = ct->sc_iot;
|
||||
bus_space_handle_t bsh = ct->sc_ioh;
|
||||
struct ct_bus_access_handle *chp = &ct->sc_ch;
|
||||
|
||||
ct_cr_write_1(bst, bsh, BSHW_LC_FCTRL, 0);
|
||||
bus_space_write_1(ct->sc_iot, ct->sc_ioh, cmd_port, CMDP_DMER);
|
||||
ct_cr_write_1(chp, BSHW_LC_FCTRL, 0);
|
||||
ct_cmdp_write_1(chp, CMDP_DMER);
|
||||
}
|
||||
|
||||
static __inline void
|
||||
@ -214,18 +230,17 @@ bshw_lc_smit_start(ct, count, direction)
|
||||
int count;
|
||||
u_int direction;
|
||||
{
|
||||
bus_space_tag_t bst = ct->sc_iot;
|
||||
bus_space_handle_t bsh = ct->sc_ioh;
|
||||
struct ct_bus_access_handle *chp = &ct->sc_ch;
|
||||
u_int8_t pval, val;
|
||||
|
||||
val = ct_cr_read_1(bst, bsh, BSHW_LC_FSET);
|
||||
cthw_set_count(bst, bsh, count);
|
||||
val = ct_cr_read_1(chp, BSHW_LC_FSET);
|
||||
cthw_set_count(chp, count);
|
||||
|
||||
pval = FCTRL_EN;
|
||||
if (direction == SCSI_LOW_WRITE)
|
||||
pval |= (val & 0xe0) | FCTRL_WRITE;
|
||||
ct_cr_write_1(bst, bsh, BSHW_LC_FCTRL, pval);
|
||||
ct_cr_write_1(bst, bsh, wd3s_cmd, WD3S_TFR_INFO);
|
||||
ct_cr_write_1(chp, BSHW_LC_FCTRL, pval);
|
||||
ct_cr_write_1(chp, wd3s_cmd, WD3S_TFR_INFO);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -233,12 +248,13 @@ bshw_lc_smit_fstat(ct, wc, read)
|
||||
struct ct_softc *ct;
|
||||
int wc, read;
|
||||
{
|
||||
struct ct_bus_access_handle *chp = &ct->sc_ch;
|
||||
u_int8_t stat;
|
||||
|
||||
while (wc -- > 0)
|
||||
{
|
||||
outb(0x5f, 0);
|
||||
stat = bus_space_read_1(ct->sc_iot, ct->sc_ioh, cmd_port);
|
||||
chp->ch_bus_weight(chp);
|
||||
stat = ct_cmdp_read_1(chp);
|
||||
if (read == SCSI_LOW_READ)
|
||||
{
|
||||
if ((stat & SF_RDY) != 0)
|
||||
@ -268,68 +284,85 @@ bshw_smit_xfer_stop(ct)
|
||||
struct targ_info *ti;
|
||||
struct sc_p *sp = &slp->sl_scp;
|
||||
u_int count;
|
||||
u_char *s;
|
||||
|
||||
bshw_lc_smit_stop(ct);
|
||||
|
||||
ti = slp->sl_nexus;
|
||||
ti = slp->sl_Tnexus;
|
||||
if (ti == NULL)
|
||||
return;
|
||||
|
||||
if (ti->ti_phase == PH_DATA)
|
||||
{
|
||||
count = cthw_get_count(ct->sc_iot, ct->sc_ioh);
|
||||
if (count < (u_int) sp->scp_datalen)
|
||||
count = cthw_get_count(&ct->sc_ch);
|
||||
if (count < bs->sc_sdatalen)
|
||||
{
|
||||
sp->scp_data += (sp->scp_datalen - count);
|
||||
sp->scp_datalen = count;
|
||||
/* XXX:
|
||||
* strict double checks!
|
||||
* target => wd33c93c transfer counts
|
||||
* wd33c93c => memory transfer counts
|
||||
*/
|
||||
if (sp->scp_direction == SCSI_LOW_READ &&
|
||||
count != bs->sc_tdatalen)
|
||||
{
|
||||
s = "read count miss";
|
||||
count != bs->sc_edatalen)
|
||||
goto bad;
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (count == (u_int) sp->scp_datalen)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
s = "strange count";
|
||||
count = bs->sc_sdatalen - count;
|
||||
if (count > (u_int) sp->scp_datalen)
|
||||
goto bad;
|
||||
|
||||
sp->scp_data += count;
|
||||
sp->scp_datalen -= count;
|
||||
}
|
||||
else if (count > bs->sc_sdatalen)
|
||||
{
|
||||
bad:
|
||||
printf("%s: smit_xfer_end: cnt error\n", slp->sl_xname);
|
||||
slp->sl_error |= PDMAERR;
|
||||
}
|
||||
scsi_low_data_finish(slp);
|
||||
}
|
||||
else
|
||||
s = "extra smit interrupt";
|
||||
|
||||
bad:
|
||||
printf("%s: smit_xfer_end: %s", slp->sl_xname, s);
|
||||
slp->sl_error |= PDMAERR;
|
||||
{
|
||||
printf("%s: smit_xfer_end: phase miss\n", slp->sl_xname);
|
||||
slp->sl_error |= PDMAERR;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
bshw_smit_xfer_start(ct)
|
||||
struct ct_softc *ct;
|
||||
{
|
||||
struct scsi_low_softc *slp = &ct->sc_sclow;
|
||||
struct ct_bus_access_handle *chp = &ct->sc_ch;
|
||||
struct bshw_softc *bs = ct->ct_hw;
|
||||
struct sc_p *sp = &slp->sl_scp;
|
||||
struct targ_info *ti = slp->sl_nexus;
|
||||
struct targ_info *ti = slp->sl_Tnexus;
|
||||
struct ct_targ_info *cti = (void *) ti;
|
||||
bus_space_tag_t bst = ct->sc_iot;
|
||||
bus_space_handle_t bsh = ct->sc_ioh;
|
||||
int datalen, count, wc = LC_SMIT_TIMEOUT * 1024 * 1024;
|
||||
u_int datalen, count, io_control;
|
||||
int wc;
|
||||
u_int8_t *data;
|
||||
|
||||
data = sp->scp_data;
|
||||
datalen = sp->scp_datalen;
|
||||
io_control = bs->sc_io_control | bshw_io_control;
|
||||
if ((io_control & BSHW_SMIT_BLOCK) != 0)
|
||||
return EINVAL;
|
||||
|
||||
ct_cr_write_1(bst, bsh, wd3s_ctrl, ct->sc_creg | CR_DMA);
|
||||
bshw_lc_smit_start(ct, sp->scp_datalen, sp->scp_direction);
|
||||
if ((slp->sl_scp.scp_datalen % DEV_BSIZE) != 0)
|
||||
return EINVAL;
|
||||
|
||||
datalen = sp->scp_datalen;
|
||||
if (slp->sl_scp.scp_direction == SCSI_LOW_READ)
|
||||
{
|
||||
if ((io_control & BSHW_READ_INTERRUPT_DRIVEN) != 0 &&
|
||||
datalen > bshw_data_read_bytes)
|
||||
datalen = bshw_data_read_bytes;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((io_control & BSHW_WRITE_INTERRUPT_DRIVEN) != 0 &&
|
||||
datalen > bshw_data_write_bytes)
|
||||
datalen = bshw_data_write_bytes;
|
||||
}
|
||||
|
||||
bs->sc_sdatalen = datalen;
|
||||
data = sp->scp_data;
|
||||
wc = LC_SMIT_TIMEOUT * 1024 * 1024;
|
||||
|
||||
ct_cr_write_1(chp, wd3s_ctrl, ct->sc_creg | CR_DMA);
|
||||
bshw_lc_smit_start(ct, datalen, sp->scp_direction);
|
||||
|
||||
if (sp->scp_direction == SCSI_LOW_READ)
|
||||
{
|
||||
@ -339,14 +372,14 @@ bshw_smit_xfer_start(ct)
|
||||
break;
|
||||
|
||||
count = (datalen > LC_FSZ ? LC_FSZ : datalen);
|
||||
bus_space_read_region_4(ct->sc_memt, ct->sc_memh,
|
||||
bus_space_read_region_4(chp->ch_memt, chp->ch_memh,
|
||||
LC_SMIT_OFFSET, (u_int32_t *) data, count >> 2);
|
||||
data += count;
|
||||
datalen -= count;
|
||||
}
|
||||
while (datalen > 0);
|
||||
|
||||
bs->sc_tdatalen = datalen;
|
||||
bs->sc_edatalen = datalen;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -365,7 +398,7 @@ bshw_smit_xfer_start(ct)
|
||||
}
|
||||
|
||||
count = (datalen > LC_SFSZ ? LC_SFSZ : datalen);
|
||||
bus_space_write_region_4(ct->sc_memt, ct->sc_memh,
|
||||
bus_space_write_region_4(chp->ch_memt, chp->ch_memh,
|
||||
LC_SMIT_OFFSET, (u_int32_t *) data, count >> 2);
|
||||
data += count;
|
||||
datalen -= count;
|
||||
@ -374,7 +407,7 @@ bshw_smit_xfer_start(ct)
|
||||
break;
|
||||
|
||||
count = (datalen > LC_REST ? LC_REST : datalen);
|
||||
bus_space_write_region_4(ct->sc_memt, ct->sc_memh,
|
||||
bus_space_write_region_4(chp->ch_memt, chp->ch_memh,
|
||||
LC_SMIT_OFFSET + LC_SFSZ,
|
||||
(u_int32_t *) data, count >> 2);
|
||||
data += count;
|
||||
@ -382,26 +415,33 @@ bshw_smit_xfer_start(ct)
|
||||
}
|
||||
while (datalen > 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*********************************************************
|
||||
* DMA TRANSFER (BS)
|
||||
*********************************************************/
|
||||
static __inline void bshw_dma_write_1 \
|
||||
__P((struct ct_bus_access_handle *, bus_addr_t, u_int8_t));
|
||||
static void bshw_dmastart __P((struct ct_softc *));
|
||||
static void bshw_dmadone __P((struct ct_softc *));
|
||||
|
||||
void
|
||||
int
|
||||
bshw_dma_xfer_start(ct)
|
||||
struct ct_softc *ct;
|
||||
{
|
||||
struct scsi_low_softc *slp = &ct->sc_sclow;
|
||||
struct sc_p *sp = &slp->sl_scp;
|
||||
struct ct_bus_access_handle *chp = &ct->sc_ch;
|
||||
struct bshw_softc *bs = ct->ct_hw;
|
||||
bus_space_tag_t bst = ct->sc_iot;
|
||||
bus_space_handle_t bsh = ct->sc_ioh;
|
||||
vaddr_t va, endva, phys, nphys;
|
||||
u_int io_control;
|
||||
|
||||
ct_cr_write_1(bst, bsh, wd3s_ctrl, ct->sc_creg | CR_DMA);
|
||||
io_control = bs->sc_io_control | bshw_io_control;
|
||||
if ((io_control & BSHW_DMA_BLOCK) != 0 && sp->scp_datalen < 256)
|
||||
return EINVAL;
|
||||
|
||||
ct_cr_write_1(chp, wd3s_ctrl, ct->sc_creg | CR_DMA);
|
||||
phys = vtophys((vaddr_t) sp->scp_data);
|
||||
if (phys >= bs->sc_minphys)
|
||||
{
|
||||
@ -421,19 +461,17 @@ bshw_dma_xfer_start(ct)
|
||||
/* setup segaddr */
|
||||
bs->sc_segaddr = (u_int8_t *) phys;
|
||||
/* setup seglen */
|
||||
endva = (vaddr_t)round_page((vaddr_t)(sp->scp_data +
|
||||
sp->scp_datalen));
|
||||
endva = (vaddr_t) round_page((vaddr_t) sp->scp_data + sp->scp_datalen);
|
||||
for (va = (vaddr_t) sp->scp_data; ; phys = nphys)
|
||||
{
|
||||
if ((va += PAGE_SIZE) >= endva)
|
||||
if ((va += BSHW_PAGE_SIZE) >= endva)
|
||||
{
|
||||
bs->sc_seglen = sp->scp_datalen;
|
||||
break;
|
||||
}
|
||||
|
||||
nphys = vtophys(va);
|
||||
if (phys + PAGE_SIZE != nphys ||
|
||||
nphys >= bs->sc_minphys)
|
||||
if (phys + BSHW_PAGE_SIZE != nphys || nphys >= bs->sc_minphys)
|
||||
{
|
||||
bs->sc_seglen =
|
||||
(u_int8_t *) trunc_page(va) - sp->scp_data;
|
||||
@ -445,7 +483,9 @@ bshw_dma_xfer_start(ct)
|
||||
}
|
||||
|
||||
bshw_dmastart(ct);
|
||||
cthw_set_count(bst, bsh, bs->sc_seglen);
|
||||
cthw_set_count(chp, bs->sc_seglen);
|
||||
ct_cr_write_1(chp, wd3s_cmd, WD3S_TFR_INFO);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
@ -460,13 +500,13 @@ bshw_dma_xfer_stop(ct)
|
||||
|
||||
bshw_dmadone(ct);
|
||||
|
||||
ti = slp->sl_nexus;
|
||||
ti = slp->sl_Tnexus;
|
||||
if (ti == NULL)
|
||||
return;
|
||||
|
||||
if (ti->ti_phase == PH_DATA)
|
||||
{
|
||||
count = cthw_get_count(ct->sc_iot, ct->sc_ioh);
|
||||
count = cthw_get_count(&ct->sc_ch);
|
||||
if (count < (u_int) bs->sc_seglen)
|
||||
{
|
||||
transbytes = bs->sc_seglen - count;
|
||||
@ -474,31 +514,27 @@ bshw_dma_xfer_stop(ct)
|
||||
sp->scp_direction == SCSI_LOW_READ)
|
||||
bcopy(bs->sc_bufp, sp->scp_data, transbytes);
|
||||
|
||||
bs->sc_bufp = NULL;
|
||||
sp->scp_data += transbytes;
|
||||
sp->scp_datalen -= transbytes;
|
||||
return;
|
||||
}
|
||||
else if (count == (u_int) bs->sc_seglen)
|
||||
else if (count > (u_int) bs->sc_seglen)
|
||||
{
|
||||
bs->sc_bufp = NULL;
|
||||
return;
|
||||
printf("%s: port data %x != seglen %x\n",
|
||||
slp->sl_xname, count, bs->sc_seglen);
|
||||
slp->sl_error |= PDMAERR;
|
||||
}
|
||||
|
||||
printf("%s: port data %x != seglen %x\n",
|
||||
slp->sl_xname, count, bs->sc_seglen);
|
||||
scsi_low_data_finish(slp);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("%s: extra DMA interrupt\n", slp->sl_xname);
|
||||
slp->sl_error |= PDMAERR;
|
||||
}
|
||||
|
||||
slp->sl_error |= PDMAERR;
|
||||
bs->sc_bufp = NULL;
|
||||
}
|
||||
|
||||
static int dmapageport[4] = { 0x27, 0x21, 0x23, 0x25 };
|
||||
|
||||
/* common dma settings */
|
||||
#undef DMA1_SMSK
|
||||
#define DMA1_SMSK (0x15)
|
||||
@ -514,56 +550,64 @@ static int dmapageport[4] = { 0x27, 0x21, 0x23, 0x25 };
|
||||
#define DMA37MD_READ 0x08
|
||||
#define DMA37MD_SINGLE 0x40
|
||||
|
||||
static bus_addr_t dmapageport[4] = { 0x27, 0x21, 0x23, 0x25 };
|
||||
|
||||
static __inline void
|
||||
bshw_dma_write_1(chp, port, val)
|
||||
struct ct_bus_access_handle *chp;
|
||||
bus_addr_t port;
|
||||
u_int8_t val;
|
||||
{
|
||||
|
||||
CT_BUS_WEIGHT(chp);
|
||||
outb(port, val);
|
||||
}
|
||||
|
||||
static void
|
||||
bshw_dmastart(ct)
|
||||
struct ct_softc *ct;
|
||||
{
|
||||
struct scsi_low_softc *slp = &ct->sc_sclow;
|
||||
struct bshw_softc *bs = ct->ct_hw;
|
||||
bus_space_tag_t bst = ct->sc_iot;
|
||||
bus_space_handle_t bsh = ct->sc_ioh;
|
||||
struct ct_bus_access_handle *chp = &ct->sc_ch;
|
||||
int chan = bs->sc_drq;
|
||||
int waport;
|
||||
u_int8_t *phys = bs->sc_segaddr;
|
||||
bus_addr_t waport;
|
||||
u_int8_t regv, *phys = bs->sc_segaddr;
|
||||
u_int nbytes = bs->sc_seglen;
|
||||
|
||||
/* flush cpu cache */
|
||||
(*bs->sc_dmasync_before) (ct);
|
||||
|
||||
/*
|
||||
* Program one of DMA channels 0..3. These are
|
||||
* byte mode channels.
|
||||
*/
|
||||
/* set dma channel mode, and reset address ff */
|
||||
#ifdef __FreeBSD__
|
||||
if (need_pre_dma_flush)
|
||||
wbinvd();
|
||||
#else
|
||||
if (slp->sl_scp.scp_direction == SCSI_LOW_READ)
|
||||
cpu_cf_preRead(curcpu);
|
||||
else
|
||||
cpu_cf_preWrite(curcpu);
|
||||
#endif
|
||||
|
||||
if (slp->sl_scp.scp_direction == SCSI_LOW_READ)
|
||||
outb(DMA1_MODE, DMA37MD_SINGLE | DMA37MD_WRITE | chan);
|
||||
regv = DMA37MD_WRITE | DMA37MD_SINGLE | chan;
|
||||
else
|
||||
outb(DMA1_MODE, DMA37MD_SINGLE | DMA37MD_READ | chan);
|
||||
outb(DMA1_FFC, 0);
|
||||
regv = DMA37MD_READ | DMA37MD_SINGLE | chan;
|
||||
|
||||
bshw_dma_write_1(chp, DMA1_MODE, regv);
|
||||
bshw_dma_write_1(chp, DMA1_FFC, 0);
|
||||
|
||||
/* send start address */
|
||||
waport = DMA1_CHN(chan);
|
||||
outb(waport, (u_int) phys);
|
||||
outb(waport, ((u_int) phys) >> 8);
|
||||
outb(dmapageport[chan], ((u_int) phys) >> 16);
|
||||
bshw_dma_write_1(chp, waport, (u_int) phys);
|
||||
bshw_dma_write_1(chp, waport, ((u_int) phys) >> 8);
|
||||
bshw_dma_write_1(chp, dmapageport[chan], ((u_int) phys) >> 16);
|
||||
|
||||
/* send count */
|
||||
outb(waport + 2, --nbytes);
|
||||
outb(waport + 2, nbytes >> 8);
|
||||
bshw_dma_write_1(chp, waport + 2, --nbytes);
|
||||
bshw_dma_write_1(chp, waport + 2, nbytes >> 8);
|
||||
|
||||
/* vendor unique hook */
|
||||
if (bs->sc_hw->dma_start)
|
||||
(*bs->sc_hw->dma_start)(ct);
|
||||
if (bs->sc_hw->hw_dma_start)
|
||||
(*bs->sc_hw->hw_dma_start)(ct);
|
||||
|
||||
outb(DMA1_SMSK, chan);
|
||||
bus_space_write_1(bst, bsh, cmd_port, CMDP_DMES);
|
||||
bshw_dma_write_1(chp, DMA1_SMSK, chan);
|
||||
ct_cmdp_write_1(chp, CMDP_DMES);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -571,25 +615,17 @@ bshw_dmadone(ct)
|
||||
struct ct_softc *ct;
|
||||
{
|
||||
struct bshw_softc *bs = ct->ct_hw;
|
||||
bus_space_tag_t bst = ct->sc_iot;
|
||||
bus_space_handle_t bsh = ct->sc_ioh;
|
||||
struct ct_bus_access_handle *chp = &ct->sc_ch;
|
||||
|
||||
outb(DMA1_SMSK, (bs->sc_drq | DMA37SM_SET));
|
||||
bus_space_write_1(bst, bsh, cmd_port, CMDP_DMER);
|
||||
bshw_dma_write_1(chp, DMA1_SMSK, (bs->sc_drq | DMA37SM_SET));
|
||||
ct_cmdp_write_1(chp, CMDP_DMER);
|
||||
|
||||
/* vendor unique hook */
|
||||
if (bs->sc_hw->dma_stop)
|
||||
(*bs->sc_hw->dma_stop)(ct);
|
||||
if (bs->sc_hw->hw_dma_stop)
|
||||
(*bs->sc_hw->hw_dma_stop) (ct);
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
if (need_post_dma_flush)
|
||||
invd();
|
||||
#else
|
||||
if (slp->sl_scp.scp_direction == SCSI_LOW_READ)
|
||||
cpu_cf_postRead(curcpu);
|
||||
else
|
||||
cpu_cf_postWrite(curcpu);
|
||||
#endif
|
||||
/* flush cpu cache */
|
||||
(*bs->sc_dmasync_after) (ct);
|
||||
}
|
||||
|
||||
/**********************************************
|
||||
@ -606,16 +642,15 @@ static int
|
||||
bshw_dma_init_texa(ct)
|
||||
struct ct_softc *ct;
|
||||
{
|
||||
bus_space_tag_t bst = ct->sc_iot;
|
||||
bus_space_handle_t bsh = ct->sc_ioh;
|
||||
struct ct_bus_access_handle *chp = &ct->sc_ch;
|
||||
u_int8_t regval;
|
||||
|
||||
if ((regval = ct_cr_read_1(bst, bsh, 0x37)) & 0x08)
|
||||
if ((regval = ct_cr_read_1(chp, 0x37)) & 0x08)
|
||||
return 0;
|
||||
|
||||
ct_cr_write_1(bst, bsh, 0x37, regval | 0x08);
|
||||
regval = ct_cr_read_1(bst, bsh, 0x3f);
|
||||
ct_cr_write_1(bst, bsh, 0x3f, regval | 0x08);
|
||||
ct_cr_write_1(chp, 0x37, regval | 0x08);
|
||||
regval = ct_cr_read_1(chp, 0x3f);
|
||||
ct_cr_write_1(chp, 0x3f, regval | 0x08);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -623,26 +658,25 @@ static int
|
||||
bshw_dma_init_sc98(ct)
|
||||
struct ct_softc *ct;
|
||||
{
|
||||
bus_space_tag_t bst = ct->sc_iot;
|
||||
bus_space_handle_t bsh = ct->sc_ioh;
|
||||
struct ct_bus_access_handle *chp = &ct->sc_ch;
|
||||
|
||||
if (ct_cr_read_1(bst, bsh, 0x37) & 0x08)
|
||||
if (ct_cr_read_1(chp, 0x37) & 0x08)
|
||||
return 0;
|
||||
|
||||
/* If your card is SC98 with bios ver 1.01 or 1.02 under no PCI */
|
||||
ct_cr_write_1(bst, bsh, 0x37, 0x1a);
|
||||
ct_cr_write_1(bst, bsh, 0x3f, 0x1a);
|
||||
ct_cr_write_1(chp, 0x37, 0x1a);
|
||||
ct_cr_write_1(chp, 0x3f, 0x1a);
|
||||
#if 0
|
||||
/* only valid for IO */
|
||||
ct_cr_write_1(bst, bsh, 0x40, 0xf4);
|
||||
ct_cr_write_1(bst, bsh, 0x41, 0x9);
|
||||
ct_cr_write_1(bst, bsh, 0x43, 0xff);
|
||||
ct_cr_write_1(bst, bsh, 0x46, 0x4e);
|
||||
ct_cr_write_1(chp, 0x40, 0xf4);
|
||||
ct_cr_write_1(chp, 0x41, 0x9);
|
||||
ct_cr_write_1(chp, 0x43, 0xff);
|
||||
ct_cr_write_1(chp, 0x46, 0x4e);
|
||||
|
||||
ct_cr_write_1(bst, bsh, 0x48, 0xf4);
|
||||
ct_cr_write_1(bst, bsh, 0x49, 0x9);
|
||||
ct_cr_write_1(bst, bsh, 0x4b, 0xff);
|
||||
ct_cr_write_1(bst, bsh, 0x4e, 0x4e);
|
||||
ct_cr_write_1(chp, 0x48, 0xf4);
|
||||
ct_cr_write_1(chp, 0x49, 0x9);
|
||||
ct_cr_write_1(chp, 0x4b, 0xff);
|
||||
ct_cr_write_1(chp, 0x4e, 0x4e);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@ -651,44 +685,40 @@ static void
|
||||
bshw_dma_start_sc98(ct)
|
||||
struct ct_softc *ct;
|
||||
{
|
||||
bus_space_tag_t bst = ct->sc_iot;
|
||||
bus_space_handle_t bsh = ct->sc_ioh;
|
||||
struct ct_bus_access_handle *chp = &ct->sc_ch;
|
||||
|
||||
ct_cr_write_1(bst, bsh, 0x73, 0x32);
|
||||
ct_cr_write_1(bst, bsh, 0x74, 0x23);
|
||||
ct_cr_write_1(chp, 0x73, 0x32);
|
||||
ct_cr_write_1(chp, 0x74, 0x23);
|
||||
}
|
||||
|
||||
static void
|
||||
bshw_dma_stop_sc98(ct)
|
||||
struct ct_softc *ct;
|
||||
{
|
||||
bus_space_tag_t bst = ct->sc_iot;
|
||||
bus_space_handle_t bsh = ct->sc_ioh;
|
||||
struct ct_bus_access_handle *chp = &ct->sc_ch;
|
||||
|
||||
ct_cr_write_1(bst, bsh, 0x73, 0x43);
|
||||
ct_cr_write_1(bst, bsh, 0x74, 0x34);
|
||||
ct_cr_write_1(chp, 0x73, 0x43);
|
||||
ct_cr_write_1(chp, 0x74, 0x34);
|
||||
}
|
||||
|
||||
static void
|
||||
bshw_dma_start_elecom(ct)
|
||||
struct ct_softc *ct;
|
||||
{
|
||||
bus_space_tag_t bst = ct->sc_iot;
|
||||
bus_space_handle_t bsh = ct->sc_ioh;
|
||||
u_int8_t tmp = ct_cr_read_1(bst, bsh, 0x4c);
|
||||
struct ct_bus_access_handle *chp = &ct->sc_ch;
|
||||
u_int8_t tmp = ct_cr_read_1(chp, 0x4c);
|
||||
|
||||
ct_cr_write_1(bst, bsh, 0x32, tmp & 0xdf);
|
||||
ct_cr_write_1(chp, 0x32, tmp & 0xdf);
|
||||
}
|
||||
|
||||
static void
|
||||
bshw_dma_stop_elecom(ct)
|
||||
struct ct_softc *ct;
|
||||
{
|
||||
bus_space_tag_t bst = ct->sc_iot;
|
||||
bus_space_handle_t bsh = ct->sc_ioh;
|
||||
u_int8_t tmp = ct_cr_read_1(bst, bsh, 0x4c);
|
||||
struct ct_bus_access_handle *chp = &ct->sc_ch;
|
||||
u_int8_t tmp = ct_cr_read_1(chp, 0x4c);
|
||||
|
||||
ct_cr_write_1(bst, bsh, 0x32, tmp | 0x20);
|
||||
ct_cr_write_1(chp, 0x32, tmp | 0x20);
|
||||
}
|
||||
|
||||
static struct bshw bshw_generic = {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NecBSD: bshwvar.h,v 1.3 1999/04/15 01:36:10 kmatsuda Exp $ */
|
||||
/* $NecBSD: bshwvar.h,v 1.3.14.3 2001/06/21 04:07:37 honda Exp $ */
|
||||
/* $NetBSD$ */
|
||||
|
||||
/*
|
||||
@ -46,12 +46,11 @@ struct bshw {
|
||||
#define BSHW_SMFIFO 0x02
|
||||
#define BSHW_DOUBLE_DMACHAN 0x04
|
||||
u_int hw_flags;
|
||||
u_int hw_sregaddr;
|
||||
|
||||
u_int sregaddr;
|
||||
|
||||
int ((*dma_init) __P((struct ct_softc *)));
|
||||
void ((*dma_start) __P((struct ct_softc *)));
|
||||
void ((*dma_stop) __P((struct ct_softc *)));
|
||||
int ((*hw_dma_init) __P((struct ct_softc *)));
|
||||
void ((*hw_dma_start) __P((struct ct_softc *)));
|
||||
void ((*hw_dma_stop) __P((struct ct_softc *)));
|
||||
};
|
||||
|
||||
struct bshw_softc {
|
||||
@ -63,7 +62,8 @@ struct bshw_softc {
|
||||
u_int8_t *sc_segaddr;
|
||||
u_int8_t *sc_bufp;
|
||||
int sc_seglen;
|
||||
int sc_tdatalen; /* temp datalen */
|
||||
u_int sc_sdatalen; /* SMIT */
|
||||
u_int sc_edatalen; /* SMIT */
|
||||
|
||||
/* private bounce */
|
||||
u_int8_t *sc_bounce_phys;
|
||||
@ -71,16 +71,26 @@ struct bshw_softc {
|
||||
u_int sc_bounce_size;
|
||||
bus_addr_t sc_minphys;
|
||||
|
||||
/* io control */
|
||||
#define BSHW_READ_INTERRUPT_DRIVEN 0x0001
|
||||
#define BSHW_WRITE_INTERRUPT_DRIVEN 0x0002
|
||||
#define BSHW_DMA_BLOCK 0x0010
|
||||
#define BSHW_SMIT_BLOCK 0x0020
|
||||
u_int sc_io_control;
|
||||
|
||||
/* hardware */
|
||||
struct bshw *sc_hw;
|
||||
void ((*sc_dmasync_before)) __P((struct ct_softc *));
|
||||
void ((*sc_dmasync_after)) __P((struct ct_softc *));
|
||||
};
|
||||
|
||||
void bshw_synch_setup __P((struct ct_softc *, struct lun_info *));
|
||||
void bshw_synch_setup __P((struct ct_softc *, struct targ_info *));
|
||||
void bshw_bus_reset __P((struct ct_softc *));
|
||||
int bshw_read_settings __P((bus_space_tag_t, bus_space_handle_t, struct bshw_softc *));
|
||||
void bshw_smit_xfer_start __P((struct ct_softc *));
|
||||
int bshw_read_settings __P((struct ct_bus_access_handle *, struct bshw_softc *));
|
||||
int bshw_smit_xfer_start __P((struct ct_softc *));
|
||||
void bshw_smit_xfer_stop __P((struct ct_softc *));
|
||||
void bshw_dma_xfer_start __P((struct ct_softc *));
|
||||
int bshw_dma_xfer_start __P((struct ct_softc *));
|
||||
void bshw_dma_xfer_stop __P((struct ct_softc *));
|
||||
|
||||
extern struct dvcfg_hwsel bshw_hwsel;
|
||||
#endif /* !_BSHWVAR_H_ */
|
||||
|
811
sys/dev/ct/ct.c
811
sys/dev/ct/ct.c
File diff suppressed because it is too large
Load Diff
@ -75,6 +75,7 @@
|
||||
#include <machine/resource.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/rman.h>
|
||||
#include <machine/md_var.h>
|
||||
|
||||
#include <pc98/pc98/pc98.h>
|
||||
#include <isa/isavar.h>
|
||||
@ -100,6 +101,9 @@ static int ct_space_map(device_t, struct bshw *,
|
||||
static void ct_space_unmap(device_t, struct ct_softc *);
|
||||
static struct bshw *ct_find_hw(device_t);
|
||||
static void ct_dmamap(void *, bus_dma_segment_t *, int, int);
|
||||
static void ct_isa_bus_access_weight __P((struct ct_bus_access_handle *));
|
||||
static void ct_isa_dmasync_before __P((struct ct_softc *));
|
||||
static void ct_isa_dmasync_after __P((struct ct_softc *));
|
||||
|
||||
struct ct_isa_softc {
|
||||
struct ct_softc sc_ct;
|
||||
@ -132,6 +136,7 @@ ct_isa_match(device_t dev)
|
||||
{
|
||||
struct bshw *hw;
|
||||
struct resource *port_res, *mem_res;
|
||||
struct ct_bus_access_handle ch;
|
||||
int rv;
|
||||
|
||||
if (ISA_PNP_PROBE(device_get_parent(dev), dev, ct_pnp_ids) == ENXIO)
|
||||
@ -146,17 +151,20 @@ ct_isa_match(device_t dev)
|
||||
if (ct_space_map(dev, hw, &port_res, &mem_res) != 0)
|
||||
return ENXIO;
|
||||
|
||||
rv = ctprobesubr(rman_get_bustag(port_res),
|
||||
rman_get_bushandle(port_res),
|
||||
0, BSHW_DEFAULT_HOSTID, BSHW_DEFAULT_CHIPCLK);
|
||||
bzero(&ch, sizeof(ch));
|
||||
ch.ch_iot = rman_get_bustag(port_res);
|
||||
ch.ch_ioh = rman_get_bushandle(port_res),
|
||||
ch.ch_bus_weight = ct_isa_bus_access_weight;
|
||||
|
||||
rv = ctprobesubr(&ch, 0, BSHW_DEFAULT_HOSTID,
|
||||
BSHW_DEFAULT_CHIPCLK, NULL);
|
||||
if (rv != 0)
|
||||
{
|
||||
struct bshw_softc bshw_tab;
|
||||
struct bshw_softc *bs = &bshw_tab;
|
||||
|
||||
memset(bs, 0, sizeof(*bs));
|
||||
bshw_read_settings(rman_get_bustag(port_res),
|
||||
rman_get_bushandle(port_res), bs);
|
||||
bshw_read_settings(&ch, bs);
|
||||
bus_set_resource(dev, SYS_RES_IRQ, 0, bs->sc_irq, 1);
|
||||
bus_set_resource(dev, SYS_RES_DRQ, 0, bs->sc_drq, 1);
|
||||
}
|
||||
@ -175,12 +183,14 @@ ct_isa_attach(device_t dev)
|
||||
{
|
||||
struct ct_isa_softc *pct = device_get_softc(dev);
|
||||
struct ct_softc *ct = &pct->sc_ct;
|
||||
struct ct_bus_access_handle *chp = &ct->sc_ch;
|
||||
struct scsi_low_softc *slp = &ct->sc_sclow;
|
||||
struct bshw_softc *bs = &pct->sc_bshw;
|
||||
struct bshw *hw;
|
||||
int irq_rid, drq_rid;
|
||||
int irq_rid, drq_rid, chiprev;
|
||||
u_int8_t *vaddr;
|
||||
bus_addr_t addr;
|
||||
intrmask_t s;
|
||||
|
||||
hw = ct_find_hw(dev);
|
||||
if (ct_space_map(dev, hw, &ct->port_res, &ct->mem_res) != 0) {
|
||||
@ -188,12 +198,14 @@ ct_isa_attach(device_t dev)
|
||||
return ENXIO;
|
||||
}
|
||||
|
||||
ct->sc_iot = rman_get_bustag(ct->port_res);
|
||||
ct->sc_ioh = rman_get_bushandle(ct->port_res);
|
||||
bzero(chp, sizeof(*chp));
|
||||
chp->ch_iot = rman_get_bustag(ct->port_res);
|
||||
chp->ch_ioh = rman_get_bushandle(ct->port_res);
|
||||
if (ct->mem_res) {
|
||||
ct->sc_memt = rman_get_bustag(ct->mem_res);
|
||||
ct->sc_memh = rman_get_bushandle(ct->mem_res);
|
||||
chp->ch_memt = rman_get_bustag(ct->mem_res);
|
||||
chp->ch_memh = rman_get_bushandle(ct->mem_res);
|
||||
}
|
||||
chp->ch_bus_weight = ct_isa_bus_access_weight;
|
||||
|
||||
irq_rid = 0;
|
||||
ct->irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &irq_rid, 0, ~0,
|
||||
@ -206,6 +218,14 @@ ct_isa_attach(device_t dev)
|
||||
return ENXIO;
|
||||
}
|
||||
|
||||
if (ctprobesubr(chp, 0, BSHW_DEFAULT_HOSTID,
|
||||
BSHW_DEFAULT_CHIPCLK, &chiprev) == 0)
|
||||
{
|
||||
device_printf(dev, "hardware missing\n");
|
||||
ct_space_unmap(dev, ct);
|
||||
return ENXIO;
|
||||
}
|
||||
|
||||
/* setup DMA map */
|
||||
if (bus_dma_tag_create(NULL, 1, 0,
|
||||
BUS_SPACE_MAXADDR_24BIT, BUS_SPACE_MAXADDR,
|
||||
@ -229,11 +249,14 @@ ct_isa_attach(device_t dev)
|
||||
|
||||
/* setup machdep softc */
|
||||
bs->sc_hw = hw;
|
||||
bs->sc_io_control = 0;
|
||||
bs->sc_bounce_phys = (u_int8_t *)addr;
|
||||
bs->sc_bounce_addr = vaddr;
|
||||
bs->sc_bounce_size = MAXBSIZE;
|
||||
bs->sc_minphys = (1 << 24);
|
||||
bshw_read_settings(ct->sc_iot, ct->sc_ioh, bs);
|
||||
bs->sc_dmasync_before = ct_isa_dmasync_before;
|
||||
bs->sc_dmasync_after = ct_isa_dmasync_after;
|
||||
bshw_read_settings(chp, bs);
|
||||
|
||||
/* setup ct driver softc */
|
||||
ct->ct_hw = bs;
|
||||
@ -245,17 +268,54 @@ ct_isa_attach(device_t dev)
|
||||
ct->ct_synch_setup = bshw_synch_setup;
|
||||
|
||||
ct->sc_xmode = CT_XMODE_DMA;
|
||||
if (ct->sc_memh != NULL)
|
||||
if (chp->ch_memh != NULL)
|
||||
ct->sc_xmode |= CT_XMODE_PIO;
|
||||
ct->sc_chiprev = CT_WD33C93_B;
|
||||
ct->sc_chipclk = BSHW_DEFAULT_CHIPCLK;
|
||||
|
||||
ct->sc_chiprev = chiprev;
|
||||
switch (chiprev)
|
||||
{
|
||||
case CT_WD33C93:
|
||||
/* s = "WD33C93"; */
|
||||
ct->sc_chipclk = 8;
|
||||
break;
|
||||
case CT_WD33C93_A:
|
||||
if (DVCFG_MAJOR(device_get_flags(dev)) > 0)
|
||||
{
|
||||
/* s = "AM33C93_A"; */
|
||||
ct->sc_chipclk = 20;
|
||||
ct->sc_chiprev = CT_AM33C93_A;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* s = "WD33C93_A"; */
|
||||
ct->sc_chipclk = 10;
|
||||
}
|
||||
break;
|
||||
|
||||
case CT_AM33C93_A:
|
||||
/* s = "AM33C93_A"; */
|
||||
ct->sc_chipclk = 20;
|
||||
break;
|
||||
|
||||
default:
|
||||
case CT_WD33C93_B:
|
||||
/* s = "WD33C93_B"; */
|
||||
ct->sc_chipclk = 20;
|
||||
break;
|
||||
}
|
||||
#if 0
|
||||
printf("%s: chiprev %s chipclk %d Mhz\n",
|
||||
slp->sl_dev.dv_xname, s, ct->sc_chipclk);
|
||||
#endif
|
||||
|
||||
slp->sl_dev = dev;
|
||||
slp->sl_hostid = bs->sc_hostid;
|
||||
slp->sl_irq = isa_get_irq(dev);
|
||||
slp->sl_cfgflags = device_get_flags(dev);
|
||||
|
||||
s = splcam();
|
||||
ctattachsubr(ct);
|
||||
splx(s);
|
||||
|
||||
if (bus_setup_intr(dev, ct->irq_res, INTR_TYPE_CAM,
|
||||
(driver_intr_t *)ctintr, ct, &ct->sc_ih)) {
|
||||
@ -320,3 +380,29 @@ ct_dmamap(void *arg, bus_dma_segment_t *seg, int nseg, int error)
|
||||
|
||||
*addr = seg->ds_addr;
|
||||
}
|
||||
|
||||
static void
|
||||
ct_isa_bus_access_weight(chp)
|
||||
struct ct_bus_access_handle *chp;
|
||||
{
|
||||
|
||||
outb(0x5f, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
ct_isa_dmasync_before(ct)
|
||||
struct ct_softc *ct;
|
||||
{
|
||||
|
||||
if (need_pre_dma_flush)
|
||||
wbinvd();
|
||||
}
|
||||
|
||||
static void
|
||||
ct_isa_dmasync_after(ct)
|
||||
struct ct_softc *ct;
|
||||
{
|
||||
|
||||
if (need_post_dma_flush)
|
||||
invd();
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NecBSD: ct_machdep.h,v 1.4 1999/07/23 20:54:00 honda Exp $ */
|
||||
/* $NecBSD: ct_machdep.h,v 1.4.12.2 2001/06/20 06:13:34 honda Exp $ */
|
||||
/* $NetBSD$ */
|
||||
|
||||
/*
|
||||
* [NetBSD for NEC PC-98 series]
|
||||
* Copyright (c) 1995, 1996, 1997, 1998
|
||||
* Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000, 2001
|
||||
* NetBSD/pc98 porting staff. All rights reserved.
|
||||
* Copyright (c) 1995, 1996, 1997, 1998
|
||||
* Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000, 2001
|
||||
* Naofumi HONDA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -36,6 +36,8 @@
|
||||
#ifndef _CT_MACHDEP_H_
|
||||
#define _CT_MACHDEP_H_
|
||||
|
||||
#include "opt_ct.h"
|
||||
|
||||
/*
|
||||
* Principal rules:
|
||||
* 1) do not use bus_space_write/read_X directly in ct.c.
|
||||
@ -43,101 +45,167 @@
|
||||
*/
|
||||
|
||||
/* special weight if requried */
|
||||
#define CT_BUS_WEIGHT
|
||||
#ifdef CT_BUS_WEIGHT
|
||||
#undef CT_BUS_WEIGHT
|
||||
#define CT_BUS_WEIGHT(chp) \
|
||||
{ \
|
||||
if ((chp)->ch_bus_weight != NULL) \
|
||||
(chp)->ch_bus_weight((chp)); \
|
||||
}
|
||||
#else /* !CT_BUS_WEIGHT */
|
||||
#define CT_BUS_WEIGHT(chp)
|
||||
#endif /* !CT_BUS_WEIGHT */
|
||||
|
||||
/* port offset */
|
||||
#ifndef CT_USE_RELOCATE_OFFSET
|
||||
#define addr_port 0
|
||||
#define stat_port 0
|
||||
#define ctrl_port 2
|
||||
#define cmd_port 4
|
||||
#else /* CT_USE_RELOCATE_OFFSET */
|
||||
#define addr_port ((chp)->ch_offset[0])
|
||||
#define stat_port ((chp)->ch_offset[1])
|
||||
#define ctrl_port ((chp)->ch_offset[2])
|
||||
#define cmd_port ((chp)->ch_offset[3])
|
||||
#endif /* CT_USE_RELOCATE_OFFSET */
|
||||
|
||||
/*
|
||||
* All port accesses primitive methods
|
||||
*/
|
||||
static __inline u_int8_t ct_cr_read_1 __P((bus_space_tag_t, bus_space_handle_t, bus_addr_t));
|
||||
static __inline void ct_cr_write_1 __P((bus_space_tag_t, bus_space_handle_t, bus_addr_t, u_int8_t));
|
||||
static __inline void ct_write_cmds __P((bus_space_tag_t, bus_space_handle_t, u_int8_t *, int));
|
||||
static __inline u_int cthw_get_count __P((bus_space_tag_t, bus_space_handle_t));
|
||||
static __inline void cthw_set_count __P((bus_space_tag_t, bus_space_handle_t, u_int));
|
||||
|
||||
#define ct_stat_read_1(bst, bsh) bus_space_read_1((bst), (bsh), stat_port)
|
||||
|
||||
static __inline void
|
||||
cthw_set_count(bst, bsh, count)
|
||||
bus_space_tag_t bst;
|
||||
bus_space_handle_t bsh;
|
||||
u_int count;
|
||||
{
|
||||
|
||||
bus_space_write_1(bst, bsh, addr_port, wd3s_cnt);
|
||||
CT_BUS_WEIGHT
|
||||
bus_space_write_1(bst, bsh, ctrl_port, count >> 16);
|
||||
CT_BUS_WEIGHT
|
||||
bus_space_write_1(bst, bsh, ctrl_port, count >> 8);
|
||||
CT_BUS_WEIGHT
|
||||
bus_space_write_1(bst, bsh, ctrl_port, count);
|
||||
CT_BUS_WEIGHT
|
||||
}
|
||||
|
||||
static __inline u_int
|
||||
cthw_get_count(bst, bsh)
|
||||
bus_space_tag_t bst;
|
||||
bus_space_handle_t bsh;
|
||||
{
|
||||
u_int count;
|
||||
|
||||
bus_space_write_1(bst, bsh, addr_port, wd3s_cnt);
|
||||
CT_BUS_WEIGHT
|
||||
count = (((u_int) bus_space_read_1(bst, bsh, ctrl_port)) << 16);
|
||||
CT_BUS_WEIGHT
|
||||
count += (((u_int) bus_space_read_1(bst, bsh, ctrl_port)) << 8);
|
||||
CT_BUS_WEIGHT
|
||||
count += ((u_int) bus_space_read_1(bst, bsh, ctrl_port));
|
||||
CT_BUS_WEIGHT
|
||||
return count;
|
||||
}
|
||||
|
||||
static __inline void
|
||||
ct_write_cmds(bst, bsh, cmd, len)
|
||||
bus_space_tag_t bst;
|
||||
bus_space_handle_t bsh;
|
||||
u_int8_t *cmd;
|
||||
int len;
|
||||
{
|
||||
int i;
|
||||
|
||||
bus_space_write_1(bst, bsh, addr_port, wd3s_cdb);
|
||||
for (i = 0; i < len; i ++)
|
||||
bus_space_write_1(bst, bsh, ctrl_port, cmd[i]);
|
||||
}
|
||||
static __inline u_int8_t ct_stat_read_1
|
||||
__P((struct ct_bus_access_handle *));
|
||||
static __inline u_int8_t ct_cmdp_read_1
|
||||
__P((struct ct_bus_access_handle *));
|
||||
static __inline void ct_cmdp_write_1
|
||||
__P((struct ct_bus_access_handle *, u_int8_t));
|
||||
static __inline u_int8_t ct_cr_read_1
|
||||
__P((struct ct_bus_access_handle *, bus_addr_t));
|
||||
static __inline void ct_cr_write_1
|
||||
__P((struct ct_bus_access_handle *, bus_addr_t, u_int8_t));
|
||||
static __inline void ct_write_cmds
|
||||
__P((struct ct_bus_access_handle *, u_int8_t *, int));
|
||||
static __inline u_int cthw_get_count
|
||||
__P((struct ct_bus_access_handle *));
|
||||
static __inline void cthw_set_count
|
||||
__P((struct ct_bus_access_handle *, u_int));
|
||||
|
||||
static __inline u_int8_t
|
||||
ct_cr_read_1(bst, bsh, offs)
|
||||
bus_space_tag_t bst;
|
||||
bus_space_handle_t bsh;
|
||||
bus_addr_t offs;
|
||||
ct_stat_read_1(chp)
|
||||
struct ct_bus_access_handle *chp;
|
||||
{
|
||||
u_int8_t regv;
|
||||
|
||||
bus_space_write_1(bst, bsh, addr_port, offs);
|
||||
CT_BUS_WEIGHT
|
||||
regv = bus_space_read_1(bst, bsh, ctrl_port);
|
||||
CT_BUS_WEIGHT
|
||||
regv = bus_space_read_1(chp->ch_iot, chp->ch_ioh, stat_port);
|
||||
CT_BUS_WEIGHT(chp)
|
||||
return regv;
|
||||
}
|
||||
|
||||
static __inline void
|
||||
ct_cr_write_1(bst, bsh, offs, val)
|
||||
bus_space_tag_t bst;
|
||||
bus_space_handle_t bsh;
|
||||
cthw_set_count(chp, count)
|
||||
struct ct_bus_access_handle *chp;
|
||||
u_int count;
|
||||
{
|
||||
bus_space_tag_t bst = chp->ch_iot;
|
||||
bus_space_handle_t bsh = chp->ch_ioh;
|
||||
|
||||
bus_space_write_1(bst, bsh, addr_port, wd3s_cnt);
|
||||
CT_BUS_WEIGHT(chp)
|
||||
bus_space_write_1(bst, bsh, ctrl_port, count >> 16);
|
||||
CT_BUS_WEIGHT(chp)
|
||||
bus_space_write_1(bst, bsh, ctrl_port, count >> 8);
|
||||
CT_BUS_WEIGHT(chp)
|
||||
bus_space_write_1(bst, bsh, ctrl_port, count);
|
||||
CT_BUS_WEIGHT(chp)
|
||||
}
|
||||
|
||||
static __inline u_int
|
||||
cthw_get_count(chp)
|
||||
struct ct_bus_access_handle *chp;
|
||||
{
|
||||
bus_space_tag_t bst = chp->ch_iot;
|
||||
bus_space_handle_t bsh = chp->ch_ioh;
|
||||
u_int count;
|
||||
|
||||
bus_space_write_1(bst, bsh, addr_port, wd3s_cnt);
|
||||
CT_BUS_WEIGHT(chp)
|
||||
count = (((u_int) bus_space_read_1(bst, bsh, ctrl_port)) << 16);
|
||||
CT_BUS_WEIGHT(chp)
|
||||
count += (((u_int) bus_space_read_1(bst, bsh, ctrl_port)) << 8);
|
||||
CT_BUS_WEIGHT(chp)
|
||||
count += ((u_int) bus_space_read_1(bst, bsh, ctrl_port));
|
||||
CT_BUS_WEIGHT(chp)
|
||||
return count;
|
||||
}
|
||||
|
||||
static __inline void
|
||||
ct_write_cmds(chp, cmd, len)
|
||||
struct ct_bus_access_handle *chp;
|
||||
u_int8_t *cmd;
|
||||
int len;
|
||||
{
|
||||
bus_space_tag_t bst = chp->ch_iot;
|
||||
bus_space_handle_t bsh = chp->ch_ioh;
|
||||
int i;
|
||||
|
||||
bus_space_write_1(bst, bsh, addr_port, wd3s_cdb);
|
||||
CT_BUS_WEIGHT(chp)
|
||||
for (i = 0; i < len; i ++)
|
||||
{
|
||||
bus_space_write_1(bst, bsh, ctrl_port, cmd[i]);
|
||||
CT_BUS_WEIGHT(chp)
|
||||
}
|
||||
}
|
||||
|
||||
static __inline u_int8_t
|
||||
ct_cr_read_1(chp, offs)
|
||||
struct ct_bus_access_handle *chp;
|
||||
bus_addr_t offs;
|
||||
{
|
||||
bus_space_tag_t bst = chp->ch_iot;
|
||||
bus_space_handle_t bsh = chp->ch_ioh;
|
||||
u_int8_t regv;
|
||||
|
||||
bus_space_write_1(bst, bsh, addr_port, offs);
|
||||
CT_BUS_WEIGHT(chp)
|
||||
regv = bus_space_read_1(bst, bsh, ctrl_port);
|
||||
CT_BUS_WEIGHT(chp)
|
||||
return regv;
|
||||
}
|
||||
|
||||
static __inline void
|
||||
ct_cr_write_1(chp, offs, val)
|
||||
struct ct_bus_access_handle *chp;
|
||||
bus_addr_t offs;
|
||||
u_int8_t val;
|
||||
{
|
||||
bus_space_tag_t bst = chp->ch_iot;
|
||||
bus_space_handle_t bsh = chp->ch_ioh;
|
||||
|
||||
bus_space_write_1(bst, bsh, addr_port, offs);
|
||||
CT_BUS_WEIGHT
|
||||
CT_BUS_WEIGHT(chp)
|
||||
bus_space_write_1(bst, bsh, ctrl_port, val);
|
||||
CT_BUS_WEIGHT
|
||||
CT_BUS_WEIGHT(chp)
|
||||
}
|
||||
|
||||
static __inline u_int8_t
|
||||
ct_cmdp_read_1(chp)
|
||||
struct ct_bus_access_handle *chp;
|
||||
{
|
||||
u_int8_t regv;
|
||||
|
||||
regv = bus_space_read_1(chp->ch_iot, chp->ch_ioh, cmd_port);
|
||||
CT_BUS_WEIGHT(chp)
|
||||
return regv;
|
||||
}
|
||||
|
||||
static __inline void
|
||||
ct_cmdp_write_1(chp, val)
|
||||
struct ct_bus_access_handle *chp;
|
||||
u_int8_t val;
|
||||
{
|
||||
|
||||
bus_space_write_1(chp->ch_iot, chp->ch_ioh, cmd_port, val);
|
||||
CT_BUS_WEIGHT(chp)
|
||||
}
|
||||
|
||||
#if defined(i386)
|
||||
@ -145,11 +213,4 @@ ct_cr_write_1(bst, bsh, offs, val)
|
||||
#else /* !i386 */
|
||||
#define SOFT_INTR_REQUIRED(slp)
|
||||
#endif /* !i386 */
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
typedef unsigned long vaddr_t;
|
||||
|
||||
#define delay(t) DELAY(t)
|
||||
#endif
|
||||
|
||||
#endif /* !_CT_MACHDEP_H_ */
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NecBSD: ctvar.h,v 1.4 1999/04/15 01:36:13 kmatsuda Exp $ */
|
||||
/* $NecBSD: ctvar.h,v 1.4.14.3 2001/06/20 06:13:34 honda Exp $ */
|
||||
/* $NetBSD$ */
|
||||
|
||||
/*
|
||||
* [NetBSD for NEC PC-98 series]
|
||||
* Copyright (c) 1995, 1996, 1997, 1998
|
||||
* Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000, 2001
|
||||
* NetBSD/pc98 porting staff. All rights reserved.
|
||||
* Copyright (c) 1995, 1996, 1997, 1998
|
||||
* Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000, 2001
|
||||
* Naofumi HONDA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -43,31 +43,53 @@
|
||||
/*****************************************************************
|
||||
* Host adapter structure
|
||||
*****************************************************************/
|
||||
struct ct_bus_access_handle {
|
||||
bus_space_tag_t ch_iot; /* core chip ctrl port tag */
|
||||
bus_space_tag_t ch_delayt; /* delay port tag */
|
||||
bus_space_tag_t ch_datat; /* data port tag (pio) */
|
||||
bus_space_tag_t ch_memt; /* data port tag (shm) */
|
||||
|
||||
bus_space_handle_t ch_ioh;
|
||||
bus_space_handle_t ch_delaybah;
|
||||
bus_space_handle_t ch_datah;
|
||||
bus_space_handle_t ch_memh;
|
||||
|
||||
void (*ch_bus_weight) __P((struct ct_bus_access_handle *));
|
||||
|
||||
#ifdef CT_USE_RELOCATE_OFFSET
|
||||
bus_addr_t ch_offset[4];
|
||||
#endif /* CT_USE_RELOCATE_OFFSET */
|
||||
};
|
||||
|
||||
struct ct_softc {
|
||||
struct scsi_low_softc sc_sclow; /* generic data */
|
||||
|
||||
struct ct_bus_access_handle sc_ch; /* bus access handle */
|
||||
|
||||
#ifdef __NetBSD__
|
||||
bus_dma_tag_t sc_dmat; /* data DMA tag */
|
||||
|
||||
void *sc_ih;
|
||||
#endif /* __NetBSD__ */
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
struct resource *port_res;
|
||||
struct resource *mem_res;
|
||||
struct resource *irq_res;
|
||||
struct resource *drq_res;
|
||||
|
||||
bus_space_tag_t sc_iot; /* core chip ctrl port tag */
|
||||
bus_space_tag_t sc_datat; /* data port tag (pio) */
|
||||
bus_space_tag_t sc_memt; /* data port tag (shm) */
|
||||
bus_dma_tag_t sc_dmat; /* data DMA tag */
|
||||
bus_dmamap_t sc_dmamapt; /* data DMAMAP tag */
|
||||
|
||||
bus_space_handle_t sc_ioh;
|
||||
bus_space_handle_t sc_datah;
|
||||
bus_space_handle_t sc_memh;
|
||||
|
||||
void *sc_ih;
|
||||
int sc_wc; /* weight counter */
|
||||
#endif /* __FreeBSD__ */
|
||||
|
||||
int sc_chiprev; /* chip version */
|
||||
#define CT_WD33C93_A 0x00000
|
||||
#define CT_WD33C93_B 0x10000
|
||||
#define CT_WD33C93_C 0x20000
|
||||
#define CT_WD33C93 0x00000
|
||||
#define CT_WD33C93_A 0x10000
|
||||
#define CT_AM33C93_A 0x10001
|
||||
#define CT_WD33C93_B 0x20000
|
||||
#define CT_WD33C93_C 0x30000
|
||||
|
||||
int sc_xmode;
|
||||
#define CT_XMODE_PIO 1
|
||||
@ -80,6 +102,7 @@ struct ct_softc {
|
||||
int sc_satgo; /* combination cmd start */
|
||||
#define CT_SAT_GOING 1
|
||||
|
||||
int sc_tmaxcnt;
|
||||
int sc_atten; /* attention */
|
||||
u_int8_t sc_creg; /* control register value */
|
||||
|
||||
@ -89,20 +112,22 @@ struct ct_softc {
|
||||
u_int cs_syncr;
|
||||
} *sc_sdp; /* synchronous data table pt */
|
||||
|
||||
struct ct_synch_data sc_default_sdt[16];
|
||||
|
||||
/*
|
||||
* Machdep stuff.
|
||||
*/
|
||||
void *ct_hw; /* point to bshw_softc etc ... */
|
||||
void (*ct_dma_xfer_start) __P((struct ct_softc *));
|
||||
void (*ct_pio_xfer_start) __P((struct ct_softc *));
|
||||
int (*ct_dma_xfer_start) __P((struct ct_softc *));
|
||||
int (*ct_pio_xfer_start) __P((struct ct_softc *));
|
||||
void (*ct_dma_xfer_stop) __P((struct ct_softc *));
|
||||
void (*ct_pio_xfer_stop) __P((struct ct_softc *));
|
||||
void (*ct_bus_reset) __P((struct ct_softc *));
|
||||
void (*ct_synch_setup) __P((struct ct_softc *, struct lun_info *));
|
||||
void (*ct_synch_setup) __P((struct ct_softc *, struct targ_info *));
|
||||
};
|
||||
|
||||
/*****************************************************************
|
||||
* Target information
|
||||
* Lun information
|
||||
*****************************************************************/
|
||||
struct ct_targ_info {
|
||||
struct targ_info cti_ti;
|
||||
@ -113,14 +138,7 @@ struct ct_targ_info {
|
||||
/*****************************************************************
|
||||
* PROTO
|
||||
*****************************************************************/
|
||||
#ifdef __NetBSD__
|
||||
#include <i386/Cbus/dev/ct/ct_machdep.h>
|
||||
#endif
|
||||
#ifdef __FreeBSD__
|
||||
#include <dev/ct/ct_machdep.h>
|
||||
#endif
|
||||
|
||||
int ctprobesubr __P((bus_space_tag_t, bus_space_handle_t ioh, u_int, int, u_int));
|
||||
int ctprobesubr __P((struct ct_bus_access_handle *, u_int, int, u_int, int *));
|
||||
void ctattachsubr __P((struct ct_softc *));
|
||||
int ctprint __P((void *, const char *));
|
||||
int ctintr __P((void *));
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -341,10 +341,13 @@ static void
|
||||
ncv_card_unload(DEVPORT_PDEVICE devi)
|
||||
{
|
||||
struct ncv_softc *sc = DEVPORT_PDEVGET_SOFTC(devi);
|
||||
intrmask_t s;
|
||||
|
||||
printf("%s: unload\n", sc->sc_sclow.sl_xname);
|
||||
s = splcam();
|
||||
scsi_low_deactivate((struct scsi_low_softc *)sc);
|
||||
scsi_low_dettach(&sc->sc_sclow);
|
||||
splx(s);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -384,6 +387,7 @@ ncvattach(DEVPORT_PDEVICE devi)
|
||||
bus_addr_t offset = 0;
|
||||
u_int iobase = DEVPORT_PDEVIOBASE(devi);
|
||||
#endif
|
||||
intrmask_t s;
|
||||
char dvname[16]; /* SCSI_LOW_DVNAME_LEN */
|
||||
|
||||
strcpy(dvname, "ncv");
|
||||
@ -426,9 +430,9 @@ ncvattach(DEVPORT_PDEVICE devi)
|
||||
slp->sl_hostid = NCV_HOSTID;
|
||||
slp->sl_cfgflags = flags;
|
||||
|
||||
s = splcam();
|
||||
ncvattachsubr(sc);
|
||||
|
||||
sc->sc_ih = ncvintr;
|
||||
splx(s);
|
||||
|
||||
return(NCVIOSZ);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NecBSD: ncr53c500hw.h,v 1.6 1998/11/26 01:59:12 honda Exp $ */
|
||||
/* $NecBSD: ncr53c500hw.h,v 1.6.18.1 2001/06/08 06:27:44 honda Exp $ */
|
||||
/* $NetBSD$ */
|
||||
|
||||
/*
|
||||
@ -44,16 +44,20 @@
|
||||
|
||||
struct ncv_hw {
|
||||
/* configuration images */
|
||||
u_int8_t cfg1;
|
||||
u_int8_t cfg2;
|
||||
u_int8_t cfg3;
|
||||
u_int8_t cfg4;
|
||||
u_int8_t cfg5;
|
||||
u_int8_t hw_cfg1;
|
||||
u_int8_t hw_cfg2;
|
||||
u_int8_t hw_cfg3;
|
||||
u_int8_t hw_cfg4;
|
||||
u_int8_t hw_cfg5;
|
||||
|
||||
/* synch */
|
||||
u_int8_t clk;
|
||||
u_int8_t mperiod;
|
||||
u_int8_t moffset;
|
||||
u_int8_t hw_clk;
|
||||
u_int8_t hw_mperiod;
|
||||
u_int8_t hw_moffset;
|
||||
|
||||
/* cfg3 quirks */
|
||||
u_int8_t hw_cfg3_fscsi;
|
||||
u_int8_t hw_cfg3_fclk;
|
||||
};
|
||||
|
||||
/* dvcfg */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NecBSD: ncr53c500hwtab.h,v 1.2 1998/11/26 01:59:13 honda Exp $ */
|
||||
/* $NecBSD: ncr53c500hwtab.h,v 1.2.18.1 2001/06/08 06:27:44 honda Exp $ */
|
||||
/* $NetBSD$ */
|
||||
|
||||
/*
|
||||
@ -34,14 +34,16 @@
|
||||
*/
|
||||
|
||||
static struct ncv_hw ncv_template = {
|
||||
NCV_HOSTID,
|
||||
C2_FE | C2_SCSI2,
|
||||
C3_FCLK,
|
||||
C4_ANE,
|
||||
0x80,
|
||||
0, /* CFG1 img */
|
||||
C2_FE | C2_SCSI2, /* CFG2 img */
|
||||
0, /* CFG3 img */
|
||||
C4_ANE, /* CFG4 img */
|
||||
0x80, /* CFG5 img */
|
||||
|
||||
CLK_40M_F,
|
||||
CLK_40M_F, /* clock */
|
||||
200 / 4, /* max period */
|
||||
15, /* max offset */
|
||||
|
||||
200 / 4,
|
||||
15,
|
||||
0x10, /* CFG3_FSCSI bit */
|
||||
0x08, /* CFG3_FCLK bit */
|
||||
};
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NecBSD: ncr53c500reg.h,v 1.5 1998/12/26 11:50:01 honda Exp $ */
|
||||
/* $NecBSD: ncr53c500reg.h,v 1.5.14.1 2001/06/08 06:27:44 honda Exp $ */
|
||||
/* $NetBSD$ */
|
||||
|
||||
/*
|
||||
@ -85,11 +85,6 @@
|
||||
/* cfg4 */
|
||||
#define C4_ANE 0x04
|
||||
|
||||
/* cfg3 */
|
||||
#define C3_NULL 0x00
|
||||
#define C3_FCLK 0x08 /* Fast SCSI */
|
||||
#define C3_FSCSI 0x10 /* Fast Clock (>25Mhz) */
|
||||
|
||||
/* cfg2 */
|
||||
#define C2_SCSI2 0x08 /* SCSI-2 Enable */
|
||||
#define C2_FE 0x40 /* Features Enable */
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NecBSD: ncr53c500var.h,v 1.11 1998/11/28 18:42:42 honda Exp $ */
|
||||
/* $NecBSD: ncr53c500var.h,v 1.11.18.1 2001/06/08 06:27:45 honda Exp $ */
|
||||
/* $NetBSD$ */
|
||||
|
||||
/*
|
||||
* [NetBSD for NEC PC-98 series]
|
||||
* Copyright (c) 1995, 1996, 1997, 1998
|
||||
* Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000, 2001
|
||||
* NetBSD/pc98 porting staff. All rights reserved.
|
||||
* Copyright (c) 1995, 1996, 1997, 1998
|
||||
* Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000, 2001
|
||||
* Naofumi HONDA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -42,18 +42,20 @@
|
||||
struct ncv_softc {
|
||||
struct scsi_low_softc sc_sclow; /* generic data */
|
||||
|
||||
#ifdef __NetBSD__
|
||||
bus_space_tag_t sc_iot;
|
||||
bus_space_tag_t sc_memt;
|
||||
bus_space_handle_t sc_ioh;
|
||||
|
||||
void *sc_ih;
|
||||
int sc_wc; /* weight counter */
|
||||
int sc_selstop; /* sel atn stop asserted */
|
||||
int sc_compseq; /* completion seq cmd asserted */
|
||||
int sc_tdatalen; /* temp xfer data len */
|
||||
#endif /* __NetBSD__ */
|
||||
|
||||
struct ncv_hw sc_hw; /* hardware register images */
|
||||
#if defined (__FreeBSD__) && __FreeBSD_version >= 400001
|
||||
#ifdef __FreeBSD__
|
||||
bus_space_tag_t sc_iot;
|
||||
bus_space_tag_t sc_memt;
|
||||
bus_space_handle_t sc_ioh;
|
||||
|
||||
#if __FreeBSD_version >= 400001
|
||||
int port_rid;
|
||||
int port_rid_dmy;
|
||||
int irq_rid;
|
||||
@ -62,19 +64,29 @@ struct ncv_softc {
|
||||
struct resource *port_res_dmy;
|
||||
struct resource *irq_res;
|
||||
struct resource *mem_res;
|
||||
|
||||
void *ncv_intrhand;
|
||||
#endif
|
||||
#endif /* __FreeBSD_version__ */
|
||||
#endif /* __FreeBSD__ */
|
||||
|
||||
int sc_tmaxcnt;
|
||||
int sc_selstop; /* sel atn stop asserted */
|
||||
int sc_compseq; /* completion seq cmd asserted */
|
||||
int sc_sdatalen; /* start datalen */
|
||||
int sc_tdatalen; /* temp xfer data len */
|
||||
|
||||
struct ncv_hw sc_hw; /* hardware register images */
|
||||
};
|
||||
|
||||
/*****************************************************************
|
||||
* Target information
|
||||
* Lun information
|
||||
*****************************************************************/
|
||||
struct ncv_targ_info {
|
||||
struct targ_info nti_ti;
|
||||
|
||||
u_int8_t nti_reg_cfg3; /* cfg3 images per target */
|
||||
u_int8_t nti_reg_offset; /* synch offset register per target */
|
||||
u_int8_t nti_reg_period; /* synch period register per target */
|
||||
u_int8_t nti_reg_cfg3; /* cfg3 images per lun */
|
||||
u_int8_t nti_reg_offset; /* synch offset register per lun */
|
||||
u_int8_t nti_reg_period; /* synch period register per lun */
|
||||
};
|
||||
|
||||
/*****************************************************************
|
||||
|
1348
sys/dev/nsp/nsp.c
1348
sys/dev/nsp/nsp.c
File diff suppressed because it is too large
Load Diff
@ -318,10 +318,13 @@ static void
|
||||
nsp_card_unload(DEVPORT_PDEVICE devi)
|
||||
{
|
||||
struct nsp_softc *sc = DEVPORT_PDEVGET_SOFTC(devi);
|
||||
intrmask_t s;
|
||||
|
||||
printf("%s: unload\n",sc->sc_sclow.sl_xname);
|
||||
s = splcam();
|
||||
scsi_low_deactivate((struct scsi_low_softc *)sc);
|
||||
scsi_low_dettach(&sc->sc_sclow);
|
||||
splx(s);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -352,6 +355,7 @@ nspattach(DEVPORT_PDEVICE devi)
|
||||
struct scsi_low_softc *slp;
|
||||
u_int32_t flags = DEVPORT_PDEVFLAGS(devi);
|
||||
u_int iobase = DEVPORT_PDEVIOBASE(devi);
|
||||
intrmask_t s;
|
||||
char dvname[16];
|
||||
|
||||
strcpy(dvname,"nsp");
|
||||
@ -406,9 +410,9 @@ nspattach(DEVPORT_PDEVICE devi)
|
||||
slp->sl_hostid = NSP_HOSTID;
|
||||
slp->sl_cfgflags = flags;
|
||||
|
||||
s = splcam();
|
||||
nspattachsubr(sc);
|
||||
|
||||
sc->sc_ih = nspintr;
|
||||
splx(s);
|
||||
|
||||
return(NSP_IOSIZE);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NecBSD: nspreg.h,v 1.4 1999/04/15 01:35:55 kmatsuda Exp $ */
|
||||
/* $NecBSD: nspreg.h,v 1.4.14.3 2001/06/29 06:27:53 honda Exp $ */
|
||||
/* $NetBSD$ */
|
||||
|
||||
/*
|
||||
@ -92,6 +92,7 @@
|
||||
#define IRQPHS_RSEL 0x20
|
||||
#define IRQPHS_FIFO 0x40
|
||||
#define IRQPHS_RST 0x80
|
||||
#define IRQPHS_PHMASK (IRQPHS_LCD | IRQPHS_LMSG | IRQPHS_LIO)
|
||||
|
||||
#define NSPR_TIMERCNT 0x17
|
||||
|
||||
@ -125,6 +126,9 @@
|
||||
#define ARBITS_RESEL 0x08
|
||||
|
||||
#define NSPR_PARITYR 0x1B /* (W/R) */
|
||||
#define PARITYR_ENABLE 0x01
|
||||
#define PARITYR_CLEAR 0x02
|
||||
#define PARITYR_PE 0x02
|
||||
|
||||
#define NSPR_CMDCR 0x1C /* (W) */
|
||||
#define CMDCR_PTCLR 0x01
|
||||
@ -139,6 +143,9 @@
|
||||
#define PTCLRR_REQ 0x04
|
||||
#define PTCLRR_HOST 0x08
|
||||
#define PTCLRR_RSS 0x30
|
||||
#define PTCLRR_RSS_ACK 0x00
|
||||
#define PTCLRR_RSS_REQ 0x10
|
||||
#define PTCLRR_RSS_HOST 0x20
|
||||
|
||||
#define NSPR_XFERCR 0x1E /* (R) */
|
||||
|
||||
@ -185,6 +192,12 @@
|
||||
#define SCBUSMON_PHMASK \
|
||||
(SCBUSMON_SEL | SCBUSMON_CD | SCBUSMON_MSG | SCBUSMON_IO)
|
||||
|
||||
/* Data phase */
|
||||
#define NSP_IS_PHASE_DATA(ph) \
|
||||
((((ph) & SCBUSMON_PHMASK) & ~SCBUSMON_IO) == 0)
|
||||
#define NSP_IS_IRQPHS_DATA(ph) \
|
||||
((((ph) & IRQPHS_PHMASK) & ~SCBUSMON_IO) == 0)
|
||||
|
||||
/* SCSI phase */
|
||||
#define PHASE_CMD (SCBUSMON_CMD & SCBUSMON_PHMASK)
|
||||
#define PHASE_DATAIN (SCBUSMON_DATAIN & SCBUSMON_PHMASK)
|
||||
@ -194,6 +207,13 @@
|
||||
#define PHASE_MSGOUT (SCBUSMON_MSGOUT & SCBUSMON_PHMASK)
|
||||
#define PHASE_SEL (SCBUSMON_SEL | SCBUSMON_IO)
|
||||
|
||||
#define IRQPHS_CMD (IRQPHS_LCD)
|
||||
#define IRQPHS_DATAIN (IRQPHS_LIO)
|
||||
#define IRQPHS_DATAOUT (0)
|
||||
#define IRQPHS_STATUS (IRQPHS_LCD | IRQPHS_LIO)
|
||||
#define IRQPHS_MSGIN (IRQPHS_LCD | IRQPHS_LMSG | IRQPHS_LIO)
|
||||
#define IRQPHS_MSGOUT (IRQPHS_LCD | IRQPHS_LMSG)
|
||||
|
||||
/* Size */
|
||||
#define NSP_MEMSIZE NBPG
|
||||
#define NSP_IOSIZE 16
|
||||
|
@ -1,11 +1,14 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NecBSD: nspvar.h,v 1.7 1999/04/15 01:35:55 kmatsuda Exp $ */
|
||||
/* $NecBSD: nspvar.h,v 1.7.14.5 2001/06/29 06:27:54 honda Exp $ */
|
||||
/* $NetBSD$ */
|
||||
|
||||
/*
|
||||
* [NetBSD for NEC PC-98 series]
|
||||
* Copyright (c) 1998
|
||||
* Copyright (c) 1998, 1999, 2000, 2001
|
||||
* NetBSD/pc98 porting staff. All rights reserved.
|
||||
*
|
||||
* Copyright (c) 1998, 1999, 2000, 2001
|
||||
* Naofumi HONDA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -40,48 +43,57 @@
|
||||
struct nsp_softc {
|
||||
struct scsi_low_softc sc_sclow; /* generic data */
|
||||
|
||||
#ifdef __NetBSD__
|
||||
bus_space_tag_t sc_iot;
|
||||
bus_space_handle_t sc_ioh;
|
||||
bus_space_tag_t sc_memt;
|
||||
bus_space_handle_t sc_memh;
|
||||
|
||||
void *sc_ih;
|
||||
int sc_wc;
|
||||
#endif /* __NetBSD__ */
|
||||
|
||||
int sc_seltout; /* selection timeout counter */
|
||||
int sc_timer; /* timer start */
|
||||
#ifdef __FreeBSD__
|
||||
bus_space_tag_t sc_iot;
|
||||
bus_space_handle_t sc_ioh;
|
||||
bus_space_tag_t sc_memt;
|
||||
bus_space_handle_t sc_memh;
|
||||
|
||||
int sc_xmode;
|
||||
#define NSP_HIGH_SMIT 2 /* write address data mode */
|
||||
#define NSP_MID_SMIT 1 /* mem access */
|
||||
#define NSP_PIO 0 /* io access */
|
||||
|
||||
u_int sc_idbit; /* host id bit pattern */
|
||||
u_int sc_mask; /* bus width mask */
|
||||
u_int sc_cnt; /* fifo R/W count (host) */
|
||||
u_int8_t sc_iclkdiv; /* scsi chip clock divisor */
|
||||
u_int8_t sc_clkdiv; /* asic chip clock divisor */
|
||||
u_int8_t sc_xfermr; /* fifo control reg */
|
||||
u_int8_t sc_icr; /* interrupt control reg */
|
||||
|
||||
u_int8_t sc_busc; /* busc registers */
|
||||
u_long sc_ringp; /* data buffer ring pointer */
|
||||
#if defined (__FreeBSD__) && __FreeBSD_version >= 400001
|
||||
#if __FreeBSD_version >= 400001
|
||||
int port_rid;
|
||||
int irq_rid;
|
||||
int mem_rid;
|
||||
struct resource *port_res;
|
||||
struct resource *irq_res;
|
||||
struct resource *mem_res;
|
||||
|
||||
void *nsp_intrhand;
|
||||
#endif
|
||||
#endif /* __FreeBSD_version */
|
||||
#endif /* __FreeBSD__ */
|
||||
|
||||
int sc_tmaxcnt; /* timeout count */
|
||||
int sc_seltout; /* selection timeout counter */
|
||||
int sc_timer; /* timer start */
|
||||
|
||||
int sc_suspendio; /* SMIT: data suspendio bytes */
|
||||
u_int8_t sc_xfermr; /* SMIT: fifo control reg */
|
||||
int sc_dataout_timeout; /* data out timeout counter */
|
||||
|
||||
u_int sc_idbit; /* host id bit pattern */
|
||||
u_int sc_cnt; /* fifo R/W count (host) */
|
||||
|
||||
u_int8_t sc_iclkdiv; /* scsi chip clock divisor */
|
||||
u_int8_t sc_clkdiv; /* asic chip clock divisor */
|
||||
u_int8_t sc_icr; /* interrupt control reg */
|
||||
|
||||
u_int8_t sc_busc; /* busc registers */
|
||||
u_int8_t sc_parr; /* parity control register */
|
||||
};
|
||||
|
||||
/*****************************************************************
|
||||
* Target information
|
||||
* Lun information
|
||||
*****************************************************************/
|
||||
struct nsp_targ_info {
|
||||
struct targ_info nti_ti; /* generic target info */
|
||||
struct targ_info nti_ti; /* generic lun info */
|
||||
|
||||
u_int8_t nti_reg_syncr; /* sync registers per devices */
|
||||
u_int8_t nti_reg_ackwidth; /* ackwidth per devices */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -237,10 +237,13 @@ static void
|
||||
stg_isa_unload(device_t devi)
|
||||
{
|
||||
struct stg_softc *sc = device_get_softc(devi);
|
||||
intrmask_t s;
|
||||
|
||||
printf("%s: unload\n",sc->sc_sclow.sl_xname);
|
||||
s = splcam();
|
||||
scsi_low_deactivate((struct scsi_low_softc *)sc);
|
||||
scsi_low_dettach(&sc->sc_sclow);
|
||||
splx(s);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -263,7 +266,7 @@ stgattach(device_t devi)
|
||||
struct scsi_low_softc *slp;
|
||||
u_int32_t flags = device_get_flags(devi);
|
||||
u_int iobase = bus_get_resource_start(devi, SYS_RES_IOPORT, 0);
|
||||
|
||||
intrmask_t s;
|
||||
char dvname[16];
|
||||
|
||||
strcpy(dvname,"stg");
|
||||
@ -288,9 +291,9 @@ stgattach(device_t devi)
|
||||
slp->sl_hostid = STG_HOSTID;
|
||||
slp->sl_cfgflags = flags;
|
||||
|
||||
s = splcam();
|
||||
stgattachsubr(sc);
|
||||
|
||||
sc->sc_ih = stgintr;
|
||||
splx(s);
|
||||
|
||||
return(STGIOSZ);
|
||||
}
|
||||
|
@ -319,10 +319,13 @@ static void
|
||||
stg_card_unload(DEVPORT_PDEVICE devi)
|
||||
{
|
||||
struct stg_softc *sc = DEVPORT_PDEVGET_SOFTC(devi);
|
||||
intrmask_t s;
|
||||
|
||||
printf("%s: unload\n",sc->sc_sclow.sl_xname);
|
||||
s = splcam();
|
||||
scsi_low_deactivate((struct scsi_low_softc *)sc);
|
||||
scsi_low_dettach(&sc->sc_sclow);
|
||||
splx(s);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -353,7 +356,7 @@ stgattach(DEVPORT_PDEVICE devi)
|
||||
struct scsi_low_softc *slp;
|
||||
u_int32_t flags = DEVPORT_PDEVFLAGS(devi);
|
||||
u_int iobase = DEVPORT_PDEVIOBASE(devi);
|
||||
|
||||
intrmask_t s;
|
||||
char dvname[16];
|
||||
|
||||
strcpy(dvname,"stg");
|
||||
@ -393,9 +396,9 @@ stgattach(DEVPORT_PDEVICE devi)
|
||||
slp->sl_hostid = STG_HOSTID;
|
||||
slp->sl_cfgflags = flags;
|
||||
|
||||
s = splcam();
|
||||
stgattachsubr(sc);
|
||||
|
||||
sc->sc_ih = stgintr;
|
||||
splx(s);
|
||||
|
||||
return(STGIOSZ);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NecBSD: tmc18c30reg.h,v 1.4 1998/03/14 07:05:23 kmatsuda Exp $ */
|
||||
/* $NecBSD: tmc18c30reg.h,v 1.4.24.1 2001/06/08 06:27:50 honda Exp $ */
|
||||
/* $NetBSD$ */
|
||||
|
||||
/*
|
||||
@ -57,14 +57,13 @@
|
||||
#define BSTAT_REQ 0x10
|
||||
#define BSTAT_SEL 0x20
|
||||
#define BSTAT_ACK 0x40
|
||||
#define BSTAT_PHMASK (BSTAT_MSG | BSTAT_IO | BSTAT_CMD)
|
||||
|
||||
#define tmc_ictl 0x02
|
||||
#define ICTL_FIFO 0x10
|
||||
#define ICTL_ARBIT 0x20
|
||||
#define ICTL_SEL 0x40
|
||||
#define ICTL_CD 0x80
|
||||
#define ICTL_ALLINT (ICTL_ARBIT | ICTL_CD | ICTL_SEL)
|
||||
#define ICTL_ALLINT (ICTL_ARBIT | ICTL_CD | ICTL_SEL | ICTL_FIFO)
|
||||
#define tmc_astat 0x02
|
||||
#define ASTAT_INT 0x01
|
||||
#define ASTAT_ARBIT 0x02
|
||||
@ -112,6 +111,7 @@
|
||||
#define tmc_cfg1 0x0a
|
||||
|
||||
#define tmc_ioctl 0x0b
|
||||
#define IOCTL_IO32 0x80
|
||||
#define tmc_cfg2 0x0b
|
||||
|
||||
#define tmc_wfifo 0x0c
|
||||
@ -127,11 +127,14 @@
|
||||
#define STATUS_PHASE (BSTAT_CMD|BSTAT_BSY|BSTAT_IO)
|
||||
#define MESSAGE_OUT_PHASE (BSTAT_CMD|BSTAT_MSG|BSTAT_BSY)
|
||||
#define MESSAGE_IN_PHASE (BSTAT_CMD|BSTAT_MSG|BSTAT_BSY|BSTAT_IO)
|
||||
|
||||
#define PHASE_RESELECTED (BSTAT_SEL|BSTAT_IO)
|
||||
|
||||
#define PHASE_MASK 0x2f
|
||||
#define RESEL_PHASE_MASK 0x2e
|
||||
#define BSTAT_PHMASK (BSTAT_MSG | BSTAT_IO | BSTAT_CMD)
|
||||
#define PHASE_MASK (BSTAT_SEL | BSTAT_BSY | BSTAT_PHMASK)
|
||||
#define RESEL_PHASE_MASK (BSTAT_SEL | BSTAT_PHMASK)
|
||||
|
||||
#define STG_IS_PHASE_DATA(st) \
|
||||
((((st) & PHASE_MASK) & ~BSTAT_IO) == BSTAT_BSY)
|
||||
|
||||
/* chip type */
|
||||
#define TMCCHIP_UNK 0x00
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NecBSD: tmc18c30var.h,v 1.12 1998/11/30 00:08:30 honda Exp $ */
|
||||
/* $NecBSD: tmc18c30var.h,v 1.12.18.2 2001/06/13 05:51:23 honda Exp $ */
|
||||
/* $NetBSD$ */
|
||||
|
||||
/*
|
||||
* [NetBSD for NEC PC-98 series]
|
||||
* Copyright (c) 1996, 1997, 1998
|
||||
* Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001
|
||||
* NetBSD/pc98 porting staff. All rights reserved.
|
||||
* Copyright (c) 1996, 1997, 1998
|
||||
* Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001
|
||||
* Naofumi HONDA. All rights reserved.
|
||||
* Copyright (c) 1996, 1997, 1998
|
||||
* Kouichi Matsuda. All rights reserved.
|
||||
@ -44,45 +44,57 @@
|
||||
struct stg_softc {
|
||||
struct scsi_low_softc sc_sclow; /* generic data */
|
||||
|
||||
#ifdef __NetBSD__
|
||||
bus_space_tag_t sc_iot;
|
||||
bus_space_tag_t sc_memt;
|
||||
bus_space_handle_t sc_ioh;
|
||||
|
||||
void *sc_ih;
|
||||
#endif /* __NetBSD__ */
|
||||
|
||||
int sc_wc; /* weight counter */
|
||||
#ifdef __FreeBSD__
|
||||
bus_space_tag_t sc_iot;
|
||||
bus_space_tag_t sc_memt;
|
||||
bus_space_handle_t sc_ioh;
|
||||
|
||||
u_int sc_chip; /* chip type */
|
||||
u_int sc_fsz; /* fifo size */
|
||||
u_int sc_idbit; /* host id bit */
|
||||
u_int8_t sc_fcb; /* fifo intr thread */
|
||||
|
||||
u_int8_t sc_fcWinit; /* write flags */
|
||||
u_int8_t sc_fcRinit; /* read flags */
|
||||
|
||||
u_int8_t sc_fcsp; /* special control flags */
|
||||
u_int8_t sc_icinit; /* interrupt masks */
|
||||
u_int8_t sc_busc; /* default bus control register */
|
||||
u_int8_t sc_imsg; /* identify msg required */
|
||||
u_int8_t sc_busimg; /* bus control register image */
|
||||
#if defined (__FreeBSD__) && __FreeBSD_version >= 400001
|
||||
#if __FreeBSD_version >= 400001
|
||||
int port_rid;
|
||||
int irq_rid;
|
||||
int mem_rid;
|
||||
struct resource *port_res;
|
||||
struct resource *irq_res;
|
||||
struct resource *mem_res;
|
||||
|
||||
void *stg_intrhand;
|
||||
#endif
|
||||
#endif /* __FreeBSD_version */
|
||||
#endif /* __FreeBSD__ */
|
||||
|
||||
int sc_tmaxcnt;
|
||||
u_int sc_chip; /* chip type */
|
||||
u_int sc_fsz; /* fifo size */
|
||||
u_int sc_idbit; /* host id bit */
|
||||
u_int sc_wthold; /* write thread */
|
||||
u_int sc_rthold; /* read thread */
|
||||
u_int sc_maxwsize; /* max write size */
|
||||
int sc_dataout_timeout; /* data out timeout counter */
|
||||
int sc_ubf_timeout; /* unexpected bus free timeout */
|
||||
|
||||
u_int8_t sc_fcWinit; /* write flags */
|
||||
u_int8_t sc_fcRinit; /* read flags */
|
||||
|
||||
u_int8_t sc_icinit; /* interrupt masks */
|
||||
u_int8_t sc_busc; /* default bus control register */
|
||||
u_int8_t sc_imsg; /* identify msg required */
|
||||
u_int8_t sc_busimg; /* bus control register image */
|
||||
};
|
||||
|
||||
/*****************************************************************
|
||||
* Target information
|
||||
* Lun information
|
||||
*****************************************************************/
|
||||
struct stg_targ_info {
|
||||
struct targ_info sti_ti; /* generic data */
|
||||
struct targ_info sti_ti; /* generic data */
|
||||
|
||||
u_int8_t sti_reg_synch; /* synch register per target */
|
||||
u_int8_t sti_reg_synch; /* synch register per lun */
|
||||
};
|
||||
|
||||
/*****************************************************************
|
||||
|
Loading…
Reference in New Issue
Block a user