#if defined(__DragonFly__)
#include "sili_dragonfly.h"
#else
#error "build for OS unknown"
#endif
#include "pmreg.h"
#include "atascsi.h"
#define NO_SILI_DEBUG
#ifdef SILI_DEBUG
#define DPRINTF(m, f...) do { if ((silidebug & (m)) == (m)) kprintf(f); } \
while (0)
#define SILI_D_TIMEOUT 0x00
#define SILI_D_VERBOSE 0x01
#define SILI_D_INTR 0x02
#define SILI_D_XFER 0x08
int silidebug = SILI_D_VERBOSE;
#else
#define DPRINTF(m, f...)
#endif
#define SILI_REG_SLOTST(n) (0x0000 + ((n) * 4))
#define SILI_REG_SLOTST_ATTN 0x80000000
#define SILI_REG_GCTL 0x0040
#define SILI_REG_GCTL_PORTEN(n) (1 << (n))
#define SILI_REG_GCTL_300CAP 0x01000000
#define SILI_REG_GCTL_I2C_IEN 0x20000000
#define SILI_REG_GCTL_MSIACK 0x40000000
#define SILI_REG_GCTL_GRESET 0x80000000
#define SILI_REG_GINT 0x0044
#define SILI_REG_GINT_I2C 0x20000000
#define SILI_REG_GINT_PORTST(n) (1 << (n))
#define SILI_REG_GINT_PORTMASK 0x0000FFFF
#define SILI_REG_PHYCONF 0x0048
#define SILI_REG_PHYCONF_ALLSS 0x000F
#define SILI_REG_BIST_CTL 0x0050
#define SILI_REG_BIST_CTL_TEN 0x80000000
#define SILI_REG_BIST_CTL_TPAT 0x40000000
#define SILI_REG_BIST_CTL_RXSEL(n) ((n) << 16)
#define SILI_REG_BIST_CTL_TXSEL(n) (1 << (n))
#define SILI_REG_BIST_PATTERN 0x0054
#define SILI_REG_BIST_STATUS 0x0058
#define SILI_REG_BIST_STATUS_CNT 0x000007FF
#define SILI_REG_BIST_STATUS_GOOD 0x80000000
#define SILI_REG_I2C_CTL 0x0060
#define SILI_REG_I2C_CTL_START 0x00000001
#define SILI_REG_I2C_CTL_STOP 0x00000002
#define SILI_REG_I2C_CTL_NACK 0x00000004
#define SILI_REG_I2C_CTL_TFDATA 0x00000008
#define SILI_REG_I2C_CTL_MABORT 0x00000010
#define SILI_REG_I2C_CTL_SCLEN 0x00000020
#define SILI_REG_I2C_CTL_UNITEN 0x00000040
#define SILI_REG_I2C_CTL_GCALLD 0x00000080
#define SILI_REG_I2C_CTL_TXBEI 0x00000100
#define SILI_REG_I2C_CTL_RXBFI 0x00000200
#define SILI_REG_I2C_CTL_BERRI 0x00000400
#define SILI_REG_I2C_CTL_STOPI 0x00000800
#define SILI_REG_I2C_CTL_ARBLI 0x00001000
#define SILI_REG_I2C_CTL_ARBDI 0x00002000
#define SILI_REG_I2C_CTL_UNITRS 0x00004000
#define SILI_REG_I2C_CTL_FASTM 0x00008000
#define SILI_REG_I2C_STS 0x0064
#define SILI_REG_I2C_STS_RW 0x00000001
#define SILI_REG_I2C_STS_ACKSTS 0x00000002
#define SILI_REG_I2C_STS_UNTBSY 0x00000004
#define SILI_REG_I2C_STS_BUSBSY 0x00000008
#define SILI_REG_I2C_STS_STOPDT 0x00000010
#define SILI_REG_I2C_STS_ARBLD 0x00000020
#define SILI_REG_I2C_STS_TXBED 0x00000040
#define SILI_REG_I2C_STS_RXBFD 0x00000080
#define SILI_REG_I2C_STS_GCALLD 0x00000100
#define SILI_REG_I2C_STS_SADDRD 0x00000200
#define SILI_REG_I2C_STS_BERRD 0x00000400
#define SILI_REG_I2C_SADDR 0x0068
#define SILI_REG_I2C_SADDR_MASK 0x0000003F
#define SILI_REG_I2C_DATA 0x006C
#define SILI_REG_FLASH_ADDR 0x0070
#define SILI_REG_FLASH_ADDR_MEMPRS 0x04000000
#define SILI_REG_FLASH_ADDR_GPIOEN 0x80000000
#define SILI_REG_FLASH_ADDR_MEMST 0x02000000
#define SILI_REG_FLASH_ADDR_MEMRD 0x01000000
#define SILI_REG_FLASH_ADDR_MASK 0x0003FFFF
#define SILI_REG_GPIO 0x0074
#define SILI_REG_GPIO_DATA_SHIFT 0
#define SILI_REG_GPIO_TDET_SHIFT 8
#define SILI_REG_GPIO_DCTL_SHIFT 16
#define SILI_PORT_REGION(port) (8192 * (port))
#define SILI_PORT_SIZE 8192
#define SILI_PREG_LRAM 0x0000
#define SILI_PREG_LRAM_SLOT(n) (0x0000 + (128 * (n)))
#define SILI_PREG_LRAM_SLOT_FIS 0x0000
#define SILI_PREG_LRAM_DMA0 0x0020
#define SILI_PREG_LRAM_DMA1 0x0030
#define SILI_PREG_LRAM_CMDACT 0x0040
#define SILI_PREG_LRAM_DMATAB 0x0040
#define SILI_PREG_PM_STATUS(n) (0x0F80 + (8 * (n)))
#define SILI_PREG_PM_QACTIVE(n) (0x0F84 + (8 * (n)))
#define SILI_PREG_PM_STATUS_SERVICE 0x00010000
#define SILI_PREG_PM_STATUS_LEGACY 0x00008000
#define SILI_PREG_PM_STATUS_NATIVE 0x00004000
#define SILI_PREG_PM_STATUS_VBSY 0x00002000
#define SILI_PREG_PM_STATUS_EXEC_SHIFT 8
#define SILI_PREG_PM_STATUS_EXEC_MASK 0x1F
#define SILI_PREG_PM_STATUS_PIO_MASK 0xFF
#define SILI_PREG_STATUS 0x1000
#define SILI_PREG_STATUS_READY 0x80000000
#define SILI_PREG_STATUS_SLOT 0x001F0000
#define SILI_PREG_STATUS_SLOT_SHIFT 16
#define SILI_PREG_STATUS_MASK 0x0200FFFF
#define SILI_PREG_CTL_SET 0x1000
#define SILI_PREG_CTL_CLR 0x1004
#define SILI_PREG_CTL_RESET 0x00000001
#define SILI_PREG_CTL_DEVRESET 0x00000002
#define SILI_PREG_CTL_INIT 0x00000004
#define SILI_PREG_CTL_NOAUTOCC 0x00000008
#define SILI_PREG_CTL_NOLED 0x00000010
#define SILI_PREG_CTL_ATA16 0x00000020
#define SILI_PREG_CTL_RESUME 0x00000040
#define SILI_PREG_CTL_TXBIST 0x00000080
#define SILI_PREG_CTL_CONT_DIS 0x00000100
#define SILI_PREG_CTL_NOSCRAM 0x00000200
#define SILI_PREG_CTL_32BITDMA 0x00000400
#define SILI_PREG_CTL_ACC_ILCK 0x00000800
#define SILI_PREG_CTL_REJ_ILCK 0x00001000
#define SILI_PREG_CTL_PMA 0x00002000
#define SILI_PREG_CTL_AUTO_ILCK 0x00004000
#define SILI_PREG_CTL_LEDON 0x00008000
#define SILI_PREG_CTL_OOB_BYP 0x02000000
#define SILI_PREG_INT_STATUS 0x1008
#define SILI_PREG_INT_ENABLE 0x1010
#define SILI_PREG_INT_DISABLE 0x1014
#define SILI_PREG_INT_STEER(n) ((n) << 30)
#define SILI_PREG_INT_CCOMPLETE 0x00000001
#define SILI_PREG_INT_CERROR 0x00000002
#define SILI_PREG_INT_READY 0x00000004
#define SILI_PREG_INT_PMCHANGE 0x00000008
#define SILI_PREG_INT_PHYRDYCHG 0x00000010
#define SILI_PREG_INT_COMWAKE 0x00000020
#define SILI_PREG_INT_UNRECFIS 0x00000040
#define SILI_PREG_INT_DEVEXCHG 0x00000080
#define SILI_PREG_INT_DECODE 0x00000100
#define SILI_PREG_INT_CRC 0x00000200
#define SILI_PREG_INT_HANDSHK 0x00000400
#define SILI_PREG_INT_SDB 0x00000800
#define SILI_PREG_INT_SHIFT 16
#define SILI_PREG_IST_CCOMPLETE 0x00010000
#define SILI_PREG_IST_CERROR 0x00020000
#define SILI_PREG_IST_READY 0x00040000
#define SILI_PREG_IST_PMCHANGE 0x00080000
#define SILI_PREG_IST_PHYRDYCHG 0x00100000
#define SILI_PREG_IST_COMWAKE 0x00200000
#define SILI_PREG_IST_UNRECFIS 0x00400000
#define SILI_PREG_IST_DEVEXCHG 0x00800000
#define SILI_PREG_IST_DECODE 0x01000000
#define SILI_PREG_IST_CRC 0x02000000
#define SILI_PREG_IST_HANDSHK 0x04000000
#define SILI_PREG_IST_SDB 0x08000000
#define SILI_PREG_INT_MASK (SILI_PREG_INT_CCOMPLETE | \
SILI_PREG_INT_CERROR | \
SILI_PREG_INT_READY | \
SILI_PREG_INT_PMCHANGE | \
SILI_PREG_INT_PHYRDYCHG | \
SILI_PREG_INT_COMWAKE | \
SILI_PREG_INT_UNRECFIS | \
SILI_PREG_INT_DEVEXCHG | \
SILI_PREG_INT_DECODE | \
SILI_PREG_INT_CRC | \
SILI_PREG_INT_HANDSHK | \
SILI_PREG_INT_SDB)
#define SILI_PREG_IST_MASK (SILI_PREG_INT_MASK << 16)
#define SILI_PFMT_INT_STATUS "\020" \
"\034SDB" \
"\033HANDSHK" \
"\032CRC" \
"\031DECODE" \
"\030DEVEXCHG" \
"\027UNRECFIS" \
"\026COMWAKE" \
"\025PHYRDYCHG" \
"\024PMCHANGE" \
"\023READY" \
"\022ERROR" \
"\021COMPLETE" \
\
"\014SDBm" \
"\013HANDSHKm" \
"\012CRCm" \
"\011DECODEm" \
"\010DEVEXCHGm" \
"\007UNRECFISm" \
"\006COMWAKEm" \
"\005PHYRDYCHGm" \
"\004PMCHANGEm" \
"\003READYm" \
"\002ERRORm" \
"\001COMPLETEm"
#define SILI_PREG_32BIT_ACTUA 0x101C
#define SILI_PREG_CMD_FIFO 0x1020
#define SILI_PREG_CERROR 0x1024
#define SILI_PREG_CERROR_DEVICE 1
#define SILI_PREG_CERROR_SDBERROR 2
#define SILI_PREG_CERROR_DATAFISERR 3
#define SILI_PREG_CERROR_SENDFISERR 4
#define SILI_PREG_CERROR_BADSTATE 5
#define SILI_PREG_CERROR_DIRECTION 6
#define SILI_PREG_CERROR_UNDERRUN 7
#define SILI_PREG_CERROR_OVERRUN 8
#define SILI_PREG_CERROR_LLOVERUN 9
#define SILI_PREG_CERROR_PKTPROTO 11
#define SILI_PREG_CERROR_BADALIGN 16
#define SILI_PREG_CERROR_PCITGTABRT 17
#define SILI_PREG_CERROR_PCIMASABRT 18
#define SILI_PREG_CERROR_PCIPARABRT 19
#define SILI_PREG_CERROR_PRBALIGN 24
#define SILI_PREG_CERROR_PCITGTABRT2 25
#define SILI_PREG_CERROR_PCIMASABRT2 26
#define SILI_PREG_CERROR_PCIPARABRT3 33
#define SILI_PREG_CERROR_PCITGTABRT3 34
#define SILI_PREG_CERROR_PCIMASABRT3 35
#define SILI_PREG_CERROR_SERVICE 36
#define SILI_PREG_FIS_CONFIG 0x1028
#define SILI_PREG_FIFO_CTL 0x102C
#define SILI_PREG_FIFO_CTL_READ_SHIFT 0
#define SILI_PREG_FIFO_CTL_WRITE_SHIFT 16
#define SILI_PREG_FIFO_CTL_MASK 0xFF
#define SILI_PREG_FIFO_CTL_ENCODE(rlevel, wlevel) (rlevel | (wlevel << 16))
#define SILI_PREG_CTR_DECODE 0x1040
#define SILI_PREG_CTR_CRC 0x1044
#define SILI_PREG_CTR_HANDSHK 0x1048
#define SILI_PREG_PHY_CONFIG 0x1050
#define SILI_PREG_PHY_CONFIG_AMP_MASK 0x1F
#define SILI_PREG_SLOTST 0x1800
#define SILI_PREG_SLOTST_ATTN 0x80000000
#define SILI_PREG_CMDACT(n) (0x1C00 + (8 * (n)))
#define SILI_PREG_CONTEXT 0x1E04
#define SILI_PREG_CONTEXT_SLOT_MASK 0x1F
#define SILI_PREG_CONTEXT_PMPORT_MASK 0x0F
#define SILI_PREG_CONTEXT_SLOT_SHIFT 0
#define SILI_PREG_CONTEXT_PMPORT_SHIFT 5
#define SILI_PREG_SCTL 0x1F00
#define SILI_PREG_SCTL_PMP 0x000F0000
#define SILI_PREG_SCTL_PMP_SHIFT 16
#define SILI_PREG_SCTL_SPM 0x0000F000
#define SILI_PREG_SCTL_SPM_NONE 0x00000000
#define SILI_PREG_SCTL_SPM_PARTIAL 0x00010000
#define SILI_PREG_SCTL_SPM_SLUMBER 0x00020000
#define SILI_PREG_SCTL_SPM_FROM 0x00040000
#define SILI_PREG_SCTL_IPM 0x00000F00
#define SILI_PREG_SCTL_IPM_NONE 0x00000000
#define SILI_PREG_SCTL_IPM_NPARTIAL 0x00000100
#define SILI_PREG_SCTL_IPM_NSLUMBER 0x00000200
#define SILI_PREG_SCTL_SPD 0x000000F0
#define SILI_PREG_SCTL_SPD_NONE 0x00000000
#define SILI_PREG_SCTL_SPD_GEN1 0x00000010
#define SILI_PREG_SCTL_SPD_GEN2 0x00000020
#define SILI_PREG_SCTL_DET 0x0000000F
#define SILI_PREG_SCTL_DET_NONE 0x00000000
#define SILI_PREG_SCTL_DET_INIT 0x00000001
#define SILI_PREG_SSTS 0x1F04
#define SILI_PREG_SSTS_IPM 0x00000F00
#define SILI_PREG_SSTS_IPM_NOCOMM 0x00000000
#define SILI_PREG_SSTS_IPM_ACTIVE 0x00000100
#define SILI_PREG_SSTS_IPM_PARTIAL 0x00000200
#define SILI_PREG_SSTS_IPM_SLUMBER 0x00000600
#define SILI_PREG_SSTS_SPD 0x000000F0
#define SILI_PREG_SSTS_SPD_NONE 0x00000000
#define SILI_PREG_SSTS_SPD_GEN1 0x00000010
#define SILI_PREG_SSTS_SPD_GEN2 0x00000020
#define SILI_PREG_SSTS_DET 0x0000000F
#define SILI_PREG_SSTS_DET_NOPHY 0x00000000
#define SILI_PREG_SSTS_DET_DEV_NE 0x00000001
#define SILI_PREG_SSTS_DET_DEV 0x00000003
#define SILI_PREG_SSTS_DET_OFFLINE 0x00000004
#define SILI_PREG_SERR 0x1F08
#define SILI_PREG_SERR_ERR_I (1<<0)
#define SILI_PREG_SERR_ERR_M (1<<1)
#define SILI_PREG_SERR_ERR_T (1<<8)
#define SILI_PREG_SERR_ERR_C (1<<9)
#define SILI_PREG_SERR_ERR_P (1<<10)
#define SILI_PREG_SERR_ERR_E (1<<11)
#define SILI_PREG_SERR_DIAG_N (1<<16)
#define SILI_PREG_SERR_DIAG_I (1<<17)
#define SILI_PREG_SERR_DIAG_W (1<<18)
#define SILI_PREG_SERR_DIAG_B (1<<19)
#define SILI_PREG_SERR_DIAG_D (1<<20)
#define SILI_PREG_SERR_DIAG_C (1<<21)
#define SILI_PREG_SERR_DIAG_H (1<<22)
#define SILI_PREG_SERR_DIAG_S (1<<23)
#define SILI_PREG_SERR_DIAG_T (1<<24)
#define SILI_PREG_SERR_DIAG_F (1<<25)
#define SILI_PREG_SERR_DIAG_X (1<<26)
#define SILI_PFMT_SERR "\020" \
"\033DIAG.X" "\032DIAG.F" "\031DIAG.T" "\030DIAG.S" \
"\027DIAG.H" "\026DIAG.C" "\025DIAG.D" "\024DIAG.B" \
"\023DIAG.W" "\022DIAG.I" "\021DIAG.N" \
"\014ERR.E" "\013ERR.P" "\012ERR.C" "\011ERR.T" \
"\002ERR.M" "\001ERR.I"
#define SILI_PREG_SACT 0x1F0C
#define SILI_PREG_SNTF 0x1F10
#define SILI_BAR2_GRO 0x0000
#define SILI_BAR2_GRD 0x0004
#define SILI_BAR2_PRO 0x0008
#define SILI_BAR2_PRD 0x000C
struct sili_sge {
u_int64_t sge_paddr;
u_int32_t sge_count;
u_int32_t sge_flags;
} __packed;
#define SILI_SGE_FLAGS_TRM 0x80000000
#define SILI_SGE_FLAGS_LNK 0x40000000
#define SILI_SGE_FLAGS_DRD 0x20000000
#define SILI_SGE_FLAGS_XCF 0x10000000
#define SILI_MAX_SGET (128 - 4)
#define SILI_MAX_PMPORTS 16
#define SILI_MAXPHYS (256 * 1024)
#if SILI_MAXPHYS / PAGE_SIZE + 1 > (SILI_MAX_SGET * 3 / 4)
#error "SILI_MAX_SGET is not big enough"
#endif
struct sili_prb {
u_int16_t prb_control;
u_int16_t prb_override;
u_int32_t prb_xfer_count;
union {
struct ata_fis_h2d h2d;
struct ata_fis_d2h d2h;
} prb_fis;
u_int32_t prb_reserved1c;
struct sili_sge prb_sge_base[2];
struct sili_sge prb_sge[SILI_MAX_SGET];
} __packed;
#define prb_h2d prb_fis.h2d
#define prb_d2h prb_fis.d2h
#define prb_activation prb_ext[0].sge_paddr
#define prb_packet(prb) ((u_int8_t *)&(prb)->prb_sge[0])
#define prb_sge_normal prb_sge_base[0]
#define prb_sge_packet prb_sge_base[1]
#define SILI_PRB_CTRL_OVERRIDE 0x0001
#define SILI_PRB_CTRL_REXMIT 0x0002
#define SILI_PRB_CTRL_EXTCMD 0x0004
#define SILI_PRB_CTRL_RECEIVE 0x0008
#define SILI_PRB_CTRL_READ 0x0010
#define SILI_PRB_CTRL_WRITE 0x0020
#define SILI_PRB_CTRL_NOINT 0x0040
#define SILI_PRB_CTRL_SOFTRESET 0x0080
#define SILI_PRB_OVER_ATAPI 0x0001
#define SILI_PRB_OVER_ATA 0x0002
#define SILI_PRB_OVER_NCQ 0x0004
#define SILI_PRB_OVER_READ 0x0008
#define SILI_PRB_OVER_WRITE 0x0010
#define SILI_PRB_OVER_RAW 0x0020
#define SILI_MAX_PORTS 16
#define SILI_MAX_CMDS 31
struct sili_dmamem {
bus_dma_tag_t adm_tag;
bus_dmamap_t adm_map;
bus_dma_segment_t adm_seg;
bus_addr_t adm_busaddr;
caddr_t adm_kva;
};
#define SILI_DMA_MAP(_adm) ((_adm)->adm_map)
#define SILI_DMA_DVA(_adm) ((_adm)->adm_busaddr)
#define SILI_DMA_KVA(_adm) ((void *)(_adm)->adm_kva)
struct sili_softc;
struct sili_port;
struct sili_device;
struct sili_ccb {
struct ata_xfer ccb_xa;
struct callout ccb_timeout;
int ccb_slot;
struct sili_port *ccb_port;
bus_dmamap_t ccb_dmamap;
struct sili_prb *ccb_prb;
struct sili_prb *ccb_prb_lram;
u_int64_t ccb_prb_paddr;
void (*ccb_done)(struct sili_ccb *);
TAILQ_ENTRY(sili_ccb) ccb_entry;
};
struct sili_port {
struct sili_softc *ap_sc;
bus_space_handle_t ap_ioh;
int ap_num;
int ap_pmcount;
int ap_flags;
#define AP_F_BUS_REGISTERED 0x0001
#define AP_F_CAM_ATTACHED 0x0002
#define AP_F_IN_RESET 0x0004
#define AP_F_SCAN_RUNNING 0x0008
#define AP_F_SCAN_REQUESTED 0x0010
#define AP_F_SCAN_COMPLETED 0x0020
#define AP_F_IGNORE_IFS 0x0040
#define AP_F_UNUSED0200 0x0200
#define AP_F_ERR_CCB_RESERVED 0x0400
#define AP_F_REINIT_ACTIVE 0x0800
int ap_signal;
thread_t ap_thread;
struct lock ap_lock;
struct lock ap_sim_lock;
struct lock ap_sig_lock;
#define AP_SIGF_INIT 0x0001
#define AP_SIGF_TIMEOUT 0x0002
#define AP_SIGF_PORTINT 0x0004
#define AP_SIGF_STOP 0x8000
struct cam_sim *ap_sim;
struct sili_prb *ap_prbs;
struct sili_dmamem *ap_dmamem_prbs;
u_int32_t ap_active;
u_int32_t ap_active_cnt;
u_int32_t ap_expired;
struct sili_ccb *ap_ccbs;
struct sili_ccb *ap_err_ccb;
int ap_run_flags;
TAILQ_HEAD(, sili_ccb) ap_ccb_free;
TAILQ_HEAD(, sili_ccb) ap_ccb_pending;
struct lock ap_ccb_lock;
int ap_type;
int ap_probe;
struct ata_port *ap_ata;
u_int32_t ap_state;
#define AP_S_NORMAL 0
#define AP_S_FATAL_ERROR 1
u_int8_t *ap_err_scratch;
char ap_name[16];
};
#define PORTNAME(_ap) ((_ap)->ap_name)
#define ATANAME(_ap, _at) ((_at) ? (_at)->at_name : (_ap)->ap_name)
struct sili_softc {
device_t sc_dev;
const struct sili_device *sc_ad;
struct resource *sc_irq;
struct resource *sc_regs;
struct resource *sc_pregs;
bus_space_tag_t sc_iot;
bus_space_handle_t sc_ioh;
bus_space_tag_t sc_piot;
bus_space_handle_t sc_pioh;
int sc_irq_type;
int sc_rid_irq;
int sc_rid_regs;
int sc_rid_pregs;
void *sc_irq_handle;
bus_dma_tag_t sc_tag_prbs;
bus_dma_tag_t sc_tag_data;
int sc_flags;
#define SILI_F_NO_NCQ 0x0001
#define SILI_F_IGN_FR 0x0002
#define SILI_F_INT_GOOD 0x0004
#define SILI_F_64BIT 0x0008
#define SILI_F_300 0x0010
#define SILI_F_NCQ 0x0020
#define SILI_F_SSNTF 0x0040
#define SILI_F_SPM 0x0080
u_int sc_ncmds;
struct sili_port *sc_ports[SILI_MAX_PORTS];
};
struct sili_device {
pci_vendor_id_t ad_vendor;
pci_product_id_t ad_product;
int ad_nports;
int (*ad_attach)(device_t dev);
int (*ad_detach)(device_t dev);
char *name;
};
#define sili_pwait_clr(_ap, _r, _b) \
sili_pwait_eq((_ap), SILI_PWAIT_TIMEOUT, (_r), (_b), 0)
#define sili_pwait_clr_to(_ap, _to, _r, _b) \
sili_pwait_eq((_ap), _to, (_r), (_b), 0)
#define sili_pwait_set(_ap, _r, _b) \
sili_pwait_eq((_ap), SILI_PWAIT_TIMEOUT, (_r), (_b), (_b))
#define sili_pwait_set_to(_ap, _to, _r, _b) \
sili_pwait_eq((_ap), _to, (_r), (_b), (_b))
#define SILI_PWAIT_TIMEOUT 1000
const struct sili_device *sili_lookup_device(device_t dev);
int sili_init(struct sili_softc *);
int sili_port_init(struct sili_port *ap);
int sili_port_alloc(struct sili_softc *, u_int);
void sili_port_state_machine(struct sili_port *ap, int initial);
void sili_port_free(struct sili_softc *, u_int);
int sili_port_reset(struct sili_port *, struct ata_port *at, int);
void sili_exclusive_access(struct sili_port *ap);
u_int32_t sili_read(struct sili_softc *, bus_size_t);
void sili_write(struct sili_softc *, bus_size_t, u_int32_t);
int sili_wait_ne(struct sili_softc *, bus_size_t, u_int32_t, u_int32_t);
u_int32_t sili_pread(struct sili_port *, bus_size_t);
void sili_pwrite(struct sili_port *, bus_size_t, u_int32_t);
int sili_pwait_eq(struct sili_port *, int, bus_size_t,
u_int32_t, u_int32_t);
void sili_intr(void *);
void sili_port_intr(struct sili_port *ap, int blockable);
int sili_cam_attach(struct sili_port *ap);
void sili_cam_changed(struct sili_port *ap, struct ata_port *at, int found);
void sili_cam_detach(struct sili_port *ap);
int sili_cam_probe(struct sili_port *ap, struct ata_port *at);
struct ata_xfer *sili_ata_get_xfer(struct sili_port *ap, struct ata_port *at);
void sili_ata_put_xfer(struct ata_xfer *xa);
int sili_ata_cmd(struct ata_xfer *xa);
int sili_pm_port_probe(struct sili_port *ap, int);
int sili_pm_port_init(struct sili_port *ap, struct ata_port *at);
int sili_pm_identify(struct sili_port *ap);
int sili_pm_set_feature(struct sili_port *ap, int feature, int enable);
int sili_pm_hardreset(struct sili_port *ap, int target, int hard);
int sili_pm_softreset(struct sili_port *ap, int target);
int sili_pm_phy_status(struct sili_port *ap, int target, u_int32_t *datap);
int sili_pm_read(struct sili_port *ap, int target,
int which, u_int32_t *res);
int sili_pm_write(struct sili_port *ap, int target,
int which, u_int32_t data);
void sili_pm_check_good(struct sili_port *ap, int target);
void sili_ata_cmd_timeout(struct sili_ccb *ccb);
void sili_quick_timeout(struct sili_ccb *ccb);
struct sili_ccb *sili_get_ccb(struct sili_port *ap);
void sili_put_ccb(struct sili_ccb *ccb);
struct sili_ccb *sili_get_err_ccb(struct sili_port *);
void sili_put_err_ccb(struct sili_ccb *);
int sili_poll(struct sili_ccb *ccb, int timeout,
void (*timeout_fn)(struct sili_ccb *));
int sili_port_signature(struct sili_port *ap, struct ata_port *at,
u_int32_t sig);
void sili_port_thread_core(struct sili_port *ap, int mask);
void sili_os_sleep(int ms);
void sili_os_hardsleep(int us);
int sili_os_softsleep(void);
void sili_os_start_port(struct sili_port *ap);
void sili_os_stop_port(struct sili_port *ap);
void sili_os_signal_port_thread(struct sili_port *ap, int mask);
void sili_os_lock_port(struct sili_port *ap);
int sili_os_lock_port_nb(struct sili_port *ap);
void sili_os_unlock_port(struct sili_port *ap);
extern u_int32_t SiliForceGen1;
extern u_int32_t SiliNoFeatures;