/*-
* Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace
* Simulation Facility, NASA Ames Research Center.
*
* 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.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
/* XXX adjust hash for large numbers of CCBs */
#define CCB_HASH_SIZE 32 /* hash table size for phystokv */
#define CCB_HASH_SHIFT 9
#define CCB_HASH(x) ((((long)(x))>>CCB_HASH_SHIFT) & (CCB_HASH_SIZE - 1))
/*
* A CCB allocation group. Each group is a page size. We can find
* the allocation group for a CCB by truncating the CCB address to
* a page boundary, and the offset from the group's DMA mapping
* by taking the offset of the CCB into the page.
*/
#define BHA_CCBS_PER_GROUP ((PAGE_SIZE - sizeof(bus_dmamap_t)) / \
sizeof(struct bha_ccb))
struct bha_ccb_group {
bus_dmamap_t bcg_dmamap;
struct bha_ccb bcg_ccbs[1]; /* determined at run-time */
};
/*
* Offset in the DMA mapping for mailboxes.
* Since all mailboxes are allocated on a single DMA'able memory
* due to the hardware limitation, an offset of any mailboxes can be
* calculated using same expression.
*/
#define BHA_MBX_OFFSET(sc, mbx) ((u_long)(mbx) - (u_long)(sc)->sc_mbo)
#define BHA_MBI_SYNC(sc, mbi, ops) \
do { \
bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_dmamap_mbox, \
BHA_MBX_OFFSET((sc), (mbi)), sizeof(struct bha_mbx_in), (ops)); \
} while (0)
#define BHA_MBO_SYNC(sc, mbo, ops) \
do { \
bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_dmamap_mbox, \
BHA_MBX_OFFSET((sc), (mbo)), sizeof(struct bha_mbx_out), (ops)); \
} while (0)
int sc_max_dmaseg; /* maximum number of DMA segments */
int sc_max_ccbs; /* maximum number of CCBs (HW) */
int sc_cur_ccbs; /* current number of CCBs */
int sc_disc_mask; /* mask of targets allowing discnnct */
int sc_ultra_mask; /* mask of targets allowing ultra */
int sc_fast_mask; /* mask of targets allowing fast */
int sc_sync_mask; /* mask of targets allowing sync */
int sc_wide_mask; /* mask of targets allowing wide */
int sc_tag_mask; /* mask of targets allowing t/q'ing */
/*
* In and Out mailboxes.
*/
struct bha_mbx_out *sc_mbo;
struct bha_mbx_in *sc_mbi;
struct bha_mbx_out *sc_cmbo; /* Collection Mail Box out */
struct bha_mbx_out *sc_tmbo; /* Target Mail Box out */
int sc_mbox_count; /* number of mailboxes */
int sc_mbofull; /* number of full Mail Box Out */
struct bha_mbx_in *sc_tmbi; /* Target Mail Box in */
int bha_find(bus_space_tag_t, bus_space_handle_t);
int bha_inquire_config(bus_space_tag_t, bus_space_handle_t,
struct bha_probe_data *);
void bha_attach(struct bha_softc *);
int bha_info(struct bha_softc *);
int bha_intr(void *);
int bha_disable_isacompat(struct bha_softc *);
int bha_probe_inquiry(bus_space_tag_t, bus_space_handle_t,
struct bha_probe_data *);