#ifndef _AIC79XX_FREEBSD_H_
#define _AIC79XX_FREEBSD_H_
#include "opt_aic79xx.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/endian.h>
#include <sys/eventhandler.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/queue.h>
#include <sys/sysctl.h>
#define AIC_PCI_CONFIG 1
#include <machine/bus.h>
#include <machine/endian.h>
#include <machine/resource.h>
#include <sys/rman.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <cam/cam.h>
#include <cam/cam_ccb.h>
#include <cam/cam_debug.h>
#include <cam/cam_sim.h>
#include <cam/cam_xpt_sim.h>
#include <cam/scsi/scsi_all.h>
#include <cam/scsi/scsi_message.h>
#include <cam/scsi/scsi_iu.h>
#define SIM_IS_SCSIBUS_B(ahd, sim) \
(0)
#define SIM_CHANNEL(ahd, sim) \
('A')
#define SIM_SCSI_ID(ahd, sim) \
(ahd->our_id)
#define SIM_PATH(ahd, sim) \
(ahd->platform_data->path)
#define BUILD_SCSIID(ahd, sim, target_id, our_id) \
((((target_id) << TID_SHIFT) & TID) | (our_id))
#define SCB_GET_SIM(ahd, scb) \
((ahd)->platform_data->sim)
#ifndef offsetof
#define offsetof(type, member) ((size_t)(&((type *)0)->member))
#endif
#define AHD_MAXPHYS (128 * 1024)
#define AHD_NSEG (roundup(btoc(AHD_MAXPHYS) + 1, 16))
#ifdef NOT_YET
#define AHD_TARGET_MODE 1
#endif
struct ahd_platform_data {
struct cam_sim *sim;
struct cam_path *path;
int regs_res_type[2];
int regs_res_id[2];
int irq_res_type;
struct resource *regs[2];
struct resource *irq;
void *ih;
eventhandler_tag eh;
struct proc *recovery_thread;
struct mtx mtx;
};
struct scb_platform_data {
};
#ifdef AHD_REG_PRETTY_PRINT
#define AIC_DEBUG_REGISTERS 1
#else
#define AIC_DEBUG_REGISTERS 0
#endif
#define AIC_CORE_INCLUDE <dev/aic7xxx/aic79xx.h>
#define AIC_LIB_PREFIX ahd
#define AIC_CONST_PREFIX AHD
#include <dev/aic7xxx/aic_osm_lib.h>
#define ahd_inb(ahd, port) \
bus_space_read_1((ahd)->tags[(port) >> 8], \
(ahd)->bshs[(port) >> 8], (port) & 0xFF)
#define ahd_outb(ahd, port, value) \
bus_space_write_1((ahd)->tags[(port) >> 8], \
(ahd)->bshs[(port) >> 8], (port) & 0xFF, value)
#define ahd_inw_atomic(ahd, port) \
aic_le16toh(bus_space_read_2((ahd)->tags[(port) >> 8], \
(ahd)->bshs[(port) >> 8], (port) & 0xFF))
#define ahd_outw_atomic(ahd, port, value) \
bus_space_write_2((ahd)->tags[(port) >> 8], \
(ahd)->bshs[(port) >> 8], \
(port & 0xFF), aic_htole16(value))
#define ahd_outsb(ahd, port, valp, count) \
bus_space_write_multi_1((ahd)->tags[(port) >> 8], \
(ahd)->bshs[(port) >> 8], \
(port & 0xFF), valp, count)
#define ahd_insb(ahd, port, valp, count) \
bus_space_read_multi_1((ahd)->tags[(port) >> 8], \
(ahd)->bshs[(port) >> 8], \
(port & 0xFF), valp, count)
static __inline void ahd_flush_device_writes(struct ahd_softc *);
static __inline void
ahd_flush_device_writes(struct ahd_softc *ahd)
{
ahd_inb(ahd, INTSTAT);
}
static __inline void ahd_lockinit(struct ahd_softc *);
static __inline void ahd_lock(struct ahd_softc *);
static __inline void ahd_unlock(struct ahd_softc *);
static __inline void
ahd_lockinit(struct ahd_softc *ahd)
{
mtx_init(&ahd->platform_data->mtx, "ahd_lock", NULL, MTX_DEF);
}
static __inline void
ahd_lock(struct ahd_softc *ahd)
{
mtx_lock(&ahd->platform_data->mtx);
}
static __inline void
ahd_unlock(struct ahd_softc *ahd)
{
mtx_unlock(&ahd->platform_data->mtx);
}
int ahd_pci_map_registers(struct ahd_softc *ahd);
int ahd_pci_map_int(struct ahd_softc *ahd);
static __inline void aic_freeze_simq(struct aic_softc*);
static __inline void aic_release_simq(struct aic_softc*);
static __inline void
aic_freeze_simq(struct aic_softc *aic)
{
xpt_freeze_simq(aic->platform_data->sim, 1);
}
static __inline void
aic_release_simq(struct aic_softc *aic)
{
xpt_release_simq(aic->platform_data->sim, TRUE);
}
static __inline void ahd_print_path(struct ahd_softc *, struct scb *);
static __inline void ahd_platform_dump_card_state(struct ahd_softc *ahd);
static __inline void
ahd_print_path(struct ahd_softc *ahd, struct scb *scb)
{
xpt_print_path(scb->io_ctx->ccb_h.path);
}
static __inline void
ahd_platform_dump_card_state(struct ahd_softc *ahd)
{
}
void ahd_notify_xfer_settings_change(struct ahd_softc *,
struct ahd_devinfo *);
void ahd_platform_set_tags(struct ahd_softc *, struct ahd_devinfo *,
int );
int ahd_platform_alloc(struct ahd_softc *ahd, void *platform_arg);
void ahd_platform_free(struct ahd_softc *ahd);
int ahd_map_int(struct ahd_softc *ahd);
int ahd_attach(struct ahd_softc *);
int ahd_softc_comp(struct ahd_softc *lahd, struct ahd_softc *rahd);
void ahd_sysctl(struct ahd_softc *ahd);
int ahd_detach(device_t);
#define ahd_platform_init(arg)
void ahd_platform_intr(void *);
static __inline void ahd_platform_flushwork(struct ahd_softc *ahd);
static __inline void
ahd_platform_flushwork(struct ahd_softc *ahd)
{
}
void ahd_done(struct ahd_softc *ahd, struct scb *scb);
void ahd_send_async(struct ahd_softc *, char ,
u_int , u_int , ac_code, void *arg);
#endif