linux/drivers/scsi/BusLogic.h

/* SPDX-License-Identifier: GPL-2.0-only */
/*

  Linux Driver for BusLogic MultiMaster and FlashPoint SCSI Host Adapters

  Copyright 1995-1998 by Leonard N. Zubkoff <[email protected]>


  The author respectfully requests that any modifications to this software be
  sent directly to him for evaluation and testing.

  Special thanks to Wayne Yen, Jin-Lon Hon, and Alex Win of BusLogic, whose
  advice has been invaluable, to David Gentzel, for writing the original Linux
  BusLogic driver, and to Paul Gortmaker, for being such a dedicated test site.

  Finally, special thanks to Mylex/BusLogic for making the FlashPoint SCCB
  Manager available as freely redistributable source code.

*/

#ifndef _BUSLOGIC_H
#define _BUSLOGIC_H


#ifndef PACKED
#define PACKED
#endif

/*
  Define the maximum number of BusLogic Host Adapters supported by this driver.
*/

#define BLOGIC_MAX_ADAPTERS


/*
  Define the maximum number of Target Devices supported by this driver.
*/

#define BLOGIC_MAXDEV


/*
  Define the maximum number of Scatter/Gather Segments used by this driver.
  For optimal performance, it is important that this limit be at least as
  large as the largest single request generated by the I/O Subsystem.
*/

#define BLOGIC_SG_LIMIT


/*
  Define the maximum, maximum automatic, minimum automatic, and default Queue
  Depth to allow for Target Devices depending on whether or not they support
  Tagged Queuing and whether or not ISA Bounce Buffers are required.
*/

#define BLOGIC_MAX_TAG_DEPTH
#define BLOGIC_MAX_AUTO_TAG_DEPTH
#define BLOGIC_MIN_AUTO_TAG_DEPTH
#define BLOGIC_TAG_DEPTH_BB
#define BLOGIC_UNTAG_DEPTH
#define BLOGIC_UNTAG_DEPTH_BB


/*
  Define the default amount of time in seconds to wait between a Host Adapter
  Hard Reset which initiates a SCSI Bus Reset and issuing any SCSI commands.
  Some SCSI devices get confused if they receive SCSI commands too soon after
  a SCSI Bus Reset.
*/

#define BLOGIC_BUS_SETTLE_TIME


/*
  Define the maximum number of Mailboxes that should be used for MultiMaster
  Host Adapters.  This number is chosen to be larger than the maximum Host
  Adapter Queue Depth and small enough so that the Host Adapter structure
  does not cross an allocation block size boundary.
*/

#define BLOGIC_MAX_MAILBOX


/*
  Define the number of CCBs that should be allocated as a group to optimize
  Kernel memory allocation.
*/

#define BLOGIC_CCB_GRP_ALLOCSIZE


/*
  Define the Host Adapter Line and Message Buffer Sizes.
*/

#define BLOGIC_LINEBUF_SIZE
#define BLOGIC_MSGBUF_SIZE


/*
  Define the Driver Message Levels.
*/

enum blogic_msglevel {};

static char *blogic_msglevelmap[] =;


/*
  Define Driver Message macros.
*/

#define blogic_announce(format, args...)

#define blogic_info(format, args...)

#define blogic_notice(format, args...)

#define blogic_warn(format, args...)

#define blogic_err(format, args...)


/*
  Define the types of BusLogic Host Adapters that are supported and the number
  of I/O Addresses required by each type.
*/

enum blogic_adapter_type {} PACKED;

#define BLOGIC_MULTIMASTER_ADDR_COUNT
#define BLOGIC_FLASHPOINT_ADDR_COUNT

static int blogic_adapter_addr_count[3] =;


/*
  Define macros for testing the Host Adapter Type.
*/

#ifdef CONFIG_SCSI_FLASHPOINT

#define blogic_multimaster_type(adapter)

#define blogic_flashpoint_type(adapter)

#else

#define blogic_multimaster_type
#define blogic_flashpoint_type

#endif


/*
  Define the possible Host Adapter Bus Types.
*/

enum blogic_adapter_bus_type {} PACKED;

static char *blogic_adapter_busnames[] =;

static enum blogic_adapter_bus_type blogic_adater_bus_types[] =;

/*
  Define the possible Host Adapter BIOS Disk Geometry Translations.
*/

enum blogic_bios_diskgeometry {} PACKED;


/*
  Define a 10^18 Statistics Byte Counter data type.
*/

struct blogic_byte_count {};


/*
  Define the structure for I/O Address and Bus Probing Information.
*/

struct blogic_probeinfo {};

/*
  Define the Probe Options.
*/

struct blogic_probe_options {};

/*
  Define the Global Options.
*/

struct blogic_global_options {};

/*
  Define the BusLogic SCSI Host Adapter I/O Register Offsets.
*/

