aic7xxx_osm.h revision 100548
1238384Sjkim/* 2238384Sjkim * FreeBSD platform specific driver option settings, data structures, 3238384Sjkim * function declarations and includes. 4238384Sjkim * 5238384Sjkim * Copyright (c) 1994-2001 Justin T. Gibbs. 6238384Sjkim * All rights reserved. 7238384Sjkim * 8238384Sjkim * Redistribution and use in source and binary forms, with or without 9238384Sjkim * modification, are permitted provided that the following conditions 10238384Sjkim * are met: 11238384Sjkim * 1. Redistributions of source code must retain the above copyright 12238384Sjkim * notice, this list of conditions, and the following disclaimer, 13238384Sjkim * without modification. 14238384Sjkim * 2. The name of the author may not be used to endorse or promote products 15238384Sjkim * derived from this software without specific prior written permission. 16238384Sjkim * 17238384Sjkim * Alternatively, this software may be distributed under the terms of the 18238384Sjkim * GNU Public License ("GPL"). 19238384Sjkim * 20238384Sjkim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 21238384Sjkim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22238384Sjkim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23238384Sjkim * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 24238384Sjkim * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25238384Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26238384Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27238384Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28238384Sjkim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29238384Sjkim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30238384Sjkim * SUCH DAMAGE. 31238384Sjkim * 32280304Sjkim * $Id$ 33280304Sjkim * 34280304Sjkim * $FreeBSD: head/sys/dev/aic7xxx/aic7xxx_osm.h 100548 2002-07-23 06:31:45Z peter $ 35280304Sjkim */ 36280304Sjkim 37238384Sjkim#ifndef _AIC7XXX_FREEBSD_H_ 38280304Sjkim#define _AIC7XXX_FREEBSD_H_ 39280304Sjkim 40280304Sjkim#include <opt_aic7xxx.h> /* for config options */ 41238384Sjkim 42280304Sjkim#include <sys/param.h> 43238384Sjkim#include <sys/systm.h> 44280304Sjkim#include <sys/bus.h> /* For device_t */ 45280304Sjkim#include <sys/endian.h> 46280304Sjkim#include <sys/eventhandler.h> 47280304Sjkim#include <sys/kernel.h> 48280304Sjkim#include <sys/malloc.h> 49238384Sjkim#include <sys/queue.h> 50238384Sjkim 51238384Sjkim#if __FreeBSD_version < 500000 52238384Sjkim#include <pci.h> 53238384Sjkim#else 54280304Sjkim#define NPCI 1 55280304Sjkim#endif 56280304Sjkim 57280304Sjkim#if NPCI > 0 58280304Sjkim#define AHC_PCI_CONFIG 1 59238384Sjkim#ifdef AHC_ALLOW_MEMIO 60238384Sjkim#include <machine/bus_memio.h> 61238384Sjkim#endif 62280304Sjkim#endif 63280304Sjkim#include <machine/bus_pio.h> 64280304Sjkim#include <machine/bus.h> 65280304Sjkim#include <machine/endian.h> 66280304Sjkim#include <machine/clock.h> 67280304Sjkim#include <machine/resource.h> 68280304Sjkim 69280304Sjkim#include <sys/rman.h> 70280304Sjkim 71280304Sjkim#if NPCI > 0 72280304Sjkim#include <pci/pcireg.h> 73280304Sjkim#include <pci/pcivar.h> 74280304Sjkim#endif 75280304Sjkim 76280304Sjkim#include <cam/cam.h> 77280304Sjkim#include <cam/cam_ccb.h> 78280304Sjkim#include <cam/cam_debug.h> 79280304Sjkim#include <cam/cam_sim.h> 80280304Sjkim#include <cam/cam_xpt_sim.h> 81280304Sjkim 82280304Sjkim#include <cam/scsi/scsi_all.h> 83280304Sjkim#include <cam/scsi/scsi_message.h> 84280304Sjkim 85280304Sjkim#ifdef CAM_NEW_TRAN_CODE 86280304Sjkim#define AHC_NEW_TRAN_SETTINGS 87280304Sjkim#endif /* CAM_NEW_TRAN_CODE */ 88280304Sjkim 89280304Sjkim/****************************** Platform Macros *******************************/ 90280304Sjkim#define SIM_IS_SCSIBUS_B(ahc, sim) \ 91280304Sjkim ((sim) == ahc->platform_data->sim_b) 92280304Sjkim#define SIM_CHANNEL(ahc, sim) \ 93280304Sjkim (((sim) == ahc->platform_data->sim_b) ? 'B' : 'A') 94280304Sjkim#define SIM_SCSI_ID(ahc, sim) \ 95280304Sjkim (((sim) == ahc->platform_data->sim_b) ? ahc->our_id_b : ahc->our_id) 96280304Sjkim#define SIM_PATH(ahc, sim) \ 97280304Sjkim (((sim) == ahc->platform_data->sim_b) ? ahc->platform_data->path_b \ 98280304Sjkim : ahc->platform_data->path) 99280304Sjkim#define BUILD_SCSIID(ahc, sim, target_id, our_id) \ 100280304Sjkim ((((target_id) << TID_SHIFT) & TID) | (our_id) \ 101280304Sjkim | (SIM_IS_SCSIBUS_B(ahc, sim) ? TWIN_CHNLB : 0)) 102280304Sjkim 103280304Sjkim#define SCB_GET_SIM(ahc, scb) \ 104280304Sjkim (SCB_GET_CHANNEL(ahc, scb) == 'A' ? (ahc)->platform_data->sim \ 105280304Sjkim : (ahc)->platform_data->sim_b) 106280304Sjkim 107280304Sjkim#ifndef offsetof 108280304Sjkim#define offsetof(type, member) ((size_t)(&((type *)0)->member)) 109280304Sjkim#endif 110280304Sjkim/************************* Forward Declarations *******************************/ 111280304Sjkimtypedef device_t ahc_dev_softc_t; 112280304Sjkimtypedef union ccb *ahc_io_ctx_t; 113238384Sjkim 114280304Sjkim/***************************** Bus Space/DMA **********************************/ 115280304Sjkim#define ahc_dma_tag_create(ahc, parent_tag, alignment, boundary, \ 116238384Sjkim lowaddr, highaddr, filter, filterarg, \ 117238384Sjkim maxsize, nsegments, maxsegsz, flags, \ 118238384Sjkim dma_tagp) \ 119238384Sjkim bus_dma_tag_create(parent_tag, alignment, boundary, \ 120238384Sjkim lowaddr, highaddr, filter, filterarg, \ 121238384Sjkim maxsize, nsegments, maxsegsz, flags, \ 122238384Sjkim dma_tagp) 123238384Sjkim 124238384Sjkim#define ahc_dma_tag_destroy(ahc, tag) \ 125238384Sjkim bus_dma_tag_destroy(tag) 126238384Sjkim 127238384Sjkim#define ahc_dmamem_alloc(ahc, dmat, vaddr, flags, mapp) \ 128280304Sjkim bus_dmamem_alloc(dmat, vaddr, flags, mapp) 129238384Sjkim 130238384Sjkim#define ahc_dmamem_free(ahc, dmat, vaddr, map) \ 131238384Sjkim bus_dmamem_free(dmat, vaddr, map) 132238384Sjkim 133238384Sjkim#define ahc_dmamap_create(ahc, tag, flags, mapp) \ 134238384Sjkim bus_dmamap_create(tag, flags, mapp) 135238384Sjkim 136238384Sjkim#define ahc_dmamap_destroy(ahc, tag, map) \ 137280304Sjkim bus_dmamap_destroy(tag, map) 138280304Sjkim 139280304Sjkim#define ahc_dmamap_load(ahc, dmat, map, addr, buflen, callback, \ 140280304Sjkim callback_arg, flags) \ 141238384Sjkim bus_dmamap_load(dmat, map, addr, buflen, callback, callback_arg, flags) 142280304Sjkim 143280304Sjkim#define ahc_dmamap_unload(ahc, tag, map) \ 144280304Sjkim bus_dmamap_unload(tag, map) 145280304Sjkim 146280304Sjkim/* XXX Need to update Bus DMA for partial map syncs */ 147280304Sjkim#define ahc_dmamap_sync(ahc, dma_tag, dmamap, offset, len, op) \ 148280304Sjkim bus_dmamap_sync(dma_tag, dmamap, op) 149280304Sjkim 150280304Sjkim/************************ Tunable Driver Parameters **************************/ 151280304Sjkim/* 152280304Sjkim * The number of dma segments supported. The sequencer can handle any number 153238384Sjkim * of physically contiguous S/G entrys. To reduce the driver's memory 154280304Sjkim * consumption, we limit the number supported to be sufficient to handle 155280304Sjkim * the largest mapping supported by the kernel, MAXPHYS. Assuming the 156280304Sjkim * transfer is as fragmented as possible and unaligned, this turns out to 157280304Sjkim * be the number of paged sized transfers in MAXPHYS plus an extra element 158238384Sjkim * to handle any unaligned residual. The sequencer fetches SG elements 159280304Sjkim * in cacheline sized chucks, so make the number per-transaction an even 160280304Sjkim * multiple of 16 which should align us on even the largest of cacheline 161280304Sjkim * boundaries. 162280304Sjkim */ 163280304Sjkim#define AHC_NSEG (roundup(btoc(MAXPHYS) + 1, 16)) 164280304Sjkim 165280304Sjkim/* This driver supports target mode */ 166280304Sjkim#define AHC_TARGET_MODE 1 167280304Sjkim 168280304Sjkim/************************** Softc/SCB Platform Data ***************************/ 169280304Sjkimstruct ahc_platform_data { 170280304Sjkim /* 171238384Sjkim * Hooks into the XPT. 172238384Sjkim */ 173238384Sjkim struct cam_sim *sim; 174280304Sjkim struct cam_sim *sim_b; 175280304Sjkim struct cam_path *path; 176280304Sjkim struct cam_path *path_b; 177280304Sjkim 178280304Sjkim int regs_res_type; 179238384Sjkim int regs_res_id; 180238384Sjkim int irq_res_type; 181238384Sjkim struct resource *regs; 182280304Sjkim struct resource *irq; 183280304Sjkim void *ih; 184280304Sjkim eventhandler_tag eh; 185280304Sjkim}; 186238384Sjkim 187280304Sjkimstruct scb_platform_data { 188280304Sjkim}; 189280304Sjkim 190280304Sjkim/********************************* Byte Order *********************************/ 191280304Sjkim#define ahc_htobe16(x) htobe16(x) 192280304Sjkim#define ahc_htobe32(x) htobe32(x) 193280304Sjkim#define ahc_htobe64(x) htobe64(x) 194280304Sjkim#define ahc_htole16(x) htole16(x) 195280304Sjkim#define ahc_htole32(x) htole32(x) 196280304Sjkim#define ahc_htole64(x) htole64(x) 197280304Sjkim 198280304Sjkim#define ahc_be16toh(x) be16toh(x) 199280304Sjkim#define ahc_be32toh(x) be32toh(x) 200280304Sjkim#define ahc_be64toh(x) be64toh(x) 201280304Sjkim#define ahc_le16toh(x) le16toh(x) 202280304Sjkim#define ahc_le32toh(x) le32toh(x) 203238384Sjkim#define ahc_le64toh(x) le64toh(x) 204238384Sjkim 205238384Sjkim/***************************** Core Includes **********************************/ 206280304Sjkim#include <dev/aic7xxx/aic7xxx.h> 207280304Sjkim 208280304Sjkim/*************************** Device Access ************************************/ 209280304Sjkim#define ahc_inb(ahc, port) \ 210280304Sjkim bus_space_read_1((ahc)->tag, (ahc)->bsh, port) 211280304Sjkim 212238384Sjkim#define ahc_outb(ahc, port, value) \ 213280304Sjkim bus_space_write_1((ahc)->tag, (ahc)->bsh, port, value) 214280304Sjkim 215280304Sjkim#define ahc_outsb(ahc, port, valp, count) \ 216280304Sjkim bus_space_write_multi_1((ahc)->tag, (ahc)->bsh, port, valp, count) 217238384Sjkim 218238384Sjkim#define ahc_insb(ahc, port, valp, count) \ 219280304Sjkim bus_space_read_multi_1((ahc)->tag, (ahc)->bsh, port, valp, count) 220280304Sjkim 221280304Sjkimstatic __inline void ahc_flush_device_writes(struct ahc_softc *); 222280304Sjkim 223280304Sjkimstatic __inline void 224280304Sjkimahc_flush_device_writes(struct ahc_softc *ahc) 225280304Sjkim{ 226280304Sjkim /* XXX Is this sufficient for all architectures??? */ 227280304Sjkim ahc_inb(ahc, INTSTAT); 228280304Sjkim} 229280304Sjkim 230238384Sjkim/**************************** Locking Primitives ******************************/ 231238384Sjkim/* Lock protecting internal data structures */ 232280304Sjkimstatic __inline void ahc_lockinit(struct ahc_softc *); 233280304Sjkimstatic __inline void ahc_lock(struct ahc_softc *, unsigned long *flags); 234280304Sjkimstatic __inline void ahc_unlock(struct ahc_softc *, unsigned long *flags); 235280304Sjkim 236280304Sjkim/* Lock held during command compeletion to the upper layer */ 237280304Sjkimstatic __inline void ahc_done_lockinit(struct ahc_softc *); 238280304Sjkimstatic __inline void ahc_done_lock(struct ahc_softc *, unsigned long *flags); 239280304Sjkimstatic __inline void ahc_done_unlock(struct ahc_softc *, unsigned long *flags); 240280304Sjkim 241280304Sjkimstatic __inline void 242280304Sjkimahc_lockinit(struct ahc_softc *ahc) 243238384Sjkim{ 244238384Sjkim} 245238384Sjkim 246280304Sjkimstatic __inline void 247280304Sjkimahc_lock(struct ahc_softc *ahc, unsigned long *flags) 248280304Sjkim{ 249280304Sjkim *flags = splcam(); 250280304Sjkim} 251280304Sjkim 252280304Sjkimstatic __inline void 253280304Sjkimahc_unlock(struct ahc_softc *ahc, unsigned long *flags) 254280304Sjkim{ 255280304Sjkim splx(*flags); 256280304Sjkim} 257238384Sjkim 258238384Sjkim/* Lock held during command compeletion to the upper layer */ 259238384Sjkimstatic __inline void 260280304Sjkimahc_done_lockinit(struct ahc_softc *ahc) 261280304Sjkim{ 262280304Sjkim} 263280304Sjkim 264280304Sjkimstatic __inline void 265280304Sjkimahc_done_lock(struct ahc_softc *ahc, unsigned long *flags) 266280304Sjkim{ 267280304Sjkim} 268280304Sjkim 269280304Sjkimstatic __inline void 270280304Sjkimahc_done_unlock(struct ahc_softc *ahc, unsigned long *flags) 271238384Sjkim{ 272238384Sjkim} 273238384Sjkim 274280304Sjkim/****************************** OS Primitives *********************************/ 275280304Sjkim#define ahc_delay DELAY 276280304Sjkim 277280304Sjkim/************************** Transaction Operations ****************************/ 278280304Sjkimstatic __inline void ahc_set_transaction_status(struct scb *, uint32_t); 279280304Sjkimstatic __inline void ahc_set_scsi_status(struct scb *, uint32_t); 280280304Sjkimstatic __inline uint32_t ahc_get_transaction_status(struct scb *); 281280304Sjkimstatic __inline uint32_t ahc_get_scsi_status(struct scb *); 282280304Sjkimstatic __inline void ahc_set_transaction_tag(struct scb *, int, u_int); 283280304Sjkimstatic __inline u_long ahc_get_transfer_length(struct scb *); 284280304Sjkimstatic __inline int ahc_get_transfer_dir(struct scb *); 285238384Sjkimstatic __inline void ahc_set_residual(struct scb *, u_long); 286238384Sjkimstatic __inline void ahc_set_sense_residual(struct scb *, u_long); 287238384Sjkimstatic __inline u_long ahc_get_residual(struct scb *); 288280304Sjkimstatic __inline int ahc_perform_autosense(struct scb *); 289280304Sjkimstatic __inline uint32_t ahc_get_sense_bufsize(struct ahc_softc*, struct scb*); 290280304Sjkimstatic __inline void ahc_freeze_ccb(union ccb *ccb); 291280304Sjkimstatic __inline void ahc_freeze_scb(struct scb *scb); 292280304Sjkimstatic __inline void ahc_platform_freeze_devq(struct ahc_softc *, struct scb *); 293280304Sjkimstatic __inline int ahc_platform_abort_scbs(struct ahc_softc *ahc, int target, 294280304Sjkim char channel, int lun, u_int tag, 295280304Sjkim role_t role, uint32_t status); 296280304Sjkim 297280304Sjkimstatic __inline 298280304Sjkimvoid ahc_set_transaction_status(struct scb *scb, uint32_t status) 299238384Sjkim{ 300280304Sjkim scb->io_ctx->ccb_h.status &= ~CAM_STATUS_MASK; 301280304Sjkim scb->io_ctx->ccb_h.status |= status; 302238384Sjkim} 303238384Sjkim 304238384Sjkimstatic __inline 305238384Sjkimvoid ahc_set_scsi_status(struct scb *scb, uint32_t status) 306238384Sjkim{ 307238384Sjkim scb->io_ctx->csio.scsi_status = status; 308280304Sjkim} 309280304Sjkim 310280304Sjkimstatic __inline 311280304Sjkimuint32_t ahc_get_transaction_status(struct scb *scb) 312238384Sjkim{ 313280304Sjkim return (scb->io_ctx->ccb_h.status & CAM_STATUS_MASK); 314280304Sjkim} 315280304Sjkim 316280304Sjkimstatic __inline 317280304Sjkimuint32_t ahc_get_scsi_status(struct scb *scb) 318280304Sjkim{ 319280304Sjkim return (scb->io_ctx->csio.scsi_status); 320280304Sjkim} 321280304Sjkim 322280304Sjkimstatic __inline 323238384Sjkimvoid ahc_set_transaction_tag(struct scb *scb, int enabled, u_int type) 324280304Sjkim{ 325280304Sjkim scb->io_ctx->csio.tag_action = type; 326238384Sjkim if (enabled) 327238384Sjkim scb->io_ctx->ccb_h.flags |= CAM_TAG_ACTION_VALID; 328238384Sjkim else 329238384Sjkim scb->io_ctx->ccb_h.flags &= ~CAM_TAG_ACTION_VALID; 330238384Sjkim} 331238384Sjkim 332280304Sjkimstatic __inline 333280304Sjkimu_long ahc_get_transfer_length(struct scb *scb) 334280304Sjkim{ 335280304Sjkim return (scb->io_ctx->csio.dxfer_len); 336280304Sjkim} 337280304Sjkim 338238384Sjkimstatic __inline 339280304Sjkimint ahc_get_transfer_dir(struct scb *scb) 340280304Sjkim{ 341280304Sjkim return (scb->io_ctx->ccb_h.flags & CAM_DIR_MASK); 342280304Sjkim} 343280304Sjkim 344280304Sjkimstatic __inline 345280304Sjkimvoid ahc_set_residual(struct scb *scb, u_long resid) 346280304Sjkim{ 347280304Sjkim scb->io_ctx->csio.resid = resid; 348280304Sjkim} 349238384Sjkim 350280304Sjkimstatic __inline 351280304Sjkimvoid ahc_set_sense_residual(struct scb *scb, u_long resid) 352238384Sjkim{ 353238384Sjkim scb->io_ctx->csio.sense_resid = resid; 354238384Sjkim} 355238384Sjkim 356238384Sjkimstatic __inline 357238384Sjkimu_long ahc_get_residual(struct scb *scb) 358280304Sjkim{ 359280304Sjkim return (scb->io_ctx->csio.resid); 360280304Sjkim} 361280304Sjkim 362280304Sjkimstatic __inline 363280304Sjkimint ahc_perform_autosense(struct scb *scb) 364238384Sjkim{ 365280304Sjkim return (!(scb->io_ctx->ccb_h.flags & CAM_DIS_AUTOSENSE)); 366280304Sjkim} 367280304Sjkim 368280304Sjkimstatic __inline uint32_t 369280304Sjkimahc_get_sense_bufsize(struct ahc_softc *ahc, struct scb *scb) 370280304Sjkim{ 371280304Sjkim return (sizeof(struct scsi_sense_data)); 372280304Sjkim} 373280304Sjkim 374280304Sjkimstatic __inline void 375238384Sjkimahc_freeze_ccb(union ccb *ccb) 376280304Sjkim{ 377280304Sjkim if ((ccb->ccb_h.status & CAM_DEV_QFRZN) == 0) { 378238384Sjkim ccb->ccb_h.status |= CAM_DEV_QFRZN; 379238384Sjkim xpt_freeze_devq(ccb->ccb_h.path, /*count*/1); 380238384Sjkim } 381238384Sjkim} 382238384Sjkim 383238384Sjkimstatic __inline void 384280304Sjkimahc_freeze_scb(struct scb *scb) 385280304Sjkim{ 386280304Sjkim ahc_freeze_ccb(scb->io_ctx); 387280304Sjkim} 388280304Sjkim 389280304Sjkimstatic __inline void 390280304Sjkimahc_platform_freeze_devq(struct ahc_softc *ahc, struct scb *scb) 391280304Sjkim{ 392238384Sjkim /* Nothing to do here for FreeBSD */ 393280304Sjkim} 394280304Sjkim 395280304Sjkimstatic __inline int 396280304Sjkimahc_platform_abort_scbs(struct ahc_softc *ahc, int target, 397280304Sjkim char channel, int lun, u_int tag, 398280304Sjkim role_t role, uint32_t status) 399280304Sjkim{ 400280304Sjkim /* Nothing to do here for FreeBSD */ 401280304Sjkim return (0); 402280304Sjkim} 403238384Sjkim 404280304Sjkimstatic __inline void 405280304Sjkimahc_platform_scb_free(struct ahc_softc *ahc, struct scb *scb) 406238384Sjkim{ 407238384Sjkim /* What do we do to generically handle driver resource shortages??? */ 408238384Sjkim if ((ahc->flags & AHC_RESOURCE_SHORTAGE) != 0 409238384Sjkim && scb->io_ctx != NULL 410238384Sjkim && (scb->io_ctx->ccb_h.status & CAM_RELEASE_SIMQ) == 0) { 411238384Sjkim scb->io_ctx->ccb_h.status |= CAM_RELEASE_SIMQ; 412280304Sjkim ahc->flags &= ~AHC_RESOURCE_SHORTAGE; 413280304Sjkim } 414280304Sjkim scb->io_ctx = NULL; 415280304Sjkim} 416238384Sjkim 417280304Sjkim/********************************** PCI ***************************************/ 418280304Sjkim#ifdef AHC_PCI_CONFIG 419280304Sjkimstatic __inline uint32_t ahc_pci_read_config(ahc_dev_softc_t pci, 420280304Sjkim int reg, int width); 421280304Sjkimstatic __inline void ahc_pci_write_config(ahc_dev_softc_t pci, 422280304Sjkim int reg, uint32_t value, 423280304Sjkim int width); 424280304Sjkimstatic __inline int ahc_get_pci_function(ahc_dev_softc_t); 425280304Sjkimstatic __inline int ahc_get_pci_slot(ahc_dev_softc_t); 426280304Sjkimstatic __inline int ahc_get_pci_bus(ahc_dev_softc_t); 427238384Sjkim 428280304Sjkimint ahc_pci_map_registers(struct ahc_softc *ahc); 429280304Sjkimint ahc_pci_map_int(struct ahc_softc *ahc); 430280304Sjkim 431280304Sjkimstatic __inline uint32_t 432280304Sjkimahc_pci_read_config(ahc_dev_softc_t pci, int reg, int width) 433280304Sjkim{ 434280304Sjkim return (pci_read_config(pci, reg, width)); 435280304Sjkim} 436280304Sjkim 437280304Sjkimstatic __inline void 438280304Sjkimahc_pci_write_config(ahc_dev_softc_t pci, int reg, uint32_t value, int width) 439280304Sjkim{ 440280304Sjkim pci_write_config(pci, reg, value, width); 441280304Sjkim} 442280304Sjkim 443280304Sjkimstatic __inline int 444280304Sjkimahc_get_pci_function(ahc_dev_softc_t pci) 445280304Sjkim{ 446238384Sjkim return (pci_get_function(pci)); 447280304Sjkim} 448280304Sjkim 449280304Sjkimstatic __inline int 450280304Sjkimahc_get_pci_slot(ahc_dev_softc_t pci) 451280304Sjkim{ 452280304Sjkim return (pci_get_slot(pci)); 453280304Sjkim} 454280304Sjkim 455238384Sjkimstatic __inline int 456280304Sjkimahc_get_pci_bus(ahc_dev_softc_t pci) 457280304Sjkim{ 458280304Sjkim return (pci_get_bus(pci)); 459280304Sjkim} 460238384Sjkim 461280304Sjkimtypedef enum 462280304Sjkim{ 463280304Sjkim AHC_POWER_STATE_D0, 464280304Sjkim AHC_POWER_STATE_D1, 465238384Sjkim AHC_POWER_STATE_D2, 466280304Sjkim AHC_POWER_STATE_D3 467280304Sjkim} ahc_power_state; 468280304Sjkim 469238384Sjkimvoid ahc_power_state_change(struct ahc_softc *ahc, 470280304Sjkim ahc_power_state new_state); 471280304Sjkim#endif 472280304Sjkim/******************************** VL/EISA *************************************/ 473238384Sjkimint aic7770_map_registers(struct ahc_softc *ahc, u_int port); 474280304Sjkimint aic7770_map_int(struct ahc_softc *ahc, int irq); 475280304Sjkim 476238384Sjkim/********************************* Debug **************************************/ 477280304Sjkimstatic __inline void ahc_print_path(struct ahc_softc *, struct scb *); 478280304Sjkimstatic __inline void ahc_platform_dump_card_state(struct ahc_softc *ahc); 479238384Sjkim 480280304Sjkimstatic __inline void 481280304Sjkimahc_print_path(struct ahc_softc *ahc, struct scb *scb) 482238384Sjkim{ 483280304Sjkim xpt_print_path(scb->io_ctx->ccb_h.path); 484280304Sjkim} 485280304Sjkim 486238384Sjkimstatic __inline void 487280304Sjkimahc_platform_dump_card_state(struct ahc_softc *ahc) 488280304Sjkim{ 489238384Sjkim /* Nothing to do here for FreeBSD */ 490238384Sjkim} 491238384Sjkim/**************************** Transfer Settings *******************************/ 492238384Sjkimvoid ahc_notify_xfer_settings_change(struct ahc_softc *, 493238384Sjkim struct ahc_devinfo *); 494238384Sjkimvoid ahc_platform_set_tags(struct ahc_softc *, struct ahc_devinfo *, 495238384Sjkim int /*enable*/); 496280304Sjkim 497280304Sjkim/************************* Initialization/Teardown ****************************/ 498280304Sjkimint ahc_platform_alloc(struct ahc_softc *ahc, void *platform_arg); 499238384Sjkimvoid ahc_platform_free(struct ahc_softc *ahc); 500280304Sjkimint ahc_map_int(struct ahc_softc *ahc); 501238384Sjkimint ahc_attach(struct ahc_softc *); 502280304Sjkimint ahc_softc_comp(struct ahc_softc *lahc, struct ahc_softc *rahc); 503238384Sjkimint ahc_detach(device_t); 504280304Sjkim 505280304Sjkim/****************************** Interrupts ************************************/ 506238384Sjkimvoid ahc_platform_intr(void *); 507280304Sjkimstatic __inline void ahc_platform_flushwork(struct ahc_softc *ahc); 508280304Sjkimstatic __inline void 509280304Sjkimahc_platform_flushwork(struct ahc_softc *ahc) 510238384Sjkim{ 511280304Sjkim} 512280304Sjkim 513280304Sjkim/************************ Misc Function Declarations **************************/ 514280304Sjkimtimeout_t ahc_timeout; 515238384Sjkimvoid ahc_done(struct ahc_softc *ahc, struct scb *scb); 516280304Sjkimvoid ahc_send_async(struct ahc_softc *, char /*channel*/, 517280304Sjkim u_int /*target*/, u_int /*lun*/, ac_code, void *arg); 518280304Sjkim#endif /* _AIC7XXX_FREEBSD_H_ */ 519280304Sjkim