2010-11-13 16:51:57 +03:00
|
|
|
/* $NetBSD: aic7xxx_osm.h,v 1.25 2010/11/13 13:52:00 uebayasi Exp $ */
|
2003-04-19 23:38:21 +04:00
|
|
|
|
2003-04-19 23:33:29 +04:00
|
|
|
/*
|
2003-04-20 19:32:10 +04:00
|
|
|
* NetBSD platform specific driver option settings, data structures,
|
2003-04-19 23:33:29 +04:00
|
|
|
* function declarations and includes.
|
|
|
|
*
|
|
|
|
* Copyright (c) 1994-2001 Justin T. Gibbs.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions, and the following disclaimer,
|
|
|
|
* without modification.
|
|
|
|
* 2. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* Alternatively, this software may be distributed under the terms of the
|
|
|
|
* GNU Public License ("GPL").
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* //depot/aic7xxx/freebsd/dev/aic7xxx/aic7xxx_osm.h#14 $
|
|
|
|
*
|
|
|
|
* $FreeBSD: /repoman/r/ncvs/src/sys/dev/aic7xxx/aic7xxx_osm.h,v 1.20 2002/12/04 22:51:29 scottl Exp $
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* Ported from FreeBSD by Pascal Renauld, Network Storage Solutions, Inc. - April 2003
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _AIC7XXX_NETBSD_H_
|
|
|
|
#define _AIC7XXX_NETBSD_H_
|
|
|
|
|
|
|
|
#include "opt_ahc.h" /* for config options */
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/scsiio.h>
|
|
|
|
#include <sys/reboot.h>
|
|
|
|
#include <sys/kthread.h>
|
|
|
|
|
|
|
|
#include <dev/pci/pcireg.h>
|
|
|
|
#include <dev/pci/pcivar.h>
|
|
|
|
|
2007-10-19 15:59:34 +04:00
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <sys/intr.h>
|
2003-04-19 23:33:29 +04:00
|
|
|
|
|
|
|
#include <dev/scsipi/scsi_all.h>
|
|
|
|
#include <dev/scsipi/scsipi_all.h>
|
|
|
|
#include <dev/scsipi/scsi_message.h>
|
|
|
|
#include <dev/scsipi/scsipi_debug.h>
|
|
|
|
#include <dev/scsipi/scsiconf.h>
|
|
|
|
#include <dev/scsipi/scsi_iu.h>
|
|
|
|
|
|
|
|
#ifdef CAM_NEW_TRAN_CODE
|
|
|
|
#define AHC_NEW_TRAN_SETTINGS
|
|
|
|
#endif /* CAM_NEW_TRAN_CODE */
|
|
|
|
|
|
|
|
|
|
|
|
/****************************** Platform Macros *******************************/
|
|
|
|
#define SIM_IS_SCSIBUS_B(ahc, sim) \
|
|
|
|
((sim) == ahc->platform_data->sim_b)
|
|
|
|
#define SIM_CHANNEL(ahc, sim) \
|
|
|
|
(((sim) == ahc->platform_data->sim_b) ? 'B' : 'A')
|
|
|
|
#define SIM_SCSI_ID(ahc, sim) \
|
|
|
|
(((sim) == ahc->platform_data->sim_b) ? ahc->our_id_b : ahc->our_id)
|
|
|
|
#define SIM_PATH(ahc, sim) \
|
|
|
|
(((sim) == ahc->platform_data->sim_b) ? ahc->platform_data->path_b \
|
|
|
|
: ahc->platform_data->path)
|
|
|
|
#define BUILD_SCSIID(ahc, sim, target_id, our_id) \
|
2006-03-14 18:24:30 +03:00
|
|
|
((((target_id) << TID_SHIFT) & TID) | (our_id))
|
2003-04-19 23:33:29 +04:00
|
|
|
|
|
|
|
#define SCB_GET_SIM(ahc, scb) \
|
|
|
|
(SCB_GET_CHANNEL(ahc, scb) == 'A' ? (ahc)->platform_data->sim \
|
|
|
|
: (ahc)->platform_data->sim_b)
|
|
|
|
|
|
|
|
#ifndef offsetof
|
|
|
|
#define offsetof(type, member) ((size_t)(&((type *)0)->member))
|
|
|
|
#endif
|
|
|
|
/************************* Forward Declarations *******************************/
|
|
|
|
typedef pcireg_t ahc_dev_softc_t;
|
|
|
|
|
|
|
|
/***************************** Bus Space/DMA **********************************/
|
|
|
|
#define ahc_dma_tag_create(ahc, parent_tag, alignment, boundary, \
|
|
|
|
lowaddr, highaddr, filter, filterarg, \
|
|
|
|
maxsize, nsegments, maxsegsz, flags, \
|
|
|
|
dma_tagp) \
|
|
|
|
bus_dma_tag_create(parent_tag, alignment, boundary, \
|
|
|
|
lowaddr, highaddr, filter, filterarg, \
|
|
|
|
maxsize, nsegments, maxsegsz, flags, \
|
|
|
|
dma_tagp)
|
|
|
|
|
|
|
|
#define ahc_dma_tag_destroy(ahc, tag) \
|
|
|
|
bus_dma_tag_destroy(tag)
|
|
|
|
|
|
|
|
#define ahc_dmamem_alloc(ahc, dmat, vaddr, flags, mapp) \
|
|
|
|
bus_dmamem_alloc(dmat, vaddr, flags, mapp)
|
|
|
|
|
|
|
|
#define ahc_dmamem_free(ahc, dmat, vaddr, map) \
|
|
|
|
bus_dmamem_free(dmat, vaddr, map)
|
|
|
|
|
|
|
|
#define ahc_dmamap_create(ahc, tag, flags, mapp) \
|
|
|
|
bus_dmamap_create(tag, flags, mapp)
|
|
|
|
|
|
|
|
#define ahc_dmamap_destroy(ahc, tag, map) \
|
|
|
|
bus_dmamap_destroy(tag, map)
|
|
|
|
|
|
|
|
#define ahc_dmamap_load(ahc, dmat, map, addr, buflen, callback, \
|
|
|
|
callback_arg, flags) \
|
|
|
|
bus_dmamap_load(dmat, map, addr, buflen, callback, callback_arg, flags)
|
|
|
|
|
|
|
|
#define ahc_dmamap_unload(ahc, tag, map) \
|
|
|
|
bus_dmamap_unload(tag, map)
|
|
|
|
|
|
|
|
/* XXX Need to update Bus DMA for partial map syncs */
|
|
|
|
#define ahc_dmamap_sync(ahc, dma_tag, dmamap, offset, len, op) \
|
|
|
|
bus_dmamap_sync(dma_tag, dmamap, offset, len, op)
|
|
|
|
|
|
|
|
/************************ Tunable Driver Parameters **************************/
|
|
|
|
/*
|
2003-05-03 22:10:37 +04:00
|
|
|
* The number of DMA segments supported. The sequencer can handle any number
|
2003-04-19 23:33:29 +04:00
|
|
|
* of physically contiguous S/G entrys. To reduce the driver's memory
|
|
|
|
* consumption, we limit the number supported to be sufficient to handle
|
|
|
|
* the largest mapping supported by the kernel, MAXPHYS. Assuming the
|
|
|
|
* transfer is as fragmented as possible and unaligned, this turns out to
|
|
|
|
* be the number of paged sized transfers in MAXPHYS plus an extra element
|
|
|
|
* to handle any unaligned residual. The sequencer fetches SG elements
|
|
|
|
* in cacheline sized chucks, so make the number per-transaction an even
|
|
|
|
* multiple of 16 which should align us on even the largest of cacheline
|
2005-02-27 03:26:58 +03:00
|
|
|
* boundaries.
|
2003-04-19 23:33:29 +04:00
|
|
|
*/
|
|
|
|
#define AHC_NSEG (roundup(btoc(MAXPHYS) + 1, 16))
|
|
|
|
|
|
|
|
/* This driver supports target mode */
|
|
|
|
//#define AHC_TARGET_MODE 1
|
|
|
|
|
|
|
|
/************************** Softc/SCB Platform Data ***************************/
|
|
|
|
struct ahc_platform_data {
|
|
|
|
/*
|
|
|
|
* Hooks into the XPT.
|
|
|
|
*/
|
|
|
|
#if 0
|
|
|
|
struct cam_sim *sim;
|
|
|
|
struct cam_sim *sim_b;
|
|
|
|
struct cam_path *path;
|
|
|
|
struct cam_path *path_b;
|
|
|
|
|
|
|
|
int regs_res_type;
|
|
|
|
int regs_res_id;
|
|
|
|
int irq_res_type;
|
|
|
|
struct resource *regs;
|
|
|
|
struct resource *irq;
|
|
|
|
void *ih;
|
|
|
|
eventhandler_tag eh;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
struct scb_platform_data {
|
|
|
|
};
|
|
|
|
|
|
|
|
/********************************* Byte Order *********************************/
|
|
|
|
#define ahc_htobe16(x) htobe16(x)
|
|
|
|
#define ahc_htobe32(x) htobe32(x)
|
|
|
|
#define ahc_htobe64(x) htobe64(x)
|
|
|
|
#define ahc_htole16(x) htole16(x)
|
|
|
|
#define ahc_htole32(x) htole32(x)
|
|
|
|
#define ahc_htole64(x) htole64(x)
|
|
|
|
|
|
|
|
#define ahc_be16toh(x) be16toh(x)
|
|
|
|
#define ahc_be32toh(x) be32toh(x)
|
|
|
|
#define ahc_be64toh(x) be64toh(x)
|
|
|
|
#define ahc_le16toh(x) le16toh(x)
|
|
|
|
#define ahc_le32toh(x) le32toh(x)
|
|
|
|
#define ahc_le64toh(x) le64toh(x)
|
|
|
|
|
|
|
|
/************************** Timer DataStructures ******************************/
|
|
|
|
typedef struct callout ahc_timer_t;
|
|
|
|
|
|
|
|
/***************************** Core Includes **********************************/
|
|
|
|
#if AHC_REG_PRETTY_PRINT
|
|
|
|
#define AIC_DEBUG_REGISTERS 1
|
|
|
|
#else
|
|
|
|
#define AIC_DEBUG_REGISTERS 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <dev/ic/aic7xxxvar.h>
|
|
|
|
|
|
|
|
/***************************** Timer Facilities *******************************/
|
|
|
|
void ahc_timeout(void*);
|
|
|
|
|
2007-07-10 00:51:58 +04:00
|
|
|
#define ahc_timer_init(x) callout_init(x, 0)
|
2003-04-19 23:33:29 +04:00
|
|
|
#define ahc_timer_stop callout_stop
|
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline void
|
2003-04-19 23:33:29 +04:00
|
|
|
ahc_timer_reset(ahc_timer_t *timer, u_int usec, ahc_callback_t *func, void *arg)
|
|
|
|
{
|
|
|
|
callout_reset(timer, (usec * hz)/1000000, func, arg);
|
|
|
|
}
|
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline void
|
2003-04-19 23:33:29 +04:00
|
|
|
ahc_scb_timer_reset(struct scb *scb, u_int usec)
|
|
|
|
{
|
2006-03-14 18:33:11 +03:00
|
|
|
if (!(scb->xs->xs_control & XS_CTL_POLL)) {
|
2003-04-19 23:33:29 +04:00
|
|
|
callout_reset(&scb->xs->xs_callout,
|
|
|
|
(usec * hz)/1000000, ahc_timeout, scb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************** Device Access ************************************/
|
|
|
|
#define ahc_inb(ahc, port) \
|
|
|
|
bus_space_read_1((ahc)->tag, (ahc)->bsh, port)
|
|
|
|
|
|
|
|
#define ahc_outb(ahc, port, value) \
|
|
|
|
bus_space_write_1((ahc)->tag, (ahc)->bsh, port, value)
|
|
|
|
|
|
|
|
#define ahc_outsb(ahc, port, valp, count) \
|
|
|
|
bus_space_write_multi_1((ahc)->tag, (ahc)->bsh, port, valp, count)
|
|
|
|
|
|
|
|
#define ahc_insb(ahc, port, valp, count) \
|
|
|
|
bus_space_read_multi_1((ahc)->tag, (ahc)->bsh, port, valp, count)
|
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline void ahc_flush_device_writes(struct ahc_softc *);
|
2003-04-19 23:33:29 +04:00
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline void
|
2003-04-19 23:33:29 +04:00
|
|
|
ahc_flush_device_writes(struct ahc_softc *ahc)
|
|
|
|
{
|
|
|
|
/* XXX Is this sufficient for all architectures??? */
|
2006-05-22 03:56:09 +04:00
|
|
|
(void)ahc_inb(ahc, INTSTAT);
|
2003-04-19 23:33:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************** Locking Primitives ******************************/
|
|
|
|
/* Lock protecting internal data structures */
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline void ahc_lockinit(struct ahc_softc *);
|
|
|
|
static __inline void ahc_lock(struct ahc_softc *, unsigned long *);
|
|
|
|
static __inline void ahc_unlock(struct ahc_softc *, unsigned long *);
|
2003-04-19 23:33:29 +04:00
|
|
|
|
2003-11-02 14:07:44 +03:00
|
|
|
/* Lock held during command completion to the upper layer */
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline void ahc_done_lockinit(struct ahc_softc *);
|
|
|
|
static __inline void ahc_done_lock(struct ahc_softc *, unsigned long *);
|
|
|
|
static __inline void ahc_done_unlock(struct ahc_softc *, unsigned long *);
|
2003-04-19 23:33:29 +04:00
|
|
|
|
|
|
|
/* Lock held during ahc_list manipulation and ahc softc frees */
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline void ahc_list_lockinit(void);
|
|
|
|
static __inline void ahc_list_lock(unsigned long *);
|
|
|
|
static __inline void ahc_list_unlock(unsigned long *);
|
2003-04-19 23:33:29 +04:00
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline void
|
2006-11-16 04:32:37 +03:00
|
|
|
ahc_lockinit(struct ahc_softc *ahc)
|
2003-04-19 23:33:29 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline void
|
2006-11-16 04:32:37 +03:00
|
|
|
ahc_lock(struct ahc_softc *ahc, unsigned long *flags)
|
2003-04-19 23:33:29 +04:00
|
|
|
{
|
|
|
|
*flags = splbio();
|
|
|
|
}
|
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline void
|
2006-11-16 04:32:37 +03:00
|
|
|
ahc_unlock(struct ahc_softc *ahc, unsigned long *flags)
|
2003-04-19 23:33:29 +04:00
|
|
|
{
|
|
|
|
splx(*flags);
|
|
|
|
}
|
|
|
|
|
2003-11-02 14:07:44 +03:00
|
|
|
/* Lock held during command completion to the upper layer */
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline void
|
2006-11-16 04:32:37 +03:00
|
|
|
ahc_done_lockinit(struct ahc_softc *ahc)
|
2003-04-19 23:33:29 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline void
|
2006-11-16 04:32:37 +03:00
|
|
|
ahc_done_lock(struct ahc_softc *ahc, unsigned long *flags)
|
2003-04-19 23:33:29 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline void
|
2006-11-16 04:32:37 +03:00
|
|
|
ahc_done_unlock(struct ahc_softc *ahc, unsigned long *flags)
|
2003-04-19 23:33:29 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Lock held during ahc_list manipulation and ahc softc frees */
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline void
|
2009-03-15 18:52:12 +03:00
|
|
|
ahc_list_lockinit(void)
|
2003-04-19 23:33:29 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline void
|
2006-11-16 04:32:37 +03:00
|
|
|
ahc_list_lock(unsigned long *flags)
|
2003-04-19 23:33:29 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline void
|
2006-11-16 04:32:37 +03:00
|
|
|
ahc_list_unlock(unsigned long *flags)
|
2003-04-19 23:33:29 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
/****************************** OS Primitives *********************************/
|
|
|
|
#define ahc_delay DELAY
|
|
|
|
|
|
|
|
/************************** Transaction Operations ****************************/
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline void ahc_set_transaction_status(struct scb *, uint32_t);
|
|
|
|
static __inline void ahc_set_scsi_status(struct scb *, uint32_t);
|
|
|
|
static __inline uint32_t ahc_get_transaction_status(struct scb *);
|
|
|
|
static __inline uint32_t ahc_get_scsi_status(struct scb *);
|
|
|
|
static __inline void ahc_set_transaction_tag(struct scb *, int, u_int);
|
|
|
|
static __inline u_long ahc_get_transfer_length(struct scb *);
|
|
|
|
static __inline int ahc_get_transfer_dir(struct scb *);
|
|
|
|
static __inline void ahc_set_residual(struct scb *, u_long);
|
|
|
|
static __inline void ahc_set_sense_residual(struct scb *, u_long);
|
|
|
|
static __inline u_long ahc_get_residual(struct scb *);
|
|
|
|
static __inline int ahc_perform_autosense(struct scb *);
|
|
|
|
static __inline uint32_t ahc_get_sense_bufsize(struct ahc_softc *,
|
2003-07-08 14:06:28 +04:00
|
|
|
struct scb *);
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline void ahc_freeze_scb(struct scb *);
|
|
|
|
static __inline void ahc_platform_freeze_devq(struct ahc_softc *, struct scb *);
|
|
|
|
static __inline int ahc_platform_abort_scbs(struct ahc_softc *, int, char,
|
2003-07-08 14:06:28 +04:00
|
|
|
int, u_int, role_t, uint32_t);
|
2003-04-19 23:33:29 +04:00
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline
|
2003-04-19 23:33:29 +04:00
|
|
|
void ahc_set_transaction_status(struct scb *scb, uint32_t status)
|
|
|
|
{
|
|
|
|
scb->xs->error = status;
|
|
|
|
}
|
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline
|
2003-04-19 23:33:29 +04:00
|
|
|
void ahc_set_scsi_status(struct scb *scb, uint32_t status)
|
|
|
|
{
|
|
|
|
scb->xs->xs_status = status;
|
|
|
|
}
|
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline
|
2003-04-19 23:33:29 +04:00
|
|
|
uint32_t ahc_get_transaction_status(struct scb *scb)
|
|
|
|
{
|
|
|
|
return (scb->xs->error);
|
|
|
|
}
|
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline
|
2003-04-19 23:33:29 +04:00
|
|
|
uint32_t ahc_get_scsi_status(struct scb *scb)
|
|
|
|
{
|
|
|
|
return (scb->xs->xs_status);
|
|
|
|
}
|
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline
|
2006-11-16 04:32:37 +03:00
|
|
|
void ahc_set_transaction_tag(struct scb *scb, int enabled, u_int type)
|
2003-04-19 23:33:29 +04:00
|
|
|
{
|
|
|
|
scb->xs->xs_tag_type = type;
|
|
|
|
}
|
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline
|
2003-04-19 23:33:29 +04:00
|
|
|
u_long ahc_get_transfer_length(struct scb *scb)
|
|
|
|
{
|
|
|
|
return (scb->xs->datalen);
|
|
|
|
}
|
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline
|
2003-04-19 23:33:29 +04:00
|
|
|
int ahc_get_transfer_dir(struct scb *scb)
|
|
|
|
{
|
|
|
|
return (scb->xs->xs_control & (XS_CTL_DATA_IN|XS_CTL_DATA_OUT));
|
|
|
|
}
|
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline
|
2003-04-19 23:33:29 +04:00
|
|
|
void ahc_set_residual(struct scb *scb, u_long resid)
|
|
|
|
{
|
|
|
|
scb->xs->resid = resid;
|
|
|
|
}
|
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline
|
2006-11-16 04:32:37 +03:00
|
|
|
void ahc_set_sense_residual(struct scb *scb, u_long resid)
|
2003-04-19 23:33:29 +04:00
|
|
|
{
|
2006-10-12 05:30:41 +04:00
|
|
|
#ifdef notdef
|
|
|
|
scb->io_ctx->csio.sense_resid = resid;
|
|
|
|
#endif
|
2003-04-19 23:33:29 +04:00
|
|
|
}
|
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline
|
2003-04-19 23:33:29 +04:00
|
|
|
u_long ahc_get_residual(struct scb *scb)
|
|
|
|
{
|
|
|
|
return (scb->xs->resid);
|
|
|
|
}
|
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline
|
2003-04-19 23:33:29 +04:00
|
|
|
int ahc_perform_autosense(struct scb *scb)
|
|
|
|
{
|
|
|
|
return (!(scb->flags & SCB_SENSE));
|
|
|
|
}
|
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline uint32_t
|
2006-11-16 04:32:37 +03:00
|
|
|
ahc_get_sense_bufsize(struct ahc_softc *ahc, struct scb *scb)
|
2003-04-19 23:33:29 +04:00
|
|
|
{
|
2005-02-21 03:29:06 +03:00
|
|
|
return (sizeof(struct scsi_sense_data));
|
2003-04-19 23:33:29 +04:00
|
|
|
}
|
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline void
|
2003-04-19 23:33:29 +04:00
|
|
|
ahc_freeze_scb(struct scb *scb)
|
|
|
|
{
|
|
|
|
struct scsipi_xfer *xs = scb->xs;
|
|
|
|
|
|
|
|
if (!(scb->flags & SCB_FREEZE_QUEUE)) {
|
|
|
|
scsipi_periph_freeze(xs->xs_periph, 1);
|
|
|
|
scb->flags |= SCB_FREEZE_QUEUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline void
|
2006-11-16 04:32:37 +03:00
|
|
|
ahc_platform_freeze_devq(struct ahc_softc *ahc, struct scb *scb)
|
2003-04-19 23:33:29 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline int
|
2006-11-16 04:32:37 +03:00
|
|
|
ahc_platform_abort_scbs(struct ahc_softc *ahc, int target,
|
|
|
|
char channel, int lun, u_int tag,
|
|
|
|
role_t role, uint32_t status)
|
2003-04-19 23:33:29 +04:00
|
|
|
{
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline void
|
2006-11-16 04:32:37 +03:00
|
|
|
ahc_platform_scb_free(struct ahc_softc *ahc, struct scb *scb)
|
2003-04-19 23:33:29 +04:00
|
|
|
{
|
2006-10-12 05:30:41 +04:00
|
|
|
#ifdef __FreeBSD__
|
2003-04-19 23:33:29 +04:00
|
|
|
/* What do we do to generically handle driver resource shortages??? */
|
|
|
|
if ((ahc->flags & AHC_RESOURCE_SHORTAGE) != 0
|
|
|
|
&& scb->io_ctx != NULL
|
|
|
|
&& (scb->io_ctx->ccb_h.status & CAM_RELEASE_SIMQ) == 0) {
|
|
|
|
scb->io_ctx->ccb_h.status |= CAM_RELEASE_SIMQ;
|
|
|
|
ahc->flags &= ~AHC_RESOURCE_SHORTAGE;
|
|
|
|
}
|
|
|
|
scb->io_ctx = NULL;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************** PCI ***************************************/
|
|
|
|
#ifdef AHC_PCI_CONFIG
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline uint32_t ahc_pci_read_config(ahc_dev_softc_t, int, int);
|
|
|
|
static __inline void ahc_pci_write_config(ahc_dev_softc_t, int, uint32_t,
|
2003-07-08 14:06:28 +04:00
|
|
|
int);
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline int ahc_get_pci_function(ahc_dev_softc_t);
|
|
|
|
static __inline int ahc_get_pci_slot(ahc_dev_softc_t);
|
|
|
|
static __inline int ahc_get_pci_bus(ahc_dev_softc_t);
|
2003-04-19 23:33:29 +04:00
|
|
|
|
2003-07-08 14:06:28 +04:00
|
|
|
int ahc_pci_map_registers(struct ahc_softc *);
|
|
|
|
int ahc_pci_map_int(struct ahc_softc *);
|
2003-04-19 23:33:29 +04:00
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline uint32_t
|
2003-04-19 23:33:29 +04:00
|
|
|
ahc_pci_read_config(ahc_dev_softc_t pci, int reg, int width)
|
|
|
|
{
|
|
|
|
return (pci_read_config(pci, reg, width));
|
|
|
|
}
|
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline void
|
2003-04-19 23:33:29 +04:00
|
|
|
ahc_pci_write_config(ahc_dev_softc_t pci, int reg, uint32_t value, int width)
|
|
|
|
{
|
|
|
|
pci_write_config(pci, reg, value, width);
|
|
|
|
}
|
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline int
|
2003-04-19 23:33:29 +04:00
|
|
|
ahc_get_pci_function(ahc_dev_softc_t pci)
|
|
|
|
{
|
|
|
|
return (pci_get_function(pci));
|
|
|
|
}
|
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline int
|
2003-04-19 23:33:29 +04:00
|
|
|
ahc_get_pci_slot(ahc_dev_softc_t pci)
|
|
|
|
{
|
|
|
|
return (pci_get_slot(pci));
|
|
|
|
}
|
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline int
|
2003-04-19 23:33:29 +04:00
|
|
|
ahc_get_pci_bus(ahc_dev_softc_t pci)
|
|
|
|
{
|
|
|
|
return (pci_get_bus(pci));
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
AHC_POWER_STATE_D0,
|
|
|
|
AHC_POWER_STATE_D1,
|
|
|
|
AHC_POWER_STATE_D2,
|
|
|
|
AHC_POWER_STATE_D3
|
|
|
|
} ahc_power_state;
|
|
|
|
|
2003-07-08 14:06:28 +04:00
|
|
|
void ahc_power_state_change(struct ahc_softc *, ahc_power_state);
|
2003-04-19 23:33:29 +04:00
|
|
|
#endif
|
|
|
|
/******************************** VL/EISA *************************************/
|
2003-07-08 14:06:28 +04:00
|
|
|
int aic7770_map_registers(struct ahc_softc *, u_int);
|
|
|
|
int aic7770_map_int(struct ahc_softc *, int);
|
2003-04-19 23:33:29 +04:00
|
|
|
|
|
|
|
/********************************* Debug **************************************/
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline void ahc_print_path(struct ahc_softc *, struct scb *);
|
|
|
|
static __inline void ahc_platform_dump_card_state(struct ahc_softc *);
|
2003-04-19 23:33:29 +04:00
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline void
|
2006-11-16 04:32:37 +03:00
|
|
|
ahc_print_path(struct ahc_softc *ahc, struct scb *scb)
|
2003-04-19 23:33:29 +04:00
|
|
|
{
|
2009-05-05 13:51:23 +04:00
|
|
|
printf("%s:", device_xname(ahc->sc_dev));
|
2003-04-19 23:33:29 +04:00
|
|
|
}
|
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline void
|
2006-11-16 04:32:37 +03:00
|
|
|
ahc_platform_dump_card_state(struct ahc_softc *ahc)
|
2003-04-19 23:33:29 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
/**************************** Transfer Settings *******************************/
|
|
|
|
void ahc_notify_xfer_settings_change(struct ahc_softc *,
|
|
|
|
struct ahc_devinfo *);
|
2003-07-08 14:06:28 +04:00
|
|
|
void ahc_platform_set_tags(struct ahc_softc *, struct ahc_devinfo *, int);
|
2003-04-19 23:33:29 +04:00
|
|
|
|
|
|
|
/************************* Initialization/Teardown ****************************/
|
2003-07-08 14:06:28 +04:00
|
|
|
int ahc_platform_alloc(struct ahc_softc *, void *);
|
|
|
|
void ahc_platform_free(struct ahc_softc *);
|
|
|
|
int ahc_map_int(struct ahc_softc *);
|
2003-04-19 23:33:29 +04:00
|
|
|
int ahc_attach(struct ahc_softc *);
|
2003-07-08 14:06:28 +04:00
|
|
|
int ahc_softc_comp(struct ahc_softc *, struct ahc_softc *);
|
2009-05-16 10:44:05 +04:00
|
|
|
int ahc_detach(struct ahc_softc *, int);
|
2003-04-19 23:33:29 +04:00
|
|
|
|
|
|
|
/****************************** Interrupts ************************************/
|
|
|
|
void ahc_platform_intr(void *);
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline void ahc_platform_flushwork(struct ahc_softc *);
|
|
|
|
static __inline void
|
2006-11-16 04:32:37 +03:00
|
|
|
ahc_platform_flushwork(struct ahc_softc *ahc)
|
2003-04-19 23:33:29 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************ Misc Function Declarations **************************/
|
2003-07-08 14:06:28 +04:00
|
|
|
void ahc_done(struct ahc_softc *, struct scb *);
|
|
|
|
void ahc_send_async(struct ahc_softc *, char, u_int, u_int, ac_code,
|
|
|
|
void *);
|
2003-04-19 23:33:29 +04:00
|
|
|
#endif /* _AIC7XXX_NETBSD_H_ */
|