1 /*- 2 * Copyright (c) 2000, 2001 Michael Smith 3 * Copyright (c) 2000 BSDi 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 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. 14 * 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 25 * SUCH DAMAGE. 26 * 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.3 2003/06/19 01:55:04 dillon Exp $ 29 */ 30 /* 31 * Portability and compatibility interfaces. 32 */ 33 34 #if __FreeBSD_version < 500003 35 # include <machine/clock.h> 36 # define INTR_ENTROPY 0 37 38 # include <sys/proc.h> /* old buf style */ 39 # include <sys/buf.h> /* old buf style */ 40 # include <sys/buf2.h> 41 typedef struct buf mlx_bio; 42 typedef struct buf_queue_head mlx_bioq; 43 # define MLX_BIO_QINIT(bq) bufq_init(&bq); 44 # define MLX_BIO_QINSERT(bq, bp) bufq_insert_tail(&bq, bp) 45 # define MLX_BIO_QFIRST(bq) bufq_first(&bq) 46 # define MLX_BIO_QREMOVE(bq, bp) bufq_remove(&bq, bp) 47 # define MLX_BIO_IS_READ(bp) ((bp)->b_flags & B_READ) 48 # define MLX_BIO_DATA(bp) (bp)->b_data 49 # define MLX_BIO_LENGTH(bp) (bp)->b_bcount 50 # define MLX_BIO_LBA(bp) (bp)->b_pblkno 51 # define MLX_BIO_SOFTC(bp) (bp)->b_dev->si_drv1 52 # define MLX_BIO_UNIT(bp) *(int *)((bp)->b_dev->si_drv2) 53 # define MLX_BIO_SET_ERROR(bp, err) do { (bp)->b_error = err; (bp)->b_flags |= B_ERROR;} while(0) 54 # define MLX_BIO_HAS_ERROR(bp) ((bp)->b_flags & B_ERROR) 55 # define MLX_BIO_RESID(bp) (bp)->b_resid 56 # define MLX_BIO_DONE(bp) biodone(bp) 57 # define MLX_BIO_STATS_START(bp) devstat_start_transaction(&((struct mlxd_softc *)MLX_BIO_SOFTC(bp))->mlxd_stats) 58 # define MLX_BIO_STATS_END(bp) devstat_end_transaction_buf(&((struct mlxd_softc *)MLX_BIO_SOFTC(bp))->mlxd_stats, bp) 59 #else 60 # include <sys/bio.h> 61 typedef struct bio mlx_bio; 62 typedef struct bio_queue_head mlx_bioq; 63 # define MLX_BIO_QINIT(bq) bioq_init(&bq); 64 # define MLX_BIO_QINSERT(bq, bp) bioq_insert_tail(&bq, bp) 65 # define MLX_BIO_QFIRST(bq) bioq_first(&bq) 66 # define MLX_BIO_QREMOVE(bq, bp) bioq_remove(&bq, bp) 67 # define MLX_BIO_IS_READ(bp) ((bp)->bio_cmd == BIO_READ) 68 # define MLX_BIO_DATA(bp) (bp)->bio_data 69 # define MLX_BIO_LENGTH(bp) (bp)->bio_bcount 70 # define MLX_BIO_LBA(bp) (bp)->bio_pblkno 71 # define MLX_BIO_SOFTC(bp) (bp)->bio_dev->si_drv1 72 # define MLX_BIO_UNIT(bp) *(int *)((bp)->bio_dev->si_drv2) 73 # define MLX_BIO_SET_ERROR(bp, err) do { (bp)->bio_error = err; (bp)->bio_flags |= BIO_ERROR;} while(0) 74 # define MLX_BIO_HAS_ERROR(bp) ((bp)->bio_flags & BIO_ERROR) 75 # define MLX_BIO_RESID(bp) (bp)->bio_resid 76 # define MLX_BIO_DONE(bp) biodone(bp) /* XXX nice to integrate bio_finish here */ 77 # define MLX_BIO_STATS_START(bp) devstat_start_transaction(&((struct mlxd_softc *)MLX_BIO_SOFTC(bp))->mlxd_stats) 78 # define MLX_BIO_STATS_END(bp) devstat_end_transaction_bio(&((struct mlxd_softc *)MLX_BIO_SOFTC(bp))->mlxd_stats, bp) 79 #endif 80 81