1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * XIP fixup macros, only useful in assembly.
4 */
5#ifndef _ASM_RISCV_XIP_FIXUP_H
6#define _ASM_RISCV_XIP_FIXUP_H
7
8#include <linux/pgtable.h>
9
10#ifdef CONFIG_XIP_KERNEL
11.macro XIP_FIXUP_OFFSET reg
12        REG_L t0, _xip_fixup
13        add \reg, \reg, t0
14.endm
15.macro XIP_FIXUP_FLASH_OFFSET reg
16	la t0, __data_loc
17	REG_L t1, _xip_phys_offset
18	sub \reg, \reg, t1
19	add \reg, \reg, t0
20.endm
21
22_xip_fixup: .dword CONFIG_PHYS_RAM_BASE - CONFIG_XIP_PHYS_ADDR - XIP_OFFSET
23_xip_phys_offset: .dword CONFIG_XIP_PHYS_ADDR + XIP_OFFSET
24#else
25.macro XIP_FIXUP_OFFSET reg
26.endm
27.macro XIP_FIXUP_FLASH_OFFSET reg
28.endm
29#endif /* CONFIG_XIP_KERNEL */
30
31#endif
32