Commit graph

9 commits

Author SHA1 Message Date
Daniel Leung bc3e77b356 xtensa: make it work with TLB misses during interrupt handling
If there are any TLB misses during interrupt handling,
the user, kernel and double exception vector will be triggered
for the miss and the DEPC and EXCCAUSE overwritten as the TLB
missse are be handled in the assembly code and execution
returned to the original vector code. Because of this, both
DEPC and EXCCAUSE being read in the C handler are not the ones
that triggered the original exception (for example, level-1
interrupt). So stash both DEPC and EXCCAUSE such that
the original cause of exception is visible in the C handler.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2024-06-15 04:44:48 -04:00
Daniel Leung 682b572414 xtensa: remove ZSR_MMU_0 and ZSR_MMU_1
They are not being used in the code so there is no need to
reserve them as scratch registers.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2024-06-15 04:44:48 -04:00
Daniel Leung b019dcb05e xtensa: userspace: use syscall to check if user context
For CPU without THREADPTR, we need an alternative way to figure
out if we are in user context. This extends the user context
check to do that via a brief syscall.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2024-03-19 22:17:34 -04:00
Daniel Leung 5d8b43feff xtensa: only need ZSR_FLUSH if CONFIG_KERNEL_COHERENCE
The ZSR_FLUSH scratch register is only needed if kconfig
CONFIG_KERNEL_COHERENCE is enabled. So update gen_zsr.py
for that.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2024-02-01 13:09:53 -06:00
Daniel Leung bc0656a92e xtensa: mmu: allocate scratch registers for MMU
When MMU is enabled, we need some scratch registers to preload
page table entries. So update gen_zsr.py to that.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-11-21 15:49:48 +01:00
Andy Ross 080e14f0f4 arch/xtensa: Rename "ALLOCA" ZSR to "A0SAVE"
This register alias was originally introduced to allow A0 to be used
as a scratch register when handling exceptions from MOVSP
instructions. (It replaced some upstream code from Cadence that
hard-coded EXCSAVE1).  Now the MMU code is now using too, and for
exactly the same purpose.

Calling it "ALLOCA" is only confusing.  Rename it to make it clear
what it's doing.

Signed-off-by: Andy Ross <andyross@google.com>
2023-11-21 15:49:48 +01:00
Daniel Leung dfc87e2754 xtensa: gen_zsr: add _STR for extra registers
This also generates the correspoing _STR entries for
extra registers.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-05-23 08:54:29 +02:00
Andy Ross c174ade4a1 arch/xtensa: Rework irq_offload: automatic config, SMP-safe
The Xtensa implementation of arch_irq_offload() required that the user
select the correct interrupt manually, and would race with itself if
invoked from separate CPUs (it was saved here by the main
irq_offload() function which has a semaphore to serialize access).

Use the new gen_zsr.py script to automatically detect the highest
available software interrupt, and keep a per-CPU set of
callback/parameter pointers.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2022-02-21 22:10:03 -05:00
Andy Ross 82071be443 arch/xtensa: Add special register allocation generator
Zephyr likes to use the various Xtensa scratch registers for its own
purposes in several places.  Unfortunately, owing to the
configurability of the architecture, we have to use different
registers for different platforms.  This has been done so far with a
collection of different tricks, some... less elegant than others.

Put it all in one place.  This is a python script that emites a
"zsr.h" header with register assignments for all the existing users.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2022-01-20 12:58:00 -05:00