1*c880b8ffSrin /* $NetBSD: instr.h,v 1.12 2022/08/30 11:05:59 rin Exp $ */ 218b2f7e6Ssimonb 318b2f7e6Ssimonb /* 418b2f7e6Ssimonb * Copyright (c) 1992, 1993 518b2f7e6Ssimonb * The Regents of the University of California. All rights reserved. 618b2f7e6Ssimonb * 718b2f7e6Ssimonb * This software was developed by the Computer Systems Engineering group 818b2f7e6Ssimonb * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 918b2f7e6Ssimonb * contributed to Berkeley. 1018b2f7e6Ssimonb * 1118b2f7e6Ssimonb * All advertising materials mentioning features or use of this software 1218b2f7e6Ssimonb * must display the following acknowledgement: 1318b2f7e6Ssimonb * This product includes software developed by the University of 1418b2f7e6Ssimonb * California, Lawrence Berkeley Laboratory. 1518b2f7e6Ssimonb * 1618b2f7e6Ssimonb * Redistribution and use in source and binary forms, with or without 1718b2f7e6Ssimonb * modification, are permitted provided that the following conditions 1818b2f7e6Ssimonb * are met: 1918b2f7e6Ssimonb * 1. Redistributions of source code must retain the above copyright 2018b2f7e6Ssimonb * notice, this list of conditions and the following disclaimer. 2118b2f7e6Ssimonb * 2. Redistributions in binary form must reproduce the above copyright 2218b2f7e6Ssimonb * notice, this list of conditions and the following disclaimer in the 2318b2f7e6Ssimonb * documentation and/or other materials provided with the distribution. 24aad01611Sagc * 3. Neither the name of the University nor the names of its contributors 2518b2f7e6Ssimonb * may be used to endorse or promote products derived from this software 2618b2f7e6Ssimonb * without specific prior written permission. 2718b2f7e6Ssimonb * 2818b2f7e6Ssimonb * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2918b2f7e6Ssimonb * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 3018b2f7e6Ssimonb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 3118b2f7e6Ssimonb * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 3218b2f7e6Ssimonb * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3318b2f7e6Ssimonb * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3418b2f7e6Ssimonb * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3518b2f7e6Ssimonb * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3618b2f7e6Ssimonb * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3718b2f7e6Ssimonb * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3818b2f7e6Ssimonb * SUCH DAMAGE. 3918b2f7e6Ssimonb * 4018b2f7e6Ssimonb * @(#)instr.h 8.1 (Berkeley) 6/11/93 4118b2f7e6Ssimonb */ 4218b2f7e6Ssimonb 43b8ea2c8cSmatt #ifndef _POWERPC_INSTR_H_ 44b8ea2c8cSmatt #define _POWERPC_INSTR_H_ 45b8ea2c8cSmatt 4618b2f7e6Ssimonb /* 4718b2f7e6Ssimonb * An instruction. 4818b2f7e6Ssimonb */ 4918b2f7e6Ssimonb union instr { 5018b2f7e6Ssimonb int i_int; /* as a whole */ 5118b2f7e6Ssimonb 5218b2f7e6Ssimonb 5318b2f7e6Ssimonb /* 5418b2f7e6Ssimonb * Any instruction type. 5518b2f7e6Ssimonb */ 5618b2f7e6Ssimonb struct { 5718b2f7e6Ssimonb u_int i_opcd:6; /* first-level decode */ 5818b2f7e6Ssimonb u_int :25; 5918b2f7e6Ssimonb u_int i_rc:1; 6018b2f7e6Ssimonb } i_any; 6118b2f7e6Ssimonb 6218b2f7e6Ssimonb /* 6318b2f7e6Ssimonb * Format A 6418b2f7e6Ssimonb */ 6518b2f7e6Ssimonb struct { 6618b2f7e6Ssimonb u_int i_opcd:6; 6718b2f7e6Ssimonb u_int i_frt:5; 6818b2f7e6Ssimonb u_int i_fra:5; 6918b2f7e6Ssimonb u_int i_frb:5; 7018b2f7e6Ssimonb u_int i_frc:5; 7118b2f7e6Ssimonb u_int i_xo:5; 7218b2f7e6Ssimonb u_int i_rc:1; 7318b2f7e6Ssimonb } i_a; 7418b2f7e6Ssimonb 7518b2f7e6Ssimonb /* 7618b2f7e6Ssimonb * Format B 7718b2f7e6Ssimonb */ 7818b2f7e6Ssimonb struct { 7918b2f7e6Ssimonb u_int i_opcd:6; 80b8ea2c8cSmatt u_int i_bo:5; 81b8ea2c8cSmatt u_int i_bi:5; 8218b2f7e6Ssimonb int i_bd:14; 83b8ea2c8cSmatt u_int i_aa:1; 84b8ea2c8cSmatt u_int i_lk:1; 8518b2f7e6Ssimonb } i_b; 8618b2f7e6Ssimonb 8718b2f7e6Ssimonb /* 8818b2f7e6Ssimonb * Format D 8918b2f7e6Ssimonb */ 9018b2f7e6Ssimonb struct { 9118b2f7e6Ssimonb u_int i_opcd:6; 9218b2f7e6Ssimonb u_int i_rs:5; 9318b2f7e6Ssimonb u_int i_ra:5; 9418b2f7e6Ssimonb int i_d:16; 9518b2f7e6Ssimonb } i_d; 9618b2f7e6Ssimonb 9718b2f7e6Ssimonb /* 9818b2f7e6Ssimonb * Format DE 9918b2f7e6Ssimonb */ 10018b2f7e6Ssimonb struct { 10118b2f7e6Ssimonb u_int i_opcd:6; 10218b2f7e6Ssimonb u_int i_rs:5; 10318b2f7e6Ssimonb u_int i_ra:5; 10418b2f7e6Ssimonb int i_d:12; 10518b2f7e6Ssimonb u_int i_xo:4; 10618b2f7e6Ssimonb } i_de; 10718b2f7e6Ssimonb 10818b2f7e6Ssimonb /* 10918b2f7e6Ssimonb * Format I 11018b2f7e6Ssimonb */ 11118b2f7e6Ssimonb struct { 11218b2f7e6Ssimonb u_int i_opcd:6; 11318b2f7e6Ssimonb int i_li:24; 11418b2f7e6Ssimonb int i_aa:1; 11518b2f7e6Ssimonb int i_lk:1; 11618b2f7e6Ssimonb } i_i; 11718b2f7e6Ssimonb 11818b2f7e6Ssimonb /* 11918b2f7e6Ssimonb * Format M 12018b2f7e6Ssimonb */ 12118b2f7e6Ssimonb struct { 12218b2f7e6Ssimonb u_int i_opcd:6; 12318b2f7e6Ssimonb u_int i_rs:5; 12418b2f7e6Ssimonb u_int i_ra:5; 12518b2f7e6Ssimonb u_int i_rb:5; 12618b2f7e6Ssimonb int i_mb:5; 12718b2f7e6Ssimonb int i_me:5; 12818b2f7e6Ssimonb u_int i_rc:1; 12918b2f7e6Ssimonb } i_m; 13018b2f7e6Ssimonb 13118b2f7e6Ssimonb /* 13218b2f7e6Ssimonb * Format MD 13318b2f7e6Ssimonb */ 13418b2f7e6Ssimonb struct { 13518b2f7e6Ssimonb u_int i_opcd:6; 13618b2f7e6Ssimonb u_int i_rs:5; 13718b2f7e6Ssimonb u_int i_ra:5; 13818b2f7e6Ssimonb int i_sh1_5:5; 13918b2f7e6Ssimonb int i_mb:6; 14018b2f7e6Ssimonb u_int i_xo:3; 141fe645b72Srin int i_sh0:1; 14218b2f7e6Ssimonb u_int i_rc:1; 14318b2f7e6Ssimonb } i_md; 14418b2f7e6Ssimonb 14518b2f7e6Ssimonb /* 14618b2f7e6Ssimonb * Format MDS 14718b2f7e6Ssimonb */ 14818b2f7e6Ssimonb struct { 14918b2f7e6Ssimonb u_int i_opcd:6; 15018b2f7e6Ssimonb u_int i_rs:5; 15118b2f7e6Ssimonb u_int i_ra:5; 15218b2f7e6Ssimonb u_int i_rb:5; 15318b2f7e6Ssimonb int i_mb:6; 15418b2f7e6Ssimonb u_int i_xo:4; 15518b2f7e6Ssimonb u_int i_rc:1; 15618b2f7e6Ssimonb } i_mds; 15718b2f7e6Ssimonb 15818b2f7e6Ssimonb 15918b2f7e6Ssimonb /* 16018b2f7e6Ssimonb * Format S 16118b2f7e6Ssimonb */ 16218b2f7e6Ssimonb struct { 16318b2f7e6Ssimonb u_int i_opcd:6; 16418b2f7e6Ssimonb int :24; 16518b2f7e6Ssimonb int i_i:1; 16618b2f7e6Ssimonb int :1; 16718b2f7e6Ssimonb } i_s; 16818b2f7e6Ssimonb 16918b2f7e6Ssimonb /* 17018b2f7e6Ssimonb * Format X 17118b2f7e6Ssimonb */ 17218b2f7e6Ssimonb struct { 17318b2f7e6Ssimonb u_int i_opcd:6; 17418b2f7e6Ssimonb u_int i_rs:5; 17518b2f7e6Ssimonb u_int i_ra:5; 17618b2f7e6Ssimonb u_int i_rb:5; 17718b2f7e6Ssimonb u_int i_xo:10; 17818b2f7e6Ssimonb u_int i_rc:1; 17918b2f7e6Ssimonb } i_x; 18018b2f7e6Ssimonb 18118b2f7e6Ssimonb /* 18218b2f7e6Ssimonb * Format XFL 18318b2f7e6Ssimonb */ 18418b2f7e6Ssimonb struct { 18518b2f7e6Ssimonb u_int i_opcd:6; 18618b2f7e6Ssimonb int :1; 18718b2f7e6Ssimonb int i_flm:8; 18818b2f7e6Ssimonb int :1; 18918b2f7e6Ssimonb int i_frb:5; 19018b2f7e6Ssimonb u_int i_xo:10; 19118b2f7e6Ssimonb int :1; 19218b2f7e6Ssimonb } i_xfl; 19318b2f7e6Ssimonb 19418b2f7e6Ssimonb /* 19518b2f7e6Ssimonb * Format XFX 19618b2f7e6Ssimonb */ 19718b2f7e6Ssimonb struct { 19818b2f7e6Ssimonb u_int i_opcd:6; 19918b2f7e6Ssimonb int i_dcrn:10; 20018b2f7e6Ssimonb u_int i_xo:10; 20118b2f7e6Ssimonb int :1; 20218b2f7e6Ssimonb } i_xfx; 20318b2f7e6Ssimonb 20418b2f7e6Ssimonb /* 20518b2f7e6Ssimonb * Format XL 20618b2f7e6Ssimonb */ 20718b2f7e6Ssimonb struct { 20818b2f7e6Ssimonb u_int i_opcd:6; 20918b2f7e6Ssimonb int i_bt:5; 21018b2f7e6Ssimonb int i_ba:5; 21118b2f7e6Ssimonb int i_bb:5; 21218b2f7e6Ssimonb u_int i_xo:10; 21318b2f7e6Ssimonb int i_lk:1; 21418b2f7e6Ssimonb } i_xl; 21518b2f7e6Ssimonb 21618b2f7e6Ssimonb /* 21718b2f7e6Ssimonb * Format XS 21818b2f7e6Ssimonb */ 21918b2f7e6Ssimonb struct { 22018b2f7e6Ssimonb u_int i_opcd:6; 22118b2f7e6Ssimonb u_int i_rs:5; 22218b2f7e6Ssimonb u_int i_ra:5; 22318b2f7e6Ssimonb int i_sh0_4:5; 22418b2f7e6Ssimonb u_int i_xo:9; 22518b2f7e6Ssimonb int i_sh5:1; 22618b2f7e6Ssimonb u_int i_rc:1; 22718b2f7e6Ssimonb } i_xs; 22818b2f7e6Ssimonb 22918b2f7e6Ssimonb }; 23018b2f7e6Ssimonb 23118b2f7e6Ssimonb #define i_rt i_rs 23218b2f7e6Ssimonb 23318b2f7e6Ssimonb /* 23418b2f7e6Ssimonb * Primary opcode numbers: 23518b2f7e6Ssimonb */ 23618b2f7e6Ssimonb 23718b2f7e6Ssimonb #define OPC_TDI 0x02 23818b2f7e6Ssimonb #define OPC_TWI 0x03 23918b2f7e6Ssimonb #define OPC_MULLI 0x07 24018b2f7e6Ssimonb #define OPC_SUBFIC 0x08 24118b2f7e6Ssimonb #define OPC_BCE 0x09 24218b2f7e6Ssimonb #define OPC_CMPLI 0x0a 24318b2f7e6Ssimonb #define OPC_CMPI 0x0b 24418b2f7e6Ssimonb #define OPC_ADDIC 0x0c 24518b2f7e6Ssimonb #define OPC_ADDIC_DOT 0x0d 24618b2f7e6Ssimonb #define OPC_ADDI 0x0e 24718b2f7e6Ssimonb #define OPC_ADDIS 0x0f 24818b2f7e6Ssimonb #define OPC_BC 0x10 24918b2f7e6Ssimonb #define OPC_SC 0x11 25018b2f7e6Ssimonb #define OPC_B 0x12 25118b2f7e6Ssimonb #define OPC_branch_19 0x13 25218b2f7e6Ssimonb #define OPC_RLWIMI 0x14 25318b2f7e6Ssimonb #define OPC_RLWINM 0x15 25418b2f7e6Ssimonb #define OPC_BE 0x16 25518b2f7e6Ssimonb #define OPC_RLWNM 0x17 25618b2f7e6Ssimonb #define OPC_ORI 0x18 25718b2f7e6Ssimonb #define OPC_ORIS 0x19 25818b2f7e6Ssimonb #define OPC_XORI 0x1a 25918b2f7e6Ssimonb #define OPC_XORIS 0x1b 26018b2f7e6Ssimonb #define OPC_ANDI 0x1c 26118b2f7e6Ssimonb #define OPC_ANDIS 0x1d 26218b2f7e6Ssimonb #define OPC_dwe_rot_30 0x1e 26318b2f7e6Ssimonb #define OPC_integer_31 0x1f 26418b2f7e6Ssimonb #define OPC_LWZ 0x20 26518b2f7e6Ssimonb #define OPC_LWZU 0x21 26618b2f7e6Ssimonb #define OPC_LBZ 0x22 26718b2f7e6Ssimonb #define OPC_LBZU 0x23 26818b2f7e6Ssimonb #define OPC_STW 0x24 26918b2f7e6Ssimonb #define OPC_STWU 0x25 27018b2f7e6Ssimonb #define OPC_STB 0x26 27118b2f7e6Ssimonb #define OPC_STBU 0x27 27218b2f7e6Ssimonb #define OPC_LHZ 0x28 27318b2f7e6Ssimonb #define OPC_LHZU 0x29 27418b2f7e6Ssimonb #define OPC_LHA 0x2a 27518b2f7e6Ssimonb #define OPC_LHAU 0x2b 27618b2f7e6Ssimonb #define OPC_STH 0x2c 27718b2f7e6Ssimonb #define OPC_STHU 0x2d 27818b2f7e6Ssimonb #define OPC_LMW 0x2e 27918b2f7e6Ssimonb #define OPC_STMW 0x2f 28018b2f7e6Ssimonb #define OPC_LFS 0x30 28118b2f7e6Ssimonb #define OPC_LFSU 0x31 28218b2f7e6Ssimonb #define OPC_LFD 0x32 28318b2f7e6Ssimonb #define OPC_LFDU 0x33 28418b2f7e6Ssimonb #define OPC_STFS 0x34 28518b2f7e6Ssimonb #define OPC_STFSU 0x35 28618b2f7e6Ssimonb #define OPC_STFD 0x36 28718b2f7e6Ssimonb #define OPC_STFDU 0x37 28818b2f7e6Ssimonb #define OPC_load_st_58 0x3a 28918b2f7e6Ssimonb #define OPC_sp_fp_59 0x3b 29018b2f7e6Ssimonb #define OPC_load_st_62 0x3e 29118b2f7e6Ssimonb #define OPC_dp_fp_63 0x3f 29218b2f7e6Ssimonb 29318b2f7e6Ssimonb /* 29418b2f7e6Ssimonb * Opcode 31 sub-types (FP only) 29518b2f7e6Ssimonb */ 29618b2f7e6Ssimonb #define OPC31_TW 0x004 29718b2f7e6Ssimonb #define OPC31_LFSX 0x217 29818b2f7e6Ssimonb #define OPC31_LFSUX 0x237 29918b2f7e6Ssimonb #define OPC31_LFDX 0x257 30018b2f7e6Ssimonb #define OPC31_LFDUX 0x277 30118b2f7e6Ssimonb #define OPC31_STFSX 0x297 30218b2f7e6Ssimonb #define OPC31_STFSUX 0x2b7 30318b2f7e6Ssimonb #define OPC31_STFDX 0x2d7 30418b2f7e6Ssimonb #define OPC31_STFDUX 0x2f7 30518b2f7e6Ssimonb #define OPC31_STFIWX 0x3d7 30618b2f7e6Ssimonb 30718b2f7e6Ssimonb /* Mask for all valid indexed FP load/store ops (except stfiwx) */ 30818b2f7e6Ssimonb #define OPC31_FPMASK 0x31f 30918b2f7e6Ssimonb #define OPC31_FPOP 0x217 31018b2f7e6Ssimonb 311b8ea2c8cSmatt /* m[ft]spr are also opcode 31; ra/rb encode the spr */ 312b8ea2c8cSmatt #define OPC31_MFSPR 0x153 313b8ea2c8cSmatt #define OPC31_MTSPR 0x1d3 314b8ea2c8cSmatt 31518b2f7e6Ssimonb /* 316e42cde72Smatt * Opcode 31 sub-types (integer only) 317e42cde72Smatt */ 318e42cde72Smatt #define OPC31_OR 0x1bc 319e42cde72Smatt 320e42cde72Smatt /* 321b761bad7Srin * Opcode 31 sub-types (load/store multiple bytes) 322b761bad7Srin */ 323b761bad7Srin #define OPC31_LWZX 0x017 324b761bad7Srin #define OPC31_LWZUX 0x037 325b761bad7Srin #define OPC31_STWX 0x097 326b761bad7Srin #define OPC31_STWUX 0x0b7 327b761bad7Srin #define OPC31_LHZX 0x117 328b761bad7Srin #define OPC31_LHZUX 0x137 329b761bad7Srin #define OPC31_LHAX 0x157 330b761bad7Srin #define OPC31_LHAUX 0x177 331b761bad7Srin #define OPC31_STHX 0x197 332b761bad7Srin #define OPC31_STHUX 0x1b7 333b761bad7Srin #define OPC31_LWBRX 0x216 334b761bad7Srin #define OPC31_STWBRX 0x296 335b761bad7Srin #define OPC31_LHBRX 0x316 336b761bad7Srin #define OPC31_STHBRX 0x396 337b761bad7Srin 338b761bad7Srin /* 33918b2f7e6Ssimonb * Opcode 59 sub-types: 34018b2f7e6Ssimonb */ 34118b2f7e6Ssimonb 34218b2f7e6Ssimonb #define OPC59_FDIVS 0x12 34318b2f7e6Ssimonb #define OPC59_FSUBS 0x14 34418b2f7e6Ssimonb #define OPC59_FADDS 0x15 34518b2f7e6Ssimonb #define OPC59_FSQRTS 0x16 34618b2f7e6Ssimonb #define OPC59_FRES 0x18 34718b2f7e6Ssimonb #define OPC59_FMULS 0x19 34818b2f7e6Ssimonb #define OPC59_FMSUBS 0x1c 34918b2f7e6Ssimonb #define OPC59_FMADDS 0x1d 35018b2f7e6Ssimonb #define OPC59_FNMSUBS 0x1e 35118b2f7e6Ssimonb #define OPC59_FNMADDS 0x1f 35218b2f7e6Ssimonb 35318b2f7e6Ssimonb /* 35418b2f7e6Ssimonb * Opcode 62 sub-types: 35518b2f7e6Ssimonb */ 35618b2f7e6Ssimonb #define OPC62_LDE 0x0 35718b2f7e6Ssimonb #define OPC62_LDEU 0x1 35818b2f7e6Ssimonb #define OPC62_LFSE 0x4 35918b2f7e6Ssimonb #define OPC62_LFSEU 0x5 36018b2f7e6Ssimonb #define OPC62_LFDE 0x6 36118b2f7e6Ssimonb #define OPC62_LFDEU 0x7 36218b2f7e6Ssimonb #define OPC62_STDE 0x8 36318b2f7e6Ssimonb #define OPC62_STDEU 0x9 36418b2f7e6Ssimonb #define OPC62_STFSE 0xc 36518b2f7e6Ssimonb #define OPC62_STFSEU 0xd 36618b2f7e6Ssimonb #define OPC62_STFDE 0xe 36718b2f7e6Ssimonb #define OPC62_STFDEU 0xf 36818b2f7e6Ssimonb 36918b2f7e6Ssimonb /* 37018b2f7e6Ssimonb * Opcode 63 sub-types: 37118b2f7e6Ssimonb * 37218b2f7e6Ssimonb * (The first group are masks....) 37318b2f7e6Ssimonb */ 37418b2f7e6Ssimonb 37518b2f7e6Ssimonb #define OPC63M_MASK 0x10 37618b2f7e6Ssimonb #define OPC63M_FDIV 0x12 37718b2f7e6Ssimonb #define OPC63M_FSUB 0x14 37818b2f7e6Ssimonb #define OPC63M_FADD 0x15 37918b2f7e6Ssimonb #define OPC63M_FSQRT 0x16 38018b2f7e6Ssimonb #define OPC63M_FSEL 0x17 38118b2f7e6Ssimonb #define OPC63M_FMUL 0x19 38218b2f7e6Ssimonb #define OPC63M_FRSQRTE 0x1a 38318b2f7e6Ssimonb #define OPC63M_FMSUB 0x1c 38418b2f7e6Ssimonb #define OPC63M_FMADD 0x1d 38518b2f7e6Ssimonb #define OPC63M_FNMSUB 0x1e 38618b2f7e6Ssimonb #define OPC63M_FNMADD 0x1f 38718b2f7e6Ssimonb 38818b2f7e6Ssimonb #define OPC63_FCMPU 0x00 38918b2f7e6Ssimonb #define OPC63_FRSP 0x0c 39018b2f7e6Ssimonb #define OPC63_FCTIW 0x0e 39118b2f7e6Ssimonb #define OPC63_FCTIWZ 0x0f 39218b2f7e6Ssimonb #define OPC63_FCMPO 0x20 39318b2f7e6Ssimonb #define OPC63_MTFSB1 0x26 39418b2f7e6Ssimonb #define OPC63_FNEG 0x28 39518b2f7e6Ssimonb #define OPC63_MCRFS 0x40 39618b2f7e6Ssimonb #define OPC63_MTFSB0 0x46 39718b2f7e6Ssimonb #define OPC63_FMR 0x48 39818b2f7e6Ssimonb #define OPC63_MTFSFI 0x86 39918b2f7e6Ssimonb #define OPC63_FNABS 0x88 40018b2f7e6Ssimonb #define OPC63_FABS 0x108 40118b2f7e6Ssimonb #define OPC63_MFFS 0x247 40218b2f7e6Ssimonb #define OPC63_MTFSF 0x2c7 40318b2f7e6Ssimonb #define OPC63_FCTID 0x32e 40418b2f7e6Ssimonb #define OPC63_FCTIDZ 0x32f 40518b2f7e6Ssimonb #define OPC63_FCFID 0x34e 40618b2f7e6Ssimonb 40718b2f7e6Ssimonb /* 408b8ea2c8cSmatt * Branch instruction modifiers. 409b8ea2c8cSmatt */ 410b8ea2c8cSmatt #define B_LK 0x01 /* Link flag (LR=CIA+4) */ 411b8ea2c8cSmatt #define B_AA 0x02 /* Absolute flag */ 412b8ea2c8cSmatt 413b8ea2c8cSmatt /* 414b8ea2c8cSmatt * Helpers for decoding mfspr 415b8ea2c8cSmatt */ 416b8ea2c8cSmatt #define OPC_MFSPR_CODE 0x7c0002a6 417b8ea2c8cSmatt #define OPC_MFSPR_MASK (~(0x1f << 21)) 418b8ea2c8cSmatt #define OPC_MFSPR(spr) (OPC_MFSPR_CODE |\ 419b8ea2c8cSmatt (((spr) & 0x1f) << 16) |\ 420b8ea2c8cSmatt (((spr) & 0x3e0) << 6)) 421b8ea2c8cSmatt #define OPC_MFSPR_REG(o) (((o) >> 21) & 0x1f) 422b8ea2c8cSmatt #define OPC_MFSPR_P(o, spr) (((o) & OPC_MFSPR_MASK) == OPC_MFSPR(spr)) 423b8ea2c8cSmatt 424b8ea2c8cSmatt /* 425b8ea2c8cSmatt * booke doesn't have lwsync even though gcc emits it so we have to emulate it. 426b8ea2c8cSmatt */ 427b8ea2c8cSmatt #define OPC_LWSYNC 0x7c2004ac 428b8ea2c8cSmatt 429b8ea2c8cSmatt /* 43018b2f7e6Ssimonb * FPCSR rounding modes. 43118b2f7e6Ssimonb */ 43218b2f7e6Ssimonb #define FSR_RD_RN 0 /* round to nearest */ 43318b2f7e6Ssimonb #define FSR_RD_RZ 1 /* round towards 0 */ 43418b2f7e6Ssimonb #define FSR_RD_RP 2 /* round towards +inf */ 43518b2f7e6Ssimonb #define FSR_RD_RM 3 /* round towards -inf */ 436b8ea2c8cSmatt 437b8ea2c8cSmatt /* 438b8ea2c8cSmatt * Convert an address to an offset used in a PowerPC branch instruction. 439b8ea2c8cSmatt * We simply shift away the low bits since we are going convert the bl 440b8ea2c8cSmatt * to a bla. 441b8ea2c8cSmatt */ 442b8ea2c8cSmatt #define fixup_addr2offset(x) ((uintptr_t)(x) >> 2) 443b8ea2c8cSmatt struct powerpc_jump_fixup_info { 444b8ea2c8cSmatt uint32_t jfi_stub; 445b8ea2c8cSmatt uint32_t jfi_real; 446b8ea2c8cSmatt }; 447b8ea2c8cSmatt 448e13c032fSmatt void powerpc_fixup_stubs(uint32_t *, uint32_t *, uint32_t *, uint32_t *); 449b8ea2c8cSmatt 450b8ea2c8cSmatt 451b8ea2c8cSmatt #endif /* !_POWERPC_INSTR_H_ */ 452