162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * Instruction formats for the sequencer program downloaded to 362306a36Sopenharmony_ci * Aic7xxx SCSI host adapters 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright (c) 1997, 1998, 2000 Justin T. Gibbs. 662306a36Sopenharmony_ci * All rights reserved. 762306a36Sopenharmony_ci * 862306a36Sopenharmony_ci * Redistribution and use in source and binary forms, with or without 962306a36Sopenharmony_ci * modification, are permitted provided that the following conditions 1062306a36Sopenharmony_ci * are met: 1162306a36Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright 1262306a36Sopenharmony_ci * notice, this list of conditions, and the following disclaimer, 1362306a36Sopenharmony_ci * without modification. 1462306a36Sopenharmony_ci * 2. Redistributions in binary form must reproduce at minimum a disclaimer 1562306a36Sopenharmony_ci * substantially similar to the "NO WARRANTY" disclaimer below 1662306a36Sopenharmony_ci * ("Disclaimer") and any redistribution must be conditioned upon 1762306a36Sopenharmony_ci * including a substantially similar Disclaimer requirement for further 1862306a36Sopenharmony_ci * binary redistribution. 1962306a36Sopenharmony_ci * 3. Neither the names of the above-listed copyright holders nor the names 2062306a36Sopenharmony_ci * of any contributors may be used to endorse or promote products derived 2162306a36Sopenharmony_ci * from this software without specific prior written permission. 2262306a36Sopenharmony_ci * 2362306a36Sopenharmony_ci * Alternatively, this software may be distributed under the terms of the 2462306a36Sopenharmony_ci * GNU General Public License ("GPL") version 2 as published by the Free 2562306a36Sopenharmony_ci * Software Foundation. 2662306a36Sopenharmony_ci * 2762306a36Sopenharmony_ci * NO WARRANTY 2862306a36Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2962306a36Sopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 3062306a36Sopenharmony_ci * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 3162306a36Sopenharmony_ci * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 3262306a36Sopenharmony_ci * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3362306a36Sopenharmony_ci * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3462306a36Sopenharmony_ci * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3562306a36Sopenharmony_ci * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 3662306a36Sopenharmony_ci * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 3762306a36Sopenharmony_ci * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 3862306a36Sopenharmony_ci * POSSIBILITY OF SUCH DAMAGES. 3962306a36Sopenharmony_ci * 4062306a36Sopenharmony_ci * $Id: //depot/aic7xxx/aic7xxx/aicasm/aicasm_insformat.h#12 $ 4162306a36Sopenharmony_ci * 4262306a36Sopenharmony_ci * $FreeBSD$ 4362306a36Sopenharmony_ci */ 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ci#include <asm/byteorder.h> 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ci/* 8bit ALU logic operations */ 4862306a36Sopenharmony_cistruct ins_format1 { 4962306a36Sopenharmony_ci#ifdef __LITTLE_ENDIAN 5062306a36Sopenharmony_ci uint32_t immediate : 8, 5162306a36Sopenharmony_ci source : 9, 5262306a36Sopenharmony_ci destination : 9, 5362306a36Sopenharmony_ci ret : 1, 5462306a36Sopenharmony_ci opcode : 4, 5562306a36Sopenharmony_ci parity : 1; 5662306a36Sopenharmony_ci#else 5762306a36Sopenharmony_ci uint32_t parity : 1, 5862306a36Sopenharmony_ci opcode : 4, 5962306a36Sopenharmony_ci ret : 1, 6062306a36Sopenharmony_ci destination : 9, 6162306a36Sopenharmony_ci source : 9, 6262306a36Sopenharmony_ci immediate : 8; 6362306a36Sopenharmony_ci#endif 6462306a36Sopenharmony_ci}; 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ci/* 8bit ALU shift/rotate operations */ 6762306a36Sopenharmony_cistruct ins_format2 { 6862306a36Sopenharmony_ci#ifdef __LITTLE_ENDIAN 6962306a36Sopenharmony_ci uint32_t shift_control : 8, 7062306a36Sopenharmony_ci source : 9, 7162306a36Sopenharmony_ci destination : 9, 7262306a36Sopenharmony_ci ret : 1, 7362306a36Sopenharmony_ci opcode : 4, 7462306a36Sopenharmony_ci parity : 1; 7562306a36Sopenharmony_ci#else 7662306a36Sopenharmony_ci uint32_t parity : 1, 7762306a36Sopenharmony_ci opcode : 4, 7862306a36Sopenharmony_ci ret : 1, 7962306a36Sopenharmony_ci destination : 9, 8062306a36Sopenharmony_ci source : 9, 8162306a36Sopenharmony_ci shift_control : 8; 8262306a36Sopenharmony_ci#endif 8362306a36Sopenharmony_ci}; 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_ci/* 8bit branch control operations */ 8662306a36Sopenharmony_cistruct ins_format3 { 8762306a36Sopenharmony_ci#ifdef __LITTLE_ENDIAN 8862306a36Sopenharmony_ci uint32_t immediate : 8, 8962306a36Sopenharmony_ci source : 9, 9062306a36Sopenharmony_ci address : 10, 9162306a36Sopenharmony_ci opcode : 4, 9262306a36Sopenharmony_ci parity : 1; 9362306a36Sopenharmony_ci#else 9462306a36Sopenharmony_ci uint32_t parity : 1, 9562306a36Sopenharmony_ci opcode : 4, 9662306a36Sopenharmony_ci address : 10, 9762306a36Sopenharmony_ci source : 9, 9862306a36Sopenharmony_ci immediate : 8; 9962306a36Sopenharmony_ci#endif 10062306a36Sopenharmony_ci}; 10162306a36Sopenharmony_ci 10262306a36Sopenharmony_ci/* 16bit ALU logic operations */ 10362306a36Sopenharmony_cistruct ins_format4 { 10462306a36Sopenharmony_ci#ifdef __LITTLE_ENDIAN 10562306a36Sopenharmony_ci uint32_t opcode_ext : 8, 10662306a36Sopenharmony_ci source : 9, 10762306a36Sopenharmony_ci destination : 9, 10862306a36Sopenharmony_ci ret : 1, 10962306a36Sopenharmony_ci opcode : 4, 11062306a36Sopenharmony_ci parity : 1; 11162306a36Sopenharmony_ci#else 11262306a36Sopenharmony_ci uint32_t parity : 1, 11362306a36Sopenharmony_ci opcode : 4, 11462306a36Sopenharmony_ci ret : 1, 11562306a36Sopenharmony_ci destination : 9, 11662306a36Sopenharmony_ci source : 9, 11762306a36Sopenharmony_ci opcode_ext : 8; 11862306a36Sopenharmony_ci#endif 11962306a36Sopenharmony_ci}; 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_ci/* 16bit branch control operations */ 12262306a36Sopenharmony_cistruct ins_format5 { 12362306a36Sopenharmony_ci#ifdef __LITTLE_ENDIAN 12462306a36Sopenharmony_ci uint32_t opcode_ext : 8, 12562306a36Sopenharmony_ci source : 9, 12662306a36Sopenharmony_ci address : 10, 12762306a36Sopenharmony_ci opcode : 4, 12862306a36Sopenharmony_ci parity : 1; 12962306a36Sopenharmony_ci#else 13062306a36Sopenharmony_ci uint32_t parity : 1, 13162306a36Sopenharmony_ci opcode : 4, 13262306a36Sopenharmony_ci address : 10, 13362306a36Sopenharmony_ci source : 9, 13462306a36Sopenharmony_ci opcode_ext : 8; 13562306a36Sopenharmony_ci#endif 13662306a36Sopenharmony_ci}; 13762306a36Sopenharmony_ci 13862306a36Sopenharmony_ci/* Far branch operations */ 13962306a36Sopenharmony_cistruct ins_format6 { 14062306a36Sopenharmony_ci#ifdef __LITTLE_ENDIAN 14162306a36Sopenharmony_ci uint32_t page : 3, 14262306a36Sopenharmony_ci opcode_ext : 5, 14362306a36Sopenharmony_ci source : 9, 14462306a36Sopenharmony_ci address : 10, 14562306a36Sopenharmony_ci opcode : 4, 14662306a36Sopenharmony_ci parity : 1; 14762306a36Sopenharmony_ci#else 14862306a36Sopenharmony_ci uint32_t parity : 1, 14962306a36Sopenharmony_ci opcode : 4, 15062306a36Sopenharmony_ci address : 10, 15162306a36Sopenharmony_ci source : 9, 15262306a36Sopenharmony_ci opcode_ext : 5, 15362306a36Sopenharmony_ci page : 3; 15462306a36Sopenharmony_ci#endif 15562306a36Sopenharmony_ci}; 15662306a36Sopenharmony_ci 15762306a36Sopenharmony_ciunion ins_formats { 15862306a36Sopenharmony_ci struct ins_format1 format1; 15962306a36Sopenharmony_ci struct ins_format2 format2; 16062306a36Sopenharmony_ci struct ins_format3 format3; 16162306a36Sopenharmony_ci struct ins_format4 format4; 16262306a36Sopenharmony_ci struct ins_format5 format5; 16362306a36Sopenharmony_ci struct ins_format6 format6; 16462306a36Sopenharmony_ci uint8_t bytes[4]; 16562306a36Sopenharmony_ci uint32_t integer; 16662306a36Sopenharmony_ci}; 16762306a36Sopenharmony_cistruct instruction { 16862306a36Sopenharmony_ci union ins_formats format; 16962306a36Sopenharmony_ci u_int srcline; 17062306a36Sopenharmony_ci struct symbol *patch_label; 17162306a36Sopenharmony_ci STAILQ_ENTRY(instruction) links; 17262306a36Sopenharmony_ci}; 17362306a36Sopenharmony_ci 17462306a36Sopenharmony_ci#define AIC_OP_OR 0x0 17562306a36Sopenharmony_ci#define AIC_OP_AND 0x1 17662306a36Sopenharmony_ci#define AIC_OP_XOR 0x2 17762306a36Sopenharmony_ci#define AIC_OP_ADD 0x3 17862306a36Sopenharmony_ci#define AIC_OP_ADC 0x4 17962306a36Sopenharmony_ci#define AIC_OP_ROL 0x5 18062306a36Sopenharmony_ci#define AIC_OP_BMOV 0x6 18162306a36Sopenharmony_ci 18262306a36Sopenharmony_ci#define AIC_OP_MVI16 0x7 18362306a36Sopenharmony_ci 18462306a36Sopenharmony_ci#define AIC_OP_JMP 0x8 18562306a36Sopenharmony_ci#define AIC_OP_JC 0x9 18662306a36Sopenharmony_ci#define AIC_OP_JNC 0xa 18762306a36Sopenharmony_ci#define AIC_OP_CALL 0xb 18862306a36Sopenharmony_ci#define AIC_OP_JNE 0xc 18962306a36Sopenharmony_ci#define AIC_OP_JNZ 0xd 19062306a36Sopenharmony_ci#define AIC_OP_JE 0xe 19162306a36Sopenharmony_ci#define AIC_OP_JZ 0xf 19262306a36Sopenharmony_ci 19362306a36Sopenharmony_ci/* Pseudo Ops */ 19462306a36Sopenharmony_ci#define AIC_OP_SHL 0x10 19562306a36Sopenharmony_ci#define AIC_OP_SHR 0x20 19662306a36Sopenharmony_ci#define AIC_OP_ROR 0x30 19762306a36Sopenharmony_ci 19862306a36Sopenharmony_ci/* 16bit Ops. Low byte main opcode. High byte extended opcode. */ 19962306a36Sopenharmony_ci#define AIC_OP_OR16 0x8005 20062306a36Sopenharmony_ci#define AIC_OP_AND16 0x8105 20162306a36Sopenharmony_ci#define AIC_OP_XOR16 0x8205 20262306a36Sopenharmony_ci#define AIC_OP_ADD16 0x8305 20362306a36Sopenharmony_ci#define AIC_OP_ADC16 0x8405 20462306a36Sopenharmony_ci#define AIC_OP_JNE16 0x8805 20562306a36Sopenharmony_ci#define AIC_OP_JNZ16 0x8905 20662306a36Sopenharmony_ci#define AIC_OP_JE16 0x8C05 20762306a36Sopenharmony_ci#define AIC_OP_JZ16 0x8B05 20862306a36Sopenharmony_ci#define AIC_OP_JMP16 0x9005 20962306a36Sopenharmony_ci#define AIC_OP_JC16 0x9105 21062306a36Sopenharmony_ci#define AIC_OP_JNC16 0x9205 21162306a36Sopenharmony_ci#define AIC_OP_CALL16 0x9305 21262306a36Sopenharmony_ci 21362306a36Sopenharmony_ci/* Page extension is low three bits of second opcode byte. */ 21462306a36Sopenharmony_ci#define AIC_OP_JMPF 0xA005 21562306a36Sopenharmony_ci#define AIC_OP_CALLF 0xB005 21662306a36Sopenharmony_ci#define AIC_OP_JCF 0xC005 21762306a36Sopenharmony_ci#define AIC_OP_JNCF 0xD005 21862306a36Sopenharmony_ci#define AIC_OP_CMPXCHG 0xE005 219