Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
arch.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019-2020 Cobham Gaisler AB
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
15
16#ifndef ZEPHYR_INCLUDE_ARCH_SPARC_ARCH_H_
17#define ZEPHYR_INCLUDE_ARCH_SPARC_ARCH_H_
18
25
26#include <zephyr/irq.h>
27#include <zephyr/sw_isr_table.h>
28#include <soc.h>
29#include <zephyr/devicetree.h>
30
31/* stacks, for SPARC architecture stack shall be 8byte-aligned */
32#define ARCH_STACK_PTR_ALIGN 8
33
34/*
35 * Software trap numbers.
36 * Assembly usage: "ta SPARC_SW_TRAP_<TYPE>"
37 */
38#define SPARC_SW_TRAP_FLUSH_WINDOWS 0x03
39#define SPARC_SW_TRAP_SET_PIL 0x09
40#define SPARC_SW_TRAP_EXCEPT 0x0F
41
42#ifndef _ASMLANGUAGE
43#include <zephyr/sys/util.h>
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
49#define STACK_ROUND_UP(x) ROUND_UP(x, ARCH_STACK_PTR_ALIGN)
50
51/*
52 * SOC specific function to translate from processor interrupt request level
53 * (1..15) to logical interrupt source number. For example by probing the
54 * interrupt controller.
55 */
56void z_irq_spurious(const void *unused);
57
58
59#define ARCH_IRQ_CONNECT(irq_p, priority_p, isr_p, isr_param_p, flags_p) \
60 { \
61 Z_ISR_DECLARE(irq_p, 0, isr_p, isr_param_p); \
62 }
63
64
65static ALWAYS_INLINE unsigned int z_sparc_set_pil_inline(unsigned int newpil)
66{
67 register uint32_t oldpil __asm__ ("o0") = newpil;
68
69 __asm__ volatile (
70 "ta %1\nnop\n" :
71 "=r" (oldpil) :
72 "i" (SPARC_SW_TRAP_SET_PIL), "r" (oldpil) :
73 "memory"
74 );
75 return oldpil;
76}
77
78static ALWAYS_INLINE unsigned int arch_irq_lock(void)
79{
80 return z_sparc_set_pil_inline(15);
81}
82
83static ALWAYS_INLINE void arch_irq_unlock(unsigned int key)
84{
85 z_sparc_set_pil_inline(key);
86}
87
88static ALWAYS_INLINE bool arch_irq_unlocked(unsigned int key)
89{
90 return key == 0;
91}
92
95{
96 /* No direct non-modifying probe available; briefly lock and
97 * restore via the existing PIL trap interface.
98 */
99 unsigned int key = arch_irq_lock();
100 bool enabled = arch_irq_unlocked(key);
101
102 arch_irq_unlock(key);
103 return enabled;
104}
105
106static ALWAYS_INLINE void arch_nop(void)
107{
108 __asm__ volatile ("nop");
109}
110
112
113static inline uint32_t arch_k_cycle_get_32(void)
114{
115 return sys_clock_cycle_get_32();
116}
117
119
120static inline uint64_t arch_k_cycle_get_64(void)
121{
122 return sys_clock_cycle_get_64();
123}
124
125#define ARCH_EXCEPT(reason_p) \
126do { \
127 register uint32_t _g1 __asm__("g1") = reason_p; \
128 \
129 __asm__ volatile ( \
130 "ta %[vector]\n\t" \
131 : \
132 : [vector] "i" (SPARC_SW_TRAP_EXCEPT), "r" (_g1) \
133 : "memory" \
134 ); \
135 CODE_UNREACHABLE; \
136} while (false)
137
138#ifdef __cplusplus
139}
140#endif
141
142#endif /*_ASMLANGUAGE */
143
144#endif /* ZEPHYR_INCLUDE_ARCH_SPARC_ARCH_H_ */
static ALWAYS_INLINE void arch_nop(void)
Definition arch.h:351
Per-arch thread definition.
Devicetree main header.
#define ALWAYS_INLINE
Definition common.h:180
Public interface for configuring interrupts.
static ALWAYS_INLINE unsigned int arch_irq_lock(void)
Definition arch.h:72
static ALWAYS_INLINE void arch_irq_unlock(unsigned int key)
Definition arch.h:83
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:114
static ALWAYS_INLINE bool arch_cpu_irqs_are_enabled(void)
Implementation of arch_cpu_irqs_are_enabled.
Definition arch.h:102
static uint64_t arch_k_cycle_get_64(void)
Definition arch.h:121
static ALWAYS_INLINE bool arch_irq_unlocked(unsigned int key)
Definition arch.h:96
#define SPARC_SW_TRAP_SET_PIL
Definition arch.h:39
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT64_TYPE__ uint64_t
Definition stdint.h:91
Software-managed ISR table.
Misc utilities.