2 * Copyright (c) 2000 Michael Smith
3 * Copyright (c) 2003 Paul Saab
4 * Copyright (c) 2003 Vinod Kashyap
5 * Copyright (c) 2000 BSDi
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * $FreeBSD: src/sys/dev/twe/twe_compat.h,v 1.14 2005/05/29 04:42:26 nyan Exp $
32 * Portability and compatibility interfaces.
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/malloc.h>
38 #include <sys/kernel.h>
39 #include <sys/sysctl.h>
46 #include <sys/devicestat.h>
47 #include <sys/thread2.h>
49 #include <bus/pci/pcireg.h>
50 #include <bus/pci/pcivar.h>
52 #define TWE_DRIVER_NAME twe
53 #define TWED_DRIVER_NAME twed
54 #define TWE_MALLOC_CLASS M_TWE
57 * Wrappers for bus-space actions
59 #define TWE_CONTROL(sc, val) bus_space_write_4((sc)->twe_btag, (sc)->twe_bhandle, 0x0, (u_int32_t)val)
60 #define TWE_STATUS(sc) (u_int32_t)bus_space_read_4((sc)->twe_btag, (sc)->twe_bhandle, 0x4)
61 #define TWE_COMMAND_QUEUE(sc, val) bus_space_write_4((sc)->twe_btag, (sc)->twe_bhandle, 0x8, (u_int32_t)val)
62 #define TWE_RESPONSE_QUEUE(sc) (TWE_Response_Queue)bus_space_read_4((sc)->twe_btag, (sc)->twe_bhandle, 0xc)
65 * FreeBSD-specific softc elements
67 #define TWE_PLATFORM_SOFTC \
68 bus_dmamap_t twe_cmdmap; /* DMA map for command */ \
69 u_int32_t twe_cmdphys; /* address of command in controller space */ \
70 device_t twe_dev; /* bus device */ \
71 cdev_t twe_dev_t; /* control device */ \
72 struct resource *twe_io; /* register interface window */ \
73 bus_space_handle_t twe_bhandle; /* bus space handle */ \
74 bus_space_tag_t twe_btag; /* bus space tag */ \
75 bus_dma_tag_t twe_parent_dmat; /* parent DMA tag */ \
76 bus_dma_tag_t twe_buffer_dmat; /* data buffer DMA tag */ \
77 bus_dma_tag_t twe_cmd_dmat; /* command buffer DMA tag */ \
78 bus_dma_tag_t twe_immediate_dmat; /* command buffer DMA tag */ \
79 struct resource *twe_irq; /* interrupt */ \
80 void *twe_intr; /* interrupt handle */ \
81 struct intr_config_hook twe_ich; /* delayed-startup hook */ \
82 void *twe_cmd; /* command structures */ \
83 void *twe_immediate; /* immediate commands */ \
84 bus_dmamap_t twe_immediate_map; \
85 struct sysctl_ctx_list sysctl_ctx; \
86 struct sysctl_oid *sysctl_tree;
89 * FreeBSD-specific request elements
91 #define TWE_PLATFORM_REQUEST \
92 bus_dmamap_t tr_dmamap; /* DMA map for data */ \
93 u_int32_t tr_dataphys; /* data buffer base address in controller space */
96 * Output identifying the controller/disk
98 #define twe_printf(sc, fmt, args...) device_printf(sc->twe_dev, fmt , ##args)
99 #define twed_printf(twed, fmt, args...) device_printf(twed->twed_dev, fmt , ##args)
101 typedef struct bio twe_bio;
102 typedef struct bio_queue_head twe_bioq;