/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Michael Lorenz.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* SX control registers */
#define SX_CONTROL_STATUS 0x00000000
#define SX_ERROR 0x00000004
#define SX_PAGE_BOUND_LOWER 0x00000008
#define SX_PAGE_BOUND_UPPER 0x0000000c
#define SX_PLANEMASK 0x00000010
#define SX_ROP_CONTROL 0x00000014 /* 8 bit ROP */
#define SX_IQ_OVERFLOW_COUNTER 0x00000018
#define SX_DIAGNOSTICS 0x0000001c
#define SX_INSTRUCTIONS 0x00000020
#define SX_ID 0x00000028
#define SX_R0_INIT 0x0000002c
#define SX_SOFTRESET 0x00000030
#define SX_SYNC 0x00000034 /* write will stall CPU until */
/* SX is idle */
/* write registers directly, only when processor is stopped */
#define SX_DIRECT_R0 0x00000100
#define SX_DIRECT_R1 0x00000104 /* and so on until R127 */
/* write registers via pseudo instructions */
#define SX_QUEUED_R0 0x00000300
#define SX_QUEUED_R1 0x00000304 /* and so on until R127 */
#define SX_QUEUED(r) (0x300 + ((r) << 2))
/* special purpose registers */
#define R_ZERO 0
#define R_SCAM 1
#define R_MASK 2 /* bitmask for SX_STORE_SELECT */
/*
* registers are repeated at 0x1000 with certain parts read only
* ( like the PAGE_BOUND registers ) which userland has no business writing to
*/
/* SX_CONTROL_STATUS */
#define SX_EE1 0x00000001 /* illegal instruction */
#define SX_EE2 0x00000002 /* page bound error */
#define SX_EE3 0x00000004 /* illegal memory access */
#define SX_EE4 0x00000008 /* illegal register access */
#define SX_EE5 0x00000010 /* alignment violation */
#define SX_EE6 0x00000020 /* illegal instruction queue write */
#define SX_EI 0x00000080 /* interrupt on error */
/*
* XXX
* the following bit definitions are from the SX manual. They're defined in a
* different way in SunOS's sxreg.h, the hardware seems to follow the latter.
*/
#if 0
#define SX_PB 0x00001000 /* enable page bound checking */
#define SX_WO 0x00002000 /* write occurred ( by SX ) */
#define SX_GO 0x00004000 /* start/stop the processor */
#define SX_MT 0x00008000 /* instruction queue is empty */
#endif
#define SX_PB 0x00000400 /* enable page bound checking */
#define SX_WO 0x00000800 /* write occurred ( by SX ) */
#define SX_GO 0x00001000 /* start/stop the processor */
#define SX_JB 0x00002000 /* Jammed/Busy specifies the type of events */
/* which increment the SX timer */
#define SX_MT 0x00004000 /* instruction queue is empty */
#define SX_BZ 0x00008000 /* Busy bit. When set it indicates that SX */
/* is processing an instruction or an */
/* instruction is pending in the Q */
#define SX_B0MOD 0x00010000 /* When set by SX it indicates that a write */
/* to bank zero of the SX registers (0-31) */
/* occurred */
#define SX_B1MOD 0x00020000 /* When set by SX it indicates that a write */
/* to bank 1 of the SX registers (32-63) */
/* occurred */
#define SX_B2MOD 0x00040000 /* When set by SX it indicates that a write */
/* to bank 2 of the SX registers (64-95) */
/* occurred */
#define SX_B3MOD 0x00080000 /* When set by SX it indicates that a write */
/* to bank 3 of the SX registers (96-127) */
/* occurred */
#define SX_MULTIPLY (0x0 << 21) /* normal multiplication */
#define SX_DOT (0x1 << 21) /* dot product of A and B */
#define SX_SAXP (0x2 << 21) /* A * SCAM + B */