xtensa: rename z_xtensa to simply xtensa

Rename the remaining z_xtensa stuff as these are (mostly)
under arch/xtensa.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
Daniel Leung 2023-12-08 11:10:50 -08:00 committed by Carles Cufí
commit a819bfb2d5
16 changed files with 149 additions and 99 deletions

View file

@ -14,9 +14,9 @@
.section .iram1, "ax"
.align 4
.global z_xtensa_backtrace_get_start
.type z_xtensa_backtrace_get_start, @function
z_xtensa_backtrace_get_start:
.global xtensa_backtrace_get_start
.type xtensa_backtrace_get_start, @function
xtensa_backtrace_get_start:
entry a1, 32
/* Spill registers onto stack (excluding this function) */
call8 xthal_window_spill

View file

@ -21,7 +21,7 @@ LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL);
#include <xtensa/simcall.h>
#endif
char *z_xtensa_exccause(unsigned int cause_code)
char *xtensa_exccause(unsigned int cause_code)
{
#if defined(CONFIG_PRINTK) || defined(CONFIG_LOG)
switch (cause_code) {
@ -85,7 +85,7 @@ char *z_xtensa_exccause(unsigned int cause_code)
#endif
}
void z_xtensa_fatal_error(unsigned int reason, const z_arch_esf_t *esf)
void xtensa_fatal_error(unsigned int reason, const z_arch_esf_t *esf)
{
if (esf) {
/* Don't want to get elbowed by xtensa_switch
@ -94,13 +94,13 @@ void z_xtensa_fatal_error(unsigned int reason, const z_arch_esf_t *esf)
*/
unsigned int key = arch_irq_lock();
z_xtensa_dump_stack(esf);
xtensa_dump_stack(esf);
coredump(reason, esf, IS_ENABLED(CONFIG_MULTITHREADING) ? k_current_get() : NULL);
#if defined(CONFIG_XTENSA_ENABLE_BACKTRACE)
#if XCHAL_HAVE_WINDOWED
z_xtensa_backtrace_print(100, (int *)esf);
xtensa_backtrace_print(100, (int *)esf);
#endif
#endif
arch_irq_unlock(key);

View file

@ -10,6 +10,8 @@
#include <kernel_arch_func.h>
#include <xtensa_internal.h>
#include <zephyr/logging/log.h>
LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL);
@ -72,7 +74,7 @@ void z_irq_spurious(const void *arg)
__asm__ volatile("rsr.intenable %0" : "=r"(ie));
LOG_ERR(" ** Spurious INTERRUPT(s) %p, INTENABLE = %p",
(void *)irqs, (void *)ie);
z_xtensa_fatal_error(K_ERR_SPURIOUS_IRQ, NULL);
xtensa_fatal_error(K_ERR_SPURIOUS_IRQ, NULL);
}
int xtensa_irq_is_enabled(unsigned int irq)

View file

@ -60,7 +60,7 @@ static uint32_t l1_page_table[CONFIG_XTENSA_MMU_NUM_L1_TABLES][XTENSA_L1_PAGE_TA
/*
* That is an alias for the page tables set used by the kernel.
*/
uint32_t *z_xtensa_kernel_ptables = (uint32_t *)l1_page_table[0];
uint32_t *xtensa_kernel_ptables = (uint32_t *)l1_page_table[0];
/*
* Each table in the level 2 maps a 4Mb memory range. It consists of 1024 entries each one
@ -170,7 +170,7 @@ static inline uint32_t *thread_page_tables_get(const struct k_thread *thread)
}
#endif
return z_xtensa_kernel_ptables;
return xtensa_kernel_ptables;
}
/**
@ -231,7 +231,7 @@ static void map_memory_range(const uint32_t start, const uint32_t end,
uint32_t l2_pos = XTENSA_MMU_L2_POS(page);
uint32_t l1_pos = XTENSA_MMU_L1_POS(page);
if (is_pte_illegal(z_xtensa_kernel_ptables[l1_pos])) {
if (is_pte_illegal(xtensa_kernel_ptables[l1_pos])) {
table = alloc_l2_table();
__ASSERT(table != NULL, "There is no l2 page table available to "
@ -239,12 +239,12 @@ static void map_memory_range(const uint32_t start, const uint32_t end,
init_page_table(table, XTENSA_L2_PAGE_TABLE_ENTRIES);
z_xtensa_kernel_ptables[l1_pos] =
xtensa_kernel_ptables[l1_pos] =
XTENSA_MMU_PTE((uint32_t)table, XTENSA_MMU_KERNEL_RING,
XTENSA_MMU_PAGE_TABLE_ATTR);
}
table = (uint32_t *)(z_xtensa_kernel_ptables[l1_pos] & XTENSA_MMU_PTE_PPN_MASK);
table = (uint32_t *)(xtensa_kernel_ptables[l1_pos] & XTENSA_MMU_PTE_PPN_MASK);
table[l2_pos] = pte;
}
}
@ -270,7 +270,7 @@ static void xtensa_init_page_tables(void)
{
volatile uint8_t entry;
init_page_table(z_xtensa_kernel_ptables, XTENSA_L1_PAGE_TABLE_ENTRIES);
init_page_table(xtensa_kernel_ptables, XTENSA_L1_PAGE_TABLE_ENTRIES);
atomic_set_bit(l1_page_table_track, 0);
for (entry = 0; entry < ARRAY_SIZE(mmu_zephyr_ranges); entry++) {
@ -342,7 +342,7 @@ void xtensa_mmu_init(void)
xtensa_init_page_tables();
}
xtensa_init_paging(z_xtensa_kernel_ptables);
xtensa_init_paging(xtensa_kernel_ptables);
arch_xtensa_mmu_post_init(_current_cpu->id == 0);
}
@ -437,12 +437,12 @@ static inline void __arch_mem_map(void *va, uintptr_t pa, uint32_t xtensa_flags,
flags = xtensa_flags;
}
ret = l2_page_table_map(z_xtensa_kernel_ptables, (void *)vaddr, paddr,
ret = l2_page_table_map(xtensa_kernel_ptables, (void *)vaddr, paddr,
flags, is_user);
__ASSERT(ret, "Virtual address (%p) already mapped", va);
if (IS_ENABLED(CONFIG_XTENSA_MMU_DOUBLE_MAP) && ret) {
ret = l2_page_table_map(z_xtensa_kernel_ptables, (void *)vaddr_uc, paddr_uc,
ret = l2_page_table_map(xtensa_kernel_ptables, (void *)vaddr_uc, paddr_uc,
flags_uc, is_user);
__ASSERT(ret, "Virtual address (%p) already mapped", vaddr_uc);
}
@ -599,10 +599,10 @@ static inline void __arch_mem_unmap(void *va)
vaddr = va;
}
is_exec = l2_page_table_unmap(z_xtensa_kernel_ptables, (void *)vaddr);
is_exec = l2_page_table_unmap(xtensa_kernel_ptables, (void *)vaddr);
if (IS_ENABLED(CONFIG_XTENSA_MMU_DOUBLE_MAP)) {
(void)l2_page_table_unmap(z_xtensa_kernel_ptables, (void *)vaddr_uc);
(void)l2_page_table_unmap(xtensa_kernel_ptables, (void *)vaddr_uc);
}
#ifdef CONFIG_USERSPACE
@ -803,7 +803,7 @@ int arch_mem_domain_init(struct k_mem_domain *domain)
__ASSERT(asid_count < (XTENSA_MMU_SHARED_ASID), "Reached maximum of ASID available");
key = k_spin_lock(&xtensa_mmu_lock);
ptables = dup_table(z_xtensa_kernel_ptables);
ptables = dup_table(xtensa_kernel_ptables);
if (ptables == NULL) {
ret = -ENOMEM;
@ -1088,7 +1088,7 @@ int arch_buffer_validate(void *addr, size_t size, int write)
return ret;
}
void z_xtensa_swap_update_page_tables(struct k_thread *incoming)
void xtensa_swap_update_page_tables(struct k_thread *incoming)
{
uint32_t *ptables = incoming->arch.ptables;
struct arch_mem_domain *domain =

View file

@ -10,6 +10,7 @@
#include <kernel_internal.h>
#include <xtensa_asm2_context.h>
#include <xtensa_internal.h>
#include <zephyr/logging/log.h>
LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL);
@ -40,8 +41,8 @@ static void *init_stack(struct k_thread *thread, int *stack_top,
void *ret;
_xtensa_irq_stack_frame_a11_t *frame;
#ifdef CONFIG_USERSPACE
struct z_xtensa_thread_stack_header *header =
(struct z_xtensa_thread_stack_header *)thread->stack_obj;
struct xtensa_thread_stack_header *header =
(struct xtensa_thread_stack_header *)thread->stack_obj;
thread->arch.psp = header->privilege_stack +
sizeof(header->privilege_stack);
@ -152,8 +153,8 @@ FUNC_NORETURN void arch_user_mode_enter(k_thread_entry_t user_entry,
current->stack_info.size -
current->stack_info.delta);
z_xtensa_userspace_enter(user_entry, p1, p2, p3,
stack_end, current->stack_info.start);
xtensa_userspace_enter(user_entry, p1, p2, p3,
stack_end, current->stack_info.start);
CODE_UNREACHABLE;
}

View file

@ -16,10 +16,10 @@
* a2 a6, a3, a4, a5, a8, a9
*
**/
.pushsection .text.z_xtensa_do_syscall, "ax"
.global z_xtensa_do_syscall
.pushsection .text.xtensa_do_syscall, "ax"
.global xtensa_do_syscall
.align 4
z_xtensa_do_syscall:
xtensa_do_syscall:
rsr a0, ZSR_CPU
l32i a0, a0, ___cpu_t_current_OFFSET
l32i a0, a0, _thread_offset_to_psp
@ -199,17 +199,17 @@ _bad_syscall:
.popsection
/* FUNC_NORETURN void z_xtensa_userspace_enter(k_thread_entry_t user_entry,
/* FUNC_NORETURN void xtensa_userspace_enter(k_thread_entry_t user_entry,
* void *p1, void *p2, void *p3,
* uint32_t stack_end,
* uint32_t stack_start)
*
* A one-way trip to userspace.
*/
.global z_xtensa_userspace_enter
.type z_xtensa_userspace_enter, @function
.global xtensa_userspace_enter
.type xtensa_userspace_enter, @function
.align 4
z_xtensa_userspace_enter:
xtensa_userspace_enter:
/* Call entry to set a bit in the windowstart and
* do the rotation, but we are going to set our own
* stack.
@ -240,7 +240,7 @@ z_xtensa_userspace_enter:
call4 xtensa_user_stack_perms
l32i a6, a1, 24
call4 z_xtensa_swap_update_page_tables
call4 xtensa_swap_update_page_tables
#ifdef CONFIG_THREAD_LOCAL_STORAGE
rur.threadptr a3
@ -302,12 +302,12 @@ arch_user_string_nlen:
/* This code might page fault */
strlen_loop:
.global z_xtensa_user_string_nlen_fault_start
z_xtensa_user_string_nlen_fault_start:
.global xtensa_user_string_nlen_fault_start
xtensa_user_string_nlen_fault_start:
l8ui a6, a2, 0 /* Current char */
.global z_xtensa_user_string_nlen_fault_end
z_xtensa_user_string_nlen_fault_end:
.global xtensa_user_string_nlen_fault_end
xtensa_user_string_nlen_fault_end:
beqz a6, strlen_done
addi a5, a5, 1
addi a2, a2, 1
@ -322,6 +322,6 @@ strlen_done:
movi a5, 0x0
s32i a5, a4, 0
.global z_xtensa_user_string_nlen_fixup
z_xtensa_user_string_nlen_fixup:
.global xtensa_user_string_nlen_fixup
xtensa_user_string_nlen_fixup:
retw

View file

@ -25,14 +25,14 @@ extern char xtensa_arch_except_epc[];
extern char xtensa_arch_kernel_oops_epc[];
#ifdef CONFIG_USERSPACE
Z_EXC_DECLARE(z_xtensa_user_string_nlen);
Z_EXC_DECLARE(xtensa_user_string_nlen);
static const struct z_exc_handle exceptions[] = {
Z_EXC_HANDLE(z_xtensa_user_string_nlen)
Z_EXC_HANDLE(xtensa_user_string_nlen)
};
#endif /* CONFIG_USERSPACE */
void z_xtensa_dump_stack(const z_arch_esf_t *stack)
void xtensa_dump_stack(const z_arch_esf_t *stack)
{
_xtensa_irq_stack_frame_raw_t *frame = (void *)stack;
_xtensa_irq_bsa_t *bsa = frame->ptr_to_bsa;
@ -115,7 +115,7 @@ static void print_fatal_exception(void *print_stack, int cause,
LOG_ERR(" ** FATAL EXCEPTION%s", (is_dblexc ? " (DOUBLE)" : ""));
LOG_ERR(" ** CPU %d EXCCAUSE %d (%s)",
arch_curr_cpu()->id, cause,
z_xtensa_exccause(cause));
xtensa_exccause(cause));
LOG_ERR(" ** PC %p VADDR %p", pc, (void *)vaddr);
if (is_dblexc) {
@ -244,7 +244,7 @@ void *xtensa_excint1_c(int *interrupted_stack)
/* Just report it to the console for now */
LOG_ERR(" ** SYSCALL PS %p PC %p",
(void *)bsa->ps, (void *)bsa->pc);
z_xtensa_dump_stack(interrupted_stack);
xtensa_dump_stack(interrupted_stack);
/* Xtensa exceptions don't automatically advance PC,
* have to skip the SYSCALL instruction manually or
@ -279,7 +279,7 @@ void *xtensa_excint1_c(int *interrupted_stack)
/* We need to distinguish between an ill in xtensa_arch_except,
* e.g for k_panic, and any other ill. For exceptions caused by
* xtensa_arch_except calls, we also need to pass the reason_p
* to z_xtensa_fatal_error. Since the ARCH_EXCEPT frame is in the
* to xtensa_fatal_error. Since the ARCH_EXCEPT frame is in the
* BSA, the first arg reason_p is stored at the A2 offset.
* We assign EXCCAUSE the unused, reserved code 63; this may be
* problematic if the app or new boards also decide to repurpose
@ -316,8 +316,7 @@ void *xtensa_excint1_c(int *interrupted_stack)
* as these are software errors. Should clean this
* up.
*/
z_xtensa_fatal_error(reason,
(void *)print_stack);
xtensa_fatal_error(reason, (void *)print_stack);
break;
}
@ -341,7 +340,7 @@ void *xtensa_excint1_c(int *interrupted_stack)
/* We are going to manipulate _current_cpu->nested manually.
* Since the error is fatal, for recoverable errors, code
* execution must not return back to the current thread as
* it is being terminated (via above z_xtensa_fatal_error()).
* it is being terminated (via above xtensa_fatal_error()).
* So we need to prevent more interrupts coming in which
* will affect the nested value as we are going outside of
* normal interrupt handling procedure.

View file

@ -277,7 +277,7 @@ noflush:
/* Switch page tables */
rsr a6, ZSR_CPU
l32i a6, a6, ___cpu_t_current_OFFSET
call4 z_xtensa_swap_update_page_tables
call4 xtensa_swap_update_page_tables
l32i a2, a3, 0
l32i a2, a2, 0
@ -407,7 +407,7 @@ _handle_tlb_miss_user:
#ifdef CONFIG_USERSPACE
_syscall:
rsr a0, ZSR_A0SAVE
j z_xtensa_do_syscall
j xtensa_do_syscall
#endif /* CONFIG_USERSPACE */
#endif /* CONFIG_XTENSA_MMU */
.popsection

View file

@ -16,7 +16,7 @@
#endif
static int mask, cause;
static inline uint32_t z_xtensa_cpu_process_stack_pc(uint32_t pc)
static inline uint32_t xtensa_cpu_process_stack_pc(uint32_t pc)
{
if (pc & 0x80000000) {
/* Top two bits of a0 (return address) specify window increment.
@ -34,7 +34,7 @@ static inline uint32_t z_xtensa_cpu_process_stack_pc(uint32_t pc)
return pc - 3;
}
static inline bool z_xtensa_stack_ptr_is_sane(uint32_t sp)
static inline bool xtensa_stack_ptr_is_sane(uint32_t sp)
{
#if defined(CONFIG_SOC_SERIES_ESP32)
return esp_stack_ptr_is_sane(sp);
@ -43,11 +43,11 @@ static inline bool z_xtensa_stack_ptr_is_sane(uint32_t sp)
#elif defined(CONFIG_SOC_XTENSA_DC233C)
return xtensa_dc233c_stack_ptr_is_sane(sp);
#else
#warning "z_xtensa_stack_ptr_is_sane is not defined for this platform"
#warning "xtensa_stack_ptr_is_sane is not defined for this platform"
#endif
}
static inline bool z_xtensa_ptr_executable(const void *p)
static inline bool xtensa_ptr_executable(const void *p)
{
#if defined(CONFIG_SOC_SERIES_ESP32)
return esp_ptr_executable(p);
@ -56,11 +56,11 @@ static inline bool z_xtensa_ptr_executable(const void *p)
#elif defined(CONFIG_SOC_XTENSA_DC233C)
return xtensa_dc233c_ptr_executable(p);
#else
#warning "z_xtensa_ptr_executable is not defined for this platform"
#warning "xtensa_ptr_executable is not defined for this platform"
#endif
}
bool z_xtensa_backtrace_get_next_frame(struct z_xtensa_backtrace_frame_t *frame)
bool xtensa_backtrace_get_next_frame(struct xtensa_backtrace_frame_t *frame)
{
/* Use frame(i-1)'s BS area located below frame(i)'s
* sp to get frame(i-1)'s sp and frame(i-2)'s pc
@ -79,12 +79,12 @@ bool z_xtensa_backtrace_get_next_frame(struct z_xtensa_backtrace_frame_t *frame)
/* Return true if both sp and pc of frame(i-1) are sane,
* false otherwise
*/
return (z_xtensa_stack_ptr_is_sane(frame->sp) &&
z_xtensa_ptr_executable((void *)
z_xtensa_cpu_process_stack_pc(frame->pc)));
return (xtensa_stack_ptr_is_sane(frame->sp) &&
xtensa_ptr_executable((void *)
xtensa_cpu_process_stack_pc(frame->pc)));
}
int z_xtensa_backtrace_print(int depth, int *interrupted_stack)
int xtensa_backtrace_print(int depth, int *interrupted_stack)
{
/* Check arguments */
if (depth <= 0) {
@ -92,9 +92,9 @@ int z_xtensa_backtrace_print(int depth, int *interrupted_stack)
}
/* Initialize stk_frame with first frame of stack */
struct z_xtensa_backtrace_frame_t stk_frame;
struct xtensa_backtrace_frame_t stk_frame;
z_xtensa_backtrace_get_start(&(stk_frame.pc), &(stk_frame.sp),
xtensa_backtrace_get_start(&(stk_frame.pc), &(stk_frame.sp),
&(stk_frame.next_pc), interrupted_stack);
__asm__ volatile("l32i a4, a3, 0");
__asm__ volatile("l32i a4, a4, 4");
@ -104,22 +104,22 @@ int z_xtensa_backtrace_print(int depth, int *interrupted_stack)
}
printk("\r\n\r\nBacktrace:");
printk("0x%08x:0x%08x ",
z_xtensa_cpu_process_stack_pc(stk_frame.pc),
xtensa_cpu_process_stack_pc(stk_frame.pc),
stk_frame.sp);
/* Check if first frame is valid */
bool corrupted = !(z_xtensa_stack_ptr_is_sane(stk_frame.sp) &&
(z_xtensa_ptr_executable((void *)
z_xtensa_cpu_process_stack_pc(stk_frame.pc)) ||
bool corrupted = !(xtensa_stack_ptr_is_sane(stk_frame.sp) &&
(xtensa_ptr_executable((void *)
xtensa_cpu_process_stack_pc(stk_frame.pc)) ||
/* Ignore the first corrupted PC in case of InstrFetchProhibited */
cause == EXCCAUSE_INSTR_PROHIBITED));
while (depth-- > 0 && stk_frame.next_pc != 0 && !corrupted) {
/* Get previous stack frame */
if (!z_xtensa_backtrace_get_next_frame(&stk_frame)) {
if (!xtensa_backtrace_get_next_frame(&stk_frame)) {
corrupted = true;
}
printk("0x%08x:0x%08x ", z_xtensa_cpu_process_stack_pc(stk_frame.pc), stk_frame.sp);
printk("0x%08x:0x%08x ", xtensa_cpu_process_stack_pc(stk_frame.pc), stk_frame.sp);
}
/* Print backtrace termination marker */

View file

@ -20,8 +20,6 @@
extern "C" {
#endif
extern void z_xtensa_fatal_error(unsigned int reason, const z_arch_esf_t *esf);
K_KERNEL_STACK_ARRAY_DECLARE(z_interrupt_stacks, CONFIG_MP_MAX_NUM_CPUS,
CONFIG_ISR_STACK_SIZE);
@ -188,13 +186,6 @@ static inline bool arch_is_in_isr(void)
return arch_curr_cpu()->nested != 0U;
}
#ifdef CONFIG_USERSPACE
extern void z_xtensa_userspace_enter(k_thread_entry_t user_entry,
void *p1, void *p2, void *p3,
uintptr_t stack_end,
uintptr_t stack_start);
#endif /* CONFIG_USERSPACE */
#ifdef __cplusplus
}
#endif

View file

@ -539,7 +539,7 @@ _do_call_\@:
rsr a6, ZSR_CPU
l32i a6, a6, ___cpu_t_current_OFFSET
call4 z_xtensa_swap_update_page_tables
call4 xtensa_swap_update_page_tables
l32i a1, a1, 0
l32i a0, a1, ___xtensa_irq_bsa_t_a0_OFFSET
addi a1, a1, ___xtensa_irq_bsa_t_SIZEOF

View file

@ -16,12 +16,17 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>
/*
/**
* @ingroup xtensa_internal_apis
* @{
*/
/**
* @brief Structure used for backtracing
*
* This structure stores the backtrace information of a particular stack frame
* (i.e. the PC and SP). This structure is used iteratively with the
* z_xtensa_cpu_get_next_backtrace_frame() function to traverse each frame
* xtensa_cpu_get_next_backtrace_frame() function to traverse each frame
* within a single stack. The next_pc represents the PC of the current
* frame's caller, thus a next_pc of 0 indicates that the current frame
* is the last frame on the stack.
@ -29,7 +34,7 @@ extern "C" {
* @note Call esp_backtrace_get_start() to obtain initialization values for
* this structure
*/
struct z_xtensa_backtrace_frame_t {
struct xtensa_backtrace_frame_t {
uint32_t pc; /* PC of the current frame */
uint32_t sp; /* SP of the current frame */
uint32_t next_pc; /* PC of the current frame's caller */
@ -52,13 +57,13 @@ struct z_xtensa_backtrace_frame_t {
* @param[out] next_pc PC of the first frame's caller
* @param[in] interrupted_stack Pointer to interrupted stack
*/
void z_xtensa_backtrace_get_start(uint32_t *pc,
void xtensa_backtrace_get_start(uint32_t *pc,
uint32_t *sp,
uint32_t *next_pc,
int *interrupted_stack);
/**
* Get the next frame on a stack for backtracing
* @brief Get the next frame on a stack for backtracing
*
* Given a stack frame(i), this function will obtain the next
* stack frame(i-1) on the same call stack (i.e. the caller of frame(i)).
@ -77,7 +82,7 @@ void z_xtensa_backtrace_get_start(uint32_t *pc,
* - True if the SP and PC of the next frame(i-1) are sane
* - False otherwise
*/
bool z_xtensa_backtrace_get_next_frame(struct z_xtensa_backtrace_frame_t *frame);
bool xtensa_backtrace_get_next_frame(struct xtensa_backtrace_frame_t *frame);
/**
* @brief Print the backtrace of the current stack
@ -89,7 +94,11 @@ bool z_xtensa_backtrace_get_next_frame(struct z_xtensa_backtrace_frame_t *frame)
* - 0 Backtrace successfully printed to completion or to depth limit
* - -1 Backtrace is corrupted
*/
int z_xtensa_backtrace_print(int depth, int *interrupted_stack);
int xtensa_backtrace_print(int depth, int *interrupted_stack);
/**
* @}
*/
#endif
#ifdef __cplusplus

View file

@ -8,7 +8,55 @@
#ifndef ZEPHYR_ARCH_XTENSA_INCLUDE_XTENSA_INTERNAL_H_
#define ZEPHYR_ARCH_XTENSA_INCLUDE_XTENSA_INTERNAL_H_
void z_xtensa_dump_stack(const z_arch_esf_t *stack);
char *z_xtensa_exccause(unsigned int cause_code);
#include <stdint.h>
#include <zephyr/arch/xtensa/exception.h>
#include <zephyr/sys/arch_interface.h>
/**
* @ingroup xtensa_internal_apis
* @{
*/
/**
* @brief Dump and print out the stack frame content.
*
* This mainly prints out the registers stashed in the stack frame.
*
* @param stack Pointer to stack frame.
*/
void xtensa_dump_stack(const z_arch_esf_t *stack);
/**
* @brief Get string description from an exception code.
*
* @param cause_code Exception code.
*
* @return String description.
*/
char *xtensa_exccause(unsigned int cause_code);
/**
* @brief Called upon a fatal error.
*
* @param reason The reason for the fatal error
* @param esf Exception context, with details and partial or full register
* state when the error occurred. May in some cases be NULL.
*/
void xtensa_fatal_error(unsigned int reason, const z_arch_esf_t *esf);
/**
* @brief Perform a one-way transition from supervisor to user mode.
*
* @see arch_user_mode_enter
*/
void xtensa_userspace_enter(k_thread_entry_t user_entry,
void *p1, void *p2, void *p3,
uintptr_t stack_end,
uintptr_t stack_start);
/**
* @}
*/
#endif /* ZEPHYR_ARCH_XTENSA_INCLUDE_XTENSA_INTERNAL_H_ */

View file

@ -18,11 +18,11 @@
#if CONFIG_USERSPACE
#define Z_XTENSA_STACK_BASE_ALIGN CONFIG_MMU_PAGE_SIZE
#define Z_XTENSA_STACK_SIZE_ALIGN CONFIG_MMU_PAGE_SIZE
#define XTENSA_STACK_BASE_ALIGN CONFIG_MMU_PAGE_SIZE
#define XTENSA_STACK_SIZE_ALIGN CONFIG_MMU_PAGE_SIZE
#else
#define Z_XTENSA_STACK_BASE_ALIGN ARCH_STACK_PTR_ALIGN
#define Z_XTENSA_STACK_SIZE_ALIGN ARCH_STACK_PTR_ALIGN
#define XTENSA_STACK_BASE_ALIGN ARCH_STACK_PTR_ALIGN
#define XTENSA_STACK_SIZE_ALIGN ARCH_STACK_PTR_ALIGN
#endif
/*
@ -46,17 +46,17 @@
/* thread stack */
#ifdef CONFIG_XTENSA_MMU
struct z_xtensa_thread_stack_header {
struct xtensa_thread_stack_header {
char privilege_stack[CONFIG_MMU_PAGE_SIZE];
} __packed __aligned(Z_XTENSA_STACK_BASE_ALIGN);
} __packed __aligned(XTENSA_STACK_BASE_ALIGN);
#define ARCH_THREAD_STACK_RESERVED \
sizeof(struct z_xtensa_thread_stack_header)
sizeof(struct xtensa_thread_stack_header)
#endif /* CONFIG_XTENSA_MMU */
#define ARCH_THREAD_STACK_OBJ_ALIGN(size) Z_XTENSA_STACK_BASE_ALIGN
#define ARCH_THREAD_STACK_OBJ_ALIGN(size) XTENSA_STACK_BASE_ALIGN
#define ARCH_THREAD_STACK_SIZE_ADJUST(size) \
ROUND_UP((size), Z_XTENSA_STACK_SIZE_ALIGN)
ROUND_UP((size), XTENSA_STACK_SIZE_ALIGN)
/* kernel stack */
#define ARCH_KERNEL_STACK_RESERVED 0

View file

@ -76,7 +76,7 @@ def get_gdb_reg_definition(soc, toolchain):
class ExceptionCodes(Enum):
# Matches arch/xtensa/core/fatal.c->z_xtensa_exccause
# Matches arch/xtensa/core/fatal.c->xtensa_exccause
ILLEGAL_INSTRUCTION = 0
# Syscall not fatal
INSTR_FETCH_ERROR = 2

View file

@ -323,8 +323,8 @@ SECTIONS
*libarch__xtensa__core.a:debug_helpers_asm.S.obj(.iram1.literal .iram1)
/* Userspace related stuff */
LIB_OBJ_FUNC_IN_SECT(libarch__xtensa__core.a,userspace.S.obj,z_xtensa_do_syscall)
LIB_OBJ_FUNC_IN_SECT(libarch__xtensa__core.a,ptables.c.obj,z_xtensa_swap_update_page_tables)
LIB_OBJ_FUNC_IN_SECT(libarch__xtensa__core.a,userspace.S.obj,xtensa_do_syscall)
LIB_OBJ_FUNC_IN_SECT(libarch__xtensa__core.a,ptables.c.obj,xtensa_swap_update_page_tables)
/* Below are to speed up execution by avoiding TLB misses
* on frequently used functions.