#define BLOGIC_CNTRL_REG
#define BLOGIC_STATUS_REG
#define BLOGIC_CMD_PARM_REG
#define BLOGIC_DATAIN_REG
#define BLOGIC_INT_REG
#define BLOGIC_GEOMETRY_REG

/*
  Define the structure of the write-only Control Register.
*/

blogic_cntrl_reg;

/*
  Define the structure of the read-only Status Register.
*/

blogic_stat_reg;

/*
  Define the structure of the read-only Interrupt Register.
*/

blogic_int_reg;

/*
  Define the structure of the read-only Geometry Register.
*/

blogic_geo_reg;

/*
  Define the BusLogic SCSI Host Adapter Command Register Operation Codes.
*/

enum blogic_opcode {};

/*
  Define the Inquire Board ID reply structure.
*/

struct blogic_board_id {};

/*
  Define the Inquire Configuration reply structure.
*/

struct blogic_config {};

/*
  Define the Inquire Setup Information reply structure.
*/

struct blogic_syncval {};

struct blogic_setup_info {};

/*
  Define the Initialize Extended Mailbox request structure.
*/

struct blogic_extmbox_req {} PACKED;


/*
  Define the Inquire PCI Host Adapter Information reply type.  The ISA
  Compatible I/O Port values are defined here and are also used with
  the Modify I/O Address command.
*/

enum blogic_isa_ioport {} PACKED;

struct blogic_adapter_info {};

/*
  Define the Inquire Extended Setup Information reply structure.
*/

struct blogic_ext_setup {} PACKED;

/*
  Define the Enable Strict Round Robin Mode request type.
*/

enum blogic_rr_req {} PACKED;


/*
  Define the Fetch Host Adapter Local RAM request type.
*/

#define BLOGIC_BIOS_BASE
#define BLOGIC_AUTOSCSI_BASE

struct blogic_fetch_localram {};

/*
  Define the Host Adapter Local RAM AutoSCSI structure.
*/

struct blogic_autoscsi {} PACKED;

/*
  Define the Host Adapter Local RAM Auto SCSI Byte 45 structure.
*/

struct blogic_autoscsi_byte45 {};

/*
  Define the Host Adapter Local RAM BIOS Drive Map Byte structure.
*/

#define BLOGIC_BIOS_DRVMAP

struct blogic_bios_drvmap {};

/*
  Define the Set CCB Format request type.  Extended LUN Format CCBs are
  necessary to support more than 8 Logical Units per Target Device.
*/

enum blogic_setccb_fmt {} PACKED;

/*
  Define the Outgoing Mailbox Action Codes.
*/

enum blogic_action {} PACKED;


/*
  Define the Incoming Mailbox Completion Codes.  The MultiMaster Firmware
  only uses codes 0 - 4.  The FlashPoint SCCB Manager has no mailboxes, so
  completion codes are stored in the CCB; it only uses codes 1, 2, 4, and 5.
*/

enum blogic_cmplt_code {} PACKED;

/*
  Define the Command Control Block (CCB) Opcodes.
*/

enum blogic_ccb_opcode {} PACKED;


/*
  Define the CCB Data Direction Codes.
*/

enum blogic_datadir {};


/*
  Define the Host Adapter Status Codes.  The MultiMaster Firmware does not
  return status code 0x0C; it uses 0x12 for both overruns and underruns.
*/

enum blogic_adapter_status {} PACKED;


/*
  Define the SCSI Target Device Status Codes.
*/

enum blogic_tgt_status {} PACKED;

/*
  Define the Queue Tag Codes.
*/

enum blogic_queuetag {};

/*
  Define the SCSI Command Descriptor Block (CDB).
*/

#define BLOGIC_CDB_MAXLEN


/*
  Define the Scatter/Gather Segment structure required by the MultiMaster
  Firmware Interface and the FlashPoint SCCB Manager.
*/

struct blogic_sg_seg {};

/*
  Define the Driver CCB Status Codes.
*/

enum blogic_ccb_status {} PACKED;


/*
  Define the 32 Bit Mode Command Control Block (CCB) structure.  The first 40
  bytes are defined by and common to both the MultiMaster Firmware and the
  FlashPoint SCCB Manager.  The next 60 bytes are defined by the FlashPoint
  SCCB Manager.  The remaining components are defined by the Linux BusLogic
  Driver.  Extended LUN Format CCBs differ from Legacy LUN Format 32 Bit Mode
  CCBs only in having the TagEnable and QueueTag fields moved from byte 17 to
  byte 1, and the Logical Unit field in byte 17 expanded to 6 bits.  In theory,
  Extended LUN Format CCBs can support up to 64 Logical Units, but in practice
  many devices will respond improperly to Logical Units between 32 and 63, and
  the SCSI-2 specification defines Bit 5 as LUNTAR.  Extended LUN Format CCBs
  are used by recent versions of the MultiMaster Firmware, as well as by the
  FlashPoint SCCB Manager; the FlashPoint SCCB Manager only supports 32 Logical
  Units.  Since 64 Logical Units are unlikely to be needed in practice, and
  since they are problematic for the above reasons, and since limiting them to
  5 bits simplifies the CCB structure definition, this driver only supports
  32 Logical Units per Target Device.
*/

struct blogic_ccb {};

/*
  Define the 32 Bit Mode Outgoing Mailbox structure.
*/

struct blogic_outbox {};

/*
  Define the 32 Bit Mode Incoming Mailbox structure.
*/

struct blogic_inbox {};


/*
  Define the BusLogic Driver Options structure.
*/

struct blogic_drvr_options {};

/*
  Define the Host Adapter Target Flags structure.
*/

struct blogic_tgt_flags {};

/*
  Define the Host Adapter Target Statistics structure.
*/

#define BLOGIC_SZ_BUCKETS

struct blogic_tgt_stats {};

/*
  Define the FlashPoint Card Handle data type.
*/

#define FPOINT_BADCARD_HANDLE


/*
  Define the FlashPoint Information structure.  This structure is defined
  by the FlashPoint SCCB Manager.
*/

struct fpoint_info {};

/*
  Define the BusLogic Driver Host Adapter structure.
*/

struct blogic_adapter {};

/*
  Define a structure for the BIOS Disk Parameters.
*/

struct bios_diskparam {};

/*
  Define a structure for the SCSI Inquiry command results.
*/

struct scsi_inquiry {};


/*
  Define functions to provide an abstraction for reading and writing the
  Host Adapter I/O Registers.
*/

static inline void blogic_busreset(struct blogic_adapter *adapter)
{}

static inline void blogic_intreset(struct blogic_adapter *adapter)
{}

static inline void blogic_softreset(struct blogic_adapter *adapter)
{}

static inline void blogic_hardreset(struct blogic_adapter *adapter)
{}

static inline unsigned char blogic_rdstatus(struct blogic_adapter *adapter)
{}

static inline void blogic_setcmdparam(struct blogic_adapter *adapter,
					unsigned char value)
{}

static inline unsigned char blogic_rddatain(struct blogic_adapter *adapter)
{}

static inline unsigned char blogic_rdint(struct blogic_adapter *adapter)
{}

static inline unsigned char blogic_rdgeom(struct blogic_adapter *adapter)
{}

/*
  blogic_execmbox issues an Execute Mailbox Command, which
  notifies the Host Adapter that an entry has been made in an Outgoing
  Mailbox.
*/

static inline void blogic_execmbox(struct blogic_adapter *adapter)
{}

/*
  blogic_delay waits for Seconds to elapse.
*/

static inline void blogic_delay(int seconds)
{}

/*
  virt_to_32bit_virt maps between Kernel Virtual Addresses and
  32 bit Kernel Virtual Addresses.  This avoids compilation warnings
  on 64 bit architectures.
*/

static inline u32 virt_to_32bit_virt(void *virt_addr)
{}

/*
  blogic_inc_count increments counter by 1, stopping at
  65535 rather than wrapping around to 0.
*/

static inline void blogic_inc_count(unsigned short *count)
{}

/*
  blogic_addcount increments Byte Counter by Amount.
*/

static inline void blogic_addcount(struct blogic_byte_count *bytecount,
					unsigned int amount)
{}

/*
  blogic_incszbucket increments the Bucket for Amount.
*/

static inline void blogic_incszbucket(unsigned int *cmdsz_buckets,
					unsigned int amount)
{}

/*
  Define the version number of the FlashPoint Firmware (SCCB Manager).
*/

#define FLASHPOINT_FW_VER

/*
  Define the possible return values from FlashPoint_HandleInterrupt.
*/

#define FPOINT_NORMAL_INT
#define FPOINT_INTERN_ERR
#define FPOINT_EXT_RESET

/*
  Define prototypes for the forward referenced BusLogic Driver
  Internal Functions.
*/

static const char *blogic_drvr_info(struct Scsi_Host *);
static int blogic_qcmd(struct Scsi_Host *h, struct scsi_cmnd *);
static int blogic_diskparam(struct scsi_device *, struct block_device *, sector_t, int *);
static int blogic_slaveconfig(struct scsi_device *);
static void blogic_qcompleted_ccb(struct blogic_ccb *);
static irqreturn_t blogic_inthandler(int, void *);
static int blogic_resetadapter(struct blogic_adapter *, bool hard_reset);
static void blogic_msg(enum blogic_msglevel, char *, struct blogic_adapter *, ...);
static int __init blogic_setup(char *);

#endif				/* _BUSLOGIC_H */