1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */ 2*4882a593Smuzhiyun #ifndef __ASM_PARISC_ALTERNATIVE_H 3*4882a593Smuzhiyun #define __ASM_PARISC_ALTERNATIVE_H 4*4882a593Smuzhiyun 5*4882a593Smuzhiyun #define ALT_COND_ALWAYS 0x80 /* always replace instruction */ 6*4882a593Smuzhiyun #define ALT_COND_NO_SMP 0x01 /* when running UP instead of SMP */ 7*4882a593Smuzhiyun #define ALT_COND_NO_DCACHE 0x02 /* if system has no d-cache */ 8*4882a593Smuzhiyun #define ALT_COND_NO_ICACHE 0x04 /* if system has no i-cache */ 9*4882a593Smuzhiyun #define ALT_COND_NO_SPLIT_TLB 0x08 /* if split_tlb == 0 */ 10*4882a593Smuzhiyun #define ALT_COND_NO_IOC_FDC 0x10 /* if I/O cache does not need flushes */ 11*4882a593Smuzhiyun #define ALT_COND_RUN_ON_QEMU 0x20 /* if running on QEMU */ 12*4882a593Smuzhiyun 13*4882a593Smuzhiyun #define INSN_PxTLB 0x02 /* modify pdtlb, pitlb */ 14*4882a593Smuzhiyun #define INSN_NOP 0x08000240 /* nop */ 15*4882a593Smuzhiyun 16*4882a593Smuzhiyun #ifndef __ASSEMBLY__ 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun #include <linux/init.h> 19*4882a593Smuzhiyun #include <linux/types.h> 20*4882a593Smuzhiyun #include <linux/stddef.h> 21*4882a593Smuzhiyun #include <linux/stringify.h> 22*4882a593Smuzhiyun 23*4882a593Smuzhiyun struct alt_instr { 24*4882a593Smuzhiyun s32 orig_offset; /* offset to original instructions */ 25*4882a593Smuzhiyun s32 len; /* end of original instructions */ 26*4882a593Smuzhiyun u32 cond; /* see ALT_COND_XXX */ 27*4882a593Smuzhiyun u32 replacement; /* replacement instruction or code */ 28*4882a593Smuzhiyun }; 29*4882a593Smuzhiyun 30*4882a593Smuzhiyun void set_kernel_text_rw(int enable_read_write); 31*4882a593Smuzhiyun void apply_alternatives_all(void); 32*4882a593Smuzhiyun void apply_alternatives(struct alt_instr *start, struct alt_instr *end, 33*4882a593Smuzhiyun const char *module_name); 34*4882a593Smuzhiyun 35*4882a593Smuzhiyun /* Alternative SMP implementation. */ 36*4882a593Smuzhiyun #define ALTERNATIVE(cond, replacement) "!0:" \ 37*4882a593Smuzhiyun ".section .altinstructions, \"aw\" !" \ 38*4882a593Smuzhiyun ".word (0b-4-.), 1, " __stringify(cond) "," \ 39*4882a593Smuzhiyun __stringify(replacement) " !" \ 40*4882a593Smuzhiyun ".previous" 41*4882a593Smuzhiyun 42*4882a593Smuzhiyun #else 43*4882a593Smuzhiyun 44*4882a593Smuzhiyun /* to replace one single instructions by a new instruction */ 45*4882a593Smuzhiyun #define ALTERNATIVE(from, to, cond, replacement)\ 46*4882a593Smuzhiyun .section .altinstructions, "aw" ! \ 47*4882a593Smuzhiyun .word (from - .), (to - from)/4 ! \ 48*4882a593Smuzhiyun .word cond, replacement ! \ 49*4882a593Smuzhiyun .previous 50*4882a593Smuzhiyun 51*4882a593Smuzhiyun /* to replace multiple instructions by new code */ 52*4882a593Smuzhiyun #define ALTERNATIVE_CODE(from, num_instructions, cond, new_instr_ptr)\ 53*4882a593Smuzhiyun .section .altinstructions, "aw" ! \ 54*4882a593Smuzhiyun .word (from - .), -num_instructions ! \ 55*4882a593Smuzhiyun .word cond, (new_instr_ptr - .) ! \ 56*4882a593Smuzhiyun .previous 57*4882a593Smuzhiyun 58*4882a593Smuzhiyun #endif /* __ASSEMBLY__ */ 59*4882a593Smuzhiyun 60*4882a593Smuzhiyun #endif /* __ASM_PARISC_ALTERNATIVE_H */ 61