#ifndef _SYS_SCSI_SCSI_RESOURCE_H
#define _SYS_SCSI_SCSI_RESOURCE_H
#ifdef __lock_lint
#include <note.h>
#endif
#include <sys/scsi/scsi_types.h>
#ifdef __cplusplus
extern "C" {
#endif
#define NULL_FUNC ((int (*)())0)
#define SLEEP_FUNC ((int (*)())1)
#ifdef _KERNEL
#define PKT_CONSISTENT 0x0001
#define PKT_DMA_PARTIAL 0x040000
#define PKT_XARQ 0x080000
#define PKT_CONSISTENT_OLD 0x001000
struct buf *scsi_alloc_consistent_buf(struct scsi_address *,
struct buf *, size_t, uint_t, int (*)(caddr_t), caddr_t);
struct scsi_pkt *scsi_init_pkt(struct scsi_address *,
struct scsi_pkt *, struct buf *, int, int, int, int,
int (*)(caddr_t), caddr_t);
void scsi_destroy_pkt(struct scsi_pkt *);
void scsi_free_consistent_buf(struct buf *);
int scsi_pkt_allocated_correctly(struct scsi_pkt *);
struct scsi_pkt *scsi_dmaget(struct scsi_pkt *, opaque_t, int (*)(void));
void scsi_dmafree(struct scsi_pkt *);
void scsi_sync_pkt(struct scsi_pkt *);
struct scsi_pkt_cache_wrapper {
struct scsi_pkt pcw_pkt;
int pcw_magic;
uint_t pcw_total_xfer;
uint_t pcw_curwin;
uint_t pcw_totalwin;
uint_t pcw_granular;
struct buf *pcw_bp;
ddi_dma_cookie_t pcw_cookie;
uint_t pcw_flags;
};
#ifdef __lock_lint
_NOTE(SCHEME_PROTECTS_DATA("unique per packet",
scsi_pkt_cache_wrapper::pcw_bp
scsi_pkt_cache_wrapper::pcw_curwin
scsi_pkt_cache_wrapper::pcw_flags
scsi_pkt_cache_wrapper::pcw_granular
scsi_pkt_cache_wrapper::pcw_total_xfer
scsi_pkt_cache_wrapper::pcw_totalwin))
#endif
struct buf *scsi_pkt2bp(struct scsi_pkt *);
#define PCW_NEED_EXT_CDB 0x0001
#define PCW_NEED_EXT_TGT 0x0002
#define PCW_NEED_EXT_SCB 0x0004
#define PCW_BOUND 0x0020
#define DEFAULT_CDBLEN 16
#define DEFAULT_PRIVLEN 0
#define DEFAULT_SCBLEN (sizeof (struct scsi_arq_status))
size_t scsi_pkt_size();
void scsi_size_clean(dev_info_t *);
struct scsi_pkt *scsi_pktalloc(struct scsi_address *, int, int, int (*)(void));
struct scsi_pkt *scsi_resalloc(struct scsi_address *, int,
int, opaque_t, int (*)(void));
void scsi_resfree(struct scsi_pkt *);
#define scsi_pktfree scsi_resfree
#endif
#ifdef __cplusplus
}
#endif
#endif