/* ps_soft_irq.h
 *
 * Soft Interrupt Handler Manifests
 *
 *
 * $Header: /smsa/bsd:include/dev/ps_soft_irq.h:bsd  1.6  $
 * $Source: /smsa/bsd:include/dev/ps_soft_irq.h: $
 *
 * Copyright (c) 1989 Acorn Computers Ltd., Cambridge, England
 */

#ifndef __dev_ps_soft_irq_h
#define __dev_ps_soft_irq_h

/*
 * The argument to soft_irq is a single word, partitioned as follows:
 * bits 00-01    Podule Number
 * bits 08-10    Logical Unit [where appropriate]
 * bits 12-14    Target Id    [where appropriate]
 * bits 24-31    Entry Code
 */

/*
 * the fields in the argument to soft_irq are obtained using
 * the masks and shifts defined below
 */

#define S_BASE                                (1<<31)
#define S_INC                                    (24)
#define S_SBIC_IDLE           (S_BASE + ( 1 << S_INC))
#define S_DMA_ATTENTION       (S_BASE + ( 2 << S_INC))
#define S_COMMAND_COMPLETE    (S_BASE + ( 3 << S_INC))
#define S_COMMAND_ISSUED      (S_BASE + ( 4 << S_INC))
#define S_COMMAND_RESTARTED   (S_BASE + ( 5 << S_INC))
#define S_DEVICE_ACTIVE       (S_BASE + ( 6 << S_INC))
#define S_DEVICE_INACTIVE     (S_BASE + ( 7 << S_INC))
#define S_KILL_COMMAND        (S_BASE + ( 8 << S_INC))
#define S_RETRY_COMMAND       (S_BASE + ( 9 << S_INC))

#define S_ID_MASK             0x00000003
#define S_TARGET_MASK         0x00000700
#define S_LUN_MASK            0x00007000
#define S_CODE_MASK           0xFF000000

#define S_ID_SHIFT                     0
#define S_TARGET_SHIFT                 8
#define S_LUN_SHIFT                   12

/* The Soft Interrupt Handler */
#define SOFT_ARGS                     32
extern void scsi_soft_irq( /* int code */ );
extern int  soft_arg[SOFT_ARGS];

/* bits 00..15 in the soft_irq state variable */
#define SF_SBIC_IDLE           (1<<0)
#define SF_IRQ_DISABLED        (1<<1)
#define SF_COMMAND_READY       (1<<2)
#define SF_COPY_PENDING        (1<<3)

/* bits 16..22 in the soft_irq state variable
 * One bit for each potential target, to indicate
 * that it has a startable command pending
 */

#define S_CMD_BIT             0x00010000

/* bits 28..30 in the soft_irq state variable
 * indicate which target has command ready
 */

#define SF_READY_SHIFT                   (28)
#define SF_READY_MASK     (7<<SF_READY_SHIFT)

/* bits 26..28 indicate which target last completed a command */
#define SF_DONE_SHIFT                    (25)
#define SF_DONE_MASK       (7<<SF_DONE_SHIFT)

#define MIN_SENSE                         (7)
#define MAX_SENSE                        (18)

#endif/*__dev_ps_soft_irq_h*/

/* EOF ps_soft_irq.h */
