typedef uint8_t physaddr[4];
typedef uint8_t physlen[4];
#define ltophys _lto4l
#define phystol _4ltol
#define BT_CTRL_PORT 0
#define BT_STAT_PORT 0
#define BT_CMD_PORT 1
#define BT_DATA_PORT 1
#define BT_INTR_PORT 2
#define BT_CTRL_HRST 0x80
#define BT_CTRL_SRST 0x40
#define BT_CTRL_IRST 0x20
#define BT_CTRL_SCRST 0x10
#define BT_STAT_STST 0x80
#define BT_STAT_DIAGF 0x40
#define BT_STAT_INIT 0x20
#define BT_STAT_IDLE 0x10
#define BT_STAT_CDF 0x08
#define BT_STAT_DF 0x04
#define BT_STAT_INVDCMD 0x01
#define BT_NOP 0x00
#define BT_MBX_INIT 0x01
#define BT_START_SCSI 0x02
#define BT_INQUIRE_REVISION 0x04
#define BT_MBO_INTR_EN 0x05
#if 0
#define BT_SEL_TIMEOUT_SET 0x06
#define BT_BUS_ON_TIME_SET 0x07
#define BT_BUS_OFF_TIME_SET 0x08
#define BT_SPEED_SET 0x09
#endif
#define BT_INQUIRE_DEVICES 0x0a
#define BT_INQUIRE_CONFIG 0x0b
#define BT_TARGET_EN 0x0c
#define BT_INQUIRE_SETUP 0x0d
#define BT_ECHO 0x1e
#define BT_INQUIRE_DEVICES_2 0x23
#define BT_MBX_INIT_EXTENDED 0x81
#define BT_INQUIRE_REVISION_3 0x84
#define BT_INQUIRE_REVISION_4 0x85
#define BT_INQUIRE_MODEL 0x8b
#define BT_INQUIRE_PERIOD 0x8c
#define BT_INQUIRE_EXTENDED 0x8d
#define BT_ROUND_ROBIN 0x8f
#define BT_INTR_ANYINTR 0x80
#define BT_INTR_SCRD 0x08
#define BT_INTR_HACC 0x04
#define BT_INTR_MBOA 0x02
#define BT_INTR_MBIF 0x01
struct bt_mbx_out {
physaddr ccb_addr;
u_char dummy[3];
u_char cmd;
};
struct bt_mbx_in {
physaddr ccb_addr;
u_char dummy[3];
u_char stat;
};
#define BT_MBO_FREE 0x0
#define BT_MBO_START 0x1
#define BT_MBO_ABORT 0x2
#define BT_MBI_FREE 0x0
#define BT_MBI_OK 0x1
#define BT_MBI_ABORT 0x2
#define BT_MBI_UNKNOWN 0x3
#define BT_MBI_ERROR 0x4
#if defined(BIG_DMA)
#define BT_NSEG 2048
#else
#define BT_NSEG (MAXPHYS / PAGE_SIZE)
#endif
struct bt_scat_gath {
physlen seg_len;
physaddr seg_addr;
};
struct bt_ccb {
u_char opcode;
u_char:3, data_in:1, data_out:1,:3;
u_char scsi_cmd_length;
u_char req_sense_length;
physlen data_length;
physaddr data_addr;
u_char dummy1[2];
u_char host_stat;
u_char target_stat;
u_char target;
u_char lun;
u_char scsi_cmd[12];
u_char dummy2[1];
u_char link_id;
physaddr link_addr;
physaddr sense_ptr;
struct scsi_sense_data scsi_sense;
struct bt_scat_gath scat_gath[BT_NSEG];
TAILQ_ENTRY(bt_ccb) chain;
struct bt_ccb *nexthash;
long hashkey;
struct scsipi_xfer *xs;
int flags;
#define CCB_ALLOC 0x01
#define CCB_ABORT 0x02
#ifdef BTDIAG
#define CCB_SENDING 0x04
#endif
int timeout;
};
struct bt_buf {
TAILQ_ENTRY(bt_buf) chain;
char buf[4096 - 2 * sizeof(struct bt_buf *)];
};
#define BT_INITIATOR_CCB 0x00
#define BT_TARGET_CCB 0x01
#define BT_INIT_SCAT_GATH_CCB 0x02
#define BT_RESET_CCB 0x81
#define BT_OK 0x00
#define BT_LINK_OK 0x0a
#define BT_LINK_IT 0x0b
#define BT_SEL_TIMEOUT 0x11
#define BT_OVER_UNDER 0x12
#define BT_BUS_FREE 0x13
#define BT_INV_BUS 0x14
#define BT_BAD_MBO 0x15
#define BT_BAD_CCB 0x16
#define BT_BAD_LINK 0x17
#define BT_INV_TARGET 0x18
#define BT_CCB_DUP 0x19
#define BT_INV_CCB 0x1a
struct bt_extended_inquire {
struct {
u_char opcode;
u_char len;
} cmd;
struct {
u_char bus_type;
#define BT_BUS_TYPE_24BIT 'A'
#define BT_BUS_TYPE_32BIT 'E'
#define BT_BUS_TYPE_MCA 'M'
u_char bios_address;
u_short max_segment;
} reply;
};
struct bt_config {
struct {
u_char opcode;
} cmd;
struct {
u_char chan;
u_char intr;
u_char scsi_dev:3;
u_char :5;
} reply;
};
struct bt_toggle {
struct {
u_char opcode;
u_char enable;
} cmd;
};
struct bt_mailbox {
struct {
u_char opcode;
u_char nmbx;
physaddr addr;
} cmd;
};
struct bt_model {
struct {
u_char opcode;
u_char len;
} cmd;
struct {
u_char id[4];
u_char version[2];
} reply;
};
struct bt_revision {
struct {
u_char opcode;
} cmd;
struct {
u_char board_type;
u_char custom_feature;
char firm_revision;
u_char firm_version;
} reply;
};
struct bt_digit {
struct {
u_char opcode;
} cmd;
struct {
u_char digit;
} reply;
};
struct bt_devices {
struct {
u_char opcode;
} cmd;
struct {
u_char junk[8];
} reply;
};
struct bt_setup {
struct {
u_char opcode;
u_char len;
} cmd;
struct {
u_char sync_neg:1;
u_char parity:1;
u_char :6;
u_char speed;
u_char bus_on;
u_char bus_off;
u_char num_mbx;
u_char mbx[3];
struct {
u_char offset:4;
u_char period:3;
u_char valid:1;
} sync[8];
u_char disc_sts;
} reply;
};
struct bt_period {
struct {
u_char opcode;
u_char len;
} cmd;
struct {
u_char period[8];
} reply;
};
#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