Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xtensa-asm2-util.s hard coding #30126

Closed
hongshui3000 opened this issue Nov 19, 2020 · 2 comments · Fixed by #30668
Closed

xtensa-asm2-util.s hard coding #30126

hongshui3000 opened this issue Nov 19, 2020 · 2 comments · Fixed by #30668
Assignees
Labels
bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug

Comments

@hongshui3000
Copy link
Contributor

hongshui3000 commented Nov 19, 2020

Describe the bug

/*
 * _restore_context
 *
 * Arrive here via a jump.  Enters into the restored context and does
 * not return.  A1 should have a context pointer in it as received
 * from switch or an interrupt exit.  Interrupts must be disabled,
 * and register windows should have been spilled.
 *
 * Note that exit from the restore is done with the RFI instruction,
 * using the EPCn/EPSn registers.  Those will have been saved already
 * by any interrupt entry so they are save to use.  Note that EPC1 and
 * RFE are NOT usable (they can't preserve PS).  Per the ISA spec, all
 * RFI levels do the same thing and differ only in the special
 * registers used to hold PC/PS, but Qemu has been observed to behave
 * strangely when RFI doesn't "return" to a INTLEVEL strictly lower
 * than it started from.  So pick level 6 (the highest that works on
 * Qemu, hardware doesn't care so it doesn't matter).  In theory we
 * should test to be able to support hardware with less than 6 levels,
 * though...
 */
.global _restore_context
_restore_context:
	call0 xtensa_restore_high_regs

	l32i a0, a1, BSA_PC_OFF
	wsr.EPC6 a0 ---------------------------------------------->hard coding
	l32i a0, a1, BSA_PS_OFF
	wsr.EPS6 a0   ---------------------------------------------->hard coding

	l32i a0, a1, BSA_SAR_OFF
	wsr.SAR a0
#if XCHAL_HAVE_LOOPS
	l32i a0, a1, BSA_LBEG_OFF
	wsr.LBEG a0
	l32i a0, a1, BSA_LEND_OFF
	wsr.LEND a0
	l32i a0, a1, BSA_LCOUNT_OFF
	wsr.LCOUNT a0
#endif
#if XCHAL_HAVE_S32C1I
	l32i a0, a1, BSA_SCOMPARE1_OFF
	wsr.SCOMPARE1 a0
#endif
#if XCHAL_HAVE_THREADPTR && defined(CONFIG_THREAD_LOCAL_STORAGE)
	l32i a0, a1, BSA_THREADPTR_OFF
	wur.THREADPTR a0
#endif
	rsync

	l32i a0, a1, BSA_A0_OFF
	l32i a2, a1, BSA_A2_OFF
	l32i a3, a1, BSA_A3_OFF
	addi a1, a1, BASE_SAVE_AREA_SIZE

	rfi 6                                   ---------------------------------->hard coding
/* The wrapper code lives here instead of in the python script that
 * generates _xtensa_handle_one_int*().  Seems cleaner, still kind of
 * ugly.
 */
#define DEF_INT_C_HANDLER(l)				\
void *xtensa_int##l##_c(void *interrupted_stack)	\
{							   \
	uint32_t irqs, intenable, m;			   \
	__asm__ volatile("rsr.interrupt %0" : "=r"(irqs)); \
	__asm__ volatile("rsr.intenable %0" : "=r"(intenable)); \
	irqs &= intenable;					\
	while ((m = _xtensa_handle_one_int##l(irqs))) {		\
		irqs ^= m;					\
		__asm__ volatile("wsr.intclear %0" : : "r"(m)); \
	}							\
	return z_get_next_switch_handle(interrupted_stack);		\
}

DEF_INT_C_HANDLER(2)
DEF_INT_C_HANDLER(3)
DEF_INT_C_HANDLER(4)
DEF_INT_C_HANDLER(5)
DEF_INT_C_HANDLER(6)   ---------------------------------->hard coding
DEF_INT_C_HANDLER(7)   ---------------------------------->hard coding

If the core architecture of the chip does not support EPC6,EPS6 , the compilation will fail。There is no external option to change this result。

@hongshui3000 hongshui3000 added the bug The issue is a bug, or the PR is fixing a bug label Nov 19, 2020
@nashif nashif added the priority: low Low impact/importance bug label Dec 1, 2020
@dcpleung
Copy link
Member

Note that DEF_INT_C_HANDLER() does not refer to EPS/EPC registers so no issue there.

@hongshui3000
Copy link
Contributor Author

hongshui3000 commented Dec 14, 2020

Note that DEF_INT_C_HANDLER() does not refer to EPS/EPC registers so no issue there.

yes,But there will be other warnings.When there is no interruption of leve6 and leve7, the interrupt function _xtensa_handle_one_int6 and _xtensa_handle_one_int7 will not exist. NXP RT600 supports up to interrupt leve5.
msg:

E:\work\rtos_work\zephyrproject\zephyr>west build -b my_demo samples/hello_world
[1/7] Building C object zephyr/arch/arch/xtensa/core/CMakeFiles/arch__xtensa__core.dir/xtensa-asm2.c.obj
E:/work/rtos_work/zephyrproject/zephyr/arch/xtensa/core/xtensa-asm2.c: In function 'xtensa_int6_c':
E:/work/rtos_work/zephyrproject/zephyr/arch/xtensa/core/xtensa-asm2.c:158: warning: implicit declaration of function '_xtensa_handle_one_int6'
E:/work/rtos_work/zephyrproject/zephyr/arch/xtensa/core/xtensa-asm2.c: In function 'xtensa_int7_c':
E:/work/rtos_work/zephyrproject/zephyr/arch/xtensa/core/xtensa-asm2.c:159: warning: implicit declaration of function '_xtensa_handle_one_int7'

dcpleung added a commit to dcpleung/zephyr that referenced this issue Dec 14, 2020
There may be Xtensa SoCs which don't have high enough interrupt
levels for EPC6/EPS6 to exist in _restore_context. So changes
these to those which should be available according to the ISA
config file.

Fixes zephyrproject-rtos#30126

Signed-off-by: Daniel Leung <[email protected]>
andrewboie pushed a commit that referenced this issue Jan 5, 2021
There may be Xtensa SoCs which don't have high enough interrupt
levels for EPC6/EPS6 to exist in _restore_context. So changes
these to those which should be available according to the ISA
config file.

Fixes #30126

Signed-off-by: Daniel Leung <[email protected]>
bwasim pushed a commit to bwasim/zephyr that referenced this issue Jan 5, 2021
There may be Xtensa SoCs which don't have high enough interrupt
levels for EPC6/EPS6 to exist in _restore_context. So changes
these to those which should be available according to the ISA
config file.

Fixes zephyrproject-rtos#30126

Signed-off-by: Daniel Leung <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants