typedef u_int8_t physaddr[4];
typedef u_int8_t physlen[4];
#define ltophys _lto4l
#define phystol _4ltol
#define BHA_CTRL_PORT 0
#define BHA_STAT_PORT 0
#define BHA_CMD_PORT 1
#define BHA_DATA_PORT 1
#define BHA_INTR_PORT 2
#define BHA_EXTGEOM_PORT 3
#define BHA_CTRL_HRST 0x80
#define BHA_CTRL_SRST 0x40
#define BHA_CTRL_IRST 0x20
#define BHA_CTRL_SCRST 0x10
#define BHA_STAT_STST 0x80
#define BHA_STAT_DIAGF 0x40
#define BHA_STAT_INIT 0x20
#define BHA_STAT_IDLE 0x10
#define BHA_STAT_CDF 0x08
#define BHA_STAT_DF 0x04
#define BHA_STAT_INVDCMD 0x01
#define BHA_NOP 0x00
#define BHA_MBX_INIT 0x01
#define BHA_START_SCSI 0x02
#define BHA_EXECUTE_BIOS_CMD 0x03
#define BHA_INQUIRE_REVISION 0x04
#define BHA_MBO_INTR_EN 0x05
#define BHA_SEL_TIMEOUT_SET 0x06
#define BHA_BUS_ON_TIME_SET 0x07
#define BHA_BUS_OFF_TIME_SET 0x08
#define BHA_BUS_SPEED_SET 0x09
#define BHA_INQUIRE_DEVICES 0x0a
#define BHA_INQUIRE_CONFIG 0x0b
#define BHA_TARGET_EN 0x0c
#define BHA_INQUIRE_SETUP 0x0d
#define BHA_WRITE_LRAM 0x1a
#define BHA_READ_LRAM 0x1b
#define BHA_WRITE_CHIP_FIFO 0x1c
#define BHA_READ_CHIP_FIFO 0x1d
#define BHA_ECHO 0x1f
#define BHA_ADAPTER_DIAGNOSTICS 0x20
#define BHA_SET_ADAPTER_OPTIONS 0x21
#define BHA_INQUIRE_DEVICES_2 0x23
#define BHA_INQUIRE_TARG_DEVS 0x24
#define BHA_DISABLE_HAC_INTR 0x25
#define BHA_MBX_INIT_EXTENDED 0x81
#define BHA_EXECUTE_SCSI_CMD 0x83
#define BHA_INQUIRE_REVISION_3 0x84
#define BHA_INQUIRE_REVISION_4 0x85
#define BHA_INQUIRE_PCI_INFO 0x86
#define BHA_INQUIRE_MODEL 0x8b
#define BHA_INQUIRE_PERIOD 0x8c
#define BHA_INQUIRE_EXTENDED 0x8d
#define BHA_ROUND_ROBIN 0x8f
#define BHA_STORE_LRAM 0x90
#define BHA_FETCH_LRAM 0x91
#define BHA_SAVE_TO_EEPROM 0x92
#define BHA_UPLOAD_AUTOSCSI 0x94
#define BHA_MODIFY_IOPORT 0x95
#define BHA_SET_CCB_FORMAT 0x96
#define BHA_WRITE_INQUIRY_BUF 0x9a
#define BHA_READ_INQUIRY_BUF 0x9b
#define BHA_FLASH_UP_DOWNLOAD 0xa7
#define BHA_READ_SCAM_DATA 0xa8
#define BHA_WRITE_SCAM_DATA 0xa9
#define BHA_INTR_ANYINTR 0x80
#define BHA_INTR_SCRD 0x08
#define BHA_INTR_HACC 0x04
#define BHA_INTR_MBOA 0x02
#define BHA_INTR_MBIF 0x01
struct bha_mbx_out {
physaddr ccb_addr;
u_int8_t reserved[3];
u_int8_t cmd;
};
struct bha_mbx_in {
physaddr ccb_addr;
u_int8_t host_stat;
u_int8_t target_stat;
u_int8_t reserved;
u_int8_t comp_stat;
};
#define BHA_MBO_FREE 0x0
#define BHA_MBO_START 0x1
#define BHA_MBO_ABORT 0x2
#define BHA_MBI_FREE 0x0
#define BHA_MBI_OK 0x1
#define BHA_MBI_ABORT 0x2
#define BHA_MBI_UNKNOWN 0x3
#define BHA_MBI_ERROR 0x4
#define BHA_MBI_BADCCB 0x5
#if defined(BIG_DMA)
WARNING...THIS WON'T WORK(won't fit on 1 page)
#if 0
#define BHA_NSEG 2048
#endif
#define BHA_NSEG 128
#else
#define BHA_NSEG 33
#endif
struct bha_scat_gath {
physlen seg_len;
physaddr seg_addr;
};
struct bha_ccb {
u_int8_t opcode;
#if BYTE_ORDER == LITTLE_ENDIAN
u_int8_t :3,
data_in :1,
data_out :1,
wide_tag_enable :1,
wide_tag_type :2;
#else
u_int8_t wide_tag_type :2,
wide_tag_enable :1,
data_out :1,
data_in :1,
:3;
#endif
u_int8_t scsi_cmd_length;
u_int8_t req_sense_length;
physlen data_length;
physaddr data_addr;
u_int8_t reserved1[2];
u_int8_t host_stat;
u_int8_t target_stat;
u_int8_t target;
#if BYTE_ORDER == LITTLE_ENDIAN
u_int8_t lun :5,
tag_enable :1,
tag_type :2;
#else
u_int8_t tag_type :2,
tag_enable :1,
lun :5;
#endif
u_int8_t scsi_cmd[12];
u_int8_t reserved2[1];
u_int8_t link_id;
physaddr link_addr;
physaddr sense_ptr;
struct scsi_sense_data scsi_sense;
struct bha_scat_gath scat_gath[BHA_NSEG];
TAILQ_ENTRY(bha_ccb) chain;
struct bha_ccb *nexthash;
bus_addr_t hashkey;
struct scsipi_xfer *xs;
int flags;
#define CCB_ALLOC 0x01
#define CCB_ABORT 0x02
#ifdef BHADIAG
#define CCB_SENDING 0x04
#endif
int timeout;
bus_dmamap_t dmamap_xfer;
};
#define BHA_INITIATOR_CCB 0x00
#define BHA_TARGET_CCB 0x01
#define BHA_INIT_SCAT_GATH_CCB 0x02
#define BHA_INIT_RESID_CCB 0x03
#define BHA_INIT_RESID_SG_CCB 0x04
#define BHA_RESET_CCB 0x81
#define BHA_OK 0x00
#define BHA_LINK_OK 0x0a
#define BHA_LINK_IT 0x0b
#define BHA_DATA_UNDRN 0x0c
#define BHA_SEL_TIMEOUT 0x11
#define BHA_OVER_UNDER 0x12
#define BHA_BUS_FREE 0x13
#define BHA_INV_BUS 0x14
#define BHA_BAD_MBO 0x15
#define BHA_BAD_CCB 0x16
#define BHA_BAD_LINK 0x17
#define BHA_INV_TARGET 0x18
#define BHA_CCB_DUP 0x19
#define BHA_INV_CCB 0x1a
#define BHA_AUTOSENSE_FAILED 0x1b
#define BHA_TAGGED_MSG_REJ 0x1c
#define BHA_UNSUP_MSG_RECVD 0x1d
#define BHA_HARDWARE_FAILURE 0x20
#define BHA_TARG_IGNORED_ATN 0x21
#define BHA_HA_SCSI_BUS_RESET 0x22
#define BHA_OTHER_SCSI_BUS_RESET 0x23
#define BHA_BAD_RECONNECT 0x24
#define BHA_HA_BUS_DEVICE_RESET 0x25
#define BHA_ABORT_QUEUE 0x26
#define BHA_SOFTWARE_FAILURE 0x27
#define BHA_HARDWARE_WATCHDOG 0x30
#define BHA_SCSI_PARITY_ERROR 0x34
struct bha_extended_inquire {
struct {
u_char opcode;
u_char len;
} cmd;
struct {
u_char bus_type;
#define BHA_BUS_TYPE_24BIT 'A'
#define BHA_BUS_TYPE_32BIT 'E'
#define BHA_BUS_TYPE_MCA 'M'
u_char bios_address;
u_short sg_limit;
u_char mbox_count;
u_char mbox_baseaddr[4];
u_char intrflags;
#define BHA_INTR_FASTEISA 0x04
#define BHA_INTR_LEVEL 0x40
u_char firmware_level[3];
u_char scsi_flags;
#define BHA_SCSI_WIDE 0x01
#define BHA_SCSI_DIFFERENTIAL 0x02
#define BHA_SCSI_SCAM 0x04
#define BHA_SCSI_ULTRA 0x08
#define BHA_SCSI_TERMINATION 0x10
} reply;
};
struct bha_config {
struct {
u_char opcode;
} cmd;
struct {
u_char chan;
u_char intr;
#if BYTE_ORDER == LITTLE_ENDIAN
u_char scsi_dev :3,
:5;
#else
u_char :5,
scsi_dev :3;
#endif
} reply;
};
struct bha_toggle {
struct {
u_char opcode;
u_char enable;
} cmd;
};
struct bha_mailbox {
struct {
u_char opcode;
u_char nmbx;
physaddr addr;
} cmd;
};
struct bha_model {
struct {
u_char opcode;
u_char len;
} cmd;
struct {
u_char id[4];
u_char version[2];
} reply;
};
struct bha_revision {
struct {
u_char opcode;
} cmd;
struct {
u_char board_type;
u_char custom_feature;
char firm_revision;
u_char firm_version;
} reply;
};
struct bha_digit {
struct {
u_char opcode;
} cmd;
struct {
u_char digit;
} reply;
};
struct bha_devices {
struct {
u_char opcode;
} cmd;
struct {
u_char lun_map[8];
} reply;
};
struct bha_sync {
#if BYTE_ORDER == LITTLE_ENDIAN
u_char offset :4,
period :3,
valid :1;
#else
u_char valid :1,
period :3,
offset :4;
#endif
};
struct bha_setup_reply {
#if BYTE_ORDER == LITTLE_ENDIAN
u_int8_t sync_neg :1,
parity :1,
:6;
#else
u_int8_t :6,
parity :1,
sync_neg :1;
#endif
u_int8_t speed;
u_int8_t bus_on;
u_int8_t bus_off;
u_int8_t num_mbx;
u_int8_t mbx[3];
struct bha_sync sync_low[8];
u_int8_t low_disc_info;
};
struct bha_setup_reply_wide {
u_int8_t signature;
u_int8_t letter_d;
u_int8_t ha_type;
u_int8_t low_wide_allowed;
u_int8_t low_wide_active;
struct bha_sync sync_high[8];
u_int8_t high_disc_info;
u_int8_t reserved;
u_int8_t high_wide_allowed;
u_int8_t high_wide_active;
};
struct bha_setup {
struct {
u_char opcode;
u_char len;
} cmd;
struct bha_setup_reply reply;
struct bha_setup_reply_wide reply_w;
};
struct bha_period_reply {
u_char period[8];
};
struct bha_period {
struct {
u_char opcode;
u_char len;
} cmd;
struct bha_period_reply reply;
struct bha_period_reply reply_w;
};
struct bha_isadisable {
struct {
u_char opcode;
u_char modifier;
} cmd;
};
#define BHA_IOMODIFY_330 0x00
#define BHA_IOMODIFY_334 0x01
#define BHA_IOMODIFY_DISABLE1 0x06
#define BHA_IOMODIFY_DISABLE2 0x07
#define INT9 0x01
#define INT10 0x02
#define INT11 0x04
#define INT12 0x08
#define INT14 0x20
#define INT15 0x40
#define EISADMA 0x00
#define CHAN0 0x01
#define CHAN5 0x20
#define CHAN6 0x40
#define CHAN7 0x80