2 * Copyright (c) 2000, 2001 Michael Smith
3 * Copyright (c) 2000 BSDi
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * $FreeBSD: src/sys/dev/mlx/mlx_compat.h,v 1.1.2.1 2001/06/25 04:37:51 msmith Exp $
28 * $DragonFly: src/sys/dev/raid/mlx/mlx_compat.h,v 1.7 2006/04/30 19:22:16 dillon Exp $
31 * Portability and compatibility interfaces.
34 #if defined(__DragonFly__) || __FreeBSD_version < 500003
35 # include <machine/clock.h>
37 # include <sys/proc.h> /* old buf style */
38 # include <sys/buf.h> /* old buf style */
39 # include <sys/buf2.h>
40 typedef struct bio mlx_bio
;
41 typedef struct bio_queue_head mlx_bioq
;
44 typedef struct bio mlx_bio
;
45 typedef struct bio_queue_head mlx_bioq
;
46 # define MLX_BIO_QINIT(bq) bioq_init(&bq);
47 # define MLX_BIO_QINSERT(bq, bp) bioq_insert_tail(&bq, bp)
48 # define MLX_BIO_QFIRST(bq) bioq_first(&bq)
49 # define MLX_BIO_QREMOVE(bq, bp) bioq_remove(&bq, bp)
50 # define MLX_BIO_IS_READ(bp) ((bp)->bio_cmd == BIO_READ)
51 # define MLX_BIO_DATA(bp) (bp)->bio_data
52 # define MLX_BIO_LENGTH(bp) (bp)->bio_bcount
53 # define MLX_BIO_LBA(bp) (bp)->bio_pblkno
54 # define MLX_BIO_SOFTC(bp) (bp)->bio_dev->si_drv1
55 # define MLX_BIO_UNIT(bp) *(int *)((bp)->bio_dev->si_drv2)
56 # define MLX_BIO_SET_ERROR(bp, err) do { (bp)->bio_error = err; (bp)->bio_flags |= BIO_ERROR;} while(0)
57 # define MLX_BIO_HAS_ERROR(bp) ((bp)->bio_flags & BIO_ERROR)
58 # define MLX_BIO_RESID(bp) (bp)->bio_resid
59 # define MLX_BIO_DONE(bp) biodone(bp) /* XXX nice to integrate bio_finish here */
60 # define MLX_BIO_STATS_START(bp) devstat_start_transaction(&((struct mlxd_softc *)MLX_BIO_SOFTC(bp))->mlxd_stats)
61 # define MLX_BIO_STATS_END(bp) devstat_end_transaction_bio(&((struct mlxd_softc *)MLX_BIO_SOFTC(bp))->mlxd_stats, bp)