Zephyr API Documentation 4.3.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
arch.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016 Cadence Design Systems, Inc.
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
14
15#ifndef ZEPHYR_INCLUDE_ARCH_XTENSA_ARCH_H_
16#define ZEPHYR_INCLUDE_ARCH_XTENSA_ARCH_H_
17
18#include <zephyr/irq.h>
19
20#include <zephyr/devicetree.h>
21#if !defined(_ASMLANGUAGE) && !defined(__ASSEMBLER__)
22#include <zephyr/types.h>
23#include <zephyr/toolchain.h>
27#include <zephyr/sw_isr_table.h>
31#include <xtensa/config/core.h>
34#include <zephyr/debug/sparse.h>
36#include <zephyr/sys/slist.h>
37
39
40#ifdef CONFIG_XTENSA_MMU
42#endif
43
44#ifdef CONFIG_XTENSA_MPU
46#endif
47
59
61
62#ifdef __cplusplus
63extern "C" {
64#endif
65
66struct arch_mem_domain {
67#ifdef CONFIG_XTENSA_MMU
69 uint8_t asid;
70 bool dirty;
71
72 /* Following are used to program registers when changing page tables. */
73 uint32_t reg_asid;
74 uint32_t reg_ptevaddr;
75 uint32_t reg_ptepin_as;
76 uint32_t reg_ptepin_at;
77 uint32_t reg_vecpin_as;
78 uint32_t reg_vecpin_at;
79#endif
80#ifdef CONFIG_XTENSA_MPU
81 struct xtensa_mpu_map mpu_map;
82#endif
84};
85
87
95void xtensa_arch_except(int reason_p);
96
105void xtensa_arch_kernel_oops(int reason_p, void *ssf);
106
107#ifdef CONFIG_USERSPACE
108
109#define ARCH_EXCEPT(reason_p) do { \
110 if (k_is_user_context()) { \
111 arch_syscall_invoke1(reason_p, \
112 K_SYSCALL_XTENSA_USER_FAULT); \
113 } else { \
114 compiler_barrier(); \
115 xtensa_arch_except(reason_p); \
116 } \
117 CODE_UNREACHABLE; \
118} while (false)
119
120#else
121
122#define ARCH_EXCEPT(reason_p) do { \
123 xtensa_arch_except(reason_p); \
124 CODE_UNREACHABLE; \
125 } while (false)
126
127#endif
128
129__syscall void xtensa_user_fault(unsigned int reason);
130
131#include <zephyr/syscalls/arch.h>
132
133/* internal routine documented in C file, needed by IRQ_CONNECT() macro */
134void z_irq_priority_set(uint32_t irq, uint32_t prio, uint32_t flags);
135
136#define ARCH_IRQ_CONNECT(irq_p, priority_p, isr_p, isr_param_p, flags_p) \
137 { \
138 Z_ISR_DECLARE(irq_p, flags_p, isr_p, isr_param_p); \
139 }
140
142static inline uint32_t arch_k_cycle_get_32(void)
143{
144 return sys_clock_cycle_get_32();
145}
146
148static inline uint64_t arch_k_cycle_get_64(void)
149{
150 return sys_clock_cycle_get_64();
151}
152
154static ALWAYS_INLINE void arch_nop(void)
155{
156 __asm__ volatile("nop");
157}
158
168{
169 int vecbase;
170
171 __asm__ volatile("rsr.vecbase %0" : "=r" (vecbase));
172 __asm__ volatile("wsr.vecbase %0; rsync" : : "r" (vecbase | 1));
173}
174
175#if defined(CONFIG_XTENSA_MMU) || defined(__DOXYGEN__)
186void arch_xtensa_mmu_post_init(bool is_core0);
187#endif
188
189#ifdef __cplusplus
190}
191#endif
192
193#endif /* !defined(_ASMLANGUAGE) && !defined(__ASSEMBLER__) */
194
195#endif /* ZEPHYR_INCLUDE_ARCH_XTENSA_ARCH_H_ */
Xtensa specific syscall header.
Devicetree main header.
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:39
#define ALWAYS_INLINE
Definition common.h:160
Public interface for configuring interrupts.
flags
Definition parser.h:97
static ALWAYS_INLINE void arch_nop(void)
Definition arch.h:56
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:44
static uint64_t arch_k_cycle_get_64(void)
Definition arch.h:51
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT64_TYPE__ uint64_t
Definition stdint.h:91
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
Definition arch.h:46
sys_snode_t node
Definition arch.h:50
pentry_t * ptables
Definition mmustructs.h:89
Software-managed ISR table.
Timer driver API.
Macros to abstract toolchain specific capabilities.
void xtensa_user_fault(unsigned int reason)
void xtensa_arch_kernel_oops(int reason_p, void *ssf)
Generate kernel oops.
void xtensa_arch_except(int reason_p)
Generate hardware exception.
void arch_xtensa_mmu_post_init(bool is_core0)
Perform additional steps after MMU initialization.
struct arch_mem_domain arch_mem_domain_t
Definition arch.h:86
static ALWAYS_INLINE void xtensa_vecbase_lock(void)
Lock VECBASE if supported by hardware.
Definition arch.h:167