162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#ifndef __ASM_ALTERNATIVE_H
362306a36Sopenharmony_ci#define __ASM_ALTERNATIVE_H
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#include <asm/alternative-macros.h>
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci#ifndef __ASSEMBLY__
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#include <linux/init.h>
1062306a36Sopenharmony_ci#include <linux/types.h>
1162306a36Sopenharmony_ci#include <linux/stddef.h>
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_cistruct alt_instr {
1462306a36Sopenharmony_ci	s32 orig_offset;	/* offset to original instruction */
1562306a36Sopenharmony_ci	s32 alt_offset;		/* offset to replacement instruction */
1662306a36Sopenharmony_ci	u16 cpucap;		/* cpucap bit set for replacement */
1762306a36Sopenharmony_ci	u8  orig_len;		/* size of original instruction(s) */
1862306a36Sopenharmony_ci	u8  alt_len;		/* size of new instruction(s), <= orig_len */
1962306a36Sopenharmony_ci};
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_citypedef void (*alternative_cb_t)(struct alt_instr *alt,
2262306a36Sopenharmony_ci				 __le32 *origptr, __le32 *updptr, int nr_inst);
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_civoid __init apply_boot_alternatives(void);
2562306a36Sopenharmony_civoid __init apply_alternatives_all(void);
2662306a36Sopenharmony_cibool alternative_is_applied(u16 cpucap);
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci#ifdef CONFIG_MODULES
2962306a36Sopenharmony_civoid apply_alternatives_module(void *start, size_t length);
3062306a36Sopenharmony_ci#else
3162306a36Sopenharmony_cistatic inline void apply_alternatives_module(void *start, size_t length) { }
3262306a36Sopenharmony_ci#endif
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_civoid alt_cb_patch_nops(struct alt_instr *alt, __le32 *origptr,
3562306a36Sopenharmony_ci		       __le32 *updptr, int nr_inst);
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci#endif /* __ASSEMBLY__ */
3862306a36Sopenharmony_ci#endif /* __ASM_ALTERNATIVE_H */
39