aicvar.h revision 54136
1100894Srwatson/*- 2100894Srwatson * Copyright (c) 1999 Luoqi Chen. 3100894Srwatson * All rights reserved. 4100894Srwatson * 5100894Srwatson * Redistribution and use in source and binary forms, with or without 6100894Srwatson * modification, are permitted provided that the following conditions 7100894Srwatson * are met: 8100894Srwatson * 1. Redistributions of source code must retain the above copyright 9100894Srwatson * notice, this list of conditions and the following disclaimer. 10100894Srwatson * 2. Redistributions in binary form must reproduce the above copyright 11100894Srwatson * notice, this list of conditions and the following disclaimer in the 12100894Srwatson * documentation and/or other materials provided with the distribution. 13100894Srwatson * 14100894Srwatson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15100894Srwatson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16100894Srwatson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17100894Srwatson * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18100894Srwatson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19100894Srwatson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20100894Srwatson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21100894Srwatson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22100894Srwatson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23100894Srwatson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24100894Srwatson * SUCH DAMAGE. 25100894Srwatson * 26100894Srwatson * $FreeBSD: head/sys/dev/aic/aicvar.h 54136 1999-12-04 22:15:02Z luoqi $ 27100894Srwatson */ 28100894Srwatson 29100894Srwatson#include "aic.h" 30100894Srwatson 31100894Srwatsonstruct aic_transinfo { 32100894Srwatson u_int8_t period; 33100894Srwatson u_int8_t offset; 34100894Srwatson}; 35100894Srwatson 36100894Srwatsonstruct aic_tinfo { 37100894Srwatson u_int16_t lubusy; 38100894Srwatson u_int8_t flags; 39100894Srwatson u_int8_t scsirate; 40100894Srwatson struct aic_transinfo current; 41100894Srwatson struct aic_transinfo goal; 42100894Srwatson struct aic_transinfo user; 43100894Srwatson}; 44100894Srwatson 45100894Srwatson#define TINFO_DISC_ENB 0x01 46100894Srwatson#define TINFO_TAG_ENB 0x02 47100894Srwatson#define TINFO_SDTR_NEGO 0x04 48100894Srwatson#define TINFO_SDTR_SENT 0x08 49104300Sphk 50101173Srwatsonstruct aic_scb { 51100894Srwatson union ccb *ccb; 52100979Srwatson u_int8_t flags; 53100979Srwatson u_int8_t tag; 54100979Srwatson u_int8_t target; 55102949Sbde u_int8_t lun; 56100979Srwatson u_int8_t status; 57100979Srwatson u_int8_t cmd_len; 58101712Srwatson u_int8_t *cmd_ptr; 59100979Srwatson u_int32_t data_len; 60100979Srwatson u_int8_t *data_ptr; 61100894Srwatson}; 62100894Srwatson 63100979Srwatson#define ccb_scb_ptr spriv_ptr0 64100979Srwatson#define ccb_aic_ptr spriv_ptr1 65100979Srwatson 66100979Srwatson#define SCB_ACTIVE 0x01 67100979Srwatson#define SCB_DISCONNECTED 0x02 68100979Srwatson#define SCB_DEVICE_RESET 0x04 69100979Srwatson#define SCB_SENSE 0x08 70100979Srwatson 71100894Srwatsonstruct aic_softc { 72100979Srwatson int unit; 73100979Srwatson bus_space_tag_t tag; 74100979Srwatson bus_space_handle_t bsh; 75100979Srwatson bus_dma_tag_t dmat; 76100979Srwatson 77100979Srwatson struct cam_sim *sim; 78100979Srwatson struct cam_path *path; 79100979Srwatson TAILQ_HEAD(,ccb_hdr) pending_ccbs, nexus_ccbs; 80100979Srwatson struct aic_scb *nexus; 81100979Srwatson 82100979Srwatson u_int32_t flags; 83100979Srwatson u_int8_t initiator; 84100979Srwatson u_int8_t state; 85100979Srwatson u_int8_t target; 86100979Srwatson u_int8_t lun; 87100979Srwatson u_int8_t prev_phase; 88100979Srwatson 89100979Srwatson u_int8_t msg_outq; 90101712Srwatson u_int8_t msg_sent; 91101712Srwatson int msg_len; 92101712Srwatson char msg_buf[8]; 93101712Srwatson 94101712Srwatson struct aic_tinfo tinfo[8]; 95101712Srwatson struct aic_scb scbs[256]; 96101712Srwatson}; 97100979Srwatson 98100979Srwatson#define AIC_DISC_ENABLE 0x01 99100979Srwatson#define AIC_DMA_ENABLE 0x02 100100979Srwatson#define AIC_PARITY_ENABLE 0x04 101104517Srwatson#define AIC_DWIO_ENABLE 0x08 102100979Srwatson#define AIC_RESOURCE_SHORTAGE 0x10 103100979Srwatson#define AIC_DROP_MSGIN 0x20 104100979Srwatson#define AIC_BUSFREE_OK 0x40 105100979Srwatson 106100979Srwatson#define AIC_IDLE 0x00 107100979Srwatson#define AIC_SELECTING 0x01 108100979Srwatson#define AIC_RESELECTED 0x02 109100979Srwatson#define AIC_RECONNECTING 0x03 110100979Srwatson#define AIC_HASNEXUS 0x04 111100979Srwatson 112100979Srwatson#define AIC_MSG_IDENTIFY 0x01 113100979Srwatson#define AIC_MSG_TAG_Q 0x02 114100979Srwatson#define AIC_MSG_SDTR 0x04 115100979Srwatson#define AIC_MSG_WDTR 0x08 116100979Srwatson#define AIC_MSG_MSGBUF 0x80 117100979Srwatson 118100979Srwatson#define AIC_SYNC_PERIOD (200 / 4) 119100979Srwatson#define AIC_SYNC_OFFSET 8 120100979Srwatson 121100979Srwatson#define aic_inb(aic, port) \ 122100979Srwatson bus_space_read_1((aic)->tag, (aic)->bsh, (port)) 123100979Srwatson 124100979Srwatson#define aic_outb(aic, port, value) \ 125103513Srwatson bus_space_write_1((aic)->tag, (aic)->bsh, (port), (value)) 126103513Srwatson 127103513Srwatson#define aic_insb(aic, port, addr, count) \ 128104236Srwatson bus_space_read_multi_1((aic)->tag, (aic)->bsh, (port), (addr), (count)) 129103513Srwatson 130100979Srwatson#define aic_outsb(aic, port, addr, count) \ 131100979Srwatson bus_space_write_multi_1((aic)->tag, (aic)->bsh, (port), (addr), (count)) 132100979Srwatson 133100979Srwatson#define aic_insw(aic, port, addr, count) \ 134100979Srwatson bus_space_read_multi_2((aic)->tag, (aic)->bsh, (port), \ 135100979Srwatson (u_int16_t *)(addr), (count)) 136100979Srwatson 137100979Srwatson#define aic_outsw(aic, port, addr, count) \ 138100979Srwatson bus_space_write_multi_2((aic)->tag, (aic)->bsh, (port), \ 139100979Srwatson (u_int16_t *)(addr), (count)) 140103514Srwatson 141103514Srwatson#define aic_insl(aic, port, addr, count) \ 142103514Srwatson bus_space_read_multi_4((aic)->tag, (aic)->bsh, (port), \ 143104236Srwatson (u_int32_t *)(addr), (count)) 144103514Srwatson 145100979Srwatson#define aic_outsl(aic, port, addr, count) \ 146100979Srwatson bus_space_write_multi_4((aic)->tag, (aic)->bsh, (port), \ 147100979Srwatson (u_int32_t *)(addr), (count)) 148100979Srwatson 149100979Srwatsonextern int aic_probe __P((struct aic_softc *)); 150100979Srwatsonextern int aic_attach __P((struct aic_softc *)); 151100979Srwatsonextern int aic_detach __P((struct aic_softc *)); 152100979Srwatsonextern void aic_intr __P((void *)); 153100979Srwatson