13#ifndef ZEPHYR_INCLUDE_ARCH_XTENSA_ARCH_H_
14#define ZEPHYR_INCLUDE_ARCH_XTENSA_ARCH_H_
19#if !defined(_ASMLANGUAGE) && !defined(__ASSEMBLER__)
28#include <xtensa/config/core.h>
35#ifdef CONFIG_KERNEL_COHERENCE
36#define ARCH_STACK_PTR_ALIGN XCHAL_DCACHE_LINESIZE
38#define ARCH_STACK_PTR_ALIGN 16
42#define sys_define_gpr_with_alias(name1, name2) union { uint32_t name1, name2; }
52#define ARCH_EXCEPT(reason_p) do { \
53 xtensa_arch_except(reason_p); \
60#define ARCH_IRQ_CONNECT(irq_p, priority_p, isr_p, isr_param_p, flags_p) \
62 Z_ISR_DECLARE(irq_p, flags_p, isr_p, isr_param_p); \
65#define XTENSA_ERR_NORET
83 __asm__
volatile(
"nop");
90 __asm__
volatile(
"rsr.vecbase %0" :
"=r" (vecbase));
96 __asm__
volatile(
"wsr.vecbase %0; rsync" : :
"r" (vecbase | 1));
99#if defined(CONFIG_XTENSA_RPO_CACHE)
100#if defined(CONFIG_ARCH_HAS_COHERENCE)
103 size_t addr = (
size_t) ptr;
105 return (addr >> 29) == CONFIG_XTENSA_UNCACHED_REGION;
109static inline bool arch_xtensa_is_ptr_cached(
void *ptr)
111 size_t addr = (
size_t) ptr;
113 return (addr >> 29) == CONFIG_XTENSA_CACHED_REGION;
116static inline bool arch_xtensa_is_ptr_uncached(
void *ptr)
118 size_t addr = (
size_t) ptr;
120 return (addr >> 29) == CONFIG_XTENSA_UNCACHED_REGION;
130 uint32_t rxor = (rto ^ rfrom) << 29;
133 if (Z_IS_POW2(rxor)) {
134 if ((rxor & rto) == 0) {
140 return (addr & ~(7U << 29)) | rto;
163static inline void __sparse_cache *arch_xtensa_cached_ptr(
void *ptr)
165 return (__sparse_force
void __sparse_cache *)z_xtrpoflip((
uint32_t) ptr,
166 CONFIG_XTENSA_CACHED_REGION,
167 CONFIG_XTENSA_UNCACHED_REGION);
188static inline void *arch_xtensa_uncached_ptr(
void __sparse_cache *ptr)
190 return (
void *)z_xtrpoflip((__sparse_force
uint32_t)ptr,
191 CONFIG_XTENSA_UNCACHED_REGION,
192 CONFIG_XTENSA_CACHED_REGION);
218#define _REGION_ATTR(r) \
220 ((r) == CONFIG_XTENSA_CACHED_REGION ? 4 : \
221 ((r) == CONFIG_XTENSA_UNCACHED_REGION ? 2 : 15)))
223#define _SET_ONE_TLB(region) do { \
224 uint32_t attr = _REGION_ATTR(region); \
225 if (XCHAL_HAVE_XLT_CACHEATTR) { \
228 if (region != CONFIG_XTENSA_CACHED_REGION) { \
229 __asm__ volatile("wdtlb %0, %1; witlb %0, %1" \
230 :: "r"(attr), "r"(addr)); \
232 __asm__ volatile("wdtlb %0, %1" \
233 :: "r"(attr), "r"(addr)); \
234 __asm__ volatile("j 1f; .align 8; 1:"); \
235 __asm__ volatile("witlb %0, %1; isync" \
236 :: "r"(attr), "r"(addr)); \
241#define ARCH_XTENSA_SET_RPO_TLB() do { \
242 register uint32_t addr = 0, addrincr = 0x20000000; \
243 FOR_EACH(_SET_ONE_TLB, (;), 0, 1, 2, 3, 4, 5, 6, 7); \
248#ifdef CONFIG_XTENSA_MMU
249extern void arch_xtensa_mmu_post_init(
bool is_core0);
static ALWAYS_INLINE void arch_nop(void)
Definition: arch.h:348
#define ALWAYS_INLINE
Definition: common.h:129
static bool arch_mem_coherent(void *ptr)
Detect memory coherence type.
Definition: arch_interface.h:866
Public interface for configuring interrupts.
uint64_t sys_clock_cycle_get_64(void)
uint32_t sys_clock_cycle_get_32(void)
static uint32_t arch_k_cycle_get_32(void)
Definition: arch.h:99
static uint64_t arch_k_cycle_get_64(void)
Definition: arch.h:106
flags
Definition: parser.h:96
Size of off_t must be equal or less than size of size_t
Definition: retained_mem.h:28
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__UINT64_TYPE__ uint64_t
Definition: stdint.h:91
Software-managed ISR table.
void xtensa_arch_except(int reason_p)
static ALWAYS_INLINE void xtensa_vecbase_lock(void)
Definition: arch.h:86
Xtensa public exception handling